mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-10 08:30:48 +01:00
Aggiornamento visualizzazione Ricevute FE
This commit is contained in:
parent
e78323a7a5
commit
5f18f7b65e
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Modules\Fatture\Fattura;
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
if ($module['name'] == 'Fatture di vendita') {
|
||||
@ -9,7 +11,7 @@ if ($module['name'] == 'Fatture di vendita') {
|
||||
}
|
||||
|
||||
if (isset($id_record)) {
|
||||
$fattura = Modules\Fatture\Fattura::with('tipo', 'stato')->find($id_record);
|
||||
$fattura = Fattura::with('tipo', 'stato')->find($id_record);
|
||||
|
||||
$is_fiscale = false;
|
||||
if (!empty($fattura)) {
|
||||
|
@ -410,6 +410,20 @@ class Fattura extends Document
|
||||
return file_get_contents($file->filepath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Restituisce le ricevute della fattura elettronica relativa al documento.
|
||||
*
|
||||
* @return iterable
|
||||
*/
|
||||
public function getRicevute()
|
||||
{
|
||||
$nome = 'Ricevuta';
|
||||
|
||||
return $this->uploads()->filter(function ($item) use ($nome) {
|
||||
return false !== strstr($item->name, $nome);
|
||||
})->sortBy('created_at');
|
||||
}
|
||||
|
||||
/**
|
||||
* Controlla se la fattura di acquisto è elettronica.
|
||||
*
|
||||
|
@ -97,15 +97,17 @@ echo '
|
||||
|
||||
<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>';
|
||||
</button>
|
||||
</div>';
|
||||
|
||||
echo '<br><br>';
|
||||
|
||||
// Messaggio esito invio
|
||||
$ultima_ricevuta = $fattura->getRicevute()->last();
|
||||
if (!empty($record['codice_stato_fe'])) {
|
||||
if ($record['codice_stato_fe'] == 'GEN') {
|
||||
echo '
|
||||
<div class="alert alert-info text-left"><i class="fa fa-info-circle"></i> '.tr("La fattura è stata generata ed è pronta per l'invio").'.</div>
|
||||
<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']));
|
||||
@ -119,20 +121,59 @@ if (!empty($record['codice_stato_fe'])) {
|
||||
}
|
||||
|
||||
echo '
|
||||
<div class="alert text-left alert-'.$class.'">
|
||||
<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'] : '').'
|
||||
<div class="pull-right">
|
||||
<i class="fa fa-clock-o tip" title="'.tr('Data e ora ricezione').'" ></i> '.Translator::timestampToLocale($record['data_stato_fe']).'
|
||||
</div>
|
||||
</small>
|
||||
';
|
||||
<div class="alert alert-'.$class.'">
|
||||
<div class="pull-right">
|
||||
<i class="fa fa-clock-o tip" title="'.tr('Data e ora ricezione').'" ></i> '.Translator::timestampToLocale($record['data_stato_fe']).'';
|
||||
|
||||
if (!empty($ultima_ricevuta)) {
|
||||
echo '
|
||||
<a href="'.ROOTDIR.'/view.php?file_id='.$ultima_ricevuta->id.'" target="_blank" class="btn btn-info btn-xs">
|
||||
<i class="fa fa-external-link"></i> '.tr('Visualizza ricevuta').'
|
||||
</a>';
|
||||
}
|
||||
|
||||
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'] : '').'
|
||||
</div>';
|
||||
|
||||
// Lettura della ricevuta
|
||||
if (!empty($ultima_ricevuta) && $stato_fe['codice'] == 'NS') {
|
||||
$contenuto_ricevuta = \Util\XML::readFile($ultima_ricevuta->filepath);
|
||||
$lista_errori = $contenuto_ricevuta['ListaErrori'];
|
||||
|
||||
if (!empty($lista_errori)) {
|
||||
echo '
|
||||
<h4>'.tr('Elenco degli errori').'</h4>
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>'.tr('Codice').'</th>
|
||||
<th>'.tr('Descrizione').'</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>';
|
||||
|
||||
$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 '
|
||||
</tbody>
|
||||
</table>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo '
|
||||
</div>';
|
||||
|
||||
echo '
|
||||
<script>
|
||||
function send(btn) {
|
||||
|
@ -130,17 +130,24 @@ class Ricevuta
|
||||
$name = basename($this->file);
|
||||
$filename = explode('.', $name)[0];
|
||||
$pieces = explode('_', $filename);
|
||||
$codice = $pieces[2];
|
||||
$codice_stato = $pieces[2];
|
||||
|
||||
$this->saveAllegato($codice);
|
||||
|
||||
//In caso di Notifica Esito il codice è definito dal nodo <Esito> della ricevuta
|
||||
if ($codice == 'NE') {
|
||||
$this->xml = XML::readFile($this->file);
|
||||
$codice = $this->xml['EsitoCommittente']['Esito'];
|
||||
// Individuazione codice per il nome dell'allegato
|
||||
$codice_nome = $codice_stato;
|
||||
if ($codice_nome == 'NS') {
|
||||
$lista_errori = $this->xml['ListaErrori'];
|
||||
$errore = $lista_errori[0] ?: $lista_errori;
|
||||
$codice_nome = $codice_nome.' - '.$errore['Errore']['Codice'];
|
||||
}
|
||||
|
||||
$this->saveStato($codice);
|
||||
$this->saveAllegato($codice_nome);
|
||||
|
||||
// In caso di Notifica Esito il codice è definito dal nodo <Esito> della ricevuta
|
||||
if ($codice_stato == 'NE') {
|
||||
$codice_stato = $this->xml['EsitoCommittente']['Esito'];
|
||||
}
|
||||
|
||||
$this->saveStato($codice_stato);
|
||||
}
|
||||
|
||||
public function getFattura()
|
||||
|
@ -125,6 +125,16 @@ class Upload extends Model
|
||||
$this->attributes['original'] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restituisce i contenuti del file.
|
||||
*
|
||||
* @return false|string
|
||||
*/
|
||||
public function getContent()
|
||||
{
|
||||
return file_get_contents($this->filepath);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user