ProcesMenu.php 46 KB

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