ProcesMenu.php 45 KB

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