Piotr Labudda 10 лет назад
Родитель
Сommit
0d1e6d94b1
2 измененных файлов с 48 добавлено и 15 удалено
  1. 47 14
      SE/se-lib/Route/UrlAction.php
  2. 1 1
      SE/se-lib/TableAjax.php

+ 47 - 14
SE/se-lib/Route/UrlAction.php

@@ -79,19 +79,18 @@ class Route_UrlAction extends RouteBase {// TODO: UrlActionBase
 		}
 	}
 
-	public static function getTableFunctions($idTbl, $idRecord, $tblName = '') {
-		$pdo = DB::getPDO();
-		/*
-			636  TABELA IN7_MK_BAZA_DYSTRYBUCJI Projekty
-				763  KOMORKA ID Nr
-				22332 22317 URL_ACTION ProjektyKosztyWstepnychRobot
-					22335 763 PARAM_IN ID_PROJECT
-
-			25  TYPESPECIALS TYPESPECIALS Powiązania tabel
-				22317  URL_ACTION ProjektyKosztyWstepnychRobot
-					22324  PARAM_IN ID_PROJECT
-		 */
-		$sth = $pdo->prepare("
+	/*
+		636  TABELA IN7_MK_BAZA_DYSTRYBUCJI Projekty
+			763  KOMORKA ID Nr
+			22332 22317 URL_ACTION ProjektyKosztyWstepnychRobot
+				22335 763 PARAM_IN ID_PROJECT
+
+		25  TYPESPECIALS TYPESPECIALS Powiązania tabel
+			22317  URL_ACTION ProjektyKosztyWstepnychRobot
+				22324  PARAM_IN ID_PROJECT
+	 */
+	public static function fetchTableFunctions($idTbl, $idRecord) {
+		$sth = DB::getPDO()->prepare("
 			select z.ID as ID
 				, z.`DESC_PL` as fun_label
 				, za.`DESC` as fun_name
@@ -106,7 +105,41 @@ class Route_UrlAction extends RouteBase {// TODO: UrlActionBase
 		");
 		$sth->bindValue(':id_zasob', $idTbl, PDO::PARAM_STR);
 		$sth->execute();
-		$rows = $sth->fetchAll();
+		return $sth->fetchAll();
+	}
+
+	public static function fetchTableFunctionsForUser($idTbl, $idRecord, $usrLogin) {
+		$sth = DB::getPDO()->prepare("
+			select z.ID as ID
+				, z.`DESC_PL` as fun_label
+				, za.`DESC` as fun_name
+				, zp.ALIAS_ID as param_in_to_cell_id
+				, zp.DESC as param_in_name
+			from CRM_LISTA_ZASOBOW z
+				join CRM_LISTA_ZASOBOW za on(za.ID = z.ALIAS_ID)
+				left join CRM_LISTA_ZASOBOW zp on(zp.PARENT_ID = z.ID and zp.`TYPE` = 'PARAM_IN')
+				left join CRM_LISTA_ZASOBOW zpa on(zpa.ID = zp.ALIAS_ID and zpa.`TYPE` = 'PARAM_IN' and zpa.`DESC` = zp.`DESC`)
+				join CRM_WSKAZNIK w on(w.ID_ZASOB = z.ID)
+--				join CRM_PROCES p on(p.ID = w.ID_PROCES)
+				join CRM_PROCES_idx_USER_to_PROCES_VIEW upv on(upv.ID_PROCES = w.ID_PROCES)
+			where z.PARENT_ID = :id_zasob
+				and z.`TYPE` = 'URL_ACTION'
+				and upv.ADM_ACCOUNT = :usr_login
+			group by z.ID
+		");
+		$sth->bindValue(':id_zasob', $idTbl, PDO::PARAM_STR);
+		$sth->bindValue(':usr_login', $usrLogin, PDO::PARAM_STR);
+		$sth->execute();
+		return $sth->fetchAll();
+	}
+
+	public static function getTableFunctions($idTbl, $idRecord, $tblName = '', $usrLogin = null) {
+		$rows = array();
+		if (!empty($usrLogin)) {
+			$rows = self::fetchTableFunctionsForUser($idTbl, $idRecord, $usrLogin);
+		} else {
+			$rows = self::fetchTableFunctions($idTbl, $idRecord);
+		}
 		$functions = array();
 		foreach ($rows as $row) {
 			if (!array_key_exists($row['ID'], $functions)) {

+ 1 - 1
SE/se-lib/TableAjax.php

@@ -6266,7 +6266,7 @@ jQuery(document).ready(function(){
 		}
 
 		$acl = $this->_acl;
-		if ($urlFunctions = Route_UrlAction::getTableFunctions($acl->getID(), $id, $acl->getName())) {
+		if ($urlFunctions = Route_UrlAction::getTableFunctions($acl->getID(), $id, $acl->getName(), User::getLogin())) {
 			foreach ($urlFunctions as $urlFunction) {
 				$rowFunction = array();
 				$rowFunction['href'] = $urlFunction['baseLink'];