2017-09-12 16:17:11 +02:00
|
|
|
<?php
|
2020-09-07 15:04:06 +02:00
|
|
|
/*
|
|
|
|
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
|
2021-01-20 15:08:51 +01:00
|
|
|
* Copyright (C) DevCode s.r.l.
|
2020-09-07 15:04:06 +02:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2017-09-12 16:17:11 +02:00
|
|
|
|
2020-07-07 18:07:56 +02:00
|
|
|
use Carbon\CarbonInterval;
|
2021-09-22 17:17:03 +02:00
|
|
|
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
2020-11-04 18:31:43 +01:00
|
|
|
use Modules\Anagrafiche\Anagrafica;
|
2021-09-22 17:17:03 +02:00
|
|
|
use Modules\Banche\Banca;
|
|
|
|
use Modules\Pagamenti\Pagamento;
|
2020-07-07 18:07:56 +02:00
|
|
|
|
2017-09-12 16:17:11 +02:00
|
|
|
include_once __DIR__.'/../../core.php';
|
|
|
|
|
2020-11-04 18:31:43 +01:00
|
|
|
$anagrafica = Anagrafica::find($documento['idanagrafica']);
|
2021-09-22 17:17:03 +02:00
|
|
|
$anagrafica_azienda = Anagrafica::find(setting('Azienda predefinita'));
|
2022-09-06 13:04:32 +02:00
|
|
|
$prezzi_ivati = setting('Utilizza prezzi di vendita comprensivi di IVA');
|
2020-11-04 18:31:43 +01:00
|
|
|
|
2021-09-22 17:17:03 +02:00
|
|
|
$pagamento = Pagamento::find($documento['idpagamento']);
|
|
|
|
|
|
|
|
// Banca dell'Azienda corrente impostata come predefinita per il Cliente
|
2021-09-22 17:24:13 +02:00
|
|
|
$banca_azienda = Banca::where('id_anagrafica', '=', $anagrafica_azienda->id)
|
|
|
|
->where('id_pianodeiconti3', '=', $pagamento['idconto_vendite'] ?: 0);
|
2021-09-22 17:17:03 +02:00
|
|
|
try {
|
|
|
|
$banca = (clone $banca_azienda)
|
|
|
|
->findOrFail($anagrafica->idbanca_vendite);
|
|
|
|
} catch (ModelNotFoundException $e) {
|
|
|
|
// Ricerca prima banca dell'Azienda con Conto corrispondente
|
|
|
|
$banca = (clone $banca_azienda)
|
2021-09-22 17:24:13 +02:00
|
|
|
->orderBy('predefined', 'DESC')
|
2021-09-22 17:17:03 +02:00
|
|
|
->first();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Ri.Ba: Banca predefinita *del Cliente* piuttosto che dell'Azienda
|
2022-01-19 11:21:49 +01:00
|
|
|
if ($pagamento && $pagamento->isRiBa()) {
|
2021-09-22 17:17:03 +02:00
|
|
|
$banca = Banca::where('id_anagrafica', $anagrafica->id)
|
|
|
|
->where('predefined', 1)
|
|
|
|
->first();
|
2020-06-16 13:03:54 +02:00
|
|
|
}
|
|
|
|
|
2021-09-02 16:27:38 +02:00
|
|
|
// Righe documento
|
|
|
|
$righe = $documento->getRighe();
|
|
|
|
|
|
|
|
$has_image = $righe->search(function ($item) {
|
|
|
|
return !empty($item->articolo->immagine);
|
2023-03-31 14:36:08 +02:00
|
|
|
}) !== false && $options['images'] == true;
|
2021-09-02 16:27:38 +02:00
|
|
|
|
2023-11-14 10:48:04 +01:00
|
|
|
$columns = $options['no-iva'] ? 5 : 6;
|
2022-05-16 15:17:44 +02:00
|
|
|
$columns = $options['pricing'] ? $columns : 3;
|
|
|
|
|
2021-09-02 16:27:38 +02:00
|
|
|
if ($has_image) {
|
|
|
|
++$columns;
|
|
|
|
}
|
|
|
|
|
2019-07-12 12:40:13 +02:00
|
|
|
// Creazione righe fantasma
|
2021-09-02 16:27:38 +02:00
|
|
|
$autofill = new \Util\Autofill($columns);
|
2019-07-12 12:40:13 +02:00
|
|
|
$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>
|
2020-06-16 13:03:54 +02:00
|
|
|
|
2020-07-17 17:34:06 +02:00
|
|
|
<table class="table">
|
|
|
|
<tr>
|
|
|
|
<td colspan="2" style="height:10mm;padding-top:2mm;">
|
|
|
|
<p class="small-bold">'.tr('Pagamento', [], ['upper' => true]).'</p>
|
|
|
|
<p>'.$pagamento['descrizione'].'</p>
|
|
|
|
</td>
|
|
|
|
<td colspan="2" style="height:10mm;padding-top:2mm;">
|
|
|
|
<p class="small-bold">'.tr('Banca di appoggio', [], ['upper' => true]).'</p>
|
|
|
|
<p><small>'.$banca['nome'].'</small></p>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td colspan="2" style="height:10mm;padding-top:2mm;white-space: nowrap;">
|
|
|
|
<p class="small-bold">'.tr('IBAN').'</p>
|
|
|
|
<p>'.$banca['iban'].'</p>
|
|
|
|
</td>
|
|
|
|
<td colspan="2" style="height:10mm;padding-top:2mm;">
|
|
|
|
<p class="small-bold">'.tr('BIC').'</p>
|
|
|
|
<p>'.$banca['bic'].'</p>
|
|
|
|
</td>
|
|
|
|
</tr>
|
2020-06-16 13:03:54 +02:00
|
|
|
</table>
|
2017-09-12 16:17:11 +02:00
|
|
|
</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>
|
2021-07-26 17:32:07 +02:00
|
|
|
</tr>';
|
|
|
|
if (!empty($destinazione)) {
|
|
|
|
echo '
|
|
|
|
<tr>
|
|
|
|
<td colspan="2" class="border-full" style="height:16mm;">
|
|
|
|
<p class="small-bold">'.tr('Destinazione diversa', [], ['upper' => true]).'</p>
|
|
|
|
<small>'.$destinazione.'</small>
|
|
|
|
</td>
|
|
|
|
</tr>';
|
|
|
|
}
|
|
|
|
echo '
|
2017-09-12 16:17:11 +02:00
|
|
|
</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>
|
2023-10-01 11:46:11 +02:00
|
|
|
<th class='text-center' width='35' >#</th>";
|
2020-06-16 13:03:54 +02:00
|
|
|
|
2021-09-02 16:27:38 +02:00
|
|
|
if ($has_image) {
|
2020-06-30 13:26:15 +02:00
|
|
|
echo "
|
2020-06-16 13:03:54 +02:00
|
|
|
<th class='text-center' width='95' >Foto</th>";
|
|
|
|
}
|
|
|
|
|
|
|
|
echo "
|
2017-09-12 16:17:11 +02:00
|
|
|
<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 "
|
2023-11-15 14:10:33 +01:00
|
|
|
<th class='text-center' style='width:15%'>".tr('Prezzo unitario', [], ['upper' => true]).'</th>';
|
|
|
|
if (!$options['no-iva']) {
|
|
|
|
echo "
|
|
|
|
<th class='text-center' style='width:10%'>".tr('IVA', [], ['upper' => true]).' (%)</th>';
|
|
|
|
}
|
|
|
|
echo "
|
2023-09-21 17:34:30 +02:00
|
|
|
<th class='text-center' style='width:15%'>".($options['hide-total'] ? tr('Importo ivato', [], ['upper' => true]) : tr('Importo', [], ['upper' => true])).'</th>';
|
2019-07-12 12:40:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
2017-09-12 16:17:11 +02:00
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
|
|
|
|
<tbody>';
|
|
|
|
|
2020-09-11 09:04:06 +02:00
|
|
|
$num = 0;
|
2023-09-15 17:18:44 +02:00
|
|
|
$has_gruppo = false;
|
|
|
|
$subtotale_gruppo = 0;
|
|
|
|
$iva_gruppo = 0;
|
|
|
|
foreach ($righe as $key => $riga) {
|
2020-09-11 09:04:06 +02:00
|
|
|
++$num;
|
2019-07-12 12:40:13 +02:00
|
|
|
$r = $riga->toArray();
|
|
|
|
|
2023-09-15 17:18:44 +02:00
|
|
|
// Gestione gruppo
|
|
|
|
$style_titolo = '';
|
|
|
|
$colspan_titolo = '';
|
|
|
|
if ($riga->is_titolo) {
|
|
|
|
$subtotale_gruppo = 0;
|
|
|
|
$iva_gruppo = 0;
|
|
|
|
$has_gruppo = true;
|
|
|
|
$colspan_titolo = $options['pricing'] ? 'colspan="5"' : 'colspan="2"';
|
|
|
|
$descrizione = '<b>'.nl2br($r['descrizione']).'</b>';
|
|
|
|
} else {
|
|
|
|
$descrizione = nl2br($r['descrizione']);
|
|
|
|
}
|
|
|
|
$subtotale_gruppo += $riga->totale_imponibile;
|
|
|
|
$iva_gruppo += $riga->iva;
|
|
|
|
|
2019-07-12 12:40:13 +02:00
|
|
|
$autofill->count($r['descrizione']);
|
2017-09-12 16:17:11 +02:00
|
|
|
|
|
|
|
echo '
|
2020-09-11 09:04:06 +02:00
|
|
|
<tr>
|
2023-05-04 11:52:53 +02:00
|
|
|
<td class="text-center" nowrap="nowrap" style="vertical-align: middle" width="25">
|
2020-09-11 09:04:06 +02:00
|
|
|
'.$num.'
|
|
|
|
</td>';
|
2020-06-16 13:03:54 +02:00
|
|
|
|
2021-09-02 16:27:38 +02:00
|
|
|
if ($has_image) {
|
|
|
|
if ($riga->isArticolo() && !empty($riga->articolo->image)) {
|
|
|
|
echo '
|
|
|
|
<td align="center">
|
2022-09-27 10:50:20 +02:00
|
|
|
<img src="'.$riga->articolo->image.'" style="max-height: 60px; max-width:80px">
|
2021-09-02 16:27:38 +02:00
|
|
|
</td>';
|
2020-06-30 13:26:15 +02:00
|
|
|
|
2021-09-02 16:27:38 +02:00
|
|
|
$autofill->set(5);
|
|
|
|
} else {
|
|
|
|
echo '
|
|
|
|
<td></td>';
|
|
|
|
}
|
2020-06-09 16:59:26 +02:00
|
|
|
}
|
|
|
|
|
2020-05-18 17:18:56 +02:00
|
|
|
echo '
|
2023-09-15 17:18:44 +02:00
|
|
|
<td style="vertical-align: middle" '.$colspan_titolo.'>
|
|
|
|
'.$descrizione;
|
2017-09-12 16:17:11 +02:00
|
|
|
|
2019-07-12 12:40:13 +02:00
|
|
|
if ($riga->isArticolo()) {
|
2023-08-04 14:54:28 +02:00
|
|
|
if ($options['hide-item-number']) {
|
2023-03-10 13:00:39 +01:00
|
|
|
$text = '';
|
2023-08-04 14:54:28 +02:00
|
|
|
} else {
|
2023-03-10 13:00:39 +01:00
|
|
|
// Codice articolo
|
|
|
|
$text = tr('COD. _COD_', [
|
|
|
|
'_COD_' => $riga->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>';
|
|
|
|
|
2023-09-15 17:18:44 +02:00
|
|
|
if (!$riga->is_titolo) {
|
|
|
|
if (!$riga->isDescrizione()) {
|
2018-02-17 09:02:19 +01:00
|
|
|
echo '
|
2023-09-15 17:18:44 +02:00
|
|
|
<td class="text-center" style="vertical-align: middle" >
|
2023-12-05 17:43:35 +01:00
|
|
|
'.Translator::numberToLocale(abs($riga->qta), $d_qta).' '.$r['um'].'
|
2023-09-15 17:18:44 +02:00
|
|
|
</td>';
|
2019-07-12 12:40:13 +02:00
|
|
|
|
2023-09-15 17:18:44 +02:00
|
|
|
if ($options['pricing']) {
|
|
|
|
// Prezzo unitario
|
2019-07-12 12:40:13 +02:00
|
|
|
echo '
|
2023-09-15 17:18:44 +02:00
|
|
|
<td class="text-right" style="vertical-align: middle">
|
2023-12-05 17:43:35 +01:00
|
|
|
'.moneyFormat($prezzi_ivati ? $riga->prezzo_unitario_ivato : $riga->prezzo_unitario, $d_importi);
|
2019-07-12 12:40:13 +02:00
|
|
|
|
2023-10-06 17:05:31 +02:00
|
|
|
if ($riga->sconto != 0) {
|
2023-09-15 17:18:44 +02:00
|
|
|
$text = discountInfo($riga, false);
|
2019-07-12 12:40:13 +02:00
|
|
|
|
2023-09-15 17:18:44 +02:00
|
|
|
echo '
|
|
|
|
<br><small class="text-muted">'.$text.'</small>';
|
2017-09-12 16:17:11 +02:00
|
|
|
|
2023-09-15 17:18:44 +02:00
|
|
|
$autofill->count($text, true);
|
|
|
|
}
|
2019-07-12 12:40:13 +02:00
|
|
|
|
2023-09-15 17:18:44 +02:00
|
|
|
echo '
|
|
|
|
</td>';
|
2023-11-14 10:48:04 +01:00
|
|
|
if (!$options['no-iva']) {
|
|
|
|
// Iva
|
|
|
|
echo '
|
|
|
|
<td class="text-center" style="vertical-align: middle">
|
2023-12-05 17:43:35 +01:00
|
|
|
'.Translator::numberToLocale($riga->aliquota->percentuale, $d_qta).'
|
2023-11-14 10:48:04 +01:00
|
|
|
</td>';
|
|
|
|
}
|
2023-09-21 17:34:30 +02:00
|
|
|
// Imponibile
|
|
|
|
echo '
|
2023-12-06 10:06:36 +01:00
|
|
|
<td class="text-right" style="vertical-align: middle" >
|
|
|
|
'.(($options['hide-total'] || $prezzi_ivati) ? moneyFormat($riga->totale, $d_importi) : moneyFormat($riga->totale_imponibile, $d_importi)).'
|
|
|
|
</td>';
|
2023-09-15 17:18:44 +02:00
|
|
|
}
|
|
|
|
} else {
|
2019-07-12 12:40:13 +02:00
|
|
|
echo '
|
2023-09-15 17:18:44 +02:00
|
|
|
<td></td>';
|
|
|
|
|
|
|
|
if ($options['pricing']) {
|
|
|
|
echo '
|
|
|
|
<td></td>
|
|
|
|
<td></td>';
|
2023-11-14 10:48:04 +01:00
|
|
|
if (!$options['no-iva']) {
|
2023-11-15 14:10:33 +01:00
|
|
|
echo '
|
2023-11-14 10:48:04 +01:00
|
|
|
<td></td>';
|
|
|
|
}
|
2023-09-15 17:18:44 +02:00
|
|
|
}
|
2019-07-12 12:40:13 +02:00
|
|
|
}
|
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();
|
2023-09-15 17:18:44 +02:00
|
|
|
|
|
|
|
$next = $righe->flatten()[$num];
|
2023-10-06 11:40:41 +02:00
|
|
|
if ($has_gruppo && ($next->is_titolo || $next == null) && ($options['pricing'] || ($options['show-only-total']))) {
|
2023-09-15 17:18:44 +02:00
|
|
|
echo '
|
|
|
|
<tr>
|
|
|
|
<td colspan="'.($options['show-only-total'] ? 2 : 5).'" class="text-right">
|
|
|
|
<b>'.tr('Subtotale', [], ['upper' => true]).':</b>
|
|
|
|
</td>
|
|
|
|
<td colspan="'.($options['show-only-total'] ? (($has_image) ? 2 : 1) : (($has_image) ? 3 : 2)).'" class="text-right">
|
2023-12-06 10:06:36 +01:00
|
|
|
'.moneyFormat($subtotale_gruppo, $d_totali).'
|
2023-09-15 17:18:44 +02:00
|
|
|
</td>
|
2023-11-14 10:48:04 +01:00
|
|
|
</tr>';
|
|
|
|
if (!$options['no-iva']) {
|
2023-11-15 14:10:33 +01:00
|
|
|
echo '
|
2023-09-15 17:18:44 +02:00
|
|
|
<tr>
|
|
|
|
<td colspan="'.($options['show-only-total'] ? 2 : 5).'" class="text-right">
|
|
|
|
<b>'.tr('Iva', [], ['upper' => true]).':</b>
|
|
|
|
</td>
|
|
|
|
<td colspan="'.($options['show-only-total'] ? (($has_image) ? 2 : 1) : (($has_image) ? 3 : 2)).'" class="text-right">
|
2023-12-06 10:06:36 +01:00
|
|
|
'.moneyFormat($iva_gruppo, $d_totali).'
|
2023-09-15 17:18:44 +02:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
2023-11-14 10:48:04 +01:00
|
|
|
<td colspan="'.($options['show-only-total'] ? 2 : 4).'" class="text-right">
|
2023-09-15 17:18:44 +02:00
|
|
|
<b>'.tr('Subtotale ivato', [], ['upper' => true]).':</b>
|
|
|
|
</td>
|
|
|
|
<td colspan="'.($options['show-only-total'] ? (($has_image) ? 2 : 1) : (($has_image) ? 3 : 2)).'" class="text-right">
|
2023-12-06 10:06:36 +01:00
|
|
|
<b>'.moneyFormat($subtotale_gruppo + $iva_gruppo, $d_totali).'</b>
|
2023-09-15 17:18:44 +02:00
|
|
|
</td>
|
|
|
|
</tr>';
|
2023-11-14 10:48:04 +01:00
|
|
|
}
|
2023-09-15 17:18:44 +02:00
|
|
|
$autofill->next();
|
|
|
|
$autofill->next();
|
|
|
|
$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;
|
2021-04-06 15:44:51 +02:00
|
|
|
$sconto_finale = $documento->getScontoFinale();
|
|
|
|
$netto_a_pagare = $documento->netto;
|
2019-07-12 12:40:13 +02:00
|
|
|
|
|
|
|
$show_sconto = $sconto > 0;
|
|
|
|
|
2017-09-12 16:17:11 +02:00
|
|
|
// TOTALE COSTI FINALI
|
2023-03-10 16:38:53 +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>
|
2023-11-24 18:24:20 +01:00
|
|
|
<td colspan="'.($options['show-only-total'] ? (($has_image) ? 3 : 2) : 4).'" class="text-right border-top">
|
2017-09-12 16:17:11 +02:00
|
|
|
<b>'.tr('Imponibile', [], ['upper' => true]).':</b>
|
|
|
|
</td>
|
|
|
|
|
2023-11-14 10:48:04 +01:00
|
|
|
<th colspan="'.($options['show-only-total'] ? (($has_image) ? ($options['no-iva'] ? 1 : 2) : 1) : (($has_image) ? 3 : 2)).'" class="text-right">
|
2023-12-06 10:06:36 +01:00
|
|
|
<b>'.moneyFormat($show_sconto ? $imponibile : $totale_imponibile, $d_totali).'</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>
|
2023-03-10 16:38:53 +01:00
|
|
|
<td colspan="'.($options['show-only-total'] ? 2 : 4).'" class="text-right border-top">
|
2017-09-12 16:17:11 +02:00
|
|
|
<b>'.tr('Sconto', [], ['upper' => true]).':</b>
|
|
|
|
</td>
|
|
|
|
|
2023-03-10 16:38:53 +01:00
|
|
|
<th colspan="'.($options['show-only-total'] ? (($has_image) ? 2 : 1) : (($has_image) ? 3 : 2)).'" class="text-right">
|
2023-12-06 10:06:36 +01:00
|
|
|
<b>'.moneyFormat($sconto, $d_totali).'</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>
|
2023-03-10 16:38:53 +01:00
|
|
|
<td colspan="'.($options['show-only-total'] ? 2 : 4).'" 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>
|
|
|
|
|
2023-03-10 16:38:53 +01:00
|
|
|
<th colspan="'.($options['show-only-total'] ? (($has_image) ? 2 : 1) : (($has_image) ? 3 : 2)).'" class="text-right">
|
2023-12-06 10:06:36 +01:00
|
|
|
<b>'.moneyFormat($totale_imponibile, $d_totali).'</b>
|
2017-09-12 16:17:11 +02:00
|
|
|
</th>
|
|
|
|
</tr>';
|
|
|
|
}
|
|
|
|
|
|
|
|
// IVA
|
2023-11-14 10:48:04 +01:00
|
|
|
if (!$options['no-iva']) {
|
2021-04-06 15:44:51 +02:00
|
|
|
echo '
|
|
|
|
<tr>
|
2023-03-10 16:38:53 +01:00
|
|
|
<td colspan="'.($options['show-only-total'] ? 2 : 4).'" class="text-right border-top">
|
2023-11-14 10:48:04 +01:00
|
|
|
<b>'.tr('Totale IVA', [], ['upper' => true]).':</b>
|
2021-04-06 15:44:51 +02:00
|
|
|
</td>
|
2023-11-14 10:48:04 +01:00
|
|
|
|
2023-03-10 16:38:53 +01:00
|
|
|
<th colspan="'.($options['show-only-total'] ? (($has_image) ? 2 : 1) : (($has_image) ? 3 : 2)).'" class="text-right">
|
2023-12-06 10:06:36 +01:00
|
|
|
<b>'.moneyFormat($totale_iva, $d_totali).'</b>
|
2021-04-06 15:44:51 +02:00
|
|
|
</th>
|
|
|
|
</tr>';
|
|
|
|
|
2023-11-14 10:48:04 +01:00
|
|
|
// TOTALE
|
2021-04-06 15:44:51 +02:00
|
|
|
echo '
|
|
|
|
<tr>
|
2023-03-10 16:38:53 +01:00
|
|
|
<td colspan="'.($options['show-only-total'] ? 2 : 4).'" class="text-right border-top">
|
2023-11-14 10:48:04 +01:00
|
|
|
<b>'.tr('Totale documento', [], ['upper' => true]).':</b>
|
2021-04-06 15:44:51 +02:00
|
|
|
</td>
|
2023-03-10 16:38:53 +01:00
|
|
|
<th colspan="'.($options['show-only-total'] ? (($has_image) ? 2 : 1) : (($has_image) ? 3 : 2)).'" class="text-right">
|
2023-12-06 10:06:36 +01:00
|
|
|
<b>'.moneyFormat($totale, $d_totali).'</b>
|
2021-04-06 15:44:51 +02:00
|
|
|
</th>
|
|
|
|
</tr>';
|
2023-11-14 10:48:04 +01:00
|
|
|
|
|
|
|
if ($sconto_finale) {
|
|
|
|
// SCONTO IN FATTURA
|
|
|
|
echo '
|
|
|
|
<tr>
|
|
|
|
<td colspan="'.($options['show-only-total'] ? 2 : 4).'" class="text-right border-top">
|
|
|
|
<b>'.tr('Sconto in fattura', [], ['upper' => true]).':</b>
|
|
|
|
</td>
|
|
|
|
<th colspan="'.($options['show-only-total'] ? (($has_image) ? 2 : 1) : (($has_image) ? 3 : 2)).'" class="text-right">
|
2023-12-06 10:06:36 +01:00
|
|
|
<b>'.moneyFormat($sconto_finale, $d_totali).'</b>
|
2023-11-14 10:48:04 +01:00
|
|
|
</th>
|
|
|
|
</tr>';
|
|
|
|
|
|
|
|
// NETTO A PAGARE
|
|
|
|
echo '
|
|
|
|
<tr>
|
|
|
|
<td colspan="'.($options['show-only-total'] ? 2 : 4).'" class="text-right border-top">
|
|
|
|
<b>'.tr('Netto a pagare', [], ['upper' => true]).':</b>
|
|
|
|
</td>
|
|
|
|
<th colspan="'.($options['show-only-total'] ? (($has_image) ? 2 : 1) : (($has_image) ? 3 : 2)).'" class="text-right">
|
2023-12-06 10:06:36 +01:00
|
|
|
<b>'.moneyFormat($netto_a_pagare, $d_totali).'</b>
|
2023-11-14 10:48:04 +01:00
|
|
|
</th>
|
|
|
|
</tr>';
|
|
|
|
}
|
2021-04-06 15:44:51 +02:00
|
|
|
}
|
2017-09-12 16:17:11 +02:00
|
|
|
}
|
|
|
|
|
2021-02-18 18:48:44 +01:00
|
|
|
echo '
|
2017-09-12 16:17:11 +02:00
|
|
|
</table>';
|
|
|
|
|
2023-11-14 10:48:04 +01:00
|
|
|
if ($options['no-iva']) {
|
2023-11-15 14:10:33 +01:00
|
|
|
echo '
|
2023-11-14 10:48:04 +01:00
|
|
|
<p colspan="3" class="text-right text-muted">
|
|
|
|
<small>Importo IVA esclusa</small>
|
|
|
|
</p>
|
|
|
|
';
|
|
|
|
}
|
|
|
|
|
2017-09-12 16:17:11 +02:00
|
|
|
// CONDIZIONI GENERALI DI FORNITURA
|
2020-06-16 13:03:54 +02:00
|
|
|
|
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>';
|
|
|
|
|
2020-07-07 18:07:56 +02:00
|
|
|
if (!empty($documento->validita) && !empty($documento->tipo_validita)) {
|
|
|
|
$intervallo = CarbonInterval::make($documento->validita.' '.$documento->tipo_validita);
|
|
|
|
|
|
|
|
echo $intervallo->forHumans();
|
|
|
|
} elseif (!empty($documento->validita)) {
|
|
|
|
echo tr('_TOT_ giorni', [
|
|
|
|
'_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>
|
2021-01-29 17:12:56 +01:00
|
|
|
|
|
|
|
<tr>
|
|
|
|
<th>
|
|
|
|
'.tr('Garanzia', [], ['upper' => true]).'
|
|
|
|
</th>
|
|
|
|
|
|
|
|
<td>
|
|
|
|
'.nl2br($documento['garanzia']).'
|
|
|
|
</td>
|
|
|
|
</tr>
|
2017-09-12 16:17:11 +02:00
|
|
|
</table>';
|
|
|
|
|
|
|
|
// Conclusione
|
|
|
|
echo '
|
|
|
|
<p class="text-center">'.tr("In attesa di un Vostro Cortese riscontro, colgo l'occasione per porgere Cordiali Saluti").'</p>';
|
2021-01-27 15:15:44 +01:00
|
|
|
|
2021-02-18 18:48:44 +01:00
|
|
|
if (!empty($documento->condizioni_fornitura)) {
|
2021-01-27 15:15:44 +01:00
|
|
|
echo '<pagebreak>'.$documento->condizioni_fornitura;
|
2021-02-18 18:48:44 +01:00
|
|
|
}
|