This commit is contained in:
Luca 2021-10-05 14:16:27 +02:00
commit 35486b743d
6 changed files with 157 additions and 51 deletions

View File

@ -126,6 +126,7 @@ function start_complete_calendar(id, callback) {
ranges[globals.translations.secondSemester] = [moment("06", "MM"), moment("12", "MM").endOf('month')];
ranges[globals.translations.thisMonth] = [moment().startOf('month'), moment().endOf('month')];
ranges[globals.translations.lastMonth] = [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')];
ranges[globals.translations.nextMonth] = [moment().add(1, 'month').startOf('month'), moment().add(1, 'month').endOf('month')];
ranges[globals.translations.thisYear] = [moment().startOf('year'), moment().endOf('year')];
ranges[globals.translations.lastYear] = [moment().subtract(1, 'year').startOf('year'), moment().subtract(1, 'year').endOf('year')];

View File

@ -90,6 +90,7 @@ if (Auth::check()) {
'secondSemester' => tr('II semestre'),
'thisMonth' => tr('Questo mese'),
'lastMonth' => tr('Mese scorso'),
'nextMonth' => tr('Mese prossimo'),
'thisYear' => tr("Quest'anno"),
'lastYear' => tr('Anno scorso'),
'apply' => tr('Applica'),

View File

@ -49,11 +49,14 @@ switch (post('op')) {
break;
case 'change-vendita':
$percentuale = post('percentuale');
$prezzo_partenza = post('prezzo_partenza');
foreach ($id_records as $id) {
$articolo = Articolo::find($id);
$percentuale = post('percentuale');
$prezzo_partenza = post('prezzo_partenza')=='vendita' ? $articolo->prezzo_vendita : $articolo->prezzo_acquisto;
$new_prezzo_vendita = $articolo->prezzo_vendita + ($articolo->prezzo_vendita * $percentuale / 100);
$new_prezzo_vendita = $prezzo_partenza + ($prezzo_partenza * $percentuale / 100);
$articolo->setPrezzoVendita($new_prezzo_vendita, $articolo->idiva_vendita);
$articolo->save();
}
@ -167,6 +170,51 @@ switch (post('op')) {
download($file, 'articoli.csv');
break;
case 'change-categoria':
$categoria = post('id_categoria');
$n_articoli = 0;
foreach ($id_records as $id) {
$articolo = Articolo::find($id);
$articolo->id_categoria = $categoria;
$articolo->id_sottocategoria = null;
$articolo->save();
++$n_articoli;
}
if ($n_articoli > 0) {
flash()->info(tr('Categoria cambiata a _NUM_ articoli!', [
'_NUM_' => $n_articoli,
]));
} else {
flash()->warning(tr('Nessun articolo modificato!'));
}
break;
case 'change-iva':
$iva = post('id_iva');
$n_articoli = 0;
foreach ($id_records as $id) {
$articolo = Articolo::find($id);
$articolo->idiva_vendita = $iva;
$articolo->save();
++$n_articoli;
}
if ($n_articoli > 0) {
flash()->info(tr('Categoria cambiata a _NUM_ articoli!', [
'_NUM_' => $n_articoli,
]));
} else {
flash()->warning(tr('Nessun articolo modificato!'));
}
break;
}
if (App::debug()) {
@ -205,7 +253,9 @@ $operations['change-vendita'] = [
'text' => '<span><i class="fa fa-refresh"></i> '.tr('Aggiorna prezzo di vendita').'</span>',
'data' => [
'title' => tr('Aggiornare il prezzo di vendita per gli articoli selezionati?'),
'msg' => 'Per indicare uno sconto inserire la percentuale con il segno meno, al contrario per un rincaro inserire la percentuale senza segno.<br><br>{[ "type": "number", "label": "'.tr('Percentuale sconto/magg.').'", "name": "percentuale", "required": 1, "icon-after": "%" ]}',
'msg' => 'Per indicare uno sconto inserire la percentuale con il segno meno, al contrario per un rincaro inserire la percentuale senza segno.<br><br>
{[ "type": "select", "label": "'.tr('Partendo da:').'", "name": "prezzo_partenza", "required": 1, "values": "list=\"acquisto\":\"Prezzo di acquisto\",\"vendita\":\"Prezzo di vendita\"" ]}<br>
{[ "type": "number", "label": "'.tr('Percentuale sconto/magg.').'", "name": "percentuale", "required": 1, "icon-after": "%" ]}',
'button' => tr('Procedi'),
'class' => 'btn btn-lg btn-warning',
'blank' => false,
@ -250,4 +300,26 @@ $operations['crea-preventivo'] = [
],
];
$operations['change-categoria'] = [
'text' => '<span><i class="fa fa-briefcase"></i> '.tr('Aggiorna categoria').'</span>',
'data' => [
'title' => tr('Cambiare la categoria?'),
'msg' => tr('Per ciascun articolo selezionato, verrà modificata la categoria').'
<br><br>{[ "type": "select", "label": "'.tr('Categoria').'", "name": "id_categoria", "required": 1, "ajax-source": "categorie" ]}',
'button' => tr('Procedi'),
'class' => 'btn btn-lg btn-warning',
],
];
$operations['change-iva'] = [
'text' => '<span><i class="fa fa-percent"></i> '.tr('Aggiorna aliquota iva').'</span>',
'data' => [
'title' => tr('Cambiare l\'aliquota iva?'),
'msg' => tr('Per ciascun articolo selezionato, verrà modificata l\'aliquota iva').'
<br><br>{[ "type": "select", "label": "'.tr('Iva').'", "name": "id_iva", "required": 1, "ajax-source": "iva" ]}',
'button' => tr('Procedi'),
'class' => 'btn btn-lg btn-warning',
],
];
return $operations;

View File

@ -128,59 +128,60 @@ if (Services::isEnabled()) {
echo '
<hr><br>
<hr><br>
<div class="alert alert-warning hidden" role="alert" id="spazio-fe">
<i class="fa fa-warning"></i> '.tr('Spazio per Fatture Elettroniche in esaurimento: _NUM_/_TOT_', [
'_NUM_' => '<span id="spazio-fe-occupato"></span>',
'_TOT_' => '<span id="spazio-fe-totale"></span>',
]).'. '.tr("Contatta l'assistenza per maggiori informazioni").'.
</div>
<div class="alert alert-warning hidden" role="alert" id="spazio-fe">
<i class="fa fa-warning"></i> '.tr('Spazio per Fatture Elettroniche in esaurimento: _NUM_/_TOT_', [
'_NUM_' => '<span id="spazio-fe-occupato"></span>',
'_TOT_' => '<span id="spazio-fe-totale"></span>',
]).'. '.tr("Contatta l'assistenza per maggiori informazioni").'.
</div>
<h4>'.tr('Statistiche su Fatture Elettroniche').'</h4>
<table class="table table-striped">
<thead>
<tr>
<th>'.tr('Anno').'</th>
<th>
'.tr('Documenti archiviati').'
<span class="tip" title="'.tr('Fatture attive e relative ricevute, fatture passive').'.">
<i class="fa fa-question-circle-o"></i>
</span>
</th>
<h4>'.tr('Statistiche su Fatture Elettroniche').'</h4>
<table class="table table-striped">
<thead>
<tr>
<th>'.tr('Anno').'</th>
<th>
'.tr('Documenti archiviati').'
<span class="tip" title="'.tr('Fatture attive e relative ricevute, fatture passive').'.">
<i class="fa fa-question-circle-o"></i>
</span>
</th>
<th>
'.tr('Totale spazio occupato').'
<span class="tip" title="'.tr('Fatture attive con eventuali allegati e ricevute, fatture passive con eventuali allegati').'.">
<i class="fa fa-question-circle-o"></i>
</span>
</th>
</tr>
</thead>
<th>
'.tr('Totale spazio occupato').'
<span class="tip" title="'.tr('Fatture attive con eventuali allegati e ricevute, fatture passive con eventuali allegati').'.">
<i class="fa fa-question-circle-o"></i>
</span>
</th>
</tr>
</thead>
<tbody id="elenco-fe">
<tr class="info">
<td>'.tr('Totale').'</td>
<td id="fe_numero"></td>
<td id="fe_spazio"></td>
</tr>
</tbody>
</table>
<tbody id="elenco-fe">
<tr class="info">
<td>'.tr('Totale').'</td>
<td id="fe_numero"></td>
<td id="fe_spazio"></td>
</tr>
</tbody>
</table>
<script>
$(document).ready(function (){
aggiornaStatisticheFE();
});
</script>';
<script>
$(document).ready(function (){
aggiornaStatisticheFE();
});
</script>';
} else {
echo '
<div class="alert alert-warning" role="alert">
<i class="fa fa-warning"></i> '.tr('Nessuna risorsa Services abilitata').'.
</div>';
<div class="alert alert-warning" role="alert">
<i class="fa fa-warning"></i> '.tr('Nessuna risorsa Services abilitata').'.
</div>';
}
echo '
</div>
</div>
</div>';
} else {

View File

@ -22,23 +22,38 @@ namespace Modules\StatoServizi;
use API\Services;
use Carbon\Carbon;
use Hooks\Manager;
use Models\Module;
class ServicesHook extends Manager
{
public function response()
{
// Elaborazione dei servizi in scadenza
$limite_scadenze = (new Carbon())->addDays(60);
$risorse_in_scadenza = Services::getRisorseInScadenza($limite_scadenze);
$message = '';
$message = tr('I seguenti servizi sono in scadenza: _LIST_', [
'_LIST_' => implode(', ', $risorse_in_scadenza->pluck('name')->all()),
]);
// 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()),
]).'. ';
}
// 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()),
]);
}
$module = Module::pool('Stato dei servizi');
return [
'icon' => 'fa fa-refresh text-warning',
'message' => $message,
'show' => Services::isEnabled() && !$risorse_in_scadenza->isEmpty(),
'link' => base_path().'/controller.php?id_module='.$module->id,
'show' => Services::isEnabled() && !empty($message),
];
}

View File

@ -74,6 +74,22 @@ class Services
return collect(self::getInformazioni()['servizi']);
}
/**
* Restituisce i servizi in scadenza per data di conclusione prossima.
*
* @param Carbon $limite_scadenze
*
* @return \Illuminate\Support\Collection
*/
public static function getServiziInScadenza($limite_scadenze)
{
return self::getServiziAttivi()
->flatten(1)
->filter(function ($item) use ($limite_scadenze) {
return (isset($item['data_conclusione']) && Carbon::parse($item['data_conclusione'])->lessThan($limite_scadenze));
});
}
/**
* Restituisce le risorse attive in Services.
*