ProcesMenu.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. <?php
  2. require_once dirname(__FILE__) . '/' . 'Lib.php';
  3. Lib::loadClass('V');
  4. Lib::loadClass('User');
  5. Lib::loadClass('ProcesTestyHelper');
  6. Lib::loadClass('TypespecialVariable');
  7. Lib::loadClass('UsersHelper');
  8. Lib::loadClass('DB');
  9. Lib::loadClass('UserBookmarks');
  10. Lib::loadClass('FilterFactory');
  11. class ProcesMenu {
  12. var $MENU_SELECT_PROCES;
  13. var $_wynik_testu;
  14. var $_wynik_testu_unactual;
  15. var $error;// errory niedopuszczajace do uruchomienia
  16. var $warning;// uwagi
  17. var $CRM_PROCES_USERA_UZYTY;
  18. var $_user_id;
  19. var $_acl;
  20. function __construct() {
  21. $this->_user_id = User::getID();
  22. if (User::isAdmin()) {
  23. $this->_user_id = V::get('_user_id', 0, $_REQUEST, 'int');
  24. if (!$this->_user_id) {
  25. $this->_user_id = User::getID();
  26. $this->_acl = User::getAcl();
  27. } else {
  28. $this->_acl = UsersHelper::getUserAcl($this->_user_id);
  29. }
  30. } else {
  31. $this->_acl = User::getAcl();
  32. }
  33. if (!$this->_acl) {
  34. die('Error Acl');
  35. }
  36. if ('1' == V::get('_CLEAN_CACHE', '', $_REQUEST)) {
  37. $this->_cleanTestsCache();
  38. }
  39. $this->_generateTestResults();
  40. }
  41. static function getInstance() {
  42. static $_instance = null;
  43. if (!$_instance) {
  44. $_instance = new ProcesMenu();
  45. }
  46. return $_instance;
  47. }
  48. function show() {
  49. static $_menu_showed = false;
  50. if (!$_menu_showed) {
  51. $actionName = V::get('_action', 'menu', $_REQUEST);
  52. // podglad testów pracownika
  53. if (User::isAdmin() && $this->_user_id != User::getID()) {
  54. $actionName = 'showMyTests';
  55. }
  56. $actionName .= 'Action';
  57. if (method_exists($this, $actionName)) {
  58. $this->{$actionName}();
  59. }
  60. //$this->show_menu_with_process();
  61. $_menu_showed = true;
  62. }
  63. }
  64. /**
  65. * @return Array
  66. */
  67. function getUserTests() {
  68. if ($this->_user_id <= 0) {
  69. throw new Exception("User id not set");
  70. }
  71. $testy_arr = array();
  72. $ses_cache_key = 'CRM_PROCES_USERA_WYKONANE_TESTY-' . $this->_user_id;
  73. if (!$this->_isTestsInCache()) {
  74. $usedProcesInitIds = $this->_acl->getUserProcesInitIds();
  75. DBG::_('DBG_PM', '1', "usedProcesInitIds", $usedProcesInitIds, __CLASS__, __FUNCTION__, __LINE__ );
  76. if (!empty($usedProcesInitIds)) {
  77. $testy_arr = ProcesTestyHelper::get_tetsy_stats($this->_user_id, 0, $usedProcesInitIds);
  78. // check if tests are actual - proces steps may change
  79. if (!empty($testy_arr)) {
  80. foreach ($usedProcesInitIds as $k_proces_id) {
  81. $last_test = null;
  82. foreach ($testy_arr as $k_ind => $v_test) {
  83. if ($v_test->ID_PROCES_INIT == $k_proces_id) {
  84. $last_test = $v_test;
  85. $last_test->test_ind = $k_ind;
  86. break;
  87. }
  88. }
  89. if (!$last_test || $last_test->TEST_END == '0000-00-00') {
  90. continue;
  91. }
  92. $max_update_date = $this->_acl->getProcesMaxUpdateDate($k_proces_id);
  93. if ($max_update_date) {
  94. $max_update_date = substr($max_update_date, 0, 10);
  95. $test_end = substr($last_test->TEST_END, 0, 10);
  96. DBG::_('DBG_PM', '1', "P_INIT({$k_proces_id}) max_update_date({$max_update_date}) TEST_END({$last_test->TEST_END}) not actual(" . ($max_update_date > $last_test->TEST_END) . ")", $last_test, __CLASS__, __FUNCTION__, __LINE__ );
  97. if ($max_update_date > $test_end) {
  98. $testy_arr[$last_test->test_ind]->unactual = $max_update_date;
  99. $testy_arr[$last_test->test_ind]->unactualId = $last_test->ID;
  100. }
  101. }
  102. }
  103. }
  104. }
  105. $this->_setTestsCache($testy_arr);
  106. }
  107. return $this->_getTestsFromCache();
  108. }
  109. private function _cleanTestsCache() {
  110. $ses_cache_key = "CRM_PROCES_USERA_WYKONANE_TESTY-{$this->_user_id}";
  111. unset($_SESSION[$ses_cache_key]);
  112. }
  113. private function _isTestsInCache() {
  114. $ses_cache_key = "CRM_PROCES_USERA_WYKONANE_TESTY-{$this->_user_id}";
  115. return isset($_SESSION[$ses_cache_key]);
  116. }
  117. private function _getTestsFromCache() {
  118. $ses_cache_key = "CRM_PROCES_USERA_WYKONANE_TESTY-{$this->_user_id}";
  119. return $_SESSION[$ses_cache_key];
  120. }
  121. private function _setTestsCache($tests) {
  122. $ses_cache_key = "CRM_PROCES_USERA_WYKONANE_TESTY-{$this->_user_id}";
  123. $_SESSION[$ses_cache_key] = $tests;
  124. }
  125. function setError($error) {
  126. $this->error[] = $error;
  127. }
  128. function ifError() {// TODO: RMME
  129. if (!empty($this->error)) {
  130. return true;
  131. }
  132. else {
  133. DEBUG_S(-1,'Wydarzyły się błędy uniemożliwiające kontynuacje pracy modułu',$this->error,__FILE__,__FUNCTION__,__LINE__);
  134. die();
  135. return false;
  136. }
  137. }
  138. function showMyTestsAction() {
  139. $this->menuAction();
  140. $userAcl = User::getAcl();
  141. $procesyInitGroup = $this->getUsedProcesInitGroupedList();
  142. if (empty($procesyInitGroup)) {
  143. echo '<p>' . "Brak przypisanych procesów." . '</p>';
  144. return;
  145. }
  146. ?>
  147. <style type="text/css">
  148. .tbl-wyniki-testow {}
  149. .tbl-wyniki-testow td {vertical-align:top;font-size:small;}
  150. .tbl-wyniki-testow .proces-box {padding:0 6px;background:#f00;color:#fff;font-weight:bold;font-family:arial;text-decoration:none}
  151. .tbl-wyniki-testow .proces-title {padding:0 3px;}
  152. .tbl-wyniki-testow .wynik-cell .wyniki-cell-header {height:56px;overflow:hidden;}
  153. .tbl-wyniki-testow .wynik-cell {padding:0 3px;}
  154. .tbl-wyniki-testow .wynik-BRAK_TESTU .proces-box {background-color:silver;}
  155. .tbl-wyniki-testow .wynik-BRAK_PYTAN .proces-box {background-color:#51B7D5;}
  156. .tbl-wyniki-testow .wynik-DOBRY .proces-box {background-color:lightgreen;}
  157. .tbl-wyniki-testow .wynik-DOSTATECZNY .proces-box {background-color:#FFFFB1; color:#777;}
  158. .tbl-wyniki-testow .wynik-NIEDOSTATECZNY .proces-box {background-color:#FC5151;}
  159. .tbl-wyniki-testow .wynik-IDEALNY .proces-box {background-color:gold;}
  160. .tbl-wyniki-testow .wynik-NIEAKTUALNY .proces-box {background-color:silver;}
  161. </style>
  162. <div class="container" style="margin-top:10px;">
  163. <form action="" method="post" class="inline-form">
  164. <input type="hidden" name="_CLEAN_CACHE" value="1">
  165. <button type="submit" class="btn btn-xs btn-warning pull-right">odśwież</button>
  166. </form>
  167. </div>
  168. <?php foreach ($procesyInitGroup as $vProcesGroup) : ?>
  169. <div class="container tbl-wyniki-testow page-header">
  170. <h3>
  171. <?php echo $vProcesGroup->label; ?>
  172. <?php if ($vProcesGroup->nr > 0) : ?>
  173. <small><a href="procesy5.php?task=CRM_PROCES&filtr_id=<?php echo $vProcesGroup->nr; ?>">{<?php echo $vProcesGroup->nr; ?>}</a></small>
  174. <?php endif; ?>
  175. </h3>
  176. </div>
  177. <div class="container tbl-wyniki-testow">
  178. <div class="row">
  179. <?php $i = 0; foreach ($vProcesGroup->sub as $proces_id => $proces_desc) : ?>
  180. <?php
  181. $wynik_teoretyczny = $this->get_ocena_testu($proces_id, 'TEORETYCZNY');
  182. $wynik_teoretyczny_value = $this->get_ocena_testu_value($proces_id, 'TEORETYCZNY');
  183. if ($wynik_teoretyczny == 'BRAK_PYTAN') {
  184. $wynik_teoretyczny_value = '';
  185. }
  186. $wynik_praktyczny = $this->get_ocena_testu($proces_id, 'PRAKTYCZNY');
  187. $wynik_unactual = $this->isTestUnactual($proces_id, 'TEORETYCZNY');
  188. ?>
  189. <div class="col-md-3 wynik-cell wynik-<?php echo $wynik_teoretyczny; ?>">
  190. <div class="panel panel-default">
  191. <div class="panel-heading">
  192. <span data-toggle="tooltip" title="<?php echo $proces_desc; ?>"><?php echo V::strShortUtf8($proces_desc, 80); ?></span>
  193. <a href="procesy5.php?task=PROCES_VIEW&id_proces=<?php echo $proces_id; ?>" title="zobacz instrukcję do procesu <?php echo $proces_id; ?>" target="_blank">{<?php echo $proces_id; ?>}</a>
  194. </div>
  195. <div class="panel-body">
  196. <li>
  197. <?php if ($userAcl->getPermsFiltrProcesId() == $proces_id) : ?>
  198. <b><a href="index.php?FUNCTION_INIT=MENU_SELECT_PROCES&_action=setPermsAll"> Wyłącz filtr uprawnien dla </a></b>
  199. <?php else : ?>
  200. <a href="index.php?FUNCTION_INIT=MENU_SELECT_PROCES&_action=setPermsByProces&id_proces=<?php echo $proces_id; ?>"> Uruchom filtr uprawnien dla </a>
  201. <?php endif; ?>
  202. <?php echo $proces_id; ?>
  203. </li>
  204. <?php if (!in_array($wynik_teoretyczny, array('DOBRY', 'IDEALNY')) || $wynik_unactual) : ?>
  205. <li>
  206. <a href="procesy5.php?task=CRM_TESTY__ADD_TEST&proces_id=<?php echo $proces_id; ?>&test_type=TEORETYCZNY"> Wykonaj test teoretyczny dla </a>
  207. <?php echo $proces_id; ?>
  208. </li>
  209. <?php endif; ?>
  210. <li>Test teoretyczny: <span class="proces-box"><?php echo $wynik_teoretyczny; ?>
  211. <?php if ($wynik_teoretyczny_value) : ?> <em>(<?php echo $wynik_teoretyczny_value; ?>)</em><?php endif; ?>
  212. </span>
  213. </li>
  214. <li class="wynik-<?php echo $wynik_praktyczny; ?>">Test praktyczny: <?php echo $wynik_praktyczny; ?></li>
  215. <?php if ($wynik_unactual) : ?>
  216. <div class="alert alert-danger">
  217. <b>Uwaga! Test nieaktualny:</b>
  218. <?php if ($wynik_unactual->unactualId) : ?>
  219. <a class="btn btn-xs btn-primary" href="procesy5.php?task=CRM_TESTY__ADD_TEST&function_init=fun_CRM_TESTY__ADD_FIX&test_id=<?php echo $wynik_unactual->unactualId; ?>">popraw</a>
  220. <?php endif; ?>
  221. <br /><?php echo $wynik_unactual->TEST_END; ?> - zakończenie testu
  222. <br /><?php echo $wynik_unactual->unactual; ?> - ostatnia zmiana w procesie
  223. </div>
  224. <?php endif; ?>
  225. </div>
  226. </div>
  227. </div>
  228. <?php if (++$i >= 4) : $i = 0; ?>
  229. </div><div class="row">
  230. <?php endif; ?>
  231. <?php endforeach; ?>
  232. </div>
  233. </div>
  234. <?php endforeach; ?>
  235. <script>
  236. jQuery(document).ready(function() {
  237. jQuery('[data-toggle="tooltip"]').tooltip();
  238. });
  239. </script>
  240. <?php
  241. SE_Layout::dol();
  242. exit;
  243. }
  244. private function getUsedProcesInitGroupedList() {
  245. $procesyInitGroup = array();
  246. $procesyInitList = $this->_acl->getUserProcesInitList();
  247. if (empty($procesyInitList)) {
  248. return;
  249. }
  250. $sqlProcesyInitIds = implode(",", array_keys($procesyInitList));
  251. $sql = "select p.`ID`, p.`PARENT_ID`, pp.`DESC` as pp__DESC
  252. from `CRM_PROCES` as p
  253. join `CRM_PROCES` as pp on(pp.`ID`=p.`PARENT_ID`)
  254. where p.`ID` in({$sqlProcesyInitIds})
  255. ";
  256. $groupedProcesyInit = array();
  257. $db = DB::getDB();
  258. $res = $db->query($sql);
  259. while ($r = $db->fetch($res)) {
  260. if (!array_key_exists($r->PARENT_ID, $procesyInitGroup)) {
  261. $procesyInitGroup[$r->PARENT_ID] = (object)array('nr'=>$r->PARENT_ID, 'label'=>$r->pp__DESC, 'sub'=>array());
  262. }
  263. $procesyInitGroup[$r->PARENT_ID]->sub[$r->ID] = $procesyInitList[$r->ID];
  264. $groupedProcesyInit[] = $r->ID;
  265. }
  266. $ungroupedProcesyInit = array_diff(array_keys($procesyInitList), $groupedProcesyInit);
  267. if (!empty($ungroupedProcesyInit)) {
  268. $procesyInitGroup[$r->PARENT_ID] = (object)array('nr'=>null, 'label'=>"Pozostałe", 'sub'=>array());
  269. foreach ($ungroupedProcesyInit as $nr) {
  270. $procesyInitGroup[$r->PARENT_ID]->sub[$nr] = $procesyInitList[$nr];
  271. }
  272. }
  273. return $procesyInitGroup;
  274. }
  275. function menuAction() {
  276. $testy_teoretyczne = $this->get_actual_tests_count('TEORETYCZNY');
  277. $testy_praktyczne = $this->get_actual_tests_count('PRAKTYCZNY');
  278. $procesy_init_arr = $this->_acl->getUserProcesInitIds();
  279. $proces_cnt = count($procesy_init_arr);
  280. $testy_ok = $this->get_actual_tests_count();
  281. $MojeTestyTitle = "Ilość Procesów: {$proces_cnt}, Aktualnych testów: {$testy_ok}, Teoretycznych: {$testy_teoretyczne}, Praktycznych: {$testy_praktyczne}";
  282. $userAcl = User::getAcl();
  283. $tbls = [];
  284. $urls = [];
  285. $outUrls = array();
  286. $outMenus = array();// typeName => label (order by label)
  287. $typeNameToIdZasob = array();// $typeName => $idZasob
  288. if ($userAcl->getPermsFiltrProcesId()) { // TODO: fetch menu from ajax - fix menuStore
  289. $tbls = $userAcl->getTablesAcl();
  290. $urls = $userAcl->getUrls();
  291. if (!empty($urls)) {
  292. foreach ($urls as $kZasobID => $vTitle) {
  293. $outUrls[$kZasobID] = $vTitle;
  294. }
  295. }
  296. asort($outUrls);
  297. $rawOutMenus = array();
  298. $labelsOutMenus = array();
  299. $outBtnsMenus = array();
  300. // DBG::nicePrint($tbls, '$tbls');
  301. if (!empty($tbls)) {
  302. foreach ($tbls as $kZasobID => $vTblAcl) {
  303. if (null == $vTblAcl) continue;
  304. $tblName = $vTblAcl->getName();
  305. $typeName = "p5_default_db:{$tblName}";
  306. $labelsOutMenus[$typeName] = $vTblAcl->getLongLabel(); // TODO: legacy
  307. $rawOutMenus[$typeName] = strtolower($vTblAcl->getLongRawLabel());
  308. $typeNameToIdZasob[$typeName] = $kZasobID;
  309. // if ($userAcl->getPermsFiltrProcesId()) {
  310. $outBtnsMenus[$typeName] = $vTblAcl->getRawLabel();
  311. // }
  312. }
  313. }
  314. asort($rawOutMenus);
  315. foreach ($rawOutMenus as $typeName => $rawLongLabel) $outMenus[$typeName] = $labelsOutMenus[$typeName]; // TODO: mv to localStorage
  316. if ($userAcl->getPermsFiltrProcesId()) {
  317. asort($outBtnsMenus);
  318. }
  319. }
  320. $active = '';
  321. $script_name = V::get('SCRIPT_NAME', '', $_SERVER);
  322. if (false !== strpos($script_name, 'index.php')) {
  323. $route = V::get('_route', '', $_GET);
  324. if (!empty($route)) {
  325. if ('p5_default_db:KONTAKTY_view' == V::get('typeName', '', $_GET)) $active = 'kontakty';
  326. else if ('default_db/KONTAKTY_view' == V::get('namespace', '', $_GET)) $active = 'kontakty';
  327. } else {
  328. $menu_init = V::get('MENU_INIT', '', $_GET);
  329. switch ($menu_init) {
  330. case 'VIEWTABLE_AJAX': $active = 'menu'; break;
  331. default: {
  332. $fun_init = V::get('FUNCTION_INIT', '', $_GET);
  333. switch ($fun_init) {
  334. case 'MENU_SELECT_PROCES': $active = 'testy'; break;
  335. case 'PRZYPOMNIJ_FUNC': $active = 'przypomnij'; break;
  336. case 'PRZYPOMNIJ': $active = 'przypomnij'; break;
  337. default:
  338. }
  339. }
  340. }
  341. }
  342. }
  343. else if (false !== strpos($script_name, 'procesy5.php')) {
  344. $task = V::get('task', '', $_GET);
  345. switch ($task) {
  346. case 'CRM_PROCES': $active = 'procesy'; break;
  347. case 'CRM_LISTA_ZASOBOW': $active = 'zasoby'; break;
  348. case 'CRM_WYSWIETL_OBOWIAZKI': $active = 'obowiazki'; break;
  349. case 'CRM_TESTY': $active = 'testy'; break;
  350. case 'CRM_TESTY_WYNIKI': $active = 'testy'; break;
  351. case 'CRM_TESTY__LIST': $active = 'testy'; break;
  352. case 'CRM_TESTY__ADD_TEST': $active = 'testy'; break;
  353. case 'CRM_TESTY__ADD_KANDYDAT': $active = 'testy'; break;
  354. case 'CRM_SEARCH': $active = 'search'; break;
  355. default:
  356. // testy_moje ?FUNCTION_INIT=MENU_SELECT_PROCES&MENU_SELECT_PROCES=show_menu_with_process => _action=showMyTests
  357. }
  358. }
  359. /*
  360. * $_SESSION['USER_PROFILE'][section][key] = val;
  361. */
  362. $userGroupIdsCSV = User::getGroupsIds();
  363. $userGroupIdsCSV = implode(',', $userGroupIdsCSV);
  364. $typeSpecialZasob = TypespecialVariable::getInstance(-1, '__ZASOB');
  365. $treeZasobyFilter = FilterFactory::build('CRM_LISTA_ZASOBOW');
  366. $lastZasobyFiltrIds = $treeZasobyFilter->get_arg('filtr_id');
  367. $typeSpecialProces = TypespecialVariable::getInstance(-1, '__PROCES');
  368. $treeProcesyFilter = FilterFactory::build('CRM_PROCES');
  369. $lastProcesyFiltrIds = $treeProcesyFilter->get_arg('filtr_id');
  370. $menuProcesViewedTblId = 0;
  371. $menuProcesViewedAclIsObject = false;
  372. if ('ViewTableAjax' == V::get('_route', '', $_REQUEST)) {
  373. $namespace = V::get('namespace', '', $_REQUEST, 'word');
  374. if (!$namespace) {
  375. $typeName = V::get('typeName', '', $_REQUEST, 'word');
  376. if ($typeName) {
  377. $namespace = str_replace(['__x3A__', ':'], '/', $typeName);
  378. }
  379. }
  380. if ($namespace) {
  381. $menuProcesViewedAclIsObject = (
  382. 'default_db/' === substr($namespace, 0, strlen('default_db/'))
  383. && strpos(substr($namespace, strlen('default_db/')), '/') > 0
  384. );
  385. $zasobTableName = (
  386. 'default_db/' === substr($namespace, 0, strlen('default_db/'))
  387. && false === strpos(substr($namespace, strlen('default_db/')), '/')
  388. )
  389. ? substr($namespace, strlen('default_db/'))
  390. : $namespace;
  391. if ($zasobTableName) {
  392. $dbID = DB::getPDO()->getZasobId();
  393. $menuProcesViewedTblId = DB::getPDO()->fetchValue("
  394. select z.ID
  395. from CRM_LISTA_ZASOBOW z
  396. where z.`DESC` = '{$zasobTableName}'
  397. and z.A_STATUS not in ('DELETED')
  398. and z.`TYPE` = 'TABELA'
  399. and z.PARENT_ID = '{$dbID}'
  400. ");
  401. }
  402. }
  403. }
  404. else if ('VIEWTABLE_AJAX' == V::get('MENU_INIT', '', $_REQUEST)) {
  405. $menuProcesViewedTblId = V::get('ZASOB_ID', 0, $_REQUEST, 'int');
  406. }
  407. UI::loadTemplate('menuMain', [
  408. 'active' => $active,
  409. 'outMenus' => $outMenus,
  410. 'outBtnsMenus' => $outBtnsMenus,
  411. 'outUrls' => $outUrls,
  412. 'typeNameToIdZasob' => $typeNameToIdZasob,
  413. 'lastProcesyFiltrIds' => $lastProcesyFiltrIds,
  414. 'menuProcesViewedTblId' => $menuProcesViewedTblId,
  415. 'userAcl__getPermsFiltrProcesId' => $userAcl->getPermsFiltrProcesId(),
  416. 'typeSpecialProces' => $typeSpecialProces,
  417. 'lastZasobyFiltrIds' => $lastZasobyFiltrIds,
  418. 'userGroupIdsCSV' => $userGroupIdsCSV,
  419. 'menuProcesViewedAclIsObject' => $menuProcesViewedAclIsObject,
  420. 'namespace' => $namespace,
  421. 'typeSpecialZasob' => $typeSpecialZasob,
  422. 'MojeTestyTitle' => $MojeTestyTitle,
  423. 'testy_ok' => $testy_ok,
  424. 'proces_cnt' => $proces_cnt,
  425. 'testy_teoretyczne' => $testy_teoretyczne,
  426. 'testy_praktyczne' => $testy_praktyczne,
  427. 'typeSpecialUserId' => (User::isAdmin()) ? TypespecialVariable::getInstance(-1, '__USER_ID') : null,
  428. 'idFiltrProcesID' => $userAcl->getPermsFiltrProcesId(),
  429. ]);
  430. }
  431. /**
  432. * Generates wyniki
  433. */
  434. private function _generateTestResults() {
  435. $this->_wynik_testu = array();// WYNIK_TESTU_PROCESU
  436. $this->_wynik_testu_unactual = array();
  437. $this_CRM_PROCES_USERA_WYKONANE_TESTY = $this->getUserTests();
  438. foreach ($this_CRM_PROCES_USERA_WYKONANE_TESTY as $v_test) {
  439. if (isset($this->_wynik_testu[$v_test->ID_PROCES_INIT][$v_test->TEST_TYPE])) {
  440. continue;// only first
  441. }
  442. $this->_wynik_testu[$v_test->ID_PROCES_INIT][$v_test->TEST_TYPE] = $v_test->OCENA;
  443. if (!empty($v_test->unactual)) {
  444. $x_test = new stdClass();
  445. $x_test->TEST_END = substr($v_test->TEST_END, 0, 10);
  446. $x_test->unactual = substr($v_test->unactual, 0, 10);
  447. $x_test->unactualId = $v_test->unactualId;
  448. $this->_wynik_testu_unactual[$v_test->ID_PROCES_INIT][$v_test->TEST_TYPE] = $x_test;
  449. }
  450. }
  451. }
  452. function get_ocena_testu($proces_id, $typ) {
  453. $ocena = $this->get_ocena_testu_value($proces_id, $typ);
  454. if (!$ocena) {
  455. return 'BRAK_TESTU';
  456. }
  457. else if ($ocena == -1) {
  458. return 'BRAK_PYTAN';
  459. }
  460. else if ($ocena == 3) {
  461. return 'IDEALNY';
  462. }
  463. else if ($ocena < 2) {
  464. return 'NIEDOSTATECZNY';
  465. }
  466. else if($ocena < 2.5) {
  467. return 'DOSTATECZNY';
  468. }
  469. else {
  470. return 'DOBRY';
  471. }
  472. }
  473. function get_ocena_testu_value($proces_id, $typ) {
  474. if (isset($this->_wynik_testu[$proces_id][$typ])) {
  475. return $this->_wynik_testu[$proces_id][$typ];
  476. }
  477. return null;
  478. }
  479. function isTestUnactual($proces_id, $typ) {
  480. if (isset($this->_wynik_testu_unactual[$proces_id][$typ])) {
  481. return $this->_wynik_testu_unactual[$proces_id][$typ];
  482. }
  483. return false;
  484. }
  485. function get_actual_tests_count($type = null) {
  486. $this_CRM_PROCES_USERA_WYKONANE_TESTY = $this->getUserTests();
  487. if ($type == 'TEORETYCZNY') {
  488. $testy_teoretyczne = 0;
  489. foreach ($this_CRM_PROCES_USERA_WYKONANE_TESTY as $int => $v_test) {
  490. if ($v_test->TEST_TYPE=='TEORETYCZNY') {
  491. if ($v_test->OCENA > 2.5) $testy_teoretyczne++;
  492. }
  493. }
  494. return $testy_teoretyczne;
  495. }
  496. else if ($type == 'PRAKTYCZNY') {
  497. $testy_praktyczne = 0;
  498. foreach ($this_CRM_PROCES_USERA_WYKONANE_TESTY as $int => $v_test) {
  499. if ($v_test->TEST_TYPE=='PRAKTYCZNY') {
  500. if ($v_test->OCENA > 2.5) $testy_praktyczne++;
  501. }
  502. }
  503. return $testy_praktyczne;
  504. }
  505. else if ($type == null) {
  506. return count($this_CRM_PROCES_USERA_WYKONANE_TESTY);
  507. }
  508. return 0;
  509. }
  510. /**
  511. * URL: _action=setPermsAll
  512. */
  513. function setPermsAllAction() {
  514. $userAcl = User::getAcl();
  515. $userAcl->fetchAllPerms(true);
  516. $this->menuAction();
  517. }
  518. /**
  519. * URL: _action=setPermsByProces
  520. */
  521. function setPermsByProcesAction() {
  522. $procesID = V::get('id_proces', 0, $_GET, 'int');
  523. if ($procesID <= 0) {
  524. echo '<div class="alert alert-danger">' . "Brak ID Procesu" . '</div>';
  525. return;
  526. }
  527. $userAcl = User::getAcl();
  528. if ($userAcl->getPermsFiltrProcesId() == $procesID) {
  529. $this->menuAction();
  530. echo '<div class="alert alert-info">' . "Filtr procesu nr {$procesID} jest już uruchomiony" . '</div>';
  531. return;
  532. }
  533. $userAcl = User::getAcl();
  534. if (!$userAcl->canExecuteProcesInit($procesID)) {
  535. $this->menuAction();
  536. echo '<div class="alert alert-danger">' . "Brak uprawnień do uruchomienia filtra procesu" . '</div>';
  537. SE_Layout::dol();
  538. exit;
  539. }
  540. $userAcl->fetchProcesPerms($procesID, true);
  541. $this->menuAction();
  542. }
  543. function move_test_from_kandydat_to_pracownik($id_kanydata, $id_pracownika) {
  544. //4673->4680
  545. //$sql='update CRM_TESTY set A_RECORD_CREATE_AUTHOR='smagielm' where A_RECORD_CREATE_AUTHOR='Kandydat.4673';
  546. //$sql='update CRM_TESTY set A_RECORD_UPDATE_AUTHOR='smagielm' where A_RECORD_UPDATE_AUTHOR='Kandydat.4673';
  547. //$sql="update CRM_TESTY set ID_TESTER='4680' where ID_TESTER='4673'";
  548. }
  549. }