1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2025-02-02 17:07:01 +01:00

Aggiunto cron per importazione ricevute FE ogni 4 ore

This commit is contained in:
Dasc3er 2020-10-28 14:15:00 +01:00
parent 6b2c4b2825
commit 6b2dd0f11a
3 changed files with 44 additions and 41 deletions

View File

@ -1,39 +0,0 @@
<?php
$skip_permissions = true;
include_once __DIR__.'/../core.php';
use Plugins\ReceiptFE\Interaction;
use Plugins\ReceiptFE\ReceiptHook;
use Plugins\ReceiptFE\Ricevuta;
$list = Interaction::getReceiptList();
if( count($list) == 0){
echo 'Nessuna ricevuta da importare';
} else {
echo count($list)." ricevute da importare:\n";
foreach ($list as $element) {
$name = $element['name'];
echo '[*] '.$name."...";
Interaction::getReceipt($name);
$fattura = null;
try {
$receipt = new Ricevuta($name, $content);
$receipt->save();
$fattura = $receipt->getFattura()->numero_esterno;
$receipt->delete();
Interaction::processReceipt($name);
echo "OK\n";
} catch (UnexpectedValueException $e) {
echo "ERRORE\n";
}
}
}

View File

@ -0,0 +1,41 @@
<?php
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
* Copyright (C) DevCode s.n.c.
*
* 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 Tasks\Manager;
class ReceiptTask extends Manager
{
public function execute()
{
if (!Interaction::isEnabled()){
return;
}
$list = Interaction::getReceiptList();
// Esecuzione dell'importazione
foreach ($list as $element) {
$name = $element['name'];
Ricevuta::process($name);
}
}
}

View File

@ -26,7 +26,8 @@ INSERT INTO `zz_cache` (`id`, `name`, `content`, `valid_time`, `expire_at`) VALU
(NULL, 'Disabilita cron', '', '1 month', NULL);
INSERT INTO `zz_tasks` (`id`, `name`, `class`, `expression`, `last_executed_at`) VALUES
(NULL, 'Backup automatico', 'Modules\\Backups\\BackupTask', '0 1 * * *', NULL);
(NULL, 'Backup automatico', 'Modules\\Backups\\BackupTask', '0 1 * * *', NULL)
(NULL, 'Importazione automatica Ricevute FE', 'Plugins\\ReceiptFE\\ReceiptTask', '0 */4 * * *', NULL);
DELETE FROM `zz_hooks` WHERE `class` = 'Modules\\Backups\\BackupHook';