2018-08-30 18:20:30 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
include_once __DIR__.'/../../core.php';
|
|
|
|
|
|
|
|
$plugin = Plugins::get($id_plugin);
|
2018-08-31 09:41:43 +02:00
|
|
|
$is_add = filter('add') ? true : false;
|
|
|
|
|
|
|
|
$pricing = Auth::admin() || Auth::user()['gruppo'] != 'Tecnici';
|
2018-08-30 18:20:30 +02:00
|
|
|
|
2019-02-01 17:44:31 +01:00
|
|
|
$rs2 = $dbo->fetchArray('SELECT * FROM co_promemoria_righe WHERE id_promemoria='.prepare($id_record).' ORDER BY id ASC');
|
2018-08-30 18:20:30 +02:00
|
|
|
|
|
|
|
if (!empty($rs2)) {
|
|
|
|
echo '
|
|
|
|
<table class="table table-striped table-condensed table-hover table-bordered">
|
|
|
|
<tr>
|
|
|
|
<th>'.tr('Descrizione').'</th>
|
|
|
|
<th width="8%">'.tr('Q.tà').'</th>
|
|
|
|
<th width="15%">'.tr('Prezzo di acquisto').'</th>';
|
|
|
|
|
2018-08-31 09:41:43 +02:00
|
|
|
if ($pricing) {
|
2018-08-30 18:20:30 +02:00
|
|
|
echo '
|
|
|
|
<th width="15%">'.tr('Prezzo di vendita').'</th>
|
|
|
|
<th width="10%">'.tr('Iva').'</th>
|
|
|
|
<th width="15%">'.tr('Subtotale').'</th>';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$record['flag_completato']) {
|
|
|
|
echo '
|
|
|
|
<th width="80"></th>';
|
|
|
|
}
|
|
|
|
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">
|
|
|
|
'.Translator::numberToLocale($r['qta'], 'qta').' '.$r['um'].'
|
|
|
|
</td>';
|
|
|
|
|
|
|
|
//Costo unitario
|
|
|
|
echo '
|
|
|
|
<td class="text-right">
|
2019-04-13 02:56:39 +02:00
|
|
|
'.moneyFormat($r['prezzo_acquisto']).'
|
2018-08-30 18:20:30 +02:00
|
|
|
</td>';
|
|
|
|
|
2018-08-31 09:41:43 +02:00
|
|
|
if ($pricing) {
|
2018-08-30 18:20:30 +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']).'';
|
2018-08-30 18:20:30 +02:00
|
|
|
|
|
|
|
if ($r['sconto_unitario'] > 0) {
|
|
|
|
echo '
|
|
|
|
<br><span class="label label-danger">
|
|
|
|
- '.tr('sconto _TOT_ _TYPE_', [
|
|
|
|
'_TOT_' => Translator::numberToLocale($r['sconto_unitario']),
|
2019-04-13 00:09:48 +02:00
|
|
|
'_TYPE_' => ($r['tipo_sconto'] == 'PRC' ? '%' : currency()),
|
2018-08-30 18:20:30 +02:00
|
|
|
]).'
|
|
|
|
</span>';
|
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
|
|
|
</td>';
|
|
|
|
|
|
|
|
echo '
|
|
|
|
<td class="text-right">
|
2019-04-13 05:52:04 +02:00
|
|
|
'.moneyFormat($r['iva']).'
|
2018-08-30 18:20:30 +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'])).'
|
2018-08-30 18:20:30 +02:00
|
|
|
</td>';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($is_add)) {
|
|
|
|
echo '
|
|
|
|
<td>
|
|
|
|
|
2019-07-29 13:16:55 +02:00
|
|
|
<button type="button" class="btn btn-warning btn-xs" data-title="'.tr('Modifica spesa').'" onclick="launch_modal(\'Modifica spesa\', \''.$plugin->fileurl('add_righe.php').'?id_plugin='.$id_plugin.'&id_record='.$id_record.'&idriga='.$r['id'].'\', \'#bs-popup2\');">
|
2018-08-30 18:20:30 +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 spesa?').'\')){ elimina_riga( \''.$r['id'].'\' ); }">
|
|
|
|
<i class="fa fa-trash"></i>
|
|
|
|
</button>
|
|
|
|
</td>';
|
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
|
|
|
</tr>';
|
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
|
|
|
</table>';
|
2018-08-31 09:41:43 +02:00
|
|
|
} else {
|
|
|
|
echo '
|
|
|
|
<p>'.tr('Nessuna riga caricata').'.</p>';
|
2018-08-30 18:20:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
function elimina_riga(id){
|
|
|
|
$.post(globals.rootdir + "/actions.php", { op: "delriga", idriga: id, id_plugin: '.$id_plugin.'}, function(data, result){
|
|
|
|
if(result == "success"){
|
|
|
|
refreshRighe('.$id_record.');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
</script>';
|