Skip to content

Commit 28429dd

Browse files
committed
refactor: miglioria grafica stampa riepilogo intervento con tabelle di riepilogo sessioni e materiale utilizzato
1 parent f34856d commit 28429dd

3 files changed

Lines changed: 184 additions & 32 deletions

File tree

templates/riepilogo_interventi/bottom.php

Lines changed: 99 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@
3737
}
3838

3939
echo '
40-
<tr>
41-
<th width="5%" style="border-right: 0"></th>
42-
<th class="text-right text-muted" style="border-left: 0;">
40+
<tr style="background-color: #eee;">
41+
<th width="5%" class="border-end-0"></th>
42+
<th class="text-right text-muted border-start-0">
4343
<b>'.tr('Totale', [], ['upper' => true]).':</b>
4444
</th>
4545
<th class="text-center">'.$somma_km.'</td>
@@ -49,22 +49,112 @@
4949
<th class="text-center">'.($pricing ? moneyFormat($somma_totale_imponibile, $d_totali) : '-').'</th>
5050
</tr>
5151
52-
<tr>
53-
<th width="5%" style="border-right: 0"></th>
54-
<th class="text-right text-muted" style="border-left: 0;">
52+
<tr style="background-color: #eee;">
53+
<th width="5%" class="border-end-0"></th>
54+
<th class="text-right text-muted border-start-0">
5555
<b>'.tr('Iva', [], ['upper' => true]).':</b>
5656
</th>
5757
<th colspan="4"></th>
5858
<th class="text-center">'.($pricing ? moneyFormat($somma_iva, $d_totali) : '-').'</th>
5959
</tr>
6060
61-
<tr>
62-
<th width="5%" style="border-right: 0"></th>
63-
<th class="text-right text-muted" style="border-left: 0;">
61+
<tr style="background-color: #eee;">
62+
<th width="5%" class="border-end-0"></th>
63+
<th class="text-right text-muted border-start-0">
6464
<b>'.tr('Totale Ivato', [], ['upper' => true]).':</b>
6565
</th>
6666
<th colspan="4"></th>
6767
<th class="text-center">'.($pricing ? moneyFormat($somma_totale_ivato, $d_totali) : '-').'</th>
6868
</tr>
6969
</tbody>
7070
</table>';
71+
72+
// Sezione riepilogativa materiali e sessioni
73+
if (!empty($riepilogo_materiali) || !empty($riepilogo_sessioni)) {
74+
echo '
75+
<div class="mt-5">
76+
<div class="row">';
77+
78+
// Riepilogo materiali
79+
if (!empty($riepilogo_materiali)) {
80+
echo '
81+
<div class="col-md-6 mb-4">
82+
<div class="card">
83+
<div class="card-header">
84+
<h6 class="text-center"><b>'.tr('Riepilogo materiale utilizzato', [], ['upper' => true]).'</b></h6>
85+
</div>
86+
<div class="card-body p-0">
87+
<table class="table table-sm table-bordered mb-0">
88+
<thead>
89+
<tr>
90+
<th class="small-bold">'.tr('Descrizione').'</th>
91+
<th class="text-center small-bold">'.tr('Qta').'</th>
92+
<th class="text-center small-bold">'.tr('Prezzo unitario').'</th>
93+
<th class="text-center small-bold">'.tr('Totale').'</th>
94+
</tr>
95+
</thead>
96+
<tbody>';
97+
98+
foreach ($riepilogo_materiali as $descrizione => $dati) {
99+
echo '
100+
<tr>
101+
<td>'.$descrizione.'</td>
102+
<td class="text-center">'.Translator::numberToLocale($dati['qta'], $d_qta).' '.$dati['um'].'</td>
103+
<td class="text-center">'.($pricing ? moneyFormat($dati['prezzo'], $d_importi) : '-').'</td>
104+
<td class="text-center fw-bold">'.($pricing ? moneyFormat($dati['totale'], $d_importi) : '-').'</td>
105+
</tr>';
106+
}
107+
108+
echo '
109+
</tbody>
110+
</table>
111+
</div>
112+
</div>
113+
</div>';
114+
}
115+
116+
// Riepilogo sessioni per tipo di attività
117+
if (!empty($riepilogo_sessioni)) {
118+
echo '
119+
<div class="col-md-6 mb-4">
120+
<div class="card">
121+
<div class="card-header bg-secondary text-white">
122+
<h6 class="text-center"><b>'.tr('Riepilogo ore per tipo di attività', [], ['upper' => true]).'</b></h6>
123+
</div>
124+
<div class="card-body p-0">
125+
<table class="table table-sm table-bordered mb-0">
126+
<thead>
127+
<tr>
128+
<th class="small-bold">'.tr('Tipo attività').'</th>
129+
<th class="text-center small-bold">'.tr('Ore totali').'</th>
130+
<th class="text-center small-bold">'.tr('Prezzo totale').'</th>
131+
</tr>
132+
</thead>
133+
<tbody>';
134+
135+
foreach ($riepilogo_sessioni as $tipo => $dati) {
136+
if (setting('Formato ore in stampa') == 'Sessantesimi') {
137+
$ore_formatted = Translator::numberToHours($dati['ore']);
138+
} else {
139+
$ore_formatted = Translator::numberToLocale($dati['ore'], $d_qta);
140+
}
141+
echo '
142+
<tr>
143+
<td>'.$tipo.'</td>
144+
<td class="text-center">'.$ore_formatted.'</td>
145+
<td class="text-center fw-bold">'.($pricing ? moneyFormat($dati['prezzo_totale'], $d_importi) : '-').'</td>
146+
</tr>';
147+
}
148+
149+
echo '
150+
</tbody>
151+
</table>
152+
</div>
153+
</div>
154+
</div>';
155+
}
156+
157+
echo '
158+
</div>
159+
</div>';
160+
}

