1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2025-02-01 16:36:45 +01:00

Miglioramenti ultimi commit

@lucasalva87
This commit is contained in:
Thomas Zilio 2018-10-31 16:22:19 +01:00
parent 699bf029d9
commit fdcc16cf14
5 changed files with 28 additions and 82 deletions

View File

@ -2,6 +2,8 @@
include_once __DIR__.'/core.php';
use Carbon\Carbon;
if (empty($id_record) && !empty($id_module)) {
redirect(ROOTDIR.'/controller.php?id_module='.$id_module);
} elseif (empty($id_record) && empty($id_module)) {
@ -201,20 +203,20 @@ if (empty($record)) {
// Informazioni sulle operazioni
if (Auth::admin()) {
echo ' <div id="tab_info" class="tab-pane">';
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">';
if (!empty($operations)) {
echo '
<ul class="timeline">';
foreach ($operations as $operation) {
$description = $operation['op'];
$icon = 'pencil-square-o';
$color = null;
$timeline = null;
$timeline_class = null;
switch ($operation['op']) {
case 'add':
@ -236,12 +238,12 @@ if (empty($record)) {
break;
default:
$timeline = ' class="timeline-inverted"';
$timeline_class = ' class="timeline-inverted"';
break;
}
echo '
<li'.$timeline.'>
<li '.$timeline_class.'>
<div class="timeline-badge '.$color.'"><i class="fa fa-'.$icon.'"></i></div>
<div class="timeline-panel">
<div class="timeline-heading">
@ -250,7 +252,7 @@ if (empty($record)) {
<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 tip" title="'.Translator::timestampToLocale($operation['created_at']).'"><i class="fa fa-clock-o"></i> '.Carbon::parse($operation['created_at'])->diffForHumans().'</small></p>
<p><small class="label label-default"><i class="fa fa-user"></i> '.tr('_USER_', [
'_USER_' => $operation['username'],
]).
@ -259,25 +261,25 @@ if (empty($record)) {
</div>
</div>
<div class="timeline-body">
</div>
<div class="timeline-footer">
</div>
</div>
</li>';
}
}
echo ' </ul>';
}else{
echo '
} 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>';
echo '
</div>';
}
// Plugin

View File

@ -368,45 +368,3 @@ 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';
}

View File

@ -1,5 +1,7 @@
<?php
use Carbon\Carbon;
switch ($resource) {
case 'sync':
// Normalizzazione degli interventi a database
@ -64,7 +66,7 @@ switch ($resource) {
$dbo->insert('in_interventi', [
'idintervento' => $idintervento,
'idanagrafica' => setting('Azienda predefinita'),
'data_richiesta' => \Carbon::now(),
'data_richiesta' => Carbon::now(),
'richiesta' => $richiesta,
'idtipointervento' => 0,
'idstatointervento' => 'CALL',

View File

@ -188,29 +188,8 @@ class FileManager implements ManagerInterface
<script>
$(document).ready(function(){
$("#'.$attachment_id.' #categoria").autocomplete({';
$n_categorie = 0;
foreach ($categories as $category) {
if (!empty($category['category'])){
if ($n_categorie==0){
$result .= '
source: [';
}
$result .= '
"'.$category['category'].'",';
$n_categorie++;
}
}
if ($n_categorie>0){
$result .= '
],';
}else{
$result .= '
source:"[]",';
}
$result .= '
$("#'.$attachment_id.' #categoria").autocomplete({
source: '.json_encode(array_column($categories, 'category')).',
minLength: 0
}).focus(function() {
$(this).autocomplete("search", $(this).val())

View File

@ -1,5 +1,7 @@
<?php
use Carbon\Carbon;
/**
* Classe per gestire le traduzioni del progetto.
*
@ -116,6 +118,9 @@ class Translator extends Util\Singleton
$this->translator->setLocale($locale);
$this->locale = $locale;
setlocale(LC_TIME, $locale);
Carbon::setLocale($locale);
self::$formatter = new Intl\Formatter(
$this->locale,
empty($formatter['timestamp']) ? 'd/m/Y H:i' : $formatter['timestamp'],