ProcesMenu.php 46 KB

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