|
@@ -13,12 +13,14 @@ class Route_UserTest extends RouteBase {
|
|
|
public function defaultAction() {
|
|
public function defaultAction() {
|
|
|
UI::gora();
|
|
UI::gora();
|
|
|
UI::menu();
|
|
UI::menu();
|
|
|
|
|
+ session_write_close();
|
|
|
try {
|
|
try {
|
|
|
$procesMenu = ProcesMenu::getInstance();
|
|
$procesMenu = ProcesMenu::getInstance();
|
|
|
// $procesMenu->menuAction();// like UI::menu() ?
|
|
// $procesMenu->menuAction();// like UI::menu() ?
|
|
|
- $acl = Core_AclHelper::getAclByNamespace('default_objects/UserProcess');
|
|
|
|
|
- $userProcessList = $acl->getItems();
|
|
|
|
|
- $this->userTestsView($userProcessList);
|
|
|
|
|
|
|
+ $acl = Core_AclHelper::getAclByNamespace('default_objects/UserTestStats');// default_objects/UserProcess
|
|
|
|
|
+ $userTestStatsList = $acl->getItems();
|
|
|
|
|
+ UI::setTitle("Testy - Moje");
|
|
|
|
|
+ $this->userTestsView($userTestStatsList);
|
|
|
} catch (Exception $e) {
|
|
} catch (Exception $e) {
|
|
|
UI::alert('danger', $e->getMessage());
|
|
UI::alert('danger', $e->getMessage());
|
|
|
}
|
|
}
|
|
@@ -28,93 +30,130 @@ class Route_UserTest extends RouteBase {
|
|
|
public function adminUserTestAction() {// TODO: replace POST from admin menu to view another user tests
|
|
public function adminUserTestAction() {// TODO: replace POST from admin menu to view another user tests
|
|
|
UI::gora();
|
|
UI::gora();
|
|
|
UI::menu();
|
|
UI::menu();
|
|
|
|
|
+ session_write_close();
|
|
|
try {
|
|
try {
|
|
|
$idUser = V::get('_user_id', 0, $_REQUEST, 'int');
|
|
$idUser = V::get('_user_id', 0, $_REQUEST, 'int');
|
|
|
- $acl = Core_AclHelper::getAclByNamespace('default_objects/UserProcess');
|
|
|
|
|
|
|
+ $user = [];// $user = Core_AclHelper::getAclByNamespace('default_db/ADMIN_USERS')->getItem($idUser);
|
|
|
|
|
+ $user['name'] = "TODO: user name({$idUser})";
|
|
|
|
|
+
|
|
|
|
|
+ $acl = Core_AclHelper::getAclByNamespace('default_objects/UserTestStats');// default_objects/UserProcess
|
|
|
$acl->setIdUser($idUser);
|
|
$acl->setIdUser($idUser);
|
|
|
- $userProcessList = $acl->getItems();
|
|
|
|
|
- $this->userTestsView($userProcessList);
|
|
|
|
|
|
|
+ $userTestStatsList = $acl->getItems();
|
|
|
|
|
+ UI::setTitle("Testy - pracownika {$user['name']}");
|
|
|
|
|
+ $this->userTestsView($userTestStatsList);
|
|
|
} catch (Exception $e) {
|
|
} catch (Exception $e) {
|
|
|
UI::alert('danger', $e->getMessage());
|
|
UI::alert('danger', $e->getMessage());
|
|
|
}
|
|
}
|
|
|
UI::dol();
|
|
UI::dol();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function userTestsView($userProcessList) {
|
|
|
|
|
- DBG::nicePrint($userProcessList, '$userProcessList');
|
|
|
|
|
|
|
+ public function userTestsView($userTestStatsList) {
|
|
|
|
|
+ $activeFiltrProcessId = User::getAcl()->getPermsFiltrProcesId();
|
|
|
|
|
+ ?>
|
|
|
|
|
+ <style type="text/css">
|
|
|
|
|
+ .tbl-wyniki-testow {}
|
|
|
|
|
+ .tbl-wyniki-testow td {vertical-align:top;font-size:small;}
|
|
|
|
|
+ .tbl-wyniki-testow .proces-box {padding:0 6px;background:#f00;color:#fff;font-weight:bold;font-family:arial;text-decoration:none}
|
|
|
|
|
+ .tbl-wyniki-testow .proces-title {padding:0 3px;}
|
|
|
|
|
+ .tbl-wyniki-testow .wynik-cell .wyniki-cell-header {height:56px;overflow:hidden;}
|
|
|
|
|
+
|
|
|
|
|
+ .tbl-wyniki-testow .wynik-cell {padding:0 3px;}
|
|
|
|
|
+ .tbl-wyniki-testow .wynik-BRAK_TESTU .proces-box {background-color:silver;}
|
|
|
|
|
+ .tbl-wyniki-testow .wynik-BRAK_PYTAN .proces-box {background-color:#51B7D5;}
|
|
|
|
|
+ .tbl-wyniki-testow .wynik-DOBRY .proces-box {background-color:lightgreen;}
|
|
|
|
|
+ .tbl-wyniki-testow .wynik-DOSTATECZNY .proces-box {background-color:#FFFFB1; color:#777;}
|
|
|
|
|
+ .tbl-wyniki-testow .wynik-NIEDOSTATECZNY .proces-box {background-color:#FC5151;}
|
|
|
|
|
+ .tbl-wyniki-testow .wynik-IDEALNY .proces-box {background-color:gold;}
|
|
|
|
|
+ .tbl-wyniki-testow .wynik-NIEAKTUALNY .proces-box {background-color:silver;}
|
|
|
|
|
+ </style>
|
|
|
|
|
+ <?php
|
|
|
|
|
|
|
|
- // old way
|
|
|
|
|
- $userAcl = User::getAcl();
|
|
|
|
|
- $procesyInitGroup = $this->getUsedProcesInitGroupedList($userAcl);
|
|
|
|
|
- DBG::nicePrint($procesyInitGroup, '$procesyInitGroup');
|
|
|
|
|
- if (empty($procesyInitGroup)) {
|
|
|
|
|
- echo '<p>' . "Brak przypisanych procesów." . '</p>';
|
|
|
|
|
- return;
|
|
|
|
|
|
|
+ $procesyInitList = [];
|
|
|
|
|
+ foreach ($userTestStatsList as $row) {
|
|
|
|
|
+ $procesyInitList[ $row['ID'] ] = $row['nazwa'];
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- public function getUsedProcesInitGroupedList($userAcl) {
|
|
|
|
|
- $procesyInitGroup = array();
|
|
|
|
|
- $procesyInitList = $this->getUserProcesInitList($userAcl);
|
|
|
|
|
- DBG::nicePrint($procesyInitList, '$procesyInitList');
|
|
|
|
|
- if (empty($procesyInitList)) {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- $sqlProcesyInitIds = implode(",", array_keys($procesyInitList));
|
|
|
|
|
- $sql = "select p.`ID`, p.`PARENT_ID`, pp.`DESC` as pp__DESC
|
|
|
|
|
- from `CRM_PROCES` as p
|
|
|
|
|
- join `CRM_PROCES` as pp on(pp.`ID`=p.`PARENT_ID`)
|
|
|
|
|
- where p.`ID` in({$sqlProcesyInitIds})
|
|
|
|
|
- ";
|
|
|
|
|
- $groupedProcesyInit = array();
|
|
|
|
|
- $db = DB::getDB();
|
|
|
|
|
- $res = $db->query($sql);
|
|
|
|
|
- while ($r = $db->fetch($res)) {
|
|
|
|
|
- if (!array_key_exists($r->PARENT_ID, $procesyInitGroup)) {
|
|
|
|
|
- $procesyInitGroup[$r->PARENT_ID] = (object)array('nr'=>$r->PARENT_ID, 'label'=>$r->pp__DESC, 'sub'=>array());
|
|
|
|
|
- }
|
|
|
|
|
- $procesyInitGroup[$r->PARENT_ID]->sub[$r->ID] = $procesyInitList[$r->ID];
|
|
|
|
|
- $groupedProcesyInit[] = $r->ID;
|
|
|
|
|
- }
|
|
|
|
|
- $ungroupedProcesyInit = array_diff(array_keys($procesyInitList), $groupedProcesyInit);
|
|
|
|
|
- if (!empty($ungroupedProcesyInit)) {
|
|
|
|
|
- $procesyInitGroup[$r->PARENT_ID] = (object)array('nr'=>null, 'label'=>"Pozostałe", 'sub'=>array());
|
|
|
|
|
- foreach ($ungroupedProcesyInit as $nr) {
|
|
|
|
|
- $procesyInitGroup[$r->PARENT_ID]->sub[$nr] = $procesyInitList[$nr];
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- return $procesyInitGroup;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ $parentIdList = [];
|
|
|
|
|
+ foreach ($userTestStatsList as $row) {
|
|
|
|
|
+ $parentIdList[ $row['PARENT_ID'] ] = true;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * List of Proces Init for user (skip filters)
|
|
|
|
|
- * TODO: read from CRM_PROCES_idx_GROUP_to_INIT_VIEW ?
|
|
|
|
|
- * TODO: read from CRM_PROCES_idx_USER_to_INIT_VIEW ? - slow
|
|
|
|
|
- * TODO: read from Schema_UserProcessStorageAcl ? - only for current logged in user
|
|
|
|
|
- */
|
|
|
|
|
- public function getUserProcesInitList($userAcl) {
|
|
|
|
|
- $userProcesInitList = array();
|
|
|
|
|
- $idUserGroupList = $userAcl->fetchGroups();
|
|
|
|
|
- $sqlIdUserGroupList = implode(",", array_keys($idUserGroupList));
|
|
|
|
|
- $sqlIdProcesListSql = <<<SQL
|
|
|
|
|
- select gi.`ID_PROCES`
|
|
|
|
|
- from `CRM_PROCES_idx_GROUP_to_PROCES` gi
|
|
|
|
|
- where gi.`ID_GROUP` in({$sqlIdUserGroupList})
|
|
|
|
|
-SQL;
|
|
|
|
|
- $fetchUserProcesInitListSql = <<<SQL
|
|
|
|
|
- select p.`ID`, p.`DESC`
|
|
|
|
|
- from `CRM_PROCES_idx` i
|
|
|
|
|
- join `CRM_PROCES` p on(p.`ID`=i.`idx_PROCES_INIT_ID`)
|
|
|
|
|
- where i.`ID_PROCES` in({$sqlIdProcesListSql})
|
|
|
|
|
- group by p.`ID`
|
|
|
|
|
- order by p.`SORT_PRIO`
|
|
|
|
|
-SQL;
|
|
|
|
|
- $db = DB::getDB();
|
|
|
|
|
- $res = $db->query($fetchUserProcesInitListSql);
|
|
|
|
|
- while ($r = $db->fetch($res)) {
|
|
|
|
|
- $userProcesInitList[$r->ID] = $r->DESC;
|
|
|
|
|
- }
|
|
|
|
|
- return $userProcesInitList;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ $sqlProcesyInitIds = (!empty($parentIdList)) ? implode(",", array_keys($parentIdList)) : '';
|
|
|
|
|
+ $parentProcessList = DB::getPDO()->fetchAll("
|
|
|
|
|
+ select p.ID, p.PARENT_ID, p.DESC as nazwa
|
|
|
|
|
+ from CRM_PROCES as p
|
|
|
|
|
+ where p.ID in({$sqlProcesyInitIds})
|
|
|
|
|
+ ");
|
|
|
|
|
+ foreach ($parentProcessList as $parentProcess) {
|
|
|
|
|
+ UI::startContainer(['class'=>"tbl-wyniki-testow page-header"]);
|
|
|
|
|
+ $linkProcessTree = "procesy5.php?task=CRM_PROCES&filtr_id={$parentProcess['ID']}";
|
|
|
|
|
+ UI::tag('h3', [], "{$parentProcess['nazwa']} <small><a href=\"{$linkProcessTree}\">{{$parentProcess['ID']}}</a></small>");
|
|
|
|
|
+ UI::endContainer();
|
|
|
|
|
+
|
|
|
|
|
+ UI::startContainer(['class'=>"tbl-wyniki-testow"]);
|
|
|
|
|
+ UI::startTag('div', ['class'=>"row"]);
|
|
|
|
|
+ $i = 0;
|
|
|
|
|
+ foreach ($userTestStatsList as $testStats) {
|
|
|
|
|
+ if ($testStats['PARENT_ID'] != $parentProcess['ID']) continue;
|
|
|
|
|
+
|
|
|
|
|
+ UI::startTag('div', ['class'=>"col-md-3 wynik-cell wynik-{$testStats['wynik_teoretyczny']}"]);
|
|
|
|
|
+ UI::startTag('div', ['class'=>"panel panel-default"]);
|
|
|
|
|
+ UI::startTag('div', ['class'=>"panel-heading"]);
|
|
|
|
|
+ UI::tag('span', ['title'=>htmlspecialchars($testStats['nazwa']), 'data-toggle'=>"tooltip"], V::strShortUtf8($testStats['nazwa'], 80), " ");
|
|
|
|
|
+ $linkProcesView = "procesy5.php?task=PROCES_VIEW&id_proces={$testStats['ID']}";
|
|
|
|
|
+ UI::tag('a', ['href'=>$linkProcesView, 'title'=>"zobacz instrukcję do procesu {$testStats['ID']}", 'target'=>"_blank"], "{{$testStats['ID']}}");
|
|
|
|
|
+ UI::endTag('div');// .panel-heading
|
|
|
|
|
+ UI::startTag('div', ['class'=>"panel-body"]);
|
|
|
|
|
+ UI::startTag('ul', ['style' => "padding-left:20px"]);
|
|
|
|
|
+ UI::startTag('li');
|
|
|
|
|
+ if ($activeFiltrProcessId == $testStats['ID']) {
|
|
|
|
|
+ UI::tag('a', ['href'=>"index.php?FUNCTION_INIT=MENU_SELECT_PROCES&_action=setPermsAll", 'style'=>"font-weight:bold"], "Wyłącz filtr uprawnien dla", " ");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ UI::tag('a', ['href'=>"index.php?FUNCTION_INIT=MENU_SELECT_PROCES&_action=setPermsByProces&id_proces={$testStats['ID']}"], "Uruchom filtr uprawnien dla", " ");
|
|
|
|
|
+ }
|
|
|
|
|
+ echo "{$testStats['ID']}";
|
|
|
|
|
+ UI::endTag('li');
|
|
|
|
|
+
|
|
|
|
|
+ UI::startTag('li');
|
|
|
|
|
+ UI::tag('a', ['href'=>"procesy5.php?task=CRM_TESTY__ADD_TEST&test_type=TEORETYCZNY&proces_id={$testStats['ID']}"], "Wykonaj test teoretyczny dla", " ");
|
|
|
|
|
+ echo "{$testStats['ID']}";
|
|
|
|
|
+ UI::endTag('li');
|
|
|
|
|
+
|
|
|
|
|
+ UI::startTag('li');
|
|
|
|
|
+ echo "Test teoretyczny: ";
|
|
|
|
|
+ UI::startTag('span', ['class'=>"proces-box"]);
|
|
|
|
|
+ echo " {$testStats['wynik_teoretyczny']} ";
|
|
|
|
|
+ if ($testStats['wynik_teoretyczny_value']) UI::tag('em', null, $testStats['wynik_teoretyczny_value']);
|
|
|
|
|
+ UI::endTag('span');
|
|
|
|
|
+ UI::endTag('li');
|
|
|
|
|
+
|
|
|
|
|
+ UI::tag('li', ['class'=>"wynik-{$testStats['wynik_praktyczny']}"], "Test praktyczny: {$testStats['wynik_praktyczny']}");
|
|
|
|
|
+
|
|
|
|
|
+ UI::endTag('ul');
|
|
|
|
|
+
|
|
|
|
|
+ $tagFixTest = ($testStats['link_popraw_test'])
|
|
|
|
|
+ ? "<a class=\"btn btn-xs btn-primary\" href=\"{$testStats['link_popraw_test']}\">popraw</a>"
|
|
|
|
|
+ : '';
|
|
|
|
|
+ if ($testStats['wynik_unactual']) {
|
|
|
|
|
+ UI::alert('danger', "
|
|
|
|
|
+ <b>Uwaga! Test nieaktualny:</b>
|
|
|
|
|
+ {$tagFixTest}
|
|
|
|
|
+ <br>" . substr($testStats['last_test_end'], 0, 10) . " - zakończenie testu
|
|
|
|
|
+ <br>" . substr($testStats['last_update_date'], 0, 10) . " - ostatnia zmiana w procesie
|
|
|
|
|
+ ");
|
|
|
|
|
+ }
|
|
|
|
|
+ UI::endTag('div');// .panel-body
|
|
|
|
|
+ UI::endTag('div');// .panel
|
|
|
|
|
+ UI::endTag('div');// .wynik-cell
|
|
|
|
|
+ if (++$i >= 4) {
|
|
|
|
|
+ $i = 0;
|
|
|
|
|
+ UI::endTag('div');// .row
|
|
|
|
|
+ UI::startTag('div', ['class'=>"row"]);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ UI::endTag('div');// .row
|
|
|
|
|
+ UI::endContainer();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
}
|
|
}
|