2017-09-12 16:17:11 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
include_once __DIR__.'/../../core.php';
|
|
|
|
|
2019-07-12 12:40:13 +02:00
|
|
|
// Creazione righe fantasma
|
|
|
|
$autofill = new \Util\Autofill($options['pricing'] ? 5 : 2);
|
|
|
|
$autofill->setRows(20, 10);
|
2017-09-12 16:17:11 +02:00
|
|
|
|
|
|
|
echo '
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-xs-6">
|
|
|
|
<div class="text-center" style="height:5mm;">
|
2017-09-21 11:02:31 +02:00
|
|
|
<b>'.tr('Preventivo num. _NUM_ del _DATE_', [
|
2020-04-01 17:17:26 +02:00
|
|
|
'_NUM_' => $documento['numero'].(count($documento->revisioni) > 1 ? ' '.tr('rev.').' '.$documento->numero_revision : ''),
|
2019-07-12 12:40:13 +02:00
|
|
|
'_DATE_' => Translator::dateToLocale($documento['data_bozza']),
|
2017-09-12 16:17:11 +02:00
|
|
|
], ['upper' => true]).'</b>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2019-07-12 12:56:46 +02:00
|
|
|
<div class="col-xs-6" style="margin-left: 10px">
|
2017-09-12 16:17:11 +02:00
|
|
|
<table class="table" style="width:100%;margin-top:5mm;">
|
|
|
|
<tr>
|
|
|
|
<td colspan=2 class="border-full" style="height:16mm;">
|
|
|
|
<p class="small-bold">'.tr('Spett.le', [], ['upper' => true]).'</p>
|
|
|
|
<p>$c_ragionesociale$</p>
|
2018-08-08 19:00:19 +02:00
|
|
|
<p>$c_indirizzo$</p>
|
|
|
|
<p>$c_citta_full$</p>
|
2017-09-12 16:17:11 +02:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
<td class="border-bottom border-left">
|
|
|
|
<p class="small-bold">'.tr('Partita IVA', [], ['upper' => true]).'</p>
|
|
|
|
</td>
|
|
|
|
<td class="border-right border-bottom text-right">
|
|
|
|
<small>$c_piva$</small>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
<td class="border-bottom border-left">
|
|
|
|
<p class="small-bold">'.tr('Codice fiscale', [], ['upper' => true]).'</p>
|
|
|
|
</td>
|
|
|
|
<td class="border-right border-bottom text-right">
|
|
|
|
<small>$c_codicefiscale$</small>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>';
|
|
|
|
|
|
|
|
// Descrizione
|
2019-07-12 12:40:13 +02:00
|
|
|
if (!empty($documento['descrizione'])) {
|
2017-09-12 16:17:11 +02:00
|
|
|
echo '
|
2019-07-12 12:40:13 +02:00
|
|
|
<p>'.nl2br($documento['descrizione']).'</p>
|
2017-09-12 16:17:11 +02:00
|
|
|
<br>';
|
|
|
|
}
|
|
|
|
|
|
|
|
// Intestazione tabella per righe
|
|
|
|
echo "
|
2017-09-12 16:45:18 +02:00
|
|
|
<table class='table table-striped table-bordered' id='contents'>
|
2017-09-12 16:17:11 +02:00
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th class='text-center' style='width:50%'>".tr('Descrizione', [], ['upper' => true])."</th>
|
2019-07-12 12:40:13 +02:00
|
|
|
<th class='text-center' style='width:10%'>".tr('Q.tà', [], ['upper' => true]).'</th>';
|
|
|
|
|
|
|
|
if ($options['pricing']) {
|
|
|
|
echo "
|
2017-09-12 16:45:18 +02:00
|
|
|
<th class='text-center' style='width:15%'>".tr('Prezzo unitario', [], ['upper' => true])."</th>
|
2019-07-12 12:40:13 +02:00
|
|
|
<th class='text-center' style='width:15%'>".tr('Importo', [], ['upper' => true])."</th>
|
|
|
|
<th class='text-center' style='width:10%'>".tr('IVA', [], ['upper' => true]).' (%)</th>';
|
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
2017-09-12 16:17:11 +02:00
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
|
|
|
|
<tbody>';
|
|
|
|
|
2019-07-12 12:40:13 +02:00
|
|
|
// Righe documento
|
|
|
|
$righe = $documento->getRighe();
|
|
|
|
foreach ($righe as $riga) {
|
|
|
|
$r = $riga->toArray();
|
|
|
|
|
|
|
|
$autofill->count($r['descrizione']);
|
2017-09-12 16:17:11 +02:00
|
|
|
|
|
|
|
echo '
|
|
|
|
<tr>
|
2020-01-22 14:55:22 +01:00
|
|
|
<td style="vertical-align: middle">
|
2017-09-12 16:17:11 +02:00
|
|
|
'.nl2br($r['descrizione']);
|
|
|
|
|
2019-07-12 12:40:13 +02:00
|
|
|
if ($riga->isArticolo()) {
|
|
|
|
// Codice articolo
|
|
|
|
$text = tr('COD. _COD_', [
|
|
|
|
'_COD_' => $riga->articolo->codice,
|
|
|
|
]);
|
2017-09-12 16:17:11 +02:00
|
|
|
echo '
|
2019-07-12 12:40:13 +02:00
|
|
|
<br><small>'.$text.'</small>';
|
2017-09-12 16:17:11 +02:00
|
|
|
|
2019-07-12 12:40:13 +02:00
|
|
|
$autofill->count($text, true);
|
2017-09-12 16:17:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
|
|
|
</td>';
|
|
|
|
|
2019-07-12 12:40:13 +02:00
|
|
|
if (!$riga->isDescrizione()) {
|
2018-02-17 09:02:19 +01:00
|
|
|
echo '
|
2020-01-22 14:55:22 +01:00
|
|
|
<td class="text-center" style="vertical-align: middle" >
|
2019-07-12 12:40:13 +02:00
|
|
|
'.Translator::numberToLocale(abs($riga->qta), 'qta').' '.$r['um'].'
|
2017-09-12 16:17:11 +02:00
|
|
|
</td>';
|
|
|
|
|
2019-07-12 12:40:13 +02:00
|
|
|
if ($options['pricing']) {
|
|
|
|
// Prezzo unitario
|
2018-02-17 09:02:19 +01:00
|
|
|
echo '
|
2020-01-22 14:55:22 +01:00
|
|
|
<td class="text-right" style="vertical-align: middle">
|
2020-02-14 17:43:39 +01:00
|
|
|
'.moneyFormat($riga->prezzo_unitario);
|
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 16:17:11 +02:00
|
|
|
</td>';
|
|
|
|
|
2019-07-12 12:40:13 +02:00
|
|
|
// Imponibile
|
2018-02-17 09:02:19 +01:00
|
|
|
echo '
|
2020-01-22 14:55:22 +01:00
|
|
|
<td class="text-right" style="vertical-align: middle" >
|
2019-07-12 12:40:13 +02:00
|
|
|
'.moneyFormat($riga->totale_imponibile).'
|
|
|
|
</td>';
|
|
|
|
|
|
|
|
// Iva
|
|
|
|
echo '
|
2020-01-22 14:55:22 +01:00
|
|
|
<td class="text-center" style="vertical-align: middle">
|
2019-07-12 12:40:13 +02:00
|
|
|
'.Translator::numberToLocale($riga->aliquota->percentuale, 0).'
|
2017-09-12 16:17:11 +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 16:17:11 +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 16:17:11 +02:00
|
|
|
</tr>';
|
|
|
|
|
2019-07-12 12:40:13 +02:00
|
|
|
$autofill->next();
|
2017-09-12 16:17:11 +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 16:17:11 +02:00
|
|
|
// TOTALE COSTI FINALI
|
2020-02-14 12:10:42 +01:00
|
|
|
if (($options['pricing'] && !isset($options['hide_total'])) || $options['show_only_total']) {
|
2017-09-12 16:17:11 +02:00
|
|
|
// Totale imponibile
|
|
|
|
echo '
|
|
|
|
<tr>
|
2020-02-14 12:37:55 +01:00
|
|
|
<td colspan="'.($options['show_only_total'] ? 1 : 3).'" class="text-right border-top">
|
2017-09-12 16:17:11 +02:00
|
|
|
<b>'.tr('Imponibile', [], ['upper' => true]).':</b>
|
|
|
|
</td>
|
|
|
|
|
2020-02-14 12:37:55 +01:00
|
|
|
<th colspan="'.($options['show_only_total'] ? 1 : 2).'" class="text-right">
|
2019-07-12 12:40:13 +02:00
|
|
|
<b>'.moneyFormat($show_sconto ? $imponibile : $totale_imponibile, 2).'</b>
|
2017-09-12 16:17:11 +02:00
|
|
|
</th>
|
|
|
|
</tr>';
|
|
|
|
|
|
|
|
// Eventuale sconto incondizionato
|
2019-07-12 12:40:13 +02:00
|
|
|
if ($show_sconto) {
|
2017-09-12 16:17:11 +02:00
|
|
|
echo '
|
|
|
|
<tr>
|
2020-02-14 12:37:55 +01:00
|
|
|
<td colspan="'.($options['show_only_total'] ? 1 : 3).'" class="text-right border-top">
|
2017-09-12 16:17:11 +02:00
|
|
|
<b>'.tr('Sconto', [], ['upper' => true]).':</b>
|
|
|
|
</td>
|
|
|
|
|
2020-02-14 12:37:55 +01:00
|
|
|
<th colspan="'.($options['show_only_total'] ? 1 : 2).'" class="text-right">
|
2019-07-12 12:40:13 +02:00
|
|
|
<b>'.moneyFormat($sconto, 2).'</b>
|
2017-09-12 16:17:11 +02:00
|
|
|
</th>
|
|
|
|
</tr>';
|
|
|
|
|
2019-07-11 17:44:42 +02:00
|
|
|
// Totale imponibile
|
2017-09-12 16:17:11 +02:00
|
|
|
echo '
|
|
|
|
<tr>
|
2020-02-14 12:37:55 +01:00
|
|
|
<td colspan="'.($options['show_only_total'] ? 1 : 3).'" class="text-right border-top">
|
2019-07-11 17:44:42 +02:00
|
|
|
<b>'.tr('Totale imponibile', [], ['upper' => true]).':</b>
|
2017-09-12 16:17:11 +02:00
|
|
|
</td>
|
|
|
|
|
2020-02-14 12:37:55 +01:00
|
|
|
<th colspan="'.($options['show_only_total'] ? 1 : 2).'" class="text-right">
|
2019-07-12 12:40:13 +02:00
|
|
|
<b>'.moneyFormat($totale_imponibile, 2).'</b>
|
2017-09-12 16:17:11 +02:00
|
|
|
</th>
|
|
|
|
</tr>';
|
|
|
|
}
|
|
|
|
|
|
|
|
// IVA
|
|
|
|
echo '
|
|
|
|
<tr>
|
2020-02-14 12:37:55 +01:00
|
|
|
<td colspan="'.($options['show_only_total'] ? 1 : 3).'" class="text-right border-top">
|
2017-09-12 16:17:11 +02:00
|
|
|
<b>'.tr('Totale IVA', [], ['upper' => true]).':</b>
|
|
|
|
</td>
|
|
|
|
|
2020-02-14 12:37:55 +01:00
|
|
|
<th colspan="'.($options['show_only_total'] ? 1 : 2).'" class="text-right">
|
2019-07-12 12:40:13 +02:00
|
|
|
<b>'.moneyFormat($totale_iva, 2).'</b>
|
2017-09-12 16:17:11 +02:00
|
|
|
</th>
|
|
|
|
</tr>';
|
|
|
|
|
2017-09-12 17:46:19 +02:00
|
|
|
// TOTALE
|
2017-09-12 16:17:11 +02:00
|
|
|
echo '
|
|
|
|
<tr>
|
2020-02-14 12:37:55 +01:00
|
|
|
<td colspan="'.($options['show_only_total'] ? 1 : 3).'" class="text-right border-top">
|
2019-07-12 12:40:13 +02:00
|
|
|
<b>'.tr('Totale documento', [], ['upper' => true]).':</b>
|
2017-09-12 16:17:11 +02:00
|
|
|
</td>
|
2020-02-14 12:37:55 +01:00
|
|
|
<th colspan="'.($options['show_only_total'] ? 1 : 2).'" class="text-right">
|
2019-05-02 10:03:57 +02:00
|
|
|
<b>'.moneyFormat($totale, 2).'</b>
|
2017-09-12 16:17:11 +02:00
|
|
|
</th>
|
|
|
|
</tr>';
|
|
|
|
}
|
|
|
|
|
|
|
|
echo'
|
|
|
|
</table>';
|
|
|
|
|
|
|
|
// CONDIZIONI GENERALI DI FORNITURA
|
2019-07-12 12:40:13 +02:00
|
|
|
$pagamento = $dbo->fetchOne('SELECT * FROM co_pagamenti WHERE id = '.$documento['idpagamento']);
|
2017-09-12 16:17:11 +02:00
|
|
|
|
|
|
|
echo '
|
|
|
|
<table class="table table-bordered">
|
|
|
|
<tr>
|
2017-09-13 11:15:31 +02:00
|
|
|
<th colspan="2" class="text-center" style="font-size:13pt;">
|
2017-09-12 16:17:11 +02:00
|
|
|
'.tr('Condizioni generali di fornitura', [], ['upper' => true]).'
|
|
|
|
</th>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
<th style="width:25%">
|
|
|
|
'.tr('Pagamento', [], ['upper' => true]).'
|
|
|
|
</th>
|
|
|
|
|
|
|
|
<td>
|
2019-07-12 12:40:13 +02:00
|
|
|
'.$pagamento['descrizione'].'
|
2017-09-12 16:17:11 +02:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
<th>
|
|
|
|
'.tr('Validità offerta', [], ['upper' => true]).'
|
|
|
|
</th>
|
|
|
|
|
2017-09-13 13:05:35 +02:00
|
|
|
<td>';
|
|
|
|
|
2019-07-12 12:40:13 +02:00
|
|
|
if (!empty($documento['validita'])) {
|
2017-09-13 13:05:35 +02:00
|
|
|
echo'
|
2017-09-12 16:17:11 +02:00
|
|
|
'.tr('_TOT_ giorni', [
|
2019-07-12 12:40:13 +02:00
|
|
|
'_TOT_' => $documento['validita'],
|
2017-09-13 13:05:35 +02:00
|
|
|
]);
|
|
|
|
} else {
|
|
|
|
echo '-';
|
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
2017-09-12 16:17:11 +02:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
<th>
|
|
|
|
'.tr('Tempi consegna', [], ['upper' => true]).'
|
|
|
|
</th>
|
|
|
|
|
|
|
|
<td>
|
2019-07-12 12:40:13 +02:00
|
|
|
'.$documento['tempi_consegna'].'
|
2017-09-12 16:17:11 +02:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
<th>
|
|
|
|
'.tr('Esclusioni', [], ['upper' => true]).'
|
|
|
|
</th>
|
|
|
|
|
|
|
|
<td>
|
2019-07-12 12:40:13 +02:00
|
|
|
'.nl2br($documento['esclusioni']).'
|
2017-09-12 16:17:11 +02:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</table>';
|
|
|
|
|
|
|
|
// Conclusione
|
|
|
|
echo '
|
|
|
|
<p class="text-center">'.tr("In attesa di un Vostro Cortese riscontro, colgo l'occasione per porgere Cordiali Saluti").'</p>';
|