mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-18 04:20:50 +01:00
Introduzione base per operazioni di verifica notifica FE
This commit is contained in:
parent
bc096deaf3
commit
796306369b
@ -29,5 +29,12 @@ switch (filter('op')) {
|
|||||||
|
|
||||||
echo json_encode($result);
|
echo json_encode($result);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'verify':
|
||||||
|
$result = Interaction::getInvoiceRecepits($id_record);
|
||||||
|
|
||||||
|
echo json_encode($result);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,17 @@ echo '
|
|||||||
|
|
||||||
<button onclick="if( confirm(\''.tr('Inviare la fattura al SDI?').'\') ){ send(this); }" class="btn btn-success btn-lg '.($send ? '' : 'disabled').'" target="_blank" '.($send ? '' : 'disabled').'>
|
<button onclick="if( confirm(\''.tr('Inviare la fattura al SDI?').'\') ){ send(this); }" class="btn btn-success btn-lg '.($send ? '' : 'disabled').'" target="_blank" '.($send ? '' : 'disabled').'>
|
||||||
<i class="fa fa-paper-plane"></i> '.tr('Invia').'
|
<i class="fa fa-paper-plane"></i> '.tr('Invia').'
|
||||||
</button><br><br>';
|
</button>';
|
||||||
|
|
||||||
|
$verify = Interaction::isEnabled() && $generated;
|
||||||
|
echo '
|
||||||
|
<i class="fa fa-arrow-right fa-fw text-muted"></i>
|
||||||
|
|
||||||
|
<button class="btn btn-warning btn-lg '.($verify ? '' : 'disabled').'" target="_blank" '.($verify ? '' : 'disabled').' onclick="verify(this)">
|
||||||
|
<i class="fa fa-question-circle"></i> '.tr('Verifica notifiche').'
|
||||||
|
</button>';
|
||||||
|
|
||||||
|
echo '<br><br>';
|
||||||
|
|
||||||
// Messaggio esito invio
|
// Messaggio esito invio
|
||||||
if (!empty($record['codice_stato_fe'])) {
|
if (!empty($record['codice_stato_fe'])) {
|
||||||
@ -110,7 +120,7 @@ if (!empty($record['codice_stato_fe'])) {
|
|||||||
|
|
||||||
echo '
|
echo '
|
||||||
<div class="alert text-left alert-'.$class.'">
|
<div class="alert text-left alert-'.$class.'">
|
||||||
<big><i class="'.$stato_fe['icon'].'" style="color:#fff;"></i>
|
<big><i class="'.$stato_fe['icon'].'" style="color:#fff;"></i>
|
||||||
<b>'.$stato_fe['codice'].'</b> - '.$stato_fe['descrizione'].'</big> '.(!empty($record['descrizione_ricevuta_fe']) ? '<br><b>NOTE:</b> '.$record['descrizione_ricevuta_fe'] : '').'
|
<b>'.$stato_fe['codice'].'</b> - '.$stato_fe['descrizione'].'</big> '.(!empty($record['descrizione_ricevuta_fe']) ? '<br><b>NOTE:</b> '.$record['descrizione_ricevuta_fe'] : '').'
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
<i class="fa fa-clock-o tip" title="'.tr('Data e ora ricezione').'" ></i> '.Translator::timestampToLocale($record['data_stato_fe']).'
|
<i class="fa fa-clock-o tip" title="'.tr('Data e ora ricezione').'" ></i> '.Translator::timestampToLocale($record['data_stato_fe']).'
|
||||||
@ -121,53 +131,82 @@ if (!empty($record['codice_stato_fe'])) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
<script>
|
|
||||||
function send(btn) {
|
|
||||||
var restore = buttonLoading(btn);
|
|
||||||
|
|
||||||
$.ajax({
|
|
||||||
url: globals.rootdir + "/actions.php",
|
|
||||||
type: "post",
|
|
||||||
data: {
|
|
||||||
op: "send",
|
|
||||||
id_module: "'.$id_module.'",
|
|
||||||
id_plugin: "'.$id_plugin.'",
|
|
||||||
id_record: "'.$id_record.'",
|
|
||||||
},
|
|
||||||
success: function(data) {
|
|
||||||
data = JSON.parse(data);
|
|
||||||
buttonRestore(btn, restore);
|
|
||||||
|
|
||||||
if (data.code == "200") {
|
|
||||||
swal("'.tr('Fattura inviata!').'", data.message, "success");
|
|
||||||
|
|
||||||
$(btn).attr("disabled", true).addClass("disabled");
|
|
||||||
} else {
|
|
||||||
swal("'.tr('Invio fallito').'", data.code + " - " + data.message, "error");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
error: function(data) {
|
|
||||||
swal("'.tr('Errore').'", "'.tr('Errore durante il salvataggio').'", "error");
|
|
||||||
|
|
||||||
buttonRestore(btn, restore);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
</script>';
|
|
||||||
|
|
||||||
echo '
|
|
||||||
|
|
||||||
</div>';
|
</div>';
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
<script>
|
<script>
|
||||||
|
function send(btn) {
|
||||||
|
var restore = buttonLoading(btn);
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: globals.rootdir + "/actions.php",
|
||||||
|
type: "post",
|
||||||
|
data: {
|
||||||
|
op: "send",
|
||||||
|
id_module: "'.$id_module.'",
|
||||||
|
id_plugin: "'.$id_plugin.'",
|
||||||
|
id_record: "'.$id_record.'",
|
||||||
|
},
|
||||||
|
success: function(data) {
|
||||||
|
data = JSON.parse(data);
|
||||||
|
buttonRestore(btn, restore);
|
||||||
|
|
||||||
|
if (data.code == "200") {
|
||||||
|
swal("'.tr('Fattura inviata!').'", data.message, "success");
|
||||||
|
|
||||||
|
$(btn).attr("disabled", true).addClass("disabled");
|
||||||
|
} else {
|
||||||
|
swal("'.tr('Invio fallito').'", data.code + " - " + data.message, "error");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function(data) {
|
||||||
|
swal("'.tr('Errore').'", "'.tr('Errore durante il salvataggio').'", "error");
|
||||||
|
|
||||||
|
buttonRestore(btn, restore);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function verify(btn) {
|
||||||
|
var restore = buttonLoading(btn);
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: globals.rootdir + "/actions.php",
|
||||||
|
type: "post",
|
||||||
|
data: {
|
||||||
|
op: "verify",
|
||||||
|
id_module: "'.$id_module.'",
|
||||||
|
id_plugin: "'.$id_plugin.'",
|
||||||
|
id_record: "'.$id_record.'",
|
||||||
|
},
|
||||||
|
success: function(data) {
|
||||||
|
data = JSON.parse(data);
|
||||||
|
buttonRestore(btn, restore);
|
||||||
|
|
||||||
|
if (data.code == "200") {
|
||||||
|
swal("'.tr('Fattura inviata!').'", data.message, "success");
|
||||||
|
|
||||||
|
$(btn).attr("disabled", true).addClass("disabled");
|
||||||
|
location.reload(); // Ricaricamento pagina
|
||||||
|
} else {
|
||||||
|
swal("'.tr('Verifica fallita').'", data.code + " - " + data.message, "error");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function(data) {
|
||||||
|
swal("'.tr('Errore').'", "'.tr('Errore durante la verifica').'", "error");
|
||||||
|
|
||||||
|
buttonRestore(btn, restore);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
$("#genera").click(function(event){
|
$("#genera").click(function(event){
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
var form = $("#edit-form");
|
var form = $("#edit-form");
|
||||||
form.find("*").prop("disabled", false);
|
form.find("*").prop("disabled", false);
|
||||||
valid = submitAjax(form);
|
valid = submitAjax(form);
|
||||||
|
|
||||||
if (valid) {';
|
if (valid) {';
|
||||||
|
|
||||||
if ($generated) {
|
if ($generated) {
|
||||||
@ -187,7 +226,7 @@ if ($generated) {
|
|||||||
});';
|
});';
|
||||||
} else {
|
} else {
|
||||||
echo '
|
echo '
|
||||||
|
|
||||||
$("#form-xml").submit();';
|
$("#form-xml").submit();';
|
||||||
}
|
}
|
||||||
echo '
|
echo '
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace Plugins\ExportFE;
|
namespace Plugins\ExportFE;
|
||||||
|
|
||||||
use API\Services;
|
use API\Services;
|
||||||
|
use UnexpectedValueException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Classe per l'interazione con API esterne.
|
* Classe per l'interazione con API esterne.
|
||||||
@ -48,4 +49,28 @@ class Interaction extends Services
|
|||||||
'message' => tr('Fattura non generata correttamente'),
|
'message' => tr('Fattura non generata correttamente'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getInvoiceRecepits($id_record)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$fattura = new FatturaElettronica($id_record);
|
||||||
|
$filename = $fattura->getFilename();
|
||||||
|
|
||||||
|
$response = static::request('POST', 'notifiche_fattura', [
|
||||||
|
'name' => $filename,
|
||||||
|
]);
|
||||||
|
$body = static::responseBody($response);
|
||||||
|
|
||||||
|
return [
|
||||||
|
'code' => $body['status'],
|
||||||
|
'results' => $body['results'],
|
||||||
|
];
|
||||||
|
} catch (UnexpectedValueException $e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'code' => 400,
|
||||||
|
'message' => tr('Fattura non generata correttamente'),
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user