templates/riepilogo_interventi/piece.php

Lines changed: 84 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,59 @@
6666
$somma_iva[] = $iva;
6767
$somma_totale_ivato[] = $totale_ivato;
6868

69+
// Raccogli dati riepilogativi per materiali
70+
$righe = $intervento->getRighe();
71+
foreach ($righe as $riga) {
72+
$descrizione = $riga->descrizione;
73+
$qta = $riga->qta;
74+
$um = $riga->um;
75+
$prezzo = $tipo == 'interno' ? $riga->costo_unitario : $riga->prezzo_unitario;
76+
$totale = $tipo == 'interno' ? $riga->spesa : $riga->totale_imponibile;
77+
78+
if (!isset($riepilogo_materiali[$descrizione])) {
79+
$riepilogo_materiali[$descrizione] = [
80+
'qta' => 0,
81+
'um' => $um,
82+
'prezzo' => $prezzo,
83+
'totale' => 0,
84+
];
85+
}
86+
87+
$riepilogo_materiali[$descrizione]['qta'] += $qta;
88+
$riepilogo_materiali[$descrizione]['totale'] += $totale;
89+
}
90+
91+
// Raccogli dati riepilogativi per sessioni (ore per tipo di attività)
92+
foreach ($sessioni as $sessione) {
93+
$tipo_attivita = $sessione->tipo->getTranslation('title');
94+
$ore_sessione = $sessione->ore;
95+
$prezzo_ore = $tipo == 'interno' ? $sessione->costo_ore_unitario : $sessione->prezzo_ore_unitario;
96+
$prezzo_totale = $ore_sessione * $prezzo_ore;
97+
98+
if (!isset($riepilogo_sessioni[$tipo_attivita])) {
99+
$riepilogo_sessioni[$tipo_attivita] = [
100+
'ore' => 0,
101+
'prezzo_totale' => 0,
102+
];
103+
}
104+
105+
$riepilogo_sessioni[$tipo_attivita]['ore'] += $ore_sessione;
106+
$riepilogo_sessioni[$tipo_attivita]['prezzo_totale'] += $prezzo_totale;
107+
}
108+
69109
$pricing ??= true;
70110

71111
// Informazioni intervento
72112
echo '
73113
<tr>
74-
<td colspan="2">';
114+
<td style="border-top: 1px solid #ddd;" colspan="7">';
75115

