Преглед изворни кода

fixed replace ID_ZASOB in param out link in SQIX_STRUCTURE_DB_SYNC

Piotr Labudda пре 10 година
родитељ
комит
4413b176d3
1 измењених фајлова са 15 додато и 27 уклоњено
  1. 15 27
      SE/superedit-SQIX_STRUCTURE_DB_SYNC.php

+ 15 - 27
SE/superedit-SQIX_STRUCTURE_DB_SYNC.php

@@ -704,39 +704,27 @@ $CONNLOCAL->query('set global max_allowed_packet=1000000000');
 		$sql="select `ID`,`DESC` from CRM_LISTA_ZASOBOW where `TYPE`='PARAM_OUT' and SYNC_SQIX_STATUS not like '%FIX_ZASOB%' and SYNC_SQIX_STATUS not like '' ";
 		$result=$CONNREMOTE->query($sql) or DEBUG_S(-3,'Problem ze sql ',$sql,__FILE__, __FUNCTION__, __LINE__) or die1(''); 
 			while($h=mysql_fetch_object($result)) {
-						if(strstr($h->DESC, '&ZASOB_ID=')) {
-							
-							$zas_id_param_out_repl=explode('&ZASOB_ID=', $h->DESC);
-							$zas_id_param_out_repl=explode('#', $zas_id_param_out_repl[1]);
-							$id_zas_oryg_h_DESC=$h->DESC; //oryginalna wartosc opisu
-							
-							
-							$zas_id_param_out_repl_2=explode('&ZASOB_ID=', $h->DESC);
-							$zas_id_param_out_repl_2=explode('&', $zas_id_param_out_repl_2[1]);
-							
-							$sql_to_find_parent="select DST_TABLE_ID from CRM_IMPORT_TRANSLATE where REM_TABLE='CRM_LISTA_ZASOBOW' and SRC_TABLE_ID='".$zas_id_param_out_repl[0]."' ;" ;
+
+				if (false !== strpos($h->DESC, 'VIEWTABLE_AJAX')) {
+					$id_zas_oryg_h_DESC = $h->DESC;// oryginalna wartosc opisu
+					$matches = array();
+					if (preg_match('/&ZASOB_ID=([0-9]+)/', $h->DESC, $matches)) {
+						if (count($matches) >= 2) {
+							$paramOutLinkZasobId = $matches[1];
+							$sql_to_find_parent="select DST_TABLE_ID from CRM_IMPORT_TRANSLATE where REM_TABLE='CRM_LISTA_ZASOBOW' and SRC_TABLE_ID='{$paramOutLinkZasobId}' ;" ;
 							$res_to_find_parent_param=$CONNREMOTE->query($sql_to_find_parent) or DEBUG_S(-3,'Problem ze sql ',$sql_to_find_parent,__FILE__, __FUNCTION__, __LINE__) or die1(''); 
-							//proba 1 dla warunku ID_ZASOB=xxx#
-							while($h_res_to_find_TS=mysql_fetch_object($res_to_find_parent_param)) {
-								$h->DESC=preg_replace('/&ZASOB_ID='.$zas_id_param_out_repl[0].'#/', '&ZASOB_ID='.$h_res_to_find_TS->DST_TABLE_ID.'#', $id_zas_oryg_h_DESC);
+							if($h_res_to_find_TS=mysql_fetch_object($res_to_find_parent_param)) {
+								$newLinkZasobId = $h_res_to_find_TS->DST_TABLE_ID;
+								$h->DESC = preg_replace('/&ZASOB_ID='.$paramOutLinkZasobId.'/', '&ZASOB_ID='.$newLinkZasobId, $id_zas_oryg_h_DESC);
 								if(strlen($h->DESC)>0) { $sql_upd="update CRM_LISTA_ZASOBOW set `DESC`='".$CONNREMOTE->_($h->DESC)."' where ID=".$h->ID." ; ";
 								$CONNREMOTE->query($sql_upd) or die('Error with upd TYPESPECIAL PARAM_OUT line: 709 ');
 								DEBUG_S(-3,'Nadpisuje TYPESPECIAL PARAM_OUT, ktory ma uzyty URL z ID_ZASOB',$sql_upd,__FILE__,__FUNCTION__,__LINE__);	
-								}							
+								}
 							}
-							//proba 2 dla warunku ID_ZASOB=xxx&
-							$res_to_find_parent_param=$CONNREMOTE->query($sql_to_find_parent) or DEBUG_S(-3,'Problem ze sql ',$sql_to_find_parent,__FILE__, __FUNCTION__, __LINE__) or die1(''); 
-							//proba 1 dla warunku ID_ZASOB=xxx#
-							while($h_res_to_find_TS=mysql_fetch_object($res_to_find_parent_param)) {
-								$h->DESC=preg_replace('/&ZASOB_ID='.$zas_id_param_out_repl_2[0].'&/', '&ZASOB_ID='.$h_res_to_find_TS->DST_TABLE_ID.'&', $id_zas_oryg_h_DESC);
-								if(strlen($h->DESC)>0) { $sql_upd="update CRM_LISTA_ZASOBOW set `DESC`='".$CONNREMOTE->_($h->DESC)."' where ID=".$h->ID." ; ";
-								$CONNREMOTE->query($sql_upd) or die('Error with upd TYPESPECIAL PARAM_OUT line: 709 ');
-								DEBUG_S(-3,'Nadpisuje TYPESPECIAL PARAM_OUT, ktory ma uzyty URL z ID_ZASOB',$sql_upd,__FILE__,__FUNCTION__,__LINE__);
-								}								
-							}							
-							
 						}
-					
+					}
+				}
+
 			}
 
 		// ! aktualizujemy numery P_ID powiazanych tabel po tabeli translate dla IMPORTow z wyjatkiem celowo nadpisanych P_ID