1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2024-12-28 00:30:45 +01:00
openstamanager/plugins/receiptFE/actions.php
Thomas Zilio 4a6ac3c870 Fix #592
2019-07-05 09:53:53 +02:00

50 lines
1.1 KiB
PHP

<?php
include_once __DIR__.'/../../core.php';
use Plugins\ReceiptFE\Interaction;
use Plugins\ReceiptFE\ReceiptHook;
use Plugins\ReceiptFE\Ricevuta;
switch (filter('op')) {
case 'import':
$list = Interaction::getReceiptList();
// Aggiornamento cache hook
ReceiptHook::update($list);
$results = [];
foreach ($list as $name) {
Interaction::getReceipt($name);
$fattura = null;
try {
$receipt = new Ricevuta($name, $content);
$receipt->save();
$fattura = $receipt->getFattura()->numero_esterno;
$receipt->delete();
Interaction::processReceipt($name);
} catch (UnexpectedValueException $e) {
}
$results[] = [
'file' => $name,
'fattura' => $fattura,
];
}
echo json_encode($results);
break;
case 'list':
$list = Interaction::getReceiptList();
echo json_encode($list);
break;
}