|
|
@@ -7,43 +7,20 @@ class Route_Status extends RouteBase {
|
|
|
|
|
|
public function defaultAction() {
|
|
|
UI::gora();
|
|
|
- $_ = array(UI, 'h');
|
|
|
UI::startTag('div', ['class' => "container"]);
|
|
|
- echo $_('h1', [], [
|
|
|
- $_('a', ['href'=>"index.php"], "SE"),
|
|
|
+ echo UI::h('h1', [], [
|
|
|
+ UI::h('a', ['href'=>"index.php"], "SE"),
|
|
|
" » ",
|
|
|
" Status systemu procesy5"
|
|
|
]);
|
|
|
try {
|
|
|
DB::getPDO();
|
|
|
|
|
|
- if (1 == V::get('event_sheduler_on', '', $_POST)) {
|
|
|
- $this->fixEventSheduler();
|
|
|
+ $this->viewStatusDatabase();
|
|
|
+ if (in_array(User::get('ADM_ADMIN_LEVEL'), ['0', '1'])) {
|
|
|
+ $this->viewStatusUsers();
|
|
|
}
|
|
|
|
|
|
- $dbEvents = DB::getPDO()->fetchFirst(" SHOW VARIABLES WHERE VARIABLE_NAME = 'event_scheduler' ");
|
|
|
- // DBG::nicePrint($dbEvents, '$dbEvents');
|
|
|
- // [Variable_name] => event_scheduler
|
|
|
- // [Value] => ON
|
|
|
-
|
|
|
- UI::table([
|
|
|
- 'caption' => 'Baza danych',
|
|
|
- 'rows' => [
|
|
|
- [
|
|
|
- 'nazwa' => 'Event Scheduler (generowanie Grafika, itp.)',
|
|
|
- 'wartość' => ('ON' == $dbEvents['Value'])
|
|
|
- ? $_('span', ['class' => "label label-success"], "ON")
|
|
|
- : $_('span', ['class' => "label label-danger"], "OFF"),
|
|
|
- '#' => UI::hButtonPost("Włącz", [
|
|
|
- 'class' => "btn btn-xs btn-default",
|
|
|
- 'data' => [
|
|
|
- 'event_sheduler_on' => 1
|
|
|
- ]
|
|
|
- ])
|
|
|
- ]
|
|
|
- ]
|
|
|
- ]);
|
|
|
-
|
|
|
// UI::table([
|
|
|
// 'caption' => 'Baza danych',
|
|
|
// 'rows' => DB::getPDO()->fetchAll(" SHOW VARIABLES ")
|
|
|
@@ -55,8 +32,89 @@ class Route_Status extends RouteBase {
|
|
|
UI::dol();
|
|
|
}
|
|
|
|
|
|
+ public function viewStatusDatabase() {
|
|
|
+ if (1 == V::get('event_sheduler_on', '', $_POST)) {
|
|
|
+ $this->fixEventSheduler();
|
|
|
+ }
|
|
|
+
|
|
|
+ $dbEvents = DB::getPDO()->fetchFirst(" SHOW VARIABLES WHERE VARIABLE_NAME = 'event_scheduler' ");
|
|
|
+ // DBG::nicePrint($dbEvents, '$dbEvents');
|
|
|
+ // [Variable_name] => event_scheduler
|
|
|
+ // [Value] => ON
|
|
|
+
|
|
|
+ UI::table([
|
|
|
+ 'caption' => UI::h('b', ['style' => "color:#000"], 'Baza danych'),
|
|
|
+ 'rows' => [
|
|
|
+ [
|
|
|
+ 'nazwa' => 'Event Scheduler (generowanie Grafika, itp.)',
|
|
|
+ 'wartość' => ('ON' == $dbEvents['Value'])
|
|
|
+ ? UI::h('span', ['class' => "label label-success"], "ON")
|
|
|
+ : UI::h('span', ['class' => "label label-danger"], "OFF"),
|
|
|
+ '#' => UI::hButtonPost("Włącz", [
|
|
|
+ 'class' => "btn btn-xs btn-default",
|
|
|
+ 'data' => [
|
|
|
+ 'event_sheduler_on' => 1
|
|
|
+ ]
|
|
|
+ ])
|
|
|
+ ]
|
|
|
+ ]
|
|
|
+ ]);
|
|
|
+ }
|
|
|
public function fixEventSheduler() {
|
|
|
DB::getPDO()->execSql(" SET GLOBAL event_scheduler='ON' ");
|
|
|
}
|
|
|
|
|
|
+ public function viewStatusUsers() {
|
|
|
+ $nowMinus3Months = date("Y-m-d", mktime(0,0,0, date('m') - 1, date('d'), date('Y')));
|
|
|
+ $sesUsers = DB::getPDO()->fetchAll("
|
|
|
+ select c.ID, c.CONF_KEY, c.CONF_VAL
|
|
|
+ from CRM_CONFIG c
|
|
|
+ where c.CONF_KEY like 'acl_user_%_%_cache_update'
|
|
|
+ and c.CONF_VAL > '{$nowMinus3Months}'
|
|
|
+ ");
|
|
|
+ $sesUsers = array_reduce( $sesUsers, function ($ret, $record) {
|
|
|
+ // $format = "acl_user_{ID_USERS}_{ID_PROCES}_cache_update";
|
|
|
+ list($idUser, $idProces) = explode('_', substr($record['CONF_KEY'], strlen('acl_user_'), -1 * strlen('_cache_update')));
|
|
|
+ if (!array_key_exists($idUser, $ret)) {
|
|
|
+ $ret[$idUser] = [
|
|
|
+ 'idUser' => $idUser,
|
|
|
+ 'lastUpdateAclCache' => $record['CONF_VAL'],
|
|
|
+ 'log' => []
|
|
|
+ ];
|
|
|
+ } else {
|
|
|
+ $ret[$idUser]['lastUpdateAclCache'] = ($record['CONF_VAL'] > $ret[$idUser]['lastUpdateAclCache'])
|
|
|
+ ? $record['CONF_VAL']
|
|
|
+ : $ret[$idUser]['lastUpdateAclCache'];
|
|
|
+ }
|
|
|
+ $ret[$idUser]['log'][] = [ 'ID_PROCES' => $idProces, 'data' => $record['CONF_VAL'] ];
|
|
|
+ return $ret;
|
|
|
+ }, [] );
|
|
|
+ $sesUsers = array_map(function ($sesGroup) {
|
|
|
+ return [
|
|
|
+ 'idUser' => $sesGroup['idUser'],
|
|
|
+ 'user' => DB::getPDO()->fetchValue("select u.ADM_ACCOUNT from ADMIN_USERS u where u.ID = {$sesGroup['idUser']}"),
|
|
|
+ 'lastUpdateAclCache' => $sesGroup['lastUpdateAclCache'],
|
|
|
+ 'log' => UI::h('span', [ 'style' => "color:#bbb" ], implode('<br>', array_map(function ($log) {
|
|
|
+ return ($log['ID_PROCES'] > 0)
|
|
|
+ ? "Filtr procesu {$log['ID_PROCES']} uruchomiony {$log['data']}"
|
|
|
+ : "Filtr ogólny uruchomiony {$log['data']}";
|
|
|
+ }, $sesGroup['log']))),
|
|
|
+ ];
|
|
|
+ }, $sesUsers);
|
|
|
+ usort($sesUsers, function ($ua, $ub) {
|
|
|
+ $a = $ua['lastUpdateAclCache'];
|
|
|
+ $b = $ub['lastUpdateAclCache'];
|
|
|
+ return ($a === $b)
|
|
|
+ ? 0
|
|
|
+ : ( ($a < $b)
|
|
|
+ ? 1
|
|
|
+ : -1
|
|
|
+ ) ;
|
|
|
+ });
|
|
|
+ UI::table([
|
|
|
+ 'caption' => UI::h('b', ['style' => "color:#000"], "Ostatnie logowania do aplikacji") . " <small>(update acl cache)</small>", // TODO: Aktualnie zalogowani użytkownicy
|
|
|
+ 'rows' => $sesUsers
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
}
|