2017-08-04 16:28:16 +02:00
|
|
|
<?php
|
|
|
|
|
2018-06-26 14:30:26 +02:00
|
|
|
if (file_exists(__DIR__.'/../../../core.php')) {
|
|
|
|
include_once __DIR__.'/../../../core.php';
|
|
|
|
} else {
|
|
|
|
include_once __DIR__.'/../../core.php';
|
2018-06-18 15:56:00 +02:00
|
|
|
}
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2018-09-28 16:43:40 +02:00
|
|
|
$show_prezzi = Auth::user()['gruppo'] != 'Tecnici' || (Auth::user()['gruppo'] == 'Tecnici' && setting('Mostra i prezzi al tecnico'));
|
|
|
|
|
2019-02-01 17:44:31 +01:00
|
|
|
$query = 'SELECT * FROM in_righe_interventi WHERE idintervento='.prepare($id_record).' ORDER BY id ASC';
|
2017-08-04 16:28:16 +02:00
|
|
|
$rs2 = $dbo->fetchArray($query);
|
|
|
|
|
|
|
|
if (count($rs2) > 0) {
|
|
|
|
echo '
|
|
|
|
<table class="table table-striped table-condensed table-hover table-bordered">
|
|
|
|
<tr>
|
2017-09-04 12:02:29 +02:00
|
|
|
<th>'.tr('Descrizione').'</th>
|
|
|
|
<th width="8%">'.tr('Q.tà').'</th>
|
|
|
|
<th width="15%">'.tr('Prezzo di acquisto').'</th>';
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2018-09-28 16:43:40 +02:00
|
|
|
if ($show_prezzi) {
|
2017-08-04 16:28:16 +02:00
|
|
|
echo '
|
2017-09-04 12:02:29 +02:00
|
|
|
<th width="15%">'.tr('Prezzo di vendita').'</th>
|
2018-03-19 18:11:51 +01:00
|
|
|
<th width="10%">'.tr('Iva').'</th>
|
2017-09-04 12:02:29 +02:00
|
|
|
<th width="15%">'.tr('Subtotale').'</th>';
|
2017-08-04 16:28:16 +02:00
|
|
|
}
|
|
|
|
|
2018-07-18 15:20:10 +02:00
|
|
|
if (!$record['flag_completato']) {
|
2017-08-04 16:28:16 +02:00
|
|
|
echo '
|
2018-09-28 16:43:40 +02:00
|
|
|
<th width="120" class="text-center">'.tr('#').'</th>';
|
2017-08-04 16:28:16 +02:00
|
|
|
}
|
|
|
|
echo '
|
|
|
|
</tr>';
|
|
|
|
|
|
|
|
foreach ($rs2 as $r) {
|
|
|
|
echo '
|
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
<input type="hidden" name="id" value="'.$r['id'].'">
|
|
|
|
'.nl2br($r['descrizione']).'
|
|
|
|
</td>';
|
|
|
|
|
|
|
|
// Quantità
|
|
|
|
echo '
|
|
|
|
<td class="text-right">
|
2018-06-29 13:35:39 +02:00
|
|
|
'.Translator::numberToLocale($r['qta'], 'qta').' '.$r['um'].'
|
2017-08-04 16:28:16 +02:00
|
|
|
</td>';
|
|
|
|
|
|
|
|
//Costo unitario
|
|
|
|
echo '
|
|
|
|
<td class="text-right">
|
2019-04-13 02:56:39 +02:00
|
|
|
'.moneyFormat($r['prezzo_acquisto']).'
|
2017-08-04 16:28:16 +02:00
|
|
|
</td>';
|
|
|
|
|
2018-09-28 16:43:40 +02:00
|
|
|
if ($show_prezzi) {
|
2017-08-04 16:28:16 +02:00
|
|
|
// Prezzo unitario
|
|
|
|
$netto = $r['prezzo_vendita'] - $r['sconto_unitario'];
|
|
|
|
|
|
|
|
echo '
|
|
|
|
<td class="text-right">
|
2019-04-13 02:56:39 +02:00
|
|
|
'.moneyFormat($r['prezzo_vendita']);
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
if ($r['sconto_unitario'] > 0) {
|
|
|
|
echo '
|
|
|
|
<br><span class="label label-danger">
|
2017-09-15 09:48:56 +02:00
|
|
|
- '.tr('sconto _TOT_ _TYPE_', [
|
|
|
|
'_TOT_' => Translator::numberToLocale($r['sconto_unitario']),
|
2019-04-13 00:09:48 +02:00
|
|
|
'_TYPE_' => ($r['tipo_sconto'] == 'PRC' ? '%' : currency()),
|
2017-09-15 09:48:56 +02:00
|
|
|
]).'
|
2017-08-04 16:28:16 +02:00
|
|
|
</span>';
|
|
|
|
}
|
|
|
|
|
2018-03-19 18:11:51 +01:00
|
|
|
echo '
|
|
|
|
</td>';
|
2018-05-05 09:29:09 +02:00
|
|
|
|
2018-03-19 18:11:51 +01:00
|
|
|
echo '
|
|
|
|
<td class="text-right">
|
2019-04-13 05:52:04 +02:00
|
|
|
'.moneyFormat($r['iva']).'
|
2017-08-04 16:28:16 +02:00
|
|
|
</td>';
|
|
|
|
|
|
|
|
// Prezzo di vendita
|
|
|
|
echo '
|
|
|
|
<td class="text-right">
|
2019-04-13 05:52:04 +02:00
|
|
|
'.moneyFormat(sum($r['prezzo_vendita'] * $r['qta'], -$r['sconto'])).'
|
2017-08-04 16:28:16 +02:00
|
|
|
</td>';
|
|
|
|
}
|
|
|
|
|
|
|
|
// Pulsante per riportare nel magazzino centrale.
|
|
|
|
// Visibile solo se l'intervento non è stato nè fatturato nè completato.
|
2018-07-18 15:20:10 +02:00
|
|
|
if (!$record['flag_completato']) {
|
2019-03-29 12:46:17 +01:00
|
|
|
$link = $record['prezzo_vendita'] == 0 ? $structure->fileurl('row-edit.php') : $structure->fileurl('add_righe.php');
|
|
|
|
|
2017-08-04 16:28:16 +02:00
|
|
|
echo '
|
2018-09-28 16:43:40 +02:00
|
|
|
<td class="text-center">
|
2019-03-29 12:46:17 +01:00
|
|
|
<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>
|
2017-09-04 12:02:29 +02:00
|
|
|
<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>
|
2017-08-04 16:28:16 +02:00
|
|
|
</td>';
|
|
|
|
}
|
|
|
|
echo '
|
|
|
|
</tr>';
|
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
|
|
|
</table>';
|
2018-11-01 12:39:54 +01:00
|
|
|
} else {
|
|
|
|
echo '
|
|
|
|
<p>'.tr('Nessuna spesa presente').'.</p>';
|
2017-08-04 16:28:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
function elimina_riga( id ){
|
|
|
|
$.post(globals.rootdir + '/modules/interventi/actions.php', { op: 'delriga', idriga: id }, function(data, result){
|
|
|
|
if( result=='success' ){
|
|
|
|
//ricarico l'elenco delle righe
|
2018-02-18 19:53:23 +01:00
|
|
|
$('#righe').load( globals.rootdir + '/modules/interventi/ajax_righe.php?id_module=<?php echo $id_module; ?>&id_record=<?php echo $id_record; ?>');
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2018-02-18 19:53:23 +01:00
|
|
|
$('#costi').load(globals.rootdir + '/modules/interventi/ajax_costi.php?id_module=<?php echo $id_module; ?>&id_record=<?php echo $id_record; ?>');
|
2017-08-04 16:28:16 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
</script>
|