2017-08-04 16:28:16 +02:00
|
|
|
<?php
|
|
|
|
|
2019-07-12 17:35:14 +02:00
|
|
|
use Modules\Interventi\Intervento;
|
|
|
|
|
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-07-12 17:35:14 +02:00
|
|
|
$intervento = Intervento::find($id_record);
|
|
|
|
$righe = $intervento->getRighe();
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2019-07-12 17:35:14 +02:00
|
|
|
if (!$righe->isEmpty()) {
|
2017-08-04 16:28:16 +02:00
|
|
|
echo '
|
2019-07-12 17:35:14 +02:00
|
|
|
<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>';
|
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 '
|
2019-07-12 17:35:14 +02:00
|
|
|
<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>';
|
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 '
|
2019-07-12 17:35:14 +02:00
|
|
|
<th class="text-center" width="120" class="text-center">'.tr('#').'</th>';
|
2017-08-04 16:28:16 +02:00
|
|
|
}
|
|
|
|
echo '
|
2019-07-12 17:35:14 +02:00
|
|
|
</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'];
|
|
|
|
|
|
|
|
echo '
|
|
|
|
<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);
|
|
|
|
}
|
|
|
|
}
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
echo '
|
2019-07-12 17:35:14 +02:00
|
|
|
</td>';
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
// Quantità
|
|
|
|
echo '
|
2019-07-12 17:35:14 +02:00
|
|
|
<td class="text-right">
|
|
|
|
'.Translator::numberToLocale($r['qta'], 'qta').' '.$r['um'].'
|
|
|
|
</td>';
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
//Costo unitario
|
|
|
|
echo '
|
2019-07-12 17:35:14 +02:00
|
|
|
<td class="text-right">
|
|
|
|
'.moneyFormat($riga->prezzo_unitario_acquisto).'
|
|
|
|
</td>';
|
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
|
|
|
// Prezzo unitario
|
|
|
|
echo '
|
2019-07-12 17:35:14 +02:00
|
|
|
<td class="text-right">
|
|
|
|
'.moneyFormat($riga->prezzo_unitario_vendita);
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2019-07-11 17:34:06 +02:00
|
|
|
if (abs($r['sconto_unitario']) > 0) {
|
2019-07-11 17:44:42 +02:00
|
|
|
$text = $r['sconto_unitario'] > 0 ? tr('sconto _TOT_ _TYPE_') : tr('maggiorazione _TOT_ _TYPE_');
|
|
|
|
|
2017-08-04 16:28:16 +02:00
|
|
|
echo '
|
2019-07-12 17:35:14 +02:00
|
|
|
<br><small class="label label-danger">'.replace($text, [
|
2019-07-11 17:44:42 +02:00
|
|
|
'_TOT_' => Translator::numberToLocale(abs($r['sconto_unitario'])),
|
2019-04-13 00:09:48 +02:00
|
|
|
'_TYPE_' => ($r['tipo_sconto'] == 'PRC' ? '%' : currency()),
|
2019-07-11 17:44:42 +02:00
|
|
|
]).'</small>';
|
2017-08-04 16:28:16 +02:00
|
|
|
}
|
|
|
|
|
2018-03-19 18:11:51 +01:00
|
|
|
echo '
|
2019-07-12 17:35:14 +02:00
|
|
|
</td>';
|
2018-05-05 09:29:09 +02:00
|
|
|
|
2018-03-19 18:11:51 +01:00
|
|
|
echo '
|
2019-07-12 17:35:14 +02:00
|
|
|
<td class="text-right">
|
|
|
|
'.moneyFormat($r['iva']).'
|
|
|
|
</td>';
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
// Prezzo di vendita
|
|
|
|
echo '
|
2019-07-12 17:35:14 +02:00
|
|
|
<td class="text-right">
|
|
|
|
'.moneyFormat($riga->imponibile).'
|
|
|
|
</td>';
|
2017-08-04 16:28:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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-07-12 17:35:14 +02:00
|
|
|
$link = $riga->isSconto() ? $structure->fileurl('row-edit.php') : $structure->fileurl('add_righe.php');
|
|
|
|
$link = $riga->isArticolo() ? $structure->fileurl('add_articolo.php') : $link;
|
2019-03-29 12:46:17 +01:00
|
|
|
|
2017-08-04 16:28:16 +02:00
|
|
|
echo '
|
2019-07-12 17:35:14 +02:00
|
|
|
<td class="text-center">';
|
|
|
|
|
|
|
|
if ($r['abilita_serial']) {
|
|
|
|
echo '
|
2019-07-29 13:16:55 +02:00
|
|
|
<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'].'\');">
|
2019-07-12 17:35:14 +02:00
|
|
|
<i class="fa fa-barcode"></i>
|
|
|
|
</button>';
|
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
2019-07-29 13:16:55 +02:00
|
|
|
<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'].'\');">
|
2019-07-12 17:35:14 +02:00
|
|
|
<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>';
|
2017-08-04 16:28:16 +02:00
|
|
|
}
|
|
|
|
echo '
|
2019-07-12 17:35:14 +02:00
|
|
|
</tr>';
|
2017-08-04 16:28:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
2019-07-12 17:35:14 +02:00
|
|
|
</tbody>
|
2017-08-04 16:28:16 +02:00
|
|
|
</table>';
|
2018-11-01 12:39:54 +01:00
|
|
|
} else {
|
|
|
|
echo '
|
2019-07-12 17:35:14 +02:00
|
|
|
<p>'.tr('Nessuna riga 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
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2019-07-12 17:35:14 +02:00
|
|
|
|
|
|
|
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; ?>');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2017-08-04 16:28:16 +02:00
|
|
|
</script>
|