2020-11-27 16:49:10 +01:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
|
2021-01-20 15:08:51 +01:00
|
|
|
* Copyright (C) DevCode s.r.l.
|
2020-11-27 16:49:10 +01:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Modules\StatoServizi;
|
|
|
|
|
|
|
|
use API\Services;
|
|
|
|
use Carbon\Carbon;
|
2021-09-24 12:26:34 +02:00
|
|
|
use Hooks\Manager;
|
2020-11-27 16:49:10 +01:00
|
|
|
|
2021-09-24 12:26:34 +02:00
|
|
|
class ServicesHook extends Manager
|
2020-11-27 16:49:10 +01:00
|
|
|
{
|
|
|
|
public function response()
|
|
|
|
{
|
2021-09-03 20:14:30 +02:00
|
|
|
// Elaborazione dei servizi in scadenza
|
2021-09-24 12:26:34 +02:00
|
|
|
$limite_scadenze = (new Carbon())->addDays(60);
|
|
|
|
$risorse_in_scadenza = Services::getRisorseInScadenza($limite_scadenze);
|
2020-11-27 16:49:10 +01:00
|
|
|
|
|
|
|
$message = tr('I seguenti servizi sono in scadenza: _LIST_', [
|
2021-09-29 11:07:51 +02:00
|
|
|
'_LIST_' => implode(', ', $risorse_in_scadenza->pluck('name')->all()),
|
2020-11-27 16:49:10 +01:00
|
|
|
]);
|
|
|
|
|
|
|
|
return [
|
|
|
|
'icon' => 'fa fa-refresh text-warning',
|
|
|
|
'message' => $message,
|
2021-10-04 09:10:38 +02:00
|
|
|
'show' => Services::isEnabled() && !$risorse_in_scadenza->isEmpty(),
|
2020-11-27 16:49:10 +01:00
|
|
|
];
|
|
|
|
}
|
2021-09-03 20:14:30 +02:00
|
|
|
|
2021-09-24 12:26:34 +02:00
|
|
|
public function execute()
|
2021-09-03 20:14:30 +02:00
|
|
|
{
|
2021-09-24 12:26:34 +02:00
|
|
|
return false;
|
|
|
|
}
|
2021-09-03 20:14:30 +02:00
|
|
|
|
2021-09-24 12:26:34 +02:00
|
|
|
public function needsExecution()
|
|
|
|
{
|
|
|
|
return false;
|
2021-09-03 20:14:30 +02:00
|
|
|
}
|
2020-11-27 16:49:10 +01:00
|
|
|
}
|