1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2024-12-25 15:22:24 +01:00
openstamanager/plugins/importFE/rows.php

131 lines
4.6 KiB
PHP
Raw Normal View History

2018-09-24 18:10:16 +02:00
<?php
include_once __DIR__.'/../../core.php';
2018-11-30 15:33:25 +01:00
$fattura_pa = new Plugins\ImportFE\FatturaElettronica(get('filename'));
2018-09-24 18:10:16 +02:00
2018-10-13 10:15:54 +02:00
echo '
<form action="'.$rootdir.'/actions.php" method="post">
<input type="hidden" name="id_module" value="'.$id_module.'">
<input type="hidden" name="id_plugin" value="'.$id_plugin.'">
<input type="hidden" name="filename" value="'.get('filename').'">
<input type="hidden" name="id_segment" value="'.get('id_segment').'">
<input type="hidden" name="id" value="'.get('id').'">
<input type="hidden" name="backto" value="record-edit">
<input type="hidden" name="op" value="generate">';
// Fornitore
$fornitore = $fattura_pa->getHeader()['CedentePrestatore']['DatiAnagrafici'];
2018-09-24 18:10:16 +02:00
2018-10-13 10:15:54 +02:00
$ragione_sociale = $fornitore['Anagrafica']['Denominazione'] ?: $fornitore['Anagrafica']['Nome'].' '.$fornitore['Anagrafica']['Cognome'];
$codice_fiscale = $fornitore['CodiceFiscale'];
$partita_iva = $fornitore['IdFiscaleIVA']['IdCodice'];
echo '
<h4>'.tr('Fornitore').'</h4>
<p>'.tr('Le informazioni principali del fornitore sono le seguenti').':</p>
<ul>
<li>'.tr('Ragione Sociale').': '.$ragione_sociale.'</li>
<li>'.tr('Codice Fiscale').': '.$codice_fiscale.'</li>
<li>'.tr('Partita IVA').': '.$partita_iva.'</li>
</ul>';
// Pagamenti
2018-09-25 16:47:44 +02:00
$pagamenti = $fattura_pa->getBody()['DatiPagamento'];
$metodi = $pagamenti['DettaglioPagamento'];
$metodi = isset($metodi[0]) ? $metodi : [$metodi];
2018-10-01 17:41:21 +02:00
// prc '.($pagamenti['CondizioniPagamento'] == 'TP01' ? '!' : '').'= 100 AND
2018-10-01 18:26:12 +02:00
$query = 'SELECT id, descrizione FROM co_pagamenti WHERE codice_modalita_pagamento_fe = '.prepare($metodi[0]['ModalitaPagamento']).' GROUP BY descrizione ORDER BY descrizione ASC';
2018-09-25 16:47:44 +02:00
2018-09-24 18:10:16 +02:00
echo '
2018-10-13 10:15:54 +02:00
<h4>'.tr('Pagamento').'</h4>
2018-09-25 16:47:44 +02:00
2018-10-13 10:15:54 +02:00
<p>'.tr('La fattura importata presenta _NUM_ rate di pagamento con le seguenti scadenze', [
2018-10-25 16:57:39 +02:00
'_NUM_' => count($metodi),
2018-10-13 10:15:54 +02:00
]).':</p>
<ul>';
// Scadenze di pagamento
foreach ($metodi as $metodo) {
echo '
<li>'.Translator::dateToLocale($metodo['DataScadenzaPagamento']).'</li>';
}
echo '
</ul>';
echo '
2018-09-25 16:47:44 +02:00
{[ "type": "select", "label": "'.tr('Pagamento').'", "name": "pagamento", "required": 1, "values": "query='.$query.'" ]}';
2018-09-24 18:10:16 +02:00
2018-11-30 15:33:25 +01:00
// Sezionale
echo '
{[ "type": "select", "label": "'.tr('Sezionale').'", "name": "id_segment", "required": 1, "values": "query=SELECT id, name AS descrizione FROM zz_segments WHERE id_module='.$id_module.' ORDER BY name", "value": "'.$_SESSION['module_'.$id_module]['id_segment'].'" ]}';
2018-10-13 10:15:54 +02:00
// Righe
$righe = $fattura_pa->getRighe();
2018-09-24 18:10:16 +02:00
if (!empty($righe)) {
echo '
2018-10-13 10:15:54 +02:00
<h4>'.tr('Righe').'</h4>
<div class="table-responsive">
<table class="table table-hover table-striped table-condensed">
<tr>
<th>'.tr('Descrizione').'</th>
<th width="10%">'.tr('Q.').'</th>
<th width="15%">'.tr('Prezzo unitario').'</th>
<th width="15%">'.tr('Iva associata').'*</th>
2018-11-30 15:33:25 +01:00
<th width="15%">'.tr('Conto').'*</th>
<th width="15%">'.tr('Articolo associato').'</th>
</tr>';
2018-09-24 18:10:16 +02:00
foreach ($righe as $key => $riga) {
2018-09-25 11:55:52 +02:00
$query = 'SELECT id, IF(codice IS NULL, descrizione, CONCAT(codice, " - ", descrizione)) AS descrizione FROM co_iva WHERE percentuale = '.prepare($riga['AliquotaIVA']);
if (!empty($riga['Natura'])) {
$query .= ' AND codice_natura_fe = '.prepare($riga['Natura']);
}
$query .= ' ORDER BY descrizione ASC';
2018-09-24 18:10:16 +02:00
echo '
<tr>
<td>'.$riga['Descrizione'].'</td>
2018-11-30 15:33:25 +01:00
<td>'.Translator::numberToLocale($riga['Quantita']).' '.$riga['UnitaMisura'].'</td>
<td>'.Translator::numberToLocale($riga['PrezzoUnitario']).'&nbsp;&euro;</td>
2018-09-25 11:55:52 +02:00
<td>
{[ "type": "select", "name": "iva['.$key.']", "values": "query='.str_replace('"', '\"', $query).'", "required": 1 ]}
</td>
<td>
2018-11-30 15:33:25 +01:00
{[ "type": "select", "name": "conto['.$key.']", "ajax-source": "conti-acquisti", "required": 1 ]}
</td>
2018-09-24 18:10:16 +02:00
<td>
{[ "type": "select", "name": "articoli['.$key.']", "ajax-source": "articoli" ]}
</td>
</tr>';
}
echo '
</table>
</div>';
2018-09-24 18:10:16 +02:00
} else {
echo '
<p>Non ci sono righe nella fattura.</p>';
}
echo '
<div class="row">
<div class="col-md-12 text-right">
<button type="submit" class="btn btn-primary">
<i class="fa fa-arrow-right"></i> '.tr('Continua').'...
</button>
</div>
</div>
</form>';
echo '
<script src="'.$rootdir.'/lib/init.js"></script>';