a.binder 8 лет назад
Родитель
Сommit
f3009e38d7
1 измененных файлов с 23 добавлено и 7 удалено
  1. 23 7
      SE/dev/audit_krs_con_digger/audit_krs_con_digger.php

+ 23 - 7
SE/dev/audit_krs_con_digger/audit_krs_con_digger.php

@@ -48,8 +48,8 @@ $tables['X']['BI_audit_ENERGA_RUM_KONTRAHENCI']['rel']['teryt']=1;
 
 $tables['Z']['BI_audit_CEIDG']['rel']['nip']='nip';
 $tables['Z']['BI_audit_CEIDG']['rel']['regon']='regon';
-$tables['Z']['BI_audit_CEIDG']['ref'][]='BI_audit_CEIDG_pelnomocnicy';
-$tables['Z']['BI_audit_CEIDG']['ref'][]='BI_audit_CEIDG_powiazania';
+$tables['Z']['BI_audit_CEIDG']['ref'][19]='BI_audit_CEIDG_pelnomocnicy';
+$tables['Z']['BI_audit_CEIDG']['ref'][18]='BI_audit_CEIDG_powiazania';
 
 $tables['Z']['BI_audit_CEIDG_pelnomocnicy']['rel']['nip']='nip';
 $tables['Z']['BI_audit_CEIDG_pelnomocnicy']['rel_and']['adres']['miejscowosc']='miejscowosc';
@@ -69,8 +69,8 @@ $tables['Z']['BI_audit_KRS']['rel']['krs']='krs';
 $tables['Z']['BI_audit_KRS']['rel_and']['adres']['miejscowosc']='A_miejscowosc';
 $tables['Z']['BI_audit_KRS']['rel_and']['adres']['ulica']='A_ulica';
 $tables['Z']['BI_audit_KRS']['rel_and']['adres']['kodPocztowy']='A_kod';
-$tables['Z']['BI_audit_KRS']['ref'][]='BI_audit_KRS_person';
-$tables['Z']['BI_audit_KRS']['ref'][]='BI_audit_KRS_company';
+$tables['Z']['BI_audit_KRS']['ref'][12]='BI_audit_KRS_person';
+$tables['Z']['BI_audit_KRS']['ref'][11]='BI_audit_KRS_company';
 
 
 
@@ -87,7 +87,7 @@ $tables['Z']['BI_audit_KRS_company']['rel']['krs']='krs';
 function start_dig($tables) {
 	global $db;
 	foreach($tables['Y'] as $Y=>$t)  {
-		$sql='select * from '.$Y ;
+		$sql='select * from '.$Y.'  limit 1' ;
 		$res=$db->query($sql);
 		 while($h=$db->fetch($res)) {
 			 $hist_loop[$Y][]=$h;
@@ -147,8 +147,24 @@ function dig_next($hist_loop,$prev_tbl,$prev_dig,$loop) {
 			  $res=$db->query($sql_ext);
 			  while($h=$db->fetch($res)) {
 				  echo "\n<br> found "; print_r($h);
-				 $hist_loop[$Y][]=$h;
-				 dig_next($hist_loop,$t,$h,$loop);
+				 $hist_loop[$tables['Z'][$T]][]=$h;
+				 
+				 print_r($hist_loop);
+				 
+				 dig_next($hist_loop, $tables['Z'][$T],$h,$loop);
+				 //rel dzieci
+				 foreach($tables[$T]['ref'] as $ref_id => $ref_table) {
+					 $sql_ref=" select REMOTE_PRIMARY_KEY from `CRM__#REF_TABLE__".$ref_id."` where `PRIMARY_KEY`=".$h->ID." ";
+					 $res_rel=$db->query($sql_ref);
+					 while($h_rel=$db->fetch($res_rel)){
+						 $sql_rel_rec="select * from `".$ref_table."` where ID=".$h_rel->REMOTE_PRIMARY_KEY." ";
+						 $res_rel_rec=$db->query($sql_rel_rec);
+						 echo "<br>#159 ref tbl ".$sql_rel_rec;
+						 while($h_rel_rec=$db->fetch($res_rel_rec)){
+							 dig_next($hist_loop,$tables['Z'][$ref_table],$h_rel_rec,$loop);
+						 }
+					 }
+				 }
 			 }
 		  }
 	  }