a.binder 8 yıl önce
ebeveyn
işleme
f62aa0c54b

+ 11 - 11
SE/dev/audit_krs_con_digger/audit_krs_con_digger.php

@@ -222,7 +222,7 @@ function sql($hist_loop,$prev_tbl,$prev_dig,$loop,$hist_time,$last_tbl,$path,$ta
 						$and=1;
 					}
 					$sql_rel_and_sql[$T][$z_rel_and_name].="  ) " ;
-					if( isset($hist_loop[$table_class][$T]) and $table_class!='X') {
+					if( isset($hist_loop[$table_class][$T]) ) {
 					 	 foreach($hist_loop[$table_class][$T] as $hist_rec) {
 						 	 $sql_rel_and_sql[$T][$z_rel_and_name].=" and ID!='".$hist_rec->ID."' ";
 					 	 }
@@ -243,7 +243,7 @@ function sql($hist_loop,$prev_tbl,$prev_dig,$loop,$hist_time,$last_tbl,$path,$ta
 					 	 }
 					 	 $sql_t[$T].=$sql_t_str[$T]." ) ";
 					 	 //not loop
-					 	 if( isset($hist_loop[$table_class][$T]) and $table_class!='X'  ) {
+					 	 if( isset($hist_loop[$table_class][$T])  ) {
 						 	 echo "<br> hist loop cnt: ". count($hist_loop[$T]);
 						 	 foreach($hist_loop[$table_class][$T] as $hist_rec) {
 							 	 $sql_t[$T].=" and ID!='".$hist_rec->ID."' ";
@@ -537,19 +537,19 @@ function dig_arr_cur($hist_loop,$T,$sql_ext,$hist_time,$loop,$last_tbl,$path,$ta
 //				 $hist_time[][$T]=$h;
 				  $hist_loop_root_cur['hist_loop']=$hist_loop;
 				  $hist_loop_root_cur['hist_time']=$hist_time;
-				  $hist_loop_root_cur['hist_loop'][$T][]=$h;
+				  $hist_loop_root_cur['hist_loop'][$table_class][$T][]=$h;
 				  $hist_loop_root_cur['hist_time'][]=$sql_ext." ##408 ".$path;
 				  $hist_loop_root_cur['hist_time'][]=$h;
 				// print_r($hist_loop);
 				 $path_root=add_path($path,$T);
 				 dig_next($hist_loop_root_cur['hist_loop'], $tables['Z'][$T],$h,$loop,$hist_loop_root_cur['hist_time'],$last_tbl,$path_root);
 				 //rel dzieci $tables['Z']['BI_audit_CEIDG']['ref'][19]='BI_audit_CEIDG_pelnomocnicy';
-				 if(isset($tables['Z'][$T]['ref'])) {
+				 if(isset($tables[$table_class][$T]['ref'])) {
 				// echo "<br>#296 try to ref tables for T ".$T."<pre>";
 				//  	print_r($tables['Z'][$T]['ref']);
 				// echo "</pre>";
 				 	
-					 foreach($tables['Z'][$T]['ref'] as $ref_id => $ref_table) {
+					 foreach($tables[$table_class][$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) or die('211 blad '.$sql_ref);
 						 echo "<br>#297 ".$sql_ref;
@@ -562,22 +562,22 @@ function dig_arr_cur($hist_loop,$T,$sql_ext,$hist_time,$loop,$last_tbl,$path,$ta
 								 $hist_loop_cur=$hist_loop_root_cur;
 //									 $hist_loop_cur['hist_time']=$hist_time;
 								 //$hist_loop[$ref_table][]=$h_rel_rec;
-								 $hist_loop_cur['hist_loop'][$ref_table][]=$h_rel_rec;
+								 $hist_loop_cur['hist_loop'][$table_class][$ref_table][]=$h_rel_rec;
 //								 $hist_time[][$ref_table]=$sql_rel_rec;
 //								 $hist_time[][$ref_table]=$h_rel_rec;
 								 $hist_loop_cur['hist_time'][]=$sql_rel_rec." #435".$path;
 								 $hist_loop_cur['hist_time'][]=$h_rel_rec;
-								 dig_next($hist_loop_cur['hist_loop'],$tables['Z'][$ref_table],$h_rel_rec,$loop,$hist_loop_cur['hist_time'],$ref_table,add_path($path_root,$ref_table));
+								 dig_next($hist_loop_cur['hist_loop'],$tables[$table_class][$ref_table],$h_rel_rec,$loop,$hist_loop_cur['hist_time'],$ref_table,add_path($path_root,$ref_table));
 							 }
 						 }
 					 }
 				 
 				 } else echo "#322 not ref to ".$T;
-				 if(isset($tables['Z'][$T]['backref'])) {
+				 if(isset($tables[$table_class][$T]['backref'])) {
 				 //echo "<br>#296 try to backref tables  T ".$T."<pre>";
 				 // 	print_r($tables['Z'][$T]['backref']);
 				 //echo "</pre>";
-					 foreach($tables['Z'][$T]['backref'] as $ref_id => $ref_table) {
+					 foreach($tables[$table_class][$T]['backref'] as $ref_id => $ref_table) {
 						 $sql_ref=" select PRIMARY_KEY from `CRM__#REF_TABLE__".$ref_id."` where `REMOTE_PRIMARY_KEY`=".$h->ID." ";
 						 $res_rel=$db->query($sql_ref) or die('318 blad '.$sql_ref);
 						 echo "<br>#319 backref ".$sql_ref;
@@ -590,13 +590,13 @@ function dig_arr_cur($hist_loop,$T,$sql_ext,$hist_time,$loop,$last_tbl,$path,$ta
 								 $hist_loop_cur=$hist_loop_root_cur;
 //  								 $hist_loop_cur['hist_time']=$hist_time;
 						//		 $hist_loop[$ref_table][]=$h_rel_rec;
-								 $hist_loop_cur['hist_loop'][$ref_table][]=$h_rel_rec;
+								 $hist_loop_cur['hist_loop'][$table_class][$ref_table][]=$h_rel_rec;
 
 								 //$hist_time[][$ref_table]=$sql_rel_rec;
 								 //$hist_time[][$ref_table]=$h_rel_rec;
 								 $hist_loop_cur['hist_time'][$ref_table][]=$sql_rel_rec." #464".$path;
 								 $hist_loop_cur['hist_time'][$ref_table][]=$h_rel_rec;
-								 dig_next($hist_loop_cur['hist_loop'],$tables['Z'][$ref_table],$h_rel_rec,$loop,$hist_loop_cur['hist_time'],$ref_table,add_path($path_root,$ref_table));
+								 dig_next($hist_loop_cur['hist_loop'],$tables[$table_class][$ref_table],$h_rel_rec,$loop,$hist_loop_cur['hist_time'],$ref_table,add_path($path_root,$ref_table));
 							 }
 						 }
 					 }