mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-06-05 22:09:38 +02:00
Correzioni sul blocco fattura per Fattura Elettronica
This commit is contained in:
@@ -25,15 +25,14 @@ use Plugins\ExportFE\Interaction;
|
||||
use Util\XML;
|
||||
|
||||
/* Per le PA EC02 e EC01 sono dei stati successivi a NE il quale a sua volta è successivo a RC. EC01 e EC02 sono definiti all'interno della ricevuta di NE che di fatto indica il rifiuto o l'accettazione. */
|
||||
$abilita_genera = empty($fattura->codice_stato_fe) || in_array($fattura->codice_stato_fe, ['GEN', 'NS', 'EC02', 'ERR']);
|
||||
$stato_fe = $database->fetchOne('SELECT * FROM fe_stati_documento WHERE codice = '.prepare($fattura->codice_stato_fe));
|
||||
$abilita_genera = empty($fattura->codice_stato_fe) || intval($stato_fe['is_generabile']);
|
||||
$ricevuta_principale = $fattura->getRicevutaPrincipale();
|
||||
|
||||
if (!empty($fattura_pa)) {
|
||||
$disabled = false;
|
||||
$generated = $fattura_pa->isGenerated();
|
||||
$generata = $fattura_pa->isGenerated();
|
||||
} else {
|
||||
$disabled = true;
|
||||
$generated = false;
|
||||
$generata = false;
|
||||
}
|
||||
|
||||
$checks = FatturaElettronica::controllaFattura($fattura);
|
||||
@@ -78,12 +77,12 @@ echo '
|
||||
<input type="hidden" name="backto" value="record-edit">
|
||||
<input type="hidden" name="op" value="generate">
|
||||
|
||||
<button id="genera" type="submit" class="btn btn-primary btn-lg '.($disabled || !$abilita_genera ? 'disabled' : '').'" '.($disabled || !$abilita_genera ? ' disabled' : null).'>
|
||||
<button id="genera" type="submit" class="btn btn-primary btn-lg '.(!$abilita_genera ? 'disabled' : '').'" '.(!$abilita_genera ? ' disabled' : null).'>
|
||||
<i class="fa fa-file"></i> '.tr('Genera').'
|
||||
</button>
|
||||
</form>';
|
||||
|
||||
$file = $generated ? Upload::where('filename', $fattura_pa->getFilename())
|
||||
$file = $generata ? Upload::where('filename', $fattura_pa->getFilename())
|
||||
->where('id_record', $id_record)
|
||||
->first() : null;
|
||||
|
||||
@@ -91,17 +90,17 @@ echo '
|
||||
|
||||
<i class="fa fa-arrow-right fa-fw text-muted"></i>
|
||||
|
||||
<a href="'.ROOTDIR.'/view.php?file_id='.($file ? $file->id : null).'" class="btn btn-info btn-lg '.($generated ? '' : 'disabled').'" target="_blank" '.($generated ? '' : 'disabled').'>
|
||||
<a href="'.ROOTDIR.'/view.php?file_id='.($file ? $file->id : null).'" class="btn btn-info btn-lg '.($generata ? '' : 'disabled').'" target="_blank" '.($generata ? '' : 'disabled').'>
|
||||
<i class="fa fa-eye"></i> '.tr('Visualizza').'
|
||||
</a>';
|
||||
|
||||
// Scelgo quando posso inviarla
|
||||
$send = Interaction::isEnabled() && $generated && in_array($record['codice_stato_fe'], ['GEN', 'ERVAL', 'ERR']);
|
||||
$inviabile = Interaction::isEnabled() && $generata && intval($stato_fe['is_inviabile']);
|
||||
|
||||
echo '
|
||||
<i class="fa fa-arrow-right fa-fw text-muted"></i>
|
||||
|
||||
<a href="'.$structure->fileurl('download.php').'?id_record='.$id_record.'" class="btn btn-primary btn-lg '.($generated ? '' : 'disabled').'" target="_blank" '.($generated ? '' : 'disabled').'>
|
||||
<a href="'.$structure->fileurl('download.php').'?id_record='.$id_record.'" class="btn btn-primary btn-lg '.($generata ? '' : 'disabled').'" target="_blank" '.($generata ? '' : 'disabled').'>
|
||||
<i class="fa fa-download"></i> '.tr('Scarica').'
|
||||
</a>';
|
||||
|
||||
@@ -109,11 +108,11 @@ echo '
|
||||
|
||||
<i class="fa fa-arrow-right fa-fw text-muted"></i>
|
||||
|
||||
<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 '.($inviabile ? '' : 'disabled').'" target="_blank" '.($inviabile ? '' : 'disabled').'>
|
||||
<i class="fa fa-paper-plane"></i> '.tr('Invia').'
|
||||
</button>';
|
||||
|
||||
$verify = Interaction::isEnabled() && $generated;
|
||||
$verify = Interaction::isEnabled() && $generata;
|
||||
echo '
|
||||
<i class="fa fa-arrow-right fa-fw text-muted"></i>
|
||||
|
||||
@@ -125,47 +124,47 @@ echo '
|
||||
echo '<br><br>';
|
||||
|
||||
// Messaggio informativo sulla ricevuta principale impostata
|
||||
if (!empty($record['codice_stato_fe'])) {
|
||||
if ($record['codice_stato_fe'] == 'GEN') {
|
||||
echo '
|
||||
<div class="alert alert-info"><i class="fa fa-info-circle"></i> '.tr("La fattura è stata generata ed è pronta per l'invio").'.</div>';
|
||||
} else {
|
||||
$stato_fe = database()->fetchOne('SELECT codice, descrizione, icon FROM fe_stati_documento WHERE codice='.prepare($record['codice_stato_fe']));
|
||||
|
||||
if (in_array($stato_fe['codice'], ['EC01', 'RC'])) {
|
||||
$class = 'success';
|
||||
} elseif (in_array($stato_fe['codice'], ['ERVAL', 'GEN', 'MC', 'WAIT', 'NE'])) {
|
||||
$class = 'warning';
|
||||
} else {
|
||||
$class = 'danger';
|
||||
}
|
||||
|
||||
echo '
|
||||
<div class="alert alert-'.$class.'">
|
||||
if (!empty($fattura->codice_stato_fe)) {
|
||||
echo '
|
||||
<div class="alert alert-'.$stato_fe['tipo'].'">
|
||||
<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').'"></i> '.timestampFormat($record['data_stato_fe']);
|
||||
|
||||
if (!empty($ricevuta_principale)) {
|
||||
echo '
|
||||
if (!empty($ricevuta_principale)) {
|
||||
echo '
|
||||
<a href="'.ROOTDIR.'/view.php?file_id='.$ricevuta_principale->id.'" target="_blank" class="btn btn-info btn-xs">
|
||||
<i class="fa fa-external-link"></i> '.tr('Visualizza ricevuta').'
|
||||
</a>';
|
||||
}
|
||||
}
|
||||
|
||||
echo '
|
||||
echo '
|
||||
</div>
|
||||
|
||||
<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>'.tr('Note', [], ['upper' => true]).':</b> '.$record['descrizione_ricevuta_fe'] : '').'
|
||||
<big>
|
||||
<i class="'.$stato_fe['icon'].'" style="color:#fff;"></i>
|
||||
<b>'.$stato_fe['codice'].'</b> - '.$stato_fe['descrizione'].'
|
||||
</big>';
|
||||
|
||||
if (!empty($record['descrizione_ricevuta_fe'])) {
|
||||
echo '
|
||||
<br><b>'.tr('Note', [], ['upper' => true]).':</b> '.$record['descrizione_ricevuta_fe'];
|
||||
}
|
||||
|
||||
if ($fattura->codice_stato_fe == 'GEN') {
|
||||
echo '
|
||||
<br><i class="fa fa-info-circle"></i> '.tr("La fattura è stata generata ed è pronta per l'invio").'.';
|
||||
}
|
||||
|
||||
echo '
|
||||
</div>';
|
||||
|
||||
// Lettura della ricevuta
|
||||
if (!empty($ricevuta_principale)) {
|
||||
$contenuto_ricevuta = XML::readFile($ricevuta_principale->filepath);
|
||||
$lista_errori = $contenuto_ricevuta['ListaErrori'];
|
||||
// Lettura della ricevuta
|
||||
if (!empty($ricevuta_principale)) {
|
||||
$contenuto_ricevuta = XML::readFile($ricevuta_principale->filepath);
|
||||
$lista_errori = $contenuto_ricevuta['ListaErrori'];
|
||||
|
||||
if (!empty($lista_errori)) {
|
||||
echo '
|
||||
if (!empty($lista_errori)) {
|
||||
echo '
|
||||
<h4>'.tr('Elenco degli errori').'</h4>
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
@@ -176,20 +175,19 @@ if (!empty($record['codice_stato_fe'])) {
|
||||
</thead>
|
||||
<tbody>';
|
||||
|
||||
$lista_errori = $lista_errori[0] ? $lista_errori : [$lista_errori];
|
||||
foreach ($lista_errori as $errore) {
|
||||
$errore = $errore['Errore'];
|
||||
echo '
|
||||
$lista_errori = $lista_errori[0] ? $lista_errori : [$lista_errori];
|
||||
foreach ($lista_errori as $errore) {
|
||||
$errore = $errore['Errore'];
|
||||
echo '
|
||||
<tr>
|
||||
<td>'.$errore['Codice'].'</td>
|
||||
<td>'.$errore['Descrizione'].'</td>
|
||||
</tr>';
|
||||
}
|
||||
}
|
||||
|
||||
echo '
|
||||
echo '
|
||||
</tbody>
|
||||
</table>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -212,7 +210,7 @@ echo '
|
||||
buttonRestore(btn, restore);
|
||||
data = JSON.parse(data);
|
||||
|
||||
if (data.code == "200") {
|
||||
if (data.code === "200") {
|
||||
swal("'.tr('Fattura inviata!').'", data.message, "success");
|
||||
|
||||
$(btn).attr("disabled", true).addClass("disabled");
|
||||
@@ -220,7 +218,7 @@ echo '
|
||||
swal("'.tr('Invio fallito').'", data.code + " - " + data.message, "error");
|
||||
}
|
||||
},
|
||||
error: function(data) {
|
||||
error: function() {
|
||||
swal("'.tr('Errore').'", "'.tr('Errore durante il salvataggio').'", "error");
|
||||
|
||||
buttonRestore(btn, restore);
|
||||
@@ -269,7 +267,7 @@ echo '
|
||||
salvaForm(this, "#edit-form").then(function(valid) {
|
||||
if (valid) {';
|
||||
|
||||
if ($generated) {
|
||||
if ($generata) {
|
||||
echo '
|
||||
swal({
|
||||
title: "'.tr('Sei sicuro di rigenerare la fattura?').'",
|
||||
|
Reference in New Issue
Block a user