Jelajahi Sumber

FixCrmProcesInitIdx: add proces to table cell with perms view

Piotr Labudda 10 tahun lalu
induk
melakukan
b148fb1595
1 mengubah file dengan 25 tambahan dan 22 penghapusan
  1. 25 22
      SE/se-lib/Route/FixCrmProcesInitIdx.php

+ 25 - 22
SE/se-lib/Route/FixCrmProcesInitIdx.php

@@ -492,28 +492,31 @@ SQL;
 				where z.`TYPE`='KOMORKA'
 				where z.`TYPE`='KOMORKA'
 					and z.`A_STATUS` in('WAITING','NORMAL')
 					and z.`A_STATUS` in('WAITING','NORMAL')
 SQL;
 SQL;
-		/* Usage - find tables for user by $userLogin:
-				SELECT up.*, tp.*
-				FROM  `CRM_PROCES_idx_USER_to_PROCES_VIEW` up
-					join `CRM_PROCES_idx_TABLE_TO_PROCES_VIEW` tp on(tp.`ID_PROCES`=up.`ID_PROCES`)
-				WHERE  `ADM_ACCOUNT` LIKE  '{$userLogin}'
-
-		-- id steps for table 'TEST_PERMS'
-				select tpv.`ID_PROCES`
-					from `CRM_PROCES_idx_TABLE_TO_PROCES_VIEW` tpv
-					where tpv.`TABLE_NAME`='TEST_PERMS'
-					group by tpv.`ID_PROCES`
-		-- id steps for user 'plabudda' for table 'TEST_PERMS'
-			select upv.*
-			from
-				(select tpv.`ID_PROCES`
-					from `CRM_PROCES_idx_TABLE_TO_PROCES_VIEW` tpv
-					where tpv.`TABLE_NAME`='TEST_PERMS'
-					group by tpv.`ID_PROCES`) as tpvg
-			--	join `CRM_PROCES_idx_GROUP_to_PROCES` igp on(.`ID_PROCES`=tpvg.`ID_PROCES`)
-				join `CRM_PROCES_idx_USER_to_PROCES_VIEW` upv on(upv.`ID_PROCES`=tpvg.`ID_PROCES`)
-			where upv.`ADM_ACCOUNT`='plabudda'
-		*/
+		$sqlList['RemoveViewTableCellToProcesWithPerms'] = "DROP VIEW IF EXISTS `CRM_PROCES_idx_TABLE_TO_PROCES_PERMS_VIEW`";
+		$sqlList['InstallViewTableCellToProcesWithPerms'] = <<<SQL
+			CREATE VIEW `CRM_PROCES_idx_TABLE_TO_PROCES_PERMS_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`
+					, replace(przyp.`FORM_TREAT`, ',', '') as FORM_TREAT
+					, IF(przyp.`FORM_TREAT` & 2,   1, 0) as PERM_R
+					, IF(przyp.`FORM_TREAT` & 4,   1, 0) as PERM_W
+					, IF(przyp.`FORM_TREAT` & 8,   1, 0) as PERM_X
+					, IF(przyp.`FORM_TREAT` & 16,  1, 0) as PERM_C
+					, IF(przyp.`FORM_TREAT` & 32,  1, 0) as PERM_S
+					, IF(przyp.`FORM_TREAT` & 64,  1, 0) as PERM_O
+					, IF(przyp.`FORM_TREAT` & 128, 1, 0) as PERM_V
+					, IF(przyp.`FORM_TREAT` & 256, 1, 0) as PERM_E
+				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` and wsk.`A_STATUS` in('WAITING','NORMAL'))
+					join `CRM_PROCES` p on(p.`ID`=wsk.`ID_PROCES` and p.`A_STATUS` in('WAITING','NORMAL'))
+					join `CRM_PRZYPADEK` as przyp on (przyp.`ID`=wsk.`ID_PRZYPADEK`)
+				where z.`TYPE`='KOMORKA'
+					and z.`A_STATUS` in('WAITING','NORMAL')
+SQL;
 		$sqlList_BUG = <<<SQL
 		$sqlList_BUG = <<<SQL
 			-- BUG  #1349 - View's SELECT contains a subquery in the FROM clause
 			-- BUG  #1349 - View's SELECT contains a subquery in the FROM clause
 			CREATE VIEW `CRM_PROCES_idx_TABLE_TO_USER_VIEW` AS
 			CREATE VIEW `CRM_PROCES_idx_TABLE_TO_USER_VIEW` AS