2017-09-12 17:46:19 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
include_once __DIR__.'/../../core.php';
|
|
|
|
|
2019-07-12 12:40:13 +02:00
|
|
|
// Righe documento
|
|
|
|
$righe = $documento->getRighe();
|
|
|
|
|
|
|
|
$has_image = $righe->search(function ($item) {
|
|
|
|
return !empty($item->articolo->immagine);
|
|
|
|
});
|
|
|
|
|
|
|
|
if ($has_image) {
|
|
|
|
$columns = 6;
|
|
|
|
$char_number = $options['pricing'] ? 26 : 63;
|
|
|
|
} else {
|
|
|
|
$columns = 5;
|
|
|
|
$char_number = $options['pricing'] ? 45 : 82;
|
2019-01-10 17:27:19 +01:00
|
|
|
}
|
2019-07-12 12:40:13 +02:00
|
|
|
$columns = $options['pricing'] ? $columns : $columns - 3;
|
2017-09-12 17:46:19 +02:00
|
|
|
|
2019-07-12 12:40:13 +02:00
|
|
|
// Creazione righe fantasma
|
|
|
|
$autofill = new \Util\Autofill($columns, $char_number);
|
|
|
|
$autofill->setRows(30);
|
2017-09-12 17:46:19 +02:00
|
|
|
|
|
|
|
// Intestazione tabella per righe
|
|
|
|
echo "
|
|
|
|
<table class='table table-striped table-bordered' id='contents'>
|
|
|
|
<thead>
|
2019-01-10 17:27:19 +01:00
|
|
|
<tr>";
|
2019-01-10 18:11:09 +01:00
|
|
|
|
|
|
|
if ($has_image) {
|
2019-07-12 12:40:13 +02:00
|
|
|
echo "
|
|
|
|
<th class='text-center' style='width:20%'>".tr('Immagine', [], ['upper' => true]).'</th>';
|
2019-01-10 17:27:19 +01:00
|
|
|
}
|
2019-07-12 12:40:13 +02:00
|
|
|
|
|
|
|
echo "
|
|
|
|
<th class='text-center'>".tr('Descrizione', [], ['upper' => true])."</th>
|
|
|
|
<th class='text-center' style='width:10%'>".tr('Q.tà', [], ['upper' => true]).'</th>';
|
|
|
|
|
|
|
|
if ($options['pricing']) {
|
|
|
|
echo "
|
2017-09-12 17:46:19 +02:00
|
|
|
<th class='text-center' style='width:15%'>".tr('Prezzo unitario', [], ['upper' => true])."</th>
|
2019-07-16 12:02:24 +02:00
|
|
|
<th class='text-center' style='width:15%'>".tr('Imponibile', [], ['upper' => true])."</th>
|
2019-07-12 12:40:13 +02:00
|
|
|
<th class='text-center' style='width:10%'>".tr('IVA', [], ['upper' => true]).' (%)</th>';
|
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
2017-09-12 17:46:19 +02:00
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
|
|
|
|
<tbody>';
|
|
|
|
|
2019-07-12 12:40:13 +02:00
|
|
|
foreach ($righe as $riga) {
|
|
|
|
$r = $riga->toArray();
|
|
|
|
|
|
|
|
$autofill->count($r['descrizione']);
|
2017-09-12 17:46:19 +02:00
|
|
|
|
|
|
|
echo '
|
2019-01-10 17:27:19 +01:00
|
|
|
<tr>';
|
2019-01-10 18:11:09 +01:00
|
|
|
|
|
|
|
if ($has_image) {
|
2019-07-12 12:40:13 +02:00
|
|
|
if ($riga->isArticolo()) {
|
|
|
|
echo '
|
|
|
|
<td align="center">
|
2020-07-06 17:58:48 +02:00
|
|
|
<img src="'.$riga->articolo->image.'" style="max-height: 80px; max-width:120px">
|
2019-07-12 12:40:13 +02:00
|
|
|
</td>';
|
|
|
|
|
|
|
|
$autofill->set(5);
|
|
|
|
} else {
|
|
|
|
echo '
|
|
|
|
<td></td>';
|
2019-01-10 18:11:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
2019-07-12 12:40:13 +02:00
|
|
|
<td>
|
2017-09-12 17:46:19 +02:00
|
|
|
'.nl2br($r['descrizione']);
|
|
|
|
|
2019-07-12 12:40:13 +02:00
|
|
|
if ($riga->isArticolo()) {
|
|
|
|
// Codice articolo
|
|
|
|
$text = tr('COD. _COD_', [
|
2020-07-06 13:32:43 +02:00
|
|
|
'_COD_' => $riga->codice,
|
2019-07-12 12:40:13 +02:00
|
|
|
]);
|
2017-09-12 17:46:19 +02:00
|
|
|
echo '
|
2019-07-12 12:40:13 +02:00
|
|
|
<br><small>'.$text.'</small>';
|
2017-09-12 17:46:19 +02:00
|
|
|
|
2019-07-12 12:40:13 +02:00
|
|
|
$autofill->count($text, true);
|
2017-09-12 17:46:19 +02:00
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-12 17:46:19 +02:00
|
|
|
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'].'
|
2017-09-12 17:46:19 +02:00
|
|
|
</td>';
|
|
|
|
|
2019-07-12 12:40:13 +02:00
|
|
|
if ($options['pricing']) {
|
|
|
|
// Prezzo unitario
|
2018-02-15 17:41:09 +01: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);
|
2018-01-18 19:03:06 +01:00
|
|
|
|
2019-07-12 12:40:13 +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);
|
2017-09-21 10:01:07 +02:00
|
|
|
}
|
2019-07-12 12:40:13 +02:00
|
|
|
|
|
|
|
echo '
|
2017-09-12 17:46:19 +02:00
|
|
|
</td>';
|
|
|
|
|
2019-07-12 12:40:13 +02:00
|
|
|
// Imponibile
|
2018-02-15 17:41:09 +01:00
|
|
|
echo '
|
2019-07-12 12:40:13 +02:00
|
|
|
<td class="text-right">
|
|
|
|
'.moneyFormat($riga->totale_imponibile).'
|
|
|
|
</td>';
|
2018-01-18 19:03:06 +01:00
|
|
|
|
2019-07-12 12:40:13 +02:00
|
|
|
// Iva
|
|
|
|
echo '
|
|
|
|
<td class="text-center">
|
|
|
|
'.Translator::numberToLocale($riga->aliquota->percentuale, 0).'
|
2017-09-12 17:46:19 +02:00
|
|
|
</td>';
|
2019-07-12 12:40:13 +02:00
|
|
|
}
|
2017-09-12 17:46:19 +02:00
|
|
|
} else {
|
|
|
|
echo '
|
2019-07-12 12:40:13 +02:00
|
|
|
<td></td>';
|
2017-09-12 17:46:19 +02:00
|
|
|
|
2019-07-12 12:40:13 +02:00
|
|
|
if ($options['pricing']) {
|
|
|
|
echo '
|
|
|
|
<td></td>
|
|
|
|
<td></td>
|
|
|
|
<td></td>';
|
|
|
|
}
|
2018-01-18 19:03:06 +01:00
|
|
|
}
|
2019-07-12 12:40:13 +02:00
|
|
|
|
2018-01-18 19:03:06 +01:00
|
|
|
echo '
|
2017-09-12 17:46:19 +02:00
|
|
|
</tr>';
|
|
|
|
|
2019-07-12 12:40:13 +02:00
|
|
|
$autofill->next();
|
2017-09-12 17:46:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
|
|
|
|autofill|
|
|
|
|
</tbody>';
|
|
|
|
|
2019-07-12 12:40:13 +02:00
|
|
|
// Calcoli
|
|
|
|
$imponibile = $documento->imponibile;
|
|
|
|
$sconto = $documento->sconto;
|
|
|
|
$totale_imponibile = $documento->totale_imponibile;
|
|
|
|
$totale_iva = $documento->iva;
|
|
|
|
$totale = $documento->totale;
|
|
|
|
|
|
|
|
$show_sconto = $sconto > 0;
|
|
|
|
|
2017-09-12 17:46:19 +02:00
|
|
|
// TOTALE COSTI FINALI
|
2017-09-21 15:51:39 +02:00
|
|
|
if ($options['pricing']) {
|
2017-09-12 17:46:19 +02:00
|
|
|
// Totale imponibile
|
|
|
|
echo '
|
|
|
|
<tr>
|
2019-07-12 12:40:13 +02:00
|
|
|
<td colspan="'.($has_image ? 4 : 3).'" class="text-right border-top">
|
2017-09-12 17:46:19 +02:00
|
|
|
<b>'.tr('Imponibile', [], ['upper' => true]).':</b>
|
|
|
|
</td>
|
|
|
|
|
2019-05-02 10:03:57 +02:00
|
|
|
<th colspan="2" class="text-right">
|
2019-07-12 12:40:13 +02:00
|
|
|
<b>'.moneyFormat($show_sconto ? $imponibile : $totale_imponibile, 2).'</b>
|
2017-09-12 17:46:19 +02:00
|
|
|
</th>
|
|
|
|
</tr>';
|
|
|
|
|
|
|
|
// Eventuale sconto incondizionato
|
2019-07-12 12:40:13 +02:00
|
|
|
if ($show_sconto) {
|
2017-09-12 17:46:19 +02:00
|
|
|
echo '
|
|
|
|
<tr>
|
2019-07-12 12:40:13 +02:00
|
|
|
<td colspan="'.($has_image ? 4 : 3).'" class="text-right border-top">
|
2017-09-12 17:46:19 +02:00
|
|
|
<b>'.tr('Sconto', [], ['upper' => true]).':</b>
|
|
|
|
</td>
|
|
|
|
|
2019-05-02 10:03:57 +02:00
|
|
|
<th colspan="2" class="text-right">
|
2019-07-12 12:40:13 +02:00
|
|
|
<b>'.moneyFormat($sconto, 2).'</b>
|
2017-09-12 17:46:19 +02:00
|
|
|
</th>
|
|
|
|
</tr>';
|
|
|
|
|
2019-07-11 17:44:42 +02:00
|
|
|
// Totale imponibile
|
2017-09-12 17:46:19 +02:00
|
|
|
echo '
|
|
|
|
<tr>
|
2019-07-12 12:40:13 +02:00
|
|
|
<td colspan="'.($has_image ? 4 : 3).'" class="text-right border-top">
|
2019-07-11 17:44:42 +02:00
|
|
|
<b>'.tr('Totale imponibile', [], ['upper' => true]).':</b>
|
2017-09-12 17:46:19 +02:00
|
|
|
</td>
|
|
|
|
|
2019-05-02 10:03:57 +02:00
|
|
|
<th colspan="2" class="text-right">
|
2019-07-12 12:40:13 +02:00
|
|
|
<b>'.moneyFormat($totale_imponibile, 2).'</b>
|
2017-09-12 17:46:19 +02:00
|
|
|
</th>
|
|
|
|
</tr>';
|
|
|
|
}
|
|
|
|
|
|
|
|
// IVA
|
|
|
|
echo '
|
|
|
|
<tr>
|
2019-07-12 12:40:13 +02:00
|
|
|
<td colspan="'.($has_image ? 4 : 3).'" class="text-right border-top">
|
2017-09-12 17:46:19 +02:00
|
|
|
<b>'.tr('Totale IVA', [], ['upper' => true]).':</b>
|
|
|
|
</td>
|
|
|
|
|
2019-05-02 10:03:57 +02:00
|
|
|
<th colspan="2" class="text-right">
|
2019-07-12 12:40:13 +02:00
|
|
|
<b>'.moneyFormat($totale_iva, 2).'</b>
|
2017-09-12 17:46:19 +02:00
|
|
|
</th>
|
|
|
|
</tr>';
|
|
|
|
|
|
|
|
// TOTALE
|
|
|
|
echo '
|
|
|
|
<tr>
|
2019-07-12 12:40:13 +02:00
|
|
|
<td colspan="'.($has_image ? 4 : 3).'" class="text-right border-top">
|
|
|
|
<b>'.tr('Totale documento', [], ['upper' => true]).':</b>
|
2017-09-12 17:46:19 +02:00
|
|
|
</td>
|
2019-05-02 10:03:57 +02:00
|
|
|
<th colspan="2" class="text-right">
|
|
|
|
<b>'.moneyFormat($totale, 2).'</b>
|
2017-09-12 17:46:19 +02:00
|
|
|
</th>
|
|
|
|
</tr>';
|
|
|
|
}
|
|
|
|
|
2018-02-15 17:41:09 +01:00
|
|
|
echo '
|
2017-09-12 17:46:19 +02:00
|
|
|
</table>';
|
|
|
|
|
2019-07-12 12:40:13 +02:00
|
|
|
if (!empty($documento['note'])) {
|
2017-09-12 17:46:19 +02:00
|
|
|
echo '
|
|
|
|
<br>
|
|
|
|
<p class="small-bold">'.tr('Note', [], ['upper' => true]).':</p>
|
2019-07-12 12:40:13 +02:00
|
|
|
<p>'.nl2br($documento['note']).'</p>';
|
2017-09-12 17:46:19 +02:00
|
|
|
}
|