2017-09-12 17:46:19 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
include_once __DIR__.'/../../core.php';
|
|
|
|
|
|
|
|
$report_name = 'ordine_'.$numero_ord.'.pdf';
|
|
|
|
|
|
|
|
$autofill = [
|
|
|
|
'count' => 0, // Conteggio delle righe
|
|
|
|
'words' => 70, // Numero di parolo dopo cui contare una riga nuova
|
|
|
|
'rows' => 20, // Numero di righe massimo presente nella pagina
|
|
|
|
'additional' => 15, // Numero di righe massimo da aggiungere
|
|
|
|
'columns' => 5, // Numero di colonne della tabella
|
|
|
|
];
|
|
|
|
|
|
|
|
$sconto = [];
|
|
|
|
$imponibile = [];
|
|
|
|
$iva = [];
|
|
|
|
|
|
|
|
// Intestazione tabella per righe
|
|
|
|
echo "
|
|
|
|
<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:10%'>".tr('Q.tà', [], ['upper' => true])."</th>
|
|
|
|
<th class='text-center' style='width:15%'>".tr('Prezzo unitario', [], ['upper' => true])."</th>
|
2018-02-09 15:27:43 +01:00
|
|
|
<th class='text-center' style='width:15%'>".tr('Importo', [], ['upper' => true])."</th>
|
2017-09-12 17:46:19 +02:00
|
|
|
<th class='text-center' style='width:10%'>".tr('IVA', [], ['upper' => true]).' (%)</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
|
|
|
|
<tbody>';
|
|
|
|
|
|
|
|
// RIGHE PREVENTIVO CON ORDINAMENTO UNICO
|
2018-02-15 14:25:27 +01:00
|
|
|
$righe = $dbo->fetchArray("SELECT *,
|
|
|
|
IFNULL((SELECT `codice` FROM `mg_articoli` WHERE `id` = `or_righe_ordini`.`idarticolo`), '') AS codice_articolo,
|
|
|
|
(SELECT GROUP_CONCAT(`serial` SEPARATOR ', ') FROM `mg_prodotti` WHERE `id_riga_ordine` = `or_righe_ordini`.`id`) AS seriali,
|
|
|
|
(SELECT `percentuale` FROM `co_iva` WHERE `id` = `or_righe_ordini`.`idiva`) AS perc_iva
|
2018-02-15 17:41:09 +01:00
|
|
|
FROM `or_righe_ordini` WHERE idordine=".prepare($id_record).' ORDER BY `order`');
|
2017-09-12 17:46:19 +02:00
|
|
|
foreach ($righe as $r) {
|
|
|
|
$count = 0;
|
|
|
|
$count += ceil(strlen($r['descrizione']) / $autofill['words']);
|
|
|
|
$count += substr_count($r['descrizione'], PHP_EOL);
|
|
|
|
|
|
|
|
echo '
|
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
'.nl2br($r['descrizione']);
|
|
|
|
|
2018-02-15 14:25:27 +01:00
|
|
|
// Codice articolo
|
2017-09-12 17:46:19 +02:00
|
|
|
if (!empty($r['codice_articolo'])) {
|
|
|
|
echo '
|
|
|
|
<br><small>'.tr('COD. _COD_', [
|
|
|
|
'_COD_' => $r['codice_articolo'],
|
|
|
|
]).'</small>';
|
|
|
|
|
|
|
|
if ($count <= 1) {
|
|
|
|
$count += 0.4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-15 14:25:27 +01:00
|
|
|
// Seriali
|
|
|
|
if (!empty($r['seriali'])) {
|
|
|
|
echo '
|
|
|
|
<br><small>'.tr('SN').': '.$r['seriali'].'</small>';
|
|
|
|
|
|
|
|
if ($count <= 1) {
|
|
|
|
$count += 0.4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-12 17:46:19 +02:00
|
|
|
echo '
|
|
|
|
</td>';
|
|
|
|
|
|
|
|
echo "
|
2018-01-18 19:03:06 +01:00
|
|
|
<td class='text-center'>";
|
2018-02-15 17:41:09 +01:00
|
|
|
if (empty($r['is_descrizione'])) {
|
|
|
|
echo '
|
2018-06-29 13:35:39 +02:00
|
|
|
'.(empty($r['qta']) ? '' : Translator::numberToLocale($r['qta'], 'qta')).' '.$r['um'];
|
2018-01-18 19:03:06 +01:00
|
|
|
}
|
|
|
|
echo '
|
2017-09-12 17:46:19 +02:00
|
|
|
</td>';
|
|
|
|
|
2017-09-21 15:51:39 +02:00
|
|
|
if ($options['pricing']) {
|
2017-09-12 17:46:19 +02:00
|
|
|
// Prezzo unitario
|
|
|
|
echo "
|
2018-01-18 19:03:06 +01:00
|
|
|
<td class='text-right'>";
|
2018-02-15 17:41:09 +01:00
|
|
|
if (empty($r['is_descrizione'])) {
|
|
|
|
echo '
|
|
|
|
'.(empty($r['qta']) || empty($r['subtotale']) ? '' : Translator::numberToLocale($r['subtotale'] / $r['qta'])).' €';
|
2018-01-18 19:03:06 +01:00
|
|
|
|
|
|
|
if ($r['sconto'] > 0) {
|
|
|
|
echo "
|
2018-02-15 17:41:09 +01:00
|
|
|
<br><small class='text-muted'>- ".tr('sconto _TOT_ _TYPE_', [
|
|
|
|
'_TOT_' => Translator::numberToLocale($r['sconto_unitario']),
|
|
|
|
'_TYPE_' => ($r['tipo_sconto'] == 'PRC' ? '%' : '€'),
|
|
|
|
]).'</small>';
|
2018-01-18 19:03:06 +01:00
|
|
|
|
|
|
|
if ($count <= 1) {
|
|
|
|
$count += 0.4;
|
|
|
|
}
|
2017-09-21 10:01:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
echo '
|
2017-09-12 17:46:19 +02:00
|
|
|
</td>';
|
|
|
|
|
|
|
|
// Imponibile
|
|
|
|
echo "
|
2018-01-18 19:03:06 +01:00
|
|
|
<td class='text-right'>";
|
2018-02-15 17:41:09 +01:00
|
|
|
if (empty($r['is_descrizione'])) {
|
|
|
|
echo '
|
|
|
|
'.(empty($r['subtotale']) ? '' : Translator::numberToLocale($r['subtotale'])).' €';
|
2018-01-18 19:03:06 +01:00
|
|
|
|
|
|
|
if ($r['sconto'] > 0) {
|
|
|
|
echo "
|
2018-02-15 17:41:09 +01:00
|
|
|
<br><small class='text-muted'>- ".tr('sconto _TOT_ _TYPE_', [
|
|
|
|
'_TOT_' => Translator::numberToLocale($r['sconto']),
|
|
|
|
'_TYPE_' => '€',
|
|
|
|
]).'</small>';
|
2018-01-18 19:03:06 +01:00
|
|
|
|
|
|
|
if ($count <= 1) {
|
|
|
|
$count += 0.4;
|
|
|
|
}
|
2017-09-12 17:46:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
echo '
|
|
|
|
</td>';
|
|
|
|
} else {
|
|
|
|
echo '
|
|
|
|
<td class="text-center">-</td>
|
|
|
|
<td class="text-center">-</td>';
|
|
|
|
}
|
|
|
|
|
|
|
|
// Iva
|
|
|
|
echo '
|
2018-01-18 19:03:06 +01:00
|
|
|
<td class="text-center">';
|
2018-02-15 17:41:09 +01:00
|
|
|
if (empty($r['is_descrizione'])) {
|
|
|
|
echo '
|
|
|
|
'.Translator::numberToLocale($r['perc_iva']);
|
2018-01-18 19:03:06 +01:00
|
|
|
}
|
|
|
|
echo '
|
2017-09-12 17:46:19 +02:00
|
|
|
</td>
|
|
|
|
</tr>';
|
|
|
|
|
|
|
|
$autofill['count'] += $count;
|
|
|
|
|
|
|
|
$sconto[] = $r['sconto'];
|
|
|
|
$imponibile[] = $r['subtotale'];
|
|
|
|
$iva[] = $r['iva'];
|
|
|
|
}
|
|
|
|
|
|
|
|
$sconto = sum($sconto);
|
|
|
|
$imponibile = sum($imponibile);
|
2018-05-11 16:57:34 +02:00
|
|
|
$iva = sum($iva, null, 2);
|
2017-09-12 17:46:19 +02:00
|
|
|
|
|
|
|
$totale = $imponibile - $sconto;
|
|
|
|
|
|
|
|
echo '
|
|
|
|
|autofill|
|
|
|
|
</tbody>';
|
|
|
|
|
|
|
|
// 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>
|
|
|
|
<td colspan="3" class="text-right border-top">
|
|
|
|
<b>'.tr('Imponibile', [], ['upper' => true]).':</b>
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<th colspan="2" class="text-center">
|
2017-09-21 10:01:07 +02:00
|
|
|
<b>'.Translator::numberToLocale($imponibile).' €</b>
|
2017-09-12 17:46:19 +02:00
|
|
|
</th>
|
|
|
|
</tr>';
|
|
|
|
|
|
|
|
// Eventuale sconto incondizionato
|
|
|
|
if (!empty($sconto)) {
|
|
|
|
echo '
|
|
|
|
<tr>
|
|
|
|
<td colspan="3" class="text-right border-top">
|
|
|
|
<b>'.tr('Sconto', [], ['upper' => true]).':</b>
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<th colspan="2" class="text-center">
|
2017-09-21 10:01:07 +02:00
|
|
|
<b>-'.Translator::numberToLocale($sconto).' €</b>
|
2017-09-12 17:46:19 +02:00
|
|
|
</th>
|
|
|
|
</tr>';
|
|
|
|
|
|
|
|
// Imponibile scontato
|
|
|
|
echo '
|
|
|
|
<tr>
|
|
|
|
<td colspan="3" class="text-right border-top">
|
|
|
|
<b>'.tr('Imponibile scontato', [], ['upper' => true]).':</b>
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<th colspan="2" class="text-center">
|
2017-09-21 10:01:07 +02:00
|
|
|
<b>'.Translator::numberToLocale($totale).' €</b>
|
2017-09-12 17:46:19 +02:00
|
|
|
</th>
|
|
|
|
</tr>';
|
|
|
|
}
|
|
|
|
|
|
|
|
// IVA
|
|
|
|
echo '
|
|
|
|
<tr>
|
|
|
|
<td colspan="3" class="text-right border-top">
|
|
|
|
<b>'.tr('Totale IVA', [], ['upper' => true]).':</b>
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<th colspan="2" class="text-center">
|
2017-09-21 10:01:07 +02:00
|
|
|
<b>'.Translator::numberToLocale($iva).' €</b>
|
2017-09-12 17:46:19 +02:00
|
|
|
</th>
|
|
|
|
</tr>';
|
|
|
|
|
|
|
|
$totale = sum($totale, $iva);
|
|
|
|
|
|
|
|
// TOTALE
|
|
|
|
echo '
|
|
|
|
<tr>
|
|
|
|
<td colspan="3" class="text-right border-top">
|
|
|
|
<b>'.tr('Quotazione totale', [], ['upper' => true]).':</b>
|
|
|
|
</td>
|
|
|
|
<th colspan="2" class="text-center">
|
2017-09-21 10:01:07 +02:00
|
|
|
<b>'.Translator::numberToLocale($totale).' €</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>';
|
|
|
|
|
|
|
|
if (!empty($records[0]['note'])) {
|
|
|
|
echo '
|
|
|
|
<br>
|
|
|
|
<p class="small-bold">'.tr('Note', [], ['upper' => true]).':</p>
|
|
|
|
<p>'.nl2br($records[0]['note']).'</p>';
|
|
|
|
}
|