mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-06-05 22:09:38 +02:00
Migliorata visualizzazione log operazioni
This commit is contained in:
95
editor.php
95
editor.php
@@ -201,62 +201,83 @@ if (empty($record)) {
|
|||||||
|
|
||||||
// Informazioni sulle operazioni
|
// Informazioni sulle operazioni
|
||||||
if (Auth::admin()) {
|
if (Auth::admin()) {
|
||||||
echo '
|
|
||||||
<div id="tab_info" class="tab-pane">
|
echo ' <div id="tab_info" class="tab-pane">';
|
||||||
<ul class="timeline">';
|
|
||||||
|
|
||||||
$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');
|
$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){
|
||||||
|
|
||||||
foreach ($operations as $operation) {
|
echo ' <ul class="timeline">';
|
||||||
$description = $operation['op'];
|
|
||||||
$icon = 'pencil-square-o';
|
|
||||||
$color = null;
|
|
||||||
$timeline = null;
|
|
||||||
|
|
||||||
switch ($operation['op']) {
|
foreach ($operations as $operation) {
|
||||||
case 'add':
|
$description = $operation['op'];
|
||||||
$description = tr('Creazione');
|
$icon = 'pencil-square-o';
|
||||||
$icon = 'plus';
|
$color = null;
|
||||||
$color = 'success';
|
$timeline = null;
|
||||||
break;
|
|
||||||
|
|
||||||
case 'update':
|
switch ($operation['op']) {
|
||||||
$description = tr('Modifica');
|
case 'add':
|
||||||
$icon = 'pencil';
|
$description = tr('Creazione');
|
||||||
$color = 'info';
|
$icon = 'plus';
|
||||||
break;
|
$color = 'success';
|
||||||
|
break;
|
||||||
|
|
||||||
case 'delete':
|
case 'update':
|
||||||
$description = tr('Eliminazione');
|
$description = tr('Modifica');
|
||||||
$icon = 'times';
|
$icon = 'pencil';
|
||||||
$color = 'danger';
|
$color = 'info';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
case 'delete':
|
||||||
$timeline = ' class="timeline-inverted"';
|
$description = tr('Eliminazione');
|
||||||
break;
|
$icon = 'times';
|
||||||
}
|
$color = 'danger';
|
||||||
|
break;
|
||||||
|
|
||||||
echo '
|
default:
|
||||||
|
$timeline = ' class="timeline-inverted"';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '
|
||||||
<li'.$timeline.'>
|
<li'.$timeline.'>
|
||||||
<div class="timeline-badge '.$color.'"><i class="fa fa-'.$icon.'"></i></div>
|
<div class="timeline-badge '.$color.'"><i class="fa fa-'.$icon.'"></i></div>
|
||||||
<div class="timeline-panel">
|
<div class="timeline-panel">
|
||||||
<div class="timeline-heading">
|
<div class="timeline-heading">
|
||||||
<h4 class="timeline-title">'.$description.'</h4>
|
<div class="row">
|
||||||
<p><small class="text-muted"><i class="fa fa-clock-o"></i> '.Translator::timestampToLocale($operation['created_at']).'</small></p>
|
<div class="col-md-8">
|
||||||
|
<h4 class="timeline-title">'.$description.'</h4>
|
||||||
|
</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>
|
||||||
<div class="timeline-body">
|
<div class="timeline-body">
|
||||||
<p>'.tr('Utente: _USER_', [
|
|
||||||
'_USER_' => $operation['username'],
|
</div>
|
||||||
]).'</p>
|
<div class="timeline-footer">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</li>';
|
</li>';
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '
|
echo ' </ul>';
|
||||||
</ul>
|
|
||||||
</div>';
|
}else{
|
||||||
|
echo '
|
||||||
|
<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
|
// Plugin
|
||||||
|
@@ -368,3 +368,45 @@ function searchFieldName($field)
|
|||||||
{
|
{
|
||||||
return str_replace([' ', '.'], ['-', ''], $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';
|
||||||
|
}
|
Reference in New Issue
Block a user