Aggiornamento API invio/ricezione FE

This commit is contained in:
Fabio Lovato 2019-01-22 08:59:11 +01:00
parent 858a3060bf
commit c29847d43f
5 changed files with 34 additions and 18 deletions

View File

@ -11,7 +11,7 @@ if (!isset($options['edit_articolo']) || !empty($options['edit_articolo'])) {
echo '
<div class="row">
<div class="col-md-12">
{[ "type": "select", "label": "'.tr('Articolo').'", "name": "idarticolo", "required": 1, "value": "'.$result['idarticolo'].'", "ajax-source": "articoli" '.(($options['dir'] == 'uscita') ? ',"icon-after": "add|'.Modules::get('Articoli')['id'].'"' : '').' ]}
{[ "type": "select", "label": "'.tr('Articolo').'", "name": "idarticolo", "required": 1, "value": "'.$result['idarticolo'].'", "ajax-source": "articoli", "icon-after": "add|'.Modules::get('Articoli')['id'].'||'.(($options['dir'] == 'uscita') ? '' : 'disabled').'" ]}
</div>
</div>';
} else {

View File

@ -28,16 +28,13 @@ switch (filter('op')) {
$result = Interaction::sendXML($id_record);
// Aggiornamento dello stato
/*
if ($result) {
database()->update('co_documenti', [
'codice_stato_fe' => 'WAIT',
], ['id' => $id_record]);
}
*/
echo json_encode([
'sent' => $result,
]);
echo json_encode($result);
break;
}

View File

@ -176,12 +176,12 @@ echo '
data = JSON.parse(data);
buttonRestore(btn, restore);
if (data.sent) {
swal("'.tr('Fattura inviata!').'", "'.tr('Fattura inoltrata con successo').'", "success");
if (data.code == "200") {
swal("'.tr('Fattura inviata!').'", data.message, "success");
$(btn).attr("disabled", true).addClass("disabled");
} else {
swal("'.tr('Invio fallito').'", "'.tr("L'invio della fattura è fallito").'", "error");
swal("'.tr('Invio fallito').'", data.code + " - " + data.message, "error");
}
},
error: function(data) {

View File

@ -27,9 +27,7 @@ class Interaction extends Connection
$body = static::responseBody($response);
if (!empty($body['sent'])) {
return true;
}
return $body;
} catch (UnexpectedValueException $e) {
}

View File

@ -18,6 +18,9 @@ class Interaction extends Connection
$response = static::request('POST', 'get_fatture_da_importare');
$body = static::responseBody($response);
$code = $body['code'];
if($code=='200'){
$list = $body['results'];
$files = glob($directory.'/*.xml');
@ -27,6 +30,7 @@ class Interaction extends Connection
return array_clean($list);
}
}
public static function getImportXML($name)
{
@ -44,4 +48,21 @@ class Interaction extends Connection
return $name;
}
public static function processXML($filename)
{
$response = static::request('POST', 'process_xml', [
'filename' => $filename,
]);
$body = static::responseBody($response);
if($body['processed']=='0'){
$message = $body['code']." - ".$body['message'];
}else{
$message = "";
}
return $message;
}
}