Переглянути джерело

fixed setPermsByProces links

Piotr Labudda 6 роки тому
батько
коміт
0a21df4bc7

+ 7 - 0
SE/index.php

@@ -33,6 +33,13 @@ User::auth();// die if not logged in
 if (!V::get('SKIP_TIMER', '', $_REQUEST)) S::timeoutUpdate(true);// User is authorized - update logout time
 
 $route = V::get('_route', '', $_REQUEST);
+try {
+	$rootPostTask = V::get('_rootPostTask', '', $_REQUEST);
+	if ($rootPostTask) Router::rootPostTask($rootPostTask);
+} catch (Exception $e) {
+	DBG::log($e);
+	S::saveUserMessage(get_class($e), $e->getMessage());
+}
 Router::route($route);
 
 //STD INCLUDE 2010-01-14

+ 6 - 9
SE/se-lib/ProcesMenu.php

@@ -314,6 +314,7 @@ jQuery(document).ready(function() {
 		$outUrls = array();
 		$outMenus = array();// typeName => label (order by label)
 		$typeNameToIdZasob = array();// $typeName => $idZasob
+
 		if ($userAcl->getPermsFiltrProcesId()) { // TODO: fetch menu from ajax - fix menuStore
 			$tbls = $userAcl->getTablesAcl();
 			$urls = $userAcl->getUrls();
@@ -390,16 +391,12 @@ jQuery(document).ready(function() {
 			}
 		}
 
-/*
- * $_SESSION['USER_PROFILE'][section][key] = val;
- */
+		/*
+		* $_SESSION['USER_PROFILE'][section][key] = val;
+		*/
 		$userGroupIdsCSV = User::getGroupsIds();
 		$userGroupIdsCSV = implode(',', $userGroupIdsCSV);
 
-		$typeSpecialUserId = null;
-		if (User::isAdmin()) {
-			$typeSpecialUserId = TypespecialVariable::getInstance(-1, '__USER_ID');
-		}
 		$typeSpecialZasob = TypespecialVariable::getInstance(-1, '__ZASOB');
 
 		$treeZasobyFilter = FilterFactory::build('CRM_LISTA_ZASOBOW');
@@ -473,9 +470,9 @@ jQuery(document).ready(function() {
 			'testy_teoretyczne' => $testy_teoretyczne,
 			'testy_praktyczne' => $testy_praktyczne,
 
-			'typeSpecialUserId' => $typeSpecialUserId,
+			'typeSpecialUserId' => (User::isAdmin()) ? TypespecialVariable::getInstance(-1, '__USER_ID') : null,
 
-			'idFiltrProcesID' => $idFiltrProcesID,
+			'idFiltrProcesID' => $userAcl->getPermsFiltrProcesId(),
 		]);
 	}
 

+ 13 - 0
SE/se-lib/Route/PostTask/SetPermsAll.php

@@ -0,0 +1,13 @@
+<?php
+
+Lib::loadClass('RouteBase');
+
+class Route_PostTask_SetPermsAll extends RouteBase {
+
+	function run() {
+		User::getAcl()->fetchAllPerms(true);
+
+		throw new AlertSuccessException("Wyłączono filtr procesu");
+	}
+
+}

+ 24 - 0
SE/se-lib/Route/PostTask/SetPermsByProces.php

@@ -0,0 +1,24 @@
+<?php
+
+Lib::loadClass('RouteBase');
+
+class Route_PostTask_SetPermsByProces extends RouteBase {
+
+	function run() {
+		$idProces = V::get('id_proces', 0, $_POST, 'int');
+		if ($idProces <= 0) throw new Exception("Brak Nr Procesu");
+
+		if (User::getAcl()->getPermsFiltrProcesId() == $idProces) {
+			throw new AlertInfoException("Filtr procesu nr {$idProces} jest już uruchomiony");
+		}
+
+		if (!User::getAcl()->canExecuteProcesInit($idProces)) {
+			throw new AlertInfoException("Brak uprawnień do uruchomienia filtra procesu nr {$idProces}");
+		}
+
+		User::getAcl()->fetchProcesPerms($idProces, true);
+
+		throw new AlertSuccessException("Uruchomiono filtr procesu nr {$idProces}");
+	}
+
+}

+ 2 - 2
SE/se-lib/Route/UserTest.php

@@ -108,11 +108,11 @@ class Route_UserTest extends RouteBase {
 								UI::h('li', [], [
 									($activeFiltrProcessId == $testStats['ID'])
 									?	UI::h('a', ['href'=>"index.php?FUNCTION_INIT=MENU_SELECT_PROCES&_action=setPermsAll", 'style'=>"font-weight:bold"], "Wyłącz filtr uprawnien dla")
-									:	UI::h('a', ['href'=>"index.php?FUNCTION_INIT=MENU_SELECT_PROCES&_action=setPermsByProces&id_proces={$testStats['ID']}"], "Uruchom filtr uprawnien dla"),
+									: UI::hButtonPost("Uruchom filtr uprawnien dla", [ 'class' => "btn btn-xs btn-link", 'style' => "padding-left:0", 'data' => [ '_rootPostTask' => "SetPermsByProces", 'id_proces' => $testStats['ID'] ] ]),
 									" {$testStats['ID']}"
 								]),
 								UI::h('li', [], [
-									UI::h('a', ['href'=>"procesy5.php?task=CRM_TESTY__ADD_TEST&test_type=TEORETYCZNY&proces_id={$testStats['ID']}"], "Wykonaj test teoretyczny dla"),
+									UI::h('a', [ 'class' => "btn btn-xs btn-link", 'style' => "padding-left:0", 'href' => "procesy5.php?task=CRM_TESTY__ADD_TEST&test_type=TEORETYCZNY&proces_id={$testStats['ID']}" ], "Wykonaj test teoretyczny dla"),
 									" {$testStats['ID']}",
 								]),
 								UI::h('li', [], [

+ 329 - 326
SE/se-lib/Route/ViewTableAjax.php

@@ -15,7 +15,7 @@ Lib::loadClass('UserProfile');
 
 class Route_ViewTableAjax extends RouteBase {
 
-	public function getTableAjaxWidget($acl, $backRefFilter = [], $childRefFilter = []) {
+	function getTableAjaxWidget($acl, $backRefFilter = [], $childRefFilter = []) {
 		$syncUrl = $this->getLink('', [ 'namespace' => $acl->getNamespace() ]);
 		$tbl = new TableAjax($acl);
 		$tbl->setRootUrl($syncUrl);
@@ -64,353 +64,356 @@ class Route_ViewTableAjax extends RouteBase {
 		return $tbl;
 	}
 
-	public function defaultAction() {
+	function defaultAction() {
 		UI::gora();
 		UI::menu();
 		try {
-			$namespace = V::get('namespace', '', $_GET, 'word');
-			if (!$namespace) {
-				$typeName = V::get('typeName', '', $_GET, 'word');
-				if (!$typeName) throw new Exception("Wrong param typeName");
-				$namespace = Api_WfsNs::getBaseWfsUri() . '/' . str_replace(':', '/', $typeName);
+			$this->defaultView();
+		} catch (Exception $e) {
+			UI::startContainer();
+			UI::alert('danger', "<strong>Wystąpiły błędy!</strong> " . $e->getMessage());
+			UI::endContainer();
+			DBG::log($e);
+		}
+		UI::dol();
+	}
+	function defaultView() {
+		$namespace = V::get('namespace', '', $_GET, 'word');
+		if (!$namespace) {
+			$typeName = V::get('typeName', '', $_GET, 'word');
+			if (!$typeName) throw new Exception("Wrong param typeName");
+			$namespace = Api_WfsNs::getBaseWfsUri() . '/' . str_replace(':', '/', $typeName);
+		}
+		$acl = Core_AclHelper::getAclByNamespace($namespace, $forceTblAclInit = ('1' == V::get('_force', '', $_GET)));
+
+		$forceFilterInit = array();
+		$requestDataFilters = array();
+		$filterInit = new stdClass();
+		$filterInit->currSortCol = $acl->getPrimaryKeyField();
+		$filterInit->currSortFlip = 'desc';
+		foreach ($_REQUEST as $k => $v) {
+			if (strlen($k) > 3 && substr($k, 0, 2) == 'f_' && !empty($v)) {// filter prefix
+				$requestDataFilters[$k] = $v;
+				$filterInit->$k = $v;
 			}
-			$acl = Core_AclHelper::getAclByNamespace($namespace, $forceTblAclInit = ('1' == V::get('_force', '', $_GET)));
-
-			$forceFilterInit = array();
-			$requestDataFilters = array();
-			$filterInit = new stdClass();
-			$filterInit->currSortCol = $acl->getPrimaryKeyField();
-			$filterInit->currSortFlip = 'desc';
-			foreach ($_REQUEST as $k => $v) {
-				if (strlen($k) > 3 && substr($k, 0, 2) == 'f_' && !empty($v)) {// filter prefix
-					$requestDataFilters[$k] = $v;
-					$filterInit->$k = $v;
-				}
-				else if (strlen($k) > 4 && substr($k, 0, 3) == 'sf_' && !empty($v)) {// special filter prefix
-					$requestDataFilters[$k] = $v;
-					$filterInit->$k = $v;
-				}
-				else if (strlen($k) > 4 && substr($k, 0, 3) == 'ff_' && !empty($v)) {// force filter prefix
-					$fldName = substr($k, 3);
-					$forceFilterInit[$fldName] = $v;
-				}
+			else if (strlen($k) > 4 && substr($k, 0, 3) == 'sf_' && !empty($v)) {// special filter prefix
+				$requestDataFilters[$k] = $v;
+				$filterInit->$k = $v;
 			}
-
-			$backRefFilter = [
-				'namespace' => V::get('backRefNS', '', $_GET),
-				'primaryKey' => V::get('backRefPK', '', $_GET),
-				'fieldName' => V::get('backRefField', '', $_GET),
-			];
-			$childRefFilter = [
-				'namespace' => V::get('childRefNS', '', $_GET),
-				'primaryKey' => V::get('childRefPK', '', $_GET),
-			];
-			$tbl = $this->getTableAjaxWidget($acl, $backRefFilter, $childRefFilter);
-			$lastDataFilters = $tbl->getFilters();
-			DBG::log([
-				'$requestDataFilters' => $requestDataFilters,
-				'$lastDataFilters' => $lastDataFilters,
-			], 'array', "TODO:BUG?:filters");
-			if (empty($lastDataFilters) && empty($requestDataFilters)) {
-				DBG::log(['TODO: run setFilterInit', [
-					'currSortCol' => $acl->getPrimaryKeyField(),
-					'currSortFlip' => 'desc',
-				]], 'array', "TODO:BUG?:filters");
-				$tbl->setFilterInit([
-					'currSortCol' => $acl->getPrimaryKeyField(),
-					'currSortFlip' => 'desc',
-				]);
-			} else if (!empty($requestDataFilters)) {
-				$tbl->setFilterInit($filterInit);
+			else if (strlen($k) > 4 && substr($k, 0, 3) == 'ff_' && !empty($v)) {// force filter prefix
+				$fldName = substr($k, 3);
+				$forceFilterInit[$fldName] = $v;
 			}
-			if (!empty($forceFilterInit)) $tbl->setForceFilterInit($forceFilterInit);
-			if (V::get('DBG_INST', '', $_GET)) { // TODO: TEST namespace
-				$siblings = ACL::getNamespaceSiblings($namespace);
-				DBG::nicePrint($siblings, '$siblings');
-				$filtrInstance = V::get('f_instance', [], $_POST, 'array');
-				DBG::nicePrint($filtrInstance, '$filtrInstance');
-				$sibling = 'default_db/CRM_PROCES/PROCES_INIT'; DBG::nicePrint(array_merge(['type'=>"radio", 'name'=>"f_instance[{$sibling}]", 'value'=>'YES'], ('YES' === V::get($sibling, '', $filtrInstance)) ? ['checked' => "checked"] : []), "merge {$sibling} YES");
-				$sibling = 'default_db/CRM_PROCES/PROCES_INIT'; DBG::nicePrint(array_merge(['type'=>"radio", 'name'=>"f_instance[{$sibling}]", 'value'=>'NO'], ('NO' === V::get($sibling, '', $filtrInstance)) ? ['checked' => "checked"] : []), "merge {$sibling} NO");
-
-				$_ = array(UI, 'h');
-				echo $_('form', ['method' => "POST", 'style' => "width:600px; border:1px solid #ddd; border-radius:2px"], [
-					$_('div', ['style' => "background-color:#ddd"], "Test Filtr instancji"),
-					$_('div', ['style' => "padding:8px"], array_map(function ($sibling) use ($filtrInstance, $_) {
-						return $_('div', [], [
-							$_('label', ['style' => "margin:0 8px"], [
-								$_('input', array_merge(['type'=>"radio", 'name'=>"f_instance[{$sibling}]", 'value'=>'YES'], ('YES' === V::get($sibling, '', $filtrInstance)) ? ['checked' => "checked"] : [])),
-								" TAK "
-							]),
-							$_('label', ['style' => "margin:0 8px"], [
-								$_('input', array_merge(['type'=>"radio", 'name'=>"f_instance[{$sibling}]", 'value'=>'NO'], ('NO' === V::get($sibling, '', $filtrInstance)) ? ['checked' => "checked"] : [])),
-								" NIE "
-							]),
-							$_('label', ['style' => "margin:0 8px"], [
-								$_('input', ['type'=>"radio", 'name'=>"f_instance[{$sibling}]", 'value'=>'x']),
-								" pomiń "
-							]),
-							// $_('button', ['onClick'=>"this.form.f_instance['{$sibling}'].value = ''; return false"], "odznacz"),
-							$_('button', ['onClick'=>"console.log(this.form.elements['f_instance[{$sibling}]']); this.form.elements['f_instance[{$sibling}]'].value = 'x'; return false"], "odznacz"),
-							" - {$sibling}"
-						]);
-					}, $siblings)),
-					$_('div', [], [
-						$_('input', ['type'=>"hidden", 'name'=>'_route', 'value'=>"ViewObject"]),
-						$_('input', ['type'=>"hidden", 'name'=>'namespace', 'value'=>$namespace]),
-						$_('input', ['type'=>"submit", 'value'=>"Filtruj - TEST"]),
-					]),
-				]);
-				DBG::nicePrint($_POST, '$_POST');
-				{
-					$args = $_POST;
-					$fIsInstance = [];
-					$fIsNotInstance = [];
-					if (!empty($args['f_instance'])) {
-						foreach ($args['f_instance'] as $inst => $selected) {
-							if ('YES' === $selected) {
-								$fIsInstance[] = $inst;
-							} else if ('NO' === $selected) {
-								$fIsNotInstance[] = $inst;
-							}
+		}
+
+		$backRefFilter = [
+			'namespace' => V::get('backRefNS', '', $_GET),
+			'primaryKey' => V::get('backRefPK', '', $_GET),
+			'fieldName' => V::get('backRefField', '', $_GET),
+		];
+		$childRefFilter = [
+			'namespace' => V::get('childRefNS', '', $_GET),
+			'primaryKey' => V::get('childRefPK', '', $_GET),
+		];
+		$tbl = $this->getTableAjaxWidget($acl, $backRefFilter, $childRefFilter);
+		$lastDataFilters = $tbl->getFilters();
+		DBG::log([
+			'$requestDataFilters' => $requestDataFilters,
+			'$lastDataFilters' => $lastDataFilters,
+		], 'array', "TODO:BUG?:filters");
+		if (empty($lastDataFilters) && empty($requestDataFilters)) {
+			DBG::log(['TODO: run setFilterInit', [
+				'currSortCol' => $acl->getPrimaryKeyField(),
+				'currSortFlip' => 'desc',
+			]], 'array', "TODO:BUG?:filters");
+			$tbl->setFilterInit([
+				'currSortCol' => $acl->getPrimaryKeyField(),
+				'currSortFlip' => 'desc',
+			]);
+		} else if (!empty($requestDataFilters)) {
+			$tbl->setFilterInit($filterInit);
+		}
+		if (!empty($forceFilterInit)) $tbl->setForceFilterInit($forceFilterInit);
+		if (V::get('DBG_INST', '', $_GET)) { // TODO: TEST namespace
+			$siblings = ACL::getNamespaceSiblings($namespace);
+			DBG::nicePrint($siblings, '$siblings');
+			$filtrInstance = V::get('f_instance', [], $_POST, 'array');
+			DBG::nicePrint($filtrInstance, '$filtrInstance');
+			$sibling = 'default_db/CRM_PROCES/PROCES_INIT'; DBG::nicePrint(array_merge(['type'=>"radio", 'name'=>"f_instance[{$sibling}]", 'value'=>'YES'], ('YES' === V::get($sibling, '', $filtrInstance)) ? ['checked' => "checked"] : []), "merge {$sibling} YES");
+			$sibling = 'default_db/CRM_PROCES/PROCES_INIT'; DBG::nicePrint(array_merge(['type'=>"radio", 'name'=>"f_instance[{$sibling}]", 'value'=>'NO'], ('NO' === V::get($sibling, '', $filtrInstance)) ? ['checked' => "checked"] : []), "merge {$sibling} NO");
+
+			$_ = array(UI, 'h');
+			echo $_('form', ['method' => "POST", 'style' => "width:600px; border:1px solid #ddd; border-radius:2px"], [
+				$_('div', ['style' => "background-color:#ddd"], "Test Filtr instancji"),
+				$_('div', ['style' => "padding:8px"], array_map(function ($sibling) use ($filtrInstance, $_) {
+					return $_('div', [], [
+						$_('label', ['style' => "margin:0 8px"], [
+							$_('input', array_merge(['type'=>"radio", 'name'=>"f_instance[{$sibling}]", 'value'=>'YES'], ('YES' === V::get($sibling, '', $filtrInstance)) ? ['checked' => "checked"] : [])),
+							" TAK "
+						]),
+						$_('label', ['style' => "margin:0 8px"], [
+							$_('input', array_merge(['type'=>"radio", 'name'=>"f_instance[{$sibling}]", 'value'=>'NO'], ('NO' === V::get($sibling, '', $filtrInstance)) ? ['checked' => "checked"] : [])),
+							" NIE "
+						]),
+						$_('label', ['style' => "margin:0 8px"], [
+							$_('input', ['type'=>"radio", 'name'=>"f_instance[{$sibling}]", 'value'=>'x']),
+							" pomiń "
+						]),
+						// $_('button', ['onClick'=>"this.form.f_instance['{$sibling}'].value = ''; return false"], "odznacz"),
+						$_('button', ['onClick'=>"console.log(this.form.elements['f_instance[{$sibling}]']); this.form.elements['f_instance[{$sibling}]'].value = 'x'; return false"], "odznacz"),
+						" - {$sibling}"
+					]);
+				}, $siblings)),
+				$_('div', [], [
+					$_('input', ['type'=>"hidden", 'name'=>'_route', 'value'=>"ViewObject"]),
+					$_('input', ['type'=>"hidden", 'name'=>'namespace', 'value'=>$namespace]),
+					$_('input', ['type'=>"submit", 'value'=>"Filtruj - TEST"]),
+				]),
+			]);
+			DBG::nicePrint($_POST, '$_POST');
+			{
+				$args = $_POST;
+				$fIsInstance = [];
+				$fIsNotInstance = [];
+				if (!empty($args['f_instance'])) {
+					foreach ($args['f_instance'] as $inst => $selected) {
+						if ('YES' === $selected) {
+							$fIsInstance[] = $inst;
+						} else if ('NO' === $selected) {
+							$fIsNotInstance[] = $inst;
 						}
 					}
 				}
-				$queryFeatures = $acl->buildQuery([
-					// TODO: 'propertyName' => "*,@instance",
-					'f_is_instance' => $fIsInstance,
-					'f_is_not_instance' => $fIsNotInstance,
-					'@instances' => '1',
-					'limit' => 10
-				]);
-				// $total = $queryFeatures->getTotal();
-				$items = $queryFeatures->getItems();
-
-				$rootNamespace = $acl->getRootNamespace();
-				DBG::nicePrint($rootNamespace, '$rootNamespace');
-				$jsRenderFunName = 'render_dropdown_instances_' . substr(md5(time()), 0, 6);
-				DBG::nicePrint($jsRenderFunName, '$jsRenderFunName');
-				UI::table([
-					'rows' => array_map(function($row) use ($namespace, $siblings, $rootNamespace, $jsRenderFunName) {
-						return [
-							'ID' => $row['ID'],
-							'DESC' => $row['DESC'],
-							'TYPE' => $row['TYPE'],
-							'Typ' => UI::h('div', ['class'=>"p5UI__dropdown-wrap"], [
-								UI::h('button', [
-									// 'onClick' => "p5UI__dropdown(event, this, 'left bottom')",
-									'onClick' => "p5UI__dropdown(event, this, 'left bottom', {$jsRenderFunName}({$row['ID']}))",
-									'class' => "btn btn-xs btn-default p5UI__dropdown-btn"
-								], [
-									UI::h('i', ['class' => "glyphicon glyphicon-tags", 'title' => "Ustaw typ danych (instancje)"]),
-								]),
-								UI::h('div', ['class' => "p5UI__dropdown-content"]
-									, array_merge(
-										[
-											UI::h('input', ['type' => "text", 'placeholder' => "Search..", 'class' => "p5UI__dropdown-input", 'onkeyup' => "p5_ViewObject_instances_filterInput(this)"], null),
-										]
-										, array_map(function ($sibling) use ($row, $namespace, $rootNamespace) {
-											return UI::h('div', ['label'=>$sibling, 'style'=>"padding:4px 0"], [
-												UI::h('button', array_merge(['class' => "btn btn-xs btn-default",
-													'style' => "margin:0 4px 0 0",
-													'title' => "Ustaw instancje '{$sibling}'",
-													'onClick' => "return p5_ViewObject_instance_set(this, '{$row['ID']}', '{$sibling}', 'yes')"],
-													(in_array($sibling, explode(',', $row['@instances']))) ? ['disabled' => "disabled"] : []
-												), "+"),
-												UI::h('button', ['class' => "btn btn-xs btn-default",
-													'style' => "margin:0 4px 0 0",
-													'title' => "Usuń instancje '{$sibling}'",
-													'onClick' => "return p5_ViewObject_instance_set(this, '{$row['ID']}', '{$sibling}', 'no')"], "-"),
-												UI::h('span', [], substr($sibling, strlen($rootNamespace) + 1)),
-											]);
-										}, $siblings)
-									)
-								)
+			}
+			$queryFeatures = $acl->buildQuery([
+				// TODO: 'propertyName' => "*,@instance",
+				'f_is_instance' => $fIsInstance,
+				'f_is_not_instance' => $fIsNotInstance,
+				'@instances' => '1',
+				'limit' => 10
+			]);
+			// $total = $queryFeatures->getTotal();
+			$items = $queryFeatures->getItems();
+
+			$rootNamespace = $acl->getRootNamespace();
+			DBG::nicePrint($rootNamespace, '$rootNamespace');
+			$jsRenderFunName = 'render_dropdown_instances_' . substr(md5(time()), 0, 6);
+			DBG::nicePrint($jsRenderFunName, '$jsRenderFunName');
+			UI::table([
+				'rows' => array_map(function($row) use ($namespace, $siblings, $rootNamespace, $jsRenderFunName) {
+					return [
+						'ID' => $row['ID'],
+						'DESC' => $row['DESC'],
+						'TYPE' => $row['TYPE'],
+						'Typ' => UI::h('div', ['class'=>"p5UI__dropdown-wrap"], [
+							UI::h('button', [
+								// 'onClick' => "p5UI__dropdown(event, this, 'left bottom')",
+								'onClick' => "p5UI__dropdown(event, this, 'left bottom', {$jsRenderFunName}({$row['ID']}))",
+								'class' => "btn btn-xs btn-default p5UI__dropdown-btn"
+							], [
+								UI::h('i', ['class' => "glyphicon glyphicon-tags", 'title' => "Ustaw typ danych (instancje)"]),
 							]),
-							'instancesList' => implode(', ', ACL::getFeatureNamespaces($namespace, $row['ID'])),
+							UI::h('div', ['class' => "p5UI__dropdown-content"]
+								, array_merge(
+									[
+										UI::h('input', ['type' => "text", 'placeholder' => "Search..", 'class' => "p5UI__dropdown-input", 'onkeyup' => "p5_ViewObject_instances_filterInput(this)"], null),
+									]
+									, array_map(function ($sibling) use ($row, $namespace, $rootNamespace) {
+										return UI::h('div', ['label'=>$sibling, 'style'=>"padding:4px 0"], [
+											UI::h('button', array_merge(['class' => "btn btn-xs btn-default",
+												'style' => "margin:0 4px 0 0",
+												'title' => "Ustaw instancje '{$sibling}'",
+												'onClick' => "return p5_ViewObject_instance_set(this, '{$row['ID']}', '{$sibling}', 'yes')"],
+												(in_array($sibling, explode(',', $row['@instances']))) ? ['disabled' => "disabled"] : []
+											), "+"),
+											UI::h('button', ['class' => "btn btn-xs btn-default",
+												'style' => "margin:0 4px 0 0",
+												'title' => "Usuń instancje '{$sibling}'",
+												'onClick' => "return p5_ViewObject_instance_set(this, '{$row['ID']}', '{$sibling}', 'no')"], "-"),
+											UI::h('span', [], substr($sibling, strlen($rootNamespace) + 1)),
+										]);
+									}, $siblings)
+								)
+							)
+						]),
+						'instancesList' => implode(', ', ACL::getFeatureNamespaces($namespace, $row['ID'])),
+					];
+				}, $items)
+			]);
+			echo UI::h('style', ['type' => "text/css"], "
+				.p5UI__dropdown-content { min-width:400px; border:1px solid #ccc; background-color: #fff; box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2) }
+				.p5UI__dropdown-content .p5UI__dropdown-item { display:block; color:#000; padding:4px; text-decoration:none }
+				.p5UI__dropdown-content .p5UI__dropdown-item:hover { background-color:#ebebeb }
+			");
+			echo UI::h('script', ['src'=>"static/vendor.js?v=816e859d", 'type'=>"text/javascript"]);
+			$jsArgs = [
+				'SET_INSTANCE_URL' => $this->getLink('setInstanceAjax'),
+				'NAMESPACE' => $namespace,
+				'DBG' => DBG::isActive() ? 'true' : 'false',
+			];
+
+			UI::inlineJS(__FILE__ . '.instancesDropdown.js', [
+				'JS_GLOBAL_FUNCTION_NAME' => $jsRenderFunName,
+				'NAMESPACE' => $namespace,
+				'SET_INSTANCE_URL' => $this->getLink('setInstanceAjax'),
+				'DBG' => DBG::isActive() ? 1 : 0,
+				'INITIAL_DROPDOWN_DATA' => [
+					// 'allowed_instances' => $siblings,
+					'allowed_instances' => array_map(function ($sibling) use ($rootNamespace) {
+						return [
+							'namespace' => $sibling,
+							'label' => substr($sibling, strlen($rootNamespace) + 1)
+						];
+					}, $siblings),
+					'items' => array_map(function($row) use ($namespace, $siblings, $rootNamespace, $jsRenderFunName) {
+						return [
+							'pk' => $row['ID'], // TODO: $primaryKeyField
+							'instances' => explode(',', $row['@instances']),
 						];
 					}, $items)
-				]);
-				echo UI::h('style', ['type' => "text/css"], "
-					.p5UI__dropdown-content { min-width:400px; border:1px solid #ccc; background-color: #fff; box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2) }
-					.p5UI__dropdown-content .p5UI__dropdown-item { display:block; color:#000; padding:4px; text-decoration:none }
-					.p5UI__dropdown-content .p5UI__dropdown-item:hover { background-color:#ebebeb }
-				");
-				echo UI::h('script', ['src'=>"static/vendor.js?v=816e859d", 'type'=>"text/javascript"]);
-				$jsArgs = [
-					'SET_INSTANCE_URL' => $this->getLink('setInstanceAjax'),
-					'NAMESPACE' => $namespace,
-					'DBG' => DBG::isActive() ? 'true' : 'false',
-				];
-
-				UI::inlineJS(__FILE__ . '.instancesDropdown.js', [
-					'JS_GLOBAL_FUNCTION_NAME' => $jsRenderFunName,
-					'NAMESPACE' => $namespace,
-					'SET_INSTANCE_URL' => $this->getLink('setInstanceAjax'),
-					'DBG' => DBG::isActive() ? 1 : 0,
-					'INITIAL_DROPDOWN_DATA' => [
-						// 'allowed_instances' => $siblings,
-						'allowed_instances' => array_map(function ($sibling) use ($rootNamespace) {
-							return [
-								'namespace' => $sibling,
-								'label' => substr($sibling, strlen($rootNamespace) + 1)
-							];
-						}, $siblings),
-						'items' => array_map(function($row) use ($namespace, $siblings, $rootNamespace, $jsRenderFunName) {
-							return [
-								'pk' => $row['ID'], // TODO: $primaryKeyField
-								'instances' => explode(',', $row['@instances']),
-							];
-						}, $items)
-					],
-				]);
-				echo UI::h('script', [], "
-					var SET_INSTANCE_URL = '{$jsArgs['SET_INSTANCE_URL']}'
-					var NAMESPACE = '{$jsArgs['NAMESPACE']}'
-					function p5_ViewObject_instance_set(n, pk, sibling, toConnect) {
-						console.log('p5_ViewObject_instance_set pk('+pk+'), sibling('+sibling+'), toConnect('+toConnect+'), n', n);
-						window.fetch(SET_INSTANCE_URL, {
-							method: 'POST',
-							headers: { 'Content-Type': 'application/json' },
-							credentials: 'same-origin',
-							body: JSON.stringify({
-								namespace: NAMESPACE,
-								primaryKey: pk,
-								instance: sibling,
-								toConnect: toConnect,
-							})
-						}).then(function (response) {
-							return response.json()
-						}).then(function (response) {
-							p5UI__notifyAjaxCallback(response)
-							console.log(response) // TODO: render list
+				],
+			]);
+			echo UI::h('script', [], "
+				var SET_INSTANCE_URL = '{$jsArgs['SET_INSTANCE_URL']}'
+				var NAMESPACE = '{$jsArgs['NAMESPACE']}'
+				function p5_ViewObject_instance_set(n, pk, sibling, toConnect) {
+					console.log('p5_ViewObject_instance_set pk('+pk+'), sibling('+sibling+'), toConnect('+toConnect+'), n', n);
+					window.fetch(SET_INSTANCE_URL, {
+						method: 'POST',
+						headers: { 'Content-Type': 'application/json' },
+						credentials: 'same-origin',
+						body: JSON.stringify({
+							namespace: NAMESPACE,
+							primaryKey: pk,
+							instance: sibling,
+							toConnect: toConnect,
 						})
-					}
-				");
-				echo UI::h('script', [], "
-					function p5_ViewObject_instances_filterInput(n) {
-						var input, filter, ul, li, a, i, div;
-						input = n // .id-myInput
-						filter = input.value.toUpperCase()
-						div = n.parentNode // .id-myDropdown
-						a = div.getElementsByTagName('div')
-						for (i = 0; i < a.length; i++) {
-							if (a[i].getAttribute('label') && a[i].getAttribute('label').toUpperCase().indexOf(filter) > -1) {
-								a[i].style.display = 'block'
-							} else {
-								a[i].style.display = 'none'
-							}
+					}).then(function (response) {
+						return response.json()
+					}).then(function (response) {
+						p5UI__notifyAjaxCallback(response)
+						console.log(response) // TODO: render list
+					})
+				}
+			");
+			echo UI::h('script', [], "
+				function p5_ViewObject_instances_filterInput(n) {
+					var input, filter, ul, li, a, i, div;
+					input = n // .id-myInput
+					filter = input.value.toUpperCase()
+					div = n.parentNode // .id-myDropdown
+					a = div.getElementsByTagName('div')
+					for (i = 0; i < a.length; i++) {
+						if (a[i].getAttribute('label') && a[i].getAttribute('label').toUpperCase().indexOf(filter) > -1) {
+							a[i].style.display = 'block'
+						} else {
+							a[i].style.display = 'none'
 						}
 					}
-				");
-				echo '<hr style="margin-top:300px">';
-				exit;
-			}
-			echo $tbl->render();
-
-			if (DBG::isActive() && V::get('DBG_ACL', '', $_GET)) {// test load perms
-				Lib::loadClass('DebugExecutionTime');
-				$dbgExecTime = new DebugExecutionTime();
-				$dbgExecTime->activate();
-				$dbgExecTime->log('start');
-				UI::startContainer(['style'=>'border:1px solid red']);
-				UI::tag('p', null, "TEST - load perms from db");
-				$idTable = $acl->getID();
-				UI::tag('p', null, "DBG idTable({$idTable})");
-				if ($idTable > 0) {
-					$dbgExecTime->log('before sql');
-					$aclTableRows = DB::getPDO()->fetchAll("select * from `CRM_PROCES_idx_TABLE_TO_PROCES_PERMS_VIEW` where ID_TABLE = {$idTable}");
-					$dbgExecTime->log('after sql', ['sql']);
-					UI::table(['caption' => "from CRM_PROCES_idx_TABLE_TO_PROCES_PERMS_VIEW", 'rows' => $aclTableRows]);
-					$csvIdProces = array();
-					foreach ($aclTableRows as $row) {
-						if (!in_array($row['ID_PROCES'], $csvIdProces)) $csvIdProces[] = $row['ID_PROCES'];
-					}
 				}
+			");
+			echo '<hr style="margin-top:300px">';
+			exit;
+		}
+		echo $tbl->render();
+
+		if (DBG::isActive() && V::get('DBG_ACL', '', $_GET)) {// test load perms
+			Lib::loadClass('DebugExecutionTime');
+			$dbgExecTime = new DebugExecutionTime();
+			$dbgExecTime->activate();
+			$dbgExecTime->log('start');
+			UI::startContainer(['style'=>'border:1px solid red']);
+			UI::tag('p', null, "TEST - load perms from db");
+			$idTable = $acl->getID();
+			UI::tag('p', null, "DBG idTable({$idTable})");
+			if ($idTable > 0) {
+				$dbgExecTime->log('before sql');
+				$aclTableRows = DB::getPDO()->fetchAll("select * from `CRM_PROCES_idx_TABLE_TO_PROCES_PERMS_VIEW` where ID_TABLE = {$idTable}");
+				$dbgExecTime->log('after sql', ['sql']);
+				UI::table(['caption' => "from CRM_PROCES_idx_TABLE_TO_PROCES_PERMS_VIEW", 'rows' => $aclTableRows]);
+				$csvIdProces = array();
+				foreach ($aclTableRows as $row) {
+					if (!in_array($row['ID_PROCES'], $csvIdProces)) $csvIdProces[] = $row['ID_PROCES'];
+				}
+			}
 
-				$tableName = $acl->getName();
-				$databaseName = DB::getPDO()->getDatabaseName();
-				UI::table([
-					'caption' => "Cell to process",
-					'rows' => array_map(
-						function ($row) use ($aclTableRows, $idTable) {
-							$row['proces'] = array();
-							$row['id_zasob'] = 0;
-							$row['PERM_R'] = 0;
-							$row['PERM_W'] = 0;
-							$row['PERM_X'] = 0;
-							$row['PERM_C'] = 0;
-							$row['PERM_S'] = 0;
-							$row['PERM_O'] = 0;
-							$row['PERM_V'] = 0;
-							$row['PERM_E'] = 0;
-							foreach ($aclTableRows as $aclInfo) {
-								if (strtolower($aclInfo['CELL_NAME']) == strtolower($row['COLUMN_NAME'])) {
-									$row['proces'][] = $aclInfo['ID_PROCES'];
-									$row['id_zasob'] = $aclInfo['ID_CELL'];
-									$row['PERM_R'] += $aclInfo['PERM_R'];
-									$row['PERM_W'] += $aclInfo['PERM_W'];
-									$row['PERM_X'] += $aclInfo['PERM_X'];
-									$row['PERM_C'] += $aclInfo['PERM_C'];
-									$row['PERM_S'] += $aclInfo['PERM_S'];
-									$row['PERM_O'] += $aclInfo['PERM_O'];
-									$row['PERM_V'] += $aclInfo['PERM_V'];
-									$row['PERM_E'] += $aclInfo['PERM_E'];
-								}
+			$tableName = $acl->getName();
+			$databaseName = DB::getPDO()->getDatabaseName();
+			UI::table([
+				'caption' => "Cell to process",
+				'rows' => array_map(
+					function ($row) use ($aclTableRows, $idTable) {
+						$row['proces'] = array();
+						$row['id_zasob'] = 0;
+						$row['PERM_R'] = 0;
+						$row['PERM_W'] = 0;
+						$row['PERM_X'] = 0;
+						$row['PERM_C'] = 0;
+						$row['PERM_S'] = 0;
+						$row['PERM_O'] = 0;
+						$row['PERM_V'] = 0;
+						$row['PERM_E'] = 0;
+						foreach ($aclTableRows as $aclInfo) {
+							if (strtolower($aclInfo['CELL_NAME']) == strtolower($row['COLUMN_NAME'])) {
+								$row['proces'][] = $aclInfo['ID_PROCES'];
+								$row['id_zasob'] = $aclInfo['ID_CELL'];
+								$row['PERM_R'] += $aclInfo['PERM_R'];
+								$row['PERM_W'] += $aclInfo['PERM_W'];
+								$row['PERM_X'] += $aclInfo['PERM_X'];
+								$row['PERM_C'] += $aclInfo['PERM_C'];
+								$row['PERM_S'] += $aclInfo['PERM_S'];
+								$row['PERM_O'] += $aclInfo['PERM_O'];
+								$row['PERM_V'] += $aclInfo['PERM_V'];
+								$row['PERM_E'] += $aclInfo['PERM_E'];
 							}
-							$row['proces'] = (empty($row['proces']))
-								? "<i style=\"color:red\">Brak</i>"
-								: implode(", ", $row['proces']);
-							if (!$row['id_zasob']) $row['id_zasob'] = DB::getPDO()->fetchValue("select ID from CRM_LISTA_ZASOBOW where `DESC` = '{$row['COLUMN_NAME']}' and PARENT_ID = {$idTable} limit 1");
-							return $row;
-						}, DB::getPDO()->fetchAll("
-							select t.TABLE_NAME, t.COLUMN_NAME, t.DATA_TYPE, t.COLUMN_TYPE
-							from `information_schema`.`COLUMNS` t
-							where t.TABLE_SCHEMA = '{$databaseName}'
-								and t.TABLE_NAME like '{$tableName}'
-						")
-					)
-				]);
-
-				if (!empty($csvIdProces)) {
-					$csvIdProces = implode(",", $csvIdProces);
-					UI::tag('p', null, "DBG csvIdProces({$csvIdProces})");
-					$userLogin = User::getLogin();
-					$dbgExecTime->log('before sql');
-					$rows = DB::getPDO()->fetchAll("select ID_PROCES from `CRM_PROCES_idx_USER_to_PROCES_VIEW` where ADM_ACCOUNT = '{$userLogin}' and ID_PROCES in({$csvIdProces}) group by ID_PROCES");
-					$dbgExecTime->log('after sql', ['sql']);
-					UI::table(['caption' => "from CRM_PROCES_idx_USER_to_PROCES_VIEW", 'rows' => $rows]);
-					$userIdProces = array(); foreach ($rows as $row) $userIdProces[] = $row['ID_PROCES'];
-					$userTablePerms = array();
-					foreach ($aclTableRows as $row) {
-						if (!in_array($row['ID_PROCES'], $userIdProces)) continue;
-						if (array_key_exists($row['CELL_NAME'], $userTablePerms)) {
-							$userTablePerms[ $row['CELL_NAME'] ][ 'PERM_R' ] += $row['PERM_R'];
-							$userTablePerms[ $row['CELL_NAME'] ][ 'PERM_W' ] += $row['PERM_W'];
-							$userTablePerms[ $row['CELL_NAME'] ][ 'PERM_X' ] += $row['PERM_X'];
-							$userTablePerms[ $row['CELL_NAME'] ][ 'PERM_C' ] += $row['PERM_C'];
-							$userTablePerms[ $row['CELL_NAME'] ][ 'PERM_S' ] += $row['PERM_S'];
-							$userTablePerms[ $row['CELL_NAME'] ][ 'PERM_O' ] += $row['PERM_O'];
-							$userTablePerms[ $row['CELL_NAME'] ][ 'PERM_V' ] += $row['PERM_V'];
-							$userTablePerms[ $row['CELL_NAME'] ][ 'PERM_E' ] += $row['PERM_E'];
-						} else {
-							$userTablePerms[ $row['CELL_NAME'] ] = $row;
-							unset($userTablePerms[ $row['CELL_NAME'] ][ 'TABLE_DESCRIPTION' ]);
-							unset($userTablePerms[ $row['CELL_NAME'] ][ 'ID_PROCES' ]);
-							unset($userTablePerms[ $row['CELL_NAME'] ][ 'FORM_TREAT' ]);
 						}
+						$row['proces'] = (empty($row['proces']))
+							? "<i style=\"color:red\">Brak</i>"
+							: implode(", ", $row['proces']);
+						if (!$row['id_zasob']) $row['id_zasob'] = DB::getPDO()->fetchValue("select ID from CRM_LISTA_ZASOBOW where `DESC` = '{$row['COLUMN_NAME']}' and PARENT_ID = {$idTable} limit 1");
+						return $row;
+					}, DB::getPDO()->fetchAll("
+						select t.TABLE_NAME, t.COLUMN_NAME, t.DATA_TYPE, t.COLUMN_TYPE
+						from `information_schema`.`COLUMNS` t
+						where t.TABLE_SCHEMA = '{$databaseName}'
+							and t.TABLE_NAME like '{$tableName}'
+					")
+				)
+			]);
+
+			if (!empty($csvIdProces)) {
+				$csvIdProces = implode(",", $csvIdProces);
+				UI::tag('p', null, "DBG csvIdProces({$csvIdProces})");
+				$userLogin = User::getLogin();
+				$dbgExecTime->log('before sql');
+				$rows = DB::getPDO()->fetchAll("select ID_PROCES from `CRM_PROCES_idx_USER_to_PROCES_VIEW` where ADM_ACCOUNT = '{$userLogin}' and ID_PROCES in({$csvIdProces}) group by ID_PROCES");
+				$dbgExecTime->log('after sql', ['sql']);
+				UI::table(['caption' => "from CRM_PROCES_idx_USER_to_PROCES_VIEW", 'rows' => $rows]);
+				$userIdProces = array(); foreach ($rows as $row) $userIdProces[] = $row['ID_PROCES'];
+				$userTablePerms = array();
+				foreach ($aclTableRows as $row) {
+					if (!in_array($row['ID_PROCES'], $userIdProces)) continue;
+					if (array_key_exists($row['CELL_NAME'], $userTablePerms)) {
+						$userTablePerms[ $row['CELL_NAME'] ][ 'PERM_R' ] += $row['PERM_R'];
+						$userTablePerms[ $row['CELL_NAME'] ][ 'PERM_W' ] += $row['PERM_W'];
+						$userTablePerms[ $row['CELL_NAME'] ][ 'PERM_X' ] += $row['PERM_X'];
+						$userTablePerms[ $row['CELL_NAME'] ][ 'PERM_C' ] += $row['PERM_C'];
+						$userTablePerms[ $row['CELL_NAME'] ][ 'PERM_S' ] += $row['PERM_S'];
+						$userTablePerms[ $row['CELL_NAME'] ][ 'PERM_O' ] += $row['PERM_O'];
+						$userTablePerms[ $row['CELL_NAME'] ][ 'PERM_V' ] += $row['PERM_V'];
+						$userTablePerms[ $row['CELL_NAME'] ][ 'PERM_E' ] += $row['PERM_E'];
+					} else {
+						$userTablePerms[ $row['CELL_NAME'] ] = $row;
+						unset($userTablePerms[ $row['CELL_NAME'] ][ 'TABLE_DESCRIPTION' ]);
+						unset($userTablePerms[ $row['CELL_NAME'] ][ 'ID_PROCES' ]);
+						unset($userTablePerms[ $row['CELL_NAME'] ][ 'FORM_TREAT' ]);
 					}
-					UI::table(['caption' => "\$userTablePerms", 'rows' => $userTablePerms]);
-				} else UI::alert('warning', "brak \$csvIdProces");
-				$dbgExecTime->printDebug();
-				UI::endContainer();
-			}
-		} catch (Exception $e) {
-			UI::startContainer();
-			UI::alert('danger', "<strong>Wystąpiły błędy!</strong> " . $e->getMessage());
+				}
+				UI::table(['caption' => "\$userTablePerms", 'rows' => $userTablePerms]);
+			} else UI::alert('warning', "brak \$csvIdProces");
+			$dbgExecTime->printDebug();
 			UI::endContainer();
-			DBG::log($e);
 		}
-		UI::dol();
 	}
 
 	public function setInstanceAjaxAction() {

+ 6 - 0
SE/se-lib/Router.php

@@ -64,4 +64,10 @@ class Router {
 		}
 	}
 
+	static function rootPostTask($rootPostTask) {
+		$className = "Route_PostTask_{$rootPostTask}";
+		Lib::loadClass($className);
+		$className::run();
+	}
+
 }

+ 14 - 0
SE/se-lib/S.php

@@ -147,4 +147,18 @@ class S {
 		];
 	}
 
+	static function saveUserMessage($className, $message) {
+		return self::_userMessage('set', $className, $message);
+	}
+	static function getUserMessage() {
+		return self::_userMessage('get');
+	}
+	static function _userMessage($action, $className = '', $message = '') {
+		static $_msg = null;
+		switch ($action) {
+			case 'set': $_msg = [ $className, $message ]; return;
+			case 'get': $ret = ($_msg) ? [ $_msg[0], $_msg[1] ] : null; $_msg = null; return $ret;
+		}
+	}
+
 }

+ 120 - 71
SE/se-lib/TableAjax.php.procesInitFiltr.js

@@ -3,83 +3,132 @@ if ('undefined' === typeof JS_FUNCTION_NAME) throw "Missing JS_FUNCTION_NAME";
 if ('undefined' === typeof URL_GET_PROCES_INIT_FILTR) throw "Missing URL_GET_PROCES_INIT_FILTR";
 if ('undefined' === typeof ID_ZASOB) throw "Missing ID_ZASOB";
 
+function p5Utils__convertToHtml(tagName, attributes, childrens) { // ( string tagName, object attributes, array childrens )
+	return '<' + tagName + ( attributes ? ' ' + p5Utils__convertAttrsToHtml(attributes) : ''  ) + '>' + ( childrens || [] ).join("") + '</' + tagName +  '>';
+}
+function p5Utils__convertAttrsToHtml(attributes) {
+	return Object.keys(attributes).map(function (attrName) {
+		var name = attrName;
+		if ('className' === name) name = 'class';
+		return '' + name + '="' + attributes[attrName] + '"'
+	}).join(" ")
+}
+
+function _viewProcesInitListItem(pInitId, label, selected) {
+	var jsInfo = "window.open('procesy5.php?task=PROCES_VIEW_LIST&id_proces=" + pInitId + "&HIDE_PANEL=0&show_big_img=1&group_stanowiska=1');return false;";
+	var h = p5Utils__convertToHtml;
+
+	return h('form', { className: "form-inline", method: "post", action: "", style: "padding: 3px 20px" }, [
+		h('input', { type: "hidden", name: "_rootPostTask", value: "SetPermsByProces" }),
+		h('input', { type: "hidden", name: "id_proces", value: pInitId }),
+		h('i', {
+			className: "glyphicon glyphicon-info-sign",
+			style: "color:#aaa; cursor:help",
+			onclick: jsInfo,
+			title: "Przeglądaj proces {" + pInitId + "} " + label,
+			onmouseover: "this.style.color = '#337AB7'", onmouseout: "this.style.color = '#aaa'"
+		}),
+		h('button', {
+			className: "btn btn-link" + ( selected ? " disabled" : "" ),
+			style: "padding:0 3px",
+			title: "Uruchom filtr procesu {" + pInitId + "}"
+		}, [
+			" {" + pInitId + "} " + label,
+		]),
+	]);
+}
+function _viewProcesGotoAndRetListItem(gotoId, label, selected) {
+	var jsInfo = "window.open('procesy5.php?task=PROCES_VIEW_LIST&id_proces=" + gotoId + "&HIDE_PANEL=0&show_big_img=1&group_stanowiska=1');return false;";
+	var h = p5Utils__convertToHtml;
+
+	return h('form', { className: "form-inline", method: "post", action: "", style: "padding:3px 20px; margin-left:20px" }, [
+		h('input', { type: "hidden", name: "_rootPostTask", value: "SetPermsByProces" }),
+		h('input', { type: "hidden", name: "id_proces", value: gotoId }),
+		h('i', {
+			className: "glyphicon glyphicon-info-sign",
+			style: "color:#aaa; cursor:help",
+			title: "Przeglądaj proces {" + gotoId + "} " + label,
+			onclick: jsInfo,
+			onmouseover: "this.style.color = '#337AB7'", onmouseout: "this.style.color = '#aaa'"
+		}),
+		h('button', {
+			className: "btn btn-link" + ( selected ? " disabled" : "" ),
+			style: "padding:0 3px",
+			title: "Uruchom filtr procesu {" + gotoId + "}"
+		}, [
+			" {" + gotoId + "} " + label,
+		]),
+	]);
+}
+function _viewProcesGotoAndRetLvl2ListItem(gotoLvl2Id, label, selected) {
+	var jsInfo = "window.open('procesy5.php?task=PROCES_VIEW_LIST&id_proces=" + gotoLvl2Id + "&HIDE_PANEL=0&show_big_img=1&group_stanowiska=1');return false;";
+	var h = p5Utils__convertToHtml;
+
+	return h('form', { className: "form-inline", method: "post", action: "", style: "padding:3px 20px; margin-left:40px" }, [
+		h('input', { type: "hidden", name: "_rootPostTask", value: "SetPermsByProces" }),
+		h('input', { type: "hidden", name: "id_proces", value: gotoLvl2Id }),
+		h('i', { className: "glyphicon glyphicon-arrow-right", style: "color:#aaa" }),
+		h('i', {
+			className: "glyphicon glyphicon-info-sign",
+			style: "color:#aaa; cursor:help",
+			title: "Przeglądaj proces {" + gotoLvl2Id + "} " + label,
+			onclick: jsInfo,
+			onmouseover: "this.style.color = '#337AB7'", onmouseout: "this.style.color = '#aaa'"
+		}),
+		h('button', {
+			className: "btn btn-link" + ( selected ? " disabled" : "" ),
+			style: "padding:0 3px",
+			title: "Uruchom filtr procesu {" + gotoLvl2Id + "}"
+		}, [
+			" {" + gotoLvl2Id + "} " + label,
+		]),
+	]);
+}
+
+
+function _viewDropdownListItem(id, label, selected, callback) {
+	var h = p5Utils__convertToHtml;
+
+	return h('li', {
+		style: "white-space:nowrap; overflow:hidden; max-width:500px; /* text-overflow:ellipsis; */",
+		onmouseover: "this.style.backgroundColor='#f5f5f5'", onmouseout: "this.style.backgroundColor='#fff'",
+	}, [
+		callback(id, label, selected),
+	]);
+}
+
 function toggleProcesInitFiltr(n) {
 	var $n = jQuery(n);
 	var $ul = $n.next();
 	if ($n.data('fetched')) return false;
 
 	function parseProcesInitData(pInitData) {
-		var procesInitMapHtml = '';
-		if (!pInitData) {
-			return '<li><a href="#">' + "Brak danych" + '</a></li>';
-		} else {
-			function _viewProcesInitListItem(pInitId, gotoIds, pInitList) {
-				var label = pInitList[pInitId];
-				var jsInfo = "window.open('procesy5.php?task=PROCES_VIEW_LIST&id_proces=" + pInitId + "&HIDE_PANEL=0&show_big_img=1&group_stanowiska=1');return false;";
-				var out = '<a href="index.php?FUNCTION_INIT=MENU_SELECT_PROCES&_action=setPermsByProces&id_proces=' + pInitId + '&MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=' + ID_ZASOB + '" title="' + "{" + pInitId + "} " + label + '">';// TODO: change to _route=ViewTableAjax&typeName=p5_default_db:{tblName}
-					out += ' <i class="glyphicon glyphicon-info-sign"';
-						out += ' onclick="' + jsInfo + '"';
-						out += ' style="color:#aaa;"';
-						out += ' onmouseover="' + "this.style.color='#337AB7'" + '"';
-						out += ' onmouseout="' + "this.style.color='#aaa'" + '"></i>';
-					out += " {" + pInitId + "} " + label;
-				out += '</a>';
-				return out;
-			}
-			function _viewProcesGotoAndRetListItem(gotoId, pInitList) {
-				var label = pInitList[gotoId];
-				var jsInfo = "window.open('procesy5.php?task=PROCES_VIEW_LIST&id_proces=" + gotoId + "&HIDE_PANEL=0&show_big_img=1&group_stanowiska=1');return false;";
-				var out = '';
-				out += '<a href="index.php?FUNCTION_INIT=MENU_SELECT_PROCES&_action=setPermsByProces&id_proces=' + gotoId + '&MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=' + ID_ZASOB + '" title="' + "{" + gotoId + "} " + label + '">';// TODO: change to _route=ViewTableAjax&typeName=p5_default_db:{tblName}
-					out += ' <span style="padding:10px;"></span>';
-					out += ' <i class="glyphicon glyphicon-arrow-right" style="color:#aaa"></i>';
-					out += ' <i class="glyphicon glyphicon-info-sign"';
-						out += ' onclick="' + jsInfo + '"';
-						out += ' style="color:#aaa;"';
-						out += ' onmouseover="' + "this.style.color='#337AB7'" + '"';
-						out += ' onmouseout="' + "this.style.color='#aaa'" + '"></i>';
-					out += " {" + gotoId + "} " + label;
-				out += '</a>';
-				return out;
-			}
-			function _viewProcesGotoAndRetLvl2ListItem(gotoLvl2Id, pInitList) {
-				var label = pInitList[gotoLvl2Id];
-				var jsInfo = "window.open('procesy5.php?task=PROCES_VIEW_LIST&id_proces=" + gotoLvl2Id + "&HIDE_PANEL=0&show_big_img=1&group_stanowiska=1');return false;";
-				var out = '';
-				out += '<a href="index.php?FUNCTION_INIT=MENU_SELECT_PROCES&_action=setPermsByProces&id_proces=' + gotoLvl2Id + '&MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=' + ID_ZASOB + '" title="' + "{" + gotoLvl2Id + "} " + label + '">';// TODO: change to _route=ViewTableAjax&typeName=p5_default_db:{tblName}
-					out += ' <span style="padding:20px;"></span>';
-					out += ' <i class="glyphicon glyphicon-arrow-right" style="color:#aaa"></i>';
-					out += ' <i class="glyphicon glyphicon-info-sign"';
-						out += ' onclick="' + jsInfo + '"';
-						out += ' style="color:#aaa;"';
-						out += ' onmouseover="' + "this.style.color='#337AB7'" + '"';
-						out += ' onmouseout="' + "this.style.color='#aaa'" + '"></i>';
-					out += " {" + gotoLvl2Id + "} " + label;
-				out += '</a>';
-				return out;
-			}
-			var sel = '',
-					liStyle = "white-space:nowrap; overflow:hidden; max-width:500px; /* text-overflow:ellipsis; */";
-			$.map(pInitData.mapTree, function(gotoIds, vInitId) {
-				sel = (pInitData.pInitListSelected && pInitData.pInitListSelected == vInitId)? ' class="disabled"' : '';
-				procesInitMapHtml += '<li' + sel + ' style="' + liStyle + '">';
-				procesInitMapHtml += _viewProcesInitListItem(vInitId, gotoIds, pInitData.pInitList);
-				procesInitMapHtml += '</li>' + "\n";
-				$.map(gotoIds, function(gotoLvl2Ids, gotoId) {
-					sel = (pInitData.pInitListSelected && pInitData.pInitListSelected == vInitId)? ' class="disabled"' : '';
-					procesInitMapHtml += '<li' + sel + ' style="' + liStyle + '">';
-					procesInitMapHtml += _viewProcesGotoAndRetListItem(gotoId, pInitData.pInitList);
-					procesInitMapHtml += '</li>' + "\n";
-					$.map(gotoLvl2Ids, function(vBool, gotoLvl2Id) {
-						sel = (pInitData.pInitListSelected && pInitData.pInitListSelected == vInitId)? ' class="disabled"' : '';
-						procesInitMapHtml += '<li' + sel + ' style="' + liStyle + '">';
-						procesInitMapHtml += _viewProcesGotoAndRetLvl2ListItem(gotoLvl2Id, pInitData.pInitList);
-						procesInitMapHtml += '</li>' + "\n";
-					});
-				});
-			});
-		}
-		return procesInitMapHtml;
+		return (!pInitData || !pInitData.mapTree)
+			? '<li><a href="#">' + "Brak danych" + '</a></li>'
+			: Object.keys(pInitData.mapTree).map(function (vInitId) {
+				var gotoIds = pInitData.mapTree[vInitId];
+				var sel = (pInitData.pInitListSelected && pInitData.pInitListSelected == vInitId);
+
+				return [
+					_viewDropdownListItem(vInitId, pInitData.pInitList[vInitId], sel, _viewProcesInitListItem)
+				].concat(
+					(!gotoIds) ? null : Object.keys(gotoIds).map(function (gotoId) {
+						var gotoLvl2Ids = gotoIds[gotoId];
+						var sel = (pInitData.pInitListSelected && pInitData.pInitListSelected == vInitId);
+
+						return [
+							_viewDropdownListItem(gotoId, pInitData.pInitList[gotoId], sel, _viewProcesGotoAndRetListItem)
+						].concat(
+							(!gotoLvl2Ids) ? null : Object.keys(gotoLvl2Ids).map(function (gotoLvl2Id) {
+								// var vBool = gotoLvl2Ids[gotoLvl2Id];
+
+								return _viewDropdownListItem(gotoLvl2Id, pInitData.pInitList[gotoLvl2Id], sel, _viewProcesGotoAndRetLvl2ListItem);
+							}).join("\n")
+						).join("\n");
+					}).join("\n")
+				).join("\n");
+			}).join("\n")
+		;
 	}
 
 	jQuery.ajax({

+ 27 - 2
SE/se-lib/UI.php

@@ -50,7 +50,10 @@ class UI {
 	}
 
 	public static function menu() {
-		if (!User::logged()) return;
+		if (!User::logged()) {
+			self::printUserMessage();
+			return;
+		}
 
 		if (User::hasAccess('menu')) {
 			Theme::top();
@@ -58,6 +61,19 @@ class UI {
 		else {
 			UI::loadTemplate('menuLevel6');
 		}
+		self::printUserMessage();
+	}
+	static function printUserMessage() {
+		$usrMsg = S::getUserMessage();
+		if (!$usrMsg) return;
+		switch ($usrMsg[0]) {
+			case 'AlertInfoException': UI::alertWithCloseBtn('info', $usrMsg[1]); return;
+			case 'AlertSuccessException': UI::alertWithCloseBtn('success', $usrMsg[1]); return;
+			case 'AlertWarningException': UI::alertWithCloseBtn('warning', $usrMsg[1]); return;
+			case 'AlertDangerException': UI::alertWithCloseBtn('danger', $usrMsg[1]); return;
+			case 'Exception': UI::alertWithCloseBtn('danger', $usrMsg[1]); return;
+			default: UI::alertWithCloseBtn('danger', "Not implemented: " . $usrMsg[1]); return;
+		}
 	}
 
 	public static function loadTemplate($tmplName, $data = array()) {
@@ -92,7 +108,7 @@ class UI {
 		}
 	}
 
-	public static function alert($alertType, $msg, $outputHtml = true) {
+	static function alert($alertType, $msg, $outputHtml = true) {
 		if (!$outputHtml) {
 			$type = ('danger' == $alertType) ? "ERROR" : strtoupper($alertType);
 			echo "{$type}: {$msg}\n";
@@ -100,6 +116,15 @@ class UI {
 		}
 		UI::tag('div', ['class'=>"alert alert-{$alertType}"], $msg, "\n");
 	}
+	static function alertWithCloseBtn($alertType, $msg, $outputHtml = true) {
+		if (!$outputHtml) {
+			$type = ('danger' == $alertType) ? "ERROR" : strtoupper($alertType);
+			echo "{$type}: {$msg}\n";
+			return;
+		}
+		$closeBtn = '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>';
+		UI::tag('div', ['class'=>"alert alert-{$alertType}"], $closeBtn . "\n" . $msg, "\n");
+	}
 
 	public static function setTitleJsTag($title) { self::setTitle($title); }
 	public static function setTitle($title) { self::tag('script', null, "document.title = '{$title}';", "\n"); }

+ 6 - 1
SE/se-lib/tmpl/menuMain.php

@@ -484,7 +484,12 @@ jQuery(document).ready(function() {
 if ($idFiltrProcesID > 0) {
     echo UI::h('div', [ 'id' => "SE-menu-sub", 'style' => "clear:both;" ], array_merge(
         [
-            UI::h('a', [ 'class' => "btn btn-xs btn-danger", 'href' => "index.php?FUNCTION_INIT=MENU_SELECT_PROCES&_action=setPermsAll", 'title' => "Wyłącz filtr uprawnień dla procesu {$idFiltrProcesID}" ], "Wyłącz filtr uprawnień: {$idFiltrProcesID}"),
+			UI::hButtonPost("Wyłącz filtr uprawnień: {$idFiltrProcesID}", [
+				'class' => "btn btn-xs btn-danger",
+				'data' => [
+					'_rootPostTask' => "SetPermsAll",
+				],
+			]),
         ],
         array_map(
             function ($label, $typeName) {