mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-21 05:50:55 +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
|
* @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'];
|
return $this->attributes['iva'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isSconto()
|
|
||||||
{
|
|
||||||
return $this->totale_imponibile > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function isMaggiorazione()
|
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
|
* @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()
|
public function getPrezzoUnitarioVenditaAttribute()
|
||||||
{
|
{
|
||||||
|
@ -122,9 +122,7 @@ abstract class Document extends Model
|
|||||||
*/
|
*/
|
||||||
protected function getRigheContabili()
|
protected function getRigheContabili()
|
||||||
{
|
{
|
||||||
$sconto = $this->scontoGlobale ? [$this->scontoGlobale] : [];
|
return $this->getRighe();
|
||||||
|
|
||||||
return $this->getRighe()->merge(collect($sconto));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,8 +53,8 @@ if (!empty($rsi)) {
|
|||||||
|
|
||||||
// Tabella con i dati
|
// Tabella con i dati
|
||||||
foreach ($rsi as $int) {
|
foreach ($rsi as $int) {
|
||||||
$int = array_merge($int, get_costi_intervento($int['id']));
|
$intervento = \Modules\Interventi\Intervento::find($int['id']);
|
||||||
$totale_stato[$int['idstatointervento']] = sum($totale_stato[$int['idstatointervento']], $int['totale_scontato']);
|
$totale_stato[$int['idstatointervento']] = sum($totale_stato[$int['idstatointervento']], $intervento->totale_imponibile);
|
||||||
|
|
||||||
// Riga intervento singolo
|
// Riga intervento singolo
|
||||||
echo '
|
echo '
|
||||||
@ -76,15 +76,15 @@ if (!empty($rsi)) {
|
|||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
'.Translator::numberToLocale($int['totale_costo']).'
|
'.Translator::numberToLocale($intervento->spesa).'
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
'.Translator::numberToLocale($int['totale_addebito']).'
|
'.Translator::numberToLocale($intervento->imponibile).'
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
'.Translator::numberToLocale($int['totale_scontato']).'
|
'.Translator::numberToLocale($intervento->totale_imponibile).'
|
||||||
</td>
|
</td>
|
||||||
</tr>';
|
</tr>';
|
||||||
|
|
||||||
|
@ -133,26 +133,19 @@ foreach ($rs as $r) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Calcoli
|
// Calcoli
|
||||||
$imponibile = sum(array_column($rs, 'subtotale'));
|
$imponibile = abs($contratto->imponibile);
|
||||||
$sconto = sum(array_column($rs, 'sconto'));
|
$sconto = $contratto->sconto;
|
||||||
$iva = sum(array_column($rs, 'iva'));
|
$totale_imponibile = abs($contratto->totale_imponibile);
|
||||||
|
$iva = abs($contratto->iva);
|
||||||
$totale_imponibile = sum($imponibile, -$sconto);
|
$totale = abs($contratto->totale);
|
||||||
|
|
||||||
$totale = sum([
|
|
||||||
$totale_imponibile,
|
|
||||||
$iva,
|
|
||||||
]);
|
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
</tbody>';
|
</tbody>';
|
||||||
|
|
||||||
// SCONTO
|
// Totale totale imponibile
|
||||||
if (abs($sconto) > 0) {
|
echo '
|
||||||
// Totale totale imponibile
|
|
||||||
echo '
|
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5"" class="text-right">
|
<td colspan="5" class="text-right">
|
||||||
<b>'.tr('Imponibile', [], ['upper' => true]).':</b>
|
<b>'.tr('Imponibile', [], ['upper' => true]).':</b>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@ -161,9 +154,11 @@ if (abs($sconto) > 0) {
|
|||||||
<td></td>
|
<td></td>
|
||||||
</tr>';
|
</tr>';
|
||||||
|
|
||||||
|
// SCONTO
|
||||||
|
if (!empty($sconto)) {
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<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>
|
<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>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@ -175,7 +170,7 @@ if (abs($sconto) > 0) {
|
|||||||
// Totale totale imponibile
|
// Totale totale imponibile
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5"" class="text-right">
|
<td colspan="5" class="text-right">
|
||||||
<b>'.tr('Totale imponibile', [], ['upper' => true]).':</b>
|
<b>'.tr('Totale imponibile', [], ['upper' => true]).':</b>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@ -183,24 +178,12 @@ if (abs($sconto) > 0) {
|
|||||||
</td>
|
</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
</tr>';
|
</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
|
// Totale iva
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5"" class="text-right">
|
<td colspan="5" class="text-right">
|
||||||
<b>'.tr('Iva', [], ['upper' => true]).':</b>
|
<b>'.tr('Iva', [], ['upper' => true]).':</b>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@ -212,7 +195,7 @@ echo '
|
|||||||
// Totale contratto
|
// Totale contratto
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5"" class="text-right">
|
<td colspan="5" class="text-right">
|
||||||
<b>'.tr('Totale', [], ['upper' => true]).':</b>
|
<b>'.tr('Totale', [], ['upper' => true]).':</b>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
|
@ -192,25 +192,11 @@ echo '
|
|||||||
</tbody>';
|
</tbody>';
|
||||||
|
|
||||||
// Calcoli
|
// Calcoli
|
||||||
$imponibile = sum(array_column($rs, 'subtotale'));
|
$imponibile = abs($ddt->imponibile);
|
||||||
$sconto = sum(array_column($rs, 'sconto'));
|
$sconto = $ddt->sconto;
|
||||||
$iva = sum(array_column($rs, 'iva'));
|
$totale_imponibile = abs($ddt->totale_imponibile);
|
||||||
|
$iva = abs($ddt->iva);
|
||||||
$totale_imponibile = sum($imponibile, -$sconto);
|
$totale = abs($ddt->totale);
|
||||||
|
|
||||||
$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
|
// IMPONIBILE
|
||||||
echo '
|
echo '
|
||||||
@ -226,8 +212,8 @@ echo '
|
|||||||
<td></td>
|
<td></td>
|
||||||
</tr>';
|
</tr>';
|
||||||
|
|
||||||
if (abs($sconto) > 0) {
|
// SCONTO
|
||||||
// SCONTO
|
if (!empty($sconto)) {
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5" class="text-right">
|
<td colspan="5" class="text-right">
|
||||||
@ -256,36 +242,19 @@ if (abs($sconto) > 0) {
|
|||||||
</tr>';
|
</tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// RIVALSA INPS
|
// IVA
|
||||||
if (abs($record['rivalsainps']) > 0) {
|
echo '
|
||||||
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 '
|
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5" class="text-right">
|
<td colspan="5" class="text-right">
|
||||||
<b>'.tr('IVA', [], ['upper' => true]).':</b>
|
<b>'.tr('IVA', [], ['upper' => true]).':</b>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td align="right">
|
<td align="right">
|
||||||
'.moneyFormat($totale_iva, 2).'
|
'.moneyFormat($iva, 2).'
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td></td>
|
<td></td>
|
||||||
</tr>';
|
</tr>';
|
||||||
}
|
|
||||||
|
|
||||||
// TOTALE
|
// TOTALE
|
||||||
echo '
|
echo '
|
||||||
@ -301,54 +270,6 @@ echo '
|
|||||||
<td></td>
|
<td></td>
|
||||||
</tr>';
|
</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 '
|
echo '
|
||||||
</table>';
|
</table>';
|
||||||
|
|
||||||
|
@ -46,7 +46,9 @@ $rs = $dbo->fetchArray('SELECT
|
|||||||
AND in_interventi.id_preventivo IS NULL
|
AND in_interventi.id_preventivo IS NULL
|
||||||
AND NOT in_interventi.id IN (SELECT idintervento FROM co_promemoria WHERE idintervento IS NOT NULL)');
|
AND NOT in_interventi.id IN (SELECT idintervento FROM co_promemoria WHERE idintervento IS NOT NULL)');
|
||||||
foreach ($rs as $key => $value) {
|
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]['prezzo'] = Translator::numberToLocale($prezzo);
|
||||||
$rs[$key]['descrizione_intervento'] = strip_tags($rs[$key]['descrizione_intervento']);
|
$rs[$key]['descrizione_intervento'] = strip_tags($rs[$key]['descrizione_intervento']);
|
||||||
|
|
||||||
|
@ -284,7 +284,7 @@ echo '
|
|||||||
</tbody>';
|
</tbody>';
|
||||||
|
|
||||||
$imponibile = abs($fattura->imponibile);
|
$imponibile = abs($fattura->imponibile);
|
||||||
$sconto = abs($fattura->sconto);
|
$sconto = $fattura->sconto;
|
||||||
$totale_imponibile = abs($fattura->totale_imponibile);
|
$totale_imponibile = abs($fattura->totale_imponibile);
|
||||||
$iva = abs($fattura->iva);
|
$iva = abs($fattura->iva);
|
||||||
$totale = abs($fattura->totale);
|
$totale = abs($fattura->totale);
|
||||||
|
@ -219,8 +219,8 @@ echo '
|
|||||||
success: function(){
|
success: function(){
|
||||||
$('#bs-popup').modal('hide');
|
$('#bs-popup').modal('hide');
|
||||||
|
|
||||||
// Ricarico gli articoli
|
// Ricarico le righe
|
||||||
$('#articoli').load(globals.rootdir + '/modules/interventi/ajax_articoli.php?id_module=<?php echo $id_module; ?>&id_record=<?php echo $id_record; ?>');
|
$('#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
|
// 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; ?>');
|
$('#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';
|
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'));
|
$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) {
|
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));
|
$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']) {
|
if ($rss[0]['flag_completato']) {
|
||||||
@ -26,77 +26,109 @@ if ($show_prezzi) {
|
|||||||
echo '
|
echo '
|
||||||
<!-- Riepilogo dei costi -->
|
<!-- Riepilogo dei costi -->
|
||||||
<table class="table table condensed table-striped table-hover table-bordered">
|
<table class="table table condensed table-striped table-hover table-bordered">
|
||||||
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th width="40%"></th>
|
<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('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('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>
|
<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>
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<th>'.tr('Totale manodopera', [], ['upper' => true]).'</th>
|
<th>'.tr('Totale manodopera', [], ['upper' => true]).'</th>
|
||||||
<td class="text-right">'.moneyFormat($costi['manodopera_costo'], 2).'</td>
|
<td class="text-right">'.moneyFormat($sessioni->sum('costo_manodopera'), 2).'</td>
|
||||||
<td class="text-right">'.moneyFormat($costi['manodopera_addebito'], 2).'</td>
|
<td class="text-right">'.moneyFormat($sessioni->sum('prezzo_manodopera'), 2).'</td>
|
||||||
<td class="text-right">'.moneyFormat($costi['manodopera_scontato'], 2).'</td>
|
<td class="text-right">'.moneyFormat($sessioni->sum('prezzo_manodopera_scontato'), 2).'</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th>'.tr('Totale diritto di chiamata', [], ['upper' => true]).'</th>
|
<th>'.tr('Totale diritto di chiamata', [], ['upper' => true]).'</th>
|
||||||
<td class="text-right">'.moneyFormat($costi['dirittochiamata_costo'], 2).'</td>
|
<td class="text-right">'.moneyFormat($sessioni->sum('costo_diritto_chiamata'), 2).'</td>
|
||||||
<td class="text-right">'.moneyFormat($costi['dirittochiamata_addebito'], 2).'</td>
|
<td class="text-right">'.moneyFormat($sessioni->sum('prezzo_diritto_chiamata'), 2).'</td>
|
||||||
<td class="text-right">'.moneyFormat($costi['dirittochiamata_scontato'], 2).'</td>
|
<td class="text-right">'.moneyFormat($sessioni->sum('prezzo_diritto_chiamata'), 2).'</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th>'.tr('Totale viaggio', [], ['upper' => true]).'</th>
|
<th>'.tr('Totale viaggio', [], ['upper' => true]).'</th>
|
||||||
<td class="text-right">'.moneyFormat($costi['viaggio_costo'], 2).'</td>
|
<td class="text-right">'.moneyFormat($sessioni->sum('costo_viaggio'), 2).'</td>
|
||||||
<td class="text-right">'.moneyFormat($costi['viaggio_addebito'], 2).'</td>
|
<td class="text-right">'.moneyFormat($sessioni->sum('prezzo_viaggio'), 2).'</td>
|
||||||
<td class="text-right">'.moneyFormat($costi['viaggio_scontato'], 2).'</td>
|
<td class="text-right">'.moneyFormat($sessioni->sum('prezzo_viaggio_scontato'), 2).'</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th>'.tr('Totale articoli', [], ['upper' => true]).'</th>
|
<th>'.tr('Totale righe', [], ['upper' => true]).'</th>
|
||||||
<td class="text-right">'.moneyFormat($costi['ricambi_costo'], 2).'</td>
|
<td class="text-right">'.moneyFormat($righe->sum('spesa'), 2).'</td>
|
||||||
<td class="text-right">'.moneyFormat($costi['ricambi_addebito'], 2).'</td>
|
<td class="text-right">'.moneyFormat($righe->sum('imponibile'), 2).'</td>
|
||||||
<td class="text-right">'.moneyFormat($costi['ricambi_scontato'], 2).'</td>
|
<td class="text-right">'.moneyFormat($righe->sum('totale_imponibile'), 2).'</td>
|
||||||
</tr>
|
</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>
|
<tr>
|
||||||
<th>'.tr('Totale altre spese', [], ['upper' => true]).'</th>
|
<td colspan="3" class="text-right">
|
||||||
<td class="text-right">'.moneyFormat($costi['altro_costo'], 2).'</td>
|
<b>'.tr('Imponibile', [], ['upper' => true]).':</b>
|
||||||
<td class="text-right">'.moneyFormat($costi['altro_addebito'], 2).'</td>
|
</td>
|
||||||
<td class="text-right">'.moneyFormat($costi['altro_scontato'], 2).'</td>
|
<td align="right">
|
||||||
</tr>
|
'.moneyFormat($imponibile, 2).'
|
||||||
|
</td>
|
||||||
|
</tr>';
|
||||||
|
|
||||||
|
// SCONTO
|
||||||
|
if (!empty($sconto)) {
|
||||||
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<th>'.tr('Sconto incondizionato', [], ['upper' => true]).'</th>
|
<td colspan="3" class="text-right">
|
||||||
<td class="text-right">-</td>
|
<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 class="text-right">-</td>
|
</td>
|
||||||
<td class="text-right">'.moneyFormat(-$costi['sconto_globale'], 2).'</td>
|
<td align="right">
|
||||||
</tr>
|
'.moneyFormat($sconto, 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>
|
|
||||||
|
|
||||||
|
// Totale imponibile
|
||||||
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<th>'.tr('Totale', [], ['upper' => true]).'</th>
|
<td colspan="3" class="text-right">
|
||||||
<th class="text-right">'.moneyFormat($costi['totaleivato_costo'], 2).'</th>
|
<b>'.tr('Totale imponibile', [], ['upper' => true]).':</b>
|
||||||
<th class="text-right">'.moneyFormat($costi['totaleivato_addebito'], 2).'</th>
|
</td>
|
||||||
<th class="text-right">'.moneyFormat($costi['totale'], 2).'</th>
|
<td align="right">
|
||||||
</tr>
|
'.moneyFormat($totale_imponibile, 2).'
|
||||||
|
</td>
|
||||||
|
</tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Totale iva
|
||||||
|
echo '
|
||||||
|
<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>
|
||||||
|
<td colspan="3" class="text-right">
|
||||||
|
<b>'.tr('Totale', [], ['upper' => true]).':</b>
|
||||||
|
</td>
|
||||||
|
<td align="right">
|
||||||
|
'.moneyFormat($totale, 2).'
|
||||||
|
</td>
|
||||||
|
</tr>';
|
||||||
|
|
||||||
|
echo '
|
||||||
</table>';
|
</table>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Modules\Interventi\Intervento;
|
||||||
|
|
||||||
if (file_exists(__DIR__.'/../../../core.php')) {
|
if (file_exists(__DIR__.'/../../../core.php')) {
|
||||||
include_once __DIR__.'/../../../core.php';
|
include_once __DIR__.'/../../../core.php';
|
||||||
} else {
|
} else {
|
||||||
@ -8,37 +10,66 @@ if (file_exists(__DIR__.'/../../../core.php')) {
|
|||||||
|
|
||||||
$show_prezzi = Auth::user()['gruppo'] != 'Tecnici' || (Auth::user()['gruppo'] == 'Tecnici' && setting('Mostra i prezzi al tecnico'));
|
$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';
|
$intervento = Intervento::find($id_record);
|
||||||
$rs2 = $dbo->fetchArray($query);
|
$righe = $intervento->getRighe();
|
||||||
|
|
||||||
if (count($rs2) > 0) {
|
if (!$righe->isEmpty()) {
|
||||||
echo '
|
echo '
|
||||||
<table class="table table-striped table-condensed table-hover table-bordered">
|
<table class="table table-striped table-hover table-condensed table-bordered">
|
||||||
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>'.tr('Descrizione').'</th>
|
<th>'.tr('Descrizione').'</th>
|
||||||
<th width="8%">'.tr('Q.tà').'</th>
|
<th class="text-center" width="8%">'.tr('Q.tà').'</th>
|
||||||
<th width="15%">'.tr('Prezzo di acquisto').'</th>';
|
<th class="text-center" width="15%">'.tr('Prezzo di acquisto').'</th>';
|
||||||
|
|
||||||
if ($show_prezzi) {
|
if ($show_prezzi) {
|
||||||
echo '
|
echo '
|
||||||
<th width="15%">'.tr('Prezzo di vendita').'</th>
|
<th class="text-center" width="15%">'.tr('Prezzo di vendita').'</th>
|
||||||
<th width="10%">'.tr('Iva').'</th>
|
<th class="text-center" width="10%">'.tr('Iva').'</th>
|
||||||
<th width="15%">'.tr('Subtotale').'</th>';
|
<th class="text-center" width="15%">'.tr('Imponibile').'</th>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$record['flag_completato']) {
|
if (!$record['flag_completato']) {
|
||||||
echo '
|
echo '
|
||||||
<th width="120" class="text-center">'.tr('#').'</th>';
|
<th class="text-center" width="120" class="text-center">'.tr('#').'</th>';
|
||||||
}
|
}
|
||||||
echo '
|
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 '
|
echo '
|
||||||
<tr>
|
<tr '.$extra.'>
|
||||||
<td>
|
<td>
|
||||||
<input type="hidden" name="id" value="'.$r['id'].'">
|
'.Modules::link($riga->isArticolo() ? Modules::get('Articoli')['id'] : null, $riga->isArticolo() ? $riga['idarticolo'] : null, $descrizione);
|
||||||
'.nl2br($r['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>';
|
</td>';
|
||||||
|
|
||||||
// Quantità
|
// Quantità
|
||||||
@ -50,16 +81,14 @@ if (count($rs2) > 0) {
|
|||||||
//Costo unitario
|
//Costo unitario
|
||||||
echo '
|
echo '
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
'.moneyFormat($r['prezzo_acquisto']).'
|
'.moneyFormat($riga->prezzo_unitario_acquisto).'
|
||||||
</td>';
|
</td>';
|
||||||
|
|
||||||
if ($show_prezzi) {
|
if ($show_prezzi) {
|
||||||
// Prezzo unitario
|
// Prezzo unitario
|
||||||
$netto = $r['prezzo_vendita'] - $r['sconto_unitario'];
|
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
'.moneyFormat($r['prezzo_vendita']);
|
'.moneyFormat($riga->prezzo_unitario_vendita);
|
||||||
|
|
||||||
if (abs($r['sconto_unitario']) > 0) {
|
if (abs($r['sconto_unitario']) > 0) {
|
||||||
$text = $r['sconto_unitario'] > 0 ? tr('sconto _TOT_ _TYPE_') : tr('maggiorazione _TOT_ _TYPE_');
|
$text = $r['sconto_unitario'] > 0 ? tr('sconto _TOT_ _TYPE_') : tr('maggiorazione _TOT_ _TYPE_');
|
||||||
@ -82,19 +111,34 @@ if (count($rs2) > 0) {
|
|||||||
// Prezzo di vendita
|
// Prezzo di vendita
|
||||||
echo '
|
echo '
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
'.moneyFormat(sum($r['prezzo_vendita'] * $r['qta'], -$r['sconto'])).'
|
'.moneyFormat($riga->imponibile).'
|
||||||
</td>';
|
</td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pulsante per riportare nel magazzino centrale.
|
// Pulsante per riportare nel magazzino centrale.
|
||||||
// Visibile solo se l'intervento non è stato nè fatturato nè completato.
|
// Visibile solo se l'intervento non è stato nè fatturato nè completato.
|
||||||
if (!$record['flag_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 '
|
echo '
|
||||||
<td class="text-center">
|
<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>
|
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>';
|
</td>';
|
||||||
}
|
}
|
||||||
echo '
|
echo '
|
||||||
@ -102,10 +146,11 @@ if (count($rs2) > 0) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
|
</tbody>
|
||||||
</table>';
|
</table>';
|
||||||
} else {
|
} else {
|
||||||
echo '
|
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>
|
</script>
|
||||||
|
@ -212,53 +212,27 @@ $_SESSION['superselect']['idsede_destinazione'] = $record['idsede_destinazione']
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php
|
<!-- RIGHE -->
|
||||||
// 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 -->
|
|
||||||
<div class="panel panel-primary">
|
<div class="panel panel-primary">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<h3 class="panel-title"><?php echo tr('Materiale utilizzato'); ?></h3>
|
<h3 class="panel-title"><?php echo tr('Righe'); ?></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>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-9">
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
if (!$record['flag_completato']) {
|
if (!$record['flag_completato']) {
|
||||||
echo '
|
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').'">
|
<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('Altre spese').'...
|
<i class="fa fa-plus"></i> '.tr('Articolo').'
|
||||||
|
</a>';
|
||||||
|
|
||||||
|
echo '
|
||||||
|
<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>';
|
</a>';
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
@ -267,9 +241,16 @@ if (!$record['flag_completato']) {
|
|||||||
</a>';
|
</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>
|
</div>
|
||||||
<br>
|
|
||||||
|
<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">
|
<div id="righe">
|
||||||
<?php
|
<?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
|
// 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');
|
$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'è)
|
// Aggiunta km come "Trasferta" (se c'è)
|
||||||
if ($costi_intervento['viaggio_addebito'] > 0) {
|
if ($intervento->prezzo_viaggio > 0) {
|
||||||
// Calcolo iva
|
// Calcolo iva
|
||||||
$query = 'SELECT * FROM co_iva WHERE id='.prepare($id_iva);
|
$query = 'SELECT * FROM co_iva WHERE id='.prepare($id_iva);
|
||||||
$dati = $dbo->fetchArray($query);
|
$dati = $dbo->fetchArray($query);
|
||||||
$desc_iva = $dati[0]['descrizione'];
|
$desc_iva = $dati[0]['descrizione'];
|
||||||
|
|
||||||
$subtot = $costi_intervento['viaggio_addebito'];
|
$subtot = $intervento->prezzo_viaggio;
|
||||||
$sconto = $costi_intervento['viaggio_addebito'] - $costi_intervento['viaggio_scontato'];
|
$sconto = $intervento->sconto_totale_viaggio;
|
||||||
$iva = ($subtot - $sconto) / 100 * $dati[0]['percentuale'];
|
$iva = ($subtot - $sconto) / 100 * $dati[0]['percentuale'];
|
||||||
$iva_indetraibile = $iva / 100 * $dati[0]['indetraibile'];
|
$iva_indetraibile = $iva / 100 * $dati[0]['indetraibile'];
|
||||||
|
|
||||||
@ -508,37 +508,6 @@ function aggiungi_intervento_in_fattura($id_intervento, $id_fattura, $descrizion
|
|||||||
$dbo->query($query);
|
$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
|
// Ricalcolo inps, ritenuta e bollo
|
||||||
if ($dir == 'entrata') {
|
if ($dir == 'entrata') {
|
||||||
ricalcola_costiagg_fattura($id_fattura);
|
ricalcola_costiagg_fattura($id_fattura);
|
||||||
|
@ -23,8 +23,9 @@ if (!empty($results)) {
|
|||||||
</tr>';
|
</tr>';
|
||||||
|
|
||||||
foreach ($results as $result) {
|
foreach ($results as $result) {
|
||||||
$costi_intervento = get_costi_intervento($result['id']);
|
$intervento = \Modules\Interventi\Intervento::find($result['id']);
|
||||||
$totale_interventi += $costi_intervento['totale'];
|
$totale_interventi += $intervento->totale;
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<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;
|
namespace Modules\Interventi\Components;
|
||||||
|
|
||||||
use Common\Model;
|
use Common\Model;
|
||||||
|
use Modules\Anagrafiche\Anagrafica;
|
||||||
use Modules\Interventi\Intervento;
|
use Modules\Interventi\Intervento;
|
||||||
|
use Modules\Iva\Aliquota;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notazione: i costi sono rivolti all'azienda, i prezzi al cliente.
|
* 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 $table = 'in_interventi_tecnici';
|
||||||
|
|
||||||
|
protected $aliquota_iva = null;
|
||||||
|
|
||||||
public function getParentID()
|
public function getParentID()
|
||||||
{
|
{
|
||||||
return 'idintervento';
|
return 'idintervento';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Relazioni Eloquent
|
||||||
|
|
||||||
|
public function anagrafica()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Anagrafica::class, 'idtecnico');
|
||||||
|
}
|
||||||
|
|
||||||
public function parent()
|
public function parent()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Intervento::class, $this->getParentID());
|
return $this->belongsTo(Intervento::class, $this->getParentID());
|
||||||
@ -159,7 +170,7 @@ class Sessione extends Model
|
|||||||
*
|
*
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
public function getScontoTotaleKmAttribute()
|
public function getScontoTotaleViaggioAttribute()
|
||||||
{
|
{
|
||||||
return calcola_sconto([
|
return calcola_sconto([
|
||||||
'sconto' => $this->scontokm_unitario,
|
'sconto' => $this->scontokm_unitario,
|
||||||
@ -175,7 +186,85 @@ class Sessione extends Model
|
|||||||
*/
|
*/
|
||||||
public function getPrezzoViaggioScontatoAttribute()
|
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;
|
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()
|
public function anagrafica()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Anagrafica::class, 'idanagrafica');
|
return $this->belongsTo(Anagrafica::class, 'idanagrafica');
|
||||||
|
@ -187,25 +187,11 @@ echo '
|
|||||||
</tbody>';
|
</tbody>';
|
||||||
|
|
||||||
// Calcoli
|
// Calcoli
|
||||||
$imponibile = sum(array_column($rs, 'subtotale'));
|
$imponibile = abs($ordine->imponibile);
|
||||||
$sconto = sum(array_column($rs, 'sconto'));
|
$sconto = $ordine->sconto;
|
||||||
$iva = sum(array_column($rs, 'iva'));
|
$totale_imponibile = abs($ordine->totale_imponibile);
|
||||||
|
$iva = abs($ordine->iva);
|
||||||
$totale_imponibile = sum($imponibile, -$sconto);
|
$totale = abs($ordine->totale);
|
||||||
|
|
||||||
$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
|
// IMPONIBILE
|
||||||
echo '
|
echo '
|
||||||
@ -220,7 +206,7 @@ echo '
|
|||||||
</tr>';
|
</tr>';
|
||||||
|
|
||||||
// SCONTO
|
// SCONTO
|
||||||
if (abs($sconto) > 0) {
|
if (!empty($sconto)) {
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5" class="text-right">
|
<td colspan="5" class="text-right">
|
||||||
@ -243,37 +229,19 @@ if (abs($sconto) > 0) {
|
|||||||
</td>
|
</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
</tr>';
|
</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
|
// IVA
|
||||||
if (abs($totale_iva) > 0) {
|
echo '
|
||||||
echo '
|
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5" class="text-right">
|
<td colspan="5" class="text-right">
|
||||||
<b>'.tr('Iva', [], ['upper' => true]).':</b>
|
<b>'.tr('Iva', [], ['upper' => true]).':</b>
|
||||||
</td>
|
</td>
|
||||||
<td align="right">
|
<td align="right">
|
||||||
'.moneyFormat($totale_iva, 2).'
|
'.moneyFormat($iva, 2).'
|
||||||
</td>
|
</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
</tr>';
|
</tr>';
|
||||||
}
|
|
||||||
|
|
||||||
// TOTALE
|
// TOTALE
|
||||||
echo '
|
echo '
|
||||||
@ -287,48 +255,6 @@ echo '
|
|||||||
<td></td>
|
<td></td>
|
||||||
</tr>';
|
</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 '
|
echo '
|
||||||
</table>';
|
</table>';
|
||||||
|
|
||||||
|
@ -19,6 +19,8 @@ $budget = get_imponibile_preventivo($id_record);
|
|||||||
$totale_costo = 0;
|
$totale_costo = 0;
|
||||||
$totale_addebito = 0;
|
$totale_addebito = 0;
|
||||||
$totale = 0;
|
$totale = 0;
|
||||||
|
$totale_ore = 0;
|
||||||
|
$totale_km = 0;
|
||||||
|
|
||||||
$totale_stato = [];
|
$totale_stato = [];
|
||||||
|
|
||||||
@ -38,8 +40,8 @@ if (!empty($rsi)) {
|
|||||||
|
|
||||||
// Tabella con i dati
|
// Tabella con i dati
|
||||||
foreach ($rsi as $int) {
|
foreach ($rsi as $int) {
|
||||||
$int = array_merge($int, get_costi_intervento($int['id']));
|
$intervento = \Modules\Interventi\Intervento::find($int['id']);
|
||||||
$totale_stato[$int['idstatointervento']] = sum($totale_stato[$int['idstatointervento']], $int['totale_scontato']);
|
$totale_stato[$int['idstatointervento']] = sum($totale_stato[$int['idstatointervento']], $intervento->totale_imponibile);
|
||||||
|
|
||||||
// Riga intervento singolo
|
// Riga intervento singolo
|
||||||
echo '
|
echo '
|
||||||
@ -61,15 +63,15 @@ if (!empty($rsi)) {
|
|||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
'.Translator::numberToLocale($int['totale_costo']).'
|
'.Translator::numberToLocale($intervento->spesa).'
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
'.Translator::numberToLocale($int['totale_addebito']).'
|
'.Translator::numberToLocale($intervento->imponibile).'
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
'.Translator::numberToLocale($int['totale_scontato']).'
|
'.Translator::numberToLocale($intervento->totale_imponibile).'
|
||||||
</td>
|
</td>
|
||||||
</tr>';
|
</tr>';
|
||||||
|
|
||||||
|
@ -128,32 +128,17 @@ foreach ($rs as $r) {
|
|||||||
</tr>';
|
</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 '
|
echo '
|
||||||
</tbody>';
|
</tbody>';
|
||||||
|
|
||||||
// SCONTO
|
// Calcoli
|
||||||
if (abs($sconto) > 0) {
|
$imponibile = abs($preventivo->imponibile);
|
||||||
echo '
|
$sconto = $preventivo->sconto;
|
||||||
|
$totale_imponibile = abs($preventivo->totale_imponibile);
|
||||||
|
$iva = abs($preventivo->iva);
|
||||||
|
$totale = abs($preventivo->totale);
|
||||||
|
|
||||||
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5" class="text-right">
|
<td colspan="5" class="text-right">
|
||||||
<b>'.tr('Imponibile', [], ['upper' => true]).':</b>
|
<b>'.tr('Imponibile', [], ['upper' => true]).':</b>
|
||||||
@ -164,6 +149,8 @@ if (abs($sconto) > 0) {
|
|||||||
<td></td>
|
<td></td>
|
||||||
</tr>';
|
</tr>';
|
||||||
|
|
||||||
|
// SCONTO
|
||||||
|
if (!empty($sconto)) {
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5" class="text-right">
|
<td colspan="5" class="text-right">
|
||||||
@ -186,18 +173,6 @@ if (abs($sconto) > 0) {
|
|||||||
</td>
|
</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
</tr>';
|
</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
|
// Totale iva
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// Calcoli
|
// Calcoli
|
||||||
$imponibile = $documento->imponibile;
|
$imponibile = abs($documento->imponibile);
|
||||||
$sconto = $documento->sconto;
|
$sconto = $documento->sconto;
|
||||||
$totale_imponibile = $documento->totale_imponibile;
|
$totale_imponibile = abs($documento->totale_imponibile);
|
||||||
$totale_iva = $documento->iva;
|
$totale_iva = abs($documento->iva);
|
||||||
$totale = $documento->totale;
|
$totale = abs($documento->totale);
|
||||||
$netto_a_pagare = $documento->netto;
|
$netto_a_pagare = abs($documento->netto);
|
||||||
|
|
||||||
$show_sconto = $sconto > 0;
|
$show_sconto = $sconto > 0;
|
||||||
|
|
||||||
$width = round(100 / ($show_sconto ? 5 : 3), 2);
|
$width = round(100 / ($show_sconto ? 5 : 3), 2);
|
||||||
|
|
||||||
// SCADENZE | TOTALI
|
// SCADENZE | TOTALI
|
||||||
|
@ -12,10 +12,10 @@ echo '
|
|||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="text-left" style="width:30%">'.tr('Intervento num.').': <b>'.$records[0]['codice'].'</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($records[0]['data_richiesta']).'</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>'.$records[0]['numero_preventivo'].'</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>'.$records[0]['numero_contratto'].'</b></td>
|
<td class="text-left" style="width:25%">'.tr('Contratto num.').': <b>'.(!empty($contratto) ? $contratto['numero'] : '').'</b></td>
|
||||||
</tr>';
|
</tr>';
|
||||||
|
|
||||||
// Dati cliente
|
// Dati cliente
|
||||||
@ -83,7 +83,7 @@ echo '
|
|||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="4">
|
<td colspan="4">
|
||||||
<b>'.tr('Tipo intervento').':</b> '.$records[0]['tipointervento'].'
|
<b>'.tr('Tipo intervento').':</b> '.$documento['tipointervento'].'
|
||||||
</td>
|
</td>
|
||||||
</tr>';
|
</tr>';
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ echo '
|
|||||||
<tr>
|
<tr>
|
||||||
<td colspan="4" style="height:20mm;">
|
<td colspan="4" style="height:20mm;">
|
||||||
<b>'.tr('Richiesta').':</b>
|
<b>'.tr('Richiesta').':</b>
|
||||||
<p>'.nl2br($records[0]['richiesta']).'</p>
|
<p>'.nl2br($documento['richiesta']).'</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>';
|
</tr>';
|
||||||
|
|
||||||
@ -101,122 +101,22 @@ echo '
|
|||||||
<tr>
|
<tr>
|
||||||
<td colspan="4" style="height:20mm;">
|
<td colspan="4" style="height:20mm;">
|
||||||
<b>'.tr('Descrizione').':</b>
|
<b>'.tr('Descrizione').':</b>
|
||||||
<p>'.nl2br($records[0]['descrizione_intervento']).'</p>
|
<p>'.nl2br($documento['descrizione']).'</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>';
|
</tr>';
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
</table>';
|
</table>';
|
||||||
|
|
||||||
$totale = [];
|
$righe = $documento->getRighe();
|
||||||
|
|
||||||
// MATERIALE UTILIzZZATO
|
if (!$righe->isEmpty()) {
|
||||||
$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)) {
|
|
||||||
echo '
|
echo '
|
||||||
<table class="table table-bordered">
|
<table class="table table-bordered">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="4" class="text-center">
|
<th colspan="4" class="text-center">
|
||||||
<b>'.tr('Materiale utilizzato', [], ['upper' => true]).'</b>
|
<b>'.tr('Materiale utilizzato e spese aggiuntive', [], ['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>
|
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
@ -234,19 +134,40 @@ if (!empty($rs2)) {
|
|||||||
</th>
|
</th>
|
||||||
|
|
||||||
<th style="font-size:8pt;width:20%" class="text-center">
|
<th style="font-size:8pt;width:20%" class="text-center">
|
||||||
<b>'.tr('Subtot.').'</b>
|
<b>'.tr('Imponibile').'</b>
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
<tbody>';
|
<tbody>';
|
||||||
|
|
||||||
foreach ($rs2 as $r) {
|
foreach ($righe as $riga) {
|
||||||
|
$r = $riga->toArray();
|
||||||
|
|
||||||
// Articolo
|
// Articolo
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<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>';
|
</td>';
|
||||||
|
|
||||||
// Quantità
|
// Quantità
|
||||||
@ -258,7 +179,7 @@ if (!empty($rs2)) {
|
|||||||
// Prezzo unitario
|
// Prezzo unitario
|
||||||
echo '
|
echo '
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
'.($options['pricing'] ? moneyFormat($r['prezzo_vendita']) : '-');
|
'.($options['pricing'] ? moneyFormat($riga->prezzo_unitario_vendita) : '-');
|
||||||
|
|
||||||
if ($options['pricing'] && $r['sconto'] > 0) {
|
if ($options['pricing'] && $r['sconto'] > 0) {
|
||||||
echo "
|
echo "
|
||||||
@ -272,13 +193,13 @@ if (!empty($rs2)) {
|
|||||||
</td>';
|
</td>';
|
||||||
|
|
||||||
// Prezzo totale
|
// Prezzo totale
|
||||||
$netto = $r['prezzo_vendita'] * $r['qta'] - $r['sconto'];
|
|
||||||
echo '
|
echo '
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
'.($options['pricing'] ? Translator::numberToLocale($netto) : '-').'
|
'.($options['pricing'] ? Translator::numberToLocale($riga->totale_imponibile) : '-').'
|
||||||
</td>
|
</td>
|
||||||
</tr>';
|
</tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
</tbody>';
|
</tbody>';
|
||||||
|
|
||||||
@ -287,11 +208,11 @@ if (!empty($rs2)) {
|
|||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="3" class="text-right">
|
<td colspan="3" class="text-right">
|
||||||
<b>'.tr('Totale spese aggiuntive', [], ['upper' => true]).':</b>
|
<b>'.tr('Totale', [], ['upper' => true]).':</b>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<th class="text-center">
|
<th class="text-center">
|
||||||
<b>'.moneyFormat($costi_intervento['altro_scontato'], 2).'</b>
|
<b>'.moneyFormat($righe->sum('totale_imponibile'), 2).'</b>
|
||||||
</th>
|
</th>
|
||||||
</tr>';
|
</tr>';
|
||||||
}
|
}
|
||||||
@ -300,8 +221,6 @@ if (!empty($rs2)) {
|
|||||||
</table>';
|
</table>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// FINE SPESE AGGIUNTIVE
|
|
||||||
|
|
||||||
// INTESTAZIONE ELENCO TECNICI
|
// INTESTAZIONE ELENCO TECNICI
|
||||||
echo '
|
echo '
|
||||||
<table class="table table-bordered vertical-middle">
|
<table class="table table-bordered vertical-middle">
|
||||||
@ -337,34 +256,34 @@ echo '
|
|||||||
<tbody>';
|
<tbody>';
|
||||||
|
|
||||||
// Sessioni di lavoro dei tecnici
|
// 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 '
|
echo '
|
||||||
<tr>';
|
<tr>';
|
||||||
|
|
||||||
// nome tecnico
|
// Nome tecnico
|
||||||
echo '
|
echo '
|
||||||
<td>
|
<td>
|
||||||
'.$r['ragione_sociale'].'
|
'.$sessione->anagrafica->ragione_sociale.'
|
||||||
</td>';
|
</td>';
|
||||||
|
|
||||||
// data
|
// Data
|
||||||
echo '
|
echo '
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
'.Translator::dateToLocale($r['orario_inizio'], '-').'
|
'.Translator::dateToLocale($sessione['orario_inizio'], '-').'
|
||||||
</td>';
|
</td>';
|
||||||
|
|
||||||
// ora inizio
|
// Ora inizio
|
||||||
echo '
|
echo '
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
'.Translator::timeToLocale($r['orario_inizio'], '-').'
|
'.Translator::timeToLocale($sessione['orario_inizio'], '-').'
|
||||||
</td>';
|
</td>';
|
||||||
|
|
||||||
// ora fine
|
// Ora fine
|
||||||
echo '
|
echo '
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
'.Translator::timeToLocale($r['orario_fine'], '-').'
|
'.Translator::timeToLocale($sessione['orario_fine'], '-').'
|
||||||
</td>';
|
</td>';
|
||||||
|
|
||||||
// Spazio aggiuntivo
|
// Spazio aggiuntivo
|
||||||
@ -383,7 +302,7 @@ foreach ($rst as $i => $r) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ore lavorate
|
// Ore lavorate
|
||||||
$ore = get_ore_intervento($id_record);
|
$ore = $documento->ore_totali;
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
@ -395,7 +314,7 @@ echo '
|
|||||||
if ($options['pricing']) {
|
if ($options['pricing']) {
|
||||||
echo '
|
echo '
|
||||||
<td colspan="3" class="text-center">
|
<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>';
|
</td>';
|
||||||
} else {
|
} else {
|
||||||
echo '
|
echo '
|
||||||
@ -403,7 +322,7 @@ if ($options['pricing']) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Timbro e firma
|
// 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 '
|
echo '
|
||||||
<td rowspan="2" class="text-center" style="font-size:8pt;height:30mm;vertical-align:bottom">
|
<td rowspan="2" class="text-center" style="font-size:8pt;height:30mm;vertical-align:bottom">
|
||||||
'.$firma.'<br>
|
'.$firma.'<br>
|
||||||
@ -415,14 +334,14 @@ echo '
|
|||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td class="text-center">
|
<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>';
|
</td>';
|
||||||
|
|
||||||
// Costo trasferta
|
// Costo trasferta
|
||||||
if ($options['pricing']) {
|
if ($options['pricing']) {
|
||||||
echo '
|
echo '
|
||||||
<td class="text-center">
|
<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>';
|
</td>';
|
||||||
} else {
|
} else {
|
||||||
echo '
|
echo '
|
||||||
@ -433,14 +352,23 @@ if ($options['pricing']) {
|
|||||||
if ($options['pricing']) {
|
if ($options['pricing']) {
|
||||||
echo '
|
echo '
|
||||||
<td class="text-center" colspan="2">
|
<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>';
|
</td>';
|
||||||
} else {
|
} else {
|
||||||
echo '
|
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
|
// TOTALE COSTI FINALI
|
||||||
if ($options['pricing']) {
|
if ($options['pricing']) {
|
||||||
// Totale imponibile
|
// Totale imponibile
|
||||||
@ -451,14 +379,12 @@ if ($options['pricing']) {
|
|||||||
</td>
|
</td>
|
||||||
|
|
||||||
<th class="text-center">
|
<th class="text-center">
|
||||||
<b>'.moneyFormat($costi_intervento['totale_addebito'], 2).'</b>
|
'.moneyFormat($show_sconto ? $imponibile : $totale_imponibile, 2).'
|
||||||
</th>
|
</th>
|
||||||
</tr>';
|
</tr>';
|
||||||
|
|
||||||
$totale_sconto = $costi_intervento['totale_addebito'] - $costi_intervento['totale_scontato'];
|
|
||||||
|
|
||||||
// Eventuale sconto totale
|
// Eventuale sconto totale
|
||||||
if (!empty($totale_sconto)) {
|
if ($show_sconto) {
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="4" class="text-right">
|
<td colspan="4" class="text-right">
|
||||||
@ -466,7 +392,7 @@ if ($options['pricing']) {
|
|||||||
</td>
|
</td>
|
||||||
|
|
||||||
<th class="text-center">
|
<th class="text-center">
|
||||||
<b>-'.moneyFormat($totale_sconto, 2).'</b>
|
<b>'.moneyFormat($sconto, 2).'</b>
|
||||||
</th>
|
</th>
|
||||||
</tr>';
|
</tr>';
|
||||||
|
|
||||||
@ -478,7 +404,7 @@ if ($options['pricing']) {
|
|||||||
</td>
|
</td>
|
||||||
|
|
||||||
<th class="text-center">
|
<th class="text-center">
|
||||||
<b>'.moneyFormat($costi_intervento['totale_scontato'], 2).'</b>
|
<b>'.moneyFormat($totale_imponibile, 2).'</b>
|
||||||
</th>
|
</th>
|
||||||
</tr>';
|
</tr>';
|
||||||
}
|
}
|
||||||
@ -492,7 +418,7 @@ if ($options['pricing']) {
|
|||||||
</td>
|
</td>
|
||||||
|
|
||||||
<th class="text-center">
|
<th class="text-center">
|
||||||
<b>'.moneyFormat($costi_intervento['iva_totale'], 2).'</b>
|
<b>'.moneyFormat($totale_iva, 2).'</b>
|
||||||
</th>
|
</th>
|
||||||
</tr>';
|
</tr>';
|
||||||
|
|
||||||
@ -503,7 +429,7 @@ if ($options['pricing']) {
|
|||||||
<b>'.tr('Totale intervento', [], ['upper' => true]).':</b>
|
<b>'.tr('Totale intervento', [], ['upper' => true]).':</b>
|
||||||
</td>
|
</td>
|
||||||
<th class="text-center">
|
<th class="text-center">
|
||||||
<b>'.moneyFormat($costi_intervento['totale'], 2).'</b>
|
<b>'.moneyFormat($totale, 2).'</b>
|
||||||
</th>
|
</th>
|
||||||
</tr>';
|
</tr>';
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,12 @@
|
|||||||
|
|
||||||
include_once __DIR__.'/../../core.php';
|
include_once __DIR__.'/../../core.php';
|
||||||
|
|
||||||
$module_name = 'Interventi';
|
use Modules\Interventi\Intervento;
|
||||||
|
|
||||||
// carica intervento
|
$documento = Intervento::find($id_record);
|
||||||
$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);
|
|
||||||
|
|
||||||
$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_cliente = $documento['idanagrafica'];
|
||||||
$id_sede = $records[0]['idsede'];
|
$id_sede = $documento['idsede'];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user