1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2024-12-29 09:11:11 +01:00
openstamanager/templates/riepilogo_interventi/piece.php

128 lines
5.2 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
$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
$ore = $sessioni->sum('ore');
$imponibile = $tipo=='cliente' ? $intervento->imponibile : $intervento->spesa;
$sconto = $tipo=='cliente' ? $intervento->sconto : 0;
$totale_imponibile = $tipo=='cliente' ? $intervento->totale_imponibile : $intervento->spesa;
$iva = $tipo=='cliente' ? $intervento->iva : (($intervento->spesa * $iva_predefinita) / 100);
$totale_ivato = $tipo=='cliente' ? $intervento->totale : ($intervento->spesa + $iva);
2019-07-12 18:37:58 +02:00
$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
2019-07-15 11:16:12 +02:00
$pricing = isset($pricing) ? $pricing : true;
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_', [
2019-07-15 11:16:12 +02:00
'_NUM_' => $intervento->codice,
'_DATE_' => dateFormat($intervento->inizio),
2020-02-01 11:40:23 +01:00
]).'</p>';
2020-02-05 14:51:39 +01:00
} else {
echo '
2020-02-01 11:40:23 +01:00
<p>'.tr('Promemoria _NUM_', [
'_NUM_' => $intervento->codice,
]).'</p>';
}
echo '
2019-07-15 11:16:12 +02:00
<p><small><b>'.tr('Cliente').':</b> '.$intervento->anagrafica->ragione_sociale.'</small></p>
<p><small><b>'.tr('Stato').':</b> '.$intervento->stato->descrizione.'</small></p>
2020-02-01 11:40:23 +01:00
<p><small><b>'.tr('Data richiesta').':</b> '.dateFormat($intervento->data_richiesta).'</small></p>
<p><small><b>'.tr('Richiesta').':</b> '.$intervento->richiesta.'</p>';
if ($intervento->descrizione) {
echo'
<p><b>'.tr('Descrizione').':</b> '.$intervento->descrizione.'</small></p>';
}
echo '
2019-07-12 18:37:58 +02:00
</td>
<td class="text-center">'.Translator::numberToLocale($ore).'</td>
2019-07-15 11:16:12 +02:00
<td class="text-center">'.($pricing ? moneyFormat($imponibile, 2) : '-').'</td>
2019-07-16 12:13:10 +02:00
<td class="text-center">'.($pricing && empty($options['dir']) ? moneyFormat($sconto, 2) : '-').'</td>
2019-07-15 11:16:12 +02:00
<td class="text-center">'.($pricing ? moneyFormat($totale_imponibile, 2) : '-').'</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>
<th style="background-color: #eee" colspan="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>
<td colspan="2"><small>'.$sessione->anagrafica->ragione_sociale.' <small>('.$sessione->tipo->descrizione.')</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>
<th style="background-color: #eee" colspan="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>
<th class="text-center" style="background-color: #eee"><small>'.($tipo=='cliente' ? tr('Prezzo unitario') : tr('Costo unitario')).'</small></th>
<th class="text-center" style="background-color: #eee"><small>'.($tipo=='cliente' ? tr('Imponibile') : tr('Costo netto')).'</small></th>
2019-07-12 18:37:58 +02:00
</tr>';
foreach ($righe as $riga) {
$prezzo = $tipo=='cliente' ? $riga->prezzo_unitario : $riga->costo_unitario;
$totale = $tipo=='cliente' ? $riga->totale_imponibile : $riga->spesa;
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>
<td colspan="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>
2019-07-16 12:13:10 +02:00
<td class="text-center"><small>'.($pricing ? moneyFormat($prezzo) : '-').'</small></td>
<td class="text-center"><small>'.($pricing ? moneyFormat($totale) : '-').'</small></td>
2019-07-12 18:37:58 +02:00
</tr>';
}
}