1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2025-02-08 07:38:54 +01:00

Migliorata visualizzazione log operazioni

This commit is contained in:
Luca 2018-10-30 20:33:28 +01:00
parent 249ed83f90
commit c9e5d86dc3
2 changed files with 100 additions and 37 deletions

View File

@ -201,12 +201,15 @@ if (empty($record)) {
// Informazioni sulle operazioni
if (Auth::admin()) {
echo '
<div id="tab_info" class="tab-pane">
<ul class="timeline">';
echo ' <div id="tab_info" class="tab-pane">';
$operations = $dbo->fetchArray('SELECT `zz_operations`.*, `zz_users`.`username` FROM `zz_operations` JOIN `zz_users` ON `zz_operations`.`id_utente` = `zz_users`.`id` WHERE id_module = '.prepare($id_module).' AND id_record = '.prepare($id_record).' ORDER BY `created_at` ASC LIMIT 200');
if (count($operations)>0){
echo ' <ul class="timeline">';
foreach ($operations as $operation) {
$description = $operation['op'];
$icon = 'pencil-square-o';
@ -242,22 +245,40 @@ if (empty($record)) {
<div class="timeline-badge '.$color.'"><i class="fa fa-'.$icon.'"></i></div>
<div class="timeline-panel">
<div class="timeline-heading">
<div class="row">
<div class="col-md-8">
<h4 class="timeline-title">'.$description.'</h4>
<p><small class="text-muted"><i class="fa fa-clock-o"></i> '.Translator::timestampToLocale($operation['created_at']).'</small></p>
</div>
<div class="col-md-4 text-right">
<p><small class="label label-default tip" title="'.Translator::timestampToLocale($operation['created_at']).'"><i class="fa fa-clock-o"></i> '.time_elapsed_string($operation['created_at']).'</small></p>
<p><small class="label label-default"><i class="fa fa-user"></i> '.tr('_USER_', [
'_USER_' => $operation['username'],
]).
'</small></p>
</div>
</div>
</div>
<div class="timeline-body">
<p>'.tr('Utente: _USER_', [
'_USER_' => $operation['username'],
]).'</p>
</div>
<div class="timeline-footer">
</div>
</div>
</li>';
}
echo ' </ul>';
}else{
echo '
</ul>
<div class="alert alert-info">
<i class="fa fa-info-circle"></i>
<b>'.tr('Informazione:').'</b> '.tr('Nessun log disponibile per questa scheda').'.
</div>';
}
echo ' </div>';
}
// Plugin
$module_record = $record;

View File

@ -368,3 +368,45 @@ function searchFieldName($field)
{
return str_replace([' ', '.'], ['-', ''], $field);
}
/**
* Restituisce il tempo trascorso tra un timestamp e questo momento.
*
* @param string $datetime
* @param bool $full
*
* @return string
*/
function time_elapsed_string($datetime, $full = false) {
$now = new DateTime;
$ago = new DateTime($datetime);
$diff = $now->diff($ago);
$diff->w = floor($diff->d / 7);
$diff->d -= $diff->w * 7;
$string = array(
'y' => 'ann',
'm' => 'mes',
'w' => 'settiman',
'd' => 'giorn',
'h' => 'or',
'i' => 'minut',
's' => 'second',
);
foreach ($string as $k => &$v) {
if ($diff->$k) {
if ($v == 'settiman' or $v == 'or')
$v = $diff->$k . ' ' . $v . ($diff->$k > 1 ? 'e' : 'a');
else if ($v == 'mes')
$v = $diff->$k . ' ' . $v . ($diff->$k > 1 ? 'i' : 'e');
else
$v = $diff->$k . ' ' . $v . ($diff->$k > 1 ? 'i' : 'o');
} else {
unset($string[$k]);
}
}
if (!$full) $string = array_slice($string, 0, 1);
return $string ? implode(', ', $string) . ' fa' : 'adesso';
}