Aggiunta stampa riepilogo interventi interno

This commit is contained in:
MatteoPistorello 2022-02-03 10:13:53 +01:00
parent 68f7f995ed
commit 6807b7cd5c
6 changed files with 97 additions and 16 deletions

View File

@ -0,0 +1,46 @@
<?php
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
* Copyright (C) DevCode s.r.l.
*
* 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/>.
*/
include_once __DIR__.'/../../../core.php';
// Trovo id_print della stampa
$id_print = $dbo->fetchOne('SELECT zz_prints.id FROM zz_prints INNER JOIN zz_modules ON zz_prints.id_module=zz_modules.id WHERE zz_modules.name="Interventi" AND zz_prints.name="Riepilogo interventi"')['id'];
echo '
<form action="'.base_path().'/pdfgen.php?id_print='.$id_print.'" method="post" target="_blank">
<div class="row">
<div class="col-md-4">
{[ "type": "select", "label": "'.tr('Stampa riepilogo').'", "name": "tipo", "required": "1", "values": "list=\"cliente\": \"'.tr('Clienti').'\", \"interno\": \"'.tr('Interno').'\"", "value": "cliente" ]}
</div>
<div class="col-md-offset-6 col-md-2">
<p style="line-height:14px;">&nbsp;</p>
<button type="submit" class="btn btn-primary btn-block">
<i class="fa fa-print"></i> '.tr('Stampa').'
</button>
</div>
</div>
</form>
<script>$(document).ready(init)</script>';

View File

@ -25,8 +25,8 @@ $v_iva = [];
$v_totale = [];
// Creazione righe fantasma
$autofill = new \Util\Autofill(6, 60);
$rows_per_page = $fattura_accompagnatoria ? 18 : 23;
$autofill = new \Util\Autofill(6, 40);
$rows_per_page = $fattura_accompagnatoria ? 13 : 18;
if (!empty($options['last-page-footer'])) {
$rows_per_page += 7;
}

View File

@ -23,6 +23,8 @@ $somma_ore = sum($somma_ore);
$somma_imponibile = sum($somma_imponibile);
$somma_sconto = sum($somma_sconto);
$somma_totale_imponibile = sum($somma_totale_imponibile);
$somma_iva = sum($somma_iva);
$somma_totale_ivato = sum($somma_totale_ivato);
echo '
<tr>
@ -35,5 +37,23 @@ echo '
<th class="text-center">'.($pricing ? moneyFormat($somma_sconto, 2) : '-').'</th>
<th class="text-center">'.($pricing ? moneyFormat($somma_totale_imponibile, 2) : '-').'</th>
</tr>
<tr>
<th width="5%" style="border-right: 0"></th>
<th class="text-right" style="border-left: 0;">
<b>'.tr('Iva', [], ['upper' => true]).':</b>
</th>
<th colspan="3"></th>
<th class="text-center">'.($pricing ? moneyFormat($somma_iva, 2) : '-').'</th>
</tr>
<tr>
<th width="5%" style="border-right: 0"></th>
<th class="text-right" style="border-left: 0;">
<b>'.tr('Totale Ivato', [], ['upper' => true]).':</b>
</th>
<th colspan="3"></th>
<th class="text-center">'.($pricing ? moneyFormat($somma_totale_ivato, 2) : '-').'</th>
</tr>
</tbody>
</table>';

View File

@ -20,19 +20,25 @@
include_once __DIR__.'/../../core.php';
use Modules\Interventi\Intervento;
use Modules\Iva\Aliquota;
$intervento = Intervento::find($record['id']);
$sessioni = $intervento->sessioni;
$iva_predefinita = floatval(Aliquota::find(setting('Iva predefinita'))->percentuale);
$ore = $sessioni->sum('ore');
$imponibile = empty($options['dir']) ? $intervento->imponibile : $intervento->spesa;
$sconto = empty($options['dir']) ? $intervento->sconto : 0;
$totale_imponibile = empty($options['dir']) ? $intervento->totale_imponibile : $intervento->spesa;
$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);
$somma_ore[] = $ore;
$somma_imponibile[] = $imponibile;
$somma_sconto[] = $sconto;
$somma_totale_imponibile[] = $totale_imponibile;
$somma_iva[] = $iva;
$somma_totale_ivato[] = $totale_ivato;
$pricing = isset($pricing) ? $pricing : true;
@ -57,8 +63,12 @@ echo '
<p><small><b>'.tr('Cliente').':</b> '.$intervento->anagrafica->ragione_sociale.'</small></p>
<p><small><b>'.tr('Stato').':</b> '.$intervento->stato->descrizione.'</small></p>
<p><small><b>'.tr('Data richiesta').':</b> '.dateFormat($intervento->data_richiesta).'</small></p>
<p><small><b>'.tr('Richiesta').':</b> '.$intervento->richiesta.'</p>
<p><b>'.tr('Descrizione').':</b> '.$intervento->descrizione.'</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 '
</td>
<td class="text-center">'.Translator::numberToLocale($ore).'</td>
<td class="text-center">'.($pricing ? moneyFormat($imponibile, 2) : '-').'</td>
@ -97,13 +107,13 @@ if (!$righe->isEmpty()) {
<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>
<th class="text-center" style="background-color: #eee"><small>'.tr('Qta').'</small></th>
<th class="text-center" style="background-color: #eee"><small>'.tr('Prezzo unitario').'</small></th>
<th class="text-center" style="background-color: #eee"><small>'.tr('Imponibile').'</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>
</tr>';
foreach ($righe as $riga) {
$prezzo = empty($options['dir']) ? $riga->prezzo_unitario : $riga->costo_unitario;
$totale = empty($options['dir']) ? $riga->totale_imponibile : $riga->spesa;
$prezzo = $tipo=='cliente' ? $riga->prezzo_unitario : $riga->costo_unitario;
$totale = $tipo=='cliente' ? $riga->totale_imponibile : $riga->spesa;
echo '
<tr>

View File

@ -19,6 +19,9 @@
include_once __DIR__.'/../../core.php';
//$tipo = post('tipo');
$tipo = post('tipo');
echo '
<h4><b>'.tr('Riepilogo interventi dal _START_ al _END_', [
'_START_' => Translator::dateToLocale($date_start),
@ -28,11 +31,11 @@ echo '
<table class="table table-bordered">
<thead>
<tr>
<th colspan="2">'.tr('Documento', [], ['upper' => true]).'</th>
<th class="text-center" style="width:10%">'.tr('Ore', [], ['upper' => true]).'</th>
<th class="text-center" style="width:15%">'.tr('Imponibile', [], ['upper' => true]).'</th>
<th class="text-center" style="width:15%">'.tr('Sconto', [], ['upper' => true]).'</th>
<th class="text-center" style="width:15%">'.tr('Totale imponibile', [], ['upper' => true]).'</th>
<th colspan="2"><small>'.tr('Documento', [], ['upper' => true]).'</small></th>
<th class="text-center" style="width:10%"><small>'.tr('Ore', [], ['upper' => true]).'</small></th>
<th class="text-center" style="width:15%"><small>'.($tipo=='cliente' ? tr('Imponibile', [], ['upper' => true]) : tr('Costo totale', [], ['upper' => true])).'</th>
<th class="text-center" style="width:15%"><small>'.tr('Sconto', [], ['upper' => true]).'</small></th>
<th class="text-center" style="width:15%"><small>'.($tipo=='cliente' ? tr('Totale imponibile', [], ['upper' => true]) : tr('Costo netto', [], ['upper' => true])).'</small></th>
</tr>
</thead>

2
update/2_4_30.sql Normal file
View File

@ -0,0 +1,2 @@
-- Aggiunta popup Stampa riepilogo interventi
UPDATE `zz_widgets` SET `more_link` = './modules/interventi/widgets/stampa_riepilogo.php', `more_link_type` = 'popup' WHERE `zz_widgets`.`name` = 'Stampa riepilogo';