openstamanager/templates/riepilogo_interventi/piece.php

140 lines
5.8 KiB
PHP
Raw Normal View History

2019-07-12 18:37:58 +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/>.
*/
2019-07-12 18:37:58 +02:00
include_once __DIR__.'/../../core.php';
use Modules\Interventi\Intervento;
use Modules\Iva\Aliquota;
2019-07-12 18:37:58 +02:00
2023-12-06 15:06:49 +01:00
$d_qta = (int) setting('Cifre decimali per quantità in stampa');
$d_importi = (int) setting('Cifre decimali per importi in stampa');
2019-07-12 18:37:58 +02:00
$intervento = Intervento::find($record['id']);
$sessioni = $intervento->sessioni;
$iva_predefinita = floatval(Aliquota::find(setting('Iva predefinita'))->percentuale);
2019-07-12 18:37:58 +02:00
$km = $sessioni->sum('km');
$ore = $sessioni->sum('ore');
2023-08-04 14:54:28 +02:00
$imponibile = $tipo == 'interno' ? $intervento->spesa : $intervento->imponibile;
$sconto = $tipo == 'interno' ? 0 : $intervento->sconto;
$totale_imponibile = $tipo == 'interno' ? $intervento->spesa : $intervento->totale_imponibile;
$iva = $tipo == 'interno' ? (($intervento->spesa * $iva_predefinita) / 100) : $intervento->iva;
$totale_ivato = $tipo == 'interno' ? ($intervento->spesa + $iva) : $intervento->totale;
2019-07-12 18:37:58 +02:00
2023-02-13 11:32:50 +01:00
$somma_km[] = $km;
$somma_ore[] = $ore;
2019-07-12 18:37:58 +02:00
$somma_imponibile[] = $imponibile;
$somma_sconto[] = $sconto;
$somma_totale_imponibile[] = $totale_imponibile;
$somma_iva[] = $iva;
$somma_totale_ivato[] = $totale_ivato;
2019-07-12 18:37:58 +02:00
2024-04-08 15:57:28 +02:00
$pricing ??= true;
2019-07-15 11:16:12 +02:00
2019-07-12 18:37:58 +02:00
// Informazioni intervento
echo '
<tr>
2020-02-01 11:40:23 +01:00
<td colspan="2">';
2020-02-05 14:51:39 +01:00
if (dateFormat($intervento->inizio)) {
echo '
2019-07-12 18:37:58 +02:00
<p>'.tr('Intervento _NUM_ del _DATE_', [
2024-03-22 15:52:24 +01:00
'_NUM_' => $intervento->codice,
'_DATE_' => dateFormat($intervento->inizio),
]).'</p>';
2020-02-05 14:51:39 +01:00
} else {
echo '
2020-02-01 11:40:23 +01:00
<p>'.tr('Promemoria _NUM_', [
2024-03-22 15:52:24 +01:00
'_NUM_' => $intervento->codice,
]).'</p>';
2020-02-01 11:40:23 +01:00
}
echo '
2019-07-15 11:16:12 +02:00
<p><small><b>'.tr('Cliente').':</b> '.$intervento->anagrafica->ragione_sociale.'</small></p>
2024-04-18 17:44:05 +02:00
<p><small><b>'.tr('Stato').':</b> '.$intervento->stato->getTranslation('title').'</small></p>
2020-02-01 11:40:23 +01:00
<p><small><b>'.tr('Data richiesta').':</b> '.dateFormat($intervento->data_richiesta).'</small></p>
2024-05-10 15:49:40 +02:00
<p><small><b>'.tr('Richiesta').':</b> '.strip_tags($intervento->richiesta).'</p>';
2024-01-15 15:30:45 +01:00
if ($intervento->descrizione) {
echo '
<p><b>'.tr('Descrizione').':</b> '.$intervento->descrizione.'</small></p>';
2024-01-15 15:30:45 +01:00
}
2022-10-11 13:14:20 +02:00
2024-01-15 15:30:45 +01:00
if (setting('Formato ore in stampa') == 'Sessantesimi') {
$ore = Translator::numberToHours($ore);
} else {
$ore = Translator::numberToLocale($ore, $d_qta);
}
echo '
</td>
<td class="text-center">'.($pricing ? $km : '-').'</td>
2022-10-11 13:14:20 +02:00
<td class="text-center">'.($pricing ? $ore : '-').'</td>
<td class="text-center">'.($pricing ? moneyFormat($imponibile, $d_importi) : '-').'</td>
<td class="text-center">'.($pricing && empty($options['dir']) ? moneyFormat($sconto, $d_importi) : '-').'</td>
<td class="text-center">'.($pricing ? moneyFormat($totale_imponibile, $d_importi) : '-').'</td>
2019-07-12 18:37:58 +02:00
</tr>';
// Sessioni
2020-02-05 14:51:39 +01:00
if (count($sessioni) > 0) {
2019-07-12 18:37:58 +02:00
echo '
<tr>
<td style="border-top: 0; border-bottom: 0;"></td>
2023-08-04 14:54:28 +02:00
<th style="background-color: #eee" colspan="'.(get('id_print') != 24 ? 3 : 2).'"><small>'.tr('Sessioni').'</small></th>
2019-07-12 18:37:58 +02:00
<th class="text-center" style="background-color: #eee"><small>'.tr('Data').'</small></th>
<th class="text-center" style="background-color: #eee"><small>'.tr('Inizio').'</small></th>
<th class="text-center" style="background-color: #eee"><small>'.tr('Fine').'</small></th>
</tr>';
foreach ($sessioni as $sessione) {
echo '
<tr>
<td style="border-top: 0; border-bottom: 0;"></td>
2024-04-18 17:44:05 +02:00
<td colspan="'.(get('id_print') != 24 ? 3 : 2).'"><small>'.$sessione->anagrafica->ragione_sociale.' <small>('.$sessione->tipo->getTranslation('title').')</small></td>
2019-07-12 18:37:58 +02:00
<td class="text-center"><small>'.dateFormat($sessione->orario_inizio).'</small></td>
<td class="text-center"><small>'.timeFormat($sessione->orario_inizio).'</small></td>
<td class="text-center"><small>'.timeFormat($sessione->orario_fine).'</small></td>
</tr>';
}
}
// Righe
$righe = $intervento->getRighe();
if (!$righe->isEmpty()) {
echo '
<tr>
<td style="border-top: 0; border-bottom: 0;"></td>
2023-08-04 14:54:28 +02:00
<th style="background-color: #eee" colspan="'.(get('id_print') != 24 ? 3 : 2).'"><small>'.tr('Materiale utilizzato e spese aggiuntive').'</small></th>
2019-07-12 18:37:58 +02:00
<th class="text-center" style="background-color: #eee"><small>'.tr('Qta').'</small></th>
2023-08-04 14:54:28 +02:00
<th class="text-center" style="background-color: #eee"><small>'.($tipo == 'interno' ? tr('Costo unitario') : tr('Prezzo unitario')).'</small></th>
<th class="text-center" style="background-color: #eee"><small>'.($tipo == 'interno' ? tr('Costo netto') : tr('Imponibile')).'</small></th>
2019-07-12 18:37:58 +02:00
</tr>';
foreach ($righe as $riga) {
2023-08-04 14:54:28 +02:00
$prezzo = $tipo == 'interno' ? $riga->costo_unitario : $riga->prezzo_unitario;
$totale = $tipo == 'interno' ? $riga->spesa : $riga->totale_imponibile;
2019-07-16 12:13:10 +02:00
2019-07-12 18:37:58 +02:00
echo '
<tr>
<td style="border-top: 0; border-bottom: 0;"></td>
2023-08-04 14:54:28 +02:00
<td colspan="'.(get('id_print') != 24 ? 3 : 2).'"><small>'.$riga->descrizione.'</small></td>
2019-07-12 18:37:58 +02:00
<td class="text-center"><small>'.$riga->qta.' '.$riga->um.'</small></td>
<td class="text-center"><small>'.($pricing ? moneyFormat($prezzo, $d_importi) : '-').'</small></td>
<td class="text-center"><small>'.($pricing ? moneyFormat($totale, $d_importi) : '-').'</small></td>
2019-07-12 18:37:58 +02:00
</tr>';
}
}