ProcesMenu.php 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183
  1. <?php
  2. require_once dirname(__FILE__) . '/' . 'Lib.php';
  3. Lib::loadClass('V');
  4. Lib::loadClass('User');
  5. Lib::loadClass('ProcesTestyHelper');
  6. Lib::loadClass('TypespecialVariable');
  7. Lib::loadClass('UsersHelper');
  8. Lib::loadClass('DB');
  9. Lib::loadClass('UserBookmarks');
  10. Lib::loadClass('FilterFactory');
  11. class ProcesMenu {
  12. var $MENU_SELECT_PROCES;
  13. var $_wynik_testu;
  14. var $_wynik_testu_unactual;
  15. var $error;// errory niedopuszczajace do uruchomienia
  16. var $warning;// uwagi
  17. var $CRM_PROCES_USERA_UZYTY;
  18. var $_user_id;
  19. var $_acl;
  20. function __construct() {
  21. $this->_user_id = User::getID();
  22. if (User::isAdmin()) {
  23. $this->_user_id = V::get('_user_id', 0, $_REQUEST, 'int');
  24. if (!$this->_user_id) {
  25. $this->_user_id = User::getID();
  26. $this->_acl = User::getAcl();
  27. } else {
  28. $this->_acl = UsersHelper::getUserAcl($this->_user_id);
  29. }
  30. } else {
  31. $this->_acl = User::getAcl();
  32. }
  33. if (!$this->_acl) {
  34. die('Error Acl');
  35. }
  36. if ('1' == V::get('_CLEAN_CACHE', '', $_REQUEST)) {
  37. $this->_cleanTestsCache();
  38. }
  39. $this->_generateTestResults();
  40. }
  41. static function getInstance() {
  42. static $_instance = null;
  43. if (!$_instance) {
  44. $_instance = new ProcesMenu();
  45. }
  46. return $_instance;
  47. }
  48. function show() {
  49. static $_menu_showed = false;
  50. if (!$_menu_showed) {
  51. $actionName = V::get('_action', 'menu', $_REQUEST);
  52. // podglad testów pracownika
  53. if (User::isAdmin() && $this->_user_id != User::getID()) {
  54. $actionName = 'showMyTests';
  55. }
  56. $actionName .= 'Action';
  57. if (method_exists($this, $actionName)) {
  58. $this->{$actionName}();
  59. }
  60. //$this->show_menu_with_process();
  61. $_menu_showed = true;
  62. }
  63. }
  64. /**
  65. * @return Array
  66. */
  67. function getUserTests() {
  68. if ($this->_user_id <= 0) {
  69. throw new Exception("User id not set");
  70. }
  71. $testy_arr = array();
  72. $ses_cache_key = 'CRM_PROCES_USERA_WYKONANE_TESTY-' . $this->_user_id;
  73. if (!$this->_isTestsInCache()) {
  74. $usedProcesInitIds = $this->_acl->getUserProcesInitIds();
  75. DBG::_('DBG_PM', '1', "usedProcesInitIds", $usedProcesInitIds, __CLASS__, __FUNCTION__, __LINE__ );
  76. if (!empty($usedProcesInitIds)) {
  77. $testy_arr = ProcesTestyHelper::get_tetsy_stats($this->_user_id, 0, $usedProcesInitIds);
  78. // check if tests are actual - proces steps may change
  79. if (!empty($testy_arr)) {
  80. foreach ($usedProcesInitIds as $k_proces_id) {
  81. $last_test = null;
  82. foreach ($testy_arr as $k_ind => $v_test) {
  83. if ($v_test->ID_PROCES_INIT == $k_proces_id) {
  84. $last_test = $v_test;
  85. $last_test->test_ind = $k_ind;
  86. break;
  87. }
  88. }
  89. if (!$last_test || $last_test->TEST_END == '0000-00-00') {
  90. continue;
  91. }
  92. $max_update_date = $this->_acl->getProcesMaxUpdateDate($k_proces_id);
  93. if ($max_update_date) {
  94. $max_update_date = substr($max_update_date, 0, 10);
  95. $test_end = substr($last_test->TEST_END, 0, 10);
  96. DBG::_('DBG_PM', '1', "P_INIT({$k_proces_id}) max_update_date({$max_update_date}) TEST_END({$last_test->TEST_END}) not actual(" . ($max_update_date > $last_test->TEST_END) . ")", $last_test, __CLASS__, __FUNCTION__, __LINE__ );
  97. if ($max_update_date > $test_end) {
  98. $testy_arr[$last_test->test_ind]->unactual = $max_update_date;
  99. $testy_arr[$last_test->test_ind]->unactualId = $last_test->ID;
  100. }
  101. }
  102. }
  103. }
  104. }
  105. $this->_setTestsCache($testy_arr);
  106. }
  107. return $this->_getTestsFromCache();
  108. }
  109. private function _cleanTestsCache() {
  110. $ses_cache_key = "CRM_PROCES_USERA_WYKONANE_TESTY-{$this->_user_id}";
  111. unset($_SESSION[$ses_cache_key]);
  112. }
  113. private function _isTestsInCache() {
  114. $ses_cache_key = "CRM_PROCES_USERA_WYKONANE_TESTY-{$this->_user_id}";
  115. return isset($_SESSION[$ses_cache_key]);
  116. }
  117. private function _getTestsFromCache() {
  118. $ses_cache_key = "CRM_PROCES_USERA_WYKONANE_TESTY-{$this->_user_id}";
  119. return $_SESSION[$ses_cache_key];
  120. }
  121. private function _setTestsCache($tests) {
  122. $ses_cache_key = "CRM_PROCES_USERA_WYKONANE_TESTY-{$this->_user_id}";
  123. $_SESSION[$ses_cache_key] = $tests;
  124. }
  125. function setError($error) {
  126. $this->error[] = $error;
  127. }
  128. function ifError() {// TODO: RMME
  129. if (!empty($this->error)) {
  130. return true;
  131. }
  132. else {
  133. DEBUG_S(-1,'Wydarzyły się błędy uniemożliwiające kontynuacje pracy modułu',$this->error,__FILE__,__FUNCTION__,__LINE__);
  134. die();
  135. return false;
  136. }
  137. }
  138. function showMyTestsAction() {
  139. $this->menuAction();
  140. $userAcl = User::getAcl();
  141. $procesyInitGroup = $this->getUsedProcesInitGroupedList();
  142. if (empty($procesyInitGroup)) {
  143. echo '<p>' . "Brak przypisanych procesów." . '</p>';
  144. return;
  145. }
  146. ?>
  147. <style type="text/css">
  148. .tbl-wyniki-testow {}
  149. .tbl-wyniki-testow td {vertical-align:top;font-size:small;}
  150. .tbl-wyniki-testow .proces-box {padding:0 6px;background:#f00;color:#fff;font-weight:bold;font-family:arial;text-decoration:none}
  151. .tbl-wyniki-testow .proces-title {padding:0 3px;}
  152. .tbl-wyniki-testow .wynik-cell .wyniki-cell-header {height:56px;overflow:hidden;}
  153. .tbl-wyniki-testow .wynik-cell {padding:0 3px;}
  154. .tbl-wyniki-testow .wynik-BRAK_TESTU .proces-box {background-color:silver;}
  155. .tbl-wyniki-testow .wynik-BRAK_PYTAN .proces-box {background-color:#51B7D5;}
  156. .tbl-wyniki-testow .wynik-DOBRY .proces-box {background-color:lightgreen;}
  157. .tbl-wyniki-testow .wynik-DOSTATECZNY .proces-box {background-color:#FFFFB1; color:#777;}
  158. .tbl-wyniki-testow .wynik-NIEDOSTATECZNY .proces-box {background-color:#FC5151;}
  159. .tbl-wyniki-testow .wynik-IDEALNY .proces-box {background-color:gold;}
  160. .tbl-wyniki-testow .wynik-NIEAKTUALNY .proces-box {background-color:silver;}
  161. </style>
  162. <div class="container" style="margin-top:10px;">
  163. <form action="" method="post" class="inline-form">
  164. <input type="hidden" name="_CLEAN_CACHE" value="1">
  165. <button type="submit" class="btn btn-xs btn-warning pull-right">odśwież</button>
  166. </form>
  167. </div>
  168. <?php foreach ($procesyInitGroup as $vProcesGroup) : ?>
  169. <div class="container tbl-wyniki-testow page-header">
  170. <h3>
  171. <?php echo $vProcesGroup->label; ?>
  172. <?php if ($vProcesGroup->nr > 0) : ?>
  173. <small><a href="procesy5.php?task=CRM_PROCES&filtr_id=<?php echo $vProcesGroup->nr; ?>">{<?php echo $vProcesGroup->nr; ?>}</a></small>
  174. <?php endif; ?>
  175. </h3>
  176. </div>
  177. <div class="container tbl-wyniki-testow">
  178. <div class="row">
  179. <?php $i = 0; foreach ($vProcesGroup->sub as $proces_id => $proces_desc) : ?>
  180. <?php
  181. $wynik_teoretyczny = $this->get_ocena_testu($proces_id, 'TEORETYCZNY');
  182. $wynik_teoretyczny_value = $this->get_ocena_testu_value($proces_id, 'TEORETYCZNY');
  183. if ($wynik_teoretyczny == 'BRAK_PYTAN') {
  184. $wynik_teoretyczny_value = '';
  185. }
  186. $wynik_praktyczny = $this->get_ocena_testu($proces_id, 'PRAKTYCZNY');
  187. $wynik_unactual = $this->isTestUnactual($proces_id, 'TEORETYCZNY');
  188. ?>
  189. <div class="col-md-3 wynik-cell wynik-<?php echo $wynik_teoretyczny; ?>">
  190. <div class="panel panel-default">
  191. <div class="panel-heading">
  192. <span data-toggle="tooltip" title="<?php echo $proces_desc; ?>"><?php echo V::strShortUtf8($proces_desc, 80); ?></span>
  193. <a href="procesy5.php?task=PROCES_VIEW&id_proces=<?php echo $proces_id; ?>" title="zobacz instrukcję do procesu <?php echo $proces_id; ?>" target="_blank">{<?php echo $proces_id; ?>}</a>
  194. </div>
  195. <div class="panel-body">
  196. <li>
  197. <?php if ($userAcl->getPermsFiltrProcesId() == $proces_id) : ?>
  198. <b><a href="index.php?FUNCTION_INIT=MENU_SELECT_PROCES&_action=setPermsAll"> Wyłącz filtr uprawnien dla </a></b>
  199. <?php else : ?>
  200. <a href="index.php?FUNCTION_INIT=MENU_SELECT_PROCES&_action=setPermsByProces&id_proces=<?php echo $proces_id; ?>"> Uruchom filtr uprawnien dla </a>
  201. <?php endif; ?>
  202. <?php echo $proces_id; ?>
  203. </li>
  204. <?php if (!in_array($wynik_teoretyczny, array('DOBRY', 'IDEALNY')) || $wynik_unactual) : ?>
  205. <li>
  206. <a href="procesy5.php?task=CRM_TESTY__ADD_TEST&proces_id=<?php echo $proces_id; ?>&test_type=TEORETYCZNY"> Wykonaj test teoretyczny dla </a>
  207. <?php echo $proces_id; ?>
  208. </li>
  209. <?php endif; ?>
  210. <li>Test teoretyczny: <span class="proces-box"><?php echo $wynik_teoretyczny; ?>
  211. <?php if ($wynik_teoretyczny_value) : ?> <em>(<?php echo $wynik_teoretyczny_value; ?>)</em><?php endif; ?>
  212. </span>
  213. </li>
  214. <li class="wynik-<?php echo $wynik_praktyczny; ?>">Test praktyczny: <?php echo $wynik_praktyczny; ?></li>
  215. <?php if ($wynik_unactual) : ?>
  216. <div class="alert alert-danger">
  217. <b>Uwaga! Test nieaktualny:</b>
  218. <?php if ($wynik_unactual->unactualId) : ?>
  219. <a class="btn btn-xs btn-primary" href="procesy5.php?task=CRM_TESTY__ADD_TEST&function_init=fun_CRM_TESTY__ADD_FIX&test_id=<?php echo $wynik_unactual->unactualId; ?>">popraw</a>
  220. <?php endif; ?>
  221. <br /><?php echo $wynik_unactual->TEST_END; ?> - zakończenie testu
  222. <br /><?php echo $wynik_unactual->unactual; ?> - ostatnia zmiana w procesie
  223. </div>
  224. <?php endif; ?>
  225. </div>
  226. </div>
  227. </div>
  228. <?php if (++$i >= 4) : $i = 0; ?>
  229. </div><div class="row">
  230. <?php endif; ?>
  231. <?php endforeach; ?>
  232. </div>
  233. </div>
  234. <?php endforeach; ?>
  235. <script>
  236. jQuery(document).ready(function() {
  237. jQuery('[data-toggle="tooltip"]').tooltip();
  238. });
  239. </script>
  240. <?php
  241. SE_Layout::dol();
  242. exit;
  243. }
  244. private function getUsedProcesInitGroupedList() {
  245. $procesyInitGroup = array();
  246. $procesyInitList = $this->_acl->getUserProcesInitList();
  247. if (empty($procesyInitList)) {
  248. return;
  249. }
  250. $sqlProcesyInitIds = implode(",", array_keys($procesyInitList));
  251. $sql = "select p.`ID`, p.`PARENT_ID`, pp.`DESC` as pp__DESC
  252. from `CRM_PROCES` as p
  253. join `CRM_PROCES` as pp on(pp.`ID`=p.`PARENT_ID`)
  254. where p.`ID` in({$sqlProcesyInitIds})
  255. ";
  256. $groupedProcesyInit = array();
  257. $db = DB::getDB();
  258. $res = $db->query($sql);
  259. while ($r = $db->fetch($res)) {
  260. if (!array_key_exists($r->PARENT_ID, $procesyInitGroup)) {
  261. $procesyInitGroup[$r->PARENT_ID] = (object)array('nr'=>$r->PARENT_ID, 'label'=>$r->pp__DESC, 'sub'=>array());
  262. }
  263. $procesyInitGroup[$r->PARENT_ID]->sub[$r->ID] = $procesyInitList[$r->ID];
  264. $groupedProcesyInit[] = $r->ID;
  265. }
  266. $ungroupedProcesyInit = array_diff(array_keys($procesyInitList), $groupedProcesyInit);
  267. if (!empty($ungroupedProcesyInit)) {
  268. $procesyInitGroup[$r->PARENT_ID] = (object)array('nr'=>null, 'label'=>"Pozostałe", 'sub'=>array());
  269. foreach ($ungroupedProcesyInit as $nr) {
  270. $procesyInitGroup[$r->PARENT_ID]->sub[$nr] = $procesyInitList[$nr];
  271. }
  272. }
  273. return $procesyInitGroup;
  274. }
  275. function menuAction() {
  276. $testy_teoretyczne = $this->get_actual_tests_count('TEORETYCZNY');
  277. $testy_praktyczne = $this->get_actual_tests_count('PRAKTYCZNY');
  278. $procesy_init_arr = $this->_acl->getUserProcesInitIds();
  279. $proces_cnt = count($procesy_init_arr);
  280. $testy_ok = $this->get_actual_tests_count();
  281. $MojeTestyTitle = "Ilość Procesów: {$proces_cnt}, Aktualnych testów: {$testy_ok}, Teoretycznych: {$testy_teoretyczne}, Praktycznych: {$testy_praktyczne}";
  282. $userAcl = User::getAcl();
  283. $tbls = [];
  284. $urls = [];
  285. $outUrls = array();
  286. $outMenus = array();// typeName => label (order by label)
  287. $typeNameToIdZasob = array();// $typeName => $idZasob
  288. if ($userAcl->getPermsFiltrProcesId()) { // TODO: fetch menu from ajax - fix menuStore
  289. $tbls = $userAcl->getTablesAcl();
  290. $urls = $userAcl->getUrls();
  291. if (!empty($urls)) {
  292. foreach ($urls as $kZasobID => $vTitle) {
  293. $outUrls[$kZasobID] = $vTitle;
  294. }
  295. }
  296. asort($outUrls);
  297. $rawOutMenus = array();
  298. $labelsOutMenus = array();
  299. $outBtnsMenus = array();
  300. // DBG::nicePrint($tbls, '$tbls');
  301. if (!empty($tbls)) {
  302. foreach ($tbls as $kZasobID => $vTblAcl) {
  303. if (null == $vTblAcl) continue;
  304. $tblName = $vTblAcl->getName();
  305. $typeName = "p5_default_db:{$tblName}";
  306. $labelsOutMenus[$typeName] = $vTblAcl->getLongLabel(); // TODO: legacy
  307. $rawOutMenus[$typeName] = strtolower($vTblAcl->getLongRawLabel());
  308. $typeNameToIdZasob[$typeName] = $kZasobID;
  309. // if ($userAcl->getPermsFiltrProcesId()) {
  310. $outBtnsMenus[$typeName] = $vTblAcl->getRawLabel();
  311. // }
  312. }
  313. }
  314. asort($rawOutMenus);
  315. foreach ($rawOutMenus as $typeName => $rawLongLabel) $outMenus[$typeName] = $labelsOutMenus[$typeName]; // TODO: mv to localStorage
  316. if ($userAcl->getPermsFiltrProcesId()) {
  317. asort($outBtnsMenus);
  318. }
  319. }
  320. $active = '';
  321. $script_name = V::get('SCRIPT_NAME', '', $_SERVER);
  322. if (false !== strpos($script_name, 'index.php')) {
  323. $route = V::get('_route', '', $_GET);
  324. if (!empty($route)) {
  325. if ('p5_default_db:KONTAKTY_view' == V::get('typeName', '', $_GET)) $active = 'kontakty';
  326. else if ('default_db/KONTAKTY_view' == V::get('namespace', '', $_GET)) $active = 'kontakty';
  327. } else {
  328. $menu_init = V::get('MENU_INIT', '', $_GET);
  329. switch ($menu_init) {
  330. case 'VIEWTABLE_AJAX': $active = 'menu'; break;
  331. default: {
  332. $fun_init = V::get('FUNCTION_INIT', '', $_GET);
  333. switch ($fun_init) {
  334. case 'MENU_SELECT_PROCES': $active = 'testy'; break;
  335. case 'PRZYPOMNIJ_FUNC': $active = 'przypomnij'; break;
  336. case 'PRZYPOMNIJ': $active = 'przypomnij'; break;
  337. default:
  338. }
  339. }
  340. }
  341. }
  342. }
  343. else if (false !== strpos($script_name, 'procesy5.php')) {
  344. $task = V::get('task', '', $_GET);
  345. switch ($task) {
  346. case 'CRM_PROCES': $active = 'procesy'; break;
  347. case 'CRM_LISTA_ZASOBOW': $active = 'zasoby'; break;
  348. case 'CRM_WYSWIETL_OBOWIAZKI': $active = 'obowiazki'; break;
  349. case 'CRM_TESTY': $active = 'testy'; break;
  350. case 'CRM_TESTY_WYNIKI': $active = 'testy'; break;
  351. case 'CRM_TESTY__LIST': $active = 'testy'; break;
  352. case 'CRM_TESTY__ADD_TEST': $active = 'testy'; break;
  353. case 'CRM_TESTY__ADD_KANDYDAT': $active = 'testy'; break;
  354. case 'CRM_SEARCH': $active = 'search'; break;
  355. default:
  356. // testy_moje ?FUNCTION_INIT=MENU_SELECT_PROCES&MENU_SELECT_PROCES=show_menu_with_process => _action=showMyTests
  357. }
  358. }
  359. /*
  360. * $_SESSION['USER_PROFILE'][section][key] = val;
  361. */
  362. $userGroupIdsCSV = User::getGroupsIds();
  363. $userGroupIdsCSV = implode(',', $userGroupIdsCSV);
  364. $typeSpecialUserId = null;
  365. if (User::isAdmin()) {
  366. $typeSpecialUserId = TypespecialVariable::getInstance(-1, '__USER_ID');
  367. }
  368. $typeSpecialZasob = TypespecialVariable::getInstance(-1, '__ZASOB');
  369. $treeZasobyFilter = FilterFactory::build('CRM_LISTA_ZASOBOW');
  370. $lastZasobyFiltrIds = $treeZasobyFilter->get_arg('filtr_id');
  371. $typeSpecialProces = TypespecialVariable::getInstance(-1, '__PROCES');
  372. $treeProcesyFilter = FilterFactory::build('CRM_PROCES');
  373. $lastProcesyFiltrIds = $treeProcesyFilter->get_arg('filtr_id');
  374. $menuProcesViewedTblId = 0;
  375. $menuProcesViewedAclIsObject = false;
  376. if ('ViewTableAjax' == V::get('_route', '', $_REQUEST)) {
  377. $namespace = V::get('namespace', '', $_REQUEST, 'word');
  378. if (!$namespace) {
  379. $typeName = V::get('typeName', '', $_REQUEST, 'word');
  380. if ($typeName) {
  381. $namespace = str_replace(['__x3A__', ':'], '/', $typeName);
  382. }
  383. }
  384. if ($namespace) {
  385. $menuProcesViewedAclIsObject = (
  386. 'default_db/' === substr($namespace, 0, strlen('default_db/'))
  387. && strpos(substr($namespace, strlen('default_db/')), '/') > 0
  388. );
  389. $zasobTableName = (
  390. 'default_db/' === substr($namespace, 0, strlen('default_db/'))
  391. && false === strpos(substr($namespace, strlen('default_db/')), '/')
  392. )
  393. ? substr($namespace, strlen('default_db/'))
  394. : $namespace;
  395. if ($zasobTableName) {
  396. $dbID = DB::getPDO()->getZasobId();
  397. $menuProcesViewedTblId = DB::getPDO()->fetchValue("
  398. select z.ID
  399. from CRM_LISTA_ZASOBOW z
  400. where z.`DESC` = '{$zasobTableName}'
  401. and z.A_STATUS not in ('DELETED')
  402. and z.`TYPE` = 'TABELA'
  403. and z.PARENT_ID = '{$dbID}'
  404. ");
  405. }
  406. }
  407. }
  408. else if ('VIEWTABLE_AJAX' == V::get('MENU_INIT', '', $_REQUEST)) {
  409. $menuProcesViewedTblId = V::get('ZASOB_ID', 0, $_REQUEST, 'int');
  410. }
  411. ?>
  412. <nav id="SE-menu" class="navbar-nav navbar-inverse" style="width:100%">
  413. <div class="container-fluid">
  414. <div class="collapse navbar-collapse">
  415. <ul class="nav navbar-nav">
  416. <?php
  417. echo UI::h('li', [ 'class' => "dropdown" . ($active == 'menu' ? ' active' : '') ], [
  418. UI::h('a',
  419. ($userAcl->getPermsFiltrProcesId())
  420. ? [
  421. 'href' => "#",
  422. 'class' => "dropdown-toggle",
  423. 'data-toggle' => "dropdown",
  424. ]
  425. : [
  426. 'href' => "#",
  427. 'class' => "dropdown-toggle",
  428. 'onClick' => "return initP5MainMenuDropdown(this, 'SE-menu-tables');",
  429. ],
  430. "Menu ". '<b class="caret"></b>'
  431. ),
  432. UI::h('ul', [
  433. 'class' => "dropdown-menu",
  434. 'id' => "SE-menu-tables",
  435. ], array_map(function ($vName, $typeName) use ($typeNameToIdZasob) {
  436. $kZasobID = $typeNameToIdZasob[$typeName];
  437. return UI::h('li', [], [
  438. UI::h('a', ['href'=>"index.php?_route=ViewTableAjax&typeName={$typeName}"], [
  439. UI::h('i', ['class'=>"bookmark-item-add glyphicon glyphicon-star-empty", 'title'=>"Add to favorites", 'data-zasobid'=>$kZasobID]),
  440. UI::h('i', ['class'=>"bookmark-item-rem glyphicon glyphicon-star", 'style'=>"display:none", 'title'=>"Remove from favorites", 'data-zasobid'=>$kZasobID]),
  441. " " . $vName
  442. ])
  443. ]);
  444. }, array_values($outMenus), array_keys($outMenus))),
  445. ]);
  446. echo UI::h('li', [ 'class' => "dropdown"], [
  447. UI::h('a',
  448. ($userAcl->getPermsFiltrProcesId())
  449. ? [
  450. 'href' => "#",
  451. 'class' => "dropdown-toggle",
  452. 'data-toggle' => "dropdown",
  453. ]
  454. : [
  455. 'href' => "#",
  456. 'class' => "dropdown-toggle",
  457. 'onClick' => "return initP5UrlsMenuDropdown(this, 'SE-menu-urls');",
  458. ],
  459. "Narzędzia " . '<b class="caret"></b>'
  460. ),
  461. UI::h('ul', [
  462. 'class' => "dropdown-menu",
  463. 'id' => "SE-menu-urls"
  464. ], array_map(function ($label, $idZasob) {
  465. return UI::h('li', [], [
  466. UI::h('a', [ 'href' => "index.php?FUNCTION_INIT=URL_INIT&ZASOB_ID={$idZasob}", 'target' => "_blank", 'title' => $label ], [
  467. UI::h('i', [ 'class' => "bookmark-item-add glyphicon glyphicon-star-empty", 'title' => "Add to favorites", 'data-zasobid' => $idZasob ]),
  468. UI::h('i', [ 'class' => "bookmark-item-rem glyphicon glyphicon-star", 'style' => "display:none", 'title' => "Remove from favorites", 'data-zasobid' => $idZasob ]),
  469. UI::h('code', [ 'style' => "margin-left:6px; margin-right:6px" ], (string)$idZasob),
  470. (mb_strlen($label, 'utf-8') > 100)? mb_substr($label, 0, 100, 'utf-8') . '...' : $label,
  471. ]),
  472. ]);
  473. }, array_values($outUrls), array_keys($outUrls))),
  474. ]);
  475. ?>
  476. <li class="dropdown <?php if ($active == 'procesy') echo "active"; ?>">
  477. <a id="ProcesMenuProcesDropdownLink" href="#" class="dropdown-toggle" data-toggle="dropdown">Procesy <b class="caret"></b></a>
  478. <ul class="dropdown-menu">
  479. <?php if (!empty($lastProcesyFiltrIds)) : ?>
  480. <li>
  481. <p class="text-muted" style="padding:3px 20px;"><nobr>Wróć do ostatniego wyszukiwania:</nobr></p>
  482. <a href="procesy5.php?task=CRM_PROCES<?php echo "&filtr_id={$lastProcesyFiltrIds}&filtr_ids=%2B&filtr_ob=%2B&filtr_img=%2B"; ?>"><?php
  483. //echo $lastProcesyFiltrIdsLabels;
  484. if (!empty($lastProcesyFiltrIds)) {
  485. $lastProcesyFiltrIds = explode(',', $lastProcesyFiltrIds);
  486. $labels = array();
  487. $labelsLimit = 4;
  488. $labelsInd = 0;
  489. foreach ($lastProcesyFiltrIds as $lastFltr) {
  490. $labels[] = '<span class="label label-info">' . $lastFltr . '</span>';
  491. if (++$labelsInd >= $labelsLimit) {
  492. $labels[] = '...';
  493. break;
  494. }
  495. }
  496. $lastProcesyFiltrIdsLabels = implode(' ', $labels);
  497. }
  498. echo $lastProcesyFiltrIdsLabels;
  499. ?></a>
  500. </li>
  501. <li class="divider"></li>
  502. <?php endif; ?>
  503. <li>
  504. <a href="index.php?FUNCTION_INIT=PROCES_MENU&HEADER_NOT_INIT=YES&_task=PROCES_FOR_USER" title="Moje Procesy">Moje Procesy</a>
  505. </li>
  506. <?php if ($menuProcesViewedTblId > 0) : ?>
  507. <li>
  508. <a href="index.php?FUNCTION_INIT=PROCES_MENU&HEADER_NOT_INIT=YES&_task=PROCES_FOR_TABLE&tblId=<?php echo $menuProcesViewedTblId; ?>">Procesy dla aktualnie przeglądanej tabeli</a>
  509. </li>
  510. <?php endif; ?>
  511. <li>
  512. <a href="procesy5.php?task=CRM_PROCES&filtr_id=" title="Wyświetlenie drzewa procesów">Wszystkie Procesy</a>
  513. </li>
  514. <?php if (0 == User::get('ADM_ADMIN_LEVEL')) : ?>
  515. <li>
  516. <a href="index.php?_route=UrlAction_ProcesView" title="Wyświetlenie drzewa procesów w formie panelowej i w formie drzewa">Procesy - <i style="color:red">NOWE</i> <i><small>(wersja testowa)</small></i></a>
  517. </li>
  518. <?php endif; ?>
  519. <li class="divider"></li>
  520. <?php if (!$typeSpecialProces) : ?>
  521. <li>
  522. <div class="alert alert-danger">Brak typespecial __PROCES</div>
  523. </li>
  524. <?php else : ?>
  525. <li>
  526. <p class="text-muted" style="padding:3px 20px;"><nobr>Wyszukaj:</nobr></p>
  527. <form id="ProcesMenuProcesFrm" action="procesy5.php" method="GET" style="padding:0 20px">
  528. <input type="hidden" name="task" value="CRM_PROCES">
  529. <?php
  530. $fldName = 'ProcesMenu__Proces_filtr_id';
  531. $fldParams = array();
  532. $fldParams['allowCreate'] = false;
  533. $fldParams['ajaxDataUrlBase'] = "index.php?FUNCTION_INIT=PROCES_MENU&HEADER_NOT_INIT=YES&_task=TYPESPECIAL&fld={$fldName}";
  534. $fldParams['placeholder'] = 'Szukaj...';
  535. $fldParams['formFieldName'] = 'filtr_id';
  536. //$fldParams['ajaxDataUrlBase'] .= "&DBG_TS=3";
  537. echo $typeSpecialProces->showFormItem($tblID = -1, $fldName, $selValue = '', $fldParams);
  538. ?>
  539. <input class="btn btn-xs btn-primary" type="submit" value="Wybierz" />
  540. <input class="pull-right btn btn-xs btn-default" type="submit" id="ProcesMenuProcesFltrAdd" value="Dodaj do filtra" />
  541. <script>
  542. jQuery(document).ready(function() {
  543. if ('procesy5.php' === window.location.pathname.substr(-12)
  544. && window.location.search.search('task=CRM_PROCES') > 0
  545. && window.location.search.search('&filtr_id=') > 0
  546. ) {
  547. jQuery('#ProcesMenuProcesFltrAdd').on('click', function(e) {
  548. var frm = jQuery(this).get(0).form;
  549. var fldNode = frm['<?php echo $fldParams['formFieldName']; ?>'],
  550. fltrId = '';
  551. if (fldNode && '' != fldNode.value) {
  552. fltrId = fldNode.value;
  553. } else {
  554. return;
  555. }
  556. var pos = 0, fltrIds = '';
  557. if ('procesy5.php' === window.location.pathname.substr(-12)
  558. && window.location.search.search('task=CRM_PROCES') > 0
  559. && (pos = window.location.search.search('&filtr_id=')) > 0
  560. ) {
  561. pos += 10;
  562. fltrIds = window.location.search.substr(pos);
  563. if ((pos = fltrIds.search('&')) > 0) {
  564. fltrIds = fltrIds.substr(0, pos);
  565. }
  566. if (fltrIds) {
  567. fltrIds = decodeURIComponent(fltrIds);
  568. fltrIds += ',' + fltrId;
  569. if (fldNode.selectize) {
  570. fldNode.selectize.addOption({id: fltrIds, name: fltrIds});
  571. fldNode.selectize.setValue(fltrIds, true);
  572. }
  573. }
  574. }
  575. });
  576. } else {
  577. jQuery('#ProcesMenuProcesFltrAdd').hide();
  578. }
  579. jQuery('#ProcesMenuProcesFrm').on('submit', function(e) {
  580. var frm = jQuery(this).get(0),
  581. fldNode = frm['<?php echo $fldParams['formFieldName']; ?>'];
  582. if (fldNode && '' != fldNode.value) {
  583. return true;
  584. } else {
  585. return false;
  586. }
  587. });
  588. jQuery('#ProcesMenuProcesDropdownLink').on('click', function(e) {
  589. setTimeout(function(){
  590. jQuery('#ts-<?php echo $fldName; ?>')
  591. .next('.selectize-control')
  592. .find('input:first')
  593. .focus();
  594. }, 200);
  595. });
  596. });
  597. </script>
  598. </form>
  599. </li>
  600. <?php endif; ?>
  601. </ul>
  602. </li>
  603. <li class="dropdown <?php if ($active == 'zasoby') echo "active"; ?>">
  604. <a id="ProcesMenuZasobDropdownLink" href="#" class="dropdown-toggle" data-toggle="dropdown">Zasoby <b class="caret"></b></a>
  605. <ul class="dropdown-menu">
  606. <?php if (!empty($lastZasobyFiltrIds)) : ?>
  607. <li>
  608. <p class="text-muted" style="padding:3px 20px;"><nobr>Wróć do ostatniego wyszukiwania:</nobr></p>
  609. <a href="procesy5.php?task=CRM_LISTA_ZASOBOW<?php echo "&filtr_id={$lastZasobyFiltrIds}&filtr_ids=%2B&filtr_ob=%2B&filtr_img=%2B"; ?>"><?php
  610. //echo $lastZasobyFiltrIdsLabels;
  611. if (!empty($lastZasobyFiltrIds)) {
  612. $lastZasobyFiltrIds = explode(',', $lastZasobyFiltrIds);
  613. $labels = array();
  614. $labelsLimit = 4;
  615. $labelsInd = 0;
  616. foreach ($lastZasobyFiltrIds as $lastFltr) {
  617. $labels[] = '<span class="badge badge-inverse">' . $lastFltr . '</span>';
  618. if (++$labelsInd >= $labelsLimit) {
  619. $labels[] = '...';
  620. break;
  621. }
  622. }
  623. $lastZasobyFiltrIdsLabels = implode(' ', $labels);
  624. }
  625. echo $lastZasobyFiltrIdsLabels;
  626. ?></a>
  627. </li>
  628. <li class="divider"></li>
  629. <?php endif; ?>
  630. <?php if (!empty($userGroupIdsCSV)) : ?>
  631. <li>
  632. <a href="procesy5.php?task=CRM_LISTA_ZASOBOW<?php echo "&filtr_id={$userGroupIdsCSV}&filtr_ids=%2B&filtr_ob=%2B&filtr_img=%2B"; ?>" title="Moje Zasoby">Moje Zasoby</a>
  633. </li>
  634. <?php endif; ?>
  635. <?php if ($menuProcesViewedTblId > 0) : ?>
  636. <li>
  637. <a href="procesy5.php?task=CRM_LISTA_ZASOBOW&filtr_id=<?= $menuProcesViewedTblId; ?>&filtr_ids=%2B&filtr_ob=%2B">Struktura aktualnie przeglądanej tabeli</a>
  638. </li>
  639. <?php endif; ?>
  640. <?php if ($menuProcesViewedTblId > 0 && User::get('ADM_ADMIN_LEVEL') < 2 && $menuProcesViewedAclIsObject) : ?>
  641. <li>
  642. <a href="index.php?_route=Storage_AclStruct&namespace=<?= $namespace; ?>">Struktura aktualnie przeglądanego obiektu (Storage)</a>
  643. </li>
  644. <?php endif; ?>
  645. <li>
  646. <a href="procesy5.php?task=CRM_LISTA_ZASOBOW&filtr_id=" title="Wyświetlenie drzewa zasobów">Wszystkie Zasoby</a>
  647. </li>
  648. <li class="divider"></li>
  649. <?php if (!$typeSpecialZasob) : ?>
  650. <li>
  651. <div class="alert alert-danger">Brak typespecial __ZASOB</div>
  652. </li>
  653. <?php else : ?>
  654. <li>
  655. <p class="text-muted" style="padding:3px 20px;"><nobr>Wyszukaj:</nobr></p>
  656. <form id="ProcesMenuZasobFrm" action="procesy5.php" method="GET" style="padding:0 20px">
  657. <input type="hidden" name="task" value="CRM_LISTA_ZASOBOW">
  658. <?php
  659. $fldName = 'ProcesMenu__Zasob_filtr_id';
  660. $fldParams = array();
  661. $fldParams['allowCreate'] = false;
  662. $fldParams['ajaxDataUrlBase'] = "index.php?FUNCTION_INIT=PROCES_MENU&HEADER_NOT_INIT=YES&_task=TYPESPECIAL&fld={$fldName}";
  663. $fldParams['placeholder'] = 'Szukaj...';
  664. $fldParams['formFieldName'] = 'filtr_id';
  665. //$fldParams['ajaxDataUrlBase'] .= "&DBG_TS=3";
  666. echo $typeSpecialZasob->showFormItem($tblID = -1, $fldName, $selValue = '', $fldParams);
  667. ?>
  668. <input class="btn btn-xs btn-primary" type="submit" value="Wybierz" />
  669. <input class="pull-right btn btn-xs btn-default" type="submit" id="ProcesMenuZasobFltrAdd" value="Dodaj do filtra" />
  670. <script>
  671. jQuery(document).ready(function() {
  672. if ('procesy5.php' === window.location.pathname.substr(-12)
  673. && window.location.search.search('task=CRM_LISTA_ZASOBOW') > 0
  674. && window.location.search.search('&filtr_id=') > 0
  675. ) {
  676. jQuery('#ProcesMenuZasobFltrAdd').on('click', function(e) {
  677. var frm = jQuery(this).get(0).form;
  678. var fldNode = frm['<?php echo $fldParams['formFieldName']; ?>'],
  679. fltrId = '';
  680. if (fldNode && '' != fldNode.value) {
  681. fltrId = fldNode.value;
  682. } else {
  683. return;
  684. }
  685. var pos = 0, fltrIds = '';
  686. if ('procesy5.php' === window.location.pathname.substr(-12)
  687. && window.location.search.search('task=CRM_LISTA_ZASOBOW') > 0
  688. && (pos = window.location.search.search('&filtr_id=')) > 0
  689. ) {
  690. pos += 10;
  691. fltrIds = window.location.search.substr(pos);
  692. if ((pos = fltrIds.search('&')) > 0) {
  693. fltrIds = fltrIds.substr(0, pos);
  694. }
  695. if (fltrIds) {
  696. fltrIds = decodeURIComponent(fltrIds);
  697. fltrIds += ',' + fltrId;
  698. if (fldNode.selectize) {
  699. fldNode.selectize.addOption({id: fltrIds, name: fltrIds});
  700. fldNode.selectize.setValue(fltrIds, true);
  701. }
  702. }
  703. }
  704. });
  705. } else {
  706. jQuery('#ProcesMenuZasobFltrAdd').hide();
  707. }
  708. jQuery('#ProcesMenuZasobFrm').on('submit', function(e) {
  709. var frm = jQuery(this).get(0),
  710. fldNode = frm['<?php echo $fldParams['formFieldName']; ?>'];
  711. if (fldNode && '' != fldNode.value) {
  712. return true;
  713. } else {
  714. return false;
  715. }
  716. });
  717. jQuery('#ProcesMenuZasobDropdownLink').on('click', function(e) {
  718. setTimeout(function(){
  719. jQuery('#ts-<?php echo $fldName; ?>')
  720. .next('.selectize-control')
  721. .find('input:first')
  722. .focus();
  723. }, 200);
  724. });
  725. });
  726. </script>
  727. </form>
  728. </li>
  729. <?php endif; ?>
  730. </ul>
  731. </li>
  732. <li<?php if ($active == 'obowiazki') echo ' class="active"'; ?>><a href="procesy5.php?task=CRM_WYSWIETL_OBOWIAZKI" title="Wyswietlenie OBOWIAZKOW">Obowiązki</a></li>
  733. <li class="dropdown <?php if ($active == 'testy') echo "active"; ?>">
  734. <a href="#" class="dropdown-toggle" data-toggle="dropdown">Testy (<?php echo "{$testy_ok} z {$proces_cnt}: T {$testy_teoretyczne}, P {$testy_praktyczne}"; ?>) <b class="caret"></b></a>
  735. <ul class="dropdown-menu">
  736. <li>
  737. <a href="index.php?_route=UserTest" title="<?php echo $MojeTestyTitle; ?>">Moje (<?php echo "{$testy_ok} z {$proces_cnt}: T {$testy_teoretyczne}, P {$testy_praktyczne}"; ?>)</a>
  738. </li>
  739. <?php if (User::hasAccess('testy')) : ?>
  740. <li>
  741. <a href="procesy5.php?task=CRM_TESTY__LIST">Lista testów</a>
  742. </li>
  743. <li>
  744. <a href="procesy5.php?task=CRM_TESTY__ADD_TEST">Uruchom nowy test</a>
  745. </li>
  746. <?php endif; ?>
  747. <?php if (User::hasAccess('procesy') || User::get('ADM_ADMIN_LEVEL') <= 2) : ?>
  748. <li class="divider"></li>
  749. <?php endif; ?>
  750. <?php if (User::hasAccess('procesy')) : ?>
  751. <li>
  752. <a href="procesy5.php?task=CRM_TESTY__ADD_KANDYDAT">Dodaj Kandydata i zaloguj się do testów</a>
  753. </li>
  754. <?php endif; ?>
  755. <?php if (User::get('ADM_ADMIN_LEVEL') <= 2) : ?>
  756. <li>
  757. <a href="procesy5.php?task=CRM_TESTY_WYNIKI" title="Wyswietlenie wyników testów">Wyniki</a>
  758. </li>
  759. <?php endif; ?>
  760. </ul>
  761. </li>
  762. <li<?= ('kontakty' == $active) ? ' class="active"' : ''; ?>><a href="index.php?_route=ViewTableAjax&namespace=default_db/KONTAKTY_view" title="Kontakty">Kontakty</a></li>
  763. <li<?= ('przypomnij' == $active) ? ' class="active"' : ''; ?>><a href="index.php?_route=Przypomnij&KTO=<?php echo User::getLogin(); ?>" title="Przypomnij">Przypomnij</a></li>
  764. </ul>
  765. <form class="navbar-form navbar-left" style="margin:3px 0;" role="search" action="procesy5.php?task=CRM_SEARCH" method="post">
  766. <div class="input-group">
  767. <input type="text" class="form-control input-sm" placeholder="Szukaj..." name="q">
  768. <span class="input-group-btn">
  769. <button class="btn btn-default btn-sm" type="submit"><i class="glyphicon glyphicon-search"></i></button>
  770. </span>
  771. </div><!-- /input-group -->
  772. </form>
  773. <div class="navbar-form navbar-right">
  774. <div class="btn-group">
  775. <button type="button" class="btn btn-link" style="margin:0; padding:6px 8px 4px 8px;"><?php S::show_session_timer(); ?></button>
  776. <a href="index.php?_route=UserMsgs" class="btn btn-link" style="margin:0; padding:6px 8px 0 8px; font-size:20px; line-height:24px;"><i class="glyphicon glyphicon-envelope"></i></a>
  777. <div class="btn-group">
  778. <button id="ProcesMenuLoginDropdownLink" type="button" class="btn btn-link dropdown-toggle" data-toggle="dropdown" aria-expanded="false"><?php echo User::getName(); ?> <span class="caret"></span></button>
  779. <ul class="dropdown-menu" role="menu">
  780. <?php if (file_exists('/Library/Server/Web/Data/Sites/Default/')) : ?>
  781. <li><a href="/webcal" target="_blank"><i class="glyphicon glyphicon-calendar"></i> Kalendarz</a></li>
  782. <?php if (file_exists('/Library/Server/Web/Data/Sites/Default/webmail/loginFromSE.php')) : ?>
  783. <li>
  784. <a href="/webmail">
  785. <form action="https://<?php echo $_SERVER['SERVER_NAME']; ?>/webmail/loginFromSE.php" method="post" target="_blank">
  786. <input type="hidden" name="_timezone" value="Europe/Berlin">
  787. <input type="hidden" name="_token" value="">
  788. <input type="hidden" name="_action" value="login">
  789. <input type="hidden" name="_task" value="login">
  790. <input type="hidden" name="_url" value="">
  791. <input type="hidden" name="_user" value="<?php echo User::getName(); ?>">
  792. <input type="hidden" name="_pass" value="<?php echo User::get('ADM_PASS_HASH'); ?>">
  793. <input type="hidden" name="EMAIL_IMAP_IMPORT_USERNAME" value="<?php echo V::get('EMAIL_IMAP_IMPORT_USERNAME', '', $_SESSION); ?>">
  794. <input type="hidden" name="EMAIL_IMAP_IMPORT_HOST" value="<?php echo V::get('EMAIL_IMAP_IMPORT_HOST', '', $_SESSION); ?>">
  795. <input type="hidden" name="EMAIL_IMAP_IMPORT_PASSWD_HASH" value="<?php echo V::get('EMAIL_IMAP_IMPORT_PASSWD_HASH', '', $_SESSION); ?>">
  796. <input type="hidden" name="loginFromSE" value="1">
  797. <!-- <input type="submit" class="btn" value="P"> -->
  798. <button type="submit" class="btn btn-link" style="width:100%;padding:0;text-align:left;color:#333;"><i class="glyphicon glyphicon-envelope"></i> Poczta</button>
  799. </form>
  800. </a>
  801. </li>
  802. <?php elseif (file_exists('/Library/Server/Web/Data/Sites/Default/webmail')) : ?>
  803. <li><a href="/webmail" target="_blank"><i class="glyphicon glyphicon-envelope"></i> Poczta</a></li>
  804. <?php endif; ?>
  805. <li><a href="index.php?_route=ChangePassword"><i class="glyphicon glyphicon-lock"></i> Zmień hasło</a></li>
  806. <li><a href="/profilemanager" target="_blank"><i class="glyphicon glyphicon-user"></i> Apple Profile Manager</a></li>
  807. <li class="divider"></li>
  808. <?php else: ?>
  809. <li><a href="index.php?_route=ChangePassword">Zmień hasło</a></li>
  810. <?php endif; ?>
  811. <li><a href="procesy5.php?task=USER" title="<?php echo User::getName(); ?>"><i class="glyphicon glyphicon-user"></i> Profil</a></li>
  812. <li><a href="index.php?_route=UrlAction_Calendar"><i class="glyphicon glyphicon-calendar"></i> Grafik pracy</a></li>
  813. <li><a href="index.php?_route=UserMsgs" title="Wiadomości systemowe"><i class="glyphicon glyphicon-envelope"></i> Wiadomości</a></li>
  814. <li><a href="index.php?_route=Notify" title="Powiadomienia"><i class="glyphicon glyphicon-bell"></i> Powiadomienia</a></li>
  815. <li><a href="index.php?_route=Users&_task=reloadPerms" title="Przeładuj uprawnienia"><i class="glyphicon glyphicon-refresh"></i> Przeładuj uprawnienia</a></li>
  816. <li class="divider"></li>
  817. <?php if (User::isAdmin()) : ?>
  818. <li><a href="index.php?_route=Status" title="Status systemu"><i class="glyphicon glyphicon-cog"></i> Status systemu</a></li>
  819. <?php endif; ?>
  820. <?php if (User::isAdmin()) : ?>
  821. <?php if (!$typeSpecialUserId) : ?>
  822. <li>
  823. <div class="alert alert-danger">Brak typespecial __USERS_ID</div>
  824. </li>
  825. <?php else : ?>
  826. <li>
  827. <p class="text-muted" style="padding:3px 20px;"><nobr>Pokaż testy pracownika:</nobr></p>
  828. <form action="index.php" method="POST">
  829. <input type="hidden" name="FUNCTION_INIT" value="MENU_SELECT_PROCES">
  830. <input type="hidden" name="_action" value="showMyTests">
  831. <?php
  832. $fldName = '_user_id';
  833. $fldParams = array();
  834. $fldParams['allowCreate'] = false;
  835. $fldParams['ajaxDataUrlBase'] = "index.php?FUNCTION_INIT=PROCES_MENU&HEADER_NOT_INIT=YES&_task=TYPESPECIAL&fld={$fldName}";
  836. $fldParams['placeholder'] = 'Szukaj...';
  837. //$fldParams['ajaxDataUrlBase'] .= "&DBG_TS=3";
  838. echo $typeSpecialUserId->showFormItem($tblID = -1, $fldName, $selValue = '', $fldParams);
  839. ?>
  840. <input class="btn btn-xs btn-warning" type="submit" value="Wybierz" />
  841. <script>
  842. jQuery(document).ready(function() {
  843. jQuery('#ProcesMenuLoginDropdownLink')
  844. .next('.dropdown-menu')
  845. .find('.selectize-input')
  846. .on('click', function(e) {
  847. return false;
  848. });
  849. jQuery('#ProcesMenuLoginDropdownLink').on('click', function(e) {
  850. setTimeout(function(){
  851. jQuery('#ts-<?php echo $fldName; ?>')
  852. .next('.selectize-control')
  853. .find('input:first')
  854. .focus();
  855. }, 200);
  856. });
  857. });
  858. </script>
  859. </form>
  860. </li>
  861. <?php endif; ?>
  862. <li class="divider"></li>
  863. <?php endif; ?>
  864. <li><a href="index.php?LOGIN=LOGOUT"><i class="glyphicon glyphicon-off"></i> Wyloguj</a></li>
  865. </ul>
  866. </div>
  867. </div>
  868. </div>
  869. <!--
  870. <li<?php if ($active == 'search') echo ' class="active"'; ?>>
  871. <form action="procesy5.php?task=CRM_SEARCH" method="post" class="navbar-search">
  872. <input type="text" name="q" value="" class="q search-query span2">
  873. <input type="image" src="icon/search.png" class="s">
  874. </form>
  875. </li>
  876. -->
  877. </div><!-- /.navbar-collapse -->
  878. </nav>
  879. <?php
  880. $idFiltrProcesID = $userAcl->getPermsFiltrProcesId();
  881. if ($idFiltrProcesID > 0) {
  882. echo UI::h('div', [ 'id' => "SE-menu-sub", 'style' => "clear:both;" ], array_merge(
  883. [
  884. 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}"),
  885. ],
  886. array_map(
  887. function ($label, $typeName) {
  888. return UI::h('a', [ 'class' => "btn btn-xs btn-default", 'href' => "index.php?_route=ViewTableAjax&typeName={$typeName}", 'title' => $label ], V::strShortUtf8($label, 20));
  889. }, array_values($outBtnsMenus), array_keys($outBtnsMenus)
  890. ),
  891. array_map(
  892. function ($label, $idZasob) {
  893. return UI::h('a', [ 'class' => "btn btn-xs btn-default", 'href' => "index.php?FUNCTION_INIT=URL_INIT&ZASOB_ID={$idZasob}", 'target' => "_blank", 'title' => $label ], V::strShortUtf8($label, 20));
  894. }, array_values($outUrls), array_keys($outUrls)
  895. )
  896. ));
  897. } else {
  898. echo UI::h('div', [ 'id' => "SE-menu-sub", 'style' => "clear:both" ]);
  899. UI::inlineJS(APP_PATH_WWW . '/static/p5UI/userBookmarks.js');
  900. // url: 'index-ajax.php?_cls=UserBookmarks',
  901. echo UI::h('script', [], "
  902. (function (global) {
  903. jQuery('#SE-menu-sub').UserBookmarks({
  904. url: 'index.php?_route=P5Menu',
  905. store: global.p5UI__MenuStore,
  906. debug: false
  907. });
  908. })(window);
  909. ");
  910. }
  911. echo '</div>';
  912. echo UI::h('script', [], "
  913. (function (global) {
  914. if (!global.p5UI__MenuStore) throw 'Missing global.p5UI__MenuStore'
  915. function p5BookmarksAdd(e, id) {
  916. e.preventDefault()
  917. e.stopPropagation()
  918. global.p5UI__MenuStore.remoteUpdate({
  919. '_postTask': 'addBookmark',
  920. '_zasobID': id,
  921. })
  922. }
  923. function p5BookmarksRemove(e, id) {
  924. e.preventDefault()
  925. e.stopPropagation()
  926. global.p5UI__MenuStore.remoteUpdate({
  927. '_postTask': 'removeBookmark',
  928. '_zasobID': id,
  929. })
  930. }
  931. global.p5BookmarksAdd = p5BookmarksAdd
  932. global.p5BookmarksRemove = p5BookmarksRemove
  933. })(window)
  934. ");
  935. UI::inlineCSS(APP_PATH_WWW . '/static/p5UI/initP5MainMenuDropdown.css');
  936. UI::inlineJS(APP_PATH_WWW . '/static/p5UI/initP5MainMenuDropdown.js');
  937. echo UI::h('script', [], "
  938. (function (global) {
  939. if (!global.p5UI__MenuStore) throw 'Missing global.p5UI__MenuStore'
  940. function initP5UrlsMenuDropdown( btnNode, idSubMenu ) {
  941. if (!btnNode._initialized) {
  942. var jqDropdownTrigger = jQuery(btnNode)
  943. var jqDropdownMenu = jQuery('#' + idSubMenu)
  944. var jqDropdownParent = jqDropdownMenu.parent()
  945. global.p5UI__MenuStore.subscribe(
  946. (function (global, idSubMenu) {
  947. return function renderP5MainMenuDropdown(data) {
  948. var jqDropdownMenu = jQuery('#' + idSubMenu)
  949. jqDropdownMenu.empty()
  950. jqDropdownMenu.append(data.urls.map(function (item) {
  951. var star = (-1 !== data.idsBookmarks.indexOf(item.id))
  952. ? '<i class=\"bookmark-item-rem glyphicon glyphicon-star\" title=\"Usuń z ulubionych\" onClick=\"return p5BookmarksRemove(event, ' + item.id + ')\"></i>'
  953. : '<i class=\"bookmark-item-add glyphicon glyphicon-star-empty\" title=\"Dodaj do ulubionych\" onClick=\"return p5BookmarksAdd(event, ' + item.id + ')\"></i>'
  954. return jQuery('<li>' +
  955. '<a href=\"index.php?FUNCTION_INIT=URL_INIT&ZASOB_ID=' + item.id + '\" target=\"_blank\" title=\"' + item.raw_label + '\">' +
  956. star +
  957. ' ' + '<code>' + item.id + '</code>' +
  958. ' ' + item.label +
  959. '</a>' +
  960. '</li>');
  961. }))
  962. }
  963. })(global, idSubMenu)
  964. )
  965. jqDropdownTrigger.attr('data-toggle', 'dropdown') // is required by bootstrap dorpdown.js evenf if is called via js
  966. global.p5UI__MenuStore.forceUpdate()
  967. jQuery(btnNode).dropdown()
  968. }
  969. btnNode._initialized = true
  970. return true;
  971. }
  972. global.initP5UrlsMenuDropdown = initP5UrlsMenuDropdown
  973. })(window)
  974. ");
  975. echo UI::h('script', [], "
  976. (function (global) {
  977. if (!global.p5UI__MenuStore) throw 'Missing global.p5UI__MenuStore'
  978. if (global.p5UI__MenuStore.hasData()) {
  979. global.p5UI__MenuStore.forceUpdate() // force update all subscribers
  980. } else {
  981. global.p5UI__MenuStore.remoteUpdate() // update from remote url
  982. }
  983. })(window)
  984. ");
  985. }
  986. /**
  987. * Generates wyniki
  988. */
  989. private function _generateTestResults() {
  990. $this->_wynik_testu = array();// WYNIK_TESTU_PROCESU
  991. $this->_wynik_testu_unactual = array();
  992. $this_CRM_PROCES_USERA_WYKONANE_TESTY = $this->getUserTests();
  993. foreach ($this_CRM_PROCES_USERA_WYKONANE_TESTY as $v_test) {
  994. if (isset($this->_wynik_testu[$v_test->ID_PROCES_INIT][$v_test->TEST_TYPE])) {
  995. continue;// only first
  996. }
  997. $this->_wynik_testu[$v_test->ID_PROCES_INIT][$v_test->TEST_TYPE] = $v_test->OCENA;
  998. if (!empty($v_test->unactual)) {
  999. $x_test = new stdClass();
  1000. $x_test->TEST_END = substr($v_test->TEST_END, 0, 10);
  1001. $x_test->unactual = substr($v_test->unactual, 0, 10);
  1002. $x_test->unactualId = $v_test->unactualId;
  1003. $this->_wynik_testu_unactual[$v_test->ID_PROCES_INIT][$v_test->TEST_TYPE] = $x_test;
  1004. }
  1005. }
  1006. }
  1007. function get_ocena_testu($proces_id, $typ) {
  1008. $ocena = $this->get_ocena_testu_value($proces_id, $typ);
  1009. if (!$ocena) {
  1010. return 'BRAK_TESTU';
  1011. }
  1012. else if ($ocena == -1) {
  1013. return 'BRAK_PYTAN';
  1014. }
  1015. else if ($ocena == 3) {
  1016. return 'IDEALNY';
  1017. }
  1018. else if ($ocena < 2) {
  1019. return 'NIEDOSTATECZNY';
  1020. }
  1021. else if($ocena < 2.5) {
  1022. return 'DOSTATECZNY';
  1023. }
  1024. else {
  1025. return 'DOBRY';
  1026. }
  1027. }
  1028. function get_ocena_testu_value($proces_id, $typ) {
  1029. if (isset($this->_wynik_testu[$proces_id][$typ])) {
  1030. return $this->_wynik_testu[$proces_id][$typ];
  1031. }
  1032. return null;
  1033. }
  1034. function isTestUnactual($proces_id, $typ) {
  1035. if (isset($this->_wynik_testu_unactual[$proces_id][$typ])) {
  1036. return $this->_wynik_testu_unactual[$proces_id][$typ];
  1037. }
  1038. return false;
  1039. }
  1040. function get_actual_tests_count($type = null) {
  1041. $this_CRM_PROCES_USERA_WYKONANE_TESTY = $this->getUserTests();
  1042. if ($type == 'TEORETYCZNY') {
  1043. $testy_teoretyczne = 0;
  1044. foreach ($this_CRM_PROCES_USERA_WYKONANE_TESTY as $int => $v_test) {
  1045. if ($v_test->TEST_TYPE=='TEORETYCZNY') {
  1046. if ($v_test->OCENA > 2.5) $testy_teoretyczne++;
  1047. }
  1048. }
  1049. return $testy_teoretyczne;
  1050. }
  1051. else if ($type == 'PRAKTYCZNY') {
  1052. $testy_praktyczne = 0;
  1053. foreach ($this_CRM_PROCES_USERA_WYKONANE_TESTY as $int => $v_test) {
  1054. if ($v_test->TEST_TYPE=='PRAKTYCZNY') {
  1055. if ($v_test->OCENA > 2.5) $testy_praktyczne++;
  1056. }
  1057. }
  1058. return $testy_praktyczne;
  1059. }
  1060. else if ($type == null) {
  1061. return count($this_CRM_PROCES_USERA_WYKONANE_TESTY);
  1062. }
  1063. return 0;
  1064. }
  1065. /**
  1066. * URL: _action=setPermsAll
  1067. */
  1068. function setPermsAllAction() {
  1069. $userAcl = User::getAcl();
  1070. $userAcl->fetchAllPerms(true);
  1071. $this->menuAction();
  1072. }
  1073. /**
  1074. * URL: _action=setPermsByProces
  1075. */
  1076. function setPermsByProcesAction() {
  1077. $procesID = V::get('id_proces', 0, $_GET, 'int');
  1078. if ($procesID <= 0) {
  1079. echo '<div class="alert alert-danger">' . "Brak ID Procesu" . '</div>';
  1080. return;
  1081. }
  1082. $userAcl = User::getAcl();
  1083. if ($userAcl->getPermsFiltrProcesId() == $procesID) {
  1084. $this->menuAction();
  1085. echo '<div class="alert alert-info">' . "Filtr procesu nr {$procesID} jest już uruchomiony" . '</div>';
  1086. return;
  1087. }
  1088. $userAcl = User::getAcl();
  1089. if (!$userAcl->canExecuteProcesInit($procesID)) {
  1090. $this->menuAction();
  1091. echo '<div class="alert alert-danger">' . "Brak uprawnień do uruchomienia filtra procesu" . '</div>';
  1092. SE_Layout::dol();
  1093. exit;
  1094. }
  1095. $userAcl->fetchProcesPerms($procesID, true);
  1096. $this->menuAction();
  1097. }
  1098. function move_test_from_kandydat_to_pracownik($id_kanydata, $id_pracownika) {
  1099. //4673->4680
  1100. //$sql='update CRM_TESTY set A_RECORD_CREATE_AUTHOR='smagielm' where A_RECORD_CREATE_AUTHOR='Kandydat.4673';
  1101. //$sql='update CRM_TESTY set A_RECORD_UPDATE_AUTHOR='smagielm' where A_RECORD_UPDATE_AUTHOR='Kandydat.4673';
  1102. //$sql="update CRM_TESTY set ID_TESTER='4680' where ID_TESTER='4673'";
  1103. }
  1104. }