فهرست منبع

FixCrmProcesInitIdx: fix fill idx group to proces, add view table to proces, fix trigger after update status on wskaznik

Piotr Labudda 10 سال پیش
والد
کامیت
285114292a
1فایلهای تغییر یافته به همراه29 افزوده شده و 4 حذف شده
  1. 29 4
      SE/se-lib/Route/FixCrmProcesInitIdx.php

+ 29 - 4
SE/se-lib/Route/FixCrmProcesInitIdx.php

@@ -157,7 +157,7 @@ SQL;
 					join `CRM_PRZYPADEK` przyp on(przyp.`ID`=wsk.`ID_PRZYPADEK`
 							and przyp.`FORM_TREAT` & 8 -- has perm X
 						)
-				where i.`TYPE` in('PROCES_INIT', 'GOTO_AND_RETURN')
+			--	where i.`TYPE` in('PROCES_INIT', 'GOTO_AND_RETURN')
 SQL;
 		$db = DB::getDB();
 		if ($db->has_errors()) {
@@ -345,7 +345,8 @@ SQL;
 				join `CRM_PRZYPADEK` przyp on(przyp.`ID`=wsk.`ID_PRZYPADEK`
 						and przyp.`FORM_TREAT` & 8 -- has perm X
 					)
-			where i.`TYPE` in('PROCES_INIT', 'GOTO_AND_RETURN');
+		--	where i.`TYPE` in('PROCES_INIT', 'GOTO_AND_RETURN')
+		;
 
 SQL;
 		$sqlList['12-set-end-time-in-config'] = <<<SQL
@@ -417,6 +418,21 @@ SQL;
 				join `CRM_PROCES_idx_GROUP_to_PROCES` gi on(gi.`ID_GROUP`=au.`ID_ZASOB`)
 				join `CRM_PROCES` p on(p.`ID`=gi.`ID_PROCES`)
 			where p.`TYPE`='PROCES_INIT'
+SQL;
+		$sqlList['RemoveViewTableToProces'] = "DROP VIEW IF EXISTS `CRM_PROCES_idx_TABLE_TO_PROCES_VIEW`";
+		$sqlList['InstallViewTableToProces'] = <<<SQL
+			CREATE VIEW `CRM_PROCES_idx_TABLE_TO_PROCES_VIEW` AS
+			select z.`ID` as `ID_CELL`
+					, z.`DESC` as `CELL_NAME`
+					, zp.`ID` as `ID_TABLE`
+					, zp.`DESC` as `TABLE_NAME`
+					, wsk.`ID_PROCES` as `ID_PROCES`
+			--		, z.*, wsk.*
+				from `CRM_LISTA_ZASOBOW` z
+					join `CRM_LISTA_ZASOBOW` zp on(zp.`ID`=z.`PARENT_ID` and zp.`TYPE`='TABELA' and zp.`A_STATUS` in('WAITING','NORMAL'))
+					join `CRM_WSKAZNIK` wsk on(wsk.`ID_ZASOB`=z.`ID`)
+				where z.`TYPE`='KOMORKA'
+					and z.`A_STATUS` in('WAITING','NORMAL')
 SQL;
 		$sqlList['RemoveProcedure'] = "DROP PROCEDURE if exists `update_proces_init_idx_rec`";
 		// throws errors:
@@ -544,7 +560,8 @@ BEGIN
 				join `CRM_PRZYPADEK` przyp on(przyp.`ID`=wsk.`ID_PRZYPADEK`
 						and przyp.`FORM_TREAT` & 8 -- has perm X
 					)
-			where i.`TYPE` in('PROCES_INIT', 'GOTO_AND_RETURN');
+		--	where i.`TYPE` in('PROCES_INIT', 'GOTO_AND_RETURN')
+		;
 
 		replace into `CRM_CONFIG` (`conf_key`, `conf_val`) values (@conf_last_exec_lock_key, ''), (@conf_last_exec_end_key, NOW());
 
@@ -666,7 +683,15 @@ SQL;
 					-- only when old or new ID_PROCES exists in `CRM_PROCES_idx`
 					-- only when old or new ID_ZASOB is group
 					-- only when old or new ID_PRZYPADEK  has perm 'X'
-					IF (NEW.`ID_PROCES`!=OLD.`ID_PROCES` or NEW.`ID_ZASOB`!=OLD.`ID_ZASOB` or NEW.`ID_PRZYPADEK`!=OLD.`ID_PRZYPADEK`)
+					IF (NEW.`ID_PROCES`!=OLD.`ID_PROCES`
+								or NEW.`ID_ZASOB`!=OLD.`ID_ZASOB`
+								or NEW.`ID_PRZYPADEK`!=OLD.`ID_PRZYPADEK`
+								or (NEW.`A_STATUS`!=OLD.`A_STATUS`
+									and ((NEW.`A_STATUS` in('WAITING','NORMAL') and OLD.`A_STATUS` not in('WAITING','NORMAL'))
+										or (NEW.`A_STATUS` not in('WAITING','NORMAL') and OLD.`A_STATUS` in('WAITING','NORMAL'))
+									)
+								)
+							)
 							AND (NEW.`ID_PROCES`>0 or OLD.`ID_PROCES`>0)
 							AND (NEW.`ID_ZASOB`>0 or OLD.`ID_ZASOB`>0)
 							AND (NEW.`ID_PRZYPADEK`>0 or OLD.`ID_PRZYPADEK`>0)