2018-07-09 12:57:55 +02:00
|
|
|
<?php
|
|
|
|
|
2018-09-18 15:57:55 +02:00
|
|
|
include_once __DIR__.'/init.php';
|
2018-07-10 12:07:48 +02:00
|
|
|
|
2018-12-07 18:16:46 +01:00
|
|
|
use Plugins\ExportFE\Interaction;
|
|
|
|
|
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':
|
|
|
|
$result = Interaction::sendXML($id_record);
|
|
|
|
|
2018-12-07 18:23:46 +01:00
|
|
|
// Aggiornamento dello stato
|
2018-12-27 19:20:30 +01:00
|
|
|
/*
|
2018-12-14 12:50:44 +01:00
|
|
|
if ($result) {
|
|
|
|
database()->update('co_documenti', [
|
|
|
|
'codice_stato_fe' => 'WAIT',
|
|
|
|
], ['id' => $id_record]);
|
|
|
|
}
|
2018-12-27 19:20:30 +01:00
|
|
|
*/
|
2018-12-07 18:16:46 +01:00
|
|
|
echo json_encode([
|
|
|
|
'sent' => $result,
|
|
|
|
]);
|
|
|
|
|
2018-07-09 12:57:55 +02:00
|
|
|
break;
|
|
|
|
}
|