Aggiunto hook per ricevute in errore o in attesa
This commit is contained in:
parent
9138591d2f
commit
bcfd453b5b
|
@ -239,7 +239,7 @@ class Mastrino extends Model
|
|||
$totale_da_distribuire -= $scadenza_da_pagare;
|
||||
}
|
||||
|
||||
// In caso alternativo, assegno il rimanente da distrubuire interamente alla scadenza
|
||||
// In caso alternativo, assegno il rimanente da distribuire interamente alla scadenza
|
||||
else {
|
||||
$pagato = $totale_da_distribuire;
|
||||
$totale_da_distribuire = 0;
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
/*
|
||||
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
|
||||
* Copyright (C) DevCode s.r.l.
|
||||
*
|
||||
* 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 Plugins\ReceiptFE;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Hooks\Manager;
|
||||
use Modules;
|
||||
use Modules\Fatture\Fattura;
|
||||
use Plugins;
|
||||
|
||||
class NotificheRicevuteHook extends Manager
|
||||
{
|
||||
public function response()
|
||||
{
|
||||
// Messaggio informativo su fatture con stato di errore
|
||||
$con_errore = Fattura::vendita()
|
||||
->whereIn('codice_stato_fe', ['NS', 'ERR', 'EC02'])
|
||||
->where('data_stato_fe', '>=', $_SESSION['period_start'])
|
||||
->orderBy('data_stato_fe')
|
||||
->count();
|
||||
|
||||
// Controllo se ci sono fatture in elaborazione da più di 7 giorni per le quali non ho ancora una ricevuta
|
||||
$data_limite = (new Carbon())->subDays(7);
|
||||
$in_attesa = Fattura::vendita()
|
||||
->where('codice_stato_fe', 'WAIT')
|
||||
->where('data_stato_fe', '>=', $_SESSION['period_start'])
|
||||
->where('data_stato_fe', '<', $data_limite)
|
||||
->orderBy('data_stato_fe')
|
||||
->count();
|
||||
|
||||
// Messaggio di importazione
|
||||
if (!empty($in_attesa) && !empty($con_errore)) {
|
||||
$message = tr('Sono presenti _ERR_ fatture elettroniche con ricevute di scarto o errori di trasmissione, _WAIT_ in attesa di ricevuta da più di 7 giorni', [
|
||||
'_ERR_' => $con_errore,
|
||||
'_WAIT_' => $in_attesa,
|
||||
]);
|
||||
} elseif (empty($in_attesa) && !empty($con_errore)) {
|
||||
$message = tr('Sono presenti _ERR_ fatture elettroniche con ricevute di scarto o errori di trasmissione', [
|
||||
'_ERR_' => $con_errore,
|
||||
]);
|
||||
}
|
||||
if (!empty($in_attesa) && empty($con_errore)) {
|
||||
$message = tr('Sono presenti _WAIT_ in attesa di ricevuta da più di 7 giorni', [
|
||||
'_WAIT_' => $in_attesa,
|
||||
]);
|
||||
}
|
||||
|
||||
$module = Modules::get('Fatture di vendita');
|
||||
$plugin = Plugins::get('Ricevute FE');
|
||||
|
||||
return [
|
||||
'icon' => 'fa fa-ticket text-yellow',
|
||||
'message' => $message,
|
||||
'show' => $con_errore != 0 || $in_attesa != 0,
|
||||
'link' => base_path().'/controller.php?id_module='.$module->id.'#tab_'.$plugin->id,
|
||||
];
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
}
|
||||
|
||||
public function needsExecution()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -21,6 +21,7 @@ namespace Plugins\ReceiptFE;
|
|||
|
||||
use Hooks\Manager;
|
||||
use Models\Cache;
|
||||
use Modules;
|
||||
|
||||
class ReceiptHook extends Manager
|
||||
{
|
||||
|
@ -101,10 +102,13 @@ class ReceiptHook extends Manager
|
|||
$notify = $total_number != 0;
|
||||
$color = $total_number == $completed_number ? 'success' : 'yellow';
|
||||
|
||||
$module = Modules::get('Fatture di vendita');
|
||||
|
||||
return [
|
||||
'icon' => 'fa fa-ticket text-'.$color,
|
||||
'message' => $message,
|
||||
'show' => $notify,
|
||||
'link' => base_path().'/controller.php?id_module='.$module->id,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -222,3 +222,6 @@ ALTER TABLE `zz_imports`
|
|||
INSERT INTO `zz_imports` (`id_module`, `name`, `class`) VALUES
|
||||
((SELECT `id` FROM `zz_modules` WHERE `name` = 'Anagrafiche'), 'Anagrafiche', 'Modules\\Anagrafiche\\Import\\CSV'),
|
||||
((SELECT `id` FROM `zz_modules` WHERE `name` = 'Articoli'), 'Articoli', 'Modules\\Articoli\\Import\\CSV');
|
||||
|
||||
-- Introduzione hook per Notifiche su Ricevute FE
|
||||
INSERT INTO `zz_hooks` (`id`, `name`, `class`, `enabled`, `id_module`, `processing_at`, `processing_token`) VALUES (NULL, 'Notifiche su Ricevute FE', 'Plugins\\ReceiptFE\\NotificheRicevuteHook', '1', (SELECT `id` FROM `zz_modules` WHERE `name`='Fatture di vendita'), NULL, NULL);
|
||||
|
|
Loading…
Reference in New Issue