ProcesMenu.php 45 KB

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