2024-02-22 15:58:03 +01:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
|
|
|
|
* Copyright (C) DevCode s.r.l.
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
include_once __DIR__.'/../../core.php';
|
|
|
|
|
2024-03-22 15:52:24 +01:00
|
|
|
if (setting('Attiva notifica di presenza utenti sul record')) {
|
|
|
|
echo '
|
2024-02-22 15:58:03 +01:00
|
|
|
<table class="table table-hover table-condensed">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
2024-02-23 13:14:38 +01:00
|
|
|
<th>'.tr('Modulo').'</th>
|
|
|
|
<th>'.tr('Record').'</th>
|
|
|
|
<th>'.tr('Data e ora accesso').'</th>
|
|
|
|
<th>'.tr('Ultimo aggiornamento').'</th>
|
|
|
|
<!--th>'.tr('Permanenza').'</th-->
|
2024-02-22 15:58:03 +01:00
|
|
|
</tr>
|
|
|
|
</thead>';
|
|
|
|
|
2024-03-22 15:52:24 +01:00
|
|
|
$sessioni = $dbo->fetchArray('SELECT
|
2024-03-05 16:01:45 +01:00
|
|
|
`zz_semaphores`.*,
|
|
|
|
SUBSTRING_INDEX(`posizione`, ",", -1) AS id_record,
|
2024-04-18 17:44:05 +02:00
|
|
|
`zz_modules_lang`.`title` AS modulo,
|
2024-03-05 16:01:45 +01:00
|
|
|
TIMESTAMPDIFF(SECOND, `zz_semaphores`.`created_at`, `zz_semaphores`.`updated`) AS permanenza,
|
|
|
|
`zz_users`.`username` AS utente
|
|
|
|
FROM
|
|
|
|
`zz_semaphores`
|
|
|
|
INNER JOIN `zz_modules` ON SUBSTRING_INDEX(`posizione`, ",", 1) = `zz_modules`.`id`
|
2024-03-22 15:52:24 +01:00
|
|
|
LEFT JOIN `zz_modules_lang` ON (`zz_modules`.`id` = `zz_modules_lang`.`id_record` AND `zz_modules_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).')
|
2024-03-05 16:01:45 +01:00
|
|
|
INNER JOIN `zz_users` ON `zz_semaphores`.`id_utente` = `zz_users`.`id`
|
|
|
|
ORDER BY
|
|
|
|
`utente` ASC, SUBSTRING_INDEX(`posizione`, ",", -1) ASC');
|
2024-02-23 13:14:38 +01:00
|
|
|
|
2024-03-22 15:52:24 +01:00
|
|
|
$gruppi = collect($sessioni)->groupBy('utente');
|
|
|
|
$i = 0;
|
|
|
|
foreach ($gruppi as $utente => $sessioni) {
|
|
|
|
$utente = Models\User::find($sessioni[$i]['id_utente']);
|
|
|
|
++$i;
|
2024-02-22 15:58:03 +01:00
|
|
|
|
2024-03-22 15:52:24 +01:00
|
|
|
echo '
|
2024-02-22 15:58:03 +01:00
|
|
|
<thead>
|
|
|
|
<tr>
|
2024-03-22 15:52:24 +01:00
|
|
|
<th colspan="5" class="text-center text-muted" >'.(($utente->photo) ? "<img class='attachment-img tip' title=".$utente->username.' src='.$utente->photo.'>' : "<i class='fa fa-user-circle-o attachment-img tip' title=".$utente->username.'></i>').'<span class="direct-chat-name"> '.$utente->anagrafica->ragione_sociale.' ['.$utente->gruppo.']</span></th>
|
2024-02-22 15:58:03 +01:00
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
|
|
|
|
<tbody>';
|
|
|
|
|
2024-03-22 15:52:24 +01:00
|
|
|
foreach ($sessioni as $sessione) {
|
|
|
|
$class = 'info';
|
2024-02-22 15:58:03 +01:00
|
|
|
|
2024-03-22 15:52:24 +01:00
|
|
|
echo '
|
2024-02-22 15:58:03 +01:00
|
|
|
<tr class="'.$class.'" data-id="'.$sessione['id'].'" data-nome='.json_encode($sessione['name']).'>
|
|
|
|
<td>
|
2024-02-23 13:14:38 +01:00
|
|
|
'.$sessione['modulo'].'
|
2024-02-22 15:58:03 +01:00
|
|
|
</td>
|
|
|
|
|
2024-02-23 13:14:38 +01:00
|
|
|
<td>
|
2024-02-22 15:58:03 +01:00
|
|
|
'.$sessione['id_record'].'
|
|
|
|
</td>
|
|
|
|
|
2024-02-23 13:14:38 +01:00
|
|
|
<td>
|
2024-02-22 15:58:03 +01:00
|
|
|
'.Translator::timestampToLocale($sessione['created_at']).'
|
|
|
|
</td>
|
|
|
|
|
2024-02-23 13:14:38 +01:00
|
|
|
<td>
|
|
|
|
<span class="tip" title="'.Translator::timestampToLocale($sessione['updated']).'" >'.Carbon\Carbon::parse($sessione['updated'])->diffForHumans().'</span>
|
2024-02-22 15:58:03 +01:00
|
|
|
</td>
|
|
|
|
|
2024-02-23 13:14:38 +01:00
|
|
|
<!--td>
|
|
|
|
<span class="tip" title="'.Translator::timestampToLocale($sessione['updated']).'" >'.gmdate('H:i:s', $sessione['permanenza']).'</span>
|
|
|
|
</td-->
|
2024-02-22 15:58:03 +01:00
|
|
|
|
|
|
|
</tr>';
|
2024-03-22 15:52:24 +01:00
|
|
|
}
|
2024-02-22 15:58:03 +01:00
|
|
|
}
|
2024-03-22 15:52:24 +01:00
|
|
|
echo '
|
2024-02-22 15:58:03 +01:00
|
|
|
</tbody>
|
|
|
|
</table>';
|
2024-03-22 15:52:24 +01:00
|
|
|
} else {
|
2024-02-22 15:58:03 +01:00
|
|
|
echo '<span>Non è possibile monitorare la presenta degli utenti.</span>';
|
|
|
|
}
|