mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-02 17:07:01 +01:00
Gestione modifica righe in row-list documenti
This commit is contained in:
parent
41c2d6e8a0
commit
15793d8161
@ -1133,6 +1133,10 @@ div.tip {
|
||||
background-color: #ff851b !important;
|
||||
}
|
||||
|
||||
.row-list .form-group {
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Component: Sidebar Mini
|
||||
|
@ -568,5 +568,103 @@ switch (post('op')) {
|
||||
]);
|
||||
flash()->info($message);
|
||||
|
||||
break;
|
||||
|
||||
case 'add_articolo':
|
||||
$id_articolo = post('id_articolo');
|
||||
$barcode = post('barcode');
|
||||
$dir = 'entrata';
|
||||
|
||||
if (!empty($barcode)) {
|
||||
$id_articolo = $dbo->selectOne('mg_articoli', 'id', ['deleted_at' => null, 'barcode' => $barcode])['id'];
|
||||
}
|
||||
|
||||
if (!empty($id_articolo)) {
|
||||
$permetti_movimenti_sotto_zero = setting('Permetti selezione articoli con quantità minore o uguale a zero in Documenti di Vendita');
|
||||
$qta_articolo = $dbo->selectOne('mg_articoli', 'qta', ['id' => $id_articolo])['qta'];
|
||||
|
||||
$originale = ArticoloOriginale::find($id_articolo);
|
||||
|
||||
if ($qta_articolo <= 0 && !$permetti_movimenti_sotto_zero && !$originale->servizio && $dir == 'entrata') {
|
||||
$response['error'] = tr('Quantità a magazzino non sufficiente');
|
||||
echo json_encode($response);
|
||||
} else {
|
||||
$articolo = Articolo::build($contratto, $originale);
|
||||
$qta = 1;
|
||||
|
||||
$articolo->descrizione = $originale->descrizione;
|
||||
$articolo->um = $originale->um;
|
||||
$articolo->qta = 1;
|
||||
$articolo->costo_unitario = $originale->prezzo_acquisto;
|
||||
|
||||
$id_iva = $originale->idiva_vendita ?: setting('Iva predefinita');
|
||||
$id_anagrafica = $contratto->idanagrafica;
|
||||
$prezzi_ivati = setting('Utilizza prezzi di vendita comprensivi di IVA');
|
||||
|
||||
// CALCOLO PREZZO UNITARIO
|
||||
$prezzo_unitario = 0;
|
||||
$sconto = 0;
|
||||
// Prezzi netti clienti / listino fornitore
|
||||
$prezzi = $dbo->fetchArray('SELECT minimo, massimo, sconto_percentuale, '.($prezzi_ivati ? 'prezzo_unitario_ivato' : 'prezzo_unitario').' AS prezzo_unitario
|
||||
FROM mg_prezzi_articoli
|
||||
WHERE id_articolo = '.prepare($id_articolo).' AND dir = '.prepare($dir).' AND id_anagrafica = '.prepare($id_anagrafica));
|
||||
|
||||
if ($prezzi) {
|
||||
foreach ($prezzi as $prezzo) {
|
||||
if ($qta >= $prezzo['minimo'] && $qta <= $prezzo['massimo']) {
|
||||
$prezzo_unitario = $prezzo['prezzo_unitario'];
|
||||
$sconto = $prezzo['sconto_percentuale'];
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($prezzo['minimo'] == null && $prezzo['massimo'] == null && $prezzo['prezzo_unitario'] != null) {
|
||||
$prezzo_unitario = $prezzo['prezzo_unitario'];
|
||||
$sconto = $prezzo['sconto_percentuale'];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (empty($prezzo_unitario)) {
|
||||
// Prezzi listini clienti
|
||||
$listino = $dbo->fetchOne('SELECT sconto_percentuale AS sconto_percentuale_listino, '.($prezzi_ivati ? 'prezzo_unitario_ivato' : 'prezzo_unitario').' AS prezzo_unitario_listino
|
||||
FROM mg_listini
|
||||
LEFT JOIN mg_listini_articoli ON mg_listini.id=mg_listini_articoli.id_listino
|
||||
LEFT JOIN an_anagrafiche ON mg_listini.id=an_anagrafiche.id_listino
|
||||
WHERE mg_listini.data_attivazione<=NOW() AND mg_listini_articoli.data_scadenza>=NOW() AND mg_listini.attivo=1 AND id_articolo = '.prepare($id_articolo).' AND dir = '.prepare($dir).' AND idanagrafica = '.prepare($id_anagrafica));
|
||||
|
||||
if ($listino) {
|
||||
$prezzo_unitario = $listino['prezzo_unitario_listino'];
|
||||
$sconto = $listino['sconto_percentuale_listino'];
|
||||
}
|
||||
}
|
||||
$prezzo_unitario = $prezzo_unitario ?: ($prezzi_ivati ? $originale->prezzo_vendita_ivato : $originale->prezzo_vendita);
|
||||
|
||||
$articolo->setPrezzoUnitario($prezzo_unitario, $id_iva);
|
||||
$articolo->setSconto($sconto, 'PRC');
|
||||
$articolo->save();
|
||||
|
||||
|
||||
flash()->info(tr('Nuovo articolo aggiunto!'));
|
||||
}
|
||||
} else {
|
||||
$response['error'] = tr('Nessun articolo corrispondente a magazzino');
|
||||
echo json_encode($response);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'update_inline':
|
||||
$id_riga = post('riga_id');
|
||||
$riga = $riga ?: Riga::find($id_riga);
|
||||
$riga = $riga ?: Articolo::find($id_riga);
|
||||
|
||||
if (!empty($riga)) {
|
||||
$riga->qta = post('qta');
|
||||
$riga->setSconto(post('sconto'), post('tipo_sconto'));
|
||||
$riga->save();
|
||||
|
||||
flash()->info(tr('Quantità aggiornata!'));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -21,9 +21,10 @@ include_once __DIR__.'/init.php';
|
||||
|
||||
$block_edit = $record['is_completato'];
|
||||
$righe = $contratto->getRighe();
|
||||
$colspan = ($block_edit ? '5' : '6');
|
||||
|
||||
echo '
|
||||
<div class="table-responsive">
|
||||
<div class="table-responsive row-list">
|
||||
<table class="table table-striped table-hover table-condensed table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
@ -34,13 +35,16 @@ echo '
|
||||
}
|
||||
echo '
|
||||
</th>
|
||||
<th width="35" class="text-center" >'.tr('#').'</th>
|
||||
<th width="35" class="text-center">'.tr('#').'</th>
|
||||
<th>'.tr('Descrizione').'</th>
|
||||
<th class="text-center tip" width="150" title="'.tr('da evadere').' / '.tr('totale').'">'.tr('Q.tà').' <i class="fa fa-question-circle-o"></i></th>
|
||||
<th class="text-center" width="150">'.tr('Prezzo unitario').'</th>
|
||||
<th class="text-center" width="150">'.tr('Iva unitaria').'</th>
|
||||
<th class="text-center" width="150">'.tr('Importo').'</th>
|
||||
<th width="100"></th>
|
||||
<th class="text-center tip" width="150">'.tr('Q.tà').'</th>
|
||||
<th class="text-center" width="140">'.tr('Prezzo unitario').'</th>';
|
||||
if (!$block_edit) {
|
||||
echo '<th class="text-center" width="150">'.tr('Sconto unitario').'</th>';
|
||||
}
|
||||
echo '
|
||||
<th class="text-center" width="140">'.tr('Importo').'</th>
|
||||
<th width="80"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@ -101,16 +105,25 @@ foreach ($righe as $riga) {
|
||||
<td></td>
|
||||
<td></td>';
|
||||
} else {
|
||||
// Quantità e unità di misura
|
||||
echo '
|
||||
// Quantità e unità di misura
|
||||
$progress_perc = $riga->qta_evasa * 100 / $riga->qta;
|
||||
echo '
|
||||
<td class="text-center">
|
||||
'.numberFormat($riga->qta_rimanente, 'qta').' / '.numberFormat($riga->qta, 'qta').' '.$riga->um.'
|
||||
{[ "type": "number", "name": "qta_'.$riga->id.'", "value": "'.$riga->qta.'", "min-value": "0", "onchange": "aggiornaInline($(this).closest(\'tr\').data(\'id\'))", "icon-after": "<span class=\'tip\' title=\''.tr('Quantità evasa: _QTA_', ['_QTA_' => numberFormat($riga->qta_evasa, 'qta')]).'\'>'.($riga->um ?: ' ').'</span>", "disabled": "'.($riga->isSconto() ? 1 : 0).'", "disabled": "'.$block_edit.'" ]}
|
||||
<div class="progress" style="height:4px;">
|
||||
<div class="progress-bar progress-bar-primary" style="width:'.$progress_perc.'%"></div>
|
||||
</div>
|
||||
</td>';
|
||||
|
||||
// Prezzi unitari
|
||||
echo '
|
||||
<td class="text-right">
|
||||
'.moneyFormat($riga->prezzo_unitario_corrente);
|
||||
<td class="text-right">';
|
||||
// Provvigione riga
|
||||
if (abs($riga->provvigione_unitaria) > 0) {
|
||||
$text = provvigioneInfo($riga);
|
||||
echo '<span class="pull-left text-info" title="'.$text.'"><i class="fa fa-handshake-o"></i></span>';
|
||||
}
|
||||
echo moneyFormat($riga->prezzo_unitario_corrente);
|
||||
|
||||
if ($dir == 'entrata' && $riga->costo_unitario != 0) {
|
||||
echo '
|
||||
@ -128,27 +141,24 @@ foreach ($righe as $riga) {
|
||||
|
||||
echo '
|
||||
</td>';
|
||||
|
||||
// Iva
|
||||
echo '
|
||||
<td class="text-right">
|
||||
'.moneyFormat($riga->iva_unitaria_scontata).'
|
||||
<br><small class="'.(($riga->aliquota->deleted_at) ? 'text-red' : '').' text-muted">'.$riga->aliquota->descrizione.(($riga->aliquota->esente) ? ' ('.$riga->aliquota->codice_natura_fe.')' : null).'</small>
|
||||
|
||||
// Sconto unitario
|
||||
if (!$block_edit) {
|
||||
echo '
|
||||
<td class="text-center">
|
||||
{[ "type": "number", "name": "sconto_'.$riga->id.'", "value": "'.($riga->sconto_percentuale ?: $riga->sconto_unitario_corrente).'", "min-value": "0", "onchange": "aggiornaInline($(this).closest(\'tr\').data(\'id\'))", "icon-after": "choice|untprc|'.$riga->tipo_sconto.'" ]}
|
||||
</td>';
|
||||
}
|
||||
|
||||
// Importo
|
||||
echo '
|
||||
<td class="text-right">
|
||||
'.moneyFormat($riga->importo);
|
||||
'.moneyFormat($riga->importo);
|
||||
|
||||
//provvigione riga
|
||||
if (abs($riga->provvigione_unitaria) > 0) {
|
||||
$text = provvigioneInfo($riga);
|
||||
|
||||
// Iva
|
||||
echo '
|
||||
<br><small class="label label-info">'.$text.'</small>';
|
||||
}
|
||||
echo '</td>';
|
||||
<br><small class="'.(($riga->aliquota->deleted_at) ? 'text-red' : '').' text-muted">'.$riga->aliquota->descrizione.(($riga->aliquota->esente) ? ' ('.$riga->aliquota->codice_natura_fe.')' : null).'</small>
|
||||
</td>';
|
||||
}
|
||||
|
||||
// Possibilità di rimuovere una riga solo se il preventivo non è stato pagato
|
||||
@ -192,7 +202,7 @@ $netto_a_pagare = $contratto->netto;
|
||||
// Totale totale imponibile
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="6" class="text-right">
|
||||
<td colspan="'.$colspan.'" class="text-right">
|
||||
<b>'.tr('Imponibile', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@ -205,7 +215,7 @@ echo '
|
||||
if (!empty($sconto)) {
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="6" class="text-right">
|
||||
<td colspan="'.$colspan.'" class="text-right">
|
||||
<b><span class="tip" title="'.tr('Un importo positivo indica uno sconto, mentre uno negativo indica una maggiorazione').'"> <i class="fa fa-question-circle-o"></i> '.tr('Sconto/maggiorazione', [], ['upper' => true]).':</span></b>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@ -217,7 +227,7 @@ if (!empty($sconto)) {
|
||||
// Totale totale imponibile
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="6" class="text-right">
|
||||
<td colspan="'.$colspan.'" class="text-right">
|
||||
<b>'.tr('Totale imponibile', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@ -230,7 +240,7 @@ if (!empty($sconto)) {
|
||||
// Totale iva
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="6" class="text-right">
|
||||
<td colspan="'.$colspan.'" class="text-right">
|
||||
<b>'.tr('Iva', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@ -242,7 +252,7 @@ echo '
|
||||
// Totale contratto
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="6" class="text-right">
|
||||
<td colspan="'.$colspan.'" class="text-right">
|
||||
<b>'.tr('Totale', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@ -255,7 +265,7 @@ echo '
|
||||
if (!empty($sconto_finale)) {
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="6" class="text-right">
|
||||
<td colspan="'.$colspan.'" class="text-right">
|
||||
<b>'.tr('Sconto in fattura', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@ -269,7 +279,7 @@ if (!empty($sconto_finale)) {
|
||||
if ($totale != $netto_a_pagare) {
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="6" class="text-right">
|
||||
<td colspan="'.$colspan.'" class="text-right">
|
||||
<b>'.tr('Netto a pagare', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@ -283,7 +293,7 @@ if ($totale != $netto_a_pagare) {
|
||||
if(!empty($contratto->provvigione)) {
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="6" class="text-right">
|
||||
<td colspan="'.$colspan.'" class="text-right">
|
||||
'.tr('Provvigioni', [], ['upper' => false]).':
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@ -294,7 +304,7 @@ if(!empty($contratto->provvigione)) {
|
||||
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="6" class="text-right">
|
||||
<td colspan="'.$colspan.'" class="text-right">
|
||||
'.tr('Netto da provvigioni', [], ['upper' => false]).':
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@ -455,4 +465,37 @@ $("#check_all").click(function(){
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$(".tipo_icon_after").on("change", function() {
|
||||
aggiornaInline($(this).closest("tr").data("id"));
|
||||
});
|
||||
|
||||
function aggiornaInline(id) {
|
||||
content_was_modified = false;
|
||||
var qta = input("qta_"+ id).get();
|
||||
var sconto = input("sconto_"+ id).get();
|
||||
var tipo_sconto = input("tipo_sconto_"+ id).get();
|
||||
|
||||
$.ajax({
|
||||
url: globals.rootdir + "/actions.php",
|
||||
type: "POST",
|
||||
data: {
|
||||
id_module: globals.id_module,
|
||||
id_record: globals.id_record,
|
||||
op: "update_inline",
|
||||
riga_id: id,
|
||||
qta: qta,
|
||||
sconto: sconto,
|
||||
tipo_sconto: tipo_sconto,
|
||||
},
|
||||
success: function (response) {
|
||||
caricaRighe(id);
|
||||
renderMessages();
|
||||
},
|
||||
error: function() {
|
||||
caricaRighe(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
init();
|
||||
</script>';
|
||||
|
@ -55,8 +55,8 @@ switch (filter('op')) {
|
||||
$ddt->save();
|
||||
|
||||
flash()->info(tr('Aggiunto ddt in _TYPE_ numero _NUM_!', [
|
||||
'_TYPE_' => ($dir == 'entrata' ? 'uscita': 'entrata'),
|
||||
'_NUM_' => ($dir == 'uscita' ? $ddt->numero: $ddt->numero_esterno)
|
||||
'_TYPE_' => $dir,
|
||||
'_NUM_' => $ddt->numero,
|
||||
]));
|
||||
|
||||
break;
|
||||
@ -531,7 +531,7 @@ switch (filter('op')) {
|
||||
// Duplica ddt
|
||||
case 'copy':
|
||||
$new = $ddt->replicate();
|
||||
$new->numero = DDT::getNextNumero($new->data, $dir, $id_segment);
|
||||
$new->numero = DDT::getNextNumero($new->data, $dir);
|
||||
$new->numero_esterno = DDT::getNextNumeroSecondario($new->data, $dir, $new->id_segment);
|
||||
|
||||
$stato = Stato::where('descrizione', '=', 'Bozza')->first();
|
||||
@ -556,6 +556,104 @@ switch (filter('op')) {
|
||||
|
||||
flash()->info(tr('DDT duplicato correttamente!'));
|
||||
|
||||
break;
|
||||
|
||||
case 'add_articolo':
|
||||
$id_articolo = post('id_articolo');
|
||||
$barcode = post('barcode');
|
||||
$dir = 'entrata';
|
||||
|
||||
if (!empty($barcode)) {
|
||||
$id_articolo = $dbo->selectOne('mg_articoli', 'id', ['deleted_at' => null, 'barcode' => $barcode])['id'];
|
||||
}
|
||||
|
||||
if (!empty($id_articolo)) {
|
||||
$permetti_movimenti_sotto_zero = setting('Permetti selezione articoli con quantità minore o uguale a zero in Documenti di Vendita');
|
||||
$qta_articolo = $dbo->selectOne('mg_articoli', 'qta', ['id' => $id_articolo])['qta'];
|
||||
|
||||
$originale = ArticoloOriginale::find($id_articolo);
|
||||
|
||||
if ($qta_articolo <= 0 && !$permetti_movimenti_sotto_zero && !$originale->servizio && $dir == 'entrata') {
|
||||
$response['error'] = tr('Quantità a magazzino non sufficiente');
|
||||
echo json_encode($response);
|
||||
} else {
|
||||
$articolo = Articolo::build($ddt, $originale);
|
||||
$qta = 1;
|
||||
|
||||
$articolo->descrizione = $originale->descrizione;
|
||||
$articolo->um = $originale->um;
|
||||
$articolo->qta = 1;
|
||||
$articolo->costo_unitario = $originale->prezzo_acquisto;
|
||||
|
||||
$id_iva = $originale->idiva_vendita ?: setting('Iva predefinita');
|
||||
$id_anagrafica = $ddt->idanagrafica;
|
||||
$prezzi_ivati = setting('Utilizza prezzi di vendita comprensivi di IVA');
|
||||
|
||||
// CALCOLO PREZZO UNITARIO
|
||||
$prezzo_unitario = 0;
|
||||
$sconto = 0;
|
||||
// Prezzi netti clienti / listino fornitore
|
||||
$prezzi = $dbo->fetchArray('SELECT minimo, massimo, sconto_percentuale, '.($prezzi_ivati ? 'prezzo_unitario_ivato' : 'prezzo_unitario').' AS prezzo_unitario
|
||||
FROM mg_prezzi_articoli
|
||||
WHERE id_articolo = '.prepare($id_articolo).' AND dir = '.prepare($dir).' AND id_anagrafica = '.prepare($id_anagrafica));
|
||||
|
||||
if ($prezzi) {
|
||||
foreach ($prezzi as $prezzo) {
|
||||
if ($qta >= $prezzo['minimo'] && $qta <= $prezzo['massimo']) {
|
||||
$prezzo_unitario = $prezzo['prezzo_unitario'];
|
||||
$sconto = $prezzo['sconto_percentuale'];
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($prezzo['minimo'] == null && $prezzo['massimo'] == null && $prezzo['prezzo_unitario'] != null) {
|
||||
$prezzo_unitario = $prezzo['prezzo_unitario'];
|
||||
$sconto = $prezzo['sconto_percentuale'];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (empty($prezzo_unitario)) {
|
||||
// Prezzi listini clienti
|
||||
$listino = $dbo->fetchOne('SELECT sconto_percentuale AS sconto_percentuale_listino, '.($prezzi_ivati ? 'prezzo_unitario_ivato' : 'prezzo_unitario').' AS prezzo_unitario_listino
|
||||
FROM mg_listini
|
||||
LEFT JOIN mg_listini_articoli ON mg_listini.id=mg_listini_articoli.id_listino
|
||||
LEFT JOIN an_anagrafiche ON mg_listini.id=an_anagrafiche.id_listino
|
||||
WHERE mg_listini.data_attivazione<=NOW() AND mg_listini_articoli.data_scadenza>=NOW() AND mg_listini.attivo=1 AND id_articolo = '.prepare($id_articolo).' AND dir = '.prepare($dir).' AND idanagrafica = '.prepare($id_anagrafica));
|
||||
|
||||
if ($listino) {
|
||||
$prezzo_unitario = $listino['prezzo_unitario_listino'];
|
||||
$sconto = $listino['sconto_percentuale_listino'];
|
||||
}
|
||||
}
|
||||
$prezzo_unitario = $prezzo_unitario ?: ($prezzi_ivati ? $originale->prezzo_vendita_ivato : $originale->prezzo_vendita);
|
||||
|
||||
$articolo->setPrezzoUnitario($prezzo_unitario, $id_iva);
|
||||
$articolo->setSconto($sconto, 'PRC');
|
||||
$articolo->save();
|
||||
|
||||
|
||||
flash()->info(tr('Nuovo articolo aggiunto!'));
|
||||
}
|
||||
} else {
|
||||
$response['error'] = tr('Nessun articolo corrispondente a magazzino');
|
||||
echo json_encode($response);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'update_inline':
|
||||
$id_riga = post('riga_id');
|
||||
$riga = $riga ?: Riga::find($id_riga);
|
||||
$riga = $riga ?: Articolo::find($id_riga);
|
||||
|
||||
if (!empty($riga)) {
|
||||
$riga->qta = post('qta');
|
||||
$riga->setSconto(post('sconto'), post('tipo_sconto'));
|
||||
$riga->save();
|
||||
|
||||
flash()->info(tr('Quantità aggiornata!'));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -21,9 +21,10 @@ include_once __DIR__.'/init.php';
|
||||
|
||||
$block_edit = $record['flag_completato'];
|
||||
$righe = $ddt->getRighe();
|
||||
$colspan = ($block_edit ? '5' : '6');
|
||||
|
||||
echo '
|
||||
<div class="table-responsive">
|
||||
<div class="table-responsive row-list">
|
||||
<table class="table table-striped table-hover table-condensed table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
@ -34,13 +35,16 @@ echo '
|
||||
}
|
||||
echo '
|
||||
</th>
|
||||
<th width="35" class="text-center" >'.tr('#').'</th>
|
||||
<th width="35" class="text-center">'.tr('#').'</th>
|
||||
<th>'.tr('Descrizione').'</th>
|
||||
<th class="text-center tip" width="150" title="'.tr('da evadere').' / '.tr('totale').'">'.tr('Q.tà').' <i class="fa fa-question-circle-o"></i></th>
|
||||
<th class="text-center" width="150">'.tr('Prezzo unitario').'</th>
|
||||
<th class="text-center" width="150">'.tr('Iva unitaria').'</th>
|
||||
<th class="text-center" width="150">'.tr('Importo').'</th>
|
||||
<th width="60"></th>
|
||||
<th class="text-center tip" width="150">'.tr('Q.tà').'</th>
|
||||
<th class="text-center" width="140">'.tr('Prezzo unitario').'</th>';
|
||||
if (!$block_edit) {
|
||||
echo '<th class="text-center" width="150">'.tr('Sconto unitario').'</th>';
|
||||
}
|
||||
echo '
|
||||
<th class="text-center" width="140">'.tr('Importo').'</th>
|
||||
<th width="80"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@ -65,164 +69,168 @@ foreach ($righe as $riga) {
|
||||
$mancanti = 0;
|
||||
}
|
||||
}
|
||||
|
||||
echo '
|
||||
<tr data-id="'.$riga->id.'" data-type="'.get_class($riga).'" '.$extra.'>
|
||||
<td class="text-center">';
|
||||
if (!$block_edit) {
|
||||
<tr data-id="'.$riga->id.'" data-type="'.get_class($riga).'">
|
||||
<td class="text-center">';
|
||||
if (!$block_edit) {
|
||||
echo '
|
||||
<input class="check" type="checkbox"/>';
|
||||
}
|
||||
echo '
|
||||
<input class="check" type="checkbox"/>';
|
||||
</td>
|
||||
|
||||
<td class="text-center">
|
||||
'.$num.'
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<small class="pull-right text-right text-muted">';
|
||||
|
||||
$numero_riferimenti_riga = $riga->referenceTargets()->count();
|
||||
$numero_riferimenti_collegati = $riga->referenceSources()->count();
|
||||
$riferimenti_presenti = $numero_riferimenti_riga;
|
||||
$testo_aggiuntivo = $riferimenti_presenti ? $numero_riferimenti_riga : '';
|
||||
echo '
|
||||
<button type="button" class="btn btn-xs btn-'.($riferimenti_presenti ? 'primary' : 'info').'" onclick="apriRiferimenti(this)">
|
||||
<i class="fa fa-chevron-right"></i> '.tr('Riferimenti').' '.$testo_aggiuntivo.'
|
||||
</button>';
|
||||
|
||||
// Aggiunta dei riferimenti ai documenti
|
||||
if ($riga->hasOriginalComponent()) {
|
||||
echo '
|
||||
<br>'.reference($riga->getOriginalComponent()->getDocument(), tr('Origine'));
|
||||
}
|
||||
echo '
|
||||
</small>';
|
||||
|
||||
if ($riga->isArticolo()) {
|
||||
echo Modules::link('Articoli', $riga->idarticolo, $riga->codice.' - '.$riga->descrizione);
|
||||
} else {
|
||||
echo nl2br($riga->descrizione);
|
||||
}
|
||||
|
||||
if ($riga->isArticolo() && !empty($riga->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>
|
||||
|
||||
<td class="text-center">
|
||||
'.$num.'
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<small class="pull-right text-right text-muted">';
|
||||
|
||||
$numero_riferimenti_riga = $riga->referenceTargets()->count();
|
||||
$numero_riferimenti_collegati = $riga->referenceSources()->count();
|
||||
$riferimenti_presenti = $numero_riferimenti_riga;
|
||||
$testo_aggiuntivo = $riferimenti_presenti ? $numero_riferimenti_riga : '';
|
||||
echo '
|
||||
<button type="button" class="btn btn-xs btn-'.($riferimenti_presenti ? 'primary' : 'info').'" onclick="apriRiferimenti(this)">
|
||||
<i class="fa fa-chevron-right"></i> '.tr('Riferimenti').' '.$testo_aggiuntivo.'
|
||||
</button>';
|
||||
|
||||
// Aggiunta dei riferimenti ai documenti
|
||||
if ($riga->hasOriginalComponent()) {
|
||||
echo '
|
||||
<br>'.reference($riga->getOriginalComponent()->getDocument(), tr('Origine'));
|
||||
}
|
||||
echo '
|
||||
</small>';
|
||||
|
||||
if ($riga->isArticolo()) {
|
||||
echo Modules::link('Articoli', $riga->idarticolo, $riga->codice.' - '.$riga->descrizione);
|
||||
} else {
|
||||
echo nl2br($riga->descrizione);
|
||||
}
|
||||
|
||||
if ($riga->isArticolo() && !empty($riga->abilita_serial)) {
|
||||
if (!empty($mancanti)) {
|
||||
echo '
|
||||
<br><b><small class="text-danger">'.tr('_NUM_ serial mancanti', [
|
||||
'_NUM_' => $mancanti,
|
||||
]).'</small></b>';
|
||||
}
|
||||
if (!empty($serials)) {
|
||||
|
||||
if ($riga->isArticolo() && !empty($riga->articolo->barcode)) {
|
||||
echo '
|
||||
<br>'.tr('SN').': '.implode(', ', $serials);
|
||||
<br><small><i class="fa fa-barcode"></i> '.$riga->articolo->barcode.'</small>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($riga->isArticolo() && !empty($riga->articolo->barcode)) {
|
||||
|
||||
if (!empty($riga->note)) {
|
||||
echo '
|
||||
<br><small class="label label-default">'.nl2br($riga->note).'</small>';
|
||||
}
|
||||
echo '
|
||||
<br><small><i class="fa fa-barcode"></i> '.$riga->articolo->barcode.'</small>';
|
||||
}
|
||||
|
||||
|
||||
if (!empty($riga->note)) {
|
||||
echo '
|
||||
<br><small class="label label-default">'.nl2br($riga->note).'</small>';
|
||||
}
|
||||
echo '
|
||||
</td>';
|
||||
</td>';
|
||||
|
||||
if ($riga->isDescrizione()) {
|
||||
echo '
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>';
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>';
|
||||
} else {
|
||||
// Quantità e unità di misura
|
||||
echo '
|
||||
<td class="text-center">
|
||||
'.numberFormat($riga->qta_rimanente, 'qta').' / '.numberFormat($riga->qta, 'qta').' '.$riga->um.'
|
||||
</td>';
|
||||
// Quantità e unità di misura
|
||||
$progress_perc = $riga->qta_evasa * 100 / $riga->qta;
|
||||
echo '
|
||||
<td class="text-center">
|
||||
{[ "type": "number", "name": "qta_'.$riga->id.'", "value": "'.$riga->qta.'", "min-value": "0", "onchange": "aggiornaInline($(this).closest(\'tr\').data(\'id\'))", "icon-after": "<span class=\'tip\' title=\''.tr('Quantità evasa: _QTA_', ['_QTA_' => numberFormat($riga->qta_evasa, 'qta')]).'\'>'.($riga->um ?: ' ').'</span>", "disabled": "'.($riga->isSconto() ? 1 : 0).'", "disabled": "'.$block_edit.'" ]}
|
||||
<div class="progress" style="height:4px;">
|
||||
<div class="progress-bar progress-bar-primary" style="width:'.$progress_perc.'%"></div>
|
||||
</div>
|
||||
</td>';
|
||||
|
||||
// Prezzi unitari
|
||||
echo '
|
||||
<td class="text-right">
|
||||
'.moneyFormat($riga->prezzo_unitario_corrente);
|
||||
<td class="text-right">';
|
||||
// Provvigione riga
|
||||
if (abs($riga->provvigione_unitaria) > 0) {
|
||||
$text = provvigioneInfo($riga);
|
||||
echo '<span class="pull-left text-info" title="'.$text.'"><i class="fa fa-handshake-o"></i></span>';
|
||||
}
|
||||
echo moneyFormat($riga->prezzo_unitario_corrente);
|
||||
|
||||
if ($dir == 'entrata' && $riga->costo_unitario != 0) {
|
||||
echo '
|
||||
<br><small class="text-muted">
|
||||
'.tr('Acquisto').': '.moneyFormat($riga->costo_unitario).'
|
||||
</small>';
|
||||
<br><small class="text-muted">
|
||||
'.tr('Acquisto').': '.moneyFormat($riga->costo_unitario).'
|
||||
</small>';
|
||||
}
|
||||
|
||||
if (abs($riga->sconto_unitario) > 0) {
|
||||
$text = discountInfo($riga);
|
||||
|
||||
echo '
|
||||
<br><small class="label label-danger">'.$text.'</small>';
|
||||
<br><small class="label label-danger">'.$text.'</small>';
|
||||
}
|
||||
|
||||
echo '
|
||||
</td>';
|
||||
|
||||
// Iva
|
||||
echo '
|
||||
<td class="text-right">
|
||||
'.moneyFormat($riga->iva_unitaria_scontata).'
|
||||
<br><small class="'.(($riga->aliquota->deleted_at) ? 'text-red' : '').' text-muted">'.$riga->aliquota->descrizione.(($riga->aliquota->esente) ? ' ('.$riga->aliquota->codice_natura_fe.')' : null).'</small>
|
||||
</td>';
|
||||
</td>';
|
||||
|
||||
// Sconto unitario
|
||||
if (!$block_edit) {
|
||||
echo '
|
||||
<td class="text-center">
|
||||
{[ "type": "number", "name": "sconto_'.$riga->id.'", "value": "'.($riga->sconto_percentuale ?: $riga->sconto_unitario_corrente).'", "min-value": "0", "onchange": "aggiornaInline($(this).closest(\'tr\').data(\'id\'))", "icon-after": "choice|untprc|'.$riga->tipo_sconto.'" ]}
|
||||
</td>';
|
||||
}
|
||||
|
||||
// Importo
|
||||
echo '
|
||||
<td class="text-right">
|
||||
'.moneyFormat($riga->importo);
|
||||
<td class="text-right">
|
||||
'.moneyFormat($riga->importo);
|
||||
|
||||
//provvigione riga
|
||||
if (abs($riga->provvigione_unitaria) > 0) {
|
||||
$text = provvigioneInfo($riga);
|
||||
|
||||
// Iva
|
||||
echo '
|
||||
<br><small class="label label-info">'.$text.'</small>';
|
||||
<br><small class="'.(($riga->aliquota->deleted_at) ? 'text-red' : '').' text-muted">'.$riga->aliquota->descrizione.(($riga->aliquota->esente) ? ' ('.$riga->aliquota->codice_natura_fe.')' : null).'</small>
|
||||
</td>';
|
||||
}
|
||||
|
||||
// Possibilità di rimuovere una riga solo se il ddt non è evaso
|
||||
echo '
|
||||
<td class="text-center">';
|
||||
|
||||
if ($record['flag_completato'] == 0) {
|
||||
echo '
|
||||
<div class="input-group-btn">';
|
||||
|
||||
if ($riga->isArticolo() && !empty($riga->abilita_serial)) {
|
||||
echo '
|
||||
<a class="btn btn-primary btn-xs" title="'.tr('Modifica seriali della riga').'" onclick="modificaSeriali(this)">
|
||||
<i class="fa fa-barcode"></i>
|
||||
</a>';
|
||||
}
|
||||
|
||||
echo ' </td>';
|
||||
}
|
||||
|
||||
// Possibilità di rimuovere una riga solo se il ddt non è evaso
|
||||
echo '
|
||||
<td class="text-center">';
|
||||
echo '
|
||||
<a class="btn btn-xs btn-warning" title="'.tr('Modifica riga').'" onclick="modificaRiga(this)">
|
||||
<i class="fa fa-edit"></i>
|
||||
</a>
|
||||
|
||||
if ($record['flag_completato'] == 0) {
|
||||
echo '
|
||||
<div class="input-group-btn">';
|
||||
<a class="btn btn-xs btn-danger" title="'.tr('Rimuovi riga').'" onclick="rimuoviRiga([$(this).closest(\'tr\').data(\'id\')])">
|
||||
<i class="fa fa-trash"></i>
|
||||
</a>
|
||||
|
||||
if ($riga->isArticolo() && !empty($riga->abilita_serial)) {
|
||||
echo '
|
||||
<a class="btn btn-primary btn-xs" title="'.tr('Modifica seriali della riga').'" onclick="modificaSeriali(this)">
|
||||
<i class="fa fa-barcode"></i>
|
||||
</a>';
|
||||
}
|
||||
<a class="btn btn-xs btn-default handle" title="'.tr('Modifica ordine delle righe').'">
|
||||
<i class="fa fa-sort"></i>
|
||||
</a>
|
||||
</div>';
|
||||
}
|
||||
|
||||
echo '
|
||||
<a class="btn btn-xs btn-warning" title="'.tr('Modifica riga').'" onclick="modificaRiga(this)">
|
||||
<i class="fa fa-edit"></i>
|
||||
</a>
|
||||
|
||||
<a class="btn btn-xs btn-danger" title="'.tr('Rimuovi riga').'" onclick="rimuoviRiga([$(this).closest(\'tr\').data(\'id\')])">
|
||||
<i class="fa fa-trash"></i>
|
||||
</a>
|
||||
|
||||
<a class="btn btn-xs btn-default handle" title="'.tr('Modifica ordine delle righe').'">
|
||||
<i class="fa fa-sort"></i>
|
||||
</a>
|
||||
</div>';
|
||||
}
|
||||
|
||||
echo '
|
||||
</td>
|
||||
</tr>';
|
||||
echo '
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
echo '
|
||||
@ -237,17 +245,15 @@ $totale = abs($ddt->totale);
|
||||
$sconto_finale = $ddt->getScontoFinale();
|
||||
$netto_a_pagare = $ddt->netto;
|
||||
|
||||
// IMPONIBILE
|
||||
// Totale totale imponibile
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="6" class="text-right">
|
||||
<td colspan="'.$colspan.'" class="text-right">
|
||||
<b>'.tr('Imponibile', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
|
||||
<td class="text-right">
|
||||
'.moneyFormat($imponibile, 2).'
|
||||
</td>
|
||||
|
||||
<td></td>
|
||||
</tr>';
|
||||
|
||||
@ -255,57 +261,49 @@ echo '
|
||||
if (!empty($sconto)) {
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="6" class="text-right">
|
||||
<td colspan="'.$colspan.'" class="text-right">
|
||||
<b><span class="tip" title="'.tr('Un importo positivo indica uno sconto, mentre uno negativo indica una maggiorazione').'"> <i class="fa fa-question-circle-o"></i> '.tr('Sconto/maggiorazione', [], ['upper' => true]).':</span></b>
|
||||
</td>
|
||||
|
||||
<td class="text-right">
|
||||
'.moneyFormat($sconto, 2).'
|
||||
</td>
|
||||
|
||||
<td></td>
|
||||
</tr>';
|
||||
|
||||
// TOTALE IMPONIBILE
|
||||
// Totale totale imponibile
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="6" class="text-right">
|
||||
<td colspan="'.$colspan.'" class="text-right">
|
||||
<b>'.tr('Totale imponibile', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
|
||||
<td class="text-right">
|
||||
'.moneyFormat($totale_imponibile, 2).'
|
||||
</td>
|
||||
|
||||
<td></td>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
// IVA
|
||||
// Totale iva
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="6" class="text-right">
|
||||
<b>'.tr('IVA', [], ['upper' => true]).':</b>
|
||||
<td colspan="'.$colspan.'" class="text-right">
|
||||
<b>'.tr('Iva', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
|
||||
<td class="text-right">
|
||||
'.moneyFormat($iva, 2).'
|
||||
</td>
|
||||
|
||||
<td></td>
|
||||
</tr>';
|
||||
|
||||
// TOTALE
|
||||
// Totale ddt
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="6" class="text-right">
|
||||
<td colspan="'.$colspan.'" class="text-right">
|
||||
<b>'.tr('Totale', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
|
||||
<td class="text-right">
|
||||
'.moneyFormat($totale, 2).'
|
||||
</td>
|
||||
|
||||
<td></td>
|
||||
</tr>';
|
||||
|
||||
@ -313,7 +311,7 @@ echo '
|
||||
if (!empty($sconto_finale)) {
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="6" class="text-right">
|
||||
<td colspan="'.$colspan.'" class="text-right">
|
||||
<b>'.tr('Sconto in fattura', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@ -327,7 +325,7 @@ if (!empty($sconto_finale)) {
|
||||
if ($totale != $netto_a_pagare) {
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="6" class="text-right">
|
||||
<td colspan="'.$colspan.'" class="text-right">
|
||||
<b>'.tr('Netto a pagare', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@ -341,8 +339,8 @@ if ($totale != $netto_a_pagare) {
|
||||
if(!empty($ddt->provvigione)) {
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="6" class="text-right">
|
||||
'.tr('Provvigioni').':
|
||||
<td colspan="'.$colspan.'" class="text-right">
|
||||
'.tr('Provvigioni', [], ['upper' => false]).':
|
||||
</td>
|
||||
<td class="text-right">
|
||||
'.moneyFormat($ddt->provvigione).'
|
||||
@ -350,17 +348,16 @@ if(!empty($ddt->provvigione)) {
|
||||
<td></td>
|
||||
</tr>';
|
||||
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="6" class="text-right">
|
||||
'.tr('Netto da provvigioni').':
|
||||
</td>
|
||||
<td class="text-right">
|
||||
'.moneyFormat($ddt->totale_imponibile - $ddt->provvigione).'
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>';
|
||||
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="'.$colspan.'" class="text-right">
|
||||
'.tr('Netto da provvigioni', [], ['upper' => false]).':
|
||||
</td>
|
||||
<td class="text-right">
|
||||
'.moneyFormat($ddt->totale_imponibile - $ddt->provvigione).'
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
echo '
|
||||
@ -530,4 +527,37 @@ $("#check_all").click(function(){
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$(".tipo_icon_after").on("change", function() {
|
||||
aggiornaInline($(this).closest("tr").data("id"));
|
||||
});
|
||||
|
||||
function aggiornaInline(id) {
|
||||
content_was_modified = false;
|
||||
var qta = input("qta_"+ id).get();
|
||||
var sconto = input("sconto_"+ id).get();
|
||||
var tipo_sconto = input("tipo_sconto_"+ id).get();
|
||||
|
||||
$.ajax({
|
||||
url: globals.rootdir + "/actions.php",
|
||||
type: "POST",
|
||||
data: {
|
||||
id_module: globals.id_module,
|
||||
id_record: globals.id_record,
|
||||
op: "update_inline",
|
||||
riga_id: id,
|
||||
qta: qta,
|
||||
sconto: sconto,
|
||||
tipo_sconto: tipo_sconto,
|
||||
},
|
||||
success: function (response) {
|
||||
caricaRighe(id);
|
||||
renderMessages();
|
||||
},
|
||||
error: function() {
|
||||
caricaRighe(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
init();
|
||||
</script>';
|
||||
|
@ -926,6 +926,97 @@ switch (post('op')) {
|
||||
|
||||
echo json_encode($has_serial);
|
||||
|
||||
break;
|
||||
|
||||
case 'add_articolo':
|
||||
$id_articolo = post('id_articolo');
|
||||
$barcode = post('barcode');
|
||||
$dir = 'entrata';
|
||||
|
||||
if (!empty($barcode)) {
|
||||
$id_articolo = $dbo->selectOne('mg_articoli', 'id', ['deleted_at' => null, 'barcode' => $barcode])['id'];
|
||||
}
|
||||
|
||||
if (!empty($id_articolo)) {
|
||||
$permetti_movimenti_sotto_zero = setting('Permetti selezione articoli con quantità minore o uguale a zero in Documenti di Vendita');
|
||||
$qta_articolo = $dbo->selectOne('mg_articoli', 'qta', ['id' => $id_articolo])['qta'];
|
||||
|
||||
$originale = ArticoloOriginale::find($id_articolo);
|
||||
|
||||
if ($qta_articolo <= 0 && !$permetti_movimenti_sotto_zero && !$originale->servizio && $dir == 'entrata') {
|
||||
$response['error'] = tr('Quantità a magazzino non sufficiente');
|
||||
echo json_encode($response);
|
||||
} else {
|
||||
$articolo = Articolo::build($fattura, $originale);
|
||||
$qta = 1;
|
||||
|
||||
$articolo->descrizione = $originale->descrizione;
|
||||
$articolo->um = $originale->um;
|
||||
$articolo->qta = 1;
|
||||
$articolo->costo_unitario = $originale->prezzo_acquisto;
|
||||
|
||||
$id_conto = ($fattura->direzione == 'entrata') ? setting('Conto predefinito fatture di vendita') : setting('Conto predefinito fatture di acquisto');
|
||||
if ($fattura->direzione == 'entrata' && !empty($originale->idconto_vendita)) {
|
||||
$id_conto = $originale->idconto_vendita;
|
||||
} elseif ($fattura->direzione == 'uscita' && !empty($originale->idconto_acquisto)) {
|
||||
$id_conto = $originale->idconto_acquisto;
|
||||
}
|
||||
$articolo->idconto = $id_conto;
|
||||
|
||||
$id_iva = $originale->idiva_vendita ?: setting('Iva predefinita');
|
||||
$id_anagrafica = $fattura->idanagrafica;
|
||||
$prezzi_ivati = setting('Utilizza prezzi di vendita comprensivi di IVA');
|
||||
|
||||
// CALCOLO PREZZO UNITARIO
|
||||
$prezzo_unitario = 0;
|
||||
$sconto = 0;
|
||||
// Prezzi netti clienti / listino fornitore
|
||||
$prezzi = $dbo->fetchArray('SELECT minimo, massimo, sconto_percentuale, '.($prezzi_ivati ? 'prezzo_unitario_ivato' : 'prezzo_unitario').' AS prezzo_unitario
|
||||
FROM mg_prezzi_articoli
|
||||
WHERE id_articolo = '.prepare($id_articolo).' AND dir = '.prepare($dir).' AND id_anagrafica = '.prepare($id_anagrafica));
|
||||
|
||||
if ($prezzi) {
|
||||
foreach ($prezzi as $prezzo) {
|
||||
if ($qta >= $prezzo['minimo'] && $qta <= $prezzo['massimo']) {
|
||||
$prezzo_unitario = $prezzo['prezzo_unitario'];
|
||||
$sconto = $prezzo['sconto_percentuale'];
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($prezzo['minimo'] == null && $prezzo['massimo'] == null && $prezzo['prezzo_unitario'] != null) {
|
||||
$prezzo_unitario = $prezzo['prezzo_unitario'];
|
||||
$sconto = $prezzo['sconto_percentuale'];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (empty($prezzo_unitario)) {
|
||||
// Prezzi listini clienti
|
||||
$listino = $dbo->fetchOne('SELECT sconto_percentuale AS sconto_percentuale_listino, '.($prezzi_ivati ? 'prezzo_unitario_ivato' : 'prezzo_unitario').' AS prezzo_unitario_listino
|
||||
FROM mg_listini
|
||||
LEFT JOIN mg_listini_articoli ON mg_listini.id=mg_listini_articoli.id_listino
|
||||
LEFT JOIN an_anagrafiche ON mg_listini.id=an_anagrafiche.id_listino
|
||||
WHERE mg_listini.data_attivazione<=NOW() AND mg_listini_articoli.data_scadenza>=NOW() AND mg_listini.attivo=1 AND id_articolo = '.prepare($id_articolo).' AND dir = '.prepare($dir).' AND idanagrafica = '.prepare($id_anagrafica));
|
||||
|
||||
if ($listino) {
|
||||
$prezzo_unitario = $listino['prezzo_unitario_listino'];
|
||||
$sconto = $listino['sconto_percentuale_listino'];
|
||||
}
|
||||
}
|
||||
$prezzo_unitario = $prezzo_unitario ?: ($prezzi_ivati ? $originale->prezzo_vendita_ivato : $originale->prezzo_vendita);
|
||||
|
||||
$articolo->setPrezzoUnitario($prezzo_unitario, $id_iva);
|
||||
$articolo->setSconto($sconto, 'PRC');
|
||||
$articolo->save();
|
||||
|
||||
|
||||
flash()->info(tr('Nuovo articolo aggiunto!'));
|
||||
}
|
||||
} else {
|
||||
$response['error'] = tr('Nessun articolo corrispondente a magazzino');
|
||||
echo json_encode($response);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -960,5 +960,103 @@ switch (post('op')) {
|
||||
$dbo->query('UPDATE `in_righe_interventi` SET `order` = '.prepare($i + 1).' WHERE id='.prepare($id_riga));
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'add_articolo':
|
||||
$id_articolo = post('id_articolo');
|
||||
$barcode = post('barcode');
|
||||
$dir = 'entrata';
|
||||
|
||||
if (!empty($barcode)) {
|
||||
$id_articolo = $dbo->selectOne('mg_articoli', 'id', ['deleted_at' => null, 'barcode' => $barcode])['id'];
|
||||
}
|
||||
|
||||
if (!empty($id_articolo)) {
|
||||
$permetti_movimenti_sotto_zero = setting('Permetti selezione articoli con quantità minore o uguale a zero in Documenti di Vendita');
|
||||
$qta_articolo = $dbo->selectOne('mg_articoli', 'qta', ['id' => $id_articolo])['qta'];
|
||||
|
||||
$originale = ArticoloOriginale::find($id_articolo);
|
||||
|
||||
if ($qta_articolo <= 0 && !$permetti_movimenti_sotto_zero && !$originale->servizio && $dir == 'entrata') {
|
||||
$response['error'] = tr('Quantità a magazzino non sufficiente');
|
||||
echo json_encode($response);
|
||||
} else {
|
||||
$articolo = Articolo::build($intervento, $originale);
|
||||
$qta = 1;
|
||||
|
||||
$articolo->descrizione = $originale->descrizione;
|
||||
$articolo->um = $originale->um;
|
||||
$articolo->qta = 1;
|
||||
$articolo->costo_unitario = $originale->prezzo_acquisto;
|
||||
|
||||
$id_iva = $originale->idiva_vendita ?: setting('Iva predefinita');
|
||||
$id_anagrafica = $intervento->idanagrafica;
|
||||
$prezzi_ivati = setting('Utilizza prezzi di vendita comprensivi di IVA');
|
||||
|
||||
// CALCOLO PREZZO UNITARIO
|
||||
$prezzo_unitario = 0;
|
||||
$sconto = 0;
|
||||
// Prezzi netti clienti / listino fornitore
|
||||
$prezzi = $dbo->fetchArray('SELECT minimo, massimo, sconto_percentuale, '.($prezzi_ivati ? 'prezzo_unitario_ivato' : 'prezzo_unitario').' AS prezzo_unitario
|
||||
FROM mg_prezzi_articoli
|
||||
WHERE id_articolo = '.prepare($id_articolo).' AND dir = '.prepare($dir).' AND id_anagrafica = '.prepare($id_anagrafica));
|
||||
|
||||
if ($prezzi) {
|
||||
foreach ($prezzi as $prezzo) {
|
||||
if ($qta >= $prezzo['minimo'] && $qta <= $prezzo['massimo']) {
|
||||
$prezzo_unitario = $prezzo['prezzo_unitario'];
|
||||
$sconto = $prezzo['sconto_percentuale'];
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($prezzo['minimo'] == null && $prezzo['massimo'] == null && $prezzo['prezzo_unitario'] != null) {
|
||||
$prezzo_unitario = $prezzo['prezzo_unitario'];
|
||||
$sconto = $prezzo['sconto_percentuale'];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (empty($prezzo_unitario)) {
|
||||
// Prezzi listini clienti
|
||||
$listino = $dbo->fetchOne('SELECT sconto_percentuale AS sconto_percentuale_listino, '.($prezzi_ivati ? 'prezzo_unitario_ivato' : 'prezzo_unitario').' AS prezzo_unitario_listino
|
||||
FROM mg_listini
|
||||
LEFT JOIN mg_listini_articoli ON mg_listini.id=mg_listini_articoli.id_listino
|
||||
LEFT JOIN an_anagrafiche ON mg_listini.id=an_anagrafiche.id_listino
|
||||
WHERE mg_listini.data_attivazione<=NOW() AND mg_listini_articoli.data_scadenza>=NOW() AND mg_listini.attivo=1 AND id_articolo = '.prepare($id_articolo).' AND dir = '.prepare($dir).' AND idanagrafica = '.prepare($id_anagrafica));
|
||||
|
||||
if ($listino) {
|
||||
$prezzo_unitario = $listino['prezzo_unitario_listino'];
|
||||
$sconto = $listino['sconto_percentuale_listino'];
|
||||
}
|
||||
}
|
||||
$prezzo_unitario = $prezzo_unitario ?: ($prezzi_ivati ? $originale->prezzo_vendita_ivato : $originale->prezzo_vendita);
|
||||
|
||||
$articolo->setPrezzoUnitario($prezzo_unitario, $id_iva);
|
||||
$articolo->setSconto($sconto, 'PRC');
|
||||
$articolo->save();
|
||||
|
||||
|
||||
flash()->info(tr('Nuovo articolo aggiunto!'));
|
||||
}
|
||||
} else {
|
||||
$response['error'] = tr('Nessun articolo corrispondente a magazzino');
|
||||
echo json_encode($response);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'update_inline':
|
||||
$id_riga = post('riga_id');
|
||||
$riga = $riga ?: Riga::find($id_riga);
|
||||
$riga = $riga ?: Articolo::find($id_riga);
|
||||
|
||||
if (!empty($riga)) {
|
||||
$riga->qta = post('qta');
|
||||
$riga->setSconto(post('sconto'), post('tipo_sconto'));
|
||||
$riga->save();
|
||||
|
||||
flash()->info(tr('Quantità aggiornata!'));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -21,11 +21,12 @@ include_once __DIR__.'/init.php';
|
||||
|
||||
$block_edit = $record['flag_completato'];
|
||||
$righe = $intervento->getRighe();
|
||||
$colspan = ($block_edit ? '5' : '6');
|
||||
|
||||
$show_prezzi = Auth::user()['gruppo'] != 'Tecnici' || (Auth::user()['gruppo'] == 'Tecnici' && setting('Mostra i prezzi al tecnico'));
|
||||
|
||||
echo '
|
||||
<div class="table-responsive">
|
||||
<div class="table-responsive row-list">
|
||||
<table class="table table-striped table-hover table-condensed table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
@ -37,14 +38,17 @@ echo '
|
||||
echo '
|
||||
</th>
|
||||
<th>'.tr('Descrizione').'</th>
|
||||
<th class="text-center" width="80">'.tr('Q.tà').'</th>';
|
||||
<th class="text-center" width="150">'.tr('Q.tà').'</th>';
|
||||
|
||||
if ($show_prezzi) {
|
||||
echo '
|
||||
<th class="text-center" width="150">'.tr('Prezzo di acquisto').'</th>
|
||||
<th class="text-center" width="150">'.tr('Prezzo di vendita').'</th>
|
||||
<th class="text-center" width="150">'.tr('Iva unitaria').'</th>
|
||||
<th class="text-center" width="150">'.tr('Importo').'</th>';
|
||||
<th class="text-center" width="140">'.tr('Prezzo di acquisto').'</th>
|
||||
<th class="text-center" width="140">'.tr('Prezzo di vendita').'</th>';
|
||||
if (!$block_edit) {
|
||||
echo '<th class="text-center" width="150">'.tr('Sconto unitario').'</th>';
|
||||
}
|
||||
echo '
|
||||
<th class="text-center" width="140">'.tr('Importo').'</th>';
|
||||
}
|
||||
|
||||
if (!$record['flag_completato']) {
|
||||
@ -119,10 +123,10 @@ echo '
|
||||
echo '
|
||||
</td>';
|
||||
|
||||
// Quantità
|
||||
echo '
|
||||
<td class="text-right">
|
||||
'.Translator::numberToLocale($riga->qta, 'qta').' '.$riga->um.'
|
||||
// Quantità e unità di misura
|
||||
echo '
|
||||
<td class="text-center">
|
||||
{[ "type": "number", "name": "qta_'.$riga->id.'", "value": "'.$riga->qta.'", "min-value": "0", "onchange": "aggiornaInline($(this).closest(\'tr\').data(\'id\'))", "icon-after": "'.($riga->um ?: ' ').'", "disabled": "'.($riga->isSconto() ? 1 : 0).'", "disabled": "'.$block_edit.'" ]}
|
||||
</td>';
|
||||
|
||||
if ($show_prezzi) {
|
||||
@ -134,8 +138,13 @@ echo '
|
||||
|
||||
// Prezzo unitario
|
||||
echo '
|
||||
<td class="text-right">
|
||||
'.moneyFormat($riga->prezzo_unitario);
|
||||
<td class="text-right">';
|
||||
// Provvigione riga
|
||||
if (abs($riga->provvigione_unitaria) > 0) {
|
||||
$text = provvigioneInfo($riga);
|
||||
echo '<span class="pull-left text-info" title="'.$text.'"><i class="fa fa-handshake-o"></i></span>';
|
||||
}
|
||||
echo moneyFormat($riga->prezzo_unitario);
|
||||
|
||||
if (abs($riga->sconto_unitario) > 0) {
|
||||
$text = discountInfo($riga);
|
||||
@ -147,27 +156,23 @@ echo '
|
||||
echo '
|
||||
</td>';
|
||||
|
||||
// Sconto unitario
|
||||
if (!$block_edit) {
|
||||
echo '
|
||||
<td class="text-right">
|
||||
'.moneyFormat($riga->iva_unitaria_scontata).'
|
||||
<br><small class="'.(($riga->aliquota->deleted_at) ? 'text-red' : '').' text-muted">'.$riga->aliquota->descrizione.(($riga->aliquota->esente) ? ' ('.$riga->aliquota->codice_natura_fe.')' : null).'</small>
|
||||
<td class="text-center">
|
||||
{[ "type": "number", "name": "sconto_'.$riga->id.'", "value": "'.($riga->sconto_percentuale ?: $riga->sconto_unitario_corrente).'", "min-value": "0", "onchange": "aggiornaInline($(this).closest(\'tr\').data(\'id\'))", "icon-after": "choice|untprc|'.$riga->tipo_sconto.'" ]}
|
||||
</td>';
|
||||
}
|
||||
|
||||
// Prezzo di vendita
|
||||
echo '
|
||||
<td class="text-right">
|
||||
'.moneyFormat($riga->importo);
|
||||
'.moneyFormat($riga->importo);
|
||||
|
||||
|
||||
//provvigione riga
|
||||
if (abs($riga->provvigione_unitaria) > 0) {
|
||||
$text = provvigioneInfo($riga);
|
||||
|
||||
// Iva
|
||||
echo '
|
||||
<br><small class="label label-info">'.$text.'</small>';
|
||||
}
|
||||
|
||||
echo '</td>';
|
||||
<br><small class="'.(($riga->aliquota->deleted_at) ? 'text-red' : '').' text-muted">'.$riga->aliquota->descrizione.(($riga->aliquota->esente) ? ' ('.$riga->aliquota->codice_natura_fe.')' : null).'</small>
|
||||
</td>';
|
||||
}
|
||||
|
||||
// Pulsante per riportare nel magazzino centrale.
|
||||
@ -213,7 +218,7 @@ echo '
|
||||
// IMPONIBILE
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="'.((!$record['flag_completato']) ? 6 : 5).'" class="text-right">
|
||||
<td colspan="'.$colspan.'" class="text-right">
|
||||
<b>'.tr('Imponibile', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@ -226,7 +231,7 @@ echo '
|
||||
if (!empty($intervento->sconto)) {
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="'.((!$record['flag_completato']) ? 6 : 5).'" class="text-right">
|
||||
<td colspan="'.$colspan.'" class="text-right">
|
||||
<b><span class="tip" title="'.tr('Un importo positivo indica uno sconto, mentre uno negativo indica una maggiorazione').'"> <i class="fa fa-question-circle-o"></i> '.tr('Sconto/maggiorazione', [], ['upper' => true]).':</span></b>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@ -238,7 +243,7 @@ echo '
|
||||
// Totale imponibile scontato
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="'.((!$record['flag_completato']) ? 6 : 5).'" class="text-right">
|
||||
<td colspan="'.$colspan.'" class="text-right">
|
||||
<b>'.tr('Totale imponibile', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@ -252,7 +257,7 @@ echo '
|
||||
if(!empty($intervento->provvigione)) {
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="'.((!$record['flag_completato']) ? 6 : 5).'" class="text-right">
|
||||
<td colspan="'.$colspan.'" class="text-right">
|
||||
'.tr('Provvigioni').':
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@ -423,4 +428,37 @@ $("#check_all").click(function(){
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$(".tipo_icon_after").on("change", function() {
|
||||
aggiornaInline($(this).closest("tr").data("id"));
|
||||
});
|
||||
|
||||
function aggiornaInline(id) {
|
||||
content_was_modified = false;
|
||||
var qta = input("qta_"+ id).get();
|
||||
var sconto = input("sconto_"+ id).get();
|
||||
var tipo_sconto = input("tipo_sconto_"+ id).get();
|
||||
|
||||
$.ajax({
|
||||
url: globals.rootdir + "/actions.php",
|
||||
type: "POST",
|
||||
data: {
|
||||
id_module: globals.id_module,
|
||||
id_record: globals.id_record,
|
||||
op: "update_inline",
|
||||
riga_id: id,
|
||||
qta: qta,
|
||||
sconto: sconto,
|
||||
tipo_sconto: tipo_sconto,
|
||||
},
|
||||
success: function (response) {
|
||||
caricaRighe(id);
|
||||
renderMessages();
|
||||
},
|
||||
error: function() {
|
||||
caricaRighe(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
init();
|
||||
</script>';
|
||||
|
@ -606,5 +606,103 @@ switch (post('op')) {
|
||||
'_NUM_' => $ordine->numero,
|
||||
]));
|
||||
|
||||
break;
|
||||
|
||||
case 'add_articolo':
|
||||
$id_articolo = post('id_articolo');
|
||||
$barcode = post('barcode');
|
||||
$dir = 'entrata';
|
||||
|
||||
if (!empty($barcode)) {
|
||||
$id_articolo = $dbo->selectOne('mg_articoli', 'id', ['deleted_at' => null, 'barcode' => $barcode])['id'];
|
||||
}
|
||||
|
||||
if (!empty($id_articolo)) {
|
||||
$permetti_movimenti_sotto_zero = setting('Permetti selezione articoli con quantità minore o uguale a zero in Documenti di Vendita');
|
||||
$qta_articolo = $dbo->selectOne('mg_articoli', 'qta', ['id' => $id_articolo])['qta'];
|
||||
|
||||
$originale = ArticoloOriginale::find($id_articolo);
|
||||
|
||||
if ($qta_articolo <= 0 && !$permetti_movimenti_sotto_zero && !$originale->servizio && $dir == 'entrata') {
|
||||
$response['error'] = tr('Quantità a magazzino non sufficiente');
|
||||
echo json_encode($response);
|
||||
} else {
|
||||
$articolo = Articolo::build($ordine, $originale);
|
||||
$qta = 1;
|
||||
|
||||
$articolo->descrizione = $originale->descrizione;
|
||||
$articolo->um = $originale->um;
|
||||
$articolo->qta = 1;
|
||||
$articolo->costo_unitario = $originale->prezzo_acquisto;
|
||||
|
||||
$id_iva = $originale->idiva_vendita ?: setting('Iva predefinita');
|
||||
$id_anagrafica = $ordine->idanagrafica;
|
||||
$prezzi_ivati = setting('Utilizza prezzi di vendita comprensivi di IVA');
|
||||
|
||||
// CALCOLO PREZZO UNITARIO
|
||||
$prezzo_unitario = 0;
|
||||
$sconto = 0;
|
||||
// Prezzi netti clienti / listino fornitore
|
||||
$prezzi = $dbo->fetchArray('SELECT minimo, massimo, sconto_percentuale, '.($prezzi_ivati ? 'prezzo_unitario_ivato' : 'prezzo_unitario').' AS prezzo_unitario
|
||||
FROM mg_prezzi_articoli
|
||||
WHERE id_articolo = '.prepare($id_articolo).' AND dir = '.prepare($dir).' AND id_anagrafica = '.prepare($id_anagrafica));
|
||||
|
||||
if ($prezzi) {
|
||||
foreach ($prezzi as $prezzo) {
|
||||
if ($qta >= $prezzo['minimo'] && $qta <= $prezzo['massimo']) {
|
||||
$prezzo_unitario = $prezzo['prezzo_unitario'];
|
||||
$sconto = $prezzo['sconto_percentuale'];
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($prezzo['minimo'] == null && $prezzo['massimo'] == null && $prezzo['prezzo_unitario'] != null) {
|
||||
$prezzo_unitario = $prezzo['prezzo_unitario'];
|
||||
$sconto = $prezzo['sconto_percentuale'];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (empty($prezzo_unitario)) {
|
||||
// Prezzi listini clienti
|
||||
$listino = $dbo->fetchOne('SELECT sconto_percentuale AS sconto_percentuale_listino, '.($prezzi_ivati ? 'prezzo_unitario_ivato' : 'prezzo_unitario').' AS prezzo_unitario_listino
|
||||
FROM mg_listini
|
||||
LEFT JOIN mg_listini_articoli ON mg_listini.id=mg_listini_articoli.id_listino
|
||||
LEFT JOIN an_anagrafiche ON mg_listini.id=an_anagrafiche.id_listino
|
||||
WHERE mg_listini.data_attivazione<=NOW() AND mg_listini_articoli.data_scadenza>=NOW() AND mg_listini.attivo=1 AND id_articolo = '.prepare($id_articolo).' AND dir = '.prepare($dir).' AND idanagrafica = '.prepare($id_anagrafica));
|
||||
|
||||
if ($listino) {
|
||||
$prezzo_unitario = $listino['prezzo_unitario_listino'];
|
||||
$sconto = $listino['sconto_percentuale_listino'];
|
||||
}
|
||||
}
|
||||
$prezzo_unitario = $prezzo_unitario ?: ($prezzi_ivati ? $originale->prezzo_vendita_ivato : $originale->prezzo_vendita);
|
||||
|
||||
$articolo->setPrezzoUnitario($prezzo_unitario, $id_iva);
|
||||
$articolo->setSconto($sconto, 'PRC');
|
||||
$articolo->save();
|
||||
|
||||
|
||||
flash()->info(tr('Nuovo articolo aggiunto!'));
|
||||
}
|
||||
} else {
|
||||
$response['error'] = tr('Nessun articolo corrispondente a magazzino');
|
||||
echo json_encode($response);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'update_inline':
|
||||
$id_riga = post('riga_id');
|
||||
$riga = $riga ?: Riga::find($id_riga);
|
||||
$riga = $riga ?: Articolo::find($id_riga);
|
||||
|
||||
if (!empty($riga)) {
|
||||
$riga->qta = post('qta');
|
||||
$riga->setSconto(post('sconto'), post('tipo_sconto'));
|
||||
$riga->save();
|
||||
|
||||
flash()->info(tr('Quantità aggiornata!'));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -23,9 +23,10 @@ use Modules\Articoli\Articolo;
|
||||
|
||||
$block_edit = $record['flag_completato'];
|
||||
$righe = $ordine->getRighe();
|
||||
$colspan = ($block_edit ? '6' : '7');
|
||||
|
||||
echo '
|
||||
<div class="table-responsive">
|
||||
<div class="table-responsive row-list">
|
||||
<table class="table table-striped table-hover table-condensed table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
@ -38,15 +39,17 @@ echo '
|
||||
</th>
|
||||
<th width="35" class="text-center" >'.tr('#').'</th>
|
||||
<th>'.tr('Descrizione').'</th>
|
||||
<th width="120">'.tr('Prev. evasione').'</th>
|
||||
<th class="text-center tip" width="150" title="'.tr('da evadere').' / '.tr('totale').'">'.tr('Q.tà').' <i class="fa fa-question-circle-o"></i></th>
|
||||
<th class="text-center" width="150">'.tr('Prezzo unitario').'</th>
|
||||
<th class="text-center" width="150">'.tr('Iva unitaria').'</th>
|
||||
<th class="text-center" width="150">'.tr('Importo').'</th>
|
||||
<th width="60"> </th>
|
||||
<th width="105">'.tr('Prev. evasione').'</th>
|
||||
<th class="text-center tip" width="190">'.tr('Q.tà').'</th>
|
||||
<th class="text-center" width="140">'.tr('Prezzo unitario').'</th>';
|
||||
if (!$block_edit) {
|
||||
echo '<th class="text-center" width="150">'.tr('Sconto unitario').'</th>';
|
||||
}
|
||||
echo '
|
||||
<th class="text-center" width="140">'.tr('Importo').'</th>
|
||||
<th width="80"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody class="sortable" id="righe">';
|
||||
|
||||
// Righe documento
|
||||
@ -72,20 +75,20 @@ foreach ($righe as $riga) {
|
||||
}
|
||||
|
||||
echo '
|
||||
<tr data-id="'.$riga->id.'" data-type="'.get_class($riga).'" '.$extra.'>
|
||||
<td class="text-center">';
|
||||
if (!$block_edit) {
|
||||
<tr data-id="'.$riga->id.'" data-type="'.get_class($riga).'">
|
||||
<td class="text-center">';
|
||||
if (!$block_edit) {
|
||||
echo '
|
||||
<input class="check" type="checkbox"/>';
|
||||
}
|
||||
echo '
|
||||
<input class="check" type="checkbox"/>';
|
||||
}
|
||||
echo '
|
||||
</td>
|
||||
</td>
|
||||
|
||||
<td class="text-center">
|
||||
'.$num.'
|
||||
</td>
|
||||
<td class="text-center">
|
||||
'.$num.'
|
||||
</td>
|
||||
|
||||
<td>';
|
||||
<td>';
|
||||
|
||||
$numero_riferimenti_riga = $riga->referenceTargets()->count();
|
||||
$numero_riferimenti_collegati = $riga->referenceSources()->count();
|
||||
@ -100,7 +103,7 @@ foreach ($righe as $riga) {
|
||||
// Aggiunta dei riferimenti ai documenti
|
||||
if ($riga->hasOriginalComponent()) {
|
||||
echo '
|
||||
<small class="pull-right text-right text-muted">'.reference($riga->getOriginalComponent()->getDocument(), tr('Origine')).'</small>';
|
||||
<small class="pull-right text-right text-muted">'.reference($riga->getOriginalComponent()->getDocument(), tr('Origine')).'</small>';
|
||||
}
|
||||
|
||||
if ($riga->isArticolo()) {
|
||||
@ -111,11 +114,11 @@ foreach ($righe as $riga) {
|
||||
if( $id_module==Modules::get('Ordini fornitore')['id'] ){
|
||||
$codice_fornitore = $riga->articolo->dettaglioFornitore( $ordine->idanagrafica )->codice_fornitore;
|
||||
if( !empty($codice_fornitore) ){
|
||||
echo '
|
||||
<br>
|
||||
<small class="text-muted">'.tr('Codice fornitore: _COD_FOR_',[
|
||||
'_COD_FOR_' => $codice_fornitore,
|
||||
]).'</small>';
|
||||
echo '
|
||||
<br>
|
||||
<small class="text-muted">'.tr('Codice fornitore: _COD_FOR_',[
|
||||
'_COD_FOR_' => $codice_fornitore,
|
||||
]).'</small>';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -124,28 +127,28 @@ foreach ($righe as $riga) {
|
||||
|
||||
if ($riga->isArticolo() && !empty($riga->abilita_serial)) {
|
||||
if (!empty($mancanti)) {
|
||||
echo '
|
||||
<br><b><small class="text-danger">'.tr('_NUM_ serial mancanti', [
|
||||
'_NUM_' => $mancanti,
|
||||
]).'</small></b>';
|
||||
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 '
|
||||
<br>'.tr('SN').': '.implode(', ', $serials);
|
||||
}
|
||||
}
|
||||
|
||||
if ($riga->isArticolo() && !empty($riga->articolo->barcode)) {
|
||||
echo '
|
||||
<br><small><i class="fa fa-barcode"></i> '.$riga->articolo->barcode.'</small>';
|
||||
}
|
||||
|
||||
echo '
|
||||
<br><small><i class="fa fa-barcode"></i> '.$riga->articolo->barcode.'</small>';
|
||||
}
|
||||
|
||||
if (!empty($riga->note)) {
|
||||
echo '
|
||||
<br><small class="label label-default">'.nl2br($riga->note).'</small>';
|
||||
echo '
|
||||
<br><small class="label label-default">'.nl2br($riga->note).'</small>';
|
||||
}
|
||||
echo '
|
||||
</td>';
|
||||
</td>';
|
||||
|
||||
// Data prevista evasione
|
||||
$info_evasione = '';
|
||||
@ -191,89 +194,88 @@ foreach ($righe as $riga) {
|
||||
<td></td>
|
||||
<td></td>';
|
||||
} else {
|
||||
// Quantità e unità di misura
|
||||
echo '
|
||||
<td class="text-center">
|
||||
<i class="'.($riga->confermato ? 'fa fa-check text-success' : 'fa fa-clock-o text-warning').'"></i>
|
||||
'.numberFormat($riga->qta_rimanente, 'qta').' / '.numberFormat($riga->qta, 'qta').' '.$riga->um.'
|
||||
</td>';
|
||||
// Quantità e unità di misura
|
||||
$progress_perc = $riga->qta_evasa * 100 / $riga->qta;
|
||||
echo '
|
||||
<td class="text-center">
|
||||
{[ "type": "number", "name": "qta_'.$riga->id.'", "value": "'.$riga->qta.'", "min-value": "0", "onchange": "aggiornaInline($(this).closest(\'tr\').data(\'id\'))", "icon-before": "<i class=\''.($riga->confermato ? 'fa fa-check text-success' : 'fa fa-clock-o text-warning').'\'></i>", "icon-after": "<span class=\'tip\' title=\''.tr('Quantità evasa: _QTA_', ['_QTA_' => numberFormat($riga->qta_evasa, 'qta')]).'\'>'.($riga->um ?: ' ').'</span>", "disabled": "'.($riga->isSconto() ? 1 : 0).'", "disabled": "'.$block_edit.'" ]}
|
||||
<div class="progress" style="height:4px;">
|
||||
<div class="progress-bar progress-bar-primary" style="width:'.$progress_perc.'%"></div>
|
||||
</div>
|
||||
</td>';
|
||||
|
||||
// Prezzi unitari
|
||||
echo '
|
||||
<td class="text-right">
|
||||
'.moneyFormat($riga->prezzo_unitario_corrente);
|
||||
|
||||
if ($dir == 'entrata' && $riga->costo_unitario != 0) {
|
||||
echo '
|
||||
<br><small class="text-muted">
|
||||
'.tr('Acquisto').': '.moneyFormat($riga->costo_unitario).'
|
||||
</small>';
|
||||
}
|
||||
<td class="text-right">';
|
||||
// Provvigione riga
|
||||
if (abs($riga->provvigione_unitaria) > 0) {
|
||||
$text = provvigioneInfo($riga);
|
||||
echo '<span class="pull-left text-info" title="'.$text.'"><i class="fa fa-handshake-o"></i></span>';
|
||||
}
|
||||
echo moneyFormat($riga->prezzo_unitario_corrente);
|
||||
|
||||
if (abs($riga->sconto_unitario) > 0) {
|
||||
$text = discountInfo($riga);
|
||||
|
||||
echo '
|
||||
<br><small class="label label-danger">'.$text.'</small>';
|
||||
<br><small class="label label-danger">'.$text.'</small>';
|
||||
}
|
||||
|
||||
echo '
|
||||
</td>';
|
||||
</td>';
|
||||
|
||||
// Iva
|
||||
echo '
|
||||
<td class="text-right">
|
||||
'.moneyFormat($riga->iva_unitaria_scontata).'
|
||||
<br><small class="'.(($riga->aliquota->deleted_at) ? 'text-red' : '').' text-muted">'.$riga->aliquota->descrizione.(($riga->aliquota->esente) ? ' ('.$riga->aliquota->codice_natura_fe.')' : null).'</small>
|
||||
</td>';
|
||||
// Sconto unitario
|
||||
if (!$block_edit) {
|
||||
echo '
|
||||
<td class="text-center">
|
||||
{[ "type": "number", "name": "sconto_'.$riga->id.'", "value": "'.($riga->sconto_percentuale ?: $riga->sconto_unitario_corrente).'", "min-value": "0", "onchange": "aggiornaInline($(this).closest(\'tr\').data(\'id\'))", "icon-after": "choice|untprc|'.$riga->tipo_sconto.'" ]}
|
||||
</td>';
|
||||
}
|
||||
|
||||
// Importo
|
||||
echo '
|
||||
<td class="text-right">
|
||||
'.moneyFormat($riga->importo);
|
||||
//provvigione riga
|
||||
if (abs($riga->provvigione_unitaria) > 0) {
|
||||
$text = provvigioneInfo($riga);
|
||||
|
||||
echo '
|
||||
<br><small class="label label-info">'.$text.'</small>';
|
||||
}
|
||||
echo '</td>';
|
||||
<td class="text-right">
|
||||
'.moneyFormat($riga->importo);
|
||||
|
||||
// Iva
|
||||
echo '
|
||||
<br><small class="'.(($riga->aliquota->deleted_at) ? 'text-red' : '').' text-muted">'.$riga->aliquota->descrizione.(($riga->aliquota->esente) ? ' ('.$riga->aliquota->codice_natura_fe.')' : null).'</small>
|
||||
</td>';
|
||||
}
|
||||
|
||||
// Possibilità di rimuovere una riga solo se l'ordine non è evaso
|
||||
echo '
|
||||
<td class="text-center">';
|
||||
|
||||
if ($record['flag_completato'] == 0) {
|
||||
// Possibilità di rimuovere una riga solo se l'ordine non è evaso
|
||||
echo '
|
||||
<div class="input-group-btn">';
|
||||
<td class="text-center">';
|
||||
|
||||
if ($riga->isArticolo() && !empty($riga->abilita_serial)) {
|
||||
if ($record['flag_completato'] == 0) {
|
||||
echo '
|
||||
<a class="btn btn-primary btn-xs" title="'.tr('Modifica seriali della riga').'" onclick="modificaSeriali(this)">
|
||||
<i class="fa fa-barcode"></i>
|
||||
</a>';
|
||||
<div class="input-group-btn">';
|
||||
|
||||
if ($riga->isArticolo() && !empty($riga->abilita_serial)) {
|
||||
echo '
|
||||
<a class="btn btn-primary btn-xs" title="'.tr('Modifica seriali della riga').'" onclick="modificaSeriali(this)">
|
||||
<i class="fa fa-barcode"></i>
|
||||
</a>';
|
||||
}
|
||||
|
||||
echo '
|
||||
<a class="btn btn-xs btn-warning" title="'.tr('Modifica riga').'" onclick="modificaRiga(this)">
|
||||
<i class="fa fa-edit"></i>
|
||||
</a>
|
||||
|
||||
<a class="btn btn-xs btn-danger" title="'.tr('Rimuovi riga').'" onclick="rimuoviRiga([$(this).closest(\'tr\').data(\'id\')])">
|
||||
<i class="fa fa-trash"></i>
|
||||
</a>
|
||||
|
||||
<a class="btn btn-xs btn-default handle" title="'.tr('Modifica ordine delle righe').'">
|
||||
<i class="fa fa-sort"></i>
|
||||
</a>
|
||||
</div>';
|
||||
}
|
||||
|
||||
echo '
|
||||
<a class="btn btn-xs btn-warning" title="'.tr('Modifica riga').'" onclick="modificaRiga(this)">
|
||||
<i class="fa fa-edit"></i>
|
||||
</a>
|
||||
|
||||
<a class="btn btn-xs btn-danger" title="'.tr('Rimuovi riga').'" onclick="rimuoviRiga([$(this).closest(\'tr\').data(\'id\')])">
|
||||
<i class="fa fa-trash"></i>
|
||||
</a>
|
||||
|
||||
<a class="btn btn-xs btn-default handle" title="'.tr('Modifica ordine delle righe').'">
|
||||
<i class="fa fa-sort"></i>
|
||||
</a>
|
||||
</div>';
|
||||
}
|
||||
|
||||
echo '
|
||||
</td>
|
||||
</tr>';
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
echo '
|
||||
@ -288,10 +290,10 @@ $totale = abs($ordine->totale);
|
||||
$sconto_finale = $ordine->getScontoFinale();
|
||||
$netto_a_pagare = $ordine->netto;
|
||||
|
||||
// IMPONIBILE
|
||||
// Totale imponibile scontato
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="7" class="text-right">
|
||||
<td colspan="'.$colspan.'" class="text-right">
|
||||
<b>'.tr('Imponibile', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@ -304,7 +306,7 @@ echo '
|
||||
if (!empty($sconto)) {
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="7" class="text-right">
|
||||
<td colspan="'.$colspan.'" class="text-right">
|
||||
<b><span class="tip" title="'.tr('Un importo positivo indica uno sconto, mentre uno negativo indica una maggiorazione').'"> <i class="fa fa-question-circle-o"></i> '.tr('Sconto/maggiorazione', [], ['upper' => true]).':</span></b>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@ -313,10 +315,10 @@ if (!empty($sconto)) {
|
||||
<td></td>
|
||||
</tr>';
|
||||
|
||||
// TOTALE IMPONIBILE
|
||||
// Totale imponibile scontato
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="7" class="text-right">
|
||||
<td colspan="'.$colspan.'" class="text-right">
|
||||
<b>'.tr('Totale imponibile', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@ -326,10 +328,10 @@ if (!empty($sconto)) {
|
||||
</tr>';
|
||||
}
|
||||
|
||||
// IVA
|
||||
// Totale iva
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="7" class="text-right">
|
||||
<td colspan="'.$colspan.'" class="text-right">
|
||||
<b>'.tr('Iva', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@ -338,10 +340,10 @@ echo '
|
||||
<td></td>
|
||||
</tr>';
|
||||
|
||||
// TOTALE
|
||||
// Totale
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="7" class="text-right">
|
||||
<td colspan="'.$colspan.'" class="text-right">
|
||||
<b>'.tr('Totale', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@ -354,7 +356,7 @@ echo '
|
||||
if (!empty($sconto_finale)) {
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="7" class="text-right">
|
||||
<td colspan="'.$colspan.'" class="text-right">
|
||||
<b>'.tr('Sconto in fattura', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@ -368,7 +370,7 @@ if (!empty($sconto_finale)) {
|
||||
if ($totale != $netto_a_pagare) {
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="7" class="text-right">
|
||||
<td colspan="'.$colspan.'" class="text-right">
|
||||
<b>'.tr('Netto a pagare', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@ -382,7 +384,7 @@ if ($totale != $netto_a_pagare) {
|
||||
if(!empty($ordine->provvigione)) {
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="7" class="text-right">
|
||||
<td colspan="'.$colspan.'" class="text-right">
|
||||
'.tr('Provvigioni').':
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@ -391,9 +393,9 @@ if(!empty($ordine->provvigione)) {
|
||||
<td></td>
|
||||
</tr>';
|
||||
|
||||
echo '
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="7" class="text-right">
|
||||
<td colspan="'.$colspan.'" class="text-right">
|
||||
'.tr('Netto da provvigioni').':
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@ -419,7 +421,7 @@ if (!$block_edit && sizeof($righe) > 0) {
|
||||
}
|
||||
echo '
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
async function modificaRiga(button) {
|
||||
let riga = $(button).closest("tr");
|
||||
@ -520,7 +522,7 @@ function apriRiferimenti(button) {
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
sortable(".sortable", {
|
||||
sortable(".sortable", {
|
||||
axis: "y",
|
||||
handle: ".handle",
|
||||
cursor: "move",
|
||||
@ -570,4 +572,37 @@ $("#check_all").click(function(){
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$(".tipo_icon_after").on("change", function() {
|
||||
aggiornaInline($(this).closest("tr").data("id"));
|
||||
});
|
||||
|
||||
function aggiornaInline(id) {
|
||||
content_was_modified = false;
|
||||
var qta = input("qta_"+ id).get();
|
||||
var sconto = input("sconto_"+ id).get();
|
||||
var tipo_sconto = input("tipo_sconto_"+ id).get();
|
||||
|
||||
$.ajax({
|
||||
url: globals.rootdir + "/actions.php",
|
||||
type: "POST",
|
||||
data: {
|
||||
id_module: globals.id_module,
|
||||
id_record: globals.id_record,
|
||||
op: "update_inline",
|
||||
riga_id: id,
|
||||
qta: qta,
|
||||
sconto: sconto,
|
||||
tipo_sconto: tipo_sconto,
|
||||
},
|
||||
success: function (response) {
|
||||
caricaRighe(id);
|
||||
renderMessages();
|
||||
},
|
||||
error: function() {
|
||||
caricaRighe(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
init();
|
||||
</script>';
|
||||
|
@ -442,5 +442,103 @@ switch (post('op')) {
|
||||
$dbo->query('UPDATE `co_righe_preventivi` SET `order` = '.prepare($i + 1).' WHERE id='.prepare($id_riga));
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'add_articolo':
|
||||
$id_articolo = post('id_articolo');
|
||||
$barcode = post('barcode');
|
||||
$dir = 'entrata';
|
||||
|
||||
if (!empty($barcode)) {
|
||||
$id_articolo = $dbo->selectOne('mg_articoli', 'id', ['deleted_at' => null, 'barcode' => $barcode])['id'];
|
||||
}
|
||||
|
||||
if (!empty($id_articolo)) {
|
||||
$permetti_movimenti_sotto_zero = setting('Permetti selezione articoli con quantità minore o uguale a zero in Documenti di Vendita');
|
||||
$qta_articolo = $dbo->selectOne('mg_articoli', 'qta', ['id' => $id_articolo])['qta'];
|
||||
|
||||
$originale = ArticoloOriginale::find($id_articolo);
|
||||
|
||||
if ($qta_articolo <= 0 && !$permetti_movimenti_sotto_zero && !$originale->servizio && $dir == 'entrata') {
|
||||
$response['error'] = tr('Quantità a magazzino non sufficiente');
|
||||
echo json_encode($response);
|
||||
} else {
|
||||
$articolo = Articolo::build($preventivo, $originale);
|
||||
$qta = 1;
|
||||
|
||||
$articolo->descrizione = $originale->descrizione;
|
||||
$articolo->um = $originale->um;
|
||||
$articolo->qta = 1;
|
||||
$articolo->costo_unitario = $originale->prezzo_acquisto;
|
||||
|
||||
$id_iva = $originale->idiva_vendita ?: setting('Iva predefinita');
|
||||
$id_anagrafica = $preventivo->idanagrafica;
|
||||
$prezzi_ivati = setting('Utilizza prezzi di vendita comprensivi di IVA');
|
||||
|
||||
// CALCOLO PREZZO UNITARIO
|
||||
$prezzo_unitario = 0;
|
||||
$sconto = 0;
|
||||
// Prezzi netti clienti / listino fornitore
|
||||
$prezzi = $dbo->fetchArray('SELECT minimo, massimo, sconto_percentuale, '.($prezzi_ivati ? 'prezzo_unitario_ivato' : 'prezzo_unitario').' AS prezzo_unitario
|
||||
FROM mg_prezzi_articoli
|
||||
WHERE id_articolo = '.prepare($id_articolo).' AND dir = '.prepare($dir).' AND id_anagrafica = '.prepare($id_anagrafica));
|
||||
|
||||
if ($prezzi) {
|
||||
foreach ($prezzi as $prezzo) {
|
||||
if ($qta >= $prezzo['minimo'] && $qta <= $prezzo['massimo']) {
|
||||
$prezzo_unitario = $prezzo['prezzo_unitario'];
|
||||
$sconto = $prezzo['sconto_percentuale'];
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($prezzo['minimo'] == null && $prezzo['massimo'] == null && $prezzo['prezzo_unitario'] != null) {
|
||||
$prezzo_unitario = $prezzo['prezzo_unitario'];
|
||||
$sconto = $prezzo['sconto_percentuale'];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (empty($prezzo_unitario)) {
|
||||
// Prezzi listini clienti
|
||||
$listino = $dbo->fetchOne('SELECT sconto_percentuale AS sconto_percentuale_listino, '.($prezzi_ivati ? 'prezzo_unitario_ivato' : 'prezzo_unitario').' AS prezzo_unitario_listino
|
||||
FROM mg_listini
|
||||
LEFT JOIN mg_listini_articoli ON mg_listini.id=mg_listini_articoli.id_listino
|
||||
LEFT JOIN an_anagrafiche ON mg_listini.id=an_anagrafiche.id_listino
|
||||
WHERE mg_listini.data_attivazione<=NOW() AND mg_listini_articoli.data_scadenza>=NOW() AND mg_listini.attivo=1 AND id_articolo = '.prepare($id_articolo).' AND dir = '.prepare($dir).' AND idanagrafica = '.prepare($id_anagrafica));
|
||||
|
||||
if ($listino) {
|
||||
$prezzo_unitario = $listino['prezzo_unitario_listino'];
|
||||
$sconto = $listino['sconto_percentuale_listino'];
|
||||
}
|
||||
}
|
||||
$prezzo_unitario = $prezzo_unitario ?: ($prezzi_ivati ? $originale->prezzo_vendita_ivato : $originale->prezzo_vendita);
|
||||
|
||||
$articolo->setPrezzoUnitario($prezzo_unitario, $id_iva);
|
||||
$articolo->setSconto($sconto, 'PRC');
|
||||
$articolo->save();
|
||||
|
||||
|
||||
flash()->info(tr('Nuovo articolo aggiunto!'));
|
||||
}
|
||||
} else {
|
||||
$response['error'] = tr('Nessun articolo corrispondente a magazzino');
|
||||
echo json_encode($response);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'update_inline':
|
||||
$id_riga = post('riga_id');
|
||||
$riga = $riga ?: Riga::find($id_riga);
|
||||
$riga = $riga ?: Articolo::find($id_riga);
|
||||
|
||||
if (!empty($riga)) {
|
||||
$riga->qta = post('qta');
|
||||
$riga->setSconto(post('sconto'), post('tipo_sconto'));
|
||||
$riga->save();
|
||||
|
||||
flash()->info(tr('Quantità aggiornata!'));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -21,9 +21,10 @@ include_once __DIR__.'/init.php';
|
||||
|
||||
$block_edit = $record['is_completato'];
|
||||
$righe = $preventivo->getRighe();
|
||||
$colspan = ($block_edit ? '6' : '7');
|
||||
|
||||
echo '
|
||||
<div class="table-responsive">
|
||||
<div class="table-responsive row-list">
|
||||
<table class="table table-striped table-hover table-condensed table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
@ -36,12 +37,15 @@ echo '
|
||||
</th>
|
||||
<th width="35" class="text-center" >'.tr('#').'</th>
|
||||
<th>'.tr('Descrizione').'</th>
|
||||
<th width="120">'.tr('Prev. evasione').'</th>
|
||||
<th class="text-center tip" width="150" title="'.tr('da evadere').' / '.tr('totale').'">'.tr('Q.tà').' <i class="fa fa-question-circle-o"></i></th>
|
||||
<th class="text-center" width="150">'.tr('Prezzo unitario').'</th>
|
||||
<th class="text-center" width="150">'.tr('Iva unitaria').'</th>
|
||||
<th class="text-center" width="150">'.tr('Importo').'</th>
|
||||
<th width="100"></th>
|
||||
<th width="105">'.tr('Prev. evasione').'</th>
|
||||
<th class="text-center tip" width="190">'.tr('Q.tà').'</th>
|
||||
<th class="text-center" width="140">'.tr('Prezzo unitario').'</th>';
|
||||
if (!$block_edit) {
|
||||
echo '<th class="text-center" width="150">'.tr('Sconto unitario').'</th>';
|
||||
}
|
||||
echo '
|
||||
<th class="text-center" width="140">'.tr('Importo').'</th>
|
||||
<th width="80"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="sortable" id="righe">';
|
||||
@ -141,24 +145,25 @@ foreach ($righe as $riga) {
|
||||
<td></td>
|
||||
<td></td>';
|
||||
} else {
|
||||
// Quantità e unità di misura
|
||||
echo '
|
||||
// Quantità e unità di misura
|
||||
$progress_perc = $riga->qta_evasa * 100 / $riga->qta;
|
||||
echo '
|
||||
<td class="text-center">
|
||||
<i class="'.($riga->confermato ? 'fa fa-check text-success' : 'fa fa-clock-o text-warning').'"></i>
|
||||
'.numberFormat($riga->qta_rimanente, 'qta').' / '.numberFormat($riga->qta, 'qta').' '.$riga->um.'
|
||||
{[ "type": "number", "name": "qta_'.$riga->id.'", "value": "'.$riga->qta.'", "min-value": "0", "onchange": "aggiornaInline($(this).closest(\'tr\').data(\'id\'))", "icon-before": "<i class=\''.($riga->confermato ? 'fa fa-check text-success' : 'fa fa-clock-o text-warning').'\'></i>", "icon-after": "<span class=\'tip\' title=\''.tr('Quantità evasa: _QTA_', ['_QTA_' => numberFormat($riga->qta_evasa, 'qta')]).'\'>'.($riga->um ?: ' ').'</span>", "disabled": "'.($riga->isSconto() ? 1 : 0).'", "disabled": "'.$block_edit.'" ]}
|
||||
<div class="progress" style="height:4px;">
|
||||
<div class="progress-bar progress-bar-primary" style="width:'.$progress_perc.'%"></div>
|
||||
</div>
|
||||
</td>';
|
||||
|
||||
// Prezzi unitari
|
||||
echo '
|
||||
<td class="text-right">
|
||||
'.moneyFormat($riga->prezzo_unitario_corrente);
|
||||
|
||||
if ($dir == 'entrata' && $riga->costo_unitario != 0) {
|
||||
echo '
|
||||
<br><small class="text-muted">
|
||||
'.tr('Acquisto').': '.moneyFormat($riga->costo_unitario).'
|
||||
</small>';
|
||||
}
|
||||
<td class="text-right">';
|
||||
// Provvigione riga
|
||||
if (abs($riga->provvigione_unitaria) > 0) {
|
||||
$text = provvigioneInfo($riga);
|
||||
echo '<span class="pull-left text-info" title="'.$text.'"><i class="fa fa-handshake-o"></i></span>';
|
||||
}
|
||||
echo moneyFormat($riga->prezzo_unitario_corrente);
|
||||
|
||||
if (abs($riga->sconto_unitario) > 0) {
|
||||
$text = discountInfo($riga);
|
||||
@ -170,27 +175,23 @@ foreach ($righe as $riga) {
|
||||
echo '
|
||||
</td>';
|
||||
|
||||
// Iva
|
||||
echo '
|
||||
<td class="text-right">
|
||||
'.moneyFormat($riga->iva_unitaria_scontata).'
|
||||
<br><small class="'.(($riga->aliquota->deleted_at) ? 'text-red' : '').' text-muted">'.$riga->aliquota->descrizione.(($riga->aliquota->esente) ? ' ('.$riga->aliquota->codice_natura_fe.')' : null).'</small>
|
||||
// Sconto unitario
|
||||
if (!$block_edit) {
|
||||
echo '
|
||||
<td class="text-center">
|
||||
{[ "type": "number", "name": "sconto_'.$riga->id.'", "value": "'.($riga->sconto_percentuale ?: $riga->sconto_unitario_corrente).'", "min-value": "0", "onchange": "aggiornaInline($(this).closest(\'tr\').data(\'id\'))", "icon-after": "choice|untprc|'.$riga->tipo_sconto.'" ]}
|
||||
</td>';
|
||||
}
|
||||
|
||||
// Importo
|
||||
echo '
|
||||
<td class="text-right">
|
||||
'.moneyFormat($riga->importo);
|
||||
'.moneyFormat($riga->importo);
|
||||
|
||||
//provvigione riga
|
||||
if (abs($riga->provvigione_unitaria) > 0) {
|
||||
$text = provvigioneInfo($riga);
|
||||
|
||||
echo '
|
||||
<br><small class="label label-info">'.$text.'</small>';
|
||||
}
|
||||
|
||||
echo '</td>';
|
||||
// Iva
|
||||
echo '
|
||||
<br><small class="'.(($riga->aliquota->deleted_at) ? 'text-red' : '').' text-muted">'.$riga->aliquota->descrizione.(($riga->aliquota->esente) ? ' ('.$riga->aliquota->codice_natura_fe.')' : null).'</small>
|
||||
</td>';
|
||||
}
|
||||
|
||||
// Possibilità di rimuovere una riga solo se il preventivo non è stato pagato
|
||||
@ -234,7 +235,7 @@ $netto_a_pagare = $preventivo->netto;
|
||||
// Totale imponibile scontato
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="7" class="text-right">
|
||||
<td colspan="'.$colspan.'" class="text-right">
|
||||
<b>'.tr('Imponibile', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@ -247,7 +248,7 @@ echo '
|
||||
if (!empty($sconto)) {
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="7" class="text-right">
|
||||
<td colspan="'.$colspan.'" class="text-right">
|
||||
<b><span class="tip" title="'.tr('Un importo positivo indica uno sconto, mentre uno negativo indica una maggiorazione').'"> <i class="fa fa-question-circle-o"></i> '.tr('Sconto/maggiorazione', [], ['upper' => true]).':</span></b>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@ -259,7 +260,7 @@ if (!empty($sconto)) {
|
||||
// Totale imponibile scontato
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="7" class="text-right">
|
||||
<td colspan="'.$colspan.'" class="text-right">
|
||||
<b>'.tr('Totale imponibile', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@ -272,7 +273,7 @@ if (!empty($sconto)) {
|
||||
// Totale iva
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="7" class="text-right">
|
||||
<td colspan="'.$colspan.'" class="text-right">
|
||||
<b>'.tr('Iva', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@ -284,7 +285,7 @@ echo '
|
||||
// Totale
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="7" class="text-right">
|
||||
<td colspan="'.$colspan.'" class="text-right">
|
||||
<b>'.tr('Totale', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@ -297,7 +298,7 @@ echo '
|
||||
if (!empty($sconto_finale)) {
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="7" class="text-right">
|
||||
<td colspan="'.$colspan.'" class="text-right">
|
||||
<b>'.tr('Sconto in fattura', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@ -311,7 +312,7 @@ if (!empty($sconto_finale)) {
|
||||
if ($totale != $netto_a_pagare) {
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="7" class="text-right">
|
||||
<td colspan="'.$colspan.'" class="text-right">
|
||||
<b>'.tr('Netto a pagare', [], ['upper' => true]).':</b>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@ -328,7 +329,7 @@ $margine_icon = ($margine <= 0 && $preventivo->totale > 0) ? 'warning' : 'check'
|
||||
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="7" class="text-right">
|
||||
<td colspan="'.$colspan.'" class="text-right">
|
||||
'.tr('Costi').':
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@ -341,7 +342,7 @@ echo '
|
||||
if(!empty($preventivo->provvigione)) {
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="7" class="text-right">
|
||||
<td colspan="'.$colspan.'" class="text-right">
|
||||
'.tr('Provvigioni').':
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@ -353,7 +354,7 @@ echo '
|
||||
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="7" class="text-right">
|
||||
<td colspan="'.$colspan.'" class="text-right">
|
||||
'.tr('Margine (_PRC_%)', [
|
||||
'_PRC_' => numberFormat($preventivo->margine_percentuale),
|
||||
]).':
|
||||
@ -365,7 +366,7 @@ echo '
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td colspan="7" class="text-right">
|
||||
<td colspan="'.$colspan.'" class="text-right">
|
||||
'.tr('Ricarico (_PRC_%)', [
|
||||
'_PRC_' => numberFormat($preventivo->ricarico_percentuale),
|
||||
]).':
|
||||
@ -523,4 +524,37 @@ $("#check_all").click(function(){
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$(".tipo_icon_after").on("change", function() {
|
||||
aggiornaInline($(this).closest("tr").data("id"));
|
||||
});
|
||||
|
||||
function aggiornaInline(id) {
|
||||
content_was_modified = false;
|
||||
var qta = input("qta_"+ id).get();
|
||||
var sconto = input("sconto_"+ id).get();
|
||||
var tipo_sconto = input("tipo_sconto_"+ id).get();
|
||||
|
||||
$.ajax({
|
||||
url: globals.rootdir + "/actions.php",
|
||||
type: "POST",
|
||||
data: {
|
||||
id_module: globals.id_module,
|
||||
id_record: globals.id_record,
|
||||
op: "update_inline",
|
||||
riga_id: id,
|
||||
qta: qta,
|
||||
sconto: sconto,
|
||||
tipo_sconto: tipo_sconto,
|
||||
},
|
||||
success: function (response) {
|
||||
caricaRighe(id);
|
||||
renderMessages();
|
||||
},
|
||||
error: function() {
|
||||
caricaRighe(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
init();
|
||||
</script>';
|
||||
|
@ -287,7 +287,7 @@ class HTMLWrapper implements WrapperInterface
|
||||
|
||||
$value = (empty($pieces[2]) || !in_array($pieces[2], array_column($choices, 'id'))) ? $choices[0]['id'] : $pieces[2];
|
||||
|
||||
$result = '{[ "type": "select", "name": "tipo_'.prepareToField($values['name']).'", "id": "tipo_'.prepareToField($values['name']).'_'.rand(0, 99).'", "value": "'.prepareToField($value).'", "values": '.json_encode($choices).', "class": "no-search", "extra": "'.$extra.'" ]}';
|
||||
$result = '{[ "type": "select", "name": "tipo_'.prepareToField($values['name']).'", "id": "tipo_'.prepareToField($values['name']).'_'.rand(0, 99).'", "value": "'.prepareToField($value).'", "values": '.json_encode($choices).', "class": "no-search tipo_icon_after", "extra": "'.$extra.'" ]}';
|
||||
|
||||
$result = \HTMLBuilder\HTMLBuilder::replace($result);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user