2017-09-12 17:46:19 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
include_once __DIR__.'/../../core.php';
|
|
|
|
|
2018-03-02 20:34:32 +01:00
|
|
|
$report_name = 'contratto_'.$records[0]['numero'].'.pdf';
|
2017-09-12 17:46:19 +02:00
|
|
|
|
|
|
|
$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' => 10, // Numero di righe massimo da aggiungere
|
|
|
|
'columns' => 4, // Numero di colonne della tabella
|
|
|
|
];
|
|
|
|
|
|
|
|
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('Contratto num. _NUM_ del _DATE_', [
|
2017-09-12 17:46:19 +02:00
|
|
|
'_NUM_' => $records[0]['numero'],
|
|
|
|
'_DATE_' => Translator::dateToLocale($records[0]['data_bozza']),
|
|
|
|
], ['upper' => true]).'</b>
|
2018-07-17 11:15:31 +02:00
|
|
|
</div>';
|
|
|
|
|
|
|
|
// Elenco impianti
|
|
|
|
if (!empty($records[0]['idimpianti'])) {
|
|
|
|
$impianti = $dbo->fetchArray('SELECT nome, matricola FROM my_impianti WHERE id IN ('.$records[0]['idimpianti'].')');
|
|
|
|
|
|
|
|
$list = [];
|
|
|
|
foreach ($impianti as $impianto) {
|
|
|
|
$list[] = $impianto['nome']." <span style='color:#777;'>(".$impianto['matricola'].')</span>';
|
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
|
|
|
<br>
|
|
|
|
<p class="small-bold">'.tr('Impianti', [], ['upper' => true]).'</p>
|
|
|
|
<p><small>'.implode(', ', $list).'</small></p>';
|
|
|
|
}
|
|
|
|
echo '
|
2017-09-12 17:46:19 +02:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="col-xs-5 col-xs-offset-1">
|
|
|
|
<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>
|
|
|
|
<p>$c_indirizzo$ $c_citta_full$</p>
|
|
|
|
</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
|
2018-03-27 16:56:33 +02:00
|
|
|
if (!empty($records[0]['desc_contratto'])) {
|
2017-09-12 17:46:19 +02:00
|
|
|
echo '
|
2018-03-27 16:56:33 +02:00
|
|
|
<p>'.nl2br($records[0]['desc_contratto']).'</p>
|
2017-09-12 17:46:19 +02:00
|
|
|
<br>';
|
|
|
|
}
|
|
|
|
|
|
|
|
$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:20%'>".tr('Prezzo unitario', [], ['upper' => true])."</th>
|
|
|
|
<th class='text-center' style='width:20%'>".tr('Imponibile', [], ['upper' => true]).'</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
|
|
|
|
<tbody>';
|
|
|
|
|
|
|
|
// RIGHE PREVENTIVO CON ORDINAMENTO UNICO
|
2018-06-29 17:30:41 +02:00
|
|
|
$righe = $dbo->fetchArray('SELECT * FROM co_righe_contratti WHERE idcontratto='.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']);
|
|
|
|
|
|
|
|
if (!empty($r['codice_articolo'])) {
|
|
|
|
echo '
|
|
|
|
<br><small>'.tr('COD. _COD_', [
|
|
|
|
'_COD_' => $r['codice_articolo'],
|
|
|
|
]).'</small>';
|
|
|
|
|
|
|
|
if ($count <= 1) {
|
|
|
|
$count += 0.4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
|
|
|
</td>';
|
|
|
|
|
|
|
|
echo "
|
2018-01-18 19:03:06 +01:00
|
|
|
<td class='text-center'>";
|
2018-02-17 09:02:19 +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-17 09:02:19 +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
|
|
|
}
|
|
|
|
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-17 09:02:19 +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 '
|
|
|
|
<br><small class="help-block">- '.tr('sconto _TOT_ _TYPE_', [
|
|
|
|
'_TOT_' => Translator::numberToLocale($r['sconto_unitario']),
|
|
|
|
'_TYPE_' => ($r['tipo_sconto'] == 'PRC' ? '%' : '€'),
|
|
|
|
]).'</small>';
|
|
|
|
|
|
|
|
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>';
|
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
|
|
|
</tr>';
|
|
|
|
|
|
|
|
$autofill['count'] += $count;
|
|
|
|
|
|
|
|
$sconto[] = $r['sconto'];
|
|
|
|
$imponibile[] = $r['subtotale'];
|
|
|
|
}
|
|
|
|
|
|
|
|
$sconto = sum($sconto);
|
|
|
|
$imponibile = sum($imponibile);
|
|
|
|
|
|
|
|
$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
|
|
|
// Eventuale sconto incondizionato
|
|
|
|
if (!empty($sconto)) {
|
|
|
|
// Totale imponibile
|
|
|
|
echo '
|
|
|
|
<tr>
|
|
|
|
<td colspan="3" class="text-right border-top">
|
|
|
|
<b>'.tr('Imponibile', [], ['upper' => true]).':</b>
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<th 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>';
|
|
|
|
|
|
|
|
echo '
|
|
|
|
<tr>
|
|
|
|
<td colspan="3" class="text-right border-top">
|
|
|
|
<b>'.tr('Sconto', [], ['upper' => true]).':</b>
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<th 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>';
|
|
|
|
}
|
|
|
|
|
|
|
|
// TOTALE
|
|
|
|
echo '
|
|
|
|
<tr>
|
|
|
|
<td colspan="3" class="text-right border-top">
|
|
|
|
<b>'.tr('Quotazione totale', [], ['upper' => true]).':</b>
|
|
|
|
</td>
|
|
|
|
<th 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>';
|
|
|
|
}
|
|
|
|
echo'
|
|
|
|
</table>';
|
|
|
|
|
|
|
|
// CONDIZIONI GENERALI DI FORNITURA
|
|
|
|
|
|
|
|
// Lettura pagamenti
|
|
|
|
$rs = $dbo->fetchArray('SELECT * FROM co_pagamenti WHERE id = '.$records[0]['idpagamento']);
|
|
|
|
$pagamento = $rs[0]['descrizione'];
|
|
|
|
|
|
|
|
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 17:46:19 +02:00
|
|
|
'.tr('Condizioni generali di fornitura', [], ['upper' => true]).'
|
|
|
|
</th>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
<th style="width:25%">
|
|
|
|
'.tr('Pagamento', [], ['upper' => true]).'
|
|
|
|
</th>
|
|
|
|
|
|
|
|
<td>
|
|
|
|
'.$pagamento.'
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
<th>
|
|
|
|
'.tr('Validità offerta', [], ['upper' => true]).'
|
|
|
|
</th>
|
|
|
|
|
2017-09-13 13:05:35 +02:00
|
|
|
<td>';
|
|
|
|
|
|
|
|
if (!empty($records[0]['validita'])) {
|
|
|
|
echo'
|
2017-09-12 17:46:19 +02:00
|
|
|
'.tr('_TOT_ giorni', [
|
|
|
|
'_TOT_' => $records[0]['validita'],
|
2017-09-13 13:05:35 +02:00
|
|
|
]);
|
|
|
|
} else {
|
|
|
|
echo '-';
|
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
2017-09-12 17:46:19 +02:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
<th>
|
|
|
|
'.tr('Validità contratto', [], ['upper' => true]).'
|
|
|
|
</th>
|
|
|
|
|
2017-09-13 13:05:35 +02:00
|
|
|
<td>';
|
|
|
|
|
|
|
|
if (!empty($records[0]['data_accettazione']) && !empty($records[0]['data_conclusione'])) {
|
|
|
|
echo '
|
2017-09-12 17:46:19 +02:00
|
|
|
'.tr('dal _START_ al _END_', [
|
|
|
|
'_START_' => Translator::dateToLocale($records[0]['data_accettazione']),
|
|
|
|
'_END_' => Translator::dateToLocale($records[0]['data_conclusione']),
|
2017-09-13 13:05:35 +02:00
|
|
|
]);
|
|
|
|
} else {
|
|
|
|
echo '-';
|
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
2017-09-12 17:46:19 +02:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
<th>
|
|
|
|
'.tr('Esclusioni', [], ['upper' => true]).'
|
|
|
|
</th>
|
|
|
|
|
|
|
|
<td>
|
|
|
|
'.nl2br($records[0]['esclusioni']).'
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</table>';
|
|
|
|
|
|
|
|
// Conclusione
|
2018-07-17 11:15:31 +02:00
|
|
|
if (empty($records[0]['fatturabile'])) {
|
|
|
|
echo '
|
2017-09-12 17:46:19 +02:00
|
|
|
<p class="text-center"><b>'.tr('Il tutto S.E. & O.').'</b></p>
|
|
|
|
<p class="text-center">'.tr("In attesa di un Vostro Cortese riscontro, colgo l'occasione per porgere Cordiali Saluti").'</p>';
|
2018-07-17 11:15:31 +02:00
|
|
|
}
|
2018-02-20 12:05:10 +01:00
|
|
|
|
2018-07-17 11:15:31 +02:00
|
|
|
// Firma
|
|
|
|
echo '<div style="position:absolute; bottom:'.($settings['margins']['bottom'] + $settings['footer-height']).'px">
|
|
|
|
<table>
|
2018-02-20 12:05:10 +01:00
|
|
|
<tr>
|
|
|
|
<td style="vertical-align:bottom;" width="50%">
|
|
|
|
lì, ___________________________
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<td align="center" style="vertical-align:bottom;" width="50%">
|
|
|
|
FIRMA PER ACCETTAZIONE<br><br>
|
2018-02-20 16:42:59 +01:00
|
|
|
_____________________________________________
|
2018-02-20 12:05:10 +01:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
<br></div>';
|