1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2024-12-27 08:12:47 +01:00
openstamanager/templates/interventi/body.php

437 lines
12 KiB
PHP
Raw Normal View History

<?php
include_once __DIR__.'/../../core.php';
/*
Dati intervento
*/
echo '
2017-09-08 18:19:39 +02:00
<table class="table table-bordered">
<tr>
<th colspan="4" style="font-size:13pt;" class="text-center">'.tr('Rapporto operazioni e interventi', [], ['upper' => true]).'</th>
2017-09-08 18:19:39 +02:00
</tr>
<tr>
2019-07-12 17:35:14 +02:00
<td class="text-left" style="width:30%">'.tr('Intervento num.').': <b>'.$documento['codice'].'</b></td>
<td class="text-left" style="width:20%">'.tr('Data').': <b>'.Translator::dateToLocale($documento['data_richiesta']).'</b></td>
<td class="text-left" style="width:25%">'.tr('Preventivo num.').': <b>'.(!empty($preventivo) ? $preventivo['numero'] : '').'</b></td>
<td class="text-left" style="width:25%">'.tr('Contratto num.').': <b>'.(!empty($contratto) ? $contratto['numero'] : '').'</b></td>
2017-09-08 18:19:39 +02:00
</tr>';
// Dati cliente
echo '
<tr>
<td colspan=2>
'.tr('Cliente').': <b>'.$c_ragionesociale.'</b>
</td>';
2017-09-08 18:19:39 +02:00
// Codice fiscale o P.Iva
2018-04-01 00:18:21 +02:00
if (!empty($c_piva)) {
2018-11-30 16:10:15 +01:00
echo '
2018-11-02 17:49:11 +01:00
<td colspan=2>
'.tr('P.Iva').': <b>'.strtoupper($c_piva).'</b>
</td>';
} else {
echo '
<td colspan=2>
'.tr('C.F.').': <b>'.strtoupper($c_codicefiscale).'</b>
2018-11-02 17:49:11 +01:00
</td>';
}
2018-11-30 16:10:15 +01:00
echo '</tr>';
//Indirizzo
if (!empty($c_indirizzo) or !empty($c_cap) or !empty($c_citta) or !empty($c_provincia)) {
echo '
2018-11-02 17:49:11 +01:00
<tr>
<td colspan="4">
'.((!empty($c_indirizzo)) ? tr('Via').': <b>'.$c_indirizzo.'</b>' : '').'
'.((!empty($c_cap)) ? tr('CAP').': <b>'.$c_cap.'</b>' : '').'
'.((!empty($c_citta)) ? tr('Città').': <b>'.$c_citta.'</b>' : '').'
'.((!empty($c_provincia)) ? tr('Provincia').': <b>'.strtoupper($c_provincia).'</b>' : '').'
</td>
</tr>';
2018-11-30 16:10:15 +01:00
}
echo '
<tr>
2017-09-08 18:19:39 +02:00
<td colspan="4">
'.tr('Telefono').': <b>'.$c_telefono.'</b>';
2018-11-30 16:10:15 +01:00
if (!empty($c_cellulare)) {
echo' - '.tr('Cellulare').': <b>'.$c_cellulare.'</b>';
}
2017-09-08 18:19:39 +02:00
echo '
</td>
</tr>';
// riga 3
// Elenco impianti su cui è stato fatto l'intervento
2017-09-21 15:51:39 +02:00
$rs2 = $dbo->fetchArray('SELECT *, (SELECT nome FROM my_impianti WHERE id=my_impianti_interventi.idimpianto) AS nome, (SELECT matricola FROM my_impianti WHERE id=my_impianti_interventi.idimpianto) AS matricola FROM my_impianti_interventi WHERE idintervento='.prepare($id_record));
2017-09-08 18:19:39 +02:00
$impianti = [];
for ($j = 0; $j < count($rs2); ++$j) {
2017-09-08 18:19:39 +02:00
$impianti[] = '<b>'.$rs2[$j]['nome']."</b> <small style='color:#777;'>(".$rs2[$j]['matricola'].')</small>';
}
echo '
<tr>
2017-09-08 18:19:39 +02:00
<td colspan="4">
'.tr('Impianti').': '.implode(', ', $impianti).'
2017-09-08 18:19:39 +02:00
</td>
</tr>';
2018-01-19 22:10:37 +01:00
// Tipo intervento
echo '
<tr>
<td colspan="4">
2020-01-03 16:45:44 +01:00
<b>'.tr('Tipo intervento').':</b> '.$documento->tipo->descrizione.'
2018-01-19 22:10:37 +01:00
</td>
</tr>';
// Richiesta
echo '
2017-09-08 18:19:39 +02:00
<tr>
<td colspan="4" style="height:20mm;">
<b>'.tr('Richiesta').':</b>
2019-07-12 17:35:14 +02:00
<p>'.nl2br($documento['richiesta']).'</p>
2017-09-08 18:19:39 +02:00
</td>
</tr>';
// Descrizione
echo '
<tr>
<td colspan="4" style="height:20mm;">
<b>'.tr('Descrizione').':</b>
2019-07-12 17:35:14 +02:00
<p>'.nl2br($documento['descrizione']).'</p>
</td>
</tr>';
echo '
</table>';
2019-07-12 17:35:14 +02:00
$righe = $documento->getRighe();
2019-07-12 17:35:14 +02:00
if (!$righe->isEmpty()) {
echo '
<table class="table table-bordered">
<thead>
<tr>
<th colspan="4" class="text-center">
2019-07-12 17:35:14 +02:00
<b>'.tr('Materiale utilizzato e spese aggiuntive', [], ['upper' => true]).'</b>
</th>
</tr>
<tr>
<th style="font-size:8pt;width:50%" class="text-center">
<b>'.tr('Descrizione').'</b>
</th>
<th style="font-size:8pt;width:15%" class="text-center">
<b>'.tr('Q.').'</b>
</th>
<th style="font-size:8pt;width:15%" class="text-center">
<b>'.tr('Prezzo unitario').'</b>
</th>
<th style="font-size:8pt;width:20%" class="text-center">
2019-07-12 17:35:14 +02:00
<b>'.tr('Imponibile').'</b>
</th>
</tr>
</thead>
<tbody>';
2019-07-12 17:35:14 +02:00
foreach ($righe as $riga) {
$r = $riga->toArray();
// Articolo
echo '
<tr>
<td>
2019-07-12 17:35:14 +02:00
'.nl2br($r['descrizione']);
if ($riga->isArticolo()) {
// Codice articolo
$text = tr('COD. _COD_', [
'_COD_' => $riga->articolo->codice,
]);
echo '
<br><small>'.$text.'</small>';
// Seriali
$seriali = $riga->serials;
if (!empty($seriali)) {
$text = tr('SN').': '.implode(', ', $seriali);
echo '
<br><small>'.$text.'</small>';
}
}
echo '
</td>';
// Quantità
echo '
<td class="text-center">
'.Translator::numberToLocale($r['qta'], 'qta').' '.$r['um'].'
</td>';
// Prezzo unitario
echo '
<td class="text-center">
2019-07-12 17:35:14 +02:00
'.($options['pricing'] ? moneyFormat($riga->prezzo_unitario_vendita) : '-');
2018-12-29 11:42:53 +01:00
if ($options['pricing'] && $r['sconto'] > 0) {
echo "
<br><small class='text-muted'>".tr('sconto _TOT_ _TYPE_', [
'_TOT_' => Translator::numberToLocale($r['sconto_unitario']),
'_TYPE_' => ($r['tipo_sconto'] == 'PRC' ? '%' : currency()),
2018-12-29 11:42:53 +01:00
]).'</small>';
}
echo '
</td>';
// Prezzo totale
echo '
<td class="text-center">
2019-07-12 17:35:14 +02:00
'.($options['pricing'] ? Translator::numberToLocale($riga->totale_imponibile) : '-').'
</td>
</tr>';
}
2019-07-12 17:35:14 +02:00
echo '
</tbody>';
2017-09-21 15:51:39 +02:00
if ($options['pricing']) {
// Totale spese aggiuntive
echo '
<tr>
<td colspan="3" class="text-right">
2019-07-12 17:35:14 +02:00
<b>'.tr('Totale', [], ['upper' => true]).':</b>
</td>
<th class="text-center">
2019-07-12 17:35:14 +02:00
<b>'.moneyFormat($righe->sum('totale_imponibile'), 2).'</b>
</th>
</tr>';
}
echo '
</table>';
}
// INTESTAZIONE ELENCO TECNICI
echo '
2017-09-12 16:45:18 +02:00
<table class="table table-bordered vertical-middle">
<thead>
<tr>
<th class="text-center" colspan="5" style="font-size:11pt;">
<b>'.tr('Ore tecnici', [], ['upper' => true]).'</b>
</th>
</tr>
<tr>
2018-01-23 16:11:02 +01:00
<th class="text-center" style="font-size:8pt;">
<b>'.tr('Tecnico').'</b>
</th>
2018-01-23 16:11:02 +01:00
<th class="text-center" style="font-size:8pt;width:14%">
<b>'.tr('Data').'</b>
</th>
2018-01-23 16:11:02 +01:00
<th class="text-center" style="font-size:8pt;width:7%">
<b>'.tr('Dalle').'</b>
</th>
2018-01-23 16:11:02 +01:00
<th class="text-center" style="font-size:8pt;width:7%">
<b>'.tr('Alle').'</b>
</th>
<td class="text-center" style="font-size:6pt;width:35%">
'.tr('I dati del ricevente verrano trattati in base alla normativa europea UE 2016/679 del 27 aprile 2016 (GDPR)').'
</td>
</tr>
</thead>
<tbody>';
// Sessioni di lavoro dei tecnici
2019-07-12 17:35:14 +02:00
$sessioni = $documento->sessioni;
foreach ($sessioni as $i => $sessione) {
echo '
<tr>';
2019-07-12 17:35:14 +02:00
// Nome tecnico
echo '
2017-09-12 16:45:18 +02:00
<td>
2019-07-12 17:35:14 +02:00
'.$sessione->anagrafica->ragione_sociale.'
</td>';
2019-07-12 17:35:14 +02:00
// Data
echo '
2017-09-12 16:45:18 +02:00
<td class="text-center">
2019-07-12 17:35:14 +02:00
'.Translator::dateToLocale($sessione['orario_inizio'], '-').'
</td>';
2019-07-12 17:35:14 +02:00
// Ora inizio
echo '
2017-09-12 16:45:18 +02:00
<td class="text-center">
2019-07-12 17:35:14 +02:00
'.Translator::timeToLocale($sessione['orario_inizio'], '-').'
</td>';
2019-07-12 17:35:14 +02:00
// Ora fine
echo '
2017-09-12 16:45:18 +02:00
<td class="text-center">
2019-07-12 17:35:14 +02:00
'.Translator::timeToLocale($sessione['orario_fine'], '-').'
</td>';
// Spazio aggiuntivo
if ($i == 0) {
echo '
<td class="text-center" style="font-size:8pt;">
'.tr('Si dichiara che i lavori sono stati eseguiti ed i materiali installati').'
</td>';
} else {
echo '
<td class="text-center" style="border-bottom:0px;border-top:0px;"></td>';
}
echo '
</tr>';
}
// Ore lavorate
2018-01-23 16:11:02 +01:00
echo '
<tr>
2017-09-12 16:45:18 +02:00
<td class="text-center">
2019-07-15 11:16:12 +02:00
<small>'.tr('Ore lavorate').':</small><br/><b>'.Translator::numberToLocale($documento->ore_totali, 2).'</b>
</td>';
2018-01-23 16:11:02 +01:00
// Costo totale manodopera
2018-02-03 13:55:09 +01:00
if ($options['pricing']) {
echo '
2018-01-23 16:11:02 +01:00
<td colspan="3" class="text-center">
2019-07-12 17:35:14 +02:00
<small>'.tr('Totale manodopera').':</small><br/><b>'.moneyFormat($sessioni->sum('prezzo_manodopera'), 2).'</b>
</td>';
} else {
echo '
2018-01-23 16:11:02 +01:00
<td colspan="3" class="text-center">-</td>';
}
// Timbro e firma
2019-07-12 17:35:14 +02:00
$firma = !empty($documento['firma_file']) ? '<img src="'.DOCROOT.'/files/interventi/'.$documento['firma_file'].'" style="width:70mm;">' : '';
echo '
2018-01-19 22:10:37 +01:00
<td rowspan="2" class="text-center" style="font-size:8pt;height:30mm;vertical-align:bottom">
'.$firma.'<br>
<i>('.tr('Timbro e firma leggibile').'.)</i>
</td>
</tr>';
2018-01-19 22:10:37 +01:00
// Totale km
echo '
2018-01-23 16:11:02 +01:00
<tr>
2018-01-19 22:10:37 +01:00
<td class="text-center">
2019-07-15 11:16:12 +02:00
<small>'.tr('Km percorsi').':</small><br/><b>'.Translator::numberToLocale($documento->km_totali, 2).'</b>
2018-01-19 22:10:37 +01:00
</td>';
2018-01-23 16:11:02 +01:00
// Costo trasferta
2018-02-03 13:55:09 +01:00
if ($options['pricing']) {
2018-01-19 22:10:37 +01:00
echo '
<td class="text-center">
2019-07-12 17:35:14 +02:00
<small>'.tr('Costi di trasferta').':</small><br/><b>'.moneyFormat($sessioni->sum('prezzo_viaggio'), 2).'</b>
2018-01-19 22:10:37 +01:00
</td>';
2018-01-23 16:11:02 +01:00
} else {
2018-01-19 22:10:37 +01:00
echo '
2018-01-23 16:11:02 +01:00
<td class="text-center">-</td>';
}
2018-01-19 22:10:37 +01:00
2018-01-23 16:11:02 +01:00
// Diritto di chiamata
2018-02-03 13:55:09 +01:00
if ($options['pricing']) {
2018-01-23 16:11:02 +01:00
echo '
<td class="text-center" colspan="2">
2019-07-12 17:35:14 +02:00
<small>'.tr('Diritto di chiamata').':</small><br/><b>'.moneyFormat($sessioni->sum('prezzo_diritto_chiamata'), 2).'</b>
2018-01-23 16:11:02 +01:00
</td>';
2018-01-19 22:10:37 +01:00
} else {
echo '
2019-07-12 17:35:14 +02:00
<td class="text-center" colspan="2">-</td>';
2018-01-19 22:10:37 +01:00
}
2019-07-12 17:35:14 +02:00
// Calcoli
$imponibile = abs($documento->imponibile);
$sconto = $documento->sconto;
$totale_imponibile = abs($documento->totale_imponibile);
$totale_iva = abs($documento->iva);
$totale = abs($documento->totale);
$netto_a_pagare = abs($documento->netto);
$show_sconto = $sconto > 0;
// TOTALE COSTI FINALI
2017-09-21 15:51:39 +02:00
if ($options['pricing']) {
// Totale imponibile
echo '
<tr>
<td colspan="4" class="text-right">
<b>'.tr('Imponibile', [], ['upper' => true]).':</b>
</td>
<th class="text-center">
2019-07-12 17:35:14 +02:00
'.moneyFormat($show_sconto ? $imponibile : $totale_imponibile, 2).'
</th>
</tr>';
2018-06-29 13:35:39 +02:00
2018-01-19 22:10:37 +01:00
// Eventuale sconto totale
2019-07-12 17:35:14 +02:00
if ($show_sconto) {
echo '
2018-01-19 22:10:37 +01:00
<tr>
<td colspan="4" class="text-right">
<b>'.tr('Sconto', [], ['upper' => true]).':</b>
</td>
2018-01-19 22:10:37 +01:00
<th class="text-center">
2019-07-12 17:35:14 +02:00
<b>'.moneyFormat($sconto, 2).'</b>
2018-01-19 22:10:37 +01:00
</th>
</tr>';
2019-07-11 17:44:42 +02:00
// Totale imponibile
echo '
2018-01-19 22:38:11 +01:00
<tr>
<td colspan="4" class="text-right">
2019-07-11 17:44:42 +02:00
<b>'.tr('Totale imponibile', [], ['upper' => true]).':</b>
2018-01-19 22:38:11 +01:00
</td>
2018-01-19 22:38:11 +01:00
<th class="text-center">
2019-07-12 17:35:14 +02:00
<b>'.moneyFormat($totale_imponibile, 2).'</b>
2018-01-19 22:38:11 +01:00
</th>
</tr>';
}
// IVA
// Totale intervento
echo '
<tr>
<td colspan="4" class="text-right">
2018-09-05 15:00:19 +02:00
<b>'.tr('Iva', [], ['upper' => true]).':</b>
</td>
<th class="text-center">
2019-07-12 17:35:14 +02:00
<b>'.moneyFormat($totale_iva, 2).'</b>
</th>
</tr>';
// TOTALE INTERVENTO
echo '
<tr>
<td colspan="4" class="text-right">
<b>'.tr('Totale intervento', [], ['upper' => true]).':</b>
</td>
<th class="text-center">
2019-07-12 17:35:14 +02:00
<b>'.moneyFormat($totale, 2).'</b>
</th>
</tr>';
}
echo '
</table>';