76116
if (dateFormat($intervento->inizio)) {
77117
echo '
78-
<p>'.tr('Intervento _NUM_ del _DATE_', [
118+
<p><strong>'.tr('Intervento _NUM_ del _DATE_', [
79119
'_NUM_' => $intervento->codice,
80120
'_DATE_' => dateFormat($intervento->inizio),
81-
]).'</p>';
121+
]).'</strong></p>';
82122
} else {
83123
echo '
84124
<p>'.tr('Promemoria _NUM_', [
@@ -87,35 +127,40 @@
87127
}
88128

89129
echo '
90-
<p><small><b>'.tr('Cliente').':</b> '.$intervento->anagrafica->ragione_sociale.($nomesede ? ' ('.$nomesede.')' : '').'</small></p>
91-
<p><small><b>'.tr('Indirizzo').':</b> '.$indirizzo.' '.$cap.' - '.$citta.' ('.strtoupper((string) $provincia).')</small></p>
92-
<p><small><b>'.tr('Stato').':</b> '.$intervento->stato->getTranslation('title').'</small></p>
93-
<p><small><b>'.tr('Data richiesta').':</b> '.dateFormat($intervento->data_richiesta).'</small></p>
94-
<p><small><b>'.tr('Richiesta').':</b> '.strip_tags((string) $intervento->richiesta).'</p>';
130+
<table style="width: 100%;">
131+
<tr>
132+
<td style="width: 50%; padding: 2px 0;">'.$intervento->anagrafica->ragione_sociale.($nomesede ? ' ('.$nomesede.')' : '').'</td>
133+
<td style="width: 50%; padding: 2px 0;">'.$indirizzo.' '.$cap.' - '.$citta.' ('.strtoupper((string) $provincia).')</td>
134+
</tr>
135+
<tr>
136+
<td style="width: 50%; padding: 2px 0;">'.$intervento->stato->getTranslation('title').'</td>
137+
<td style="width: 50%; padding: 2px 0;">'.tr('Data richiesta').': '.dateFormat($intervento->data_richiesta).'</td>
138+
</tr>
139+
<tr>
140+
<td colspan="2" style="padding: 2px 0; border-bottom: 1px solid #ddd; border-top: 1px solid #ddd;"><b>'.tr('Richiesta').':</b> '.strip_tags((string) $intervento->richiesta).'</td>';
95141
if ($intervento->descrizione) {
96142
echo '
97-
<p><b>'.tr('Descrizione').':</b> '.$intervento->descrizione.'</small></p>';
143+
</tr>
144+
<tr>
145+
<td colspan="2" style="padding: 2px 0; border-bottom: 1px solid #ddd;"><b>'.tr('Descrizione').':</b> '.$intervento->descrizione.'</td>
146+
</tr>';
98147
}
148+
echo '
149+
</tr>
150+
</table>';
99151

100152
if (setting('Formato ore in stampa') == 'Sessantesimi') {
101153
$ore = Translator::numberToHours($ore);
102154
} else {
103155
$ore = Translator::numberToLocale($ore, $d_qta);
104156
}
105-
echo '
106-
</td>
107-
<td class="text-center">'.($pricing ? $km : '-').'</td>
108-
<td class="text-center">'.($pricing ? $ore : '-').'</td>
109-
<td class="text-center">'.($pricing ? moneyFormat($imponibile, $d_importi) : '-').'</td>
110-
<td class="text-center">'.($pricing && empty($options['dir']) ? moneyFormat($sconto, $d_importi) : '-').'</td>
111-
<td class="text-center">'.($pricing ? moneyFormat($totale_imponibile, $d_importi) : '-').'</td>
112-
</tr>';
157+
113158

114159
// Sessioni
115160
if (count($sessioni) > 0) {
116161
echo '
117162
<tr>
118-
<td style="border-top: 0; border-bottom: 0;"></td>
163+
<th></th>
119164
<th style="background-color: #eee" colspan="'.(get('id_print') != 24 ? 3 : 2).'"><small>'.tr('Sessioni').'</small></th>
120165
<th class="text-center" style="background-color: #eee"><small>'.tr('Data').'</small></th>
121166
<th class="text-center" style="background-color: #eee"><small>'.tr('Inizio').'</small></th>
@@ -125,8 +170,8 @@
125170
foreach ($sessioni as $sessione) {
126171
echo '
127172
<tr>
128-
<td style="border-top: 0; border-bottom: 0;"></td>
129-
<td colspan="'.(get('id_print') != 24 ? 3 : 2).'"><small>'.$sessione->anagrafica->ragione_sociale.' <small>('.$sessione->tipo->getTranslation('title').')</small></td>
173+
<td></td>
174+
<td colspan="'.(get('id_print') != 24 ? 3 : 2).'"><small>'.$sessione->anagrafica->ragione_sociale.' ('.$sessione->tipo->getTranslation('title').')</small></td>
130175
<td class="text-center"><small>'.dateFormat($sessione->orario_inizio).'</small></td>
131176
<td class="text-center"><small>'.timeFormat($sessione->orario_inizio).'</small></td>
132177
<td class="text-center"><small>'.timeFormat($sessione->orario_fine).'</small></td>
@@ -139,7 +184,7 @@
139184
if (!$righe->isEmpty()) {
140185
echo '
141186
<tr>
142-
<td style="border-top: 0; border-bottom: 0;"></td>
187+
<td></td>
143188
<th style="background-color: #eee" colspan="'.(get('id_print') != 24 ? 3 : 2).'"><small>'.tr('Materiale utilizzato e spese aggiuntive').'</small></th>
144189
<th class="text-center" style="background-color: #eee"><small>'.tr('Qta').'</small></th>
145190
<th class="text-center" style="background-color: #eee"><small>'.($tipo == 'interno' ? tr('Costo unitario') : tr('Prezzo unitario')).'</small></th>
@@ -152,11 +197,28 @@
152197

153198
echo '
154199
<tr>
155-
<td style="border-top: 0; border-bottom: 0;"></td>
200+
<td></td>
156201
<td colspan="'.(get('id_print') != 24 ? 3 : 2).'"><small>'.$riga->descrizione.'</small></td>
157202
<td class="text-center"><small>'.$riga->qta.' '.$riga->um.'</small></td>
158203
<td class="text-center"><small>'.($pricing ? moneyFormat($prezzo, $d_importi) : '-').'</small></td>
159204
<td class="text-center"><small>'.($pricing ? moneyFormat($totale, $d_importi) : '-').'</small></td>
160205
</tr>';
161206
}
207+
208+
// Riga di riepilogo con i valori dell'intervento
209+
echo '
210+
<tr>
211+
<td colspan="2" class="text-muted" style="border-top: 1px solid #ddd;">'.tr('Totale intervento', [], ['upper' => true]).':</td>
212+
<td class="text-center" style="border-top: 1px solid #ddd;">'.($pricing ? $km : '-').'</td>
213+
<td class="text-center" style="border-top: 1px solid #ddd;">'.($pricing ? $ore : '-').'</td>
214+
<td class="text-center" style="border-top: 1px solid #ddd;">'.($pricing ? moneyFormat($imponibile, $d_importi) : '-').'</td>
215+
<td class="text-center" style="border-top: 1px solid #ddd;">'.($pricing && empty($options['dir']) ? moneyFormat($sconto, $d_importi) : '-').'</td>
216+
<td class="text-center" style="border-top: 1px solid #ddd;"><b>'.($pricing ? moneyFormat($totale_imponibile, $d_importi) : '-').'</b></td>
217+
</tr>';
218+
219+
// Linea di separazione più distinta tra interventi
220+
echo '
221+
<tr>
222+
<td colspan="7" style="border-bottom: 1px solid #000; padding: 10px 0;"></td>
223+
</tr>';
162224
}

templates/riepilogo_interventi/top.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<br>
2727
<h5 class="text-center"><b>'.tr('Riepilogo attività selezionate', [], ['upper' => true]).'</b></h5>
2828
29-
<table class="table border-bottom">
29+
<table class="table">
3030
<thead>
3131
<tr>
3232
<th colspan="2" class="text-muted"><small>'.tr('Documento', [], ['upper' => true]).'</small></th>

0 commit comments

Comments
 (0)