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.secondSemester] = [moment("06", "MM"), moment("12", "MM").endOf('month')];
ranges[globals.translations.thisMonth] = [moment().startOf('month'), moment().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.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.thisYear] = [moment().startOf('year'), moment().endOf('year')];
ranges[globals.translations.lastYear] = [moment().subtract(1, 'year').startOf('year'), moment().subtract(1, 'year').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'), 'secondSemester' => tr('II semestre'),
'thisMonth' => tr('Questo mese'), 'thisMonth' => tr('Questo mese'),
'lastMonth' => tr('Mese scorso'), 'lastMonth' => tr('Mese scorso'),
'nextMonth' => tr('Mese prossimo'),
'thisYear' => tr("Quest'anno"), 'thisYear' => tr("Quest'anno"),
'lastYear' => tr('Anno scorso'), 'lastYear' => tr('Anno scorso'),
'apply' => tr('Applica'), 'apply' => tr('Applica'),

View File

@ -49,11 +49,14 @@ switch (post('op')) {
break; break;
case 'change-vendita': case 'change-vendita':
$percentuale = post('percentuale');
$prezzo_partenza = post('prezzo_partenza');
foreach ($id_records as $id) { foreach ($id_records as $id) {
$articolo = Articolo::find($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->setPrezzoVendita($new_prezzo_vendita, $articolo->idiva_vendita);
$articolo->save(); $articolo->save();
} }
@ -167,6 +170,51 @@ switch (post('op')) {
download($file, 'articoli.csv'); download($file, 'articoli.csv');
break; 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()) { if (App::debug()) {
@ -205,7 +253,9 @@ $operations['change-vendita'] = [
'text' => '<span><i class="fa fa-refresh"></i> '.tr('Aggiorna prezzo di vendita').'</span>', 'text' => '<span><i class="fa fa-refresh"></i> '.tr('Aggiorna prezzo di vendita').'</span>',
'data' => [ 'data' => [
'title' => tr('Aggiornare il prezzo di vendita per gli articoli selezionati?'), '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'), 'button' => tr('Procedi'),
'class' => 'btn btn-lg btn-warning', 'class' => 'btn btn-lg btn-warning',
'blank' => false, '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; return $operations;

View File

@ -182,6 +182,7 @@ if (Services::isEnabled()) {
echo ' echo '
</div> </div>
</div>
</div>'; </div>';
} else { } else {
/* /*

View File

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