1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2024-12-28 16:50:06 +01:00
openstamanager/templates/fatture/body.php

190 lines
4.8 KiB
PHP
Raw Normal View History

<?php
include_once __DIR__.'/../../core.php';
$v_iva = [];
$v_totale = [];
2019-07-12 12:40:13 +02:00
// Creazione righe fantasma
$autofill = new \Util\Autofill(5, 40);
$rows_per_page = $fattura_accompagnatoria ? 15 : 20;
if (!empty($options['last-page-footer'])) {
2019-08-28 10:36:08 +02:00
$rows_per_page += 7;
}
$autofill->setRows($rows_per_page);
2019-07-12 12:40:13 +02:00
// Intestazione tabella per righe
echo "
2017-09-12 16:45:18 +02:00
<table class='table table-striped table-bordered' id='contents'>
<thead>
<tr>
<th class='text-center' style='width:50%'>".tr('Descrizione', [], ['upper' => true])."</th>
<th class='text-center' style='width:14%'>".tr('Q.tà', [], ['upper' => true])."</th>
2017-09-12 16:45:18 +02:00
<th class='text-center' style='width:16%'>".tr('Prezzo unitario', [], ['upper' => true])."</th>
<th class='text-center' style='width:20%'>".tr('Importo', [], ['upper' => true])."</th>
<th class='text-center' style='width:10%'>".tr('IVA', [], ['upper' => true]).' (%)</th>
</tr>
</thead>
<tbody>';
2019-07-12 12:40:13 +02:00
// Righe documento
$righe = $documento->getRighe();
2019-07-11 18:10:38 +02:00
foreach ($righe as $riga) {
$r = $riga->toArray();
2019-07-12 12:40:13 +02:00
$autofill->count($r['descrizione']);
2018-12-12 18:42:41 +01:00
2019-07-12 12:40:13 +02:00
$v_iva[$r['desc_iva']] = sum($v_iva[$r['desc_iva']], $riga->iva);
$v_totale[$r['desc_iva']] = sum($v_totale[$r['desc_iva']], $riga->totale_imponibile);
2017-09-08 17:03:47 +02:00
echo '
<tr>
2017-09-08 17:03:47 +02:00
<td>
'.nl2br($r['descrizione']);
2019-07-12 12:40:13 +02:00
if ($riga->isArticolo()) {
// Codice articolo
$text = tr('COD. _COD_', [
'_COD_' => $riga->articolo->codice,
]);
echo '
2019-07-12 12:40:13 +02:00
<br><small>'.$text.'</small>';
2019-07-12 12:40:13 +02:00
$autofill->count($text, true);
2019-07-12 12:40:13 +02:00
// Seriali
$seriali = $riga->serials;
if (!empty($seriali)) {
2019-07-12 13:04:28 +02:00
$text = tr('SN').': '.implode(', ', $seriali);
2019-07-12 12:40:13 +02:00
echo '
<br><small>'.$text.'</small>';
2018-02-15 14:25:27 +01:00
2019-07-12 12:40:13 +02:00
$autofill->count($text, true);
2018-02-15 14:25:27 +01:00
}
}
// Aggiunta dei riferimenti ai documenti
2018-09-27 16:19:25 +02:00
if (!empty($record['ref_documento'])) {
$data = $dbo->fetchArray("SELECT IF(numero_esterno != '', numero_esterno, numero) AS numero, data FROM co_documenti WHERE id = ".prepare($record['ref_documento']));
2018-07-04 12:57:53 +02:00
$text = tr('Rif. fattura _NUM_ del _DATE_', [
'_NUM_' => $data[0]['numero'],
'_DATE_' => Translator::dateToLocale($data[0]['data']),
]);
echo '
<br><small>'.$text.'</small>';
2019-07-12 12:40:13 +02:00
$autofill->count($text, true);
2018-07-04 12:57:53 +02:00
}
// Aggiunta dei riferimenti ai documenti
if (setting('Riferimento dei documenti nelle stampe')) {
$ref = doc_references($r, $record['dir'], ['iddocumento']);
if (!empty($ref)) {
echo '
<br><small>'.$ref['description'].'</small>';
2018-07-04 12:57:53 +02:00
2019-07-12 12:40:13 +02:00
$autofill->count($ref['description'], true);
}
}
echo '
</td>';
2019-07-12 12:40:13 +02:00
if (!$riga->isDescrizione()) {
2018-02-15 17:41:09 +01:00
echo '
2019-07-12 12:40:13 +02:00
<td class="text-center">
'.Translator::numberToLocale(abs($riga->qta), 'qta').' '.$r['um'].'
</td>';
2019-07-12 12:40:13 +02:00
// Prezzo unitario
2018-08-11 15:49:46 +02:00
echo '
2019-07-12 12:40:13 +02:00
<td class="text-right">
2020-02-14 17:43:39 +01:00
'.moneyFormat($riga->prezzo_unitario);
2019-07-11 18:10:38 +02:00
if ($riga->sconto > 0) {
2020-02-15 14:11:44 +01:00
$text = discountInfo($riga, false);
2019-07-12 12:40:13 +02:00
echo '
<br><small class="text-muted">'.$text.'</small>';
$autofill->count($text, true);
}
2019-07-12 12:40:13 +02:00
echo '
</td>';
2019-07-12 12:40:13 +02:00
// Imponibile
2018-08-11 15:49:46 +02:00
echo '
2019-07-12 12:40:13 +02:00
<td class="text-right">
'.moneyFormat($riga->totale_imponibile).'
</td>';
2019-07-12 12:40:13 +02:00
// Iva
2018-02-15 17:41:09 +01:00
echo '
2019-07-12 12:40:13 +02:00
<td class="text-center">
'.Translator::numberToLocale($riga->aliquota->percentuale, 0).'
</td>';
} else {
echo '
<td></td>
<td></td>
<td></td>
<td></td>';
}
2019-07-12 12:40:13 +02:00
echo '
</tr>';
2019-07-12 12:40:13 +02:00
$autofill->next();
}
echo '
|autofill|
</tbody>
</table>';
// Aggiungo diciture particolari per l'anagrafica cliente
2019-07-12 12:40:13 +02:00
$dicitura = $dbo->fetchOne('SELECT diciturafissafattura AS dicitura FROM an_anagrafiche WHERE idanagrafica = '.prepare($id_cliente));
2019-07-12 12:40:13 +02:00
if (!empty($dicitura['dicitura'])) {
echo '
<p class="text-center">
<b>'.nl2br($dicitura['dicitura']).'</b>
</p>';
}
// Aggiungo diciture per condizioni iva particolari
foreach ($v_iva as $key => $value) {
2019-07-12 12:40:13 +02:00
$dicitura = $dbo->fetchOne('SELECT dicitura FROM co_iva WHERE descrizione = '.prepare($key));
2019-07-12 12:40:13 +02:00
if (!empty($dicitura['dicitura'])) {
echo '
<p class="text-center">
<b>'.nl2br($dicitura['dicitura']).'</b>
</p>';
}
}
2018-03-22 19:10:29 +01:00
echo '
<table class="table">';
echo '
<tr>
2018-03-22 19:10:29 +01:00
<td width="100%">';
2018-09-27 16:19:25 +02:00
if (!empty($record['note'])) {
2018-03-22 19:10:29 +01:00
echo '
<p class="small-bold">'.tr('Note', [], ['upper' => true]).':</p>
2018-09-27 16:19:25 +02:00
<p>'.nl2br($record['note']).'</p>';
2018-03-22 19:10:29 +01:00
}
2019-07-12 12:40:13 +02:00
2018-03-22 19:10:29 +01:00
echo '
</td>';
2018-03-22 19:10:29 +01:00
echo '
</tr>';
echo '
</table>';