Aggiornamento stampe consuntivi
This commit is contained in:
parent
5cdee79a1e
commit
9e4e687b3e
|
@ -20,7 +20,7 @@ if ($options['action'] == 'add') {
|
|||
// Sconto unitario
|
||||
echo '
|
||||
<div class="col-md-'.($options['action'] == 'add' ? 4 : 6).'">
|
||||
{[ "type": "number", "label": "'.tr('Sconto/maggiorazione unitario').'", "name": "sconto_unitario", "value": "'.$result['sconto_unitario'].'", "icon-after": "'.currency().'", "help": "'.tr('Il valore positivo indica uno sconto: per applicare una maggiorazione inserire un valore negativo').'" ]}
|
||||
{[ "type": "number", "label": "'.tr('Sconto/maggiorazione percentuale').'", "name": "sconto_percentuale", "icon-after": "%", "help": "'.tr('Il valore positivo indica uno sconto: per applicare una maggiorazione inserire un valore negativo').'. <b>'.tr("L'importo dello sconto viene calcolato sul totale imponibile del documento al momento dell'aggiunta dello sconto").'</b>." ]}
|
||||
</div>';
|
||||
|
||||
// Iva
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
<?php
|
||||
|
||||
include_once __DIR__.'/../../../core.php';
|
||||
|
||||
$idcontratto = get('idcontratto');
|
||||
$idpianificazione = get('idpianificazione');
|
||||
$importo = get('importo');
|
||||
$n_rata = get('n_rata');
|
||||
|
||||
// Lettura numero contratto e nome zona
|
||||
$rs = $dbo->fetchArray('SELECT numero, (SELECT descrizione FROM an_zone WHERE id=(SELECT idzona FROM co_ordiniservizio_pianificazionefatture WHERE id='.prepare($idpianificazione).')) AS zona FROM co_contratti WHERE id='.prepare($idcontratto));
|
||||
$numero = $rs[0]['numero'];
|
||||
$zona = $rs[0]['zona'];
|
||||
|
||||
echo '
|
||||
<form id="add_form" action="'.$rootdir.'/editor.php?id_module='.Modules::get('Contratti')['id'].'&id_record='.$idcontratto.'&op=addfattura&idpianificazione='.$idpianificazione.'&importo='.$importo.'" method="post">
|
||||
<input type="hidden" name="backto" value="record-edit">';
|
||||
|
||||
// Data
|
||||
echo '
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
{[ "type": "date", "label": "'.tr('Data').'", "name": "data", "required": 1, "class": "text-center", "value": "-now-" ]}
|
||||
</div>';
|
||||
|
||||
// Tipo di documento
|
||||
echo '
|
||||
<div class="col-md-4">
|
||||
{[ "type": "select", "label": "'.tr('Tipo di fattura').'", "name": "idtipodocumento", "required": 1, "values": "query=SELECT * FROM co_tipidocumento WHERE dir=\'entrata\'" ]}
|
||||
</div>';
|
||||
|
||||
// Sezionale
|
||||
echo '
|
||||
<div class="col-md-4">
|
||||
{[ "type": "select", "label": "'.tr('Sezionale').'", "name": "id_segment", "required": 1, "values": "query=SELECT id, name AS descrizione FROM zz_segments WHERE id_module='.Modules::get('Fatture di vendita')['id'].' ORDER BY name", "value":"'.$_SESSION['module_'.Modules::get('Fatture di vendita')['id']]['id_segment'].'" ]}
|
||||
</div>
|
||||
|
||||
</div>';
|
||||
|
||||
// Note
|
||||
echo '
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
{[ "type": "textarea", "label": "'.tr('Descrizione').'", "name": "note", "value": "Rata '.$n_rata.' del contratto numero '.$numero.', zona '.$zona.'" ]}
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
echo '
|
||||
<!-- PULSANTI -->
|
||||
<div class="row">
|
||||
<div class="col-md-12 text-right">
|
||||
<button type="submit" class="btn btn-primary pull-right">
|
||||
<i class="fa fa-plus"></i> '.tr('Aggiungi').'
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>';
|
||||
|
||||
echo '
|
||||
<script src="'.$rootdir.'/lib/init.js"></script>';
|
|
@ -1,377 +0,0 @@
|
|||
<?php
|
||||
|
||||
include_once __DIR__.'/../../../core.php';
|
||||
|
||||
/* GESTIONE ORDINI DI SERVIZI */
|
||||
|
||||
// TODO: aggiornare con la funzione months()
|
||||
$mesi = [
|
||||
tr('Gennaio'),
|
||||
tr('Febbraio'),
|
||||
tr('Marzo'),
|
||||
tr('Aprile'),
|
||||
tr('Maggio'),
|
||||
tr('Giugno'),
|
||||
tr('Luglio'),
|
||||
tr('Agosto'),
|
||||
tr('Settembre'),
|
||||
tr('Ottobre'),
|
||||
tr('Novembre'),
|
||||
tr('Dicembre'),
|
||||
];
|
||||
|
||||
// Pianificazione fatture
|
||||
if (get('op') == 'add_fatturazione') {
|
||||
$prev_data = '';
|
||||
|
||||
// Azzero la pianificazione zone se era già stata fatta, per poter sostituire la pianificazione,
|
||||
// mantenendo però le pianificazioni già fatturate
|
||||
foreach (post('zona') as $data_scadenza => $zone) {
|
||||
foreach ($zone as $n => $idzona) {
|
||||
$dbo->query('DELETE FROM co_ordiniservizio_pianificazionefatture WHERE idzona='.prepare($idzona).' AND iddocumento=0 AND idcontratto='.prepare($id_record));
|
||||
}
|
||||
}
|
||||
|
||||
// Ciclo fra le voci in arrivo dal form
|
||||
foreach (post('zona') as $data_scadenza => $zone) {
|
||||
// Ogni data può avere più zone da pianificare
|
||||
foreach ($zone as $n => $idzona) {
|
||||
// Aggiunta pianificazione solo se la zona è spuntata
|
||||
if (in_array($idzona, post('idzona'))) {
|
||||
// Creazione pianificazione
|
||||
$dbo->query('INSERT INTO co_ordiniservizio_pianificazionefatture(idcontratto, data_scadenza, idzona, iddocumento) VALUES('.prepare($id_record).', '.prepare($data_scadenza).', '.prepare($idzona).', 0)');
|
||||
}
|
||||
|
||||
$prev_data = $data_scadenza;
|
||||
}
|
||||
}
|
||||
|
||||
flash()->info(tr('Pianificazione generata correttamente!'));
|
||||
}
|
||||
|
||||
// Eliminazione pianificazione specifica
|
||||
elseif (get('op') == 'del_pianificazione') {
|
||||
$idpianificazione = get('idpianificazione');
|
||||
|
||||
$n = $dbo->fetchNum('SELECT id FROM co_ordiniservizio_pianificazionefatture WHERE id='.prepare($idpianificazione));
|
||||
|
||||
if ($n == 1) {
|
||||
// Eliminazione ordine di servizio
|
||||
if ($dbo->query('DELETE FROM co_ordiniservizio_pianificazionefatture WHERE id='.prepare($idpianificazione))) {
|
||||
flash()->info(tr('Pianificazione eliminata correttamente!'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Creazione fattura pianificata
|
||||
elseif (get('op') == 'addfattura') {
|
||||
$idpianificazione = get('idpianificazione');
|
||||
$descrizione = post('note');
|
||||
$data = post('data');
|
||||
$idtipodocumento = post('idtipodocumento');
|
||||
$note = post('note');
|
||||
|
||||
// Lettura idanagrafica
|
||||
$rs = $dbo->fetchArray('SELECT idanagrafica FROM co_contratti WHERE id='.prepare($id_record));
|
||||
$idanagrafica = $rs[0]['idanagrafica'];
|
||||
|
||||
$dir = 'entrata';
|
||||
$idconto = setting('Conto predefinito fatture di vendita');
|
||||
$numero = get_new_numerofattura($data);
|
||||
$id_segment = post('id_segment');
|
||||
$numero_esterno = get_new_numerosecondariofattura($data);
|
||||
|
||||
// Tipo di pagamento + banca predefinite dall'anagrafica
|
||||
$query = 'SELECT id, (SELECT idbanca_vendite FROM an_anagrafiche WHERE idanagrafica = '.prepare($idanagrafica).') AS idbanca FROM co_pagamenti WHERE id = (SELECT idpagamento_vendite AS pagamento FROM an_anagrafiche WHERE idanagrafica='.prepare($idanagrafica).')';
|
||||
$rs = $dbo->fetchArray($query);
|
||||
$idpagamento = $rs[0]['id'];
|
||||
$idbanca = $rs[0]['idbanca'];
|
||||
|
||||
// Se la fattura è di vendita e non è stato associato un pagamento predefinito al cliente leggo il pagamento dalle impostazioni
|
||||
if ($dir == 'entrata' && $idpagamento == '') {
|
||||
$idpagamento = setting('Tipo di pagamento predefinito');
|
||||
}
|
||||
|
||||
// Se non è impostata la banca dell'anagrafica, uso quella del pagamento.
|
||||
if (empty($idbanca)) {
|
||||
// Banca predefinita del pagamento
|
||||
$query = 'SELECT id FROM co_banche WHERE id_pianodeiconti3 = (SELECT idconto_vendite FROM co_pagamenti WHERE id = '.prepare($idpagamento).')';
|
||||
$rs = $dbo->fetchArray($query);
|
||||
$idbanca = $rs[0]['id'];
|
||||
}
|
||||
|
||||
$query = 'INSERT INTO co_documenti(numero, numero_esterno, idanagrafica, idtipodocumento, idpagamento, data, idstatodocumento, note, idsede, id_segment, idconto, idbanca) VALUES ('.prepare($numero).', '.prepare($numero_esterno).', '.prepare($idanagrafica).', '.prepare($idtipodocumento).', '.prepare($idpagamento).', '.prepare($data).", (SELECT `id` FROM `co_statidocumento` WHERE `descrizione`='Bozza'), ".prepare($note).', (SELECT idsede_fatturazione FROM an_anagrafiche WHERE idanagrafica='.prepare($idanagrafica).'), '.prepare($id_segment).', '.prepare($idconto).', '.prepare($idbanca).' )';
|
||||
$dbo->query($query);
|
||||
$iddocumento = $dbo->lastInsertedID();
|
||||
|
||||
// Imposto l'iddocumento anche sulla pianificazione, giusto per tener traccia della fattura generata
|
||||
$dbo->query('UPDATE co_ordiniservizio_pianificazionefatture SET iddocumento='.prepare($iddocumento).' WHERE id='.prepare($idpianificazione));
|
||||
|
||||
// Leggo quante rate si vogliono pagare per dividerle per mese
|
||||
$rs = $dbo->fetchArray('SELECT id FROM co_ordiniservizio_pianificazionefatture WHERE idcontratto='.prepare($id_record));
|
||||
|
||||
// L'importo deve essere diviso per il numero di mesi
|
||||
$rs2 = $dbo->fetchArray('SELECT SUM(subtotale) AS totale FROM co_righe_contratti WHERE idcontratto='.prepare($id_record));
|
||||
$importo = $rs2[0]['totale'] / sizeof($rs);
|
||||
|
||||
// Lettura iva del cliente o predefinita
|
||||
$rs2 = $dbo->fetchArray('SELECT idiva_vendite AS idiva FROM an_anagrafiche WHERE idanagrafica='.prepare($idanagrafica));
|
||||
$idiva = $rs2[0]['idiva'];
|
||||
|
||||
if ($idiva != 0) {
|
||||
$rs2 = $dbo->fetchArray('SELECT * FROM co_iva WHERE id='.prepare($idiva));
|
||||
} else {
|
||||
$rs2 = $dbo->fetchArray('SELECT * FROM co_iva WHERE id='.prepare(setting('Iva predefinita')));
|
||||
}
|
||||
|
||||
$desc_iva = $rs2[0]['descrizione'];
|
||||
|
||||
$iva = $importo / 100 * $rs2[0]['percentuale'];
|
||||
$iva_indetraibile = $importo / 100 * $rs2[0]['indetraibile'];
|
||||
|
||||
// Inserimento riga in fattura
|
||||
$dbo->query('INSERT INTO co_righe_documenti(iddocumento, idcontratto, descrizione, desc_iva, iva, iva_indetraibile, subtotale, um, qta, `order`) VALUES('.prepare($iddocumento).', '.prepare($id_record).', '.prepare($descrizione).', '.prepare($desc_iva).', '.prepare($iva).', '.prepare($iva_indetraibile).', '.prepare($importo).", '-', 1, (SELECT IFNULL(MAX(`order`) + 1, 0) FROM co_righe_documenti AS t WHERE iddocumento=".prepare($iddocumento).'))');
|
||||
|
||||
redirect($rootdir.'/editor.php?id_module='.Modules::get('Fatture di vendita')['id'].'&id_record='.$iddocumento.'&dir=entrata');
|
||||
exit();
|
||||
}
|
||||
|
||||
echo '
|
||||
<div class="box">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">'.tr('Pianificazione fatturazione').'</h3>
|
||||
</div>
|
||||
<div class="box-body">';
|
||||
|
||||
echo '
|
||||
<p>'.tr('Qui puoi programmare la fatturazione del contratto').'.</p>';
|
||||
|
||||
/*
|
||||
Fatture pianificate
|
||||
*/
|
||||
$rs = $dbo->fetchArray('SELECT *, (SELECT SUM(subtotale) FROM co_righe_contratti WHERE idcontratto='.prepare($id_record).') AS budget_contratto, (SELECT descrizione FROM an_zone WHERE id=idzona) AS zona FROM co_ordiniservizio_pianificazionefatture WHERE idcontratto='.prepare($id_record).' ORDER BY data_scadenza ASC');
|
||||
|
||||
if (empty($rs)) {
|
||||
echo '
|
||||
<p>'.tr('Non sono ancora state pianificate fatture').'...</p>';
|
||||
} else {
|
||||
$rs2 = $dbo->fetchArray('SELECT * FROM co_ordiniservizio_pianificazionefatture WHERE idcontratto='.prepare($id_record).' ORDER BY idzona');
|
||||
|
||||
for ($i = 0; $i < sizeof($rs2); ++$i) {
|
||||
// Leggo quante rate sono pianificate per dividere l'importo delle sedi in modo corretto
|
||||
++$n_rate[$rs2[$i]['idzona']];
|
||||
|
||||
// Leggo il totale già fatturato per questa zona per toglierlo dalla divisione (totale/n_rate)
|
||||
$rs3 = $dbo->fetchArray('SELECT SUM(subtotale-sconto) AS totale FROM co_righe_documenti WHERE iddocumento IN (SELECT iddocumento FROM co_ordiniservizio_pianificazionefatture WHERE iddocumento='.prepare($rs2[$i]['iddocumento']).')');
|
||||
$gia_fatturato[$rs2[$i]['idzona']] += $rs3[0]['totale'];
|
||||
}
|
||||
|
||||
echo '
|
||||
<table class="table table-bordered table-striped table-hover table-condensed">
|
||||
<tr>
|
||||
<th width="10%">'.tr('Scadenza').'</th>
|
||||
<th width="15%">'.tr('Zona').'</th>
|
||||
<th width="15%">'.tr('Importo').'</th>
|
||||
<th>'.tr('Documento').'</th>
|
||||
<th width="20%">'.tr('Stato').'</th>
|
||||
<th width="12%"></th>
|
||||
</tr>';
|
||||
|
||||
$prev_mese = '';
|
||||
$n_rata = 0;
|
||||
|
||||
for ($i = 0; $i < sizeof($rs); ++$i) {
|
||||
// Lettura numero di sedi in cui si sono pianificati ordini di servizio per la zona corrente
|
||||
if (!empty($rs[$i]['idzona'])) {
|
||||
$n_sedi_pianificate = $dbo->fetchNum('SELECT DISTINCT(idsede) FROM my_impianti WHERE id IN (SELECT idimpianto FROM co_ordiniservizio WHERE idcontratto='.prepare($id_record).') AND idsede IN(SELECT id FROM an_sedi WHERE idzona='.prepare($rs[$i]['idzona']).')');
|
||||
|
||||
// Verifico se ci sono impianti in questa zona legati alla sede legale
|
||||
$n_sedi_pianificate += $dbo->fetchNum('SELECT DISTINCT(idsede) FROM my_impianti WHERE id IN (SELECT idimpianto FROM co_ordiniservizio WHERE idcontratto='.prepare($id_record).') AND idsede=(SELECT idsede FROM an_anagrafiche WHERE idanagrafica=(SELECT idanagrafica FROM co_contratti WHERE id='.prepare($id_record).') AND idzona='.prepare($rs[$i]['idzona']).') AND idsede=0');
|
||||
}
|
||||
// Fix nel caso non siano previste sedi pianificate (l'eventuale 0 portava a problemi nel calcolo dell'importo)
|
||||
$n_sedi_pianificate = ($n_sedi_pianificate < 1) ? 1 : $n_sedi_pianificate;
|
||||
// else{
|
||||
// $n_sedi_pianificate = $dbo->fetchNum("SELECT (idsede) FROM my_impianti WHERE id IN (SELECT idimpianto FROM co_ordiniservizio WHERE idcontratto=\"".$id_record."\") AND idsede=0");
|
||||
// }
|
||||
|
||||
echo '
|
||||
<tr>
|
||||
<td>';
|
||||
// Data scadenza
|
||||
if ($prev_mese != $rs[$i]['data_scadenza']) {
|
||||
++$n_rata;
|
||||
echo '
|
||||
<b>'.$mesi[intval(date('m', strtotime($rs[$i]['data_scadenza']))) - 1].' '.date('Y', strtotime($rs[$i]['data_scadenza'])).'</b></td>';
|
||||
}
|
||||
echo '
|
||||
</td>';
|
||||
|
||||
// Sede
|
||||
if ($rs[$i]['zona'] == '') {
|
||||
$zona = 'Altro';
|
||||
} else {
|
||||
$zona = $rs[$i]['zona'];
|
||||
}
|
||||
|
||||
if ($n_sedi_pianificate == 1) {
|
||||
$n_sedi = tr('1 sede');
|
||||
} else {
|
||||
$n_sedi = tr('_NUM_ sedi', [
|
||||
'_NUM_' => $n_sedi_pianificate,
|
||||
]);
|
||||
}
|
||||
|
||||
echo '
|
||||
<td>'.$zona.' ('.$n_sedi.')</td>';
|
||||
|
||||
/*
|
||||
Importo
|
||||
*/
|
||||
// Se è stata emessa una fattura, bisogna utilizzare il totale della fattura da scalare al totale pianificato
|
||||
if ($rs[$i]['iddocumento'] != 0) {
|
||||
$rs2 = $dbo->fetchArray('SELECT SUM(subtotale-sconto) AS totale FROM co_righe_documenti WHERE iddocumento='.prepare($rs[$i]['iddocumento']));
|
||||
$importo = $rs2[0]['totale'];
|
||||
} else {
|
||||
// $importo = ($rs[$i]['budget_contratto'] * $n_sedi_pianificate / $n_rate[ $rs[$i]['idzona'] ]) - ($gia_fatturato[ $rs[$i]['idzona'] ] * $n_sedi_pianificate / sizeof($gia_fatturato[ $rs[$i]['idzona'] ]) );
|
||||
$importo = ($rs[$i]['budget_contratto'] * $n_sedi_pianificate / $n_rate[$rs[$i]['idzona']]);
|
||||
}
|
||||
|
||||
echo '
|
||||
<td class="center">
|
||||
'.moneyFormat($importo).'<br>
|
||||
<small>'.moneyFormat($rs[$i]['budget_contratto']).' x '.$n_sedi_pianificate.' sedi / '.$n_rate[$rs[$i]['idzona']].' rate'.$extra.'</small>
|
||||
</td>';
|
||||
|
||||
// Documento collegato (fattura)
|
||||
if ($rs[$i]['iddocumento'] != 0) {
|
||||
$rsf = $dbo->fetchArray('SELECT numero, numero_esterno, data, (SELECT SUM(subtotale) FROM co_righe_documenti WHERE iddocumento=co_documenti.id) AS imponibile, (SELECT icona FROM co_statidocumento WHERE id=co_documenti.idstatodocumento) AS icona, (SELECT descrizione FROM co_statidocumento WHERE id=co_documenti.idstatodocumento) AS stato FROM co_documenti WHERE id='.prepare($rs[$i]['iddocumento']));
|
||||
|
||||
if ($rsf[0]['numero_esterno'] != '') {
|
||||
$numero_doc = $rsf[0]['numero_esterno'];
|
||||
} else {
|
||||
$numero_doc = $rsf[0]['numero'];
|
||||
}
|
||||
|
||||
$documento = Modules::link('Fatture di vendita', $rs[$i]['iddocumento'], tr('Fattura num. _NUM_ del _DATE_', [
|
||||
'_NUM_' => $numero_doc,
|
||||
'_DATE_' => Translator::dateToLocale($rsf[0]['data']),
|
||||
]));
|
||||
|
||||
$stato = '<i class="'.$rsf[0]['icona'].'"></i> '.$rsf[0]['stato'];
|
||||
} else {
|
||||
$documento = '';
|
||||
$stato = '<i class="fa fa-clock-o"></i> '.tr('Non ancora fatturato');
|
||||
}
|
||||
|
||||
// Link a fattura
|
||||
echo '
|
||||
<td>'.$documento.'</td>';
|
||||
|
||||
// Stato
|
||||
echo '
|
||||
<td>'.$stato.'</td>';
|
||||
|
||||
// Funzioni
|
||||
echo '
|
||||
<td>';
|
||||
if ($rs[$i]['iddocumento'] == 0) {
|
||||
// Creazione fattura
|
||||
echo "
|
||||
<button type='button' class='btn btn-primary btn-sm' onclick=\"launch_modal( 'Crea fattura', '".$rootdir.'/modules/contratti/plugins/addfattura.php?idcontratto='.$id_record.'&idpianificazione='.$rs[$i]['id'].'&importo='.$importo.'&n_rata='.$n_rata."', 1 );\">
|
||||
<i class='fa fa-euro'></i> ".tr('Crea fattura').'
|
||||
</button>';
|
||||
|
||||
// Eliminazione pianificazione
|
||||
echo '
|
||||
<a class="btn btn-danger ask" data-backto="record-edit" data-method="get" data-op="del_pianificazione" data-idpianificazione="'.$rs[$i]['id'].'" data-msg="'.tr('Vuoi eliminare questa pianificazione?').'">
|
||||
<i class="fa fa-trash"></i>
|
||||
</a>';
|
||||
}
|
||||
|
||||
echo '
|
||||
</td>
|
||||
</tr>';
|
||||
|
||||
$prev_mese = $rs[$i]['data_scadenza'];
|
||||
}
|
||||
echo '
|
||||
</table>';
|
||||
}
|
||||
echo '
|
||||
<br><br>';
|
||||
|
||||
/*
|
||||
Schema per pianificare la fatturazione per zona
|
||||
*/
|
||||
$rs = $dbo->fetchArray('SELECT id, descrizione FROM an_zone WHERE ( id IN (SELECT idzona FROM an_sedi WHERE id IN (SELECT idsede FROM my_impianti WHERE id IN (SELECT idimpianto FROM co_ordiniservizio WHERE idcontratto='.prepare($id_record).'))) ) OR ( id=(SELECT idzona FROM an_anagrafiche WHERE idanagrafica=(SELECT idanagrafica FROM co_contratti WHERE id='.prepare($id_record).") AND idzona=an_zone.id) ) UNION SELECT 0, 'Altro'");
|
||||
|
||||
if (sizeof($rs) == 0) {
|
||||
echo '
|
||||
<p>'.tr('Non sono ancora stati pianificati ordini di servizio').'...</p>';
|
||||
}
|
||||
|
||||
// Elenco voci di servizio con mesi in cui eseguirle
|
||||
else {
|
||||
// Calcolo mese iniziale e finale del contratto
|
||||
$rs2 = $dbo->fetchArray('SELECT data_accettazione, data_conclusione, TIMESTAMPDIFF( MONTH, data_accettazione, data_conclusione ) AS mesi FROM co_contratti WHERE id='.prepare($id_record));
|
||||
$n_mesi = $rs2[0]['mesi'] + 1;
|
||||
$mese_start = date('m', strtotime($rs2[0]['data_accettazione']));
|
||||
|
||||
echo "
|
||||
<button type='button' class='btn btn-primary' onclick=\"$(this).next().next().removeClass('hide'); $(this).remove();\">
|
||||
<i class='fa fa-calendar'></i> ".tr('Pianifica la fatturazione').'
|
||||
</button>
|
||||
<br>';
|
||||
|
||||
echo "
|
||||
<form action='".$rootdir.'/editor.php?id_module='.Modules::get('Contratti')['id'].'&id_record='.$id_record."&op=add_fatturazione' id='pianifica_form' method='post' class='hide'>
|
||||
<input type='hidden' name='backto' value='record-edit'>";
|
||||
|
||||
// Indice zone fatturabili
|
||||
echo '
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
{[ "type": "select", "label": "'.tr('Zone per le quali pianificare la fatturazione').'", "name": "idzona[]", "values": "query=SELECT id, descrizione FROM an_zone WHERE (id IN (SELECT idzona FROM an_sedi WHERE id IN (SELECT idsede FROM my_impianti WHERE id IN (SELECT idimpianto FROM co_ordiniservizio WHERE idcontratto='.prepare($id_record).')))) OR ( id=(SELECT idzona FROM an_anagrafiche WHERE idanagrafica=(SELECT idanagrafica FROM co_contratti WHERE id='.prepare($id_record).') AND idzona=an_zone.id) ) UNION SELECT 0, \'Altro\'", "multiple": 1, "extra": "onchange=\"$(this).find(\'option\').each( function(){ if( $(this).is(\':selected\') ){ $(\'#zona_\'+$(this).val()).removeClass(\'hide\'); }else{ $(\'#zona_\'+$(this).val()).addClass(\'hide\'); } });\"" ]}
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
// Zone
|
||||
for ($i = 0; $i < sizeof($rs); ++$i) {
|
||||
echo '
|
||||
<div class="hide" id="zona_'.$rs[$i]['id'].'">
|
||||
<big><b>'.$rs[$i]['descrizione'].'</b></big>
|
||||
<hr>
|
||||
<div class="row">';
|
||||
|
||||
for ($j = 0; $j < $n_mesi; ++$j) {
|
||||
echo '
|
||||
<div class="col-md-3">
|
||||
<small><label for="m_'.date('Ym', strtotime($rs2[0]['data_accettazione'].' +'.$j.' month')).'_'.$rs[$i]['id'].'">
|
||||
<input type="checkbox" id="m_'.date('Ym', strtotime($rs2[0]['data_accettazione'].' +'.$j.' month')).'_'.$rs[$i]['id'].'" name="zona['.date('Y-m-t', strtotime($rs2[0]['data_accettazione'].' +'.$j.' month')).'][]" value="'.$rs[$i]['id'].'" />'.$mesi[intval(date('m', strtotime($rs2[0]['data_accettazione'].' +'.$j.' month'))) - 1].' '.date('Y', strtotime($rs2[0]['data_accettazione'].' +'.$j.' month')).'
|
||||
</label></small>
|
||||
</div>';
|
||||
}
|
||||
|
||||
echo '
|
||||
</div>
|
||||
</div>';
|
||||
}
|
||||
|
||||
echo "
|
||||
|
||||
<div class='clearfix'></div>
|
||||
<br>";
|
||||
|
||||
// Pianificazione
|
||||
echo "
|
||||
<button type='button' class='btn btn-primary' onclick=\"if( $('input[type=checkbox]:checked').length>0 ){ if( confirm('Pianificare la fatturazione?') ){ $('#pianifica_form').submit(); } }\">
|
||||
<i class='fa fa-plus'></i> ".tr('Pianifica ora').'
|
||||
</button>';
|
||||
|
||||
echo '
|
||||
</form>';
|
||||
}
|
||||
|
||||
echo '
|
||||
</div>
|
||||
</div>';
|
|
@ -1,251 +0,0 @@
|
|||
<?php
|
||||
|
||||
include_once __DIR__.'/../../../core.php';
|
||||
|
||||
/*
|
||||
Salvataggio voci di servizio
|
||||
*/
|
||||
if (filter('op') == 'save_ordineservizio') {
|
||||
$n_errors = 0;
|
||||
|
||||
if (post('eseguito') !== null) {
|
||||
foreach (post('eseguito') as $idvoceservizio => $eseguito) {
|
||||
$presenza = post('presenza')[$idvoceservizio];
|
||||
$esito = post('esito')[$idvoceservizio];
|
||||
$priorita = post('priorita')[$idvoceservizio];
|
||||
|
||||
if (!$dbo->query('UPDATE co_ordiniservizio_vociservizio SET eseguito='.prepare($eseguito).', presenza='.prepare($presenza).', esito='.prepare($esito).', priorita='.prepare($priorita).', note='.prepare(post('note_ods')[$idvoceservizio]).' WHERE id='.prepare($idvoceservizio))) {
|
||||
++$n_errors;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($n_errors == 0) {
|
||||
flash()->info(tr('Voci di servizio salvate correttamente!'));
|
||||
} else {
|
||||
flash()->error(tr('Errore durante il salvataggio delle voci di servizio!'));
|
||||
}
|
||||
|
||||
// Aggiornamento 4 spunte
|
||||
$dbo->query('UPDATE co_ordiniservizio SET copia_centrale='.prepare(post('copia_centrale')).', copia_cliente='.prepare(post('copia_cliente')).', copia_amministratore='.prepare(post('copia_amministratore')).'", funzionamento_in_sicurezza='.prepare(post('funzionamento_in_sicurezza')).' WHERE idintervento='.prepare($id_record));
|
||||
}
|
||||
|
||||
/*
|
||||
Visualizzazione voci di servizio collegate a questo intervento
|
||||
*/
|
||||
// Info principali
|
||||
$rs = $dbo->fetchArray('SELECT * FROM co_ordiniservizio WHERE idintervento='.prepare($idintervento));
|
||||
$check_copia_centrale = $rs[0]['copia_centrale'];
|
||||
$check_copia_cliente = $rs[0]['copia_cliente'];
|
||||
$check_copia_amministratore = $rs[0]['copia_amministratore'];
|
||||
$check_funzionamento_in_sicurezza = $rs[0]['funzionamento_in_sicurezza'];
|
||||
|
||||
if (sizeof($rs) == 0) {
|
||||
echo '
|
||||
<p>'.tr('Nessun collegamento a ordini di servizio')."...</p>\n";
|
||||
} else {
|
||||
echo '
|
||||
<p>'.tr('Ordine di servizio numero _NUM_ (termine massimo _DATE_)', [
|
||||
'_NUM_' => '<b>'.$rs[0]['id'].'</b>',
|
||||
'_DATE_' => Translator::dateToLocale($rs[0]['data_scadenza']),
|
||||
]).':</p>';
|
||||
|
||||
$rs = $dbo->fetchArray('SELECT * FROM co_ordiniservizio_vociservizio WHERE idordineservizio=(SELECT id FROM co_ordiniservizio WHERE idintervento='.prepare($idintervento).' LIMIT 0,1) ORDER BY categoria ASC');
|
||||
|
||||
echo '
|
||||
<form action="'.$rootdir.'/editor.php?id_module='.Modules::get('Interventi')['id'].'&id_record='.$id_record.'&idordineservizio='.$rs[0]['idordineservizio'].'&op=save_ordineservizio" method="post" id="form-ordineservizio">
|
||||
<div class="row">
|
||||
<div class="col-md-9">
|
||||
<table class="table table-hover table-striped">
|
||||
<tr>
|
||||
<th width="30%">'.tr('Voce di servizio').'</th>
|
||||
<th>'.tr('Presenza').'</th>
|
||||
<th>'.tr('Eseguito').'</th>
|
||||
<th>'.tr('Esito').'</th>
|
||||
<th>'.tr('Priorità').'</th>
|
||||
<th width="30%">'.tr('Note').'</th>
|
||||
</tr>';
|
||||
|
||||
$prev_cat = '';
|
||||
|
||||
for ($i = 0; $i < sizeof($rs); ++$i) {
|
||||
if ($prev_cat != $rs[$i]['categoria']) {
|
||||
echo '
|
||||
<tr>
|
||||
<th colspan="6">'.$rs[$i]['categoria'].'</th>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
echo '
|
||||
<tr>
|
||||
<td>'.$rs[$i]['voce'].'</td>';
|
||||
|
||||
// Presenza SI
|
||||
if ($rs[$i]['presenza'] == '1') {
|
||||
$attr_si = 'checked="true"';
|
||||
$attr_no = '';
|
||||
}
|
||||
|
||||
// Presenza NO
|
||||
elseif ($rs[$i]['presenza'] == '-1') {
|
||||
$attr_si = '';
|
||||
$attr_no = 'checked="true"';
|
||||
}
|
||||
|
||||
// Nessuna spunta
|
||||
else {
|
||||
$attr_si = '';
|
||||
$attr_no = '';
|
||||
}
|
||||
|
||||
echo '
|
||||
<td>
|
||||
<div>
|
||||
<input type="radio" name="presenza['.$rs[$i]['id'].']" value="1" '.$attr_si.'> '.tr('Sì').'<br>
|
||||
<input type="radio" name="presenza['.$rs[$i]['id'].']" value="-1" '.$attr_no.'> '.tr('No').'
|
||||
</div>
|
||||
</td>';
|
||||
|
||||
// Eseguito SI
|
||||
if ($rs[$i]['eseguito'] == '1') {
|
||||
$attr_si = 'checked="true"';
|
||||
$attr_no = '';
|
||||
}
|
||||
|
||||
// Eseguito NO
|
||||
elseif ($rs[$i]['eseguito'] == '-1') {
|
||||
$attr_si = '';
|
||||
$attr_no = 'checked="true"';
|
||||
}
|
||||
|
||||
// Nessuna spunta
|
||||
else {
|
||||
$attr_si = '';
|
||||
$attr_no = '';
|
||||
}
|
||||
|
||||
echo '
|
||||
<td>
|
||||
<div>
|
||||
<input type="radio" name="eseguito['.$rs[$i]['id'].']" value="1" '.$attr_si.'> '.tr('Sì').'<br>
|
||||
<input type="radio" name="eseguito['.$rs[$i]['id'].']" value="-1" '.$attr_no.'> '.tr('No').'
|
||||
</div>
|
||||
</td>';
|
||||
|
||||
// Esito SI
|
||||
if ($rs[$i]['esito'] == '1') {
|
||||
$attr_si = 'checked="true"';
|
||||
$attr_no = '';
|
||||
}
|
||||
|
||||
// Esito NO
|
||||
elseif ($rs[$i]['esito'] == '-1') {
|
||||
$attr_si = '';
|
||||
$attr_no = 'checked="true"';
|
||||
}
|
||||
|
||||
// Nessuna spunta
|
||||
else {
|
||||
$attr_si = '';
|
||||
$attr_no = '';
|
||||
}
|
||||
|
||||
echo '
|
||||
<td>
|
||||
<div>
|
||||
<input type="radio" name="esito['.$rs[$i]['id'].']" value="1" '.$attr_si.'> '.tr('Pos.').'<br>
|
||||
<input type="radio" name="esito['.$rs[$i]['id'].']" value="-1" '.$attr_no.'> '.tr('Neg.').'
|
||||
</div>
|
||||
</td>';
|
||||
|
||||
// Priorità 1
|
||||
if ($rs[$i]['priorita'] == '1') {
|
||||
$attr_1 = 'checked="true"';
|
||||
$attr_2 = '';
|
||||
$attr_3 = '';
|
||||
}
|
||||
|
||||
// Priorità 2
|
||||
elseif ($rs[$i]['priorita'] == '2') {
|
||||
$attr_1 = '';
|
||||
$attr_2 = 'checked="true"';
|
||||
$attr_3 = '';
|
||||
}
|
||||
|
||||
// Priorità 3
|
||||
elseif ($rs[$i]['priorita'] == '3') {
|
||||
$attr_1 = '';
|
||||
$attr_2 = '';
|
||||
$attr_3 = 'checked="true"';
|
||||
}
|
||||
|
||||
// Nessuna priorità
|
||||
else {
|
||||
$attr_1 = '';
|
||||
$attr_2 = '';
|
||||
$attr_3 = '';
|
||||
}
|
||||
|
||||
echo '
|
||||
<td>
|
||||
<div>
|
||||
<input type="radio" name="priorita['.$rs[$i]['id'].']" value="3" '.$attr_si.'> '.tr('A').'<br>
|
||||
<input type="radio" name="priorita['.$rs[$i]['id'].']" value="2" '.$attr_no.'> '.tr('M').'
|
||||
<input type="radio" name="priorita['.$rs[$i]['id'].']" value="-1" '.$attr_no.'> '.tr('B').'
|
||||
</div>
|
||||
</td>';
|
||||
|
||||
echo '
|
||||
<td>
|
||||
{[ "type": "text", "name": "note_ods['.$rs[$i]['id'].']", "value": "'.$rs[$i]['note'].'" ]}
|
||||
</td>';
|
||||
|
||||
$prev_cat = $rs[$i]['categoria'];
|
||||
}
|
||||
|
||||
echo '
|
||||
</tr>
|
||||
</table>
|
||||
</div>';
|
||||
|
||||
// Parte destra
|
||||
echo '
|
||||
<div class="col-md-3">';
|
||||
|
||||
echo '
|
||||
{[ "type": "checkbox", "label": "'.tr('Consegnata copia in centrale').'", "name": "copia_centrale", "value": "'.$check_copia_centrale.'" ]}';
|
||||
|
||||
echo '
|
||||
{[ "type": "checkbox", "label": "'.tr('Consegnata copia al cliente').'", "name": "copia_cliente", "value": "'.$check_copia_cliente.'" ]}';
|
||||
|
||||
echo '
|
||||
{[ "type": "checkbox", "label": "'.tr("Consegnata copia all'amministratore").'", "name": "copia_amministratore", "value": "'.$check_copia_amministratore.'" ]}';
|
||||
|
||||
if ($check_funzionamento_in_sicurezza == '1') {
|
||||
$attr = 'checked="true"';
|
||||
} else {
|
||||
$attr = '';
|
||||
}
|
||||
echo '
|
||||
{[ "type": "checkbox", "label": "'.tr("L'impianto può funzionare in sicurezza").'", "name": "funzionamento_in_sicurezza", "value": "'.$check_funzionamento_in_sicurezza.'" ]}';
|
||||
|
||||
echo '
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="clearfix"></div>
|
||||
|
||||
<button type="button" class="btn btn-success" onclick="if( confirm(\'Salvere le modifiche?\') ){ $(\'#form-ordineservizio\').submit(); }">
|
||||
<i class="fa fa-check"></i> '.tr('Salva modifiche').'
|
||||
</button>
|
||||
|
||||
</form>';
|
||||
|
||||
/*
|
||||
Stampa intervento con voci di servizio
|
||||
*/
|
||||
echo '
|
||||
<div class="text-center">
|
||||
'.Prints::getLink('Ordine di servizio', $id_record, 'btn-primary', tr('Stampa ordine di servizio')).'
|
||||
</div>';
|
||||
}
|
|
@ -1,361 +0,0 @@
|
|||
<?php
|
||||
|
||||
include_once __DIR__.'/../../../core.php';
|
||||
|
||||
/*
|
||||
GESTIONE ORDINI DI SERVIZIO
|
||||
*/
|
||||
// TODO: aggiornare con la funzione months()
|
||||
$mesi = [
|
||||
tr('Gennaio'),
|
||||
tr('Febbraio'),
|
||||
tr('Marzo'),
|
||||
tr('Aprile'),
|
||||
tr('Maggio'),
|
||||
tr('Giugno'),
|
||||
tr('Luglio'),
|
||||
tr('Agosto'),
|
||||
tr('Settembre'),
|
||||
tr('Ottobre'),
|
||||
tr('Novembre'),
|
||||
tr('Dicembre'),
|
||||
];
|
||||
|
||||
// Generazione ordini di servizio
|
||||
if (get('op') == 'add_ordineservizio') {
|
||||
$prev_data = '';
|
||||
|
||||
// Ciclo fra le voci in arrivo dal form
|
||||
foreach (post('voce') as $data_scadenza => $ordiniservizio) {
|
||||
$data_scadenza = date_create_from_format('Ym', $data_scadenza)->format(Intl\Formatter::getStandardFormats()['date']);
|
||||
|
||||
// Ogni data può avere più voci di servizio da salvare
|
||||
foreach ($ordiniservizio as $n => $idvoce) {
|
||||
// Aggiunta ordine di servizio solo se la voce è spuntata
|
||||
if (in_array($idvoce, post('idvoce'))) {
|
||||
// Creazione ordine di servizio per data di scadenza
|
||||
if ($prev_data != $data_scadenza) {
|
||||
$dbo->query('INSERT INTO co_ordiniservizio(idcontratto, data_scadenza, idimpianto, stato) VALUES('.prepare($id_record).', '.prepare($data_scadenza).', '.prepare(post('matricola')).", 'aperto')");
|
||||
$idordineservizio = $dbo->lastInsertedID();
|
||||
}
|
||||
|
||||
$dbo->query('INSERT INTO co_ordiniservizio_vociservizio(idordineservizio, voce, categoria, eseguito) VALUES('.prepare($idordineservizio).', (SELECT descrizione FROM in_vociservizio WHERE id='.prepare($idvoce).'), (SELECT categoria FROM in_vociservizio WHERE id='.prepare($idvoce).'), 0 )');
|
||||
}
|
||||
|
||||
$prev_data = $data_scadenza;
|
||||
}
|
||||
}
|
||||
|
||||
flash()->info(tr('Ordini di servizio generati correttamente!'));
|
||||
}
|
||||
|
||||
// Eliminazione pianificazione specifica
|
||||
elseif (get('op') == 'del_ordineservizio') {
|
||||
$idordineservizio = get('idordineservizio');
|
||||
|
||||
$n = $dbo->fetchNum('SELECT id FROM co_ordiniservizio WHERE id='.prepare($idordineservizio)." AND stato='aperto'");
|
||||
|
||||
if ($n == 1) {
|
||||
// Eliminazione ordine di servizio
|
||||
if ($dbo->query('DELETE FROM co_ordiniservizio WHERE id='.prepare($idordineservizio))) {
|
||||
// Eliminazione voci di servizio collegate
|
||||
$dbo->query('DELETE FROM co_ordiniservizio_vociservizio WHERE idordineservizio='.prepare($idordineservizio));
|
||||
|
||||
flash()->info(tr('Ordine di servizio eliminato correttamente!'));
|
||||
}
|
||||
}
|
||||
|
||||
// Non si può eliminare l'ordine di servizio perché è chiuso
|
||||
else {
|
||||
flash()->info(tr('Ordine di servizio già chiuso, impossibile eliminarlo!'));
|
||||
}
|
||||
}
|
||||
|
||||
echo '
|
||||
<div class="box">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">'.tr('Pianificazione ordini di servizio').'</h3>
|
||||
</div>
|
||||
<div class="box-body">';
|
||||
|
||||
echo '
|
||||
<p>'.tr('Qui puoi programmare gli ordini di servizio del contratto').'.</p>';
|
||||
|
||||
/*
|
||||
Ordini di servizio pianificati
|
||||
*/
|
||||
|
||||
// (SELECT idsede FROM my_impianti WHERE idimpianto=co_ordiniservizio.idimpianto)
|
||||
|
||||
$rs = $dbo->fetchArray("SELECT *, (SELECT CONCAT_WS(' ', nomesede, citta) FROM an_sedi WHERE id=(SELECT idsede FROM my_impianti WHERE idimpianto=co_ordiniservizio.idimpianto LIMIT 0,1)) AS sede, (SELECT CONCAT_WS(' - ', matricola, nome) FROM my_impianti WHERE id=co_ordiniservizio.idimpianto) AS impianto, (SELECT MIN(orario_inizio) FROM in_interventi_tecnici WHERE idintervento=co_ordiniservizio.idintervento) AS data_intervento FROM co_ordiniservizio WHERE idcontratto=".prepare($id_record).' ORDER BY data_scadenza ASC');
|
||||
|
||||
if (empty($rs)) {
|
||||
echo '
|
||||
<p>'.tr('Non sono ancora stati pianificati ordini di servizio').'...</p>';
|
||||
} else {
|
||||
echo '
|
||||
<table class="table table-striped table-hover table-bordered table-condensed">
|
||||
<tr>
|
||||
<th width="10%">'.tr('Entro').'</th>
|
||||
<th>'.tr('Sede').'</th>
|
||||
<th width="20%">'.tr('Impianto').'</th>
|
||||
<th width="10%">'.tr('Voci di servizio').'</th>
|
||||
<th width="10%">'.tr('Stato').'</th>
|
||||
<th width="3%"></th>
|
||||
</tr>';
|
||||
|
||||
$prev_mese = '';
|
||||
|
||||
foreach ($rs as $r) {
|
||||
echo '
|
||||
<tr>
|
||||
<td>';
|
||||
// Data scadenza
|
||||
if ($prev_mese != $r['data_scadenza']) {
|
||||
echo '
|
||||
<b>'.$mesi[intval(date('m', strtotime($r['data_scadenza']))) - 1].' '.date('Y', strtotime($r['data_scadenza'])).'</b>
|
||||
</td>';
|
||||
} else {
|
||||
echo '
|
||||
<small><em>'.$mesi[intval(date('m', strtotime($r['data_scadenza']))) - 1].' '.date('Y', strtotime($r['data_scadenza'])).'</em></small>';
|
||||
}
|
||||
|
||||
// Sede
|
||||
if ($r['sede'] == '') {
|
||||
$sede = 'Sede legale';
|
||||
} else {
|
||||
$sede = $r['sede'];
|
||||
}
|
||||
|
||||
echo '
|
||||
<td>'.$sede.'</td>';
|
||||
|
||||
// Impianto
|
||||
echo '
|
||||
<td>
|
||||
'.Modules::link('MyImpianti', $r['idimpianto'], $r['impianto']).'
|
||||
</td>';
|
||||
|
||||
// Voci di servizio
|
||||
$rs2 = $dbo->fetchArray('SELECT * FROM co_ordiniservizio_vociservizio WHERE idordineservizio='.prepare($r['id']).' ORDER BY categoria ASC');
|
||||
|
||||
echo '
|
||||
<td class="text-center">
|
||||
<button type="button" class="btn btn-primary btn-sm" onclick="launch_modal(\'Pianifica intervento\', \'#voci_'.$r['id'].'\' );">
|
||||
<i class="fa fa-list"></i> '.tr('Visualizza').'... ('.sizeof($rs2).')
|
||||
</button>';
|
||||
|
||||
// Popup voci di servizio
|
||||
echo '
|
||||
<div class="hide">
|
||||
<div id="voci_'.$r['id'].'">';
|
||||
|
||||
if (empty($rs2)) {
|
||||
echo '
|
||||
<p>'.tr('Non sono state pianificate voci di servizio').'...</p>';
|
||||
} else {
|
||||
echo '
|
||||
<table class="table table-bordered table-condensed table-hover table-striped">
|
||||
<tr>
|
||||
<th>'.tr('Voci di servizio').'</th>
|
||||
<th width="40%">'.tr('Eseguito').'</th>
|
||||
</tr>';
|
||||
|
||||
$prev_cat = '';
|
||||
|
||||
for ($v = 0; $v < sizeof($rs2); ++$v) {
|
||||
if ($rs2[$v]['categoria'] != $prev_cat) {
|
||||
echo '
|
||||
<tr>
|
||||
<th colspan="2">'.$rs2[$v]['categoria'].'</th>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
echo '
|
||||
<tr>
|
||||
<td>'.$rs2[$v]['voce'].'</td>
|
||||
|
||||
<td>';
|
||||
|
||||
// intervento non ancora eseguito
|
||||
if (empty($r['idintervento'])) {
|
||||
echo '
|
||||
<span class="text-warning">
|
||||
<i class="fa fa-clock-o"></i> '.tr('non ancora eseguito').'
|
||||
</span>';
|
||||
} else {
|
||||
$res = $dbo->fetchArray('SELECT codice FROM in_interventi WHERE id='.prepare($rsp[$i]['idintervento']));
|
||||
|
||||
echo '
|
||||
<span class="text-success">
|
||||
<i class="fa fa-check"></i>
|
||||
'.Modules::link('Interventi', $r['idintervento'], tr('Intervento num. _NUM_ del _DATE_', [
|
||||
'_NUM_' => $res['codice'],
|
||||
'_DATE_' => Translator::dateToLocale($r[0]['data_intervento']),
|
||||
])).'
|
||||
</span>';
|
||||
}
|
||||
echo '
|
||||
</td>
|
||||
</tr>';
|
||||
|
||||
$prev_cat = $rs2[$v]['categoria'];
|
||||
}
|
||||
|
||||
echo '
|
||||
</table>';
|
||||
}
|
||||
echo '
|
||||
</div>
|
||||
</div>
|
||||
</td>';
|
||||
|
||||
// Stato
|
||||
echo '
|
||||
<td class="text-center">';
|
||||
if (empty($r['idintervento'])) {
|
||||
echo '
|
||||
<span class="text-warning"><i class="fa fa-clock-o"></i> '.tr('aperto').'</span>';
|
||||
} else {
|
||||
echo '
|
||||
<span class="text-success"><i class="fa fa-check"></i> '.tr('chiuso').'/span>';
|
||||
}
|
||||
echo '
|
||||
</td>';
|
||||
|
||||
// Funzioni
|
||||
echo '
|
||||
<td>';
|
||||
if (empty($r['idintervento'])) {
|
||||
echo '
|
||||
<a class="btn btn-danger ask" data-backto="record-edit" data-method="get" data-op="del_ordineservizio" data-idordineservizio="'.$r['id'].'" data-msg="'.tr('Vuoi eliminare questa pianificazione?').'">
|
||||
<i class="fa fa-trash"></i>
|
||||
</a>';
|
||||
}
|
||||
|
||||
echo '
|
||||
</td>
|
||||
</tr>';
|
||||
|
||||
$prev_mese = $r['data_scadenza'];
|
||||
}
|
||||
echo '
|
||||
</table>';
|
||||
}
|
||||
|
||||
echo '
|
||||
<br><br>';
|
||||
|
||||
/*
|
||||
Schema per aggiungere ordini di servizio
|
||||
*/
|
||||
$rs = $dbo->fetchArray('SELECT * FROM in_vociservizio ORDER BY categoria ASC');
|
||||
|
||||
if (empty($rs)) {
|
||||
echo '
|
||||
<p>
|
||||
'.tr('Non sono ancora state inserite voci di servizio').'.
|
||||
<a href="'.$rootdir.'/controller.php?id_module='.Modules::get('Voci di servizio')['id'].'">'.tr('Inizia ora').'...</a>
|
||||
</p>';
|
||||
}
|
||||
|
||||
// Elenco voci di servizio con mesi in cui eseguirle
|
||||
else {
|
||||
// Calcolo mese iniziale e finale del contratto
|
||||
$rs2 = $dbo->fetchArray('SELECT data_accettazione, data_conclusione, TIMESTAMPDIFF(MONTH, data_accettazione, data_conclusione) AS mesi FROM co_contratti WHERE id='.prepare($id_record));
|
||||
|
||||
if (!empty($rs2[0]['data_accettazione']) && !empty($rs2[0]['data_conclusione'])) {
|
||||
$n_mesi = $rs2[0]['mesi'] + 1;
|
||||
$mese_start = date('m', strtotime($rs2[0]['data_accettazione']));
|
||||
|
||||
echo '
|
||||
<button type="button" class="btn btn-primary" onclick="$(this).next().removeClass(\'hide\'); $(this).remove();">
|
||||
<i class="fa fa-calendar"></i> '.tr('Pianifica nuovi ordini di servizio').'
|
||||
</button>
|
||||
|
||||
<form action="'.$rootdir.'/editor.php?id_module='.Modules::get('Contratti')['id'].'&id_record='.$id_record.'&op=add_ordineservizio" id="plan_form" method="post" class="no-check hide">
|
||||
<input type="hidden" name="backto" value="record-edit">';
|
||||
|
||||
// Selezione impianto
|
||||
echo '
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
{[ "type": "select", "label": "'.tr('Impianto').'", "name": "matricola", "values": "query=SELECT my_impianti.id, CONCAT(my_impianti.matricola, \" - \", my_impianti.nome) AS descrizione, an_sedi.optgroup FROM my_impianti INNER JOIN (SELECT id, CONCAT(an_sedi.nomesede, \"(\", an_sedi.citta, \")\") AS optgroup FROM an_sedi WHERE idanagrafica='.prepare($record['idanagrafica']).' UNION SELECT 0, \'Sede legale\') AS an_sedi ON my_impianti.idsede = an_sedi.id WHERE my_impianti.idanagrafica='.prepare($record['idanagrafica']).' AND my_impianti.id NOT IN(SELECT idimpianto FROM co_ordiniservizio WHERE idcontratto='.prepare($id_record).') ORDER BY idsede ASC, matricola ASC" ]}
|
||||
</div>';
|
||||
|
||||
// Indice voci di servizio
|
||||
echo '
|
||||
<div class="col-md-6">
|
||||
{[ "type": "select", "label": "'.tr('Voci di servizio da pianificare').'", "name": "idvoce[]", "values": "query=SELECT id, descrizione, categoria AS optgroup FROM in_vociservizio ORDER BY categoria ASC", "multiple": 1, "extra": "onchange=\"$(this).find(\'option\').each( function(){ if( $(this).is(\':selected\') ){ $(\'#voce_\'+$(this).val()).removeClass(\'hide\'); }else{ $(\'#voce_\'+$(this).val()).addClass(\'hide\'); } });\"" ]}
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
// voci di servizio
|
||||
foreach ($rs as $r) {
|
||||
echo '
|
||||
<div class="col-md-3 hide" id="voce_'.$r['id'].'">
|
||||
<big><b>'.$r['id'].' - '.$r['descrizione'].'</b></big>
|
||||
<hr>';
|
||||
|
||||
for ($j = 0; $j < $n_mesi; ++$j) {
|
||||
$id_mese = date('Ym', strtotime($rs2[0]['data_accettazione'].' +'.$j.' month'));
|
||||
$nome_mese = $mesi[intval(date('m', strtotime($rs2[0]['data_accettazione'].' +'.$j.' month'))) - 1].' '.date('Y', strtotime($rs2[0]['data_accettazione'].' +'.$j.' month'));
|
||||
echo '
|
||||
<small>
|
||||
<label for="m_'.$id_mese.'_'.$r['id'].'">
|
||||
<input type="checkbox" id="m_'.$id_mese.'_'.$r['id'].'" name="voce['.$id_mese.'][]" value="'.$r['id'].'">
|
||||
'.$nome_mese.'
|
||||
</label>
|
||||
</small><br>';
|
||||
}
|
||||
|
||||
echo '
|
||||
</div>';
|
||||
}
|
||||
|
||||
echo '
|
||||
<div class="clearfix"></div><br>';
|
||||
|
||||
echo '
|
||||
<button type="button" class="btn btn-primary" onclick="if($(\'#matricola\').val() && $(\'#idvoce\').val() ){ if( confirm(\'Pianificare questo ordine di servizio?\') ){ $(\'#plan_form\').submit(); } } else { if ( !$(\'#matricola\').val()) {alert (\'Seleziona un impianto.\'); $(\'#matricola\').focus();}else { alert (\'Seleziona le voci di servizio da pianificare.\'); $(\'#idvoce\').focus(); } }">
|
||||
<i class="fa fa-plus"></i> '.tr('Aggiungi').'
|
||||
</button>';
|
||||
|
||||
/*
|
||||
Copia pianificazione da una già fatta per un impianto ad un'altra
|
||||
*/
|
||||
// Opzione di copia pianificazione solo se ci sono ancora impianti non pianificati
|
||||
$query2 = 'SELECT * FROM my_impianti WHERE idanagrafica='.prepare($record['idanagrafica']).' AND id IN (SELECT idimpianto FROM co_ordiniservizio WHERE idcontratto='.prepare($id_record).')';
|
||||
$cont = $dbo->fetchNum($query2);
|
||||
|
||||
if ($cont > 0) {
|
||||
// Elenco impianti già pianificati
|
||||
echo '
|
||||
<hr>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
{[ "type": "select", "label": "'.tr('Copiare la pianificazione da un altro impianto').'", "name": "matricola_src", "values": "query=SELECT my_impianti.id, CONCAT(my_impianti.matricola, \" - \", my_impianti.nome) AS descrizione, an_sedi.optgroup FROM my_impianti INNER JOIN (SELECT id, CONCAT(an_sedi.nomesede, \"(\", an_sedi.citta, \")\") AS optgroup FROM an_sedi WHERE idanagrafica='.prepare($record['idanagrafica']).' UNION SELECT 0, \'Sede legale\') AS an_sedi ON my_impianti.idsede = an_sedi.id WHERE my_impianti.idanagrafica='.prepare($record['idanagrafica']).' AND my_impianti.id IN(SELECT idimpianto FROM co_ordiniservizio WHERE idcontratto='.prepare($id_record).') ORDER BY idsede ASC, matricola ASC" ]}
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
echo '
|
||||
<div class="clearfix"></div><br>';
|
||||
|
||||
echo '
|
||||
<button type="button" class="btn btn-primary" onclick="copia_pianificazione_os( \''.$id_record.'\', $(\'#matricola_src option:selected\').val() );">
|
||||
<i class="fa fa-upload"></i>'.tr('Carica questa pianificazione').'
|
||||
</button>';
|
||||
}
|
||||
|
||||
echo '
|
||||
</form>';
|
||||
} else {
|
||||
echo '
|
||||
<p>'.tr('Le date di accettazione e conclusione del contratto non sono ancora state impostate').'</p>';
|
||||
}
|
||||
}
|
||||
|
||||
echo '
|
||||
</div>
|
||||
</div>';
|
|
@ -160,159 +160,6 @@ function add_tecnico($idintervento, $idtecnico, $inizio, $fine, $idcontratto = n
|
|||
return true;
|
||||
}
|
||||
|
||||
function get_costi_intervento($id_intervento)
|
||||
{
|
||||
$dbo = database();
|
||||
|
||||
$decimals = setting('Cifre decimali per importi');
|
||||
|
||||
$idiva = setting('Iva predefinita');
|
||||
$rs_iva = $dbo->fetchArray('SELECT descrizione, percentuale, indetraibile FROM co_iva WHERE id='.prepare($idiva));
|
||||
|
||||
$tecnici = $dbo->fetchArray('SELECT
|
||||
|
||||
COALESCE(SUM(
|
||||
ROUND(prezzo_ore_unitario_tecnico*ore, '.$decimals.')
|
||||
), 0) AS manodopera_costo,
|
||||
COALESCE(SUM(
|
||||
ROUND(prezzo_ore_unitario*ore, '.$decimals.')
|
||||
), 0) AS manodopera_addebito,
|
||||
COALESCE(SUM(
|
||||
ROUND(prezzo_ore_unitario*ore, '.$decimals.') - ROUND(sconto, '.$decimals.')
|
||||
), 0) AS manodopera_scontato,
|
||||
|
||||
|
||||
COALESCE(SUM(
|
||||
ROUND(prezzo_dirittochiamata_tecnico, '.$decimals.')
|
||||
), 0) AS dirittochiamata_costo,
|
||||
COALESCE(SUM(
|
||||
ROUND(prezzo_dirittochiamata, '.$decimals.')
|
||||
), 0) AS dirittochiamata_addebito,
|
||||
COALESCE(SUM(
|
||||
ROUND(prezzo_dirittochiamata, '.$decimals.')
|
||||
), 0) AS dirittochiamata_scontato,
|
||||
|
||||
COALESCE(SUM(
|
||||
ROUND(prezzo_km_consuntivo_tecnico, '.$decimals.')
|
||||
), 0) AS viaggio_costo,
|
||||
COALESCE(SUM(
|
||||
ROUND(prezzo_km_consuntivo, '.$decimals.')
|
||||
), 0) viaggio_addebito,
|
||||
COALESCE(SUM(
|
||||
ROUND(prezzo_km_consuntivo, '.$decimals.') - ROUND(scontokm, '.$decimals.')
|
||||
), 0) AS viaggio_scontato
|
||||
|
||||
FROM in_interventi_tecnici WHERE idintervento='.prepare($id_intervento));
|
||||
|
||||
$articoli = $dbo->fetchArray('SELECT
|
||||
COALESCE(SUM(
|
||||
ROUND(prezzo_acquisto, '.$decimals.') * ROUND(qta, '.$decimals.')
|
||||
), 0) AS ricambi_costo,
|
||||
COALESCE(SUM(
|
||||
ROUND(prezzo_vendita, '.$decimals.') * ROUND(qta, '.$decimals.')
|
||||
), 0) AS ricambi_addebito,
|
||||
COALESCE(SUM(
|
||||
ROUND(prezzo_vendita, '.$decimals.') * ROUND(qta, '.$decimals.') - ROUND(sconto, '.$decimals.')
|
||||
), 0) AS ricambi_scontato,
|
||||
ROUND(
|
||||
(SELECT percentuale FROM co_iva WHERE co_iva.id=mg_articoli_interventi.idiva), '.$decimals.'
|
||||
) AS ricambi_iva
|
||||
|
||||
FROM mg_articoli_interventi WHERE idintervento='.prepare($id_intervento));
|
||||
|
||||
$altro = $dbo->fetchArray('SELECT
|
||||
COALESCE(SUM(
|
||||
ROUND(prezzo_acquisto, '.$decimals.') * ROUND(qta, '.$decimals.')
|
||||
), 0) AS altro_costo,
|
||||
COALESCE(SUM(
|
||||
ROUND(prezzo_vendita, '.$decimals.') * ROUND(qta, '.$decimals.')
|
||||
), 0) AS altro_addebito,
|
||||
COALESCE(SUM(
|
||||
ROUND(prezzo_vendita, '.$decimals.') * ROUND(qta, '.$decimals.') - ROUND(sconto, '.$decimals.')
|
||||
), 0) AS altro_scontato,
|
||||
ROUND(
|
||||
(SELECT percentuale FROM co_iva WHERE co_iva.id=in_righe_interventi.idiva), '.$decimals.'
|
||||
) AS altro_iva
|
||||
|
||||
FROM in_righe_interventi WHERE idintervento='.prepare($id_intervento));
|
||||
|
||||
$result = array_merge($tecnici[0], $articoli[0], $altro[0]);
|
||||
|
||||
$result['totale_costo'] = sum([
|
||||
$result['manodopera_costo'],
|
||||
$result['dirittochiamata_costo'],
|
||||
$result['viaggio_costo'],
|
||||
$result['ricambi_costo'],
|
||||
$result['altro_costo'],
|
||||
]);
|
||||
|
||||
$result['totale_addebito'] = sum([
|
||||
$result['manodopera_addebito'],
|
||||
$result['dirittochiamata_addebito'],
|
||||
$result['viaggio_addebito'],
|
||||
$result['ricambi_addebito'],
|
||||
$result['altro_addebito'],
|
||||
]);
|
||||
|
||||
$result['totale_scontato'] = sum([
|
||||
$result['manodopera_scontato'],
|
||||
$result['dirittochiamata_scontato'],
|
||||
$result['viaggio_scontato'],
|
||||
$result['ricambi_scontato'],
|
||||
$result['altro_scontato'],
|
||||
]);
|
||||
|
||||
$result['iva_costo'] = sum([
|
||||
$result['manodopera_costo'] * $rs_iva[0]['percentuale'] / 100,
|
||||
$result['dirittochiamata_costo'] * $rs_iva[0]['percentuale'] / 100,
|
||||
$result['viaggio_costo'] * $rs_iva[0]['percentuale'] / 100,
|
||||
$result['ricambi_costo'] * $result['ricambi_iva'] / 100,
|
||||
$result['altro_costo'] * $result['altro_iva'] / 100,
|
||||
]);
|
||||
|
||||
$result['iva_addebito'] = sum([
|
||||
$result['manodopera_addebito'] * $rs_iva[0]['percentuale'] / 100,
|
||||
$result['dirittochiamata_addebito'] * $rs_iva[0]['percentuale'] / 100,
|
||||
$result['viaggio_addebito'] * $rs_iva[0]['percentuale'] / 100,
|
||||
$result['ricambi_addebito'] * $result['ricambi_iva'] / 100,
|
||||
$result['altro_addebito'] * $result['altro_iva'] / 100,
|
||||
]);
|
||||
|
||||
$result['iva_totale'] = sum([
|
||||
$result['manodopera_scontato'] * $rs_iva[0]['percentuale'] / 100,
|
||||
$result['dirittochiamata_scontato'] * $rs_iva[0]['percentuale'] / 100,
|
||||
$result['viaggio_scontato'] * $rs_iva[0]['percentuale'] / 100,
|
||||
$result['ricambi_scontato'] * $result['ricambi_iva'] / 100,
|
||||
$result['altro_scontato'] * $result['altro_iva'] / 100,
|
||||
]);
|
||||
|
||||
$result['totaleivato_costo'] = sum([
|
||||
$result['manodopera_costo'] + ($result['manodopera_costo'] * $rs_iva[0]['percentuale'] / 100),
|
||||
$result['dirittochiamata_costo'] + ($result['dirittochiamata_costo'] * $rs_iva[0]['percentuale'] / 100),
|
||||
$result['viaggio_costo'] + ($result['viaggio_costo'] * $rs_iva[0]['percentuale'] / 100),
|
||||
$result['ricambi_costo'] + ($result['ricambi_costo'] * $result['ricambi_iva'] / 100),
|
||||
$result['altro_costo'] + ($result['altro_costo'] * $result['altro_iva'] / 100),
|
||||
]);
|
||||
|
||||
$result['totaleivato_addebito'] = sum([
|
||||
$result['manodopera_addebito'] + ($result['manodopera_addebito'] * $rs_iva[0]['percentuale'] / 100),
|
||||
$result['dirittochiamata_addebito'] + ($result['dirittochiamata_addebito'] * $rs_iva[0]['percentuale'] / 100),
|
||||
$result['viaggio_addebito'] + ($result['viaggio_addebito'] * $rs_iva[0]['percentuale'] / 100),
|
||||
$result['ricambi_addebito'] + ($result['ricambi_addebito'] * $result['ricambi_iva'] / 100),
|
||||
$result['altro_addebito'] + ($result['altro_addebito'] * $result['altro_iva'] / 100),
|
||||
]);
|
||||
|
||||
$result['totale'] = sum([
|
||||
$result['manodopera_scontato'] + ($result['manodopera_scontato'] * $rs_iva[0]['percentuale'] / 100),
|
||||
$result['dirittochiamata_scontato'] + ($result['dirittochiamata_scontato'] * $rs_iva[0]['percentuale'] / 100),
|
||||
$result['viaggio_scontato'] + ($result['viaggio_scontato'] * $rs_iva[0]['percentuale'] / 100),
|
||||
$result['ricambi_scontato'] + ($result['ricambi_scontato'] * $result['ricambi_iva'] / 100),
|
||||
$result['altro_scontato'] + ($result['altro_scontato'] * $result['altro_iva'] / 100),
|
||||
]);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calcola le ore presenti tra due date.
|
||||
*
|
||||
|
|
|
@ -6,6 +6,7 @@ use Common\Model;
|
|||
use Modules\Anagrafiche\Anagrafica;
|
||||
use Modules\Interventi\Intervento;
|
||||
use Modules\Iva\Aliquota;
|
||||
use Modules\TipiIntervento\Tipo as TipoSessione;
|
||||
|
||||
/**
|
||||
* Notazione: i costi sono rivolti all'azienda, i prezzi al cliente.
|
||||
|
@ -32,6 +33,11 @@ class Sessione extends Model
|
|||
return $this->belongsTo(Anagrafica::class, 'idtecnico');
|
||||
}
|
||||
|
||||
public function tipo()
|
||||
{
|
||||
return $this->belongsTo(TipoSessione::class, 'idtipointervento');
|
||||
}
|
||||
|
||||
public function parent()
|
||||
{
|
||||
return $this->belongsTo(Intervento::class, $this->getParentID());
|
||||
|
|
|
@ -13,6 +13,8 @@ class Intervento extends Document
|
|||
{
|
||||
protected $table = 'in_interventi';
|
||||
|
||||
protected $info = [];
|
||||
|
||||
/**
|
||||
* Crea un nuovo preventivo.
|
||||
*
|
||||
|
@ -41,11 +43,46 @@ class Intervento extends Document
|
|||
|
||||
public function getOreTotaliAttribute()
|
||||
{
|
||||
$sessioni = $this->sessioni;
|
||||
if (!isset($this->info['ore_totali'])) {
|
||||
$sessioni = $this->sessioni;
|
||||
|
||||
$ore = $sessioni->sum('ore');
|
||||
$this->info['ore_totali'] = $sessioni->sum('ore');
|
||||
}
|
||||
|
||||
return $ore;
|
||||
return $this->info['ore_totali'];
|
||||
}
|
||||
|
||||
public function getKmTotaliAttribute()
|
||||
{
|
||||
if (!isset($this->info['km_totali'])) {
|
||||
$sessioni = $this->sessioni;
|
||||
|
||||
$this->info['km_totali'] = $sessioni->sum('km');
|
||||
}
|
||||
|
||||
return $this->info['km_totali'];
|
||||
}
|
||||
|
||||
public function getInizioAttribute()
|
||||
{
|
||||
if (!isset($this->info['inizio'])) {
|
||||
$sessioni = $this->sessioni;
|
||||
|
||||
$this->info['inizio'] = $sessioni->min('orario_inizio');
|
||||
}
|
||||
|
||||
return $this->info['inizio'];
|
||||
}
|
||||
|
||||
public function getFineAttribute()
|
||||
{
|
||||
if (!isset($this->info['fine'])) {
|
||||
$sessioni = $this->sessioni;
|
||||
|
||||
$this->info['fine'] = $sessioni->max('orario_fine');
|
||||
}
|
||||
|
||||
return $this->info['fine'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -490,6 +490,8 @@ class Prints
|
|||
include self::filepath($id_print, 'top.php');
|
||||
$top = ob_get_clean();
|
||||
|
||||
$top = str_replace(array_keys($replaces), array_values($replaces), $top);
|
||||
|
||||
$mpdf->WriteHTML($top);
|
||||
|
||||
foreach ($records as $record) {
|
||||
|
@ -504,6 +506,8 @@ class Prints
|
|||
include self::filepath($id_print, 'bottom.php');
|
||||
$bottom = ob_get_clean();
|
||||
|
||||
$bottom = str_replace(array_keys($replaces), array_values($replaces), $bottom);
|
||||
|
||||
$mpdf->WriteHTML($bottom);
|
||||
|
||||
$report = '';
|
||||
|
|
|
@ -1,643 +0,0 @@
|
|||
<?php
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
echo '
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
<div class="text-center">
|
||||
<h4 class="text-bold">'.tr('Consuntivo', [], ['upper' => true]).'</h4>
|
||||
<b>'.tr('Contratto num. _NUM_ del _DATE_', [
|
||||
'_NUM_' => $records[0]['numero'],
|
||||
'_DATE_' => Translator::dateToLocale($records[0]['data']),
|
||||
], ['upper' => true]).'</b>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-5 col-xs-offset-1">
|
||||
<table class="table" style="width:100%;margin-top:5mm;">
|
||||
<tr>
|
||||
<td colspan=2 class="border-full" style="height:16mm;">
|
||||
<p class="small-bold">'.tr('Spett.le', [], ['upper' => true]).'</p>
|
||||
<p>$c_ragionesociale$</p>
|
||||
<p>$c_indirizzo$ $c_citta_full$</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="border-bottom border-left">
|
||||
<p class="small-bold">'.tr('Partita IVA', [], ['upper' => true]).'</p>
|
||||
</td>
|
||||
<td class="border-right border-bottom text-right">
|
||||
<small>$c_piva$</small>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="border-bottom border-left">
|
||||
<p class="small-bold">'.tr('Codice fiscale', [], ['upper' => true]).'</p>
|
||||
</td>
|
||||
<td class="border-right border-bottom text-right">
|
||||
<small>$c_codicefiscale$</small>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
// Descrizione
|
||||
if (!empty($records[0]['descrizione'])) {
|
||||
echo '
|
||||
<p>'.nl2br($records[0]['descrizione']).'</p>
|
||||
<br>';
|
||||
}
|
||||
|
||||
$totale_ore_impiegate = 0;
|
||||
|
||||
$sconto = [];
|
||||
$imponibile = [];
|
||||
|
||||
$interventi = $dbo->fetchArray('SELECT in_interventi.id, in_interventi.codice,
|
||||
(SELECT GROUP_CONCAT(DISTINCT ragione_sociale) FROM in_interventi_tecnici JOIN an_anagrafiche ON an_anagrafiche.idanagrafica = in_interventi_tecnici.idtecnico WHERE idintervento=in_interventi.id) AS tecnici,
|
||||
(SELECT MIN(orario_inizio) FROM in_interventi_tecnici WHERE idintervento=in_interventi.id) AS inizio,
|
||||
(SELECT SUM(ore) FROM in_interventi_tecnici WHERE idintervento=in_interventi.id) AS ore,
|
||||
(SELECT MIN(km) FROM in_interventi_tecnici WHERE idintervento=in_interventi.id) AS km
|
||||
FROM co_promemoria
|
||||
INNER JOIN in_interventi ON co_promemoria.idintervento=in_interventi.id
|
||||
WHERE co_promemoria.idcontratto='.prepare($id_record).'
|
||||
UNION
|
||||
SELECT in_interventi.id, in_interventi.codice,
|
||||
(SELECT GROUP_CONCAT(DISTINCT ragione_sociale) FROM in_interventi_tecnici JOIN an_anagrafiche ON an_anagrafiche.idanagrafica = in_interventi_tecnici.idtecnico WHERE idintervento=in_interventi.id) AS tecnici,
|
||||
(SELECT MIN(orario_inizio) FROM in_interventi_tecnici WHERE idintervento=in_interventi.id) AS inizio,
|
||||
(SELECT SUM(ore) FROM in_interventi_tecnici WHERE idintervento=in_interventi.id) AS ore,
|
||||
(SELECT MIN(km) FROM in_interventi_tecnici WHERE idintervento=in_interventi.id) AS km
|
||||
FROM in_interventi
|
||||
WHERE id_contratto = '.prepare($id_record).'
|
||||
ORDER BY id DESC');
|
||||
|
||||
if (!empty($interventi)) {
|
||||
// Interventi
|
||||
echo "
|
||||
<table class='table table-striped table-bordered' id='contents'>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class='text-center' style='width:50%'>".tr('Attività', [], ['upper' => true])."</th>
|
||||
<th class='text-center' style='width:10%'>".tr('Ore', [], ['upper' => true])."</th>
|
||||
<th class='text-center' style='width:15%'>".tr('Km', [], ['upper' => true])."</th>
|
||||
<th class='text-center' style='width:15%'>".tr('Sconto', [], ['upper' => true])."</th>
|
||||
<th class='text-center' style='width:10%'>".tr('Imponibile', [], ['upper' => true]).'</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>';
|
||||
|
||||
$ore = [];
|
||||
$km = [];
|
||||
$sconto_int = [];
|
||||
$imponibile_int = [];
|
||||
|
||||
foreach ($interventi as $int) {
|
||||
$int = array_merge($int, get_costi_intervento($int['id']));
|
||||
$int['sconto'] = ($int['manodopera_addebito'] - $int['manodopera_scontato']) + ($int['viaggio_addebito'] - $int['viaggio_scontato']);
|
||||
$int['subtotale'] = $int['manodopera_scontato'] + $int['viaggio_scontato'];
|
||||
|
||||
echo '
|
||||
<tr>
|
||||
<td>
|
||||
'.tr('Intervento num. _NUM_ del _DATE_', [
|
||||
'_NUM_' => $int['codice'],
|
||||
'_DATE_' => Translator::dateToLocale($int['inizio']),
|
||||
]);
|
||||
|
||||
if (!empty($int['tecnici'])) {
|
||||
echo '
|
||||
<br><small class="text-muted">'.tr('Tecnici').': '.str_replace(',', ', ', $int['tecnici']).'.</small>';
|
||||
}
|
||||
|
||||
echo '
|
||||
</td>';
|
||||
|
||||
echo '
|
||||
<td class="text-center">
|
||||
'.Translator::numberToLocale($int['ore']).'
|
||||
</td>
|
||||
|
||||
<td class="text-center">
|
||||
'.Translator::numberToLocale($int['km']).'
|
||||
</td>';
|
||||
|
||||
if ($options['pricing']) {
|
||||
echo '
|
||||
|
||||
<td class="text-center">
|
||||
'.moneyFormat($int['sconto']).'
|
||||
</td>
|
||||
|
||||
<td class="text-center">
|
||||
'.moneyFormat($int['subtotale']).'
|
||||
</td>';
|
||||
} else {
|
||||
echo '
|
||||
<td class="text-center">-</td>
|
||||
<td class="text-center">-</td>';
|
||||
}
|
||||
|
||||
echo '
|
||||
</tr>';
|
||||
|
||||
// Calcolo il totale delle ore lavorate
|
||||
$tecnici = $dbo->fetchArray('SELECT orario_inizio, orario_fine FROM in_interventi_tecnici WHERE idintervento='.prepare($int['id']));
|
||||
foreach ($tecnici as $tecnico) {
|
||||
$totale_ore_impiegate += calcola_ore_intervento($tecnico['orario_inizio'], $tecnico['orario_fine']);
|
||||
}
|
||||
|
||||
$ore[] = $int['ore'];
|
||||
$km[] = $int['km'];
|
||||
|
||||
$sconto_int[] = $sconto;
|
||||
$imponibile_int[] = $int['subtotale'];
|
||||
}
|
||||
|
||||
$ore = sum($ore);
|
||||
$km = sum($km);
|
||||
|
||||
$sconto_int = sum($sconto_int);
|
||||
$imponibile_int = sum($imponibile_int);
|
||||
$totale_int = $imponibile_int - $sconto_int;
|
||||
|
||||
$sconto[] = $sconto_int;
|
||||
$imponibile[] = $imponibile_int;
|
||||
|
||||
echo '
|
||||
</tbody>';
|
||||
|
||||
// Totale interventi
|
||||
echo '
|
||||
<tr>
|
||||
<td class="text-right">
|
||||
<b>'.tr('Totale', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
|
||||
<td class="text-center">
|
||||
<b>'.Translator::numberToLocale($ore).'</b>
|
||||
</td>
|
||||
|
||||
<td class="text-center">
|
||||
<b>'.Translator::numberToLocale($km).'</b>
|
||||
</td>';
|
||||
|
||||
if ($options['pricing']) {
|
||||
echo '
|
||||
|
||||
<td class="text-center">
|
||||
<b>'.moneyFormat($sconto_int).'</b>
|
||||
</td>
|
||||
|
||||
<th class="text-center">
|
||||
<b>'.moneyFormat($totale_int).'</b>
|
||||
</th>';
|
||||
} else {
|
||||
echo '
|
||||
<td class="text-center">-</td>
|
||||
<td class="text-center">-</td>';
|
||||
}
|
||||
|
||||
echo '
|
||||
</tr>';
|
||||
|
||||
echo '
|
||||
</table>';
|
||||
|
||||
$count = $dbo->fetchArray('SELECT COUNT(*) FROM `mg_articoli_interventi` WHERE idintervento IN ('.implode(',', array_column($interventi, 'id')).')');
|
||||
if (!empty($count)) {
|
||||
echo '
|
||||
<table class="table table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="4" class="text-center">
|
||||
<b>'.tr('Materiale utilizzato', [], ['upper' => true]).'</b>
|
||||
</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th style="font-size:8pt;width:50%" class="text-center">
|
||||
<b>'.tr('Descrizione').'</b>
|
||||
</th>
|
||||
|
||||
<th style="font-size:8pt;width:15%" class="text-center">
|
||||
<b>'.tr('Q.tà').'</b>
|
||||
</th>
|
||||
|
||||
<th style="font-size:8pt;width:15%" class="text-center">
|
||||
<b>'.tr('Prezzo').'</b>
|
||||
</th>
|
||||
|
||||
<th style="font-size:8pt;width:15%" class="text-center">
|
||||
<b>'.tr('Importo').'</b>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>';
|
||||
|
||||
$sconto_art = [];
|
||||
$imponibile_art = [];
|
||||
|
||||
// Articoli per intervento
|
||||
foreach ($interventi as $int) {
|
||||
$righe = $dbo->fetchArray("SELECT *, (SELECT codice FROM mg_articoli WHERE id=idarticolo) AS codice, (SELECT CONCAT_WS(serial, 'SN: ', ', ') FROM mg_prodotti WHERE mg_articoli_interventi.idarticolo = mg_prodotti.id_articolo) AS serials FROM `mg_articoli_interventi` WHERE idintervento =".prepare($int['id']).' ORDER BY idarticolo ASC');
|
||||
|
||||
foreach ($righe as $r) {
|
||||
echo '
|
||||
<tr>';
|
||||
|
||||
// Descrizione
|
||||
echo '
|
||||
<td>
|
||||
'.$r['descrizione'];
|
||||
|
||||
// Codice
|
||||
if (!empty($r['codice'])) {
|
||||
echo '
|
||||
<br><small class="text-muted">'.tr('COD. _COD_', [
|
||||
'_COD_' => $r['codice'],
|
||||
]).'</small>';
|
||||
}
|
||||
|
||||
echo '
|
||||
<br><small class="text-muted">'.tr('Intervento num. _NUM_ del _DATE_', [
|
||||
'_NUM_' => $int['codice'],
|
||||
'_DATE_' => Translator::dateToLocale($int['inizio']),
|
||||
]).'.</small>';
|
||||
|
||||
echo '
|
||||
</td>';
|
||||
|
||||
// Quantità
|
||||
echo '
|
||||
<td class="text-center">
|
||||
'.Translator::numberToLocale($r['qta'], 'qta').' '.$r['um'].'
|
||||
</td>';
|
||||
|
||||
if ($options['pricing']) {
|
||||
// Prezzo unitario
|
||||
echo "
|
||||
<td class='text-center'>
|
||||
".moneyFormat($r['prezzo_vendita']);
|
||||
|
||||
if ($r['sconto'] > 0) {
|
||||
echo "
|
||||
<br><small class='text-muted'>- ".tr('sconto _TOT_ _TYPE_', [
|
||||
'_TOT_' => Translator::numberToLocale($r['sconto_unitario']),
|
||||
'_TYPE_' => ($r['tipo_sconto'] == 'PRC' ? '%' : currency()),
|
||||
]).'</small>';
|
||||
|
||||
if ($count <= 1) {
|
||||
$count += 0.4;
|
||||
}
|
||||
}
|
||||
|
||||
echo '
|
||||
</td>';
|
||||
|
||||
// Netto
|
||||
$netto = $r['prezzo_vendita'] * $r['qta'];
|
||||
echo '
|
||||
<td class="text-center">
|
||||
'.moneyFormat($netto);
|
||||
|
||||
if ($r['sconto'] > 0) {
|
||||
echo "
|
||||
<br><small class='text-muted'>- ".tr('sconto _TOT_ _TYPE_', [
|
||||
'_TOT_' => Translator::numberToLocale($r['sconto']),
|
||||
'_TYPE_' => currency(),
|
||||
]).'</small>';
|
||||
|
||||
if ($count <= 1) {
|
||||
$count += 0.4;
|
||||
}
|
||||
}
|
||||
|
||||
echo '
|
||||
</td>';
|
||||
} else {
|
||||
echo '
|
||||
<td class="text-center">-</td>
|
||||
<td class="text-center">-</td>';
|
||||
}
|
||||
|
||||
echo '
|
||||
|
||||
</tr>';
|
||||
|
||||
$sconto_art[] = $r['sconto'];
|
||||
$imponibile_art[] = $r['prezzo_vendita'] * $r['qta'];
|
||||
}
|
||||
}
|
||||
|
||||
echo '
|
||||
</tbody>';
|
||||
|
||||
$sconto_art = sum($sconto_art);
|
||||
$imponibile_art = sum($imponibile_art);
|
||||
$totale_art = $imponibile_art - $sconto_art;
|
||||
|
||||
$sconto[] = $sconto_art;
|
||||
$imponibile[] = $imponibile_art;
|
||||
|
||||
// Totale spesa articoli
|
||||
if ($options['pricing']) {
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="2" class="text-right">
|
||||
<b>'.tr('Totale materiale utilizzato', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
|
||||
<th colspan="2" class="text-center">
|
||||
<b>'.moneyFormat($totale_art).'</b>
|
||||
</th>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
echo '
|
||||
</table>';
|
||||
}
|
||||
|
||||
// Altre spese per intervento
|
||||
$count = $dbo->fetchArray('SELECT COUNT(*) FROM `in_righe_interventi` WHERE idintervento IN ('.implode(',', array_column($interventi, 'id')).')');
|
||||
if (!empty($count)) {
|
||||
echo '
|
||||
<table class="table table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="4" class="text-center">
|
||||
<b>'.tr('Spese aggiuntive', [], ['upper' => true]).'</b>
|
||||
</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th style="font-size:8pt;width:50%" class="text-center">
|
||||
<b>'.tr('Descrizione').'</b>
|
||||
</th>
|
||||
|
||||
<th style="font-size:8pt;width:15%" class="text-center">
|
||||
<b>'.tr('Q.tà').'</b>
|
||||
</th>
|
||||
|
||||
<th style="font-size:8pt;width:15%" class="text-center">
|
||||
<b>'.tr('Prezzo').'</b>
|
||||
</th>
|
||||
|
||||
<th style="font-size:8pt;width:15%" class="text-center">
|
||||
<b>'.tr('Importo').'</b>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>';
|
||||
|
||||
$sconto_spese = [];
|
||||
$imponibile_spese = [];
|
||||
|
||||
// Articoli per intervento
|
||||
foreach ($interventi as $int) {
|
||||
$righe = $dbo->fetchArray('SELECT * FROM `in_righe_interventi` WHERE idintervento ='.prepare($int['id']).' ORDER BY id ASC');
|
||||
|
||||
foreach ($righe as $r) {
|
||||
echo '
|
||||
<tr>';
|
||||
|
||||
// Descrizione
|
||||
echo '
|
||||
<td>
|
||||
'.$r['descrizione'];
|
||||
|
||||
echo '
|
||||
<br><small class="text-muted">'.tr('Intervento num. _NUM_ del _DATE_', [
|
||||
'_NUM_' => $int['codice'],
|
||||
'_DATE_' => Translator::dateToLocale($int['inizio']),
|
||||
]).'.</small>';
|
||||
|
||||
echo '
|
||||
</td>';
|
||||
|
||||
// Quantità
|
||||
echo '
|
||||
<td class="text-center">
|
||||
'.Translator::numberToLocale($r['qta'], 'qta').' '.$r['um'].'
|
||||
</td>';
|
||||
|
||||
if ($options['pricing']) {
|
||||
// Prezzo unitario
|
||||
echo "
|
||||
<td class='text-center'>
|
||||
".moneyFormat($r['prezzo_vendita']);
|
||||
|
||||
if ($r['sconto'] > 0) {
|
||||
echo "
|
||||
<br><small class='text-muted'>- ".tr('sconto _TOT_ _TYPE_', [
|
||||
'_TOT_' => Translator::numberToLocale($r['sconto_unitario']),
|
||||
'_TYPE_' => ($r['tipo_sconto'] == 'PRC' ? '%' : currency()),
|
||||
]).'</small>';
|
||||
|
||||
if ($count <= 1) {
|
||||
$count += 0.4;
|
||||
}
|
||||
}
|
||||
|
||||
echo '
|
||||
</td>';
|
||||
|
||||
// Netto
|
||||
$netto = $r['prezzo_vendita'] * $r['qta'];
|
||||
echo '
|
||||
<td class="text-center">
|
||||
'.moneyFormat($netto);
|
||||
|
||||
if ($r['sconto'] > 0) {
|
||||
echo "
|
||||
<br><small class='text-muted'>- ".tr('sconto _TOT_ _TYPE_', [
|
||||
'_TOT_' => Translator::numberToLocale($r['sconto']),
|
||||
'_TYPE_' => currency(),
|
||||
]).'</small>';
|
||||
|
||||
if ($count <= 1) {
|
||||
$count += 0.4;
|
||||
}
|
||||
}
|
||||
|
||||
echo '
|
||||
</td>';
|
||||
} else {
|
||||
echo '
|
||||
<td class="text-center">-</td>
|
||||
<td class="text-center">-</td>';
|
||||
}
|
||||
|
||||
echo '
|
||||
</tr>';
|
||||
|
||||
$sconto_spese[] = $r['sconto'];
|
||||
$imponibile_spese[] = $r['prezzo_vendita'] * $r['qta'];
|
||||
}
|
||||
}
|
||||
|
||||
echo '
|
||||
</tbody>';
|
||||
|
||||
$sconto_spese = sum($sconto_spese);
|
||||
$imponibile_spese = sum($imponibile_spese);
|
||||
$totale_spese = $imponibile_spese - $sconto_spese;
|
||||
|
||||
$sconto[] = $sconto_spese;
|
||||
$imponibile[] = $imponibile_spese;
|
||||
|
||||
// Totale spese aggiuntive
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="2" class="text-right">
|
||||
<b>'.tr('Totale spese aggiuntive', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
|
||||
<th colspan="2" class="text-center">
|
||||
<b>'.moneyFormat($totale_spese).'</b>
|
||||
</th>
|
||||
</tr>';
|
||||
|
||||
echo '
|
||||
</table>';
|
||||
}
|
||||
}
|
||||
|
||||
// TOTALE COSTI FINALI
|
||||
$sconto = sum($sconto);
|
||||
$imponibile = sum($imponibile);
|
||||
|
||||
$totale = $imponibile - $sconto;
|
||||
|
||||
$rs = $dbo->fetchArray('SELECT SUM(subtotale-sconto) as budget FROM `co_righe_contratti` WHERE idcontratto = '.prepare($id_record));
|
||||
$budget = $rs[0]['budget'];
|
||||
|
||||
$rs = $dbo->fetchArray("SELECT SUM(qta) AS totale_ore FROM `co_righe_contratti` WHERE um='ore' AND idcontratto = ".prepare($id_record));
|
||||
$totale_ore = $rs[0]['totale_ore'];
|
||||
|
||||
$rapporto = $budget - $totale;
|
||||
|
||||
// Totale imponibile
|
||||
echo '
|
||||
<table class="table table-bordered" style="display:none;">';
|
||||
|
||||
if ($options['pricing']) {
|
||||
// Pulisco da informazioni irrilevanti (imponibile,iva)
|
||||
$show = false;
|
||||
|
||||
if ($show) {
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="3" class="text-right border-top" >
|
||||
<b>'.tr('Imponibile', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
|
||||
<th colspan="2" class="text-center">
|
||||
<b>'.moneyFormat($imponibile).'</b>
|
||||
</th>
|
||||
</tr>';
|
||||
|
||||
// Eventuale sconto incondizionato
|
||||
if (!empty($sconto)) {
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="3" class="text-right border-top">
|
||||
<b>'.tr('Sconto', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
|
||||
<th colspan="2" class="text-center">
|
||||
<b>-'.moneyFormat($sconto).'</b>
|
||||
</th>
|
||||
</tr>';
|
||||
|
||||
// Totale imponibile
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="3" class="text-right border-top">
|
||||
<b>'.tr('Totale imponibile', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
|
||||
<th colspan="2" class="text-center">
|
||||
<b>'.moneyFormat($totale).'</b>
|
||||
</th>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
// IVA
|
||||
$rs = $dbo->fetchArray('SELECT * FROM co_iva WHERE co_iva.id = '.prepare(setting('Iva predefinita')));
|
||||
$percentuale_iva = $rs[0]['percentuale'];
|
||||
$iva = $totale / 100 * $percentuale_iva;
|
||||
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="3" class="text-right border-top">
|
||||
<b>'.tr('Iva (_PRC_%)', [
|
||||
'_PRC_' => Translator::numberToLocale($percentuale_iva, 0),
|
||||
], ['upper' => true]).':</b>
|
||||
</td>
|
||||
|
||||
<th colspan="2" class="text-center">
|
||||
<b>'.moneyFormat($iva).'</b>
|
||||
</th>
|
||||
</tr>';
|
||||
|
||||
//$totale = sum($totale, $iva);
|
||||
}
|
||||
|
||||
// TOTALE
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="3" class="text-right border-top">
|
||||
<b>'.tr('Totale consuntivo (no IVA)', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<th colspan="2" class="text-center">
|
||||
<b>'.moneyFormat($totale).'</b>
|
||||
</th>
|
||||
</tr>';
|
||||
|
||||
// BUDGET
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="3" class="text-right border-top">
|
||||
<b>'.tr('Budget (no IVA)', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<th colspan="2" class="text-center">
|
||||
<b>'.moneyFormat($budget).'</b>
|
||||
</th>
|
||||
</tr>';
|
||||
|
||||
// RAPPORTO
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="3" class="text-right border-top">
|
||||
<b>'.tr('Rapporto budget/spesa (no IVA)', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<th colspan="2" class="text-center">
|
||||
<b>'.moneyFormat($rapporto).'</b>
|
||||
</th>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
// ORE RESIDUE
|
||||
if (!empty($totale_ore)) {
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="3" class="text-right border-top">
|
||||
<b>'.tr('Ore residue', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<th colspan="2" class="text-center">
|
||||
<b>'.Translator::numberToLocale($totale_ore - $totale_ore_impiegate).'</b><br>
|
||||
<p>'.tr('Ore erogate').': '.Translator::numberToLocale($totale_ore_impiegate).'</p>
|
||||
<p>'.tr('Ore in contratto').': '.Translator::numberToLocale($totale_ore).'</p>
|
||||
</th>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
echo'
|
||||
</table>';
|
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
|
||||
include_once __DIR__.'/../riepilogo_interventi/bottom.php';
|
||||
|
||||
$budget = get_imponibile_preventivo($id_record);
|
||||
|
||||
$rapporto = floatval($budget) - floatval($somma_totale_imponibile);
|
||||
|
||||
$rs = $dbo->fetchArray("SELECT SUM(qta) AS totale_ore FROM `co_righe_contratti` WHERE um='ore' AND idcontratto = ".prepare($id_record));
|
||||
$totale_ore = $rs[0]['totale_ore'];
|
||||
$totale_ore_impiegate = $records->sum('ore_totali');
|
||||
|
||||
if ($pricing || !empty($totale_ore)) {
|
||||
// Totale imponibile
|
||||
echo '
|
||||
<table class="table table-bordered">';
|
||||
if ($pricing) {
|
||||
// TOTALE
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="3" class="text-right border-top">
|
||||
<b>'.tr('Totale consuntivo (no iva)', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<th colspan="2" class="text-center">
|
||||
<b>'.moneyFormat($somma_totale_imponibile).'</b>
|
||||
</th>
|
||||
</tr>';
|
||||
|
||||
// BUDGET
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="3" class="text-right border-top">
|
||||
<b>'.tr('Budget (no IVA)', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<th colspan="2" class="text-center">
|
||||
<b>'.moneyFormat($budget).'</b>
|
||||
</th>
|
||||
</tr>';
|
||||
|
||||
// RAPPORTO
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="3" class="text-right border-top">
|
||||
<b>'.tr('Rapporto budget/spesa (no IVA)', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<th colspan="2" class="text-center">
|
||||
<b>'.moneyFormat($rapporto).'</b>
|
||||
</th>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
// ORE RESIDUE
|
||||
if (!empty($totale_ore)) {
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="3" class="text-right border-top">
|
||||
<b>'.tr('Ore residue', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<th colspan="2" class="text-center">
|
||||
<b>'.Translator::numberToLocale($totale_ore - $totale_ore_impiegate).'</b><br>
|
||||
<p>'.tr('Ore erogate').': '.Translator::numberToLocale($totale_ore_impiegate).'</p>
|
||||
<p>'.tr('Ore in contratto').': '.Translator::numberToLocale($totale_ore).'</p>
|
||||
</th>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
echo '
|
||||
</table>';
|
||||
}
|
|
@ -2,10 +2,12 @@
|
|||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
$module_name = 'Contratti';
|
||||
use Modules\Contratti\Contratto;
|
||||
|
||||
// Lettura info fattura
|
||||
$records = $dbo->fetchArray('SELECT *, data_bozza AS data FROM co_contratti WHERE id='.prepare($id_record));
|
||||
$documento = Contratto::find($id_record);
|
||||
$records = $documento->interventi;
|
||||
|
||||
$id_cliente = $records[0]['idanagrafica'];
|
||||
$id_sede = $records[0]['idsede'];
|
||||
$id_cliente = $documento['idanagrafica'];
|
||||
$id_sede = $documento['idsede'];
|
||||
|
||||
$pricing = $options['pricing'];
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
<?php
|
||||
|
||||
include __DIR__.'/../riepilogo_interventi/piece.php';
|
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
echo '
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
<div class="text-center">
|
||||
<h4 class="text-bold">'.tr('Consuntivo', [], ['upper' => true]).'</h4>
|
||||
<b>'.tr('Contratto num. _NUM_ del _DATE_', [
|
||||
'_NUM_' => $documento['numero'],
|
||||
'_DATE_' => Translator::dateToLocale($documento['data_bozza']),
|
||||
], ['upper' => true]).'</b>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-5 col-xs-offset-1">
|
||||
<table class="table" style="width:100%;margin-top:5mm;">
|
||||
<tr>
|
||||
<td colspan=2 class="border-full" style="height:16mm;">
|
||||
<p class="small-bold">'.tr('Spett.le', [], ['upper' => true]).'</p>
|
||||
<p>$c_ragionesociale$</p>
|
||||
<p>$c_indirizzo$ $c_citta_full$</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="border-bottom border-left">
|
||||
<p class="small-bold">'.tr('Partita IVA', [], ['upper' => true]).'</p>
|
||||
</td>
|
||||
<td class="border-right border-bottom text-right">
|
||||
<small>$c_piva$</small>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="border-bottom border-left">
|
||||
<p class="small-bold">'.tr('Codice fiscale', [], ['upper' => true]).'</p>
|
||||
</td>
|
||||
<td class="border-right border-bottom text-right">
|
||||
<small>$c_codicefiscale$</small>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
// Descrizione
|
||||
if (!empty($documento['descrizione'])) {
|
||||
echo '
|
||||
<p>'.nl2br($documento['descrizione']).'</p>
|
||||
<br>';
|
||||
}
|
||||
|
||||
echo '
|
||||
<table class="table table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="2">'.tr('Documento', [], ['upper' => true]).'</th>
|
||||
<th class="text-center">'.tr('Imponibile', [], ['upper' => true]).'</th>
|
||||
<th class="text-center">'.tr('Sconto', [], ['upper' => true]).'</th>
|
||||
<th class="text-center">'.tr('Totale imponibile', [], ['upper' => true]).'</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>';
|
|
@ -302,12 +302,10 @@ foreach ($sessioni as $i => $sessione) {
|
|||
}
|
||||
|
||||
// Ore lavorate
|
||||
$ore = $documento->ore_totali;
|
||||
|
||||
echo '
|
||||
<tr>
|
||||
<td class="text-center">
|
||||
<small>'.tr('Ore lavorate').':</small><br/><b>'.Translator::numberToLocale($ore, 2).'</b>
|
||||
<small>'.tr('Ore lavorate').':</small><br/><b>'.Translator::numberToLocale($documento->ore_totali, 2).'</b>
|
||||
</td>';
|
||||
|
||||
// Costo totale manodopera
|
||||
|
@ -334,7 +332,7 @@ echo '
|
|||
echo '
|
||||
<tr>
|
||||
<td class="text-center">
|
||||
<small>'.tr('Km percorsi').':</small><br/><b>'.Translator::numberToLocale($sessioni->sum('km'), 2).'</b>
|
||||
<small>'.tr('Km percorsi').':</small><br/><b>'.Translator::numberToLocale($documento->km_totali, 2).'</b>
|
||||
</td>';
|
||||
|
||||
// Costo trasferta
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
<style>
|
||||
<!--
|
||||
.table_values td{
|
||||
border: 1px solid #888;
|
||||
padding: 4px;
|
||||
}
|
||||
-->
|
||||
</style>
|
||||
|
||||
<page backcolor="#ffffff" backtop="10mm" backbottom="10mm" backleft="5mm" backright="5mm" footer="" style="font-size: $font_size$">
|
||||
$body$
|
||||
</page>
|
|
@ -1,48 +0,0 @@
|
|||
<page_header>
|
||||
</page_header>
|
||||
|
||||
|
||||
<!-- Footer -->
|
||||
<page_footer>
|
||||
<table>
|
||||
<tr><td style="width:90mm; border:1px solid #000;">
|
||||
<b>CONTROLLO EFFETTUATO DA:</b><br/>
|
||||
<div style="padding:10px;">
|
||||
$f_ragionesociale$
|
||||
$f_indirizzo$
|
||||
$f_citta_full$
|
||||
$f_piva$
|
||||
$f_codicefiscale$
|
||||
$f_capsoc$
|
||||
$f_telefono$
|
||||
$f_sitoweb$
|
||||
$f_email$
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td align="right">
|
||||
<table>
|
||||
<tr><td align="right">
|
||||
Firma Tecnico<br/><br/><br/>
|
||||
</td>
|
||||
<td>
|
||||
___________________________________<br/><br/><br/>
|
||||
</td></tr>
|
||||
|
||||
<tr><td align="right">
|
||||
Firma Cliente<br/><br/><br/>
|
||||
</td>
|
||||
<td>
|
||||
___________________________________<br/><br/><br/>
|
||||
</td></tr>
|
||||
|
||||
<tr><td align="right">
|
||||
Firma Amministratore
|
||||
</td>
|
||||
<td>
|
||||
___________________________________
|
||||
</td></tr>
|
||||
</table>
|
||||
</td></tr>
|
||||
</table>
|
||||
</page_footer>
|
|
@ -1,197 +0,0 @@
|
|||
<?php
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
$module_name = 'Interventi';
|
||||
|
||||
// carica info ordine servizio
|
||||
$idintervento = get('idintervento');
|
||||
$query = "SELECT *, (SELECT CONCAT_WS('-', codice, ragione_sociale ) FROM an_anagrafiche WHERE idanagrafica=(SELECT idtecnico FROM in_interventi_tecnici WHERE idintervento=co_ordiniservizio.idintervento LIMIT 0,1)) AS tecnico, (SELECT data FROM in_interventi WHERE id=co_ordiniservizio.idintervento) AS data_intervento FROM co_ordiniservizio WHERE idintervento=\"$idintervento\" ".Modules::getAdditionalsQuery('Interventi');
|
||||
$rs = $dbo->fetchArray($query);
|
||||
$idcliente = $rs[0]['idanagrafica'];
|
||||
$data_intervento = $rs[0]['data_intervento'];
|
||||
|
||||
$copia_centrale = $rs[0]['copia_centrale'];
|
||||
$copia_cliente = $rs[0]['copia_cliente'];
|
||||
$copia_amministratore = $rs[0]['copia_amministratore'];
|
||||
$funzionamento_in_sicurezza = $rs[0]['funzionamento_in_sicurezza'];
|
||||
|
||||
// carica report html
|
||||
$report = file_get_contents($docroot.'/templates/interventi_ordiniservizio/intervento.html');
|
||||
$body = file_get_contents($docroot.'/templates/interventi_ordiniservizio/intervento_body.html');
|
||||
|
||||
include_once $docroot.'/templates/pdfgen_variables.php';
|
||||
|
||||
/*
|
||||
Dati intervento
|
||||
*/
|
||||
$body .= "<table class=\"table_values\" cellspacing=\"0\" border=\"0\" cellpadding=\"0\" style=\"width:100%; table-layout:fixed; border-color:#aaa;\">\n";
|
||||
|
||||
// Titolo
|
||||
$body .= "<tr><td align=\"center\" colspan=\"2\" valign=\"middle\" style=\"font-size:14pt;\" bgcolor=\"#dddddd\"><b>Programmazione della manutenzione periodica</b></td></tr>\n";
|
||||
|
||||
// Titolo "ordine di servizio" e tecnico
|
||||
$body .= "<tr>\n";
|
||||
$body .= '<td style="width:50%;">ORDINE DI SERVIZIO Num. '.$rs[0]['id']."</td>\n";
|
||||
$body .= '<td style="width:50%;">TECNICO: '.$rs[0]['tecnico']."</td>\n";
|
||||
$body .= "</tr>\n";
|
||||
|
||||
$body .= "</table>\n\n\n";
|
||||
|
||||
/*
|
||||
Dati intestazione doppia
|
||||
*/
|
||||
// Info contratto
|
||||
$rs2 = $dbo->fetchArray('SELECT * FROM co_contratti WHERE id="'.$rs[0]['idcontratto'].'"');
|
||||
$body .= "<table class=\"table_values\" cellspacing=\"0\" border=\"0\" cellpadding=\"0\" style=\"width:100%; table-layout:fixed; border-color:#aaa;\">\n";
|
||||
|
||||
// Informazioni a sinistra
|
||||
$body .= "<tr>\n";
|
||||
$body .= "<td style=\"width:50%;\" valign=\"top\">\n";
|
||||
$body .= ' <b>Contratto num. '.$rs2[0]['numero'].":</b><br/>\n";
|
||||
$body .= ' durata dal '.Translator::dateToLocale($rs2[0]['data_accettazione']).' al '.Translator::dateToLocale($rs2[0]['data_conclusione'])."<br/>\n";
|
||||
$body .= ' Tipologia: '.$rs2[0]['nome']."<br/><br/>\n";
|
||||
|
||||
// Info impianto
|
||||
$rs3 = $dbo->fetchArray('SELECT * FROM my_impianti WHERE id="'.$rs[0]['id'].'"');
|
||||
$body .= " <b>Impianto:</b><br/>\n";
|
||||
$body .= ' Matricola: '.$rs3[0]['matricola']."<br/>\n";
|
||||
$body .= ' Tipologia: '.$rs3[0]['nome']."<br/>\n";
|
||||
$body .= ' Data di installazione: '.Translator::dateToLocale($rs3[0]['data'])."<br/>\n";
|
||||
$body .= ' Ubicazione: '.$rs3[0]['ubicazione']."<br/>\n";
|
||||
$body .= ' Scala: '.$rs3[0]['scala']."<br/>\n";
|
||||
$body .= ' Piano: '.$rs3[0]['piano']."<br/><br/>\n";
|
||||
|
||||
$body .= " <b>Lavori da eseguire nel periodo:</b><br/>\n";
|
||||
$body .= ' dal 01/'.date('m/Y', strtotime($rs[0]['data_scadenza'])).' al '.date('t/m/Y', strtotime($rs[0]['data_scadenza']))."<br/><br/>\n";
|
||||
$body .= "</td>\n";
|
||||
|
||||
/*
|
||||
Info cliente
|
||||
*/
|
||||
$body .= "<td style=\"width:50%;\" valign=\"top\">\n";
|
||||
|
||||
// Sede impianto
|
||||
$ripeti = true;
|
||||
$rs2 = $dbo->fetchArray('SELECT * FROM an_sedi WHERE id=(SELECT idsede FROM my_impianti WHERE id="'.$rs[0]['id'].'")');
|
||||
|
||||
if ($rs2[0]['indirizzo'] != '') {
|
||||
$body .= " <b>Indirizzo impianto:</b><br/>\n";
|
||||
$body .= ' '.$rs2[0]['nomesede']."<br/>\n";
|
||||
$body .= ' '.$rs2[0]['indirizzo']."<br/>\n";
|
||||
$body .= ' '.$rs2[0]['cap'].' '.$rs2[0]['citta'].' '.$rs2[0]['provincia']."<br/><br/>\n";
|
||||
$ripeti = false;
|
||||
}
|
||||
|
||||
$rs2 = $dbo->fetchArray('SELECT * FROM an_anagrafiche WHERE idanagrafica=(SELECT idanagrafica FROM in_interventi WHERE id="'.$idintervento.'")');
|
||||
|
||||
if ($ripeti) {
|
||||
$body .= " <b>Indirizzo impianto:</b><br/>\n";
|
||||
$body .= ' '.$rs2[0]['indirizzo']."<br/>\n";
|
||||
$body .= ' '.$rs2[0]['cap'].' '.$rs2[0]['citta'].' '.$rs2[0]['provincia']."<br/>\n";
|
||||
$body .= ' Telefono: '.$rs2[0]['telefono']."<br/>\n";
|
||||
$body .= ' Email: '.$rs2[0]['email']."<br/><br/>\n";
|
||||
|
||||
$body .= " <b>Cliente:</b><br/>\n";
|
||||
$body .= ' '.$rs2[0]['indirizzo']."<br/>\n";
|
||||
$body .= ' '.$rs2[0]['cap'].' '.$rs2[0]['citta'].' '.$rs2[0]['provincia']."<br/>\n";
|
||||
$body .= ' Telefono: '.$rs2[0]['telefono']."<br/>\n";
|
||||
$body .= ' Email: '.$rs2[0]['email']."<br/>\n";
|
||||
} else {
|
||||
$body .= " <b>Cliente</b><br/>\n";
|
||||
$body .= ' '.$rs2[0]['ragione_sociale']."<br/>\n";
|
||||
$body .= ' '.$rs2[0]['indirizzo']."<br/>\n";
|
||||
$body .= ' '.$rs2[0]['cap'].' '.$rs2[0]['citta'].' '.$rs2[0]['provincia']."<br/>\n";
|
||||
$body .= ' Telefono: '.$rs2[0]['telefono']."<br/>\n";
|
||||
$body .= ' Email: '.$rs2[0]['email']."<br/>\n";
|
||||
}
|
||||
|
||||
$body .= "</td></tr>\n";
|
||||
$body .= "</table><br/>\n\n\n";
|
||||
|
||||
/*
|
||||
Elenco voci di servizio
|
||||
*/
|
||||
$rs = $dbo->fetchArray('SELECT * FROM co_ordiniservizio_vociservizio WHERE idordineservizio=(SELECT id FROM co_ordiniservizio WHERE idintervento="'.$idintervento.'" LIMIT 0,1) ORDER BY categoria ASC');
|
||||
|
||||
$body .= "<table class=\"table_values\" cellspacing=\"0\" border=\"0\" cellpadding=\"10\" style=\"width:100%; table-layout:fixed; border-color:#aaa;\">\n";
|
||||
$body .= "<col width='60'><col width='16'><col width='16'><col width='77'>\n";
|
||||
$body .= "<tr><td style='background:#ccc; width:60mm;'><b>VERIFICHE</b></td>\n";
|
||||
$body .= "<td style='background:#ccc; width:16mm;' align='center'><small><small><b>ESEGUITO</b></small></small></td>\n";
|
||||
$body .= "<td style='background:#ccc; width:16mm;' align='center'><small><small><b>NON ESEGUITO</b></small></small></td>\n";
|
||||
$body .= "<td style='background:#ccc; width:77mm;'><b>NOTE</b></td></tr>\n";
|
||||
|
||||
$prev_cat = '';
|
||||
|
||||
for ($i = 0; $i < sizeof($rs); ++$i) {
|
||||
if ($rs[$i]['eseguito'] == '1') {
|
||||
$eseguito_si = "<span style='font-size:24px;'>x</span>";
|
||||
$eseguito_no = '';
|
||||
} elseif ($rs[$i]['eseguito'] == '-1') {
|
||||
$eseguito_si = '';
|
||||
$eseguito_no = "<span style='font-size:24px;'>x</span>";
|
||||
} else {
|
||||
$eseguito_si = '';
|
||||
$eseguito_no = '';
|
||||
}
|
||||
|
||||
if ($prev_cat != $rs[$i]['categoria']) {
|
||||
$body .= "<tr style='background:#ddd;'><td colspan='4'><b>".$rs[$i]['categoria']."</b></td></tr>\n";
|
||||
}
|
||||
|
||||
$body .= "<tr><td valign='top'>".$rs[$i]['voce']." </td>\n";
|
||||
$body .= "<td align='center' valign='top'>".$eseguito_si." </td>\n";
|
||||
$body .= "<td align='center' valign='top'>".$eseguito_no." </td>\n";
|
||||
$body .= "<td align='left' valign='top'>".$rs[$i]['note']." </td></tr>\n";
|
||||
|
||||
$prev_cat = $rs[$i]['categoria'];
|
||||
}
|
||||
|
||||
$body .= "</table><br/>\n\n\n";
|
||||
|
||||
/*
|
||||
Spunte e note
|
||||
*/
|
||||
$body .= "<table cellspacing=\"0\" border=\"0\" cellpadding=\"10\" style=\"width:100%; table-layout:fixed;\">\n";
|
||||
|
||||
// Copia centrale
|
||||
if ($copia_centrale == '1') {
|
||||
$copia_centrale = 'Sì';
|
||||
} else {
|
||||
$copia_centrale = 'NO';
|
||||
}
|
||||
$body .= "<tr><td style=\"width:62mm;\">\n";
|
||||
$body .= " Consegnata copia in centrale: <b>$copia_centrale</b>";
|
||||
$body .= "</td>\n";
|
||||
|
||||
// Copia cliente
|
||||
if ($copia_cliente == '1') {
|
||||
$copia_cliente = 'Sì';
|
||||
} else {
|
||||
$copia_cliente = 'NO';
|
||||
}
|
||||
$body .= "<td style=\"width:62mm;\" align=\"center\">\n";
|
||||
$body .= " al cliente: <b>$copia_cliente</b>";
|
||||
$body .= "</td>\n";
|
||||
|
||||
// Copia amministratore
|
||||
if ($copia_amministratore == '1') {
|
||||
$copia_amministratore = 'Sì';
|
||||
} else {
|
||||
$copia_amministratore = 'NO';
|
||||
}
|
||||
$body .= "<td style=\"width:62mm;\" align=\"right\">\n";
|
||||
$body .= " all'amministratore: <b>$copia_amministratore</b>";
|
||||
$body .= "</td></tr>\n";
|
||||
|
||||
// Funzionamento in sicurezza
|
||||
if ($funzionamento_in_sicurezza == '1') {
|
||||
$funzionamento_in_sicurezza = 'Sì';
|
||||
} else {
|
||||
$funzionamento_in_sicurezza = 'NO';
|
||||
}
|
||||
$body .= "<tr><td colspan=\"3\" style=\"width:62mm;\">\n";
|
||||
$body .= ' <br/>In data '.Translator::dateToLocale($data_intervento)." l'impianto può funzionare in sicurezza: <b>$funzionamento_in_sicurezza</b>";
|
||||
$body .= "</td></tr>\n";
|
||||
|
||||
$body .= "</table>\n\n\n";
|
|
@ -1,561 +0,0 @@
|
|||
<?php
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
echo '
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
<div class="text-center">
|
||||
<h4 class="text-bold">'.tr('Consuntivo', [], ['upper' => true]).'</h4>
|
||||
<b>'.tr('Preventivo num. _NUM_ del _DATE_', [
|
||||
'_NUM_' => $records[0]['numero'],
|
||||
'_DATE_' => Translator::dateToLocale($records[0]['data']),
|
||||
], ['upper' => true]).'</b>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-5 col-xs-offset-1">
|
||||
<table class="table" style="width:100%;margin-top:5mm;">
|
||||
<tr>
|
||||
<td colspan=2 class="border-full" style="height:16mm;">
|
||||
<p class="small-bold">'.tr('Spett.le', [], ['upper' => true]).'</p>
|
||||
<p>$c_ragionesociale$</p>
|
||||
<p>$c_indirizzo$ $c_citta_full$</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="border-bottom border-left">
|
||||
<p class="small-bold">'.tr('Partita IVA', [], ['upper' => true]).'</p>
|
||||
</td>
|
||||
<td class="border-right border-bottom text-right">
|
||||
<small>$c_piva$</small>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="border-bottom border-left">
|
||||
<p class="small-bold">'.tr('Codice fiscale', [], ['upper' => true]).'</p>
|
||||
</td>
|
||||
<td class="border-right border-bottom text-right">
|
||||
<small>$c_codicefiscale$</small>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
// Descrizione
|
||||
if (!empty($records[0]['descrizione'])) {
|
||||
echo '
|
||||
<p>'.nl2br($records[0]['descrizione']).'</p>
|
||||
<br>';
|
||||
}
|
||||
|
||||
$sconto = [];
|
||||
$imponibile = [];
|
||||
|
||||
$interventi = $dbo->fetchArray('SELECT *, in_interventi.id, in_interventi.codice, (SELECT GROUP_CONCAT(DISTINCT ragione_sociale) FROM in_interventi_tecnici JOIN an_anagrafiche ON an_anagrafiche.idanagrafica = in_interventi_tecnici.idtecnico WHERE idintervento=in_interventi.id) AS tecnici, (SELECT MIN(orario_inizio) FROM in_interventi_tecnici WHERE idintervento=in_interventi.id) AS inizio, (SELECT SUM(ore) FROM in_interventi_tecnici WHERE idintervento=in_interventi.id) AS ore, (SELECT SUM(km) FROM in_interventi_tecnici WHERE idintervento=in_interventi.id) AS km FROM in_interventi WHERE in_interventi.id_preventivo='.prepare($id_record).' ORDER BY inizio DESC');
|
||||
|
||||
if (!empty($interventi)) {
|
||||
// Interventi
|
||||
echo "
|
||||
<table class='table table-striped table-bordered' id='contents'>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class='text-center' style='width:50%'>".tr('Attività', [], ['upper' => true])."</th>
|
||||
<th class='text-center' style='width:10%'>".tr('Ore', [], ['upper' => true])."</th>
|
||||
<th class='text-center' style='width:15%'>".tr('Km', [], ['upper' => true])."</th>
|
||||
<th class='text-center' style='width:15%'>".tr('Sconto', [], ['upper' => true])."</th>
|
||||
<th class='text-center' style='width:10%'>".tr('Imponibile', [], ['upper' => true]).'</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>';
|
||||
|
||||
$ore = [];
|
||||
$km = [];
|
||||
$sconto_int = [];
|
||||
$imponibile_int = [];
|
||||
|
||||
foreach ($interventi as $int) {
|
||||
$int = array_merge($int, get_costi_intervento($int['id']));
|
||||
$int['sconto'] = ($int['manodopera_addebito'] - $int['manodopera_scontato']) + ($int['viaggio_addebito'] - $int['viaggio_scontato']);
|
||||
$int['subtotale'] = $int['manodopera_scontato'] + $int['viaggio_scontato'];
|
||||
$sconto[] = $int['sconto_globale'];
|
||||
|
||||
echo '
|
||||
<tr>
|
||||
<td>
|
||||
'.tr('Intervento num. _NUM_ del _DATE_', [
|
||||
'_NUM_' => $int['codice'],
|
||||
'_DATE_' => Translator::dateToLocale($int['inizio']),
|
||||
]);
|
||||
|
||||
if (!empty($int['tecnici'])) {
|
||||
echo '
|
||||
<br><small class="text-muted">'.tr('Tecnici').': '.str_replace(',', ', ', $int['tecnici']).'.</small>';
|
||||
}
|
||||
|
||||
echo '
|
||||
</td>';
|
||||
|
||||
echo '
|
||||
<td class="text-center">
|
||||
'.Translator::numberToLocale($int['ore']).'
|
||||
</td>
|
||||
|
||||
<td class="text-center">
|
||||
'.Translator::numberToLocale($int['km']).'
|
||||
</td>
|
||||
|
||||
<td class="text-center">
|
||||
'.moneyFormat($int['sconto']).'
|
||||
</td>
|
||||
|
||||
<td class="text-center">
|
||||
'.moneyFormat($int['subtotale']).'
|
||||
</td>
|
||||
</tr>';
|
||||
|
||||
$ore[] = $int['ore'];
|
||||
$km[] = $int['km'];
|
||||
|
||||
$sconto_int[] = $sconto;
|
||||
$imponibile_int[] = $int['subtotale'];
|
||||
}
|
||||
|
||||
$ore = sum($ore);
|
||||
$km = sum($km);
|
||||
|
||||
$sconto_int = sum($sconto_int);
|
||||
$imponibile_int = sum($imponibile_int);
|
||||
$totale_int = $imponibile_int - $sconto_int;
|
||||
|
||||
$sconto[] = $sconto_int;
|
||||
$imponibile[] = $imponibile_int;
|
||||
|
||||
echo '
|
||||
</tbody>';
|
||||
|
||||
// Totale interventi
|
||||
echo '
|
||||
<tr>
|
||||
<td class="text-right">
|
||||
<b>'.tr('Totale', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
|
||||
<td class="text-center">
|
||||
<b>'.Translator::numberToLocale($ore).'</b>
|
||||
</td>
|
||||
|
||||
<td class="text-center">
|
||||
<b>'.Translator::numberToLocale($km).'</b>
|
||||
</td>
|
||||
|
||||
<td class="text-center">
|
||||
<b>'.moneyFormat($sconto_int).'</b>
|
||||
</td>
|
||||
|
||||
<th class="text-center">
|
||||
<b>'.moneyFormat($totale_int).'</b>
|
||||
</th>
|
||||
</tr>';
|
||||
|
||||
echo '
|
||||
</table>';
|
||||
|
||||
$count = $dbo->fetchArray('SELECT COUNT(*) FROM `mg_articoli_interventi` WHERE idintervento IN ('.implode(',', array_column($interventi, 'id')).')');
|
||||
if (!empty($count)) {
|
||||
echo '
|
||||
<table class="table table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="4" class="text-center">
|
||||
<b>'.tr('Materiale utilizzato', [], ['upper' => true]).'</b>
|
||||
</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th style="font-size:8pt;width:50%" class="text-center">
|
||||
<b>'.tr('Descrizione').'</b>
|
||||
</th>
|
||||
|
||||
<th style="font-size:8pt;width:15%" class="text-center">
|
||||
<b>'.tr('Q.tà').'</b>
|
||||
</th>
|
||||
|
||||
<th style="font-size:8pt;width:15%" class="text-center">
|
||||
<b>'.tr('Prezzo').'</b>
|
||||
</th>
|
||||
|
||||
<th style="font-size:8pt;width:15%" class="text-center">
|
||||
<b>'.tr('Importo').'</b>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>';
|
||||
|
||||
$sconto_art = [];
|
||||
$imponibile_art = [];
|
||||
|
||||
// Articoli per intervento
|
||||
foreach ($interventi as $int) {
|
||||
$righe = $dbo->fetchArray("SELECT *, (SELECT codice FROM mg_articoli WHERE id=idarticolo) AS codice, (SELECT CONCAT_WS(serial, 'SN: ', ', ') FROM mg_prodotti WHERE mg_articoli_interventi.idarticolo = mg_prodotti.id_articolo AND mg_prodotti.id_riga_intervento = mg_articoli_interventi.idintervento) AS serials FROM `mg_articoli_interventi` WHERE idintervento =".prepare($int['id']).' ORDER BY idarticolo ASC');
|
||||
|
||||
foreach ($righe as $r) {
|
||||
echo '
|
||||
<tr>';
|
||||
|
||||
// Descrizione
|
||||
echo '
|
||||
<td>
|
||||
'.$r['descrizione'];
|
||||
|
||||
// Codice
|
||||
if (!empty($r['codice'])) {
|
||||
echo '
|
||||
<br><small class="text-muted">'.tr('COD. _COD_', [
|
||||
'_COD_' => $r['codice'],
|
||||
]).'</small>';
|
||||
}
|
||||
|
||||
echo '
|
||||
<br><small class="text-muted">'.tr('Intervento num. _NUM_ del _DATE_', [
|
||||
'_NUM_' => $int['codice'],
|
||||
'_DATE_' => Translator::dateToLocale($int['inizio']),
|
||||
]).'.</small>';
|
||||
|
||||
echo '
|
||||
</td>';
|
||||
|
||||
// Quantità
|
||||
echo '
|
||||
<td class="text-center">
|
||||
'.Translator::numberToLocale($r['qta'], 'qta').' '.$r['um'].'
|
||||
</td>';
|
||||
|
||||
// Prezzo unitario
|
||||
echo "
|
||||
<td class='text-center'>
|
||||
".moneyFormat($r['prezzo_vendita']);
|
||||
|
||||
if ($r['sconto'] > 0) {
|
||||
echo "
|
||||
<br><small class='text-muted'>- ".tr('sconto _TOT_ _TYPE_', [
|
||||
'_TOT_' => Translator::numberToLocale($r['sconto_unitario']),
|
||||
'_TYPE_' => ($r['tipo_sconto'] == 'PRC' ? '%' : currency()),
|
||||
]).'</small>';
|
||||
|
||||
if ($count <= 1) {
|
||||
$count += 0.4;
|
||||
}
|
||||
}
|
||||
|
||||
echo '
|
||||
</td>';
|
||||
|
||||
// Netto
|
||||
$netto = $r['prezzo_vendita'] * $r['qta'];
|
||||
echo '
|
||||
<td class="text-center">
|
||||
'.moneyFormat($netto);
|
||||
|
||||
if ($r['sconto'] > 0) {
|
||||
echo "
|
||||
<br><small class='text-muted'>- ".tr('sconto _TOT_ _TYPE_', [
|
||||
'_TOT_' => Translator::numberToLocale($r['sconto']),
|
||||
'_TYPE_' => currency(),
|
||||
]).'</small>';
|
||||
|
||||
if ($count <= 1) {
|
||||
$count += 0.4;
|
||||
}
|
||||
}
|
||||
|
||||
echo '
|
||||
</td>
|
||||
</tr>';
|
||||
|
||||
$sconto_art[] = $r['sconto'];
|
||||
$imponibile_art[] = $r['prezzo_vendita'] * $r['qta'];
|
||||
}
|
||||
}
|
||||
|
||||
echo '
|
||||
</tbody>';
|
||||
|
||||
$sconto_art = sum($sconto_art);
|
||||
$imponibile_art = sum($imponibile_art);
|
||||
$totale_art = $imponibile_art - $sconto_art;
|
||||
|
||||
$sconto[] = $sconto_art;
|
||||
$imponibile[] = $imponibile_art;
|
||||
|
||||
// Totale spesa articoli
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="2" class="text-right">
|
||||
<b>'.tr('Totale materiale utilizzato', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
|
||||
<th colspan="2" class="text-center">
|
||||
<b>'.moneyFormat($totale_art).'</b>
|
||||
</th>
|
||||
</tr>';
|
||||
|
||||
echo '
|
||||
</table>';
|
||||
}
|
||||
|
||||
// Altre spese per intervento
|
||||
$count = $dbo->fetchArray('SELECT COUNT(*) FROM `in_righe_interventi` WHERE idintervento IN ('.implode(',', array_column($interventi, 'id')).')');
|
||||
if (!empty($count)) {
|
||||
echo '
|
||||
<table class="table table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="4" class="text-center">
|
||||
<b>'.tr('Spese aggiuntive', [], ['upper' => true]).'</b>
|
||||
</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th style="font-size:8pt;width:50%" class="text-center">
|
||||
<b>'.tr('Descrizione').'</b>
|
||||
</th>
|
||||
|
||||
<th style="font-size:8pt;width:15%" class="text-center">
|
||||
<b>'.tr('Q.tà').'</b>
|
||||
</th>
|
||||
|
||||
<th style="font-size:8pt;width:15%" class="text-center">
|
||||
<b>'.tr('Prezzo').'</b>
|
||||
</th>
|
||||
|
||||
<th style="font-size:8pt;width:15%" class="text-center">
|
||||
<b>'.tr('Importo').'</b>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>';
|
||||
|
||||
$sconto_spese = [];
|
||||
$imponibile_spese = [];
|
||||
|
||||
// Articoli per intervento
|
||||
foreach ($interventi as $int) {
|
||||
$righe = $dbo->fetchArray('SELECT * FROM `in_righe_interventi` WHERE idintervento ='.prepare($int['id']).' ORDER BY id ASC');
|
||||
|
||||
foreach ($righe as $r) {
|
||||
echo '
|
||||
<tr>';
|
||||
|
||||
// Descrizione
|
||||
echo '
|
||||
<td>
|
||||
'.$r['descrizione'];
|
||||
|
||||
echo '
|
||||
<br><small class="text-muted">'.tr('Intervento num. _NUM_ del _DATE_', [
|
||||
'_NUM_' => $int['codice'],
|
||||
'_DATE_' => Translator::dateToLocale($int['inizio']),
|
||||
]).'.</small>';
|
||||
|
||||
echo '
|
||||
</td>';
|
||||
|
||||
// Quantità
|
||||
echo '
|
||||
<td class="text-center">
|
||||
'.Translator::numberToLocale($r['qta'], 'qta').' '.$r['um'].'
|
||||
</td>';
|
||||
|
||||
// Prezzo unitario
|
||||
echo "
|
||||
<td class='text-center'>
|
||||
".moneyFormat($r['prezzo_vendita']);
|
||||
|
||||
if ($r['sconto'] > 0) {
|
||||
echo "
|
||||
<br><small class='text-muted'>- ".tr('sconto _TOT_ _TYPE_', [
|
||||
'_TOT_' => Translator::numberToLocale($r['sconto_unitario']),
|
||||
'_TYPE_' => ($r['tipo_sconto'] == 'PRC' ? '%' : currency()),
|
||||
]).'</small>';
|
||||
|
||||
if ($count <= 1) {
|
||||
$count += 0.4;
|
||||
}
|
||||
}
|
||||
|
||||
echo '
|
||||
</td>';
|
||||
|
||||
// Netto
|
||||
$netto = $r['prezzo_vendita'] * $r['qta'];
|
||||
echo '
|
||||
<td class="text-center">
|
||||
'.moneyFormat($netto);
|
||||
|
||||
if ($r['sconto'] > 0) {
|
||||
echo "
|
||||
<br><small class='text-muted'>- ".tr('sconto _TOT_ _TYPE_', [
|
||||
'_TOT_' => Translator::numberToLocale($r['sconto']),
|
||||
'_TYPE_' => currency(),
|
||||
]).'</small>';
|
||||
|
||||
if ($count <= 1) {
|
||||
$count += 0.4;
|
||||
}
|
||||
}
|
||||
|
||||
echo '
|
||||
</td>
|
||||
</tr>';
|
||||
|
||||
$sconto_spese[] = $r['sconto'];
|
||||
$imponibile_spese[] = $r['prezzo_vendita'] * $r['qta'];
|
||||
}
|
||||
}
|
||||
|
||||
echo '
|
||||
</tbody>';
|
||||
|
||||
$sconto_spese = sum($sconto_spese);
|
||||
$imponibile_spese = sum($imponibile_spese);
|
||||
$totale_spese = $imponibile_spese - $sconto_spese;
|
||||
|
||||
$sconto[] = $sconto_spese;
|
||||
$imponibile[] = $imponibile_spese;
|
||||
|
||||
// Totale spese aggiuntive
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="2" class="text-right">
|
||||
<b>'.tr('Totale spese aggiuntive', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
|
||||
<th colspan="2" class="text-center">
|
||||
<b>'.moneyFormat($totale_spese).'</b>
|
||||
</th>
|
||||
</tr>';
|
||||
|
||||
echo '
|
||||
</table>';
|
||||
}
|
||||
}
|
||||
|
||||
// TOTALE COSTI FINALI
|
||||
$sconto = sum($sconto);
|
||||
$imponibile = sum($imponibile);
|
||||
|
||||
$totale = $imponibile - $sconto;
|
||||
|
||||
//$rs = $dbo->fetchArray('SELECT SUM(subtotale) as budget FROM `co_righe_preventivi` WHERE idpreventivo = '.prepare($id_record));
|
||||
//$budget = $rs[0]['budget'];
|
||||
$budget = get_imponibile_preventivo($id_record);
|
||||
|
||||
//pulisco da informazioni irrilevanti (imponibile,iva)
|
||||
$show = false;
|
||||
|
||||
$rapporto = floatval($budget) - floatval($totale);
|
||||
|
||||
// Totale imponibile
|
||||
echo '
|
||||
<table class="table table-bordered">';
|
||||
|
||||
if ($show) {
|
||||
echo '<tr>
|
||||
<td colspan="3" class="text-right border-top">
|
||||
<b>'.tr('Imponibile', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
|
||||
<th colspan="2" class="text-center">
|
||||
<b>'.moneyFormat($imponibile).'</b>
|
||||
</th>
|
||||
</tr>';
|
||||
|
||||
// Eventuale sconto incondizionato
|
||||
if (!empty($sconto)) {
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="3" class="text-right border-top">
|
||||
<b>'.tr('Sconto', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
|
||||
<th colspan="2" class="text-center">
|
||||
<b>-'.moneyFormat($sconto).'</b>
|
||||
</th>
|
||||
</tr>';
|
||||
|
||||
// Totale imponibile
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="3" class="text-right border-top">
|
||||
<b>'.tr('Totale imponibile', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
|
||||
<th colspan="2" class="text-center">
|
||||
<b>'.moneyFormat($totale).'</b>
|
||||
</th>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
// IVA
|
||||
$rs = $dbo->fetchArray('SELECT * FROM co_iva WHERE co_iva.id = '.prepare(setting('Iva predefinita')));
|
||||
$percentuale_iva = $rs[0]['percentuale'];
|
||||
$iva = $totale / 100 * $percentuale_iva;
|
||||
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="3" class="text-right border-top">
|
||||
<b>'.tr('Iva (_PRC_%)', [
|
||||
'_PRC_' => Translator::numberToLocale($percentuale_iva, 0),
|
||||
], ['upper' => true]).':</b>
|
||||
</td>
|
||||
|
||||
<th colspan="2" class="text-center">
|
||||
<b>'.moneyFormat($iva).'</b>
|
||||
</th>
|
||||
</tr>';
|
||||
|
||||
//$totale = sum($totale, $iva);
|
||||
}
|
||||
|
||||
// TOTALE
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="3" class="text-right border-top">
|
||||
<b>'.tr('Totale consuntivo (no iva)', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<th colspan="2" class="text-center">
|
||||
<b>'.moneyFormat($totale).'</b>
|
||||
</th>
|
||||
</tr>';
|
||||
|
||||
// BUDGET
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="3" class="text-right border-top">
|
||||
<b>'.tr('Budget (no IVA)', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<th colspan="2" class="text-center">
|
||||
<b>'.moneyFormat($budget).'</b>
|
||||
</th>
|
||||
</tr>';
|
||||
|
||||
// RAPPORTO
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="3" class="text-right border-top">
|
||||
<b>'.tr('Rapporto budget/spesa (no IVA)', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<th colspan="2" class="text-center">
|
||||
<b>'.moneyFormat($rapporto).'</b>
|
||||
</th>
|
||||
</tr>';
|
||||
|
||||
echo'
|
||||
</table>';
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
include_once __DIR__.'/../riepilogo_interventi/bottom.php';
|
||||
|
||||
$budget = get_imponibile_preventivo($id_record);
|
||||
|
||||
$rapporto = floatval($budget) - floatval($somma_totale_imponibile);
|
||||
|
||||
if ($pricing) {
|
||||
// Totale imponibile
|
||||
echo '
|
||||
<table class="table table-bordered">';
|
||||
|
||||
// TOTALE
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="3" class="text-right border-top">
|
||||
<b>'.tr('Totale consuntivo (no iva)', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<th colspan="2" class="text-center">
|
||||
<b>'.moneyFormat($somma_totale_imponibile).'</b>
|
||||
</th>
|
||||
</tr>';
|
||||
|
||||
// BUDGET
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="3" class="text-right border-top">
|
||||
<b>'.tr('Budget (no IVA)', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<th colspan="2" class="text-center">
|
||||
<b>'.moneyFormat($budget).'</b>
|
||||
</th>
|
||||
</tr>';
|
||||
|
||||
// RAPPORTO
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="3" class="text-right border-top">
|
||||
<b>'.tr('Rapporto budget/spesa (no IVA)', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<th colspan="2" class="text-center">
|
||||
<b>'.moneyFormat($rapporto).'</b>
|
||||
</th>
|
||||
</tr>';
|
||||
|
||||
echo '
|
||||
</table>';
|
||||
}
|
|
@ -2,10 +2,12 @@
|
|||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
$module_name = 'Preventivi';
|
||||
use Modules\Preventivi\Preventivo;
|
||||
|
||||
// Lettura info fattura
|
||||
$records = $dbo->fetchArray('SELECT *, data_bozza AS data FROM co_preventivi WHERE id='.prepare($id_record));
|
||||
$documento = Preventivo::find($id_record);
|
||||
$records = $documento->interventi;
|
||||
|
||||
$id_cliente = $records[0]['idanagrafica'];
|
||||
$id_sede = $records[0]['idsede'];
|
||||
$id_cliente = $documento['idanagrafica'];
|
||||
$id_sede = $documento['idsede'];
|
||||
|
||||
$pricing = $options['pricing'];
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
<?php
|
||||
|
||||
include __DIR__.'/../riepilogo_interventi/piece.php';
|
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
echo '
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
<div class="text-center">
|
||||
<h4 class="text-bold">'.tr('Consuntivo', [], ['upper' => true]).'</h4>
|
||||
<b>'.tr('Preventivo num. _NUM_ del _DATE_', [
|
||||
'_NUM_' => $documento['numero'],
|
||||
'_DATE_' => Translator::dateToLocale($documento['data_bozza']),
|
||||
], ['upper' => true]).'</b>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-5 col-xs-offset-1">
|
||||
<table class="table" style="width:100%;margin-top:5mm;">
|
||||
<tr>
|
||||
<td colspan=2 class="border-full" style="height:16mm;">
|
||||
<p class="small-bold">'.tr('Spett.le', [], ['upper' => true]).'</p>
|
||||
<p>$c_ragionesociale$</p>
|
||||
<p>$c_indirizzo$ $c_citta_full$</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="border-bottom border-left">
|
||||
<p class="small-bold">'.tr('Partita IVA', [], ['upper' => true]).'</p>
|
||||
</td>
|
||||
<td class="border-right border-bottom text-right">
|
||||
<small>$c_piva$</small>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="border-bottom border-left">
|
||||
<p class="small-bold">'.tr('Codice fiscale', [], ['upper' => true]).'</p>
|
||||
</td>
|
||||
<td class="border-right border-bottom text-right">
|
||||
<small>$c_codicefiscale$</small>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
// Descrizione
|
||||
if (!empty($documento['descrizione'])) {
|
||||
echo '
|
||||
<p>'.nl2br($documento['descrizione']).'</p>
|
||||
<br>';
|
||||
}
|
||||
|
||||
echo '
|
||||
<table class="table table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="2">'.tr('Documento', [], ['upper' => true]).'</th>
|
||||
<th class="text-center">'.tr('Imponibile', [], ['upper' => true]).'</th>
|
||||
<th class="text-center">'.tr('Sconto', [], ['upper' => true]).'</th>
|
||||
<th class="text-center">'.tr('Totale imponibile', [], ['upper' => true]).'</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>';
|
|
@ -12,9 +12,9 @@ echo '
|
|||
<th class="text-right" style="border-left: 0;">
|
||||
<b>'.tr('Totale', [], ['upper' => true]).':</b>
|
||||
</th>
|
||||
<th class="text-right">'.moneyFormat($somma_imponibile, 2).'</th>
|
||||
<th class="text-right">'.moneyFormat($somma_sconto, 2).'</th>
|
||||
<th class="text-right">'.moneyFormat($somma_totale_imponibile, 2).'</th>
|
||||
<th class="text-center">'.($pricing ? moneyFormat($somma_imponibile, 2) : '-').'</th>
|
||||
<th class="text-center">'.($pricing ? moneyFormat($somma_sconto, 2) : '-').'</th>
|
||||
<th class="text-center">'.($pricing ? moneyFormat($somma_totale_imponibile, 2) : '-').'</th>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>';
|
||||
|
|
|
@ -4,6 +4,7 @@ include_once __DIR__.'/../../core.php';
|
|||
|
||||
use Modules\Interventi\Intervento;
|
||||
|
||||
print_r($record['id']);
|
||||
$intervento = Intervento::find($record['id']);
|
||||
|
||||
$imponibile = $intervento->imponibile;
|
||||
|
@ -14,19 +15,22 @@ $somma_imponibile[] = $imponibile;
|
|||
$somma_sconto[] = $sconto;
|
||||
$somma_totale_imponibile[] = $totale_imponibile;
|
||||
|
||||
$pricing = isset($pricing) ? $pricing : true;
|
||||
|
||||
// Informazioni intervento
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<p>'.tr('Intervento _NUM_ del _DATE_', [
|
||||
'_NUM_' => $intervento['codice'],
|
||||
'_DATE_' => dateFormat($record['Data inizio']),
|
||||
'_NUM_' => $intervento->codice,
|
||||
'_DATE_' => dateFormat($intervento->inizio),
|
||||
]).'</p>
|
||||
<small><b>'.tr('Cliente').':</b> '.$intervento->anagrafica->ragione_sociale.'</small>
|
||||
<p><small><b>'.tr('Cliente').':</b> '.$intervento->anagrafica->ragione_sociale.'</small></p>
|
||||
<p><small><b>'.tr('Stato').':</b> '.$intervento->stato->descrizione.'</small></p>
|
||||
</td>
|
||||
<td class="text-right">'.moneyFormat($imponibile, 2).'</td>
|
||||
<td class="text-right">'.moneyFormat($sconto, 2).'</td>
|
||||
<td class="text-right">'.moneyFormat($totale_imponibile, 2).'</td>
|
||||
<td class="text-center">'.($pricing ? moneyFormat($imponibile, 2) : '-').'</td>
|
||||
<td class="text-center">'.($pricing ? moneyFormat($sconto, 2) : '-').'</td>
|
||||
<td class="text-center">'.($pricing ? moneyFormat($totale_imponibile, 2) : '-').'</td>
|
||||
</tr>';
|
||||
|
||||
// Sessioni
|
||||
|
@ -45,7 +49,7 @@ if (!empty($sessioni)) {
|
|||
echo '
|
||||
<tr>
|
||||
<td style="border-top: 0; border-bottom: 0;"></td>
|
||||
<td><small>'.$sessione->anagrafica->ragione_sociale.'</small></td>
|
||||
<td><small>'.$sessione->anagrafica->ragione_sociale.' <small>('.$sessione->tipo->descrizione.')</small></td>
|
||||
<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>
|
||||
|
@ -71,8 +75,8 @@ if (!$righe->isEmpty()) {
|
|||
<td style="border-top: 0; border-bottom: 0;"></td>
|
||||
<td><small>'.$riga->descrizione.'</small></td>
|
||||
<td class="text-center"><small>'.$riga->qta.' '.$riga->um.'</small></td>
|
||||
<td class="text-right"><small>'.moneyFormat($riga->prezzo_unitario_vendita).'</small></td>
|
||||
<td class="text-right"><small>'.moneyFormat($riga->totale_imponibile).'</small></td>
|
||||
<td class="text-center"><small>'.($pricing ? moneyFormat($riga->prezzo_unitario_vendita) : '-').'</small></td>
|
||||
<td class="text-center"><small>'.($pricing ? moneyFormat($riga->totale_imponibile) : '-').'</small></td>
|
||||
</tr>';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +1,3 @@
|
|||
UPDATE `zz_prints` SET `filename` = 'Preventivo num. {numero} del {data}' WHERE `name` = 'Preventivo (senza totali)';
|
||||
|
||||
DELETE FROM `zz_plugins` WHERE `name` = 'Pianificazione ordini di servizio';
|
||||
|
|
Loading…
Reference in New Issue