|
66 | 66 | $somma_iva[] = $iva; |
67 | 67 | $somma_totale_ivato[] = $totale_ivato; |
68 | 68 |
|
| 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 | + |
69 | 109 | $pricing ??= true; |
70 | 110 |
|
71 | 111 | // Informazioni intervento |
72 | 112 | echo ' |
73 | 113 | <tr> |
74 | | - <td colspan="2">'; |
| 114 | + <td style="border-top: 1px solid #ddd;" colspan="7">'; |
75 | 115 |
|
76 | 116 | if (dateFormat($intervento->inizio)) { |
77 | 117 | echo ' |
78 | | - <p>'.tr('Intervento _NUM_ del _DATE_', [ |
| 118 | + <p><strong>'.tr('Intervento _NUM_ del _DATE_', [ |
79 | 119 | '_NUM_' => $intervento->codice, |
80 | 120 | '_DATE_' => dateFormat($intervento->inizio), |
81 | | - ]).'</p>'; |
| 121 | + ]).'</strong></p>'; |
82 | 122 | } else { |
83 | 123 | echo ' |
84 | 124 | <p>'.tr('Promemoria _NUM_', [ |
|
87 | 127 | } |
88 | 128 |
|
89 | 129 | 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>'; |
95 | 141 | if ($intervento->descrizione) { |
96 | 142 | 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>'; |
98 | 147 | } |
| 148 | +echo ' |
| 149 | + </tr> |
| 150 | + </table>'; |
99 | 151 |
|
100 | 152 | if (setting('Formato ore in stampa') == 'Sessantesimi') { |
101 | 153 | $ore = Translator::numberToHours($ore); |
102 | 154 | } else { |
103 | 155 | $ore = Translator::numberToLocale($ore, $d_qta); |
104 | 156 | } |
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 | + |
113 | 158 |
|
114 | 159 | // Sessioni |
115 | 160 | if (count($sessioni) > 0) { |
116 | 161 | echo ' |
117 | 162 | <tr> |
118 | | - <td style="border-top: 0; border-bottom: 0;"></td> |
| 163 | + <th></th> |
119 | 164 | <th style="background-color: #eee" colspan="'.(get('id_print') != 24 ? 3 : 2).'"><small>'.tr('Sessioni').'</small></th> |
120 | 165 | <th class="text-center" style="background-color: #eee"><small>'.tr('Data').'</small></th> |
121 | 166 | <th class="text-center" style="background-color: #eee"><small>'.tr('Inizio').'</small></th> |
|
125 | 170 | foreach ($sessioni as $sessione) { |
126 | 171 | echo ' |
127 | 172 | <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> |
130 | 175 | <td class="text-center"><small>'.dateFormat($sessione->orario_inizio).'</small></td> |
131 | 176 | <td class="text-center"><small>'.timeFormat($sessione->orario_inizio).'</small></td> |
132 | 177 | <td class="text-center"><small>'.timeFormat($sessione->orario_fine).'</small></td> |
|
139 | 184 | if (!$righe->isEmpty()) { |
140 | 185 | echo ' |
141 | 186 | <tr> |
142 | | - <td style="border-top: 0; border-bottom: 0;"></td> |
| 187 | + <td></td> |
143 | 188 | <th style="background-color: #eee" colspan="'.(get('id_print') != 24 ? 3 : 2).'"><small>'.tr('Materiale utilizzato e spese aggiuntive').'</small></th> |
144 | 189 | <th class="text-center" style="background-color: #eee"><small>'.tr('Qta').'</small></th> |
145 | 190 | <th class="text-center" style="background-color: #eee"><small>'.($tipo == 'interno' ? tr('Costo unitario') : tr('Prezzo unitario')).'</small></th> |
|
152 | 197 |
|
153 | 198 | echo ' |
154 | 199 | <tr> |
155 | | - <td style="border-top: 0; border-bottom: 0;"></td> |
| 200 | + <td></td> |
156 | 201 | <td colspan="'.(get('id_print') != 24 ? 3 : 2).'"><small>'.$riga->descrizione.'</small></td> |
157 | 202 | <td class="text-center"><small>'.$riga->qta.' '.$riga->um.'</small></td> |
158 | 203 | <td class="text-center"><small>'.($pricing ? moneyFormat($prezzo, $d_importi) : '-').'</small></td> |
159 | 204 | <td class="text-center"><small>'.($pricing ? moneyFormat($totale, $d_importi) : '-').'</small></td> |
160 | 205 | </tr>'; |
161 | 206 | } |
| 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>'; |
162 | 224 | } |
0 commit comments