ProcesMenu.php 46 KB

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