mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-06-05 22:09:38 +02:00
Aggiornamento visualizzazione Ricevute FE
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Modules\Fatture\Fattura;
|
||||||
|
|
||||||
include_once __DIR__.'/../../core.php';
|
include_once __DIR__.'/../../core.php';
|
||||||
|
|
||||||
if ($module['name'] == 'Fatture di vendita') {
|
if ($module['name'] == 'Fatture di vendita') {
|
||||||
@@ -9,7 +11,7 @@ if ($module['name'] == 'Fatture di vendita') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isset($id_record)) {
|
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;
|
$is_fiscale = false;
|
||||||
if (!empty($fattura)) {
|
if (!empty($fattura)) {
|
||||||
|
@@ -410,6 +410,20 @@ class Fattura extends Document
|
|||||||
return file_get_contents($file->filepath);
|
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.
|
* 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)">
|
<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').'
|
<i class="fa fa-question-circle"></i> '.tr('Verifica notifiche').'
|
||||||
</button>';
|
</button>
|
||||||
|
</div>';
|
||||||
|
|
||||||
echo '<br><br>';
|
echo '<br><br>';
|
||||||
|
|
||||||
// Messaggio esito invio
|
// Messaggio esito invio
|
||||||
|
$ultima_ricevuta = $fattura->getRicevute()->last();
|
||||||
if (!empty($record['codice_stato_fe'])) {
|
if (!empty($record['codice_stato_fe'])) {
|
||||||
if ($record['codice_stato_fe'] == 'GEN') {
|
if ($record['codice_stato_fe'] == 'GEN') {
|
||||||
echo '
|
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 {
|
} else {
|
||||||
$stato_fe = database()->fetchOne('SELECT codice, descrizione, icon FROM fe_stati_documento WHERE codice='.prepare($record['codice_stato_fe']));
|
$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 '
|
echo '
|
||||||
<div class="alert text-left alert-'.$class.'">
|
<div class="alert 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">
|
<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']).'';
|
||||||
</div>
|
|
||||||
</small>
|
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 '
|
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>';
|
</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 '
|
echo '
|
||||||
<script>
|
<script>
|
||||||
function send(btn) {
|
function send(btn) {
|
||||||
|
@@ -130,17 +130,24 @@ class Ricevuta
|
|||||||
$name = basename($this->file);
|
$name = basename($this->file);
|
||||||
$filename = explode('.', $name)[0];
|
$filename = explode('.', $name)[0];
|
||||||
$pieces = explode('_', $filename);
|
$pieces = explode('_', $filename);
|
||||||
$codice = $pieces[2];
|
$codice_stato = $pieces[2];
|
||||||
|
|
||||||
$this->saveAllegato($codice);
|
// Individuazione codice per il nome dell'allegato
|
||||||
|
$codice_nome = $codice_stato;
|
||||||
//In caso di Notifica Esito il codice è definito dal nodo <Esito> della ricevuta
|
if ($codice_nome == 'NS') {
|
||||||
if ($codice == 'NE') {
|
$lista_errori = $this->xml['ListaErrori'];
|
||||||
$this->xml = XML::readFile($this->file);
|
$errore = $lista_errori[0] ?: $lista_errori;
|
||||||
$codice = $this->xml['EsitoCommittente']['Esito'];
|
$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()
|
public function getFattura()
|
||||||
|
@@ -125,6 +125,16 @@ class Upload extends Model
|
|||||||
$this->attributes['original'] = $value;
|
$this->attributes['original'] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Restituisce i contenuti del file.
|
||||||
|
*
|
||||||
|
* @return false|string
|
||||||
|
*/
|
||||||
|
public function getContent()
|
||||||
|
{
|
||||||
|
return file_get_contents($this->filepath);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user