menuAction();// like UI::menu() ? $acl = Core_AclHelper::getAclByNamespace('default_objects/UserTestStats');// default_objects/UserProcess $userTestStatsList = $acl->getItems(); UI::setTitle("Testy - Moje"); $this->userTestsView($userTestStatsList); } catch (Exception $e) { UI::alert('danger', $e->getMessage()); } UI::dol(); } public function adminUserTestAction() {// TODO: replace POST from admin menu to view another user tests UI::gora(); UI::menu(); session_write_close(); try { $idUser = V::get('_user_id', 0, $_REQUEST, 'int'); $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); $userTestStatsList = $acl->getItems(); UI::setTitle("Testy - pracownika {$user['name']}"); $this->userTestsView($userTestStatsList); } catch (Exception $e) { UI::alert('danger', $e->getMessage()); } UI::dol(); } public function userTestsView($userTestStatsList) { $activeFiltrProcessId = User::getAcl()->getPermsFiltrProcesId(); echo UI::h('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;} "); $procesyInitList = []; foreach ($userTestStatsList as $row) { $procesyInitList[ $row['ID'] ] = $row['nazwa']; } $parentIdList = array_filter( array_map(function ($row) { return (int)$row['PARENT_ID']; }, $userTestStatsList), function ($id) { return $id > 0; } ); $sqlProcesyInitIds = (!empty($parentIdList)) ? implode(",", $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) { echo UI::h('div', ['class'=>"container tbl-wyniki-testow page-header"], [ UI::h('h3', [], [ "{$parentProcess['nazwa']} ", UI::h('small', [], [ UI::h('a', [ 'href' => "procesy5.php?task=CRM_PROCES&filtr_id={$parentProcess['ID']}" ], "{{$parentProcess['ID']}}"), ]), ]), ]); UI::startContainer(['class'=>"tbl-wyniki-testow"]); UI::startTag('div', ['class'=>"row"]); $i = 0; foreach ($userTestStatsList as $testStats) { if ($testStats['PARENT_ID'] != $parentProcess['ID']) continue; echo UI::h('div', ['class'=>"col-md-3 wynik-cell wynik-{$testStats['wynik_teoretyczny']}"], [ UI::h('div', ['class'=>"panel panel-default"], [ UI::h('div', ['class'=>"panel-heading"], [ UI::h('span', ['title'=>htmlspecialchars($testStats['nazwa']), 'data-toggle'=>"tooltip"], V::strShortUtf8($testStats['nazwa'], 80)), UI::h('a', ['href'=>"procesy5.php?task=PROCES_VIEW&id_proces={$testStats['ID']}", 'title'=>"zobacz instrukcję do procesu {$testStats['ID']}", 'target'=>"_blank"], "{{$testStats['ID']}}"), ]), // .panel-heading UI::h('div', ['class'=>"panel-body"], [ UI::h('ul', ['style' => "padding-left:20px"], [ UI::h('li', [], [ ($activeFiltrProcessId == $testStats['ID']) ? UI::h('a', ['href'=>"index.php?FUNCTION_INIT=MENU_SELECT_PROCES&_action=setPermsAll", 'style'=>"font-weight:bold"], "Wyłącz filtr uprawnien dla") : UI::h('a', ['href'=>"index.php?FUNCTION_INIT=MENU_SELECT_PROCES&_action=setPermsByProces&id_proces={$testStats['ID']}"], "Uruchom filtr uprawnien dla"), " {$testStats['ID']}" ]), UI::h('li', [], [ UI::h('a', ['href'=>"procesy5.php?task=CRM_TESTY__ADD_TEST&test_type=TEORETYCZNY&proces_id={$testStats['ID']}"], "Wykonaj test teoretyczny dla"), " {$testStats['ID']}", ]), UI::h('li', [], [ "Test teoretyczny: ", UI::h('span', ['class'=>"proces-box"], [ " {$testStats['wynik_teoretyczny']} ", ($testStats['wynik_teoretyczny_value']) ? UI::h('em', null, $testStats['wynik_teoretyczny_value']) : '', ]), ]), UI::h('li', ['class'=>"wynik-{$testStats['wynik_praktyczny']}"], "Test praktyczny: {$testStats['wynik_praktyczny']}"), ]), ($testStats['wynik_unactual']) ? UI::h('div', [ 'class' => "alert alert-danger" ], [ "Uwaga! Test nieaktualny: ", ($testStats['link_popraw_test']) ? " popraw" : '', "
" . substr($testStats['last_test_end'], 0, 10) . " - zakończenie testu", "
" . substr($testStats['last_update_date'], 0, 10) . " - ostatnia zmiana w procesie", ]) : '', ]), // .panel-body ]), // .panel ]); // .wynik-cell if (++$i >= 4) { $i = 0; UI::endTag('div');// .row UI::startTag('div', ['class'=>"row"]); } } UI::endTag('div');// .row UI::endContainer(); } } }