mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-16 19:40:44 +01:00
Migliorati messaggi su stato dei servizi
This commit is contained in:
parent
5955aeeb97
commit
7bec13cc2a
@ -25,16 +25,16 @@ include_once __DIR__.'/../../core.php';
|
||||
// Informazioni sui servizi attivi
|
||||
echo '
|
||||
<div class="row">';
|
||||
|
||||
$limite_scadenze = (new Carbon())->addDays(60);
|
||||
$days = 60;
|
||||
$limite_scadenze = (new Carbon())->addDays($days);
|
||||
if (Services::isEnabled()) {
|
||||
echo '
|
||||
<!-- Informazioni sui Servizi attivi -->
|
||||
<div class="col-md-12 col-lg-6">
|
||||
<div class="box box-success">
|
||||
<div class="box box-primary">
|
||||
<div class="box-header">
|
||||
<h3 class="box-title">
|
||||
'.tr('Servizi attivi').'
|
||||
'.tr('Servizi').'
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
@ -43,12 +43,12 @@ if (Services::isEnabled()) {
|
||||
$servizi = Services::getServiziAttivi()->flatten(1);
|
||||
if (!$servizi->isEmpty()) {
|
||||
echo '
|
||||
<table class="table table-striped table-hover">
|
||||
<table class="box-body table table-striped table-hover table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="50%">'.tr('Nome').'</th>
|
||||
<th>'.tr('Tipo').'</th>
|
||||
<th>'.tr('Nome').'</th>
|
||||
<th>'.tr('Scadenza').'</th>
|
||||
<th width="30%">'.tr('Scadenza').'</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@ -57,9 +57,9 @@ if (Services::isEnabled()) {
|
||||
$scadenza = Carbon::parse($servizio['data_conclusione']);
|
||||
|
||||
echo '
|
||||
<tr class="'.($scadenza->lessThan($limite_scadenze) ? 'info' : '').'">
|
||||
<td>'.$servizio['sottocategoria'].'</td>
|
||||
<tr class="'.($scadenza->lessThan(Carbon::now()) ? 'danger' : ($scadenza->lessThan($limite_scadenze) ? 'warning' : '')).'">
|
||||
<td>'.$servizio['codice'].' - '.$servizio['nome'].'</td>
|
||||
<td>'.$servizio['sottocategoria'].'</td>
|
||||
<td>'.dateFormat($scadenza).' ('.$scadenza->diffForHumans().')</td>
|
||||
</tr>';
|
||||
}
|
||||
@ -84,7 +84,7 @@ if (Services::isEnabled()) {
|
||||
<div class="box box-primary">
|
||||
<div class="box-header">
|
||||
<h3 class="box-title">
|
||||
'.tr('Risorse Services').'
|
||||
'.tr('Risorse').'
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
@ -94,26 +94,39 @@ if (Services::isEnabled()) {
|
||||
$risorse_attive = Services::getRisorseAttive();
|
||||
if (!$risorse_attive->isEmpty()) {
|
||||
$risorse_in_scadenza = Services::getRisorseInScadenza($limite_scadenze);
|
||||
$risorse_scadute = Services::getRisorseScadute();
|
||||
|
||||
if (!$risorse_in_scadenza->isEmpty()) {
|
||||
echo '
|
||||
<div class="alert alert-warning" role="alert"> <i class="fa fa-warning"></i> '.tr('Attenzione, _NUM_ risorse sono in scadenza:', [
|
||||
'_NUM_' => $risorse_in_scadenza->count(),
|
||||
]).'</div>';
|
||||
if (!$risorse_in_scadenza->isEmpty() || !$risorse_scadute->isEmpty() ) {
|
||||
|
||||
if (!$risorse_in_scadenza->isEmpty()){
|
||||
echo '
|
||||
<div class="alert alert-warning" role="alert"> <i class="fa fa-clock-o"></i> '.tr('Attenzione, _NUM_ risorse sono in scadenza o stanno per esaurire i crediti:', [
|
||||
'_NUM_' => $risorse_in_scadenza->count(),
|
||||
]).'</div>';
|
||||
|
||||
}
|
||||
|
||||
if (!$risorse_scadute->isEmpty()){
|
||||
echo '
|
||||
<div class="alert alert-danger" role="alert"> <i class="fa fa-exclamation-triangle"></i> '.tr('Attenzione, _NUM_ risorse sono scadute o hanno esaurito i crediti:', [
|
||||
'_NUM_' => $risorse_scadute->count(),
|
||||
]).'</div>';
|
||||
}
|
||||
|
||||
} else {
|
||||
echo '
|
||||
<div class="alert alert-success" role="alert"> <i class="fa fa-check"></i> '.tr('Bene, tutte le risorse sono attive e non presentano avvisi:', [
|
||||
<div class="alert alert-success" role="alert"> <i class="fa fa-check-circle"></i> '.tr('Bene, tutte le risorse sono attive e non presentano avvisi:', [
|
||||
'_NUM_' => $risorse_attive->count(),
|
||||
]).'</div>';
|
||||
}
|
||||
|
||||
echo '
|
||||
<table class="table table-striped table-hover">
|
||||
<table class="box-body table table-striped table-hover table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="50%">'.tr('Nome').'</th>
|
||||
<th>'.tr('Crediti').'</th>
|
||||
<th>'.tr('Scadenza').'</th>
|
||||
<th width="30%">'.tr('Scadenza').'</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@ -122,24 +135,23 @@ if (Services::isEnabled()) {
|
||||
foreach ($risorse_attive as $servizio) {
|
||||
$scadenza = Carbon::parse($servizio['expiration_at']);
|
||||
echo '
|
||||
<tr>
|
||||
<tr class="'.($scadenza->lessThan(Carbon::now()) ? 'danger' : ($scadenza->lessThan($limite_scadenze) ? 'warning' : '')).'">
|
||||
<td>'.$servizio['name'].'</td>
|
||||
<td>'.(($servizio['credits'] < 100 && $servizio['credits']) ? '<b><i class="fa fa-icon fa-warning" ></i>' : '').(($servizio['credits']) ? $servizio['credits'] : '-').(($servizio['credits'] < 100 && $servizio['credits']) ? '</b>' : '').'</td>
|
||||
<td>'.((Carbon::now()->diffInDays($scadenza, false) < 60 && $scadenza) ? '<b><i class="fa fa-icon fa-warning" ></i>' : '').dateFormat($scadenza).' ('.$scadenza->diffForHumans().')'.((Carbon::now()->diffInDays($scadenza, false) < 60 && $scadenza) ? '</b>' : '').'</td>
|
||||
<td>'.((Carbon::now()->diffInDays($scadenza, false) < $days && $scadenza) ? '<b><i class="fa fa-icon fa-warning" ></i>' : '').dateFormat($scadenza).' ('.$scadenza->diffForHumans().')'.((Carbon::now()->diffInDays($scadenza, false) < $days && $scadenza) ? '</b>' : '').'</td>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
echo '
|
||||
</tbody>
|
||||
</table><hr>';
|
||||
</table></div></div>';
|
||||
|
||||
//Il servizio Fatturazione Elettronica deve essere presente per visualizzare le Statistiche su Fatture Elettroniche
|
||||
if (Services::getRisorseAttive()->where('name', 'Fatturazione Elettronica')->count()) {
|
||||
echo '
|
||||
|
||||
<div class="panel panel-info">
|
||||
|
||||
<div class="panel-heading" > <i class="fa fa-file"></i> '.tr('Statistiche su Fatture Elettroniche').'</div>
|
||||
<div class="panel-heading" > <i class="fa fa-bar-chart"></i> '.tr('Statistiche su Fatture Elettroniche').'</div>
|
||||
|
||||
<div class="panel-body">
|
||||
|
||||
@ -161,7 +173,7 @@ if (Services::isEnabled()) {
|
||||
</div>
|
||||
|
||||
|
||||
<table class="table table-striped">
|
||||
<table class="box-body table table-striped table-hover table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>'.tr('Anno').'</th>
|
||||
@ -182,7 +194,7 @@ if (Services::isEnabled()) {
|
||||
</thead>
|
||||
|
||||
<tbody id="elenco-fe">
|
||||
<tr class="info">
|
||||
<tr style="background-color:#CCCCCC;" >
|
||||
<td>'.tr('Totale').'</td>
|
||||
<td id="fe_numero"></td>
|
||||
<td id="fe_spazio"></td>
|
||||
@ -205,9 +217,6 @@ if (Services::isEnabled()) {
|
||||
}
|
||||
|
||||
echo '
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>';
|
||||
} else {
|
||||
/*
|
||||
@ -303,7 +312,7 @@ function aggiornaStatisticheFE(){
|
||||
const data = response.history[i];
|
||||
if (data["year"] == '.date('Y').'){
|
||||
|
||||
var highlight = "<tr style=\"background-color:#FFFEEE;\" >";
|
||||
var highlight = "<tr class=\"info\" >";
|
||||
var number = data["number"];
|
||||
|
||||
if (response.maxNumber>0 && response.maxNumber)
|
||||
|
@ -34,23 +34,46 @@ class ServicesHook extends Manager
|
||||
// Elaborazione dei servizi in scadenza
|
||||
$servizi_in_scadenza = Services::getServiziInScadenza($limite_scadenze);
|
||||
if (!$servizi_in_scadenza->isEmpty()) {
|
||||
$message .= tr('I seguenti servizi sono in scadenza: _LIST_', [
|
||||
'_LIST_' => implode(', ', $servizi_in_scadenza->pluck('nome')->all()),
|
||||
]).'. ';
|
||||
$message .= '<i class="fa fa-clock-o text-warning"> </i> ';
|
||||
$message .= tr('I seguenti servizi sono in scadenza:<ul><li> _LIST_', [
|
||||
'_LIST_' => implode('</li><li>', $servizi_in_scadenza->pluck('nome')->all()),
|
||||
]).'</ul>';
|
||||
}
|
||||
|
||||
|
||||
// Elaborazione delle risorse Services scadute
|
||||
$risorse_scadute = Services::getRisorseScadute();
|
||||
if (!$risorse_scadute->isEmpty()) {
|
||||
$message .= '<i class="fa fa-exclamation-triangle text-danger"> </i> ';
|
||||
$message .= tr('Le seguenti risorse sono scadute:<ul><li> _LIST_', [
|
||||
'_LIST_' => implode('</li><li>', $risorse_scadute->pluck('name')->all()),
|
||||
]).'</ul>';
|
||||
}
|
||||
|
||||
// Elaborazione dei servizi scaduti
|
||||
$servizi_scaduti = Services::getServiziScaduti();
|
||||
if (!$servizi_scaduti->isEmpty()) {
|
||||
$message .= '<i class="fa fa-exclamation-triangle text-danger"> </i> ';
|
||||
$message .= tr('I seguenti servizi sono scaduti:<ul><li> _LIST_', [
|
||||
'_LIST_' => implode('</li><li>', $servizi_scaduti->pluck('nome')->all()),
|
||||
]).'</ul>';
|
||||
}
|
||||
|
||||
|
||||
// Elaborazione delle risorse Services in scadenza
|
||||
$risorse_in_scadenza = Services::getRisorseInScadenza($limite_scadenze);
|
||||
if (!$risorse_in_scadenza->isEmpty()) {
|
||||
$message .= tr('Le seguenti risorse Services sono in scadenza: _LIST_', [
|
||||
'_LIST_' => implode(', ', $risorse_in_scadenza->pluck('name')->all()),
|
||||
]);
|
||||
$message .= '<i class="fa fa-clock-o text-warning"> </i> ';
|
||||
$message .= tr('Le seguenti risorse sono in scadenza:<ul><li> _LIST_', [
|
||||
'_LIST_' => implode('</li><li>', $risorse_in_scadenza->pluck('name')->all()),
|
||||
]).'</ul>';
|
||||
}
|
||||
|
||||
|
||||
$module = Module::pool('Stato dei servizi');
|
||||
|
||||
return [
|
||||
'icon' => 'fa fa-refresh text-warning',
|
||||
'icon' => null,
|
||||
'message' => $message,
|
||||
'link' => base_path().'/controller.php?id_module='.$module->id,
|
||||
'show' => Services::isEnabled() && !empty($message),
|
||||
|
@ -86,7 +86,21 @@ class Services
|
||||
return self::getServiziAttivi()
|
||||
->flatten(1)
|
||||
->filter(function ($item) use ($limite_scadenze) {
|
||||
return isset($item['data_conclusione']) && Carbon::parse($item['data_conclusione'])->lessThan($limite_scadenze);
|
||||
return isset($item['data_conclusione']) && Carbon::parse($item['expiration_at'])->greaterThan(Carbon::now()) && Carbon::parse($item['data_conclusione'])->lessThan($limite_scadenze);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Restituisce i servizi scaduti.
|
||||
*
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public static function getServiziScaduti()
|
||||
{
|
||||
return self::getServiziAttivi()
|
||||
->flatten(1)
|
||||
->filter(function ($item) use ($limite_scadenze) {
|
||||
return isset($item['data_conclusione']) && Carbon::parse($item['data_conclusione'])->lessThan(Carbon::now());
|
||||
});
|
||||
}
|
||||
|
||||
@ -123,11 +137,27 @@ class Services
|
||||
{
|
||||
return self::getRisorseAttive()
|
||||
->filter(function ($item) use ($limite_scadenze) {
|
||||
return (isset($item['expiration_at']) && Carbon::parse($item['expiration_at'])->lessThan($limite_scadenze))
|
||||
return (isset($item['expiration_at']) && Carbon::parse($item['expiration_at'])->greaterThan(Carbon::now()) && Carbon::parse($item['expiration_at'])->lessThan($limite_scadenze))
|
||||
|| (isset($item['credits']) && $item['credits'] < 100);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Restituisce le risorse scadute per assenza di crediti oppure per data di fine prossima.
|
||||
*
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public static function getRisorseScadute()
|
||||
{
|
||||
return self::getRisorseAttive()
|
||||
->filter(function ($item) use ($limite_scadenze) {
|
||||
return (isset($item['expiration_at']) && Carbon::parse($item['expiration_at'])->lessThan(Carbon::now()))
|
||||
|| (isset($item['credits']) && $item['credits'] < 0);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Effettua una richiesta a Services.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user