ProcesMenu.php 46 KB

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