1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2024-12-28 16:50:06 +01:00
openstamanager/plugins/exportFE/actions.php

69 lines
1.8 KiB
PHP
Raw Normal View History

2018-07-09 12:57:55 +02:00
<?php
2018-09-18 15:57:55 +02:00
include_once __DIR__.'/init.php';
2018-12-07 18:16:46 +01:00
use Plugins\ExportFE\Interaction;
use Plugins\ReceiptFE\Interaction as RecepitInteraction;
use Plugins\ReceiptFE\Ricevuta;
2018-12-07 18:16:46 +01:00
2018-07-09 12:57:55 +02:00
switch (filter('op')) {
case 'generate':
2018-09-21 15:50:42 +02:00
if (!empty($fattura_pa)) {
$file = $fattura_pa->save($upload_dir);
2018-11-09 07:02:59 +01:00
2018-07-19 17:29:21 +02:00
flash()->info(tr('Fattura elettronica generata correttamente!'));
2018-07-09 12:57:55 +02:00
2018-09-21 15:50:42 +02:00
if (!$fattura_pa->isValid()) {
2018-11-16 10:41:21 +01:00
$errors = $fattura_pa->getErrors();
flash()->warning(tr('La fattura elettronica potrebbe avere delle irregolarità!').' '.tr('Controllare i seguenti campi: _LIST_', [
'_LIST_' => implode(', ', $errors),
]).'.');
2018-07-09 12:57:55 +02:00
}
2018-09-18 15:57:55 +02:00
} else {
2018-07-19 17:29:21 +02:00
flash()->error(tr('Impossibile generare la fattura elettronica'));
2018-07-09 12:57:55 +02:00
}
2018-12-07 18:16:46 +01:00
break;
case 'send':
2019-07-24 17:17:54 +02:00
$result = Interaction::sendInvoice($id_record);
2018-12-07 18:16:46 +01:00
2019-01-22 08:59:11 +01:00
echo json_encode($result);
2018-12-07 18:16:46 +01:00
break;
case 'verify':
$result = Interaction::getInvoiceRecepits($id_record);
$last_recepit = $result['results'][0];
// Messaggi relativi
if (empty($last_recepit)){
echo json_encode($result);
return;
}
// Importazione ultima ricevuta individuata
RecepitInteraction::getReceipt($last_recepit);
$fattura = null;
try {
$receipt = new Ricevuta($last_recepit);
$receipt->save();
$fattura = $receipt->getFattura()->numero_esterno;
$receipt->delete();
RecepitInteraction::processReceipt($name);
} catch (UnexpectedValueException $e) {
}
echo json_encode([
'file' => $last_recepit,
'fattura' => $fattura,
]);
2018-07-09 12:57:55 +02:00
break;
}