mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-16 19:40:44 +01:00
Miglioramento struttura Interventi
This commit is contained in:
parent
a16044c417
commit
79b61b34b1
@ -96,9 +96,15 @@ abstract class Article extends Row
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getMissingSerialsAttribute()
|
||||
public function getMissingSerialsNumberAttribute()
|
||||
{
|
||||
return $this->qta - count($this->serials);
|
||||
if (!$this->abilita_serial) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$missing = $this->qta - count($this->serials);
|
||||
|
||||
return $missing;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -24,14 +24,9 @@ abstract class Discount extends Row
|
||||
return $this->attributes['iva'];
|
||||
}
|
||||
|
||||
public function isSconto()
|
||||
{
|
||||
return $this->totale_imponibile > 0;
|
||||
}
|
||||
|
||||
public function isMaggiorazione()
|
||||
{
|
||||
return !$this->isSconto();
|
||||
return $this->totale_imponibile < 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -125,7 +125,7 @@ abstract class Row extends Description
|
||||
}
|
||||
|
||||
/**
|
||||
* Imposta il costo unitario della riga.
|
||||
* Imposta il prezzo unitario della riga.
|
||||
*
|
||||
* @param float $value
|
||||
*/
|
||||
@ -135,7 +135,7 @@ abstract class Row extends Description
|
||||
}
|
||||
|
||||
/**
|
||||
* Restituisce il costo unitario della riga.
|
||||
* Restituisce il prezzo unitario della riga.
|
||||
*/
|
||||
public function getPrezzoUnitarioVenditaAttribute()
|
||||
{
|
||||
|
@ -122,9 +122,7 @@ abstract class Document extends Model
|
||||
*/
|
||||
protected function getRigheContabili()
|
||||
{
|
||||
$sconto = $this->scontoGlobale ? [$this->scontoGlobale] : [];
|
||||
|
||||
return $this->getRighe()->merge(collect($sconto));
|
||||
return $this->getRighe();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -53,8 +53,8 @@ if (!empty($rsi)) {
|
||||
|
||||
// Tabella con i dati
|
||||
foreach ($rsi as $int) {
|
||||
$int = array_merge($int, get_costi_intervento($int['id']));
|
||||
$totale_stato[$int['idstatointervento']] = sum($totale_stato[$int['idstatointervento']], $int['totale_scontato']);
|
||||
$intervento = \Modules\Interventi\Intervento::find($int['id']);
|
||||
$totale_stato[$int['idstatointervento']] = sum($totale_stato[$int['idstatointervento']], $intervento->totale_imponibile);
|
||||
|
||||
// Riga intervento singolo
|
||||
echo '
|
||||
@ -76,15 +76,15 @@ if (!empty($rsi)) {
|
||||
</td>
|
||||
|
||||
<td class="text-right">
|
||||
'.Translator::numberToLocale($int['totale_costo']).'
|
||||
'.Translator::numberToLocale($intervento->spesa).'
|
||||
</td>
|
||||
|
||||
<td class="text-right">
|
||||
'.Translator::numberToLocale($int['totale_addebito']).'
|
||||
'.Translator::numberToLocale($intervento->imponibile).'
|
||||
</td>
|
||||
|
||||
<td class="text-right">
|
||||
'.Translator::numberToLocale($int['totale_scontato']).'
|
||||
'.Translator::numberToLocale($intervento->totale_imponibile).'
|
||||
</td>
|
||||
</tr>';
|
||||
|
||||
|
@ -133,26 +133,19 @@ foreach ($rs as $r) {
|
||||
}
|
||||
|
||||
// Calcoli
|
||||
$imponibile = sum(array_column($rs, 'subtotale'));
|
||||
$sconto = sum(array_column($rs, 'sconto'));
|
||||
$iva = sum(array_column($rs, 'iva'));
|
||||
|
||||
$totale_imponibile = sum($imponibile, -$sconto);
|
||||
|
||||
$totale = sum([
|
||||
$totale_imponibile,
|
||||
$iva,
|
||||
]);
|
||||
$imponibile = abs($contratto->imponibile);
|
||||
$sconto = $contratto->sconto;
|
||||
$totale_imponibile = abs($contratto->totale_imponibile);
|
||||
$iva = abs($contratto->iva);
|
||||
$totale = abs($contratto->totale);
|
||||
|
||||
echo '
|
||||
</tbody>';
|
||||
|
||||
// SCONTO
|
||||
if (abs($sconto) > 0) {
|
||||
// Totale totale imponibile
|
||||
echo '
|
||||
// Totale totale imponibile
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="5"" class="text-right">
|
||||
<td colspan="5" class="text-right">
|
||||
<b>'.tr('Imponibile', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@ -161,9 +154,11 @@ if (abs($sconto) > 0) {
|
||||
<td></td>
|
||||
</tr>';
|
||||
|
||||
// SCONTO
|
||||
if (!empty($sconto)) {
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="5"" class="text-right">
|
||||
<td colspan="5" class="text-right">
|
||||
<b><span class="tip" title="'.tr('Un importo positivo indica uno sconto, mentre uno negativo indica una maggiorazione').'"> <i class="fa fa-question-circle-o"></i> '.tr('Sconto/maggiorazione', [], ['upper' => true]).':</span></b>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@ -175,7 +170,7 @@ if (abs($sconto) > 0) {
|
||||
// Totale totale imponibile
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="5"" class="text-right">
|
||||
<td colspan="5" class="text-right">
|
||||
<b>'.tr('Totale imponibile', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@ -183,24 +178,12 @@ if (abs($sconto) > 0) {
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>';
|
||||
} else {
|
||||
// Totale imponibile
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="5"" class="text-right">
|
||||
<b>'.tr('Imponibile', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<span id="budget">'.moneyFormat($imponibile, 2).'</span>
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
// Totale iva
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="5"" class="text-right">
|
||||
<td colspan="5" class="text-right">
|
||||
<b>'.tr('Iva', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@ -212,7 +195,7 @@ echo '
|
||||
// Totale contratto
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="5"" class="text-right">
|
||||
<td colspan="5" class="text-right">
|
||||
<b>'.tr('Totale', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@ -240,7 +223,7 @@ $(document).ready(function(){
|
||||
order += ","+$(this).data("id");
|
||||
});
|
||||
order = order.replace(/^,/, "");
|
||||
|
||||
|
||||
$.post("'.$rootdir.'/actions.php", {
|
||||
id: ui.item.data("id"),
|
||||
id_module: '.$id_module.',
|
||||
|
@ -192,25 +192,11 @@ echo '
|
||||
</tbody>';
|
||||
|
||||
// Calcoli
|
||||
$imponibile = sum(array_column($rs, 'subtotale'));
|
||||
$sconto = sum(array_column($rs, 'sconto'));
|
||||
$iva = sum(array_column($rs, 'iva'));
|
||||
|
||||
$totale_imponibile = sum($imponibile, -$sconto);
|
||||
|
||||
$totale_iva = sum($iva, $record['iva_rivalsainps']);
|
||||
|
||||
$totale = sum([
|
||||
$totale_imponibile,
|
||||
$record['rivalsainps'],
|
||||
$totale_iva,
|
||||
]);
|
||||
|
||||
$netto_a_pagare = sum([
|
||||
$totale,
|
||||
//$marca_da_bollo, // Variabile non inizializzata!
|
||||
-$record['ritenutaacconto'],
|
||||
]);
|
||||
$imponibile = abs($ddt->imponibile);
|
||||
$sconto = $ddt->sconto;
|
||||
$totale_imponibile = abs($ddt->totale_imponibile);
|
||||
$iva = abs($ddt->iva);
|
||||
$totale = abs($ddt->totale);
|
||||
|
||||
// IMPONIBILE
|
||||
echo '
|
||||
@ -226,8 +212,8 @@ echo '
|
||||
<td></td>
|
||||
</tr>';
|
||||
|
||||
if (abs($sconto) > 0) {
|
||||
// SCONTO
|
||||
// SCONTO
|
||||
if (!empty($sconto)) {
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="5" class="text-right">
|
||||
@ -256,36 +242,19 @@ if (abs($sconto) > 0) {
|
||||
</tr>';
|
||||
}
|
||||
|
||||
// RIVALSA INPS
|
||||
if (abs($record['rivalsainps']) > 0) {
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="5" class="text-right">
|
||||
<b>'.tr('Rivalsa', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
|
||||
<td align="right">
|
||||
'.moneyFormat($record['rivalsainps'], 2).'
|
||||
</td>
|
||||
|
||||
<td></td>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
if (abs($totale_iva) > 0) {
|
||||
echo '
|
||||
// IVA
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="5" class="text-right">
|
||||
<b>'.tr('IVA', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
|
||||
<td align="right">
|
||||
'.moneyFormat($totale_iva, 2).'
|
||||
'.moneyFormat($iva, 2).'
|
||||
</td>
|
||||
|
||||
<td></td>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
// TOTALE
|
||||
echo '
|
||||
@ -301,54 +270,6 @@ echo '
|
||||
<td></td>
|
||||
</tr>';
|
||||
|
||||
// Mostra marca da bollo se c'è
|
||||
if (abs($record['bollo']) > 0) {
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="5" class="text-right">
|
||||
<b>'.tr('Marca da bollo', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
|
||||
<td align="right">
|
||||
'.moneyFormat($record['bollo'], 2).'
|
||||
</td>
|
||||
|
||||
<td></td>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
// RITENUTA D'ACCONTO
|
||||
if (abs($record['ritenutaacconto']) > 0) {
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="5" class="text-right">
|
||||
<b>'.tr("Ritenuta d'acconto", [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
|
||||
<td align="right">
|
||||
'.moneyFormat($record['ritenutaacconto'], 2).'
|
||||
</td>
|
||||
|
||||
<td></td>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
// NETTO A PAGARE
|
||||
if ($totale != $netto_a_pagare) {
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="5" class="text-right">
|
||||
<b>'.tr('Netto a pagare', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
|
||||
<td align="right">
|
||||
'.moneyFormat($netto_a_pagare, 2).'
|
||||
</td>
|
||||
|
||||
<td></td>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
echo '
|
||||
</table>';
|
||||
|
||||
|
@ -46,7 +46,9 @@ $rs = $dbo->fetchArray('SELECT
|
||||
AND in_interventi.id_preventivo IS NULL
|
||||
AND NOT in_interventi.id IN (SELECT idintervento FROM co_promemoria WHERE idintervento IS NOT NULL)');
|
||||
foreach ($rs as $key => $value) {
|
||||
$prezzo = get_costi_intervento($value['id'])['totale'];
|
||||
$intervento = \Modules\Interventi\Intervento::find($value['id']);
|
||||
$prezzo = $intervento->totale;
|
||||
|
||||
$rs[$key]['prezzo'] = Translator::numberToLocale($prezzo);
|
||||
$rs[$key]['descrizione_intervento'] = strip_tags($rs[$key]['descrizione_intervento']);
|
||||
|
||||
|
@ -284,7 +284,7 @@ echo '
|
||||
</tbody>';
|
||||
|
||||
$imponibile = abs($fattura->imponibile);
|
||||
$sconto = abs($fattura->sconto);
|
||||
$sconto = $fattura->sconto;
|
||||
$totale_imponibile = abs($fattura->totale_imponibile);
|
||||
$iva = abs($fattura->iva);
|
||||
$totale = abs($fattura->totale);
|
||||
|
@ -219,8 +219,8 @@ echo '
|
||||
success: function(){
|
||||
$('#bs-popup').modal('hide');
|
||||
|
||||
// Ricarico gli articoli
|
||||
$('#articoli').load(globals.rootdir + '/modules/interventi/ajax_articoli.php?id_module=<?php echo $id_module; ?>&id_record=<?php echo $id_record; ?>');
|
||||
// Ricarico le righe
|
||||
$('#righe').load(globals.rootdir + '/modules/interventi/ajax_righe.php?id_module=<?php echo $id_module; ?>&id_record=<?php echo $id_record; ?>');
|
||||
|
||||
// Ricarico la tabella dei costi
|
||||
$('#costi').load(globals.rootdir + '/modules/interventi/ajax_costi.php?id_module=<?php echo $id_module; ?>&id_record=<?php echo $id_record; ?>');
|
||||
|
@ -1,160 +0,0 @@
|
||||
<?php
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
$show_prezzi = Auth::user()['gruppo'] != 'Tecnici' || (Auth::user()['gruppo'] == 'Tecnici' && setting('Mostra i prezzi al tecnico'));
|
||||
|
||||
$query = 'SELECT *, (SELECT id FROM mg_articoli WHERE mg_articoli_interventi.idarticolo = mg_articoli.id) ref_articolo, (SELECT codice FROM mg_articoli WHERE id=mg_articoli_interventi.idarticolo) AS codice, mg_articoli_interventi.id AS idriga, (SELECT prc_guadagno FROM mg_listini WHERE id=(SELECT idlistino_vendite FROM an_anagrafiche WHERE idanagrafica=(SELECT idanagrafica FROM in_interventi WHERE id=mg_articoli_interventi.idintervento) ) ) AS prc_guadagno FROM mg_articoli_interventi WHERE idintervento='.prepare($id_record);
|
||||
$rs = $dbo->fetchArray($query);
|
||||
|
||||
if (!empty($rs)) {
|
||||
echo '
|
||||
<table class="table table-striped table-condensed table-hover table-bordered">
|
||||
<tr>
|
||||
<th>'.tr('Articolo').'</th>
|
||||
<th width="8%">'.tr('Q.tà').'</th>';
|
||||
|
||||
if ($show_prezzi) {
|
||||
echo '
|
||||
<th width="15%">'.tr('Prezzo di acquisto').'</th>';
|
||||
}
|
||||
|
||||
if ($show_prezzi) {
|
||||
echo '
|
||||
<th width="15%">'.tr('Prezzo di vendita').'</th>
|
||||
<th width="10%">'.tr('Iva').'</th>
|
||||
<th width="15%">'.tr('Imponibile').'</th>';
|
||||
}
|
||||
|
||||
if (!$record['flag_completato']) {
|
||||
echo '
|
||||
<th width="120" class="text-center">'.tr('#').'</th>';
|
||||
}
|
||||
echo '
|
||||
</tr>';
|
||||
|
||||
foreach ($rs as $r) {
|
||||
$extra = '';
|
||||
$mancanti = 0;
|
||||
|
||||
// Individuazione dei seriali
|
||||
if (!empty($r['idarticolo']) && !empty($r['abilita_serial'])) {
|
||||
$serials = array_column($dbo->fetchArray('SELECT serial FROM mg_prodotti WHERE serial IS NOT NULL AND id_riga_intervento='.prepare($r['id'])), 'serial');
|
||||
$mancanti = $r['qta'] - count($serials);
|
||||
|
||||
if ($mancanti > 0) {
|
||||
$extra = 'class="warning"';
|
||||
} else {
|
||||
$mancanti = 0;
|
||||
}
|
||||
}
|
||||
|
||||
echo '
|
||||
<tr '.$extra.'>
|
||||
<td>
|
||||
<input type="hidden" name="id" value="'.$r['id'].'">
|
||||
'.((!empty($r['ref_articolo'])) ? Modules::link('Articoli', $r['idarticolo'], (!empty($r['codice']) ? $r['codice'].' - ' : '').$r['descrizione']) : $r['descrizione'].' '.tr('[ELIMINATO]'));
|
||||
|
||||
// Info extra (lotto, serial, altro)
|
||||
if (!empty($r['abilita_serial'])) {
|
||||
if (!empty($mancanti)) {
|
||||
echo '
|
||||
<br><b><small class="text-danger">'.tr('_NUM_ serial mancanti', [
|
||||
'_NUM_' => $mancanti,
|
||||
]).'</small></b>';
|
||||
}
|
||||
if (!empty($serials)) {
|
||||
echo '
|
||||
<br>'.tr('SN').': '.implode(', ', $serials);
|
||||
}
|
||||
}
|
||||
|
||||
echo '
|
||||
</td>';
|
||||
|
||||
// Quantità
|
||||
echo '
|
||||
<td class="text-right">
|
||||
'.Translator::numberToLocale($r['qta'], 'qta').' '.$r['um'].'
|
||||
</td>';
|
||||
|
||||
if ($show_prezzi) {
|
||||
echo '
|
||||
<td class="text-right">
|
||||
'.moneyFormat($r['prezzo_acquisto']).'
|
||||
</td>';
|
||||
}
|
||||
|
||||
if ($show_prezzi) {
|
||||
// Prezzo unitario
|
||||
echo '
|
||||
<td class="text-right">
|
||||
'.moneyFormat($r['prezzo_vendita']);
|
||||
|
||||
if ($r['sconto_unitario'] > 0) {
|
||||
echo '
|
||||
<br><span class="label label-danger">
|
||||
- '.tr('sconto _TOT_ _TYPE_', [
|
||||
'_TOT_' => Translator::numberToLocale($r['sconto_unitario']),
|
||||
'_TYPE_' => ($r['tipo_sconto'] == 'PRC' ? '%' : currency()),
|
||||
]).'
|
||||
</span>';
|
||||
}
|
||||
|
||||
echo '
|
||||
</td>';
|
||||
|
||||
echo '
|
||||
<td class="text-right">
|
||||
'.moneyFormat($r['iva']).'
|
||||
</td>';
|
||||
|
||||
// Prezzo di vendita
|
||||
echo '
|
||||
<td class="text-right">
|
||||
<span class="prezzo_articolo">'.Translator::numberToLocale(sum($r['prezzo_vendita'] * $r['qta'], -$r['sconto'])).'</span> '.currency().'
|
||||
</td>';
|
||||
}
|
||||
|
||||
// Pulsante per riportare nel magazzino centrale.
|
||||
// Visibile solo se l'intervento non è stato nè fatturato nè completato.
|
||||
if (!$record['flag_completato']) {
|
||||
echo '
|
||||
<td class="text-center">';
|
||||
|
||||
if ($r['abilita_serial']) {
|
||||
echo '
|
||||
<button type="button" class="btn btn-info btn-xs" data-toggle="tooltip" onclick="launch_modal(\''.tr('Modifica articoli').'\', \''.$rootdir.'/modules/fatture/add_serial.php?id_module='.$id_module.'&id_record='.$id_record.'&idarticolo='.$r['idriga'].'&idriga='.$r['id'].'\', 1);"><i class="fa fa-barcode"></i></button>';
|
||||
}
|
||||
|
||||
echo '
|
||||
|
||||
<button type="button" class="btn btn-warning btn-xs" data-toggle="tooltip" onclick="launch_modal(\''.tr('Modifica articoli').'\', \''.$rootdir.'/modules/interventi/add_articolo.php?id_module='.$id_module.'&id_record='.$id_record.'&idriga='.$r['idriga'].'\', 1);"><i class="fa fa-edit"></i></button>
|
||||
|
||||
<button type="button" class="btn btn-danger btn-xs" data-toggle="tooltip" title="Riporta in magazzino" onclick="if(confirm(\''.tr('Riportare questo articolo in magazzino?').'\') ){ ritorna_al_magazzino(\''.$r['id'].'\'); }"><i class="fa fa-angle-double-left"></i> <i class="fa fa-truck"></i></button>
|
||||
</td>';
|
||||
}
|
||||
echo '
|
||||
</tr>';
|
||||
}
|
||||
|
||||
echo '
|
||||
</table>';
|
||||
} else {
|
||||
echo '
|
||||
<p>'.tr('Nessun articolo presente').'.</p>';
|
||||
}
|
||||
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
function ritorna_al_magazzino( id ){
|
||||
$.post(globals.rootdir + '/modules/interventi/actions.php', {op: 'unlink_articolo', idriga: id, id_record: '<?php echo $id_record; ?>', id_module: '<?php echo $id_module; ?>' }, function(data, result){
|
||||
if( result == 'success' ){
|
||||
// ricarico l'elenco degli articoli
|
||||
$('#articoli').load(globals.rootdir + '/modules/interventi/ajax_articoli.php?id_module=<?php echo $id_module; ?>&id_record=<?php echo $id_record; ?>');
|
||||
|
||||
$('#costi').load(globals.rootdir + '/modules/interventi/ajax_costi.php?id_module=<?php echo $id_module; ?>&id_record=<?php echo $id_record; ?>');
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
@ -6,15 +6,15 @@ if (file_exists(__DIR__.'/../../../core.php')) {
|
||||
include_once __DIR__.'/../../core.php';
|
||||
}
|
||||
|
||||
use Modules\Interventi\Intervento;
|
||||
|
||||
$intervento = Intervento::find($id_record);
|
||||
$sessioni = $intervento->sessioni;
|
||||
$righe = $intervento->getRighe();
|
||||
|
||||
$show_prezzi = Auth::user()['gruppo'] != 'Tecnici' || (Auth::user()['gruppo'] == 'Tecnici' && setting('Mostra i prezzi al tecnico'));
|
||||
|
||||
$idiva = setting('Iva predefinita');
|
||||
$rs_iva = $dbo->fetchArray('SELECT descrizione, percentuale, indetraibile FROM co_iva WHERE id='.prepare($idiva));
|
||||
($rs_iva[0]['percentuale'] > 0) ? $hide = '' : $hide = 'hide';
|
||||
|
||||
if ($show_prezzi) {
|
||||
$costi = get_costi_intervento($id_record);
|
||||
|
||||
$rss = $dbo->fetchArray('SELECT in_statiintervento.completato AS flag_completato FROM in_statiintervento INNER JOIN in_interventi ON in_statiintervento.idstatointervento=in_interventi.idstatointervento WHERE in_interventi.id='.prepare($id_record));
|
||||
|
||||
if ($rss[0]['flag_completato']) {
|
||||
@ -26,77 +26,109 @@ if ($show_prezzi) {
|
||||
echo '
|
||||
<!-- Riepilogo dei costi -->
|
||||
<table class="table table condensed table-striped table-hover table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="40%"></th>
|
||||
<th width="20%" class="text-center">'.tr('Costo', [], ['upper' => true]).' <span class="tip" title="'.tr('Costo interno').'"><i class="fa fa-question-circle-o"></i></span></th>
|
||||
<th width="20%" class="text-center">'.tr('Addebito', [], ['upper' => true]).' <span class="tip" title="'.tr('Addebito al cliente').'"><i class="fa fa-question-circle-o"></i></span></th>
|
||||
<th width="20%" class="text-center">'.tr('Tot. Scontato', [], ['upper' => true]).' <span class="tip" title="'.tr('Addebito scontato al cliente').'"><i class="fa fa-question-circle-o"></i></span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>'.tr('Totale manodopera', [], ['upper' => true]).'</th>
|
||||
<td class="text-right">'.moneyFormat($sessioni->sum('costo_manodopera'), 2).'</td>
|
||||
<td class="text-right">'.moneyFormat($sessioni->sum('prezzo_manodopera'), 2).'</td>
|
||||
<td class="text-right">'.moneyFormat($sessioni->sum('prezzo_manodopera_scontato'), 2).'</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th>'.tr('Totale diritto di chiamata', [], ['upper' => true]).'</th>
|
||||
<td class="text-right">'.moneyFormat($sessioni->sum('costo_diritto_chiamata'), 2).'</td>
|
||||
<td class="text-right">'.moneyFormat($sessioni->sum('prezzo_diritto_chiamata'), 2).'</td>
|
||||
<td class="text-right">'.moneyFormat($sessioni->sum('prezzo_diritto_chiamata'), 2).'</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th>'.tr('Totale viaggio', [], ['upper' => true]).'</th>
|
||||
<td class="text-right">'.moneyFormat($sessioni->sum('costo_viaggio'), 2).'</td>
|
||||
<td class="text-right">'.moneyFormat($sessioni->sum('prezzo_viaggio'), 2).'</td>
|
||||
<td class="text-right">'.moneyFormat($sessioni->sum('prezzo_viaggio_scontato'), 2).'</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th>'.tr('Totale righe', [], ['upper' => true]).'</th>
|
||||
<td class="text-right">'.moneyFormat($righe->sum('spesa'), 2).'</td>
|
||||
<td class="text-right">'.moneyFormat($righe->sum('imponibile'), 2).'</td>
|
||||
<td class="text-right">'.moneyFormat($righe->sum('totale_imponibile'), 2).'</td>
|
||||
</tr>
|
||||
</tbody>';
|
||||
|
||||
// Calcoli
|
||||
$imponibile = abs($intervento->imponibile);
|
||||
$sconto = $intervento->sconto;
|
||||
$totale_imponibile = abs($intervento->totale_imponibile);
|
||||
$iva = abs($intervento->iva);
|
||||
$totale = abs($intervento->totale);
|
||||
|
||||
echo '
|
||||
<tr>
|
||||
<th width="40%"></th>
|
||||
<th width="20%" class="text-center">'.tr('Costo', [], ['upper' => true]).' <span class="tip" title="'.tr('Costo interno').'"><i class="fa fa-question-circle-o"></i></span></th>
|
||||
<th width="20%" class="text-center">'.tr('Addebito', [], ['upper' => true]).' <span class="tip" title="'.tr('Addebito al cliente').'"><i class="fa fa-question-circle-o"></i></span></th>
|
||||
<th width="20%" class="text-center">'.tr('Tot. Scontato', [], ['upper' => true]).' <span class="tip" title="'.tr('Addebito scontato al cliente').'"><i class="fa fa-question-circle-o"></i></span></th>
|
||||
</tr>
|
||||
<td colspan="3" class="text-right">
|
||||
<b>'.tr('Imponibile', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<td align="right">
|
||||
'.moneyFormat($imponibile, 2).'
|
||||
</td>
|
||||
</tr>';
|
||||
|
||||
// SCONTO
|
||||
if (!empty($sconto)) {
|
||||
echo '
|
||||
<tr>
|
||||
<th>'.tr('Totale manodopera', [], ['upper' => true]).'</th>
|
||||
<td class="text-right">'.moneyFormat($costi['manodopera_costo'], 2).'</td>
|
||||
<td class="text-right">'.moneyFormat($costi['manodopera_addebito'], 2).'</td>
|
||||
<td class="text-right">'.moneyFormat($costi['manodopera_scontato'], 2).'</td>
|
||||
</tr>
|
||||
<td colspan="3" class="text-right">
|
||||
<b><span class="tip" title="'.tr('Un importo positivo indica uno sconto, mentre uno negativo indica una maggiorazione').'"> <i class="fa fa-question-circle-o"></i> '.tr('Sconto/maggiorazione', [], ['upper' => true]).':</span></b>
|
||||
</td>
|
||||
<td align="right">
|
||||
'.moneyFormat($sconto, 2).'
|
||||
</td>
|
||||
</tr>';
|
||||
|
||||
// Totale imponibile
|
||||
echo '
|
||||
<tr>
|
||||
<th>'.tr('Totale diritto di chiamata', [], ['upper' => true]).'</th>
|
||||
<td class="text-right">'.moneyFormat($costi['dirittochiamata_costo'], 2).'</td>
|
||||
<td class="text-right">'.moneyFormat($costi['dirittochiamata_addebito'], 2).'</td>
|
||||
<td class="text-right">'.moneyFormat($costi['dirittochiamata_scontato'], 2).'</td>
|
||||
</tr>
|
||||
<td colspan="3" class="text-right">
|
||||
<b>'.tr('Totale imponibile', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<td align="right">
|
||||
'.moneyFormat($totale_imponibile, 2).'
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
// Totale iva
|
||||
echo '
|
||||
<tr>
|
||||
<th>'.tr('Totale viaggio', [], ['upper' => true]).'</th>
|
||||
<td class="text-right">'.moneyFormat($costi['viaggio_costo'], 2).'</td>
|
||||
<td class="text-right">'.moneyFormat($costi['viaggio_addebito'], 2).'</td>
|
||||
<td class="text-right">'.moneyFormat($costi['viaggio_scontato'], 2).'</td>
|
||||
</tr>
|
||||
<td colspan="3" class="text-right">
|
||||
<b>'.tr('IVA', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<td align="right">
|
||||
'.moneyFormat($iva, 2).'
|
||||
</td>
|
||||
</tr>';
|
||||
|
||||
// Totale preventivo
|
||||
echo '
|
||||
<tr>
|
||||
<th>'.tr('Totale articoli', [], ['upper' => true]).'</th>
|
||||
<td class="text-right">'.moneyFormat($costi['ricambi_costo'], 2).'</td>
|
||||
<td class="text-right">'.moneyFormat($costi['ricambi_addebito'], 2).'</td>
|
||||
<td class="text-right">'.moneyFormat($costi['ricambi_scontato'], 2).'</td>
|
||||
</tr>
|
||||
<td colspan="3" class="text-right">
|
||||
<b>'.tr('Totale', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<td align="right">
|
||||
'.moneyFormat($totale, 2).'
|
||||
</td>
|
||||
</tr>';
|
||||
|
||||
<tr>
|
||||
<th>'.tr('Totale altre spese', [], ['upper' => true]).'</th>
|
||||
<td class="text-right">'.moneyFormat($costi['altro_costo'], 2).'</td>
|
||||
<td class="text-right">'.moneyFormat($costi['altro_addebito'], 2).'</td>
|
||||
<td class="text-right">'.moneyFormat($costi['altro_scontato'], 2).'</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th>'.tr('Sconto incondizionato', [], ['upper' => true]).'</th>
|
||||
<td class="text-right">-</td>
|
||||
<td class="text-right">-</td>
|
||||
<td class="text-right">'.moneyFormat(-$costi['sconto_globale'], 2).'</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr class='.$hide.' >
|
||||
<th>'.tr('Imponibile', [], ['upper' => true]).'</th>
|
||||
<td class="text-right">'.moneyFormat($costi['totale_costo'], 2).'</td>
|
||||
<td class="text-right">'.moneyFormat($costi['totale_addebito'], 2).'</td>
|
||||
<td class="text-right">'.moneyFormat($costi['totale_scontato'], 2).'</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr class='.$hide.' >
|
||||
<th>'.tr('IVA', [], ['upper' => true]).'</th>
|
||||
<td class="text-right">'.moneyFormat($costi['iva_costo'], 2).'</td>
|
||||
<td class="text-right">'.moneyFormat($costi['iva_addebito'], 2).'</td>
|
||||
<td class="text-right">'.moneyFormat($costi['iva_totale'], 2).'</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th>'.tr('Totale', [], ['upper' => true]).'</th>
|
||||
<th class="text-right">'.moneyFormat($costi['totaleivato_costo'], 2).'</th>
|
||||
<th class="text-right">'.moneyFormat($costi['totaleivato_addebito'], 2).'</th>
|
||||
<th class="text-right">'.moneyFormat($costi['totale'], 2).'</th>
|
||||
</tr>
|
||||
echo '
|
||||
</table>';
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Modules\Interventi\Intervento;
|
||||
|
||||
if (file_exists(__DIR__.'/../../../core.php')) {
|
||||
include_once __DIR__.'/../../../core.php';
|
||||
} else {
|
||||
@ -8,104 +10,147 @@ if (file_exists(__DIR__.'/../../../core.php')) {
|
||||
|
||||
$show_prezzi = Auth::user()['gruppo'] != 'Tecnici' || (Auth::user()['gruppo'] == 'Tecnici' && setting('Mostra i prezzi al tecnico'));
|
||||
|
||||
$query = 'SELECT * FROM in_righe_interventi WHERE idintervento='.prepare($id_record).' ORDER BY id ASC';
|
||||
$rs2 = $dbo->fetchArray($query);
|
||||
$intervento = Intervento::find($id_record);
|
||||
$righe = $intervento->getRighe();
|
||||
|
||||
if (count($rs2) > 0) {
|
||||
if (!$righe->isEmpty()) {
|
||||
echo '
|
||||
<table class="table table-striped table-condensed table-hover table-bordered">
|
||||
<tr>
|
||||
<th>'.tr('Descrizione').'</th>
|
||||
<th width="8%">'.tr('Q.tà').'</th>
|
||||
<th width="15%">'.tr('Prezzo di acquisto').'</th>';
|
||||
<table class="table table-striped table-hover table-condensed table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>'.tr('Descrizione').'</th>
|
||||
<th class="text-center" width="8%">'.tr('Q.tà').'</th>
|
||||
<th class="text-center" width="15%">'.tr('Prezzo di acquisto').'</th>';
|
||||
|
||||
if ($show_prezzi) {
|
||||
echo '
|
||||
<th width="15%">'.tr('Prezzo di vendita').'</th>
|
||||
<th width="10%">'.tr('Iva').'</th>
|
||||
<th width="15%">'.tr('Subtotale').'</th>';
|
||||
<th class="text-center" width="15%">'.tr('Prezzo di vendita').'</th>
|
||||
<th class="text-center" width="10%">'.tr('Iva').'</th>
|
||||
<th class="text-center" width="15%">'.tr('Imponibile').'</th>';
|
||||
}
|
||||
|
||||
if (!$record['flag_completato']) {
|
||||
echo '
|
||||
<th width="120" class="text-center">'.tr('#').'</th>';
|
||||
<th class="text-center" width="120" class="text-center">'.tr('#').'</th>';
|
||||
}
|
||||
echo '
|
||||
</tr>';
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>';
|
||||
|
||||
foreach ($righe as $riga) {
|
||||
$r = $riga->toArray();
|
||||
|
||||
$extra = '';
|
||||
$mancanti = $riga->isArticolo() ? $riga->missing_serials_number : 0;
|
||||
if ($mancanti > 0) {
|
||||
$extra = 'class="warning"';
|
||||
}
|
||||
$descrizione = (!empty($riga->articolo) ? $riga->articolo->codice.' - ' : '').$riga['descrizione'];
|
||||
|
||||
foreach ($rs2 as $r) {
|
||||
echo '
|
||||
<tr>
|
||||
<td>
|
||||
<input type="hidden" name="id" value="'.$r['id'].'">
|
||||
'.nl2br($r['descrizione']).'
|
||||
</td>';
|
||||
<tr '.$extra.'>
|
||||
<td>
|
||||
'.Modules::link($riga->isArticolo() ? Modules::get('Articoli')['id'] : null, $riga->isArticolo() ? $riga['idarticolo'] : null, $descrizione);
|
||||
|
||||
if ($riga->isArticolo()) {
|
||||
if (!empty($mancanti)) {
|
||||
echo '
|
||||
<br><b><small class="text-danger">'.tr('_NUM_ serial mancanti', [
|
||||
'_NUM_' => $mancanti,
|
||||
]).'</small></b>';
|
||||
}
|
||||
|
||||
$serials = $riga->serials;
|
||||
if (!empty($serials)) {
|
||||
echo '
|
||||
<br>'.tr('SN').': '.implode(', ', $serials);
|
||||
}
|
||||
}
|
||||
|
||||
echo '
|
||||
</td>';
|
||||
|
||||
// Quantità
|
||||
echo '
|
||||
<td class="text-right">
|
||||
'.Translator::numberToLocale($r['qta'], 'qta').' '.$r['um'].'
|
||||
</td>';
|
||||
<td class="text-right">
|
||||
'.Translator::numberToLocale($r['qta'], 'qta').' '.$r['um'].'
|
||||
</td>';
|
||||
|
||||
//Costo unitario
|
||||
echo '
|
||||
<td class="text-right">
|
||||
'.moneyFormat($r['prezzo_acquisto']).'
|
||||
</td>';
|
||||
<td class="text-right">
|
||||
'.moneyFormat($riga->prezzo_unitario_acquisto).'
|
||||
</td>';
|
||||
|
||||
if ($show_prezzi) {
|
||||
// Prezzo unitario
|
||||
$netto = $r['prezzo_vendita'] - $r['sconto_unitario'];
|
||||
|
||||
echo '
|
||||
<td class="text-right">
|
||||
'.moneyFormat($r['prezzo_vendita']);
|
||||
<td class="text-right">
|
||||
'.moneyFormat($riga->prezzo_unitario_vendita);
|
||||
|
||||
if (abs($r['sconto_unitario']) > 0) {
|
||||
$text = $r['sconto_unitario'] > 0 ? tr('sconto _TOT_ _TYPE_') : tr('maggiorazione _TOT_ _TYPE_');
|
||||
|
||||
echo '
|
||||
<br><small class="label label-danger">'.replace($text, [
|
||||
<br><small class="label label-danger">'.replace($text, [
|
||||
'_TOT_' => Translator::numberToLocale(abs($r['sconto_unitario'])),
|
||||
'_TYPE_' => ($r['tipo_sconto'] == 'PRC' ? '%' : currency()),
|
||||
]).'</small>';
|
||||
}
|
||||
|
||||
echo '
|
||||
</td>';
|
||||
</td>';
|
||||
|
||||
echo '
|
||||
<td class="text-right">
|
||||
'.moneyFormat($r['iva']).'
|
||||
</td>';
|
||||
<td class="text-right">
|
||||
'.moneyFormat($r['iva']).'
|
||||
</td>';
|
||||
|
||||
// Prezzo di vendita
|
||||
echo '
|
||||
<td class="text-right">
|
||||
'.moneyFormat(sum($r['prezzo_vendita'] * $r['qta'], -$r['sconto'])).'
|
||||
</td>';
|
||||
<td class="text-right">
|
||||
'.moneyFormat($riga->imponibile).'
|
||||
</td>';
|
||||
}
|
||||
|
||||
// Pulsante per riportare nel magazzino centrale.
|
||||
// Visibile solo se l'intervento non è stato nè fatturato nè completato.
|
||||
if (!$record['flag_completato']) {
|
||||
$link = $r['is_sconto'] == 1 ? $structure->fileurl('row-edit.php') : $structure->fileurl('add_righe.php');
|
||||
$link = $riga->isSconto() ? $structure->fileurl('row-edit.php') : $structure->fileurl('add_righe.php');
|
||||
$link = $riga->isArticolo() ? $structure->fileurl('add_articolo.php') : $link;
|
||||
|
||||
echo '
|
||||
<td class="text-center">
|
||||
<button type="button" class="btn btn-warning btn-xs" data-toggle="tooltip" onclick="launch_modal(\''.tr('Modifica spesa').'\', \''.$link.'?id_module='.$id_module.'&id_record='.$id_record.'&idriga='.$r['id'].'\', 1);"><i class="fa fa-edit"></i></button>
|
||||
<button type="button" class="btn btn-danger btn-xs" data-toggle="tooltip" onclick="if(confirm(\''.tr('Eliminare questa spesa?').'\')){ elimina_riga( \''.$r['id'].'\' ); }"><i class="fa fa-trash"></i></button>
|
||||
</td>';
|
||||
<td class="text-center">';
|
||||
|
||||
if ($r['abilita_serial']) {
|
||||
echo '
|
||||
<button type="button" class="btn btn-info btn-xs" data-toggle="tooltip" onclick="launch_modal(\''.tr('Modifica articoli').'\', \''.$rootdir.'/modules/fatture/add_serial.php?id_module='.$id_module.'&id_record='.$id_record.'&idarticolo='.$r['idriga'].'&idriga='.$r['id'].'\', 1);">
|
||||
<i class="fa fa-barcode"></i>
|
||||
</button>';
|
||||
}
|
||||
|
||||
echo '
|
||||
<button type="button" class="btn btn-warning btn-xs" data-toggle="tooltip" onclick="launch_modal(\''.tr('Modifica').'\', \''.$link.'?id_module='.$id_module.'&id_record='.$id_record.'&idriga='.$r['id'].'\', 1);">
|
||||
<i class="fa fa-edit"></i>
|
||||
</button>
|
||||
|
||||
<button type="button" class="btn btn-danger btn-xs" data-toggle="tooltip" onclick="if(confirm(\''.tr('Eliminare questa riga?').'\')){ '.($riga->isArticolo() ? 'ritorna_al_magazzino' : 'elimina_riga').'( \''.$r['id'].'\' ); }">
|
||||
<i class="fa fa-trash"></i>
|
||||
</button>
|
||||
</td>';
|
||||
}
|
||||
echo '
|
||||
</tr>';
|
||||
</tr>';
|
||||
}
|
||||
|
||||
echo '
|
||||
</tbody>
|
||||
</table>';
|
||||
} else {
|
||||
echo '
|
||||
<p>'.tr('Nessuna spesa presente').'.</p>';
|
||||
<p>'.tr('Nessuna riga presente').'.</p>';
|
||||
}
|
||||
|
||||
?>
|
||||
@ -121,4 +166,15 @@ if (count($rs2) > 0) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function ritorna_al_magazzino( id ){
|
||||
$.post(globals.rootdir + '/modules/interventi/actions.php', {op: 'unlink_articolo', idriga: id, id_record: '<?php echo $id_record; ?>', id_module: '<?php echo $id_module; ?>' }, function(data, result){
|
||||
if( result == 'success' ){
|
||||
// ricarico l'elenco degli articoli
|
||||
$('#righe').load( globals.rootdir + '/modules/interventi/ajax_righe.php?id_module=<?php echo $id_module; ?>&id_record=<?php echo $id_record; ?>');
|
||||
|
||||
$('#costi').load(globals.rootdir + '/modules/interventi/ajax_costi.php?id_module=<?php echo $id_module; ?>&id_record=<?php echo $id_record; ?>');
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
@ -212,64 +212,45 @@ $_SESSION['superselect']['idsede_destinazione'] = $record['idsede_destinazione']
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
// Conteggio numero articoli intervento per eventuale blocco della sede di partenza
|
||||
$articoli = $dbo->fetchArray('SELECT mg_articoli_interventi.id FROM mg_articoli_interventi INNER JOIN in_interventi ON in_interventi.id=mg_articoli_interventi.idintervento WHERE in_interventi.id='.prepare($id_record));
|
||||
?>
|
||||
<!-- ARTICOLI -->
|
||||
<!-- RIGHE -->
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title"><?php echo tr('Materiale utilizzato'); ?></h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
{[ "type": "select", "label": "<?php echo tr('Partenza merce'); ?>", "name": "idsede_partenza", "ajax-source": "sedi_azienda", "value": "$idsede_partenza$", "readonly": "<?php echo ($record['flag_completato'] || sizeof($articoli)) ? 1 : 0; ?>" ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="articoli">
|
||||
<?php
|
||||
if (file_exists($docroot.'/modules/interventi/custom/ajax_articoli.php')) {
|
||||
include $docroot.'/modules/interventi/custom/ajax_articoli.php';
|
||||
} else {
|
||||
include $docroot.'/modules/interventi/ajax_articoli.php';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php if (!$record['flag_completato']) {
|
||||
?>
|
||||
<button type="button" class="btn btn-primary" onclick="launch_modal( '<?php echo tr('Aggiungi articolo'); ?>', '<?php echo $rootdir; ?>/modules/interventi/add_articolo.php?id_module=<?php echo $id_module; ?>&id_record=<?php echo $id_record; ?>&idriga=0', 1);"><i class="fa fa-plus"></i> <?php echo tr('Aggiungi articolo'); ?>...</button>
|
||||
<?php
|
||||
} ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- SPESE AGGIUNTIVE -->
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title"><?php echo tr('Altre spese'); ?></h3>
|
||||
<h3 class="panel-title"><?php echo tr('Righe'); ?></h3>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<div class="row">
|
||||
<div class="col-md-9">
|
||||
|
||||
<?php
|
||||
|
||||
if (!$record['flag_completato']) {
|
||||
echo '
|
||||
<a class="btn btn-sm btn-primary" data-href="'.$structure->fileurl('add_righe.php').'?id_module='.$id_module.'&id_record='.$id_record.'&is_sconto" data-toggle="tooltip" data-title="'.tr('Aggiungi altre spese').'">
|
||||
<i class="fa fa-plus"></i> '.tr('Altre spese').'...
|
||||
</a>';
|
||||
<a class="btn btn-sm btn-primary" data-href="'.$structure->fileurl('add_articolo.php').'?id_module='.$id_module.'&id_record='.$id_record.'&is_articolo&idriga=0" data-toggle="tooltip" data-title="'.tr('Aggiungi articolo').'">
|
||||
<i class="fa fa-plus"></i> '.tr('Articolo').'
|
||||
</a>';
|
||||
|
||||
echo '
|
||||
<a class="btn btn-sm btn-primary" data-href="'.$structure->fileurl('row-add.php').'?id_module='.$id_module.'&id_record='.$id_record.'&is_sconto" data-toggle="tooltip" data-title="'.tr('Aggiungi sconto/maggiorazione').'">
|
||||
<i class="fa fa-plus"></i> '.tr('Sconto/maggiorazione').'
|
||||
</a>';
|
||||
<a class="btn btn-sm btn-primary" data-href="'.$structure->fileurl('add_righe.php').'?id_module='.$id_module.'&id_record='.$id_record.'&is_riga" data-toggle="tooltip" data-title="'.tr('Aggiungi altre spese').'">
|
||||
<i class="fa fa-plus"></i> '.tr('Riga').'
|
||||
</a>';
|
||||
|
||||
echo '
|
||||
<a class="btn btn-sm btn-primary" data-href="'.$structure->fileurl('row-add.php').'?id_module='.$id_module.'&id_record='.$id_record.'&is_sconto" data-toggle="tooltip" data-title="'.tr('Aggiungi sconto/maggiorazione').'">
|
||||
<i class="fa fa-plus"></i> '.tr('Sconto/maggiorazione').'
|
||||
</a>';
|
||||
}
|
||||
|
||||
// Conteggio numero articoli intervento per eventuale blocco della sede di partenza
|
||||
$articoli = $dbo->fetchArray('SELECT mg_articoli_interventi.id FROM mg_articoli_interventi INNER JOIN in_interventi ON in_interventi.id=mg_articoli_interventi.idintervento WHERE in_interventi.id='.prepare($id_record));
|
||||
|
||||
?>
|
||||
<div class="clearfix"></div>
|
||||
<br>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
{[ "type": "select", "label": "<?php echo tr('Partenza merce'); ?>", "name": "idsede_partenza", "ajax-source": "sedi_azienda", "value": "$idsede_partenza$", "readonly": "<?php echo ($record['flag_completato'] || !empty($articoli)) ? 1 : 0; ?>" ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="righe">
|
||||
<?php
|
||||
|
@ -387,7 +387,7 @@ function aggiungi_intervento_in_fattura($id_intervento, $id_fattura, $descrizion
|
||||
}
|
||||
}
|
||||
|
||||
$costi_intervento = get_costi_intervento($id_intervento);
|
||||
$intervento = \Modules\Interventi\Intervento::find($id_intervento);
|
||||
|
||||
// Fatturo i diritti di chiamata raggruppati per costo
|
||||
$rst = $dbo->fetchArray('SELECT COUNT(id) AS qta, SUM(prezzo_dirittochiamata) AS tot_prezzo_dirittochiamata FROM in_interventi_tecnici WHERE idintervento='.prepare($id_intervento).' AND prezzo_dirittochiamata > 0 GROUP BY prezzo_dirittochiamata');
|
||||
@ -479,14 +479,14 @@ function aggiungi_intervento_in_fattura($id_intervento, $id_fattura, $descrizion
|
||||
}
|
||||
|
||||
// Aggiunta km come "Trasferta" (se c'è)
|
||||
if ($costi_intervento['viaggio_addebito'] > 0) {
|
||||
if ($intervento->prezzo_viaggio > 0) {
|
||||
// Calcolo iva
|
||||
$query = 'SELECT * FROM co_iva WHERE id='.prepare($id_iva);
|
||||
$dati = $dbo->fetchArray($query);
|
||||
$desc_iva = $dati[0]['descrizione'];
|
||||
|
||||
$subtot = $costi_intervento['viaggio_addebito'];
|
||||
$sconto = $costi_intervento['viaggio_addebito'] - $costi_intervento['viaggio_scontato'];
|
||||
$subtot = $intervento->prezzo_viaggio;
|
||||
$sconto = $intervento->sconto_totale_viaggio;
|
||||
$iva = ($subtot - $sconto) / 100 * $dati[0]['percentuale'];
|
||||
$iva_indetraibile = $iva / 100 * $dati[0]['indetraibile'];
|
||||
|
||||
@ -508,37 +508,6 @@ function aggiungi_intervento_in_fattura($id_intervento, $id_fattura, $descrizion
|
||||
$dbo->query($query);
|
||||
}
|
||||
|
||||
// Aggiunta sconto
|
||||
if (!empty($costi_intervento['sconto_globale'])) {
|
||||
$subtot = 0;
|
||||
$sconto = $costi_intervento['sconto_globale'];
|
||||
|
||||
// Calcolo iva
|
||||
$query = 'SELECT * FROM co_iva WHERE id='.prepare($id_iva);
|
||||
$rs = $dbo->fetchArray($query);
|
||||
$desc_iva = $rs[0]['descrizione'];
|
||||
|
||||
$iva = ($subtot) / 100 * $rs[0]['percentuale'];
|
||||
$iva_indetraibile = $iva / 100 * $rs[0]['indetraibile'];
|
||||
|
||||
// Calcolo rivalsa inps
|
||||
$query = 'SELECT * FROM co_rivalse WHERE id='.prepare($id_rivalsa_inps);
|
||||
$rs = $dbo->fetchArray($query);
|
||||
$rivalsainps = ($subtot) / 100 * $rs[0]['percentuale'];
|
||||
|
||||
// Calcolo ritenuta d'acconto
|
||||
$query = 'SELECT * FROM co_ritenutaacconto WHERE id='.prepare($id_ritenuta_acconto);
|
||||
$rs = $dbo->fetchArray($query);
|
||||
if ($calcolo_ritenuta_acconto == 'Imponibile') {
|
||||
$ritenutaacconto = $subtot / 100 * $rs[0]['percentuale'];
|
||||
} else {
|
||||
$ritenutaacconto = ($subtot + $rivalsainps) / 100 * $rs[0]['percentuale'];
|
||||
}
|
||||
|
||||
$query = 'INSERT INTO co_righe_documenti(iddocumento, idintervento, idconto, idiva, desc_iva, iva, iva_indetraibile, descrizione, subtotale, sconto_unitario, tipo_sconto, qta, idrivalsainps, rivalsainps, idritenutaacconto, ritenutaacconto, calcolo_ritenuta_acconto, `order`) VALUES('.prepare($id_fattura).', NULL, '.prepare($id_conto).', '.prepare($id_iva).', '.prepare($desc_iva).', '.prepare($iva).', '.prepare($iva_indetraibile).', '.prepare('Sconto '.$descrizione).', '.prepare($subtot).', '.$sconto.', "UNT", 1, '.prepare($id_rivalsa_inps).', '.prepare($rivalsainps).', '.prepare($id_ritenuta_acconto).', '.prepare($ritenutaacconto).', '.prepare($calcolo_ritenuta_acconto).', (SELECT IFNULL(MAX(`order`) + 1, 0) FROM co_righe_documenti AS t WHERE iddocumento='.prepare($id_fattura).'))';
|
||||
$dbo->query($query);
|
||||
}
|
||||
|
||||
// Ricalcolo inps, ritenuta e bollo
|
||||
if ($dir == 'entrata') {
|
||||
ricalcola_costiagg_fattura($id_fattura);
|
||||
|
@ -23,8 +23,9 @@ if (!empty($results)) {
|
||||
</tr>';
|
||||
|
||||
foreach ($results as $result) {
|
||||
$costi_intervento = get_costi_intervento($result['id']);
|
||||
$totale_interventi += $costi_intervento['totale'];
|
||||
$intervento = \Modules\Interventi\Intervento::find($result['id']);
|
||||
$totale_interventi += $intervento->totale;
|
||||
|
||||
echo '
|
||||
<tr>
|
||||
<td>
|
||||
|
@ -27,9 +27,24 @@ trait RelationTrait
|
||||
{
|
||||
}
|
||||
|
||||
public function getSubtotaleAttribute()
|
||||
/**
|
||||
* Restituisce il prezzo unitario della riga.
|
||||
*/
|
||||
public function getPrezzoUnitarioVenditaAttribute()
|
||||
{
|
||||
return $this->prezzo_vendita * $this->qta;
|
||||
if (!isset($this->prezzo_unitario_vendita_riga)) {
|
||||
$this->prezzo_unitario_vendita_riga = $this->prezzo_vendita;
|
||||
}
|
||||
|
||||
return !is_nan($this->prezzo_unitario_vendita_riga) ? $this->prezzo_unitario_vendita_riga : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restituisce il costo unitario della riga.
|
||||
*/
|
||||
public function getPrezzoUnitarioAcquistoAttribute()
|
||||
{
|
||||
return $this->prezzo_acquisto;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3,7 +3,9 @@
|
||||
namespace Modules\Interventi\Components;
|
||||
|
||||
use Common\Model;
|
||||
use Modules\Anagrafiche\Anagrafica;
|
||||
use Modules\Interventi\Intervento;
|
||||
use Modules\Iva\Aliquota;
|
||||
|
||||
/**
|
||||
* Notazione: i costi sono rivolti all'azienda, i prezzi al cliente.
|
||||
@ -16,11 +18,20 @@ class Sessione extends Model
|
||||
|
||||
protected $table = 'in_interventi_tecnici';
|
||||
|
||||
protected $aliquota_iva = null;
|
||||
|
||||
public function getParentID()
|
||||
{
|
||||
return 'idintervento';
|
||||
}
|
||||
|
||||
// Relazioni Eloquent
|
||||
|
||||
public function anagrafica()
|
||||
{
|
||||
return $this->belongsTo(Anagrafica::class, 'idtecnico');
|
||||
}
|
||||
|
||||
public function parent()
|
||||
{
|
||||
return $this->belongsTo(Intervento::class, $this->getParentID());
|
||||
@ -159,7 +170,7 @@ class Sessione extends Model
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getScontoTotaleKmAttribute()
|
||||
public function getScontoTotaleViaggioAttribute()
|
||||
{
|
||||
return calcola_sconto([
|
||||
'sconto' => $this->scontokm_unitario,
|
||||
@ -175,7 +186,85 @@ class Sessione extends Model
|
||||
*/
|
||||
public function getPrezzoViaggioScontatoAttribute()
|
||||
{
|
||||
return $this->prezzo_viaggio - $this->sconto_totale_km;
|
||||
return $this->prezzo_viaggio - $this->sconto_totale_viaggio;
|
||||
}
|
||||
|
||||
// Attributi di contabilità
|
||||
|
||||
/**
|
||||
* Restituisce l'imponibile dell'elemento.
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getImponibileAttribute()
|
||||
{
|
||||
return $this->prezzo_manodopera + $this->prezzo_viaggio + $this->prezzo_diritto_chiamata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restituisce il totale imponibile dell'elemento.
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getTotaleImponibileAttribute()
|
||||
{
|
||||
return $this->prezzo_manodopera_scontato + $this->prezzo_viaggio_scontato + $this->prezzo_diritto_chiamata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restituisce il totale (imponibile + iva) dell'elemento.
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getTotaleAttribute()
|
||||
{
|
||||
return $this->totale_imponibile + $this->iva;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restituisce la spesa (prezzo_unitario_acquisto * qta) relativa all'elemento.
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getSpesaAttribute()
|
||||
{
|
||||
return $this->costo_manodopera;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restituisce il gaudagno totale (totale_imponibile - spesa) relativo all'elemento.
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getGuadagnoAttribute()
|
||||
{
|
||||
return $this->totale_imponibile - $this->spesa;
|
||||
}
|
||||
|
||||
public function getIvaIndetraibileAttribute()
|
||||
{
|
||||
return $this->iva / 100 * $this->aliquota->indetraibile;
|
||||
}
|
||||
|
||||
public function getIvaAttribute()
|
||||
{
|
||||
return ($this->totale_imponibile) * $this->aliquota->percentuale / 100;
|
||||
}
|
||||
|
||||
public function getIvaDetraibileAttribute()
|
||||
{
|
||||
return $this->iva - $this->iva_indetraibile;
|
||||
}
|
||||
|
||||
public function getAliquotaAttribute()
|
||||
{
|
||||
if (!isset($this->aliquota_iva)) {
|
||||
$id_iva = setting('Iva predefinita');
|
||||
|
||||
$this->aliquota_iva = Aliquota::find($id_iva);
|
||||
}
|
||||
|
||||
return $this->aliquota_iva;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -39,6 +39,29 @@ class Intervento extends Document
|
||||
return $model;
|
||||
}
|
||||
|
||||
public function getOreTotaliAttribute()
|
||||
{
|
||||
$sessioni = $this->sessioni;
|
||||
|
||||
$ore = $sessioni->sum('ore');
|
||||
|
||||
return $ore;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restituisce la collezione di righe e articoli con valori rilevanti per i conti.
|
||||
*
|
||||
* @return iterable
|
||||
*/
|
||||
public function getRigheContabili()
|
||||
{
|
||||
$results = parent::getRigheContabili();
|
||||
|
||||
return $results->merge($this->sessioni);
|
||||
}
|
||||
|
||||
// Relazioni Eloquent
|
||||
|
||||
public function anagrafica()
|
||||
{
|
||||
return $this->belongsTo(Anagrafica::class, 'idanagrafica');
|
||||
|
@ -187,25 +187,11 @@ echo '
|
||||
</tbody>';
|
||||
|
||||
// Calcoli
|
||||
$imponibile = sum(array_column($rs, 'subtotale'));
|
||||
$sconto = sum(array_column($rs, 'sconto'));
|
||||
$iva = sum(array_column($rs, 'iva'));
|
||||
|
||||
$totale_imponibile = sum($imponibile, -$sconto);
|
||||
|
||||
$totale_iva = sum($iva, $record['iva_rivalsainps']);
|
||||
|
||||
$totale = sum([
|
||||
$totale_imponibile,
|
||||
$record['rivalsainps'],
|
||||
$totale_iva,
|
||||
]);
|
||||
|
||||
$netto_a_pagare = sum([
|
||||
$totale,
|
||||
//$marca_da_bollo, // Variabile non inizializzata!
|
||||
-$record['ritenutaacconto'],
|
||||
]);
|
||||
$imponibile = abs($ordine->imponibile);
|
||||
$sconto = $ordine->sconto;
|
||||
$totale_imponibile = abs($ordine->totale_imponibile);
|
||||
$iva = abs($ordine->iva);
|
||||
$totale = abs($ordine->totale);
|
||||
|
||||
// IMPONIBILE
|
||||
echo '
|
||||
@ -220,7 +206,7 @@ echo '
|
||||
</tr>';
|
||||
|
||||
// SCONTO
|
||||
if (abs($sconto) > 0) {
|
||||
if (!empty($sconto)) {
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="5" class="text-right">
|
||||
@ -243,37 +229,19 @@ if (abs($sconto) > 0) {
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>';
|
||||
|
||||
//$totale -= $sconto;
|
||||
}
|
||||
|
||||
// RIVALSA INPS
|
||||
if (abs($record['rivalsainps']) > 0) {
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="5" class="text-right">
|
||||
<b>'.tr('Rivalsa', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<td align="right">
|
||||
'.moneyFormat($record['rivalsainps'], 2).'
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
// IVA
|
||||
if (abs($totale_iva) > 0) {
|
||||
echo '
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="5" class="text-right">
|
||||
<b>'.tr('Iva', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<td align="right">
|
||||
'.moneyFormat($totale_iva, 2).'
|
||||
'.moneyFormat($iva, 2).'
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
// TOTALE
|
||||
echo '
|
||||
@ -287,48 +255,6 @@ echo '
|
||||
<td></td>
|
||||
</tr>';
|
||||
|
||||
// Mostra marca da bollo se c'è
|
||||
if (abs($record['bollo']) > 0) {
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="5" class="text-right">
|
||||
<b>'.tr('Marca da bollo', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<td align="right">
|
||||
'.moneyFormat($record['bollo'], 2).'
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
// RITENUTA D'ACCONTO
|
||||
if (abs($record['ritenutaacconto']) > 0) {
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="5" class="text-right">
|
||||
<b>'.tr("Ritenuta d'acconto", [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<td align="right">
|
||||
'.moneyFormat($record['ritenutaacconto'], 2).'
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
// NETTO A PAGARE
|
||||
if ($totale != $netto_a_pagare) {
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="5" class="text-right">
|
||||
<b>'.tr('Netto a pagare', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<td align="right">
|
||||
'.moneyFormat($netto_a_pagare, 2).'
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
echo '
|
||||
</table>';
|
||||
|
||||
|
@ -19,6 +19,8 @@ $budget = get_imponibile_preventivo($id_record);
|
||||
$totale_costo = 0;
|
||||
$totale_addebito = 0;
|
||||
$totale = 0;
|
||||
$totale_ore = 0;
|
||||
$totale_km = 0;
|
||||
|
||||
$totale_stato = [];
|
||||
|
||||
@ -38,8 +40,8 @@ if (!empty($rsi)) {
|
||||
|
||||
// Tabella con i dati
|
||||
foreach ($rsi as $int) {
|
||||
$int = array_merge($int, get_costi_intervento($int['id']));
|
||||
$totale_stato[$int['idstatointervento']] = sum($totale_stato[$int['idstatointervento']], $int['totale_scontato']);
|
||||
$intervento = \Modules\Interventi\Intervento::find($int['id']);
|
||||
$totale_stato[$int['idstatointervento']] = sum($totale_stato[$int['idstatointervento']], $intervento->totale_imponibile);
|
||||
|
||||
// Riga intervento singolo
|
||||
echo '
|
||||
@ -61,15 +63,15 @@ if (!empty($rsi)) {
|
||||
</td>
|
||||
|
||||
<td class="text-right">
|
||||
'.Translator::numberToLocale($int['totale_costo']).'
|
||||
'.Translator::numberToLocale($intervento->spesa).'
|
||||
</td>
|
||||
|
||||
<td class="text-right">
|
||||
'.Translator::numberToLocale($int['totale_addebito']).'
|
||||
'.Translator::numberToLocale($intervento->imponibile).'
|
||||
</td>
|
||||
|
||||
<td class="text-right">
|
||||
'.Translator::numberToLocale($int['totale_scontato']).'
|
||||
'.Translator::numberToLocale($intervento->totale_imponibile).'
|
||||
</td>
|
||||
</tr>';
|
||||
|
||||
|
@ -128,32 +128,17 @@ foreach ($rs as $r) {
|
||||
</tr>';
|
||||
}
|
||||
|
||||
// Calcoli
|
||||
$totale_acquisto = 0;
|
||||
foreach ($rs as $r) {
|
||||
$totale_acquisto += ($r['prezzo_unitario_acquisto'] * $r['qta']);
|
||||
}
|
||||
$imponibile = sum(array_column($rs, 'subtotale'));
|
||||
$sconto = sum(array_column($rs, 'sconto'));
|
||||
$iva = sum(array_column($rs, 'iva'));
|
||||
|
||||
$totale_imponibile = sum($imponibile, -$sconto);
|
||||
|
||||
$totale = sum([
|
||||
$totale_imponibile,
|
||||
$iva,
|
||||
]);
|
||||
$totale_guadagno = sum([
|
||||
$totale_imponibile
|
||||
- $totale_acquisto,
|
||||
]);
|
||||
|
||||
echo '
|
||||
</tbody>';
|
||||
|
||||
// SCONTO
|
||||
if (abs($sconto) > 0) {
|
||||
echo '
|
||||
// Calcoli
|
||||
$imponibile = abs($preventivo->imponibile);
|
||||
$sconto = $preventivo->sconto;
|
||||
$totale_imponibile = abs($preventivo->totale_imponibile);
|
||||
$iva = abs($preventivo->iva);
|
||||
$totale = abs($preventivo->totale);
|
||||
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="5" class="text-right">
|
||||
<b>'.tr('Imponibile', [], ['upper' => true]).':</b>
|
||||
@ -164,6 +149,8 @@ if (abs($sconto) > 0) {
|
||||
<td></td>
|
||||
</tr>';
|
||||
|
||||
// SCONTO
|
||||
if (!empty($sconto)) {
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="5" class="text-right">
|
||||
@ -186,18 +173,6 @@ if (abs($sconto) > 0) {
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>';
|
||||
} else {
|
||||
// Totale imponibile
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="5" class="text-right">
|
||||
<b>'.tr('Imponibile', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<td align="right">
|
||||
'.moneyFormat($imponibile, 2).'
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
// Totale iva
|
||||
|
@ -1,14 +1,15 @@
|
||||
<?php
|
||||
|
||||
// Calcoli
|
||||
$imponibile = $documento->imponibile;
|
||||
$imponibile = abs($documento->imponibile);
|
||||
$sconto = $documento->sconto;
|
||||
$totale_imponibile = $documento->totale_imponibile;
|
||||
$totale_iva = $documento->iva;
|
||||
$totale = $documento->totale;
|
||||
$netto_a_pagare = $documento->netto;
|
||||
$totale_imponibile = abs($documento->totale_imponibile);
|
||||
$totale_iva = abs($documento->iva);
|
||||
$totale = abs($documento->totale);
|
||||
$netto_a_pagare = abs($documento->netto);
|
||||
|
||||
$show_sconto = $sconto > 0;
|
||||
|
||||
$width = round(100 / ($show_sconto ? 5 : 3), 2);
|
||||
|
||||
// SCADENZE | TOTALI
|
||||
|
@ -12,10 +12,10 @@ echo '
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="text-left" style="width:30%">'.tr('Intervento num.').': <b>'.$records[0]['codice'].'</b></td>
|
||||
<td class="text-left" style="width:20%">'.tr('Data').': <b>'.Translator::dateToLocale($records[0]['data_richiesta']).'</b></td>
|
||||
<td class="text-left" style="width:25%">'.tr('Preventivo num.').': <b>'.$records[0]['numero_preventivo'].'</b></td>
|
||||
<td class="text-left" style="width:25%">'.tr('Contratto num.').': <b>'.$records[0]['numero_contratto'].'</b></td>
|
||||
<td class="text-left" style="width:30%">'.tr('Intervento num.').': <b>'.$documento['codice'].'</b></td>
|
||||
<td class="text-left" style="width:20%">'.tr('Data').': <b>'.Translator::dateToLocale($documento['data_richiesta']).'</b></td>
|
||||
<td class="text-left" style="width:25%">'.tr('Preventivo num.').': <b>'.(!empty($preventivo) ? $preventivo['numero'] : '').'</b></td>
|
||||
<td class="text-left" style="width:25%">'.tr('Contratto num.').': <b>'.(!empty($contratto) ? $contratto['numero'] : '').'</b></td>
|
||||
</tr>';
|
||||
|
||||
// Dati cliente
|
||||
@ -83,7 +83,7 @@ echo '
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="4">
|
||||
<b>'.tr('Tipo intervento').':</b> '.$records[0]['tipointervento'].'
|
||||
<b>'.tr('Tipo intervento').':</b> '.$documento['tipointervento'].'
|
||||
</td>
|
||||
</tr>';
|
||||
|
||||
@ -92,7 +92,7 @@ echo '
|
||||
<tr>
|
||||
<td colspan="4" style="height:20mm;">
|
||||
<b>'.tr('Richiesta').':</b>
|
||||
<p>'.nl2br($records[0]['richiesta']).'</p>
|
||||
<p>'.nl2br($documento['richiesta']).'</p>
|
||||
</td>
|
||||
</tr>';
|
||||
|
||||
@ -101,122 +101,22 @@ echo '
|
||||
<tr>
|
||||
<td colspan="4" style="height:20mm;">
|
||||
<b>'.tr('Descrizione').':</b>
|
||||
<p>'.nl2br($records[0]['descrizione_intervento']).'</p>
|
||||
<p>'.nl2br($documento['descrizione']).'</p>
|
||||
</td>
|
||||
</tr>';
|
||||
|
||||
echo '
|
||||
</table>';
|
||||
|
||||
$totale = [];
|
||||
$righe = $documento->getRighe();
|
||||
|
||||
// MATERIALE UTILIzZZATO
|
||||
$rs2 = $dbo->fetchArray("SELECT *,
|
||||
(SELECT codice FROM mg_articoli WHERE id=idarticolo) AS codice_art,
|
||||
(SELECT GROUP_CONCAT(`serial` SEPARATOR ', ') FROM `mg_prodotti` WHERE `id_riga_intervento` = `mg_articoli_interventi`.`idintervento`) AS seriali
|
||||
FROM `mg_articoli_interventi` WHERE idintervento=".prepare($id_record)." AND NOT idarticolo='0' ORDER BY idarticolo ASC");
|
||||
if (!empty($rs2)) {
|
||||
if (!$righe->isEmpty()) {
|
||||
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:20%" class="text-center">
|
||||
<b>'.tr('Codice').'</b>
|
||||
</th>
|
||||
|
||||
<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>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>';
|
||||
|
||||
foreach ($rs2 as $r) {
|
||||
echo '
|
||||
<tr>';
|
||||
|
||||
// Codice
|
||||
echo '
|
||||
<td>
|
||||
'.$r['codice_art'].'
|
||||
</td>';
|
||||
|
||||
// Descrizione
|
||||
echo '
|
||||
<td>
|
||||
'.$r['descrizione'];
|
||||
|
||||
// Seriali
|
||||
if (!empty($r['seriali'])) {
|
||||
echo '
|
||||
<br><small>'.tr('SN').': '.$r['seriali'].'</small>';
|
||||
}
|
||||
|
||||
echo '
|
||||
</td>';
|
||||
|
||||
// Quantità
|
||||
echo '
|
||||
<td class="text-center">
|
||||
'.Translator::numberToLocale($r['qta'], 'qta').' '.$r['um'].'
|
||||
</td>';
|
||||
|
||||
// Netto
|
||||
$netto = $r['prezzo_vendita'] * $r['qta'] - $r['sconto'];
|
||||
echo '
|
||||
<td class="text-center">
|
||||
'.($options['pricing'] ? moneyFormat($netto) : '-').'
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
echo '
|
||||
</tbody>';
|
||||
|
||||
// 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($costi_intervento['ricambi_scontato'], 2).'</b>
|
||||
</th>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
echo '
|
||||
</table>';
|
||||
}
|
||||
|
||||
// FINE MATERIALE UTILIZZATO
|
||||
|
||||
// Conteggio SPESE AGGIUNTIVE
|
||||
$rs2 = $dbo->fetchArray('SELECT * FROM in_righe_interventi WHERE idintervento='.prepare($id_record).' ORDER BY id ASC');
|
||||
if (!empty($rs2)) {
|
||||
echo '
|
||||
<table class="table table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="4" class="text-center">
|
||||
<b>'.tr('Spese aggiuntive', [], ['upper' => true]).'</b>
|
||||
<b>'.tr('Materiale utilizzato e spese aggiuntive', [], ['upper' => true]).'</b>
|
||||
</th>
|
||||
</tr>
|
||||
|
||||
@ -234,19 +134,40 @@ if (!empty($rs2)) {
|
||||
</th>
|
||||
|
||||
<th style="font-size:8pt;width:20%" class="text-center">
|
||||
<b>'.tr('Subtot.').'</b>
|
||||
<b>'.tr('Imponibile').'</b>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>';
|
||||
|
||||
foreach ($rs2 as $r) {
|
||||
foreach ($righe as $riga) {
|
||||
$r = $riga->toArray();
|
||||
|
||||
// Articolo
|
||||
echo '
|
||||
<tr>
|
||||
<td>
|
||||
'.nl2br($r['descrizione']).'
|
||||
'.nl2br($r['descrizione']);
|
||||
|
||||
if ($riga->isArticolo()) {
|
||||
// Codice articolo
|
||||
$text = tr('COD. _COD_', [
|
||||
'_COD_' => $riga->articolo->codice,
|
||||
]);
|
||||
echo '
|
||||
<br><small>'.$text.'</small>';
|
||||
|
||||
// Seriali
|
||||
$seriali = $riga->serials;
|
||||
if (!empty($seriali)) {
|
||||
$text = tr('SN').': '.implode(', ', $seriali);
|
||||
echo '
|
||||
<br><small>'.$text.'</small>';
|
||||
}
|
||||
}
|
||||
|
||||
echo '
|
||||
</td>';
|
||||
|
||||
// Quantità
|
||||
@ -258,7 +179,7 @@ if (!empty($rs2)) {
|
||||
// Prezzo unitario
|
||||
echo '
|
||||
<td class="text-center">
|
||||
'.($options['pricing'] ? moneyFormat($r['prezzo_vendita']) : '-');
|
||||
'.($options['pricing'] ? moneyFormat($riga->prezzo_unitario_vendita) : '-');
|
||||
|
||||
if ($options['pricing'] && $r['sconto'] > 0) {
|
||||
echo "
|
||||
@ -272,13 +193,13 @@ if (!empty($rs2)) {
|
||||
</td>';
|
||||
|
||||
// Prezzo totale
|
||||
$netto = $r['prezzo_vendita'] * $r['qta'] - $r['sconto'];
|
||||
echo '
|
||||
<td class="text-center">
|
||||
'.($options['pricing'] ? Translator::numberToLocale($netto) : '-').'
|
||||
'.($options['pricing'] ? Translator::numberToLocale($riga->totale_imponibile) : '-').'
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
echo '
|
||||
</tbody>';
|
||||
|
||||
@ -287,11 +208,11 @@ if (!empty($rs2)) {
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="3" class="text-right">
|
||||
<b>'.tr('Totale spese aggiuntive', [], ['upper' => true]).':</b>
|
||||
<b>'.tr('Totale', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
|
||||
<th class="text-center">
|
||||
<b>'.moneyFormat($costi_intervento['altro_scontato'], 2).'</b>
|
||||
<b>'.moneyFormat($righe->sum('totale_imponibile'), 2).'</b>
|
||||
</th>
|
||||
</tr>';
|
||||
}
|
||||
@ -300,8 +221,6 @@ if (!empty($rs2)) {
|
||||
</table>';
|
||||
}
|
||||
|
||||
// FINE SPESE AGGIUNTIVE
|
||||
|
||||
// INTESTAZIONE ELENCO TECNICI
|
||||
echo '
|
||||
<table class="table table-bordered vertical-middle">
|
||||
@ -337,34 +256,34 @@ echo '
|
||||
<tbody>';
|
||||
|
||||
// Sessioni di lavoro dei tecnici
|
||||
$rst = $dbo->fetchArray('SELECT an_anagrafiche.*, in_interventi_tecnici.* FROM in_interventi_tecnici JOIN an_anagrafiche ON in_interventi_tecnici.idtecnico=an_anagrafiche.idanagrafica WHERE in_interventi_tecnici.idintervento='.prepare($id_record).' ORDER BY in_interventi_tecnici.orario_inizio');
|
||||
|
||||
foreach ($rst as $i => $r) {
|
||||
$sessioni = $documento->sessioni;
|
||||
foreach ($sessioni as $i => $sessione) {
|
||||
echo '
|
||||
<tr>';
|
||||
|
||||
// nome tecnico
|
||||
// Nome tecnico
|
||||
echo '
|
||||
<td>
|
||||
'.$r['ragione_sociale'].'
|
||||
'.$sessione->anagrafica->ragione_sociale.'
|
||||
</td>';
|
||||
|
||||
// data
|
||||
// Data
|
||||
echo '
|
||||
<td class="text-center">
|
||||
'.Translator::dateToLocale($r['orario_inizio'], '-').'
|
||||
'.Translator::dateToLocale($sessione['orario_inizio'], '-').'
|
||||
</td>';
|
||||
|
||||
// ora inizio
|
||||
// Ora inizio
|
||||
echo '
|
||||
<td class="text-center">
|
||||
'.Translator::timeToLocale($r['orario_inizio'], '-').'
|
||||
'.Translator::timeToLocale($sessione['orario_inizio'], '-').'
|
||||
</td>';
|
||||
|
||||
// ora fine
|
||||
// Ora fine
|
||||
echo '
|
||||
<td class="text-center">
|
||||
'.Translator::timeToLocale($r['orario_fine'], '-').'
|
||||
'.Translator::timeToLocale($sessione['orario_fine'], '-').'
|
||||
</td>';
|
||||
|
||||
// Spazio aggiuntivo
|
||||
@ -383,7 +302,7 @@ foreach ($rst as $i => $r) {
|
||||
}
|
||||
|
||||
// Ore lavorate
|
||||
$ore = get_ore_intervento($id_record);
|
||||
$ore = $documento->ore_totali;
|
||||
|
||||
echo '
|
||||
<tr>
|
||||
@ -395,7 +314,7 @@ echo '
|
||||
if ($options['pricing']) {
|
||||
echo '
|
||||
<td colspan="3" class="text-center">
|
||||
<small>'.tr('Totale manodopera').':</small><br/><b>'.moneyFormat($costi_intervento['manodopera_addebito'], 2).'</b>
|
||||
<small>'.tr('Totale manodopera').':</small><br/><b>'.moneyFormat($sessioni->sum('prezzo_manodopera'), 2).'</b>
|
||||
</td>';
|
||||
} else {
|
||||
echo '
|
||||
@ -403,7 +322,7 @@ if ($options['pricing']) {
|
||||
}
|
||||
|
||||
// Timbro e firma
|
||||
$firma = !empty($records[0]['firma_file']) ? '<img src="'.DOCROOT.'/files/interventi/'.$records[0]['firma_file'].'" style="width:70mm;">' : '';
|
||||
$firma = !empty($documento['firma_file']) ? '<img src="'.DOCROOT.'/files/interventi/'.$documento['firma_file'].'" style="width:70mm;">' : '';
|
||||
echo '
|
||||
<td rowspan="2" class="text-center" style="font-size:8pt;height:30mm;vertical-align:bottom">
|
||||
'.$firma.'<br>
|
||||
@ -415,14 +334,14 @@ echo '
|
||||
echo '
|
||||
<tr>
|
||||
<td class="text-center">
|
||||
<small>'.tr('Km percorsi').':</small><br/><b>'.Translator::numberToLocale($records[0]['tot_km'], 2).'</b>
|
||||
<small>'.tr('Km percorsi').':</small><br/><b>'.Translator::numberToLocale($sessioni->sum('km'), 2).'</b>
|
||||
</td>';
|
||||
|
||||
// Costo trasferta
|
||||
if ($options['pricing']) {
|
||||
echo '
|
||||
<td class="text-center">
|
||||
<small>'.tr('Costi di trasferta').':</small><br/><b>'.moneyFormat($records[0]['tot_km_consuntivo'], 2).'</b>
|
||||
<small>'.tr('Costi di trasferta').':</small><br/><b>'.moneyFormat($sessioni->sum('prezzo_viaggio'), 2).'</b>
|
||||
</td>';
|
||||
} else {
|
||||
echo '
|
||||
@ -433,14 +352,23 @@ if ($options['pricing']) {
|
||||
if ($options['pricing']) {
|
||||
echo '
|
||||
<td class="text-center" colspan="2">
|
||||
<small>'.tr('Diritto di chiamata').':</small><br/><b>'.moneyFormat($records[0]['tot_dirittochiamata'], 2).'</b>
|
||||
<small>'.tr('Diritto di chiamata').':</small><br/><b>'.moneyFormat($sessioni->sum('prezzo_diritto_chiamata'), 2).'</b>
|
||||
</td>';
|
||||
} else {
|
||||
echo '
|
||||
<td class="text-center" colspan="2">-</td>
|
||||
';
|
||||
<td class="text-center" colspan="2">-</td>';
|
||||
}
|
||||
|
||||
// Calcoli
|
||||
$imponibile = abs($documento->imponibile);
|
||||
$sconto = $documento->sconto;
|
||||
$totale_imponibile = abs($documento->totale_imponibile);
|
||||
$totale_iva = abs($documento->iva);
|
||||
$totale = abs($documento->totale);
|
||||
$netto_a_pagare = abs($documento->netto);
|
||||
|
||||
$show_sconto = $sconto > 0;
|
||||
|
||||
// TOTALE COSTI FINALI
|
||||
if ($options['pricing']) {
|
||||
// Totale imponibile
|
||||
@ -451,14 +379,12 @@ if ($options['pricing']) {
|
||||
</td>
|
||||
|
||||
<th class="text-center">
|
||||
<b>'.moneyFormat($costi_intervento['totale_addebito'], 2).'</b>
|
||||
'.moneyFormat($show_sconto ? $imponibile : $totale_imponibile, 2).'
|
||||
</th>
|
||||
</tr>';
|
||||
|
||||
$totale_sconto = $costi_intervento['totale_addebito'] - $costi_intervento['totale_scontato'];
|
||||
|
||||
// Eventuale sconto totale
|
||||
if (!empty($totale_sconto)) {
|
||||
if ($show_sconto) {
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="4" class="text-right">
|
||||
@ -466,7 +392,7 @@ if ($options['pricing']) {
|
||||
</td>
|
||||
|
||||
<th class="text-center">
|
||||
<b>-'.moneyFormat($totale_sconto, 2).'</b>
|
||||
<b>'.moneyFormat($sconto, 2).'</b>
|
||||
</th>
|
||||
</tr>';
|
||||
|
||||
@ -478,7 +404,7 @@ if ($options['pricing']) {
|
||||
</td>
|
||||
|
||||
<th class="text-center">
|
||||
<b>'.moneyFormat($costi_intervento['totale_scontato'], 2).'</b>
|
||||
<b>'.moneyFormat($totale_imponibile, 2).'</b>
|
||||
</th>
|
||||
</tr>';
|
||||
}
|
||||
@ -492,7 +418,7 @@ if ($options['pricing']) {
|
||||
</td>
|
||||
|
||||
<th class="text-center">
|
||||
<b>'.moneyFormat($costi_intervento['iva_totale'], 2).'</b>
|
||||
<b>'.moneyFormat($totale_iva, 2).'</b>
|
||||
</th>
|
||||
</tr>';
|
||||
|
||||
@ -503,7 +429,7 @@ if ($options['pricing']) {
|
||||
<b>'.tr('Totale intervento', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<th class="text-center">
|
||||
<b>'.moneyFormat($costi_intervento['totale'], 2).'</b>
|
||||
<b>'.moneyFormat($totale, 2).'</b>
|
||||
</th>
|
||||
</tr>';
|
||||
}
|
||||
|
@ -2,13 +2,12 @@
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
$module_name = 'Interventi';
|
||||
use Modules\Interventi\Intervento;
|
||||
|
||||
// carica intervento
|
||||
$query = 'SELECT in_interventi.*, (SELECT nome FROM co_contratti WHERE id=in_interventi.id_contratto) AS nome_contratto, (SELECT numero FROM co_contratti WHERE id=in_interventi.id_contratto) AS numero_contratto, (SELECT numero FROM co_preventivi WHERE id=in_interventi.id_preventivo) AS numero_preventivo, (SELECT SUM(prezzo_dirittochiamata) FROM in_interventi_tecnici GROUP BY idintervento HAVING idintervento=in_interventi.id) AS `tot_dirittochiamata`, (SELECT SUM(km) FROM in_interventi_tecnici GROUP BY idintervento HAVING idintervento=in_interventi.id) AS `tot_km`, (SELECT SUM(ore*prezzo_ore_unitario) FROM in_interventi_tecnici GROUP BY idintervento HAVING idintervento=in_interventi.id) AS `tot_ore_consuntivo`, (SELECT SUM(prezzo_km_consuntivo) FROM in_interventi_tecnici GROUP BY idintervento HAVING idintervento=in_interventi.id) AS `tot_km_consuntivo`, in_interventi.descrizione AS `descrizione_intervento`, richiesta, (SELECT descrizione FROM in_tipiintervento WHERE idtipointervento=in_interventi.idtipointervento) AS tipointervento FROM in_interventi INNER JOIN in_tipiintervento ON in_interventi.idtipointervento=in_tipiintervento.idtipointervento WHERE id='.prepare($id_record);
|
||||
$records = $dbo->fetchArray($query);
|
||||
$documento = Intervento::find($id_record);
|
||||
|
||||
$costi_intervento = get_costi_intervento($id_record);
|
||||
$preventivo = $dbo->fetchOne('SELECT numero FROM co_preventivi WHERE id = '.prepare($documento['id_preventivo']));
|
||||
$contratto = $dbo->fetchOne('SELECT nome, numero FROM co_contratti WHERE id = '.prepare($documento['id_contratto']));
|
||||
|
||||
$id_cliente = $records[0]['idanagrafica'];
|
||||
$id_sede = $records[0]['idsede'];
|
||||
$id_cliente = $documento['idanagrafica'];
|
||||
$id_sede = $documento['idsede'];
|
||||
|
Loading…
x
Reference in New Issue
Block a user