ProcesMenu.php 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198
  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()) {
  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();
  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. if ('VIEWTABLE_AJAX' == V::get('MENU_INIT', '', $_REQUEST)) {
  376. $menuProcesViewedTblId = V::get('ZASOB_ID', 0, $_REQUEST, 'int');
  377. }
  378. else if ('ViewTableAjax' == V::get('_route', '', $_REQUEST)) {
  379. $typeName = V::get('typeName', '', $_REQUEST, 'word');
  380. if (array_key_exists($typeName, $typeNameToIdZasob)) $menuProcesViewedTblId = $typeNameToIdZasob[$typeName];
  381. }
  382. ?>
  383. <nav id="SE-menu" class="navbar-nav navbar-inverse" style="width:100%">
  384. <div class="container-fluid">
  385. <div class="collapse navbar-collapse">
  386. <ul class="nav navbar-nav">
  387. <?php
  388. echo UI::h('li', [ 'class' => "dropdown" . ($active == 'menu' ? ' active' : '') ], [
  389. UI::h('a',
  390. ($userAcl->getPermsFiltrProcesId())
  391. ? [
  392. 'href' => "#",
  393. 'class' => "dropdown-toggle",
  394. 'data-toggle' => "dropdown",
  395. ]
  396. : [
  397. 'href' => "#",
  398. 'class' => "dropdown-toggle",
  399. 'onClick' => "return initP5MainMenuDropdown(this, 'SE-menu-tables');",
  400. ],
  401. "Menu ". '<b class="caret"></b>'
  402. ),
  403. UI::h('ul', [
  404. 'class' => "dropdown-menu",
  405. 'id' => "SE-menu-tables",
  406. ], array_map(function ($vName, $typeName) use ($typeNameToIdZasob) {
  407. $kZasobID = $typeNameToIdZasob[$typeName];
  408. return UI::h('li', [], [
  409. UI::h('a', ['href'=>"index.php?_route=ViewTableAjax&typeName={$typeName}"], [
  410. UI::h('i', ['class'=>"bookmark-item-add glyphicon glyphicon-star-empty", 'title'=>"Add to favorites", 'data-zasobid'=>$kZasobID]),
  411. UI::h('i', ['class'=>"bookmark-item-rem glyphicon glyphicon-star", 'style'=>"display:none", 'title'=>"Remove from favorites", 'data-zasobid'=>$kZasobID]),
  412. " " . $vName
  413. ])
  414. ]);
  415. }, array_values($outMenus), array_keys($outMenus))),
  416. ]);
  417. echo UI::h('li', [ 'class' => "dropdown"], [
  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 initP5UrlsMenuDropdown(this, 'SE-menu-urls');",
  429. ],
  430. "Narzędzia " . '<b class="caret"></b>'
  431. ),
  432. UI::h('ul', [
  433. 'class' => "dropdown-menu",
  434. 'id' => "SE-menu-urls"
  435. ], array_map(function ($label, $idZasob) {
  436. return UI::h('li', [], [
  437. UI::h('a', [ 'href' => "index.php?FUNCTION_INIT=URL_INIT&ZASOB_ID={$idZasob}", 'target' => "_blank", 'title' => $label ], [
  438. UI::h('i', [ 'class' => "bookmark-item-add glyphicon glyphicon-star-empty", 'title' => "Add to favorites", 'data-zasobid' => $idZasob ]),
  439. UI::h('i', [ 'class' => "bookmark-item-rem glyphicon glyphicon-star", 'style' => "display:none", 'title' => "Remove from favorites", 'data-zasobid' => $idZasob ]),
  440. UI::h('code', [ 'style' => "margin-left:6px; margin-right:6px" ], (string)$idZasob),
  441. (mb_strlen($label, 'utf-8') > 100)? mb_substr($label, 0, 100, 'utf-8') . '...' : $label,
  442. ]),
  443. ]);
  444. }, array_values($outUrls), array_keys($outUrls))),
  445. ]);
  446. ?>
  447. <li class="dropdown <?php if ($active == 'procesy') echo "active"; ?>">
  448. <a id="ProcesMenuProcesDropdownLink" href="#" class="dropdown-toggle" data-toggle="dropdown">Procesy <b class="caret"></b></a>
  449. <ul class="dropdown-menu">
  450. <?php if (!empty($lastProcesyFiltrIds)) : ?>
  451. <li>
  452. <p class="text-muted" style="padding:3px 20px;"><nobr>Wróć do ostatniego wyszukiwania:</nobr></p>
  453. <a href="procesy5.php?task=CRM_PROCES<?php echo "&filtr_id={$lastProcesyFiltrIds}&filtr_ids=%2B&filtr_ob=%2B&filtr_img=%2B"; ?>"><?php
  454. //echo $lastProcesyFiltrIdsLabels;
  455. if (!empty($lastProcesyFiltrIds)) {
  456. $lastProcesyFiltrIds = explode(',', $lastProcesyFiltrIds);
  457. $labels = array();
  458. $labelsLimit = 4;
  459. $labelsInd = 0;
  460. foreach ($lastProcesyFiltrIds as $lastFltr) {
  461. $labels[] = '<span class="label label-info">' . $lastFltr . '</span>';
  462. if (++$labelsInd >= $labelsLimit) {
  463. $labels[] = '...';
  464. break;
  465. }
  466. }
  467. $lastProcesyFiltrIdsLabels = implode(' ', $labels);
  468. }
  469. echo $lastProcesyFiltrIdsLabels;
  470. ?></a>
  471. </li>
  472. <li class="divider"></li>
  473. <?php endif; ?>
  474. <li>
  475. <a href="index.php?FUNCTION_INIT=PROCES_MENU&HEADER_NOT_INIT=YES&_task=PROCES_FOR_USER" title="Moje Procesy">Moje Procesy</a>
  476. </li>
  477. <?php if ($menuProcesViewedTblId > 0) : ?>
  478. <li>
  479. <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>
  480. </li>
  481. <?php endif; ?>
  482. <li>
  483. <a href="procesy5.php?task=CRM_PROCES&filtr_id=" title="Wyświetlenie drzewa procesów">Wszystkie Procesy</a>
  484. </li>
  485. <?php if (0 == User::get('ADM_ADMIN_LEVEL')) : ?>
  486. <li>
  487. <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>
  488. </li>
  489. <?php endif; ?>
  490. <li class="divider"></li>
  491. <?php if (!$typeSpecialProces) : ?>
  492. <li>
  493. <div class="alert alert-danger">Brak typespecial __PROCES</div>
  494. </li>
  495. <?php else : ?>
  496. <li>
  497. <p class="text-muted" style="padding:3px 20px;"><nobr>Wyszukaj:</nobr></p>
  498. <form id="ProcesMenuProcesFrm" action="procesy5.php" method="GET" style="padding:0 20px">
  499. <input type="hidden" name="task" value="CRM_PROCES">
  500. <?php
  501. $fldName = 'ProcesMenu__Proces_filtr_id';
  502. $fldParams = array();
  503. $fldParams['allowCreate'] = false;
  504. $fldParams['ajaxDataUrlBase'] = "index.php?FUNCTION_INIT=PROCES_MENU&HEADER_NOT_INIT=YES&_task=TYPESPECIAL&fld={$fldName}";
  505. $fldParams['placeholder'] = 'Szukaj...';
  506. $fldParams['formFieldName'] = 'filtr_id';
  507. //$fldParams['ajaxDataUrlBase'] .= "&DBG_TS=3";
  508. echo $typeSpecialProces->showFormItem($tblID = -1, $fldName, $selValue = '', $fldParams);
  509. ?>
  510. <input class="btn btn-xs btn-primary" type="submit" value="Wybierz" />
  511. <input class="pull-right btn btn-xs btn-default" type="submit" id="ProcesMenuProcesFltrAdd" value="Dodaj do filtra" />
  512. <script>
  513. jQuery(document).ready(function() {
  514. if ('procesy5.php' === window.location.pathname.substr(-12)
  515. && window.location.search.search('task=CRM_PROCES') > 0
  516. && window.location.search.search('&filtr_id=') > 0
  517. ) {
  518. jQuery('#ProcesMenuProcesFltrAdd').on('click', function(e) {
  519. var frm = jQuery(this).get(0).form;
  520. var fldNode = frm['<?php echo $fldParams['formFieldName']; ?>'],
  521. fltrId = '';
  522. if (fldNode && '' != fldNode.value) {
  523. fltrId = fldNode.value;
  524. } else {
  525. return;
  526. }
  527. var pos = 0, fltrIds = '';
  528. if ('procesy5.php' === window.location.pathname.substr(-12)
  529. && window.location.search.search('task=CRM_PROCES') > 0
  530. && (pos = window.location.search.search('&filtr_id=')) > 0
  531. ) {
  532. pos += 10;
  533. fltrIds = window.location.search.substr(pos);
  534. if ((pos = fltrIds.search('&')) > 0) {
  535. fltrIds = fltrIds.substr(0, pos);
  536. }
  537. if (fltrIds) {
  538. fltrIds = decodeURIComponent(fltrIds);
  539. fltrIds += ',' + fltrId;
  540. if (fldNode.selectize) {
  541. fldNode.selectize.addOption({id: fltrIds, name: fltrIds});
  542. fldNode.selectize.setValue(fltrIds, true);
  543. }
  544. }
  545. }
  546. });
  547. } else {
  548. jQuery('#ProcesMenuProcesFltrAdd').hide();
  549. }
  550. jQuery('#ProcesMenuProcesFrm').on('submit', function(e) {
  551. var frm = jQuery(this).get(0),
  552. fldNode = frm['<?php echo $fldParams['formFieldName']; ?>'];
  553. if (fldNode && '' != fldNode.value) {
  554. return true;
  555. } else {
  556. return false;
  557. }
  558. });
  559. jQuery('#ProcesMenuProcesDropdownLink').on('click', function(e) {
  560. setTimeout(function(){
  561. jQuery('#ts-<?php echo $fldName; ?>')
  562. .next('.selectize-control')
  563. .find('input:first')
  564. .focus();
  565. }, 200);
  566. });
  567. });
  568. </script>
  569. </form>
  570. </li>
  571. <?php endif; ?>
  572. </ul>
  573. </li>
  574. <li class="dropdown <?php if ($active == 'zasoby') echo "active"; ?>">
  575. <a id="ProcesMenuZasobDropdownLink" href="#" class="dropdown-toggle" data-toggle="dropdown">Zasoby <b class="caret"></b></a>
  576. <ul class="dropdown-menu">
  577. <?php if (!empty($lastZasobyFiltrIds)) : ?>
  578. <li>
  579. <p class="text-muted" style="padding:3px 20px;"><nobr>Wróć do ostatniego wyszukiwania:</nobr></p>
  580. <a href="procesy5.php?task=CRM_LISTA_ZASOBOW<?php echo "&filtr_id={$lastZasobyFiltrIds}&filtr_ids=%2B&filtr_ob=%2B&filtr_img=%2B"; ?>"><?php
  581. //echo $lastZasobyFiltrIdsLabels;
  582. if (!empty($lastZasobyFiltrIds)) {
  583. $lastZasobyFiltrIds = explode(',', $lastZasobyFiltrIds);
  584. $labels = array();
  585. $labelsLimit = 4;
  586. $labelsInd = 0;
  587. foreach ($lastZasobyFiltrIds as $lastFltr) {
  588. $labels[] = '<span class="badge badge-inverse">' . $lastFltr . '</span>';
  589. if (++$labelsInd >= $labelsLimit) {
  590. $labels[] = '...';
  591. break;
  592. }
  593. }
  594. $lastZasobyFiltrIdsLabels = implode(' ', $labels);
  595. }
  596. echo $lastZasobyFiltrIdsLabels;
  597. ?></a>
  598. </li>
  599. <li class="divider"></li>
  600. <?php endif; ?>
  601. <?php if (!empty($userGroupIdsCSV)) : ?>
  602. <li>
  603. <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>
  604. </li>
  605. <?php endif; ?>
  606. <?php if ($menuProcesViewedTblId > 0) : ?>
  607. <li>
  608. <a href="procesy5.php?task=CRM_LISTA_ZASOBOW&filtr_id=<?= $menuProcesViewedTblId; ?>&filtr_ids=%2B&filtr_ob=%2B" title="Struktura aktualnie przeglądanej tabeli">Struktura aktualnie przeglądanej tabeli</a>
  609. </li>
  610. <?php endif; ?>
  611. <li>
  612. <a href="procesy5.php?task=CRM_LISTA_ZASOBOW&filtr_id=" title="Wyświetlenie drzewa zasobów">Wszystkie Zasoby</a>
  613. </li>
  614. <li class="divider"></li>
  615. <?php if (!$typeSpecialZasob) : ?>
  616. <li>
  617. <div class="alert alert-danger">Brak typespecial __ZASOB</div>
  618. </li>
  619. <?php else : ?>
  620. <li>
  621. <p class="text-muted" style="padding:3px 20px;"><nobr>Wyszukaj:</nobr></p>
  622. <form id="ProcesMenuZasobFrm" action="procesy5.php" method="GET" style="padding:0 20px">
  623. <input type="hidden" name="task" value="CRM_LISTA_ZASOBOW">
  624. <?php
  625. $fldName = 'ProcesMenu__Zasob_filtr_id';
  626. $fldParams = array();
  627. $fldParams['allowCreate'] = false;
  628. $fldParams['ajaxDataUrlBase'] = "index.php?FUNCTION_INIT=PROCES_MENU&HEADER_NOT_INIT=YES&_task=TYPESPECIAL&fld={$fldName}";
  629. $fldParams['placeholder'] = 'Szukaj...';
  630. $fldParams['formFieldName'] = 'filtr_id';
  631. //$fldParams['ajaxDataUrlBase'] .= "&DBG_TS=3";
  632. echo $typeSpecialZasob->showFormItem($tblID = -1, $fldName, $selValue = '', $fldParams);
  633. ?>
  634. <input class="btn btn-xs btn-primary" type="submit" value="Wybierz" />
  635. <input class="pull-right btn btn-xs btn-default" type="submit" id="ProcesMenuZasobFltrAdd" value="Dodaj do filtra" />
  636. <script>
  637. jQuery(document).ready(function() {
  638. if ('procesy5.php' === window.location.pathname.substr(-12)
  639. && window.location.search.search('task=CRM_LISTA_ZASOBOW') > 0
  640. && window.location.search.search('&filtr_id=') > 0
  641. ) {
  642. jQuery('#ProcesMenuZasobFltrAdd').on('click', function(e) {
  643. var frm = jQuery(this).get(0).form;
  644. var fldNode = frm['<?php echo $fldParams['formFieldName']; ?>'],
  645. fltrId = '';
  646. if (fldNode && '' != fldNode.value) {
  647. fltrId = fldNode.value;
  648. } else {
  649. return;
  650. }
  651. var pos = 0, fltrIds = '';
  652. if ('procesy5.php' === window.location.pathname.substr(-12)
  653. && window.location.search.search('task=CRM_LISTA_ZASOBOW') > 0
  654. && (pos = window.location.search.search('&filtr_id=')) > 0
  655. ) {
  656. pos += 10;
  657. fltrIds = window.location.search.substr(pos);
  658. if ((pos = fltrIds.search('&')) > 0) {
  659. fltrIds = fltrIds.substr(0, pos);
  660. }
  661. if (fltrIds) {
  662. fltrIds = decodeURIComponent(fltrIds);
  663. fltrIds += ',' + fltrId;
  664. if (fldNode.selectize) {
  665. fldNode.selectize.addOption({id: fltrIds, name: fltrIds});
  666. fldNode.selectize.setValue(fltrIds, true);
  667. }
  668. }
  669. }
  670. });
  671. } else {
  672. jQuery('#ProcesMenuZasobFltrAdd').hide();
  673. }
  674. jQuery('#ProcesMenuZasobFrm').on('submit', function(e) {
  675. var frm = jQuery(this).get(0),
  676. fldNode = frm['<?php echo $fldParams['formFieldName']; ?>'];
  677. if (fldNode && '' != fldNode.value) {
  678. return true;
  679. } else {
  680. return false;
  681. }
  682. });
  683. jQuery('#ProcesMenuZasobDropdownLink').on('click', function(e) {
  684. setTimeout(function(){
  685. jQuery('#ts-<?php echo $fldName; ?>')
  686. .next('.selectize-control')
  687. .find('input:first')
  688. .focus();
  689. }, 200);
  690. });
  691. });
  692. </script>
  693. </form>
  694. </li>
  695. <?php endif; ?>
  696. </ul>
  697. </li>
  698. <li<?php if ($active == 'obowiazki') echo ' class="active"'; ?>><a href="procesy5.php?task=CRM_WYSWIETL_OBOWIAZKI" title="Wyswietlenie OBOWIAZKOW">Obowiązki</a></li>
  699. <li class="dropdown <?php if ($active == 'testy') echo "active"; ?>">
  700. <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>
  701. <ul class="dropdown-menu">
  702. <li>
  703. <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>
  704. </li>
  705. <?php if (User::hasAccess('testy')) : ?>
  706. <li>
  707. <a href="procesy5.php?task=CRM_TESTY__LIST">Lista testów</a>
  708. </li>
  709. <li>
  710. <a href="procesy5.php?task=CRM_TESTY__ADD_TEST">Uruchom nowy test</a>
  711. </li>
  712. <?php endif; ?>
  713. <?php if (User::hasAccess('procesy') || User::get('ADM_ADMIN_LEVEL') <= 2) : ?>
  714. <li class="divider"></li>
  715. <?php endif; ?>
  716. <?php if (User::hasAccess('procesy')) : ?>
  717. <li>
  718. <a href="procesy5.php?task=CRM_TESTY__ADD_KANDYDAT">Dodaj Kandydata i zaloguj się do testów</a>
  719. </li>
  720. <?php endif; ?>
  721. <?php if (User::get('ADM_ADMIN_LEVEL') <= 2) : ?>
  722. <li>
  723. <a href="procesy5.php?task=CRM_TESTY_WYNIKI" title="Wyswietlenie wyników testów">Wyniki</a>
  724. </li>
  725. <?php endif; ?>
  726. </ul>
  727. </li>
  728. <li<?= ('kontakty' == $active) ? ' class="active"' : ''; ?>><a href="index.php?_route=ViewTableAjax&namespace=default_db/KONTAKTY_view" title="Kontakty">Kontakty</a></li>
  729. <li<?= ('przypomnij' == $active) ? ' class="active"' : ''; ?>><a href="index.php?_route=Przypomnij&KTO=<?php echo User::getLogin(); ?>" title="Przypomnij">Przypomnij</a></li>
  730. </ul>
  731. <form class="navbar-form navbar-left" style="margin:3px 0;" role="search" action="procesy5.php?task=CRM_SEARCH" method="post">
  732. <div class="input-group">
  733. <input type="text" class="form-control input-sm" placeholder="Szukaj..." name="q">
  734. <span class="input-group-btn">
  735. <button class="btn btn-default btn-sm" type="submit"><i class="glyphicon glyphicon-search"></i></button>
  736. </span>
  737. </div><!-- /input-group -->
  738. </form>
  739. <div class="navbar-form navbar-right">
  740. <div class="btn-group">
  741. <button type="button" class="btn btn-link" style="margin:0; padding:6px 8px 4px 8px;"><?php S::show_session_timer(); ?></button>
  742. <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>
  743. <div class="btn-group">
  744. <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>
  745. <ul class="dropdown-menu" role="menu">
  746. <?php if (file_exists('/Library/Server/Web/Data/Sites/Default/')) : ?>
  747. <li><a href="/webcal" target="_blank"><i class="glyphicon glyphicon-calendar"></i> Kalendarz</a></li>
  748. <?php if (file_exists('/Library/Server/Web/Data/Sites/Default/webmail/loginFromSE.php')) : ?>
  749. <li>
  750. <a href="/webmail">
  751. <form action="https://<?php echo $_SERVER['SERVER_NAME']; ?>/webmail/loginFromSE.php" method="post" target="_blank">
  752. <input type="hidden" name="_timezone" value="Europe/Berlin">
  753. <input type="hidden" name="_token" value="">
  754. <input type="hidden" name="_action" value="login">
  755. <input type="hidden" name="_task" value="login">
  756. <input type="hidden" name="_url" value="">
  757. <input type="hidden" name="_user" value="<?php echo User::getName(); ?>">
  758. <input type="hidden" name="_pass" value="<?php echo User::get('ADM_PASS_HASH'); ?>">
  759. <input type="hidden" name="EMAIL_IMAP_IMPORT_USERNAME" value="<?php echo V::get('EMAIL_IMAP_IMPORT_USERNAME', '', $_SESSION); ?>">
  760. <input type="hidden" name="EMAIL_IMAP_IMPORT_HOST" value="<?php echo V::get('EMAIL_IMAP_IMPORT_HOST', '', $_SESSION); ?>">
  761. <input type="hidden" name="EMAIL_IMAP_IMPORT_PASSWD_HASH" value="<?php echo V::get('EMAIL_IMAP_IMPORT_PASSWD_HASH', '', $_SESSION); ?>">
  762. <input type="hidden" name="loginFromSE" value="1">
  763. <!-- <input type="submit" class="btn" value="P"> -->
  764. <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>
  765. </form>
  766. </a>
  767. </li>
  768. <?php elseif (file_exists('/Library/Server/Web/Data/Sites/Default/webmail')) : ?>
  769. <li><a href="/webmail" target="_blank"><i class="glyphicon glyphicon-envelope"></i> Poczta</a></li>
  770. <?php endif; ?>
  771. <li><a href="/changepassword" target="_blank"><i class="glyphicon glyphicon-lock"></i> Zmień hasło</a></li>
  772. <li><a href="/profilemanager" target="_blank"><i class="glyphicon glyphicon-user"></i> Apple Profile Manager</a></li>
  773. <li class="divider"></li>
  774. <?php else: ?>
  775. <li><a href="index.php?LOGIN=PASSEDIT">Zmień hasło</a></li>
  776. <?php endif; ?>
  777. <li><a href="procesy5.php?task=USER" title="<?php echo User::getName(); ?>"><i class="glyphicon glyphicon-user"></i> Profil</a></li>
  778. <li><a href="index.php?_route=UrlAction_Calendar"><i class="glyphicon glyphicon-calendar"></i> Grafik pracy</a></li>
  779. <li><a href="index.php?_route=UserMsgs" title="Wiadomości systemowe"><i class="glyphicon glyphicon-envelope"></i> Wiadomości</a></li>
  780. <li><a href="index.php?_route=Notify" title="Powiadomienia"><i class="glyphicon glyphicon-bell"></i> Powiadomienia</a></li>
  781. <li><a href="index.php?_route=Users&_task=reloadPerms" title="Przeładuj uprawnienia"><i class="glyphicon glyphicon-refresh"></i> Przeładuj uprawnienia</a></li>
  782. <li class="divider"></li>
  783. <?php if (User::isAdmin()) : ?>
  784. <li><a href="index.php?_route=Status" title="Status systemu"><i class="glyphicon glyphicon-cog"></i> Status systemu</a></li>
  785. <?php endif; ?>
  786. <?php if (User::isAdmin()) : ?>
  787. <?php if (!$typeSpecialUserId) : ?>
  788. <li>
  789. <div class="alert alert-danger">Brak typespecial __USERS_ID</div>
  790. </li>
  791. <?php else : ?>
  792. <li>
  793. <p class="text-muted" style="padding:3px 20px;"><nobr>Pokaż testy pracownika:</nobr></p>
  794. <form action="index.php" method="POST">
  795. <input type="hidden" name="FUNCTION_INIT" value="MENU_SELECT_PROCES">
  796. <input type="hidden" name="_action" value="showMyTests">
  797. <?php
  798. $fldName = '_user_id';
  799. $fldParams = array();
  800. $fldParams['allowCreate'] = false;
  801. $fldParams['ajaxDataUrlBase'] = "index.php?FUNCTION_INIT=PROCES_MENU&HEADER_NOT_INIT=YES&_task=TYPESPECIAL&fld={$fldName}";
  802. $fldParams['placeholder'] = 'Szukaj...';
  803. //$fldParams['ajaxDataUrlBase'] .= "&DBG_TS=3";
  804. echo $typeSpecialUserId->showFormItem($tblID = -1, $fldName, $selValue = '', $fldParams);
  805. ?>
  806. <input class="btn btn-xs btn-warning" type="submit" value="Wybierz" />
  807. <script>
  808. jQuery(document).ready(function() {
  809. jQuery('#ProcesMenuLoginDropdownLink')
  810. .next('.dropdown-menu')
  811. .find('.selectize-input')
  812. .on('click', function(e) {
  813. return false;
  814. });
  815. jQuery('#ProcesMenuLoginDropdownLink').on('click', function(e) {
  816. setTimeout(function(){
  817. jQuery('#ts-<?php echo $fldName; ?>')
  818. .next('.selectize-control')
  819. .find('input:first')
  820. .focus();
  821. }, 200);
  822. });
  823. });
  824. </script>
  825. </form>
  826. </li>
  827. <?php endif; ?>
  828. <li class="divider"></li>
  829. <?php endif; ?>
  830. <li><a href="index.php?LOGIN=LOGOUT"><i class="glyphicon glyphicon-off"></i> Wyloguj</a></li>
  831. </ul>
  832. </div>
  833. </div>
  834. </div>
  835. <!--
  836. <li<?php if ($active == 'search') echo ' class="active"'; ?>>
  837. <form action="procesy5.php?task=CRM_SEARCH" method="post" class="navbar-search">
  838. <input type="text" name="q" value="" class="q search-query span2">
  839. <input type="image" src="icon/search.png" class="s">
  840. </form>
  841. </li>
  842. -->
  843. </div><!-- /.navbar-collapse -->
  844. </nav>
  845. <?php
  846. UI::inlineJS(APP_PATH_WWW . '/static/p5UI/menuStore.js');
  847. $idFiltrProcesID = $userAcl->getPermsFiltrProcesId();
  848. if ($idFiltrProcesID > 0) {
  849. echo UI::h('div', [ 'id' => "SE-menu-sub", 'style' => "clear:both;" ], array_merge(
  850. [
  851. 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}"),
  852. ],
  853. array_map(
  854. function ($label, $typeName) {
  855. return UI::h('a', [ 'class' => "btn btn-xs btn-default", 'href' => "index.php?_route=ViewTableAjax&typeName={$typeName}", 'title' => $label ], V::strShortUtf8($label, 20));
  856. }, array_values($outBtnsMenus), array_keys($outBtnsMenus)
  857. ),
  858. array_map(
  859. function ($label, $idZasob) {
  860. 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));
  861. }, array_values($outUrls), array_keys($outUrls)
  862. )
  863. ));
  864. } else {
  865. echo UI::h('div', [ 'id' => "SE-menu-sub", 'style' => "clear:both" ]);
  866. UI::inlineJS(APP_PATH_WWW . '/static/p5UI/userBookmarks.js');
  867. // url: 'index-ajax.php?_cls=UserBookmarks',
  868. echo UI::h('script', [], "
  869. (function (global) {
  870. jQuery('#SE-menu-sub').UserBookmarks({
  871. url: 'index.php?_route=P5Menu',
  872. store: global.p5UI__MenuStore,
  873. debug: false
  874. });
  875. })(window);
  876. ");
  877. }
  878. echo '</div>';
  879. echo UI::h('script', [], "
  880. (function (global) {
  881. if (!global.p5UI__MenuStore) throw 'Missing global.p5UI__MenuStore'
  882. function p5BookmarksAdd(e, id) {
  883. e.preventDefault()
  884. e.stopPropagation()
  885. global.p5UI__MenuStore.remoteUpdate({
  886. '_postTask': 'addBookmark',
  887. '_zasobID': id,
  888. })
  889. }
  890. function p5BookmarksRemove(e, id) {
  891. e.preventDefault()
  892. e.stopPropagation()
  893. global.p5UI__MenuStore.remoteUpdate({
  894. '_postTask': 'removeBookmark',
  895. '_zasobID': id,
  896. })
  897. }
  898. global.p5BookmarksAdd = p5BookmarksAdd
  899. global.p5BookmarksRemove = p5BookmarksRemove
  900. })(window)
  901. ");
  902. echo UI::h('script', [], "
  903. (function (global) {
  904. if (!global.p5UI__MenuStore) throw 'Missing global.p5UI__MenuStore'
  905. function initP5MainMenuDropdown( btnNode, idSubMenu ) {
  906. if (!btnNode._initialized) {
  907. var jqDropdownTrigger = jQuery(btnNode)
  908. var jqDropdownMenu = jQuery('#' + idSubMenu)
  909. var jqDropdownParent = jqDropdownMenu.parent()
  910. global.p5UI__MenuStore.subscribe(
  911. (function (global, idSubMenu) {
  912. return function renderP5MainMenuDropdown(data) {
  913. var jqDropdownMenu = jQuery('#' + idSubMenu)
  914. jqDropdownMenu.empty()
  915. jqDropdownMenu.append(data.objects.map(function (item) {
  916. var star = (-1 !== data.idsBookmarks.indexOf(item.id))
  917. ? '<i class=\"bookmark-item-rem glyphicon glyphicon-star\" title=\"Usuń z ulubionych\" onClick=\"return p5BookmarksRemove(event, ' + item.id + ')\"></i>'
  918. : '<i class=\"bookmark-item-add glyphicon glyphicon-star-empty\" title=\"Dodaj do ulubionych\" onClick=\"return p5BookmarksAdd(event, ' + item.id + ')\"></i>'
  919. return jQuery('<li>' +
  920. '<a href=\"index.php?_route=ViewTableAjax&namespace=' + item.namespace + '\">' +
  921. star +
  922. ' ' + item.label +
  923. '</a>' +
  924. '</li>');
  925. }))
  926. }
  927. })(global, idSubMenu)
  928. )
  929. jqDropdownTrigger.attr('data-toggle', 'dropdown') // is required by bootstrap dorpdown.js evenf if is called via js
  930. global.p5UI__MenuStore.forceUpdate()
  931. jQuery(btnNode).dropdown()
  932. }
  933. btnNode._initialized = true
  934. return true;
  935. }
  936. global.initP5MainMenuDropdown = initP5MainMenuDropdown
  937. })(window)
  938. ");
  939. echo UI::h('script', [], "
  940. (function (global) {
  941. if (!global.p5UI__MenuStore) throw 'Missing global.p5UI__MenuStore'
  942. function initP5UrlsMenuDropdown( btnNode, idSubMenu ) {
  943. if (!btnNode._initialized) {
  944. var jqDropdownTrigger = jQuery(btnNode)
  945. var jqDropdownMenu = jQuery('#' + idSubMenu)
  946. var jqDropdownParent = jqDropdownMenu.parent()
  947. global.p5UI__MenuStore.subscribe(
  948. (function (global, idSubMenu) {
  949. return function renderP5MainMenuDropdown(data) {
  950. var jqDropdownMenu = jQuery('#' + idSubMenu)
  951. jqDropdownMenu.empty()
  952. jqDropdownMenu.append(data.urls.map(function (item) {
  953. var star = (-1 !== data.idsBookmarks.indexOf(item.id))
  954. ? '<i class=\"bookmark-item-rem glyphicon glyphicon-star\" title=\"Usuń z ulubionych\" onClick=\"return p5BookmarksRemove(event, ' + item.id + ')\"></i>'
  955. : '<i class=\"bookmark-item-add glyphicon glyphicon-star-empty\" title=\"Dodaj do ulubionych\" onClick=\"return p5BookmarksAdd(event, ' + item.id + ')\"></i>'
  956. return jQuery('<li>' +
  957. '<a href=\"index.php?FUNCTION_INIT=URL_INIT&ZASOB_ID=' + item.id + '\" target=\"_blank\" title=\"' + item.raw_label + '\">' +
  958. star +
  959. ' ' + '<code>' + item.id + '</code>' +
  960. ' ' + item.label +
  961. '</a>' +
  962. '</li>');
  963. }))
  964. }
  965. })(global, idSubMenu)
  966. )
  967. jqDropdownTrigger.attr('data-toggle', 'dropdown') // is required by bootstrap dorpdown.js evenf if is called via js
  968. global.p5UI__MenuStore.forceUpdate()
  969. jQuery(btnNode).dropdown()
  970. }
  971. btnNode._initialized = true
  972. return true;
  973. }
  974. global.initP5UrlsMenuDropdown = initP5UrlsMenuDropdown
  975. })(window)
  976. ");
  977. $args = [
  978. 'P5MENU_URL' => Router::getRoute('P5Menu')->getLink(),
  979. ];
  980. echo UI::h('script', [], "
  981. (function (global) {
  982. if (!global.p5UI__MenuStore) throw 'Missing global.p5UI__MenuStore'
  983. var P5MENU_URL = '{$args['P5MENU_URL']}'
  984. global.p5UI__MenuStore.setRemoteUrl(P5MENU_URL)
  985. if (global.p5UI__MenuStore.hasData()) {
  986. global.p5UI__MenuStore.forceUpdate() // force update all subscribers
  987. } else {
  988. global.p5UI__MenuStore.remoteUpdate() // update from remote url @see setRemoteUrl
  989. }
  990. })(window)
  991. ");
  992. }
  993. /**
  994. * Generates wyniki
  995. */
  996. private function _generateTestResults() {
  997. $this->_wynik_testu = array();// WYNIK_TESTU_PROCESU
  998. $this->_wynik_testu_unactual = array();
  999. $this_CRM_PROCES_USERA_WYKONANE_TESTY = $this->getUserTests();
  1000. foreach ($this_CRM_PROCES_USERA_WYKONANE_TESTY as $v_test) {
  1001. if (isset($this->_wynik_testu[$v_test->ID_PROCES_INIT][$v_test->TEST_TYPE])) {
  1002. continue;// only first
  1003. }
  1004. $this->_wynik_testu[$v_test->ID_PROCES_INIT][$v_test->TEST_TYPE] = $v_test->OCENA;
  1005. if (!empty($v_test->unactual)) {
  1006. $x_test = new stdClass();
  1007. $x_test->TEST_END = substr($v_test->TEST_END, 0, 10);
  1008. $x_test->unactual = substr($v_test->unactual, 0, 10);
  1009. $x_test->unactualId = $v_test->unactualId;
  1010. $this->_wynik_testu_unactual[$v_test->ID_PROCES_INIT][$v_test->TEST_TYPE] = $x_test;
  1011. }
  1012. }
  1013. }
  1014. function get_ocena_testu($proces_id, $typ) {
  1015. $ocena = $this->get_ocena_testu_value($proces_id, $typ);
  1016. if (!$ocena) {
  1017. return 'BRAK_TESTU';
  1018. }
  1019. else if ($ocena == -1) {
  1020. return 'BRAK_PYTAN';
  1021. }
  1022. else if ($ocena == 3) {
  1023. return 'IDEALNY';
  1024. }
  1025. else if ($ocena < 2) {
  1026. return 'NIEDOSTATECZNY';
  1027. }
  1028. else if($ocena < 2.5) {
  1029. return 'DOSTATECZNY';
  1030. }
  1031. else {
  1032. return 'DOBRY';
  1033. }
  1034. }
  1035. function get_ocena_testu_value($proces_id, $typ) {
  1036. if (isset($this->_wynik_testu[$proces_id][$typ])) {
  1037. return $this->_wynik_testu[$proces_id][$typ];
  1038. }
  1039. return null;
  1040. }
  1041. function isTestUnactual($proces_id, $typ) {
  1042. if (isset($this->_wynik_testu_unactual[$proces_id][$typ])) {
  1043. return $this->_wynik_testu_unactual[$proces_id][$typ];
  1044. }
  1045. return false;
  1046. }
  1047. function get_actual_tests_count($type = null) {
  1048. $this_CRM_PROCES_USERA_WYKONANE_TESTY = $this->getUserTests();
  1049. if ($type == 'TEORETYCZNY') {
  1050. $testy_teoretyczne = 0;
  1051. foreach ($this_CRM_PROCES_USERA_WYKONANE_TESTY as $int => $v_test) {
  1052. if ($v_test->TEST_TYPE=='TEORETYCZNY') {
  1053. if ($v_test->OCENA > 2.5) $testy_teoretyczne++;
  1054. }
  1055. }
  1056. return $testy_teoretyczne;
  1057. }
  1058. else if ($type == 'PRAKTYCZNY') {
  1059. $testy_praktyczne = 0;
  1060. foreach ($this_CRM_PROCES_USERA_WYKONANE_TESTY as $int => $v_test) {
  1061. if ($v_test->TEST_TYPE=='PRAKTYCZNY') {
  1062. if ($v_test->OCENA > 2.5) $testy_praktyczne++;
  1063. }
  1064. }
  1065. return $testy_praktyczne;
  1066. }
  1067. else if ($type == null) {
  1068. return count($this_CRM_PROCES_USERA_WYKONANE_TESTY);
  1069. }
  1070. return 0;
  1071. }
  1072. /**
  1073. * URL: _action=setPermsAll
  1074. */
  1075. function setPermsAllAction() {
  1076. $userAcl = User::getAcl();
  1077. $userAcl->fetchAllPerms(true);
  1078. $this->menuAction();
  1079. }
  1080. /**
  1081. * URL: _action=setPermsByProces
  1082. */
  1083. function setPermsByProcesAction() {
  1084. $procesID = V::get('id_proces', 0, $_GET, 'int');
  1085. if ($procesID <= 0) {
  1086. echo '<div class="alert alert-danger">' . "Brak ID Procesu" . '</div>';
  1087. return;
  1088. }
  1089. $userAcl = User::getAcl();
  1090. if ($userAcl->getPermsFiltrProcesId() == $procesID) {
  1091. $this->menuAction();
  1092. echo '<div class="alert alert-info">' . "Filtr procesu nr {$procesID} jest już uruchomiony" . '</div>';
  1093. return;
  1094. }
  1095. $userAcl = User::getAcl();
  1096. if (!$userAcl->canExecuteProcesInit($procesID)) {
  1097. $this->menuAction();
  1098. echo '<div class="alert alert-danger">' . "Brak uprawnień do uruchomienia filtra procesu" . '</div>';
  1099. SE_Layout::dol();
  1100. exit;
  1101. }
  1102. $userAcl->fetchProcesPerms($procesID, true);
  1103. $this->menuAction();
  1104. }
  1105. function move_test_from_kandydat_to_pracownik($id_kanydata, $id_pracownika) {
  1106. //4673->4680
  1107. //$sql='update CRM_TESTY set A_RECORD_CREATE_AUTHOR='smagielm' where A_RECORD_CREATE_AUTHOR='Kandydat.4673';
  1108. //$sql='update CRM_TESTY set A_RECORD_UPDATE_AUTHOR='smagielm' where A_RECORD_UPDATE_AUTHOR='Kandydat.4673';
  1109. //$sql="update CRM_TESTY set ID_TESTER='4680' where ID_TESTER='4673'";
  1110. }
  1111. }