mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-06-05 22:09:38 +02:00
Aggiunta selezione righe nei documenti per eliminazione e duplicazione
This commit is contained in:
@@ -299,16 +299,40 @@ switch (post('op')) {
|
|||||||
|
|
||||||
// Eliminazione riga
|
// Eliminazione riga
|
||||||
case 'delete_riga':
|
case 'delete_riga':
|
||||||
$id_riga = post('riga_id');
|
$id_righe = (array)post('righe');
|
||||||
$type = post('riga_type');
|
|
||||||
$riga = $contratto->getRiga($type, $id_riga);
|
|
||||||
|
|
||||||
if (!empty($riga)) {
|
foreach ($id_righe as $id_riga) {
|
||||||
|
$riga = Articolo::find($id_riga) ?: Riga::find($id_riga);
|
||||||
|
$riga = $riga ?: Descrizione::find($id_riga);
|
||||||
|
$riga = $riga ?: Sconto::find($id_riga);
|
||||||
$riga->delete();
|
$riga->delete();
|
||||||
|
|
||||||
flash()->info(tr('Riga eliminata!'));
|
$riga = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
flash()->info(tr('Righe eliminate!'));
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Duplicazione riga
|
||||||
|
case 'copy_riga':
|
||||||
|
$id_righe = (array)post('righe');
|
||||||
|
|
||||||
|
foreach ($id_righe as $id_riga) {
|
||||||
|
$riga = Articolo::find($id_riga) ?: Riga::find($id_riga);
|
||||||
|
$riga = $riga ?: Descrizione::find($id_riga);
|
||||||
|
$riga = $riga ?: Sconto::find($id_riga);
|
||||||
|
|
||||||
|
$new_riga = $riga->replicate();
|
||||||
|
$new_riga->setDocument($contratto);
|
||||||
|
$new_riga->qta_evasa = 0;
|
||||||
|
$new_riga->save();
|
||||||
|
|
||||||
|
$riga = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
flash()->info(tr('Righe duplicate!'));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Scollegamento intervento da contratto
|
// Scollegamento intervento da contratto
|
||||||
|
@@ -19,11 +19,21 @@
|
|||||||
|
|
||||||
include_once __DIR__.'/init.php';
|
include_once __DIR__.'/init.php';
|
||||||
|
|
||||||
|
$block_edit = $record['is_completato'];
|
||||||
|
$righe = $contratto->getRighe();
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="table table-striped table-hover table-condensed table-bordered">
|
<table class="table table-striped table-hover table-condensed table-bordered">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th width="5" class="text-center">';
|
||||||
|
if (!$block_edit && sizeof($righe) > 0) {
|
||||||
|
echo '
|
||||||
|
<input id="check_all" type="checkbox"/>';
|
||||||
|
}
|
||||||
|
echo '
|
||||||
|
</th>
|
||||||
<th width="35" class="text-center" >'.tr('#').'</th>
|
<th width="35" class="text-center" >'.tr('#').'</th>
|
||||||
<th>'.tr('Descrizione').'</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 tip" width="150" title="'.tr('da evadere').' / '.tr('totale').'">'.tr('Q.tà').' <i class="fa fa-question-circle-o"></i></th>
|
||||||
@@ -34,16 +44,23 @@ echo '
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
<tbody class="sortable">';
|
<tbody class="sortable" id="righe">';
|
||||||
|
|
||||||
// Righe documento
|
// Righe documento
|
||||||
$righe = $contratto->getRighe();
|
|
||||||
$num = 0;
|
$num = 0;
|
||||||
foreach ($righe as $riga) {
|
foreach ($righe as $riga) {
|
||||||
++$num;
|
++$num;
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
<tr data-id="'.$riga->id.'" data-type="'.get_class($riga).'">
|
<tr data-id="'.$riga->id.'" data-type="'.get_class($riga).'">
|
||||||
|
<td class="text-center">';
|
||||||
|
if (!$block_edit) {
|
||||||
|
echo '
|
||||||
|
<input class="check" type="checkbox"/>';
|
||||||
|
}
|
||||||
|
echo '
|
||||||
|
</td>
|
||||||
|
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
'.$num.'
|
'.$num.'
|
||||||
</td>
|
</td>
|
||||||
@@ -126,7 +143,7 @@ foreach ($righe as $riga) {
|
|||||||
<i class="fa fa-edit"></i>
|
<i class="fa fa-edit"></i>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a class="btn btn-xs btn-danger" title="'.tr('Rimuovi riga').'" onclick="rimuoviRiga(this)">
|
<a class="btn btn-xs btn-danger" title="'.tr('Rimuovi riga').'" onclick="rimuoviRiga([$(this).closest(\'tr\').data(\'id\')])">
|
||||||
<i class="fa fa-trash"></i>
|
<i class="fa fa-trash"></i>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
@@ -156,7 +173,7 @@ $netto_a_pagare = $contratto->netto;
|
|||||||
// Totale totale imponibile
|
// Totale totale imponibile
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5" class="text-right">
|
<td colspan="6" class="text-right">
|
||||||
<b>'.tr('Imponibile', [], ['upper' => true]).':</b>
|
<b>'.tr('Imponibile', [], ['upper' => true]).':</b>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@@ -169,7 +186,7 @@ echo '
|
|||||||
if (!empty($sconto)) {
|
if (!empty($sconto)) {
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5" class="text-right">
|
<td colspan="6" class="text-right">
|
||||||
<b><span class="tip" title="'.tr('Un importo positivo indica uno sconto, mentre uno negativo indica una maggiorazione').'"> <i class="fa fa-question-circle-o"></i> '.tr('Sconto/maggiorazione', [], ['upper' => true]).':</span></b>
|
<b><span class="tip" title="'.tr('Un importo positivo indica uno sconto, mentre uno negativo indica una maggiorazione').'"> <i class="fa fa-question-circle-o"></i> '.tr('Sconto/maggiorazione', [], ['upper' => true]).':</span></b>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@@ -181,7 +198,7 @@ if (!empty($sconto)) {
|
|||||||
// Totale totale imponibile
|
// Totale totale imponibile
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5" class="text-right">
|
<td colspan="6" class="text-right">
|
||||||
<b>'.tr('Totale imponibile', [], ['upper' => true]).':</b>
|
<b>'.tr('Totale imponibile', [], ['upper' => true]).':</b>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@@ -194,7 +211,7 @@ if (!empty($sconto)) {
|
|||||||
// Totale iva
|
// Totale iva
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5" class="text-right">
|
<td colspan="6" class="text-right">
|
||||||
<b>'.tr('Iva', [], ['upper' => true]).':</b>
|
<b>'.tr('Iva', [], ['upper' => true]).':</b>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@@ -206,7 +223,7 @@ echo '
|
|||||||
// Totale contratto
|
// Totale contratto
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5" class="text-right">
|
<td colspan="6" class="text-right">
|
||||||
<b>'.tr('Totale', [], ['upper' => true]).':</b>
|
<b>'.tr('Totale', [], ['upper' => true]).':</b>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@@ -219,7 +236,7 @@ echo '
|
|||||||
if (!empty($sconto_finale)) {
|
if (!empty($sconto_finale)) {
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5" class="text-right">
|
<td colspan="6" class="text-right">
|
||||||
<b>'.tr('Sconto in fattura', [], ['upper' => true]).':</b>
|
<b>'.tr('Sconto in fattura', [], ['upper' => true]).':</b>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@@ -233,7 +250,7 @@ if (!empty($sconto_finale)) {
|
|||||||
if ($totale != $netto_a_pagare) {
|
if ($totale != $netto_a_pagare) {
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5" class="text-right">
|
<td colspan="6" class="text-right">
|
||||||
<b>'.tr('Netto a pagare', [], ['upper' => true]).':</b>
|
<b>'.tr('Netto a pagare', [], ['upper' => true]).':</b>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@@ -244,10 +261,22 @@ if ($totale != $netto_a_pagare) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
</table>
|
</table>';
|
||||||
</div>';
|
if (!$block_edit && sizeof($righe) > 0) {
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
|
<div class="btn-group">
|
||||||
|
<button type="button" class="btn btn-xs btn-default disabled" id="elimina_righe" onclick="duplicaRiga(getSelectData());">
|
||||||
|
<i class="fa fa-copy"></i>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button type="button" class="btn btn-xs btn-default disabled" id="duplica_righe" onclick="rimuoviRiga(getSelectData());">
|
||||||
|
<i class="fa fa-trash"></i>
|
||||||
|
</button>
|
||||||
|
</div>';
|
||||||
|
}
|
||||||
|
echo '
|
||||||
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
async function modificaRiga(button) {
|
async function modificaRiga(button) {
|
||||||
let riga = $(button).closest("tr");
|
let riga = $(button).closest("tr");
|
||||||
@@ -265,18 +294,24 @@ async function modificaRiga(button) {
|
|||||||
openModal("'.tr('Modifica riga').'", "'.$module->fileurl('row-edit.php').'?id_module=" + globals.id_module + "&id_record=" + globals.id_record + "&riga_id=" + id + "&riga_type=" + type);
|
openModal("'.tr('Modifica riga').'", "'.$module->fileurl('row-edit.php').'?id_module=" + globals.id_module + "&id_record=" + globals.id_record + "&riga_id=" + id + "&riga_type=" + type);
|
||||||
}
|
}
|
||||||
|
|
||||||
function rimuoviRiga(button) {
|
// Estraggo le righe spuntate
|
||||||
|
function getSelectData() {
|
||||||
|
let data=new Array();
|
||||||
|
$(\'#righe\').find(\'.check:checked\').each(function (){
|
||||||
|
data.push($(this).closest(\'tr\').data(\'id\'));
|
||||||
|
});
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
function rimuoviRiga(id) {
|
||||||
swal({
|
swal({
|
||||||
title: "'.tr('Rimuovere questa riga?').'",
|
title: "'.tr('Rimuovere queste righe?').'",
|
||||||
html: "'.tr('Sei sicuro di volere rimuovere questa riga dal documento?').' '.tr("L'operazione è irreversibile").'.",
|
html: "'.tr('Sei sicuro di volere rimuovere queste righe dal documento?').' '.tr("L'operazione è irreversibile").'.",
|
||||||
type: "warning",
|
type: "warning",
|
||||||
showCancelButton: true,
|
showCancelButton: true,
|
||||||
confirmButtonText: "'.tr('Sì').'"
|
confirmButtonText: "'.tr('Sì').'"
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
let riga = $(button).closest("tr");
|
|
||||||
let id = riga.data("id");
|
|
||||||
let type = riga.data("type");
|
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: globals.rootdir + "/actions.php",
|
url: globals.rootdir + "/actions.php",
|
||||||
type: "POST",
|
type: "POST",
|
||||||
@@ -285,8 +320,35 @@ function rimuoviRiga(button) {
|
|||||||
id_module: globals.id_module,
|
id_module: globals.id_module,
|
||||||
id_record: globals.id_record,
|
id_record: globals.id_record,
|
||||||
op: "delete_riga",
|
op: "delete_riga",
|
||||||
riga_type: type,
|
righe: id,
|
||||||
riga_id: id,
|
},
|
||||||
|
success: function (response) {
|
||||||
|
location.reload();
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
location.reload();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}).catch(swal.noop);
|
||||||
|
}
|
||||||
|
|
||||||
|
function duplicaRiga(id) {
|
||||||
|
swal({
|
||||||
|
title: "'.tr('Duplicare queste righe?').'",
|
||||||
|
html: "'.tr('Sei sicuro di volere queste righe del documento?').'",
|
||||||
|
type: "warning",
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonText: "'.tr('Sì').'"
|
||||||
|
}).then(function () {
|
||||||
|
$.ajax({
|
||||||
|
url: globals.rootdir + "/actions.php",
|
||||||
|
type: "POST",
|
||||||
|
dataType: "json",
|
||||||
|
data: {
|
||||||
|
id_module: globals.id_module,
|
||||||
|
id_record: globals.id_record,
|
||||||
|
op: "copy_riga",
|
||||||
|
righe: id,
|
||||||
},
|
},
|
||||||
success: function (response) {
|
success: function (response) {
|
||||||
location.reload();
|
location.reload();
|
||||||
@@ -316,4 +378,37 @@ $(document).ready(function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(".check").on("change", function() {
|
||||||
|
let checked = 0;
|
||||||
|
$(".check").each(function() {
|
||||||
|
if ($(this).is(":checked")) {
|
||||||
|
checked = 1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (checked) {
|
||||||
|
$("#elimina_righe").removeClass("disabled");
|
||||||
|
$("#duplica_righe").removeClass("disabled");
|
||||||
|
} else {
|
||||||
|
$("#elimina_righe").addClass("disabled");
|
||||||
|
$("#duplica_righe").addClass("disabled");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#check_all").click(function(){
|
||||||
|
if( $(this).is(":checked") ){
|
||||||
|
$(".check").each(function(){
|
||||||
|
if( !$(this).is(":checked") ){
|
||||||
|
$(this).trigger("click");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
$(".check").each(function(){
|
||||||
|
if( $(this).is(":checked") ){
|
||||||
|
$(this).trigger("click");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>';
|
</script>';
|
||||||
|
@@ -386,24 +386,50 @@ switch (filter('op')) {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Scollegamento riga generica da ddt
|
// Eliminazione riga
|
||||||
case 'delete_riga':
|
case 'delete_riga':
|
||||||
$id_riga = post('riga_id');
|
$id_righe = (array)post('righe');
|
||||||
$type = post('riga_type');
|
|
||||||
|
|
||||||
$riga = $ddt->getRiga($type, $id_riga);
|
foreach ($id_righe as $id_riga) {
|
||||||
|
$riga = Articolo::find($id_riga) ?: Riga::find($id_riga);
|
||||||
if (!empty($riga)) {
|
$riga = $riga ?: Descrizione::find($id_riga);
|
||||||
|
$riga = $riga ?: Sconto::find($id_riga);
|
||||||
try {
|
try {
|
||||||
$riga->delete();
|
$riga->delete();
|
||||||
|
|
||||||
flash()->info(tr('Riga rimossa!'));
|
|
||||||
} catch (InvalidArgumentException $e) {
|
} catch (InvalidArgumentException $e) {
|
||||||
flash()->error(tr('Alcuni serial number sono già stati utilizzati!'));
|
flash()->error(tr('Alcuni serial number sono già stati utilizzati!'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$riga = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
ricalcola_costiagg_ddt($id_record);
|
ricalcola_costiagg_ddt($id_record);
|
||||||
|
flash()->info(tr('Righe eliminate!'));
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Duplicazione riga
|
||||||
|
case 'copy_riga':
|
||||||
|
$id_righe = (array)post('righe');
|
||||||
|
|
||||||
|
foreach ($id_righe as $id_riga) {
|
||||||
|
$riga = Articolo::find($id_riga) ?: Riga::find($id_riga);
|
||||||
|
$riga = $riga ?: Descrizione::find($id_riga);
|
||||||
|
$riga = $riga ?: Sconto::find($id_riga);
|
||||||
|
|
||||||
|
$new_riga = $riga->replicate();
|
||||||
|
$new_riga->setDocument($ddt);
|
||||||
|
$new_riga->qta_evasa = 0;
|
||||||
|
$new_riga->save();
|
||||||
|
|
||||||
|
if ($new_riga->isArticolo()) {
|
||||||
|
$new_riga->movimenta($new_riga->qta);
|
||||||
|
}
|
||||||
|
|
||||||
|
$riga = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
flash()->info(tr('Righe duplicate!'));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -474,7 +500,9 @@ switch (filter('op')) {
|
|||||||
$copia_riga->save();
|
$copia_riga->save();
|
||||||
|
|
||||||
// Movimentazione forzata in direzione del documento
|
// Movimentazione forzata in direzione del documento
|
||||||
$copia_riga->movimenta($riga->qta);
|
if ($copia_riga->isArticolo()) {
|
||||||
|
$copia_riga->movimenta($copia_riga->qta);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Salvataggio riferimento
|
// Salvataggio riferimento
|
||||||
|
@@ -19,11 +19,21 @@
|
|||||||
|
|
||||||
include_once __DIR__.'/init.php';
|
include_once __DIR__.'/init.php';
|
||||||
|
|
||||||
|
$block_edit = $record['flag_completato'];
|
||||||
|
$righe = $ddt->getRighe();
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="table table-striped table-hover table-condensed table-bordered">
|
<table class="table table-striped table-hover table-condensed table-bordered">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th width="5" class="text-center">';
|
||||||
|
if (!$block_edit && sizeof($righe) > 0) {
|
||||||
|
echo '
|
||||||
|
<input id="check_all" type="checkbox"/>';
|
||||||
|
}
|
||||||
|
echo '
|
||||||
|
</th>
|
||||||
<th width="35" class="text-center" >'.tr('#').'</th>
|
<th width="35" class="text-center" >'.tr('#').'</th>
|
||||||
<th>'.tr('Descrizione').'</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 tip" width="150" title="'.tr('da evadere').' / '.tr('totale').'">'.tr('Q.tà').' <i class="fa fa-question-circle-o"></i></th>
|
||||||
@@ -34,10 +44,9 @@ echo '
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
<tbody class="sortable">';
|
<tbody class="sortable" id="righe">';
|
||||||
|
|
||||||
// Righe documento
|
// Righe documento
|
||||||
$righe = $ddt->getRighe();
|
|
||||||
$num = 0;
|
$num = 0;
|
||||||
foreach ($righe as $riga) {
|
foreach ($righe as $riga) {
|
||||||
++$num;
|
++$num;
|
||||||
@@ -59,6 +68,14 @@ foreach ($righe as $riga) {
|
|||||||
|
|
||||||
echo '
|
echo '
|
||||||
<tr data-id="'.$riga->id.'" data-type="'.get_class($riga).'" '.$extra.'>
|
<tr data-id="'.$riga->id.'" data-type="'.get_class($riga).'" '.$extra.'>
|
||||||
|
<td class="text-center">';
|
||||||
|
if (!$block_edit) {
|
||||||
|
echo '
|
||||||
|
<input class="check" type="checkbox"/>';
|
||||||
|
}
|
||||||
|
echo '
|
||||||
|
</td>
|
||||||
|
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
'.$num.'
|
'.$num.'
|
||||||
</td>
|
</td>
|
||||||
@@ -174,7 +191,7 @@ foreach ($righe as $riga) {
|
|||||||
<i class="fa fa-edit"></i>
|
<i class="fa fa-edit"></i>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a class="btn btn-xs btn-danger" title="'.tr('Rimuovi riga').'" onclick="rimuoviRiga(this)">
|
<a class="btn btn-xs btn-danger" title="'.tr('Rimuovi riga').'" onclick="rimuoviRiga([$(this).closest(\'tr\').data(\'id\')])">
|
||||||
<i class="fa fa-trash"></i>
|
<i class="fa fa-trash"></i>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
@@ -204,7 +221,7 @@ $netto_a_pagare = $ddt->netto;
|
|||||||
// IMPONIBILE
|
// IMPONIBILE
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5" class="text-right">
|
<td colspan="6" class="text-right">
|
||||||
<b>'.tr('Imponibile', [], ['upper' => true]).':</b>
|
<b>'.tr('Imponibile', [], ['upper' => true]).':</b>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
@@ -219,7 +236,7 @@ echo '
|
|||||||
if (!empty($sconto)) {
|
if (!empty($sconto)) {
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5" class="text-right">
|
<td colspan="6" class="text-right">
|
||||||
<b><span class="tip" title="'.tr('Un importo positivo indica uno sconto, mentre uno negativo indica una maggiorazione').'"> <i class="fa fa-question-circle-o"></i> '.tr('Sconto/maggiorazione', [], ['upper' => true]).':</span></b>
|
<b><span class="tip" title="'.tr('Un importo positivo indica uno sconto, mentre uno negativo indica una maggiorazione').'"> <i class="fa fa-question-circle-o"></i> '.tr('Sconto/maggiorazione', [], ['upper' => true]).':</span></b>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
@@ -233,7 +250,7 @@ if (!empty($sconto)) {
|
|||||||
// TOTALE IMPONIBILE
|
// TOTALE IMPONIBILE
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5" class="text-right">
|
<td colspan="6" class="text-right">
|
||||||
<b>'.tr('Totale imponibile', [], ['upper' => true]).':</b>
|
<b>'.tr('Totale imponibile', [], ['upper' => true]).':</b>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
@@ -248,7 +265,7 @@ if (!empty($sconto)) {
|
|||||||
// IVA
|
// IVA
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5" class="text-right">
|
<td colspan="6" class="text-right">
|
||||||
<b>'.tr('IVA', [], ['upper' => true]).':</b>
|
<b>'.tr('IVA', [], ['upper' => true]).':</b>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
@@ -262,7 +279,7 @@ echo '
|
|||||||
// TOTALE
|
// TOTALE
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5" class="text-right">
|
<td colspan="6" class="text-right">
|
||||||
<b>'.tr('Totale', [], ['upper' => true]).':</b>
|
<b>'.tr('Totale', [], ['upper' => true]).':</b>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
@@ -277,7 +294,7 @@ echo '
|
|||||||
if (!empty($sconto_finale)) {
|
if (!empty($sconto_finale)) {
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5" class="text-right">
|
<td colspan="6" class="text-right">
|
||||||
<b>'.tr('Sconto in fattura', [], ['upper' => true]).':</b>
|
<b>'.tr('Sconto in fattura', [], ['upper' => true]).':</b>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@@ -291,7 +308,7 @@ if (!empty($sconto_finale)) {
|
|||||||
if ($totale != $netto_a_pagare) {
|
if ($totale != $netto_a_pagare) {
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5" class="text-right">
|
<td colspan="6" class="text-right">
|
||||||
<b>'.tr('Netto a pagare', [], ['upper' => true]).':</b>
|
<b>'.tr('Netto a pagare', [], ['upper' => true]).':</b>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@@ -302,10 +319,22 @@ if ($totale != $netto_a_pagare) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
</table>
|
</table>';
|
||||||
</div>';
|
if (!$block_edit && sizeof($righe) > 0) {
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
|
<div class="btn-group">
|
||||||
|
<button type="button" class="btn btn-xs btn-default disabled" id="elimina_righe" onclick="duplicaRiga(getSelectData());">
|
||||||
|
<i class="fa fa-copy"></i>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button type="button" class="btn btn-xs btn-default disabled" id="duplica_righe" onclick="rimuoviRiga(getSelectData());">
|
||||||
|
<i class="fa fa-trash"></i>
|
||||||
|
</button>
|
||||||
|
</div>';
|
||||||
|
}
|
||||||
|
echo '
|
||||||
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
async function modificaRiga(button) {
|
async function modificaRiga(button) {
|
||||||
let riga = $(button).closest("tr");
|
let riga = $(button).closest("tr");
|
||||||
@@ -323,18 +352,24 @@ async function modificaRiga(button) {
|
|||||||
openModal("'.tr('Modifica riga').'", "'.$module->fileurl('row-edit.php').'?id_module=" + globals.id_module + "&id_record=" + globals.id_record + "&riga_id=" + id + "&riga_type=" + type);
|
openModal("'.tr('Modifica riga').'", "'.$module->fileurl('row-edit.php').'?id_module=" + globals.id_module + "&id_record=" + globals.id_record + "&riga_id=" + id + "&riga_type=" + type);
|
||||||
}
|
}
|
||||||
|
|
||||||
function rimuoviRiga(button) {
|
// Estraggo le righe spuntate
|
||||||
|
function getSelectData() {
|
||||||
|
let data=new Array();
|
||||||
|
$(\'#righe\').find(\'.check:checked\').each(function (){
|
||||||
|
data.push($(this).closest(\'tr\').data(\'id\'));
|
||||||
|
});
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
function rimuoviRiga(id) {
|
||||||
swal({
|
swal({
|
||||||
title: "'.tr('Rimuovere questa riga?').'",
|
title: "'.tr('Rimuovere queste righe?').'",
|
||||||
html: "'.tr('Sei sicuro di volere rimuovere questa riga dal documento?').' '.tr("L'operazione è irreversibile").'.",
|
html: "'.tr('Sei sicuro di volere rimuovere queste righe dal documento?').' '.tr("L'operazione è irreversibile").'.",
|
||||||
type: "warning",
|
type: "warning",
|
||||||
showCancelButton: true,
|
showCancelButton: true,
|
||||||
confirmButtonText: "'.tr('Sì').'"
|
confirmButtonText: "'.tr('Sì').'"
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
let riga = $(button).closest("tr");
|
|
||||||
let id = riga.data("id");
|
|
||||||
let type = riga.data("type");
|
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: globals.rootdir + "/actions.php",
|
url: globals.rootdir + "/actions.php",
|
||||||
type: "POST",
|
type: "POST",
|
||||||
@@ -343,8 +378,35 @@ function rimuoviRiga(button) {
|
|||||||
id_module: globals.id_module,
|
id_module: globals.id_module,
|
||||||
id_record: globals.id_record,
|
id_record: globals.id_record,
|
||||||
op: "delete_riga",
|
op: "delete_riga",
|
||||||
riga_type: type,
|
righe: id,
|
||||||
riga_id: id,
|
},
|
||||||
|
success: function (response) {
|
||||||
|
location.reload();
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
location.reload();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}).catch(swal.noop);
|
||||||
|
}
|
||||||
|
|
||||||
|
function duplicaRiga(id) {
|
||||||
|
swal({
|
||||||
|
title: "'.tr('Duplicare queste righe?').'",
|
||||||
|
html: "'.tr('Sei sicuro di volere queste righe del documento?').'",
|
||||||
|
type: "warning",
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonText: "'.tr('Sì').'"
|
||||||
|
}).then(function () {
|
||||||
|
$.ajax({
|
||||||
|
url: globals.rootdir + "/actions.php",
|
||||||
|
type: "POST",
|
||||||
|
dataType: "json",
|
||||||
|
data: {
|
||||||
|
id_module: globals.id_module,
|
||||||
|
id_record: globals.id_record,
|
||||||
|
op: "copy_riga",
|
||||||
|
righe: id,
|
||||||
},
|
},
|
||||||
success: function (response) {
|
success: function (response) {
|
||||||
location.reload();
|
location.reload();
|
||||||
@@ -390,4 +452,37 @@ $(document).ready(function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(".check").on("change", function() {
|
||||||
|
let checked = 0;
|
||||||
|
$(".check").each(function() {
|
||||||
|
if ($(this).is(":checked")) {
|
||||||
|
checked = 1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (checked) {
|
||||||
|
$("#elimina_righe").removeClass("disabled");
|
||||||
|
$("#duplica_righe").removeClass("disabled");
|
||||||
|
} else {
|
||||||
|
$("#elimina_righe").addClass("disabled");
|
||||||
|
$("#duplica_righe").addClass("disabled");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#check_all").click(function(){
|
||||||
|
if( $(this).is(":checked") ){
|
||||||
|
$(".check").each(function(){
|
||||||
|
if( !$(this).is(":checked") ){
|
||||||
|
$(this).trigger("click");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
$(".check").each(function(){
|
||||||
|
if( $(this).is(":checked") ){
|
||||||
|
$(this).trigger("click");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>';
|
</script>';
|
||||||
|
@@ -631,22 +631,52 @@ switch (post('op')) {
|
|||||||
|
|
||||||
// Scollegamento riga generica da documento
|
// Scollegamento riga generica da documento
|
||||||
case 'delete_riga':
|
case 'delete_riga':
|
||||||
$id_riga = post('riga_id');
|
$id_righe = (array)post('righe');
|
||||||
$type = post('riga_type');
|
|
||||||
$riga = $fattura->getRiga($type, $id_riga);
|
foreach ($id_righe as $id_riga) {
|
||||||
|
$riga = Articolo::find($id_riga) ?: Riga::find($id_riga);
|
||||||
|
$riga = $riga ?: Descrizione::find($id_riga);
|
||||||
|
$riga = $riga ?: Sconto::find($id_riga);
|
||||||
|
|
||||||
if (!empty($riga)) {
|
|
||||||
try {
|
try {
|
||||||
$riga->delete();
|
$riga->delete();
|
||||||
|
|
||||||
// Ricalcolo inps, ritenuta e bollo
|
// Ricalcolo inps, ritenuta e bollo
|
||||||
ricalcola_costiagg_fattura($id_record);
|
ricalcola_costiagg_fattura($id_record);
|
||||||
|
|
||||||
flash()->info(tr('Riga rimossa!'));
|
|
||||||
} catch (InvalidArgumentException $e) {
|
} catch (InvalidArgumentException $e) {
|
||||||
flash()->error(tr('Alcuni serial number sono già stati utilizzati!'));
|
flash()->error(tr('Alcuni serial number sono già stati utilizzati!'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$riga = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
flash()->info(tr('Righe eliminate!'));
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Duplicazione riga
|
||||||
|
case 'copy_riga':
|
||||||
|
$id_righe = (array)post('righe');
|
||||||
|
|
||||||
|
foreach ($id_righe as $id_riga) {
|
||||||
|
$riga = Articolo::find($id_riga) ?: Riga::find($id_riga);
|
||||||
|
$riga = $riga ?: Descrizione::find($id_riga);
|
||||||
|
$riga = $riga ?: Sconto::find($id_riga);
|
||||||
|
|
||||||
|
$new_riga = $riga->replicate();
|
||||||
|
$new_riga->setDocument($fattura);
|
||||||
|
$new_riga->qta_evasa = 0;
|
||||||
|
$new_riga->save();
|
||||||
|
|
||||||
|
if ($new_riga->isArticolo()) {
|
||||||
|
$new_riga->movimenta($new_riga->qta);
|
||||||
|
}
|
||||||
|
|
||||||
|
$riga = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
flash()->info(tr('Righe duplicate!'));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'add_serial':
|
case 'add_serial':
|
||||||
|
@@ -21,11 +21,21 @@ use Modules\Interventi\Intervento;
|
|||||||
|
|
||||||
include_once __DIR__.'/init.php';
|
include_once __DIR__.'/init.php';
|
||||||
|
|
||||||
|
$block_edit = !empty($note_accredito) || in_array($record['stato'], ['Emessa', 'Pagato', 'Parzialmente pagato']) || !$abilita_genera;
|
||||||
|
$righe = $fattura->getRighe();
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="table table-striped table-hover table-condensed table-bordered">
|
<table class="table table-striped table-hover table-condensed table-bordered">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th width="5" class="text-center">';
|
||||||
|
if (!$block_edit && sizeof($righe) > 0) {
|
||||||
|
echo '
|
||||||
|
<input id="check_all" type="checkbox"/>';
|
||||||
|
}
|
||||||
|
echo '
|
||||||
|
</th>
|
||||||
<th width="35" class="text-center" >'.tr('#').'</th>
|
<th width="35" class="text-center" >'.tr('#').'</th>
|
||||||
<th>'.tr('Descrizione').'</th>
|
<th>'.tr('Descrizione').'</th>
|
||||||
<th class="text-center" width="150">'.tr('Q.tà').'</th>
|
<th class="text-center" width="150">'.tr('Q.tà').'</th>
|
||||||
@@ -35,10 +45,9 @@ echo '
|
|||||||
<th width="120"></th>
|
<th width="120"></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody class="sortable">';
|
<tbody class="sortable" id="righe">';
|
||||||
|
|
||||||
// Righe documento
|
// Righe documento
|
||||||
$righe = $fattura->getRighe();
|
|
||||||
$num = 0;
|
$num = 0;
|
||||||
foreach ($righe as $riga) {
|
foreach ($righe as $riga) {
|
||||||
++$num;
|
++$num;
|
||||||
@@ -90,6 +99,14 @@ foreach ($righe as $riga) {
|
|||||||
|
|
||||||
echo '
|
echo '
|
||||||
<tr data-id="'.$riga->id.'" data-type="'.get_class($riga).'" '.$extra.'>
|
<tr data-id="'.$riga->id.'" data-type="'.get_class($riga).'" '.$extra.'>
|
||||||
|
<td class="text-center">';
|
||||||
|
if (!$block_edit) {
|
||||||
|
echo '
|
||||||
|
<input class="check" type="checkbox"/>';
|
||||||
|
}
|
||||||
|
echo '
|
||||||
|
</td>
|
||||||
|
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
'.$num.'
|
'.$num.'
|
||||||
</td>
|
</td>
|
||||||
@@ -227,7 +244,7 @@ foreach ($righe as $riga) {
|
|||||||
<i class="fa fa-edit"></i>
|
<i class="fa fa-edit"></i>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a class="btn btn-xs btn-danger" title="'.tr('Rimuovi riga').'" onclick="rimuoviRiga(this)">
|
<a class="btn btn-xs btn-danger" title="'.tr('Rimuovi riga').'" onclick="rimuoviRiga([$(this).closest(\'tr\').data(\'id\')])">
|
||||||
<i class="fa fa-trash"></i>
|
<i class="fa fa-trash"></i>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
@@ -260,7 +277,7 @@ $ritenuta_contributi = $fattura->totale_ritenuta_contributi;
|
|||||||
// IMPONIBILE
|
// IMPONIBILE
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5" class="text-right">
|
<td colspan="6" class="text-right">
|
||||||
<b>'.tr('Imponibile', [], ['upper' => true]).':</b>
|
<b>'.tr('Imponibile', [], ['upper' => true]).':</b>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@@ -273,7 +290,7 @@ echo '
|
|||||||
if (!empty($sconto)) {
|
if (!empty($sconto)) {
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5" class="text-right">
|
<td colspan="6" class="text-right">
|
||||||
<b><span class="tip" title="'.tr('Un importo positivo indica uno sconto, mentre uno negativo indica una maggiorazione').'"><i class="fa fa-question-circle-o"></i> '.tr('Sconto/maggiorazione', [], ['upper' => true]).':</span></b>
|
<b><span class="tip" title="'.tr('Un importo positivo indica uno sconto, mentre uno negativo indica una maggiorazione').'"><i class="fa fa-question-circle-o"></i> '.tr('Sconto/maggiorazione', [], ['upper' => true]).':</span></b>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@@ -285,7 +302,7 @@ if (!empty($sconto)) {
|
|||||||
// TOTALE IMPONIBILE
|
// TOTALE IMPONIBILE
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5" class="text-right">
|
<td colspan="6" class="text-right">
|
||||||
<b>'.tr('Totale imponibile', [], ['upper' => true]).':</b>
|
<b>'.tr('Totale imponibile', [], ['upper' => true]).':</b>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@@ -299,7 +316,7 @@ if (!empty($sconto)) {
|
|||||||
if (!empty($rivalsa_inps)) {
|
if (!empty($rivalsa_inps)) {
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5" class="text-right">';
|
<td colspan="6" class="text-right">';
|
||||||
|
|
||||||
if ($dir == 'entrata') {
|
if ($dir == 'entrata') {
|
||||||
$descrizione_rivalsa = $database->fetchOne('SELECT CONCAT_WS(\' - \', codice, descrizione) AS descrizione FROM fe_tipo_cassa WHERE codice = '.prepare(setting('Tipo Cassa Previdenziale')));
|
$descrizione_rivalsa = $database->fetchOne('SELECT CONCAT_WS(\' - \', codice, descrizione) AS descrizione FROM fe_tipo_cassa WHERE codice = '.prepare(setting('Tipo Cassa Previdenziale')));
|
||||||
@@ -323,7 +340,7 @@ if (!empty($rivalsa_inps)) {
|
|||||||
if (!empty($iva)) {
|
if (!empty($iva)) {
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5" class="text-right">';
|
<td colspan="6" class="text-right">';
|
||||||
|
|
||||||
if ($records[0]['split_payment']) {
|
if ($records[0]['split_payment']) {
|
||||||
echo '<b>'.tr('Iva a carico del destinatario', [], ['upper' => true]).':</b>';
|
echo '<b>'.tr('Iva a carico del destinatario', [], ['upper' => true]).':</b>';
|
||||||
@@ -342,7 +359,7 @@ if (!empty($iva)) {
|
|||||||
// TOTALE
|
// TOTALE
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5" class="text-right">
|
<td colspan="6" class="text-right">
|
||||||
<b>'.tr('Totale', [], ['upper' => true]).':</b>
|
<b>'.tr('Totale', [], ['upper' => true]).':</b>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@@ -355,7 +372,7 @@ echo '
|
|||||||
if (!empty($ritenuta_acconto)) {
|
if (!empty($ritenuta_acconto)) {
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5" class="text-right">
|
<td colspan="6" class="text-right">
|
||||||
<b>'.tr("Ritenuta d'acconto", [], ['upper' => true]).':</b>
|
<b>'.tr("Ritenuta d'acconto", [], ['upper' => true]).':</b>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@@ -369,7 +386,7 @@ if (!empty($ritenuta_acconto)) {
|
|||||||
if (!empty($ritenuta_contributi)) {
|
if (!empty($ritenuta_contributi)) {
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5" class="text-right">
|
<td colspan="6" class="text-right">
|
||||||
<b>'.tr('Ritenuta previdenziale', [], ['upper' => true]).':</b>
|
<b>'.tr('Ritenuta previdenziale', [], ['upper' => true]).':</b>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@@ -383,7 +400,7 @@ if (!empty($ritenuta_contributi)) {
|
|||||||
if (!empty($sconto_finale)) {
|
if (!empty($sconto_finale)) {
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5" class="text-right">
|
<td colspan="6" class="text-right">
|
||||||
<b>'.tr('Sconto in fattura', [], ['upper' => true]).':</b>
|
<b>'.tr('Sconto in fattura', [], ['upper' => true]).':</b>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@@ -397,7 +414,7 @@ if (!empty($sconto_finale)) {
|
|||||||
if ($totale != $netto_a_pagare) {
|
if ($totale != $netto_a_pagare) {
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5" class="text-right">
|
<td colspan="6" class="text-right">
|
||||||
<b>'.tr('Netto a pagare', [], ['upper' => true]).':</b>
|
<b>'.tr('Netto a pagare', [], ['upper' => true]).':</b>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@@ -408,10 +425,22 @@ if ($totale != $netto_a_pagare) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
</table>
|
</table>';
|
||||||
</div>';
|
if (!$block_edit && sizeof($righe) > 0) {
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
|
<div class="btn-group">
|
||||||
|
<button type="button" class="btn btn-xs btn-default disabled" id="elimina_righe" onclick="duplicaRiga(getSelectData());">
|
||||||
|
<i class="fa fa-copy"></i>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button type="button" class="btn btn-xs btn-default disabled" id="duplica_righe" onclick="rimuoviRiga(getSelectData());">
|
||||||
|
<i class="fa fa-trash"></i>
|
||||||
|
</button>
|
||||||
|
</div>';
|
||||||
|
}
|
||||||
|
echo '
|
||||||
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
async function modificaRiga(button) {
|
async function modificaRiga(button) {
|
||||||
let riga = $(button).closest("tr");
|
let riga = $(button).closest("tr");
|
||||||
@@ -429,18 +458,24 @@ async function modificaRiga(button) {
|
|||||||
openModal("'.tr('Modifica riga').'", "'.$module->fileurl('row-edit.php').'?id_module=" + globals.id_module + "&id_record=" + globals.id_record + "&riga_id=" + id + "&riga_type=" + type);
|
openModal("'.tr('Modifica riga').'", "'.$module->fileurl('row-edit.php').'?id_module=" + globals.id_module + "&id_record=" + globals.id_record + "&riga_id=" + id + "&riga_type=" + type);
|
||||||
}
|
}
|
||||||
|
|
||||||
function rimuoviRiga(button) {
|
// Estraggo le righe spuntate
|
||||||
|
function getSelectData() {
|
||||||
|
let data=new Array();
|
||||||
|
$(\'#righe\').find(\'.check:checked\').each(function (){
|
||||||
|
data.push($(this).closest(\'tr\').data(\'id\'));
|
||||||
|
});
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
function rimuoviRiga(id) {
|
||||||
swal({
|
swal({
|
||||||
title: "'.tr('Rimuovere questa riga?').'",
|
title: "'.tr('Rimuovere queste righe?').'",
|
||||||
html: "'.tr('Sei sicuro di volere rimuovere questa riga dal documento?').' '.tr("L'operazione è irreversibile").'.",
|
html: "'.tr('Sei sicuro di volere rimuovere queste righe dal documento?').' '.tr("L'operazione è irreversibile").'.",
|
||||||
type: "warning",
|
type: "warning",
|
||||||
showCancelButton: true,
|
showCancelButton: true,
|
||||||
confirmButtonText: "'.tr('Sì').'"
|
confirmButtonText: "'.tr('Sì').'"
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
let riga = $(button).closest("tr");
|
|
||||||
let id = riga.data("id");
|
|
||||||
let type = riga.data("type");
|
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: globals.rootdir + "/actions.php",
|
url: globals.rootdir + "/actions.php",
|
||||||
type: "POST",
|
type: "POST",
|
||||||
@@ -449,8 +484,35 @@ function rimuoviRiga(button) {
|
|||||||
id_module: globals.id_module,
|
id_module: globals.id_module,
|
||||||
id_record: globals.id_record,
|
id_record: globals.id_record,
|
||||||
op: "delete_riga",
|
op: "delete_riga",
|
||||||
riga_type: type,
|
righe: id,
|
||||||
riga_id: id,
|
},
|
||||||
|
success: function (response) {
|
||||||
|
location.reload();
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
location.reload();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}).catch(swal.noop);
|
||||||
|
}
|
||||||
|
|
||||||
|
function duplicaRiga(id) {
|
||||||
|
swal({
|
||||||
|
title: "'.tr('Duplicare queste righe?').'",
|
||||||
|
html: "'.tr('Sei sicuro di volere queste righe del documento?').'",
|
||||||
|
type: "warning",
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonText: "'.tr('Sì').'"
|
||||||
|
}).then(function () {
|
||||||
|
$.ajax({
|
||||||
|
url: globals.rootdir + "/actions.php",
|
||||||
|
type: "POST",
|
||||||
|
dataType: "json",
|
||||||
|
data: {
|
||||||
|
id_module: globals.id_module,
|
||||||
|
id_record: globals.id_record,
|
||||||
|
op: "copy_riga",
|
||||||
|
righe: id,
|
||||||
},
|
},
|
||||||
success: function (response) {
|
success: function (response) {
|
||||||
location.reload();
|
location.reload();
|
||||||
@@ -496,4 +558,37 @@ $(document).ready(function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(".check").on("change", function() {
|
||||||
|
let checked = 0;
|
||||||
|
$(".check").each(function() {
|
||||||
|
if ($(this).is(":checked")) {
|
||||||
|
checked = 1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (checked) {
|
||||||
|
$("#elimina_righe").removeClass("disabled");
|
||||||
|
$("#duplica_righe").removeClass("disabled");
|
||||||
|
} else {
|
||||||
|
$("#elimina_righe").addClass("disabled");
|
||||||
|
$("#duplica_righe").addClass("disabled");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#check_all").click(function(){
|
||||||
|
if( $(this).is(":checked") ){
|
||||||
|
$(".check").each(function(){
|
||||||
|
if( !$(this).is(":checked") ){
|
||||||
|
$(this).trigger("click");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
$(".check").each(function(){
|
||||||
|
if( $(this).is(":checked") ){
|
||||||
|
$(this).trigger("click");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>';
|
</script>';
|
||||||
|
@@ -406,20 +406,46 @@ switch (post('op')) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'delete_riga':
|
case 'delete_riga':
|
||||||
$id_riga = post('riga_id');
|
$id_righe = (array)post('righe');
|
||||||
$type = post('riga_type');
|
|
||||||
$riga = $intervento->getRiga($type, $id_riga);
|
|
||||||
|
|
||||||
if (!empty($riga)) {
|
foreach ($id_righe as $id_riga) {
|
||||||
|
$riga = Articolo::find($id_riga) ?: Riga::find($id_riga);
|
||||||
|
$riga = $riga ?: Sconto::find($id_riga);
|
||||||
try {
|
try {
|
||||||
$riga->delete();
|
$riga->delete();
|
||||||
|
|
||||||
flash()->info(tr('Riga rimossa!'));
|
|
||||||
} catch (InvalidArgumentException $e) {
|
} catch (InvalidArgumentException $e) {
|
||||||
flash()->error(tr('Alcuni serial number sono già stati utilizzati!'));
|
flash()->error(tr('Alcuni serial number sono già stati utilizzati!'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$riga = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
flash()->info(tr('Righe eliminate!'));
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Duplicazione riga
|
||||||
|
case 'copy_riga':
|
||||||
|
$id_righe = (array)post('righe');
|
||||||
|
|
||||||
|
foreach ($id_righe as $id_riga) {
|
||||||
|
$riga = Articolo::find($id_riga) ?: Riga::find($id_riga);
|
||||||
|
$riga = $riga ?: Sconto::find($id_riga);
|
||||||
|
|
||||||
|
$new_riga = $riga->replicate();
|
||||||
|
$new_riga->setDocument($intervento);
|
||||||
|
$new_riga->qta_evasa = 0;
|
||||||
|
$new_riga->save();
|
||||||
|
|
||||||
|
if ($new_riga->isArticolo()) {
|
||||||
|
$new_riga->movimenta($new_riga->qta);
|
||||||
|
}
|
||||||
|
|
||||||
|
$riga = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
flash()->info(tr('Righe duplicate!'));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'manage_barcode':
|
case 'manage_barcode':
|
||||||
@@ -773,6 +799,10 @@ switch (post('op')) {
|
|||||||
|
|
||||||
$new_riga->qta_evasa = 0;
|
$new_riga->qta_evasa = 0;
|
||||||
$new_riga->save();
|
$new_riga->save();
|
||||||
|
|
||||||
|
if ($new_riga->isArticolo()) {
|
||||||
|
$new_riga->movimenta($new_riga->qta);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -19,15 +19,23 @@
|
|||||||
|
|
||||||
include_once __DIR__.'/init.php';
|
include_once __DIR__.'/init.php';
|
||||||
|
|
||||||
$show_prezzi = Auth::user()['gruppo'] != 'Tecnici' || (Auth::user()['gruppo'] == 'Tecnici' && setting('Mostra i prezzi al tecnico'));
|
$block_edit = $record['flag_completato'];
|
||||||
|
|
||||||
$righe = $intervento->getRighe();
|
$righe = $intervento->getRighe();
|
||||||
|
|
||||||
|
$show_prezzi = Auth::user()['gruppo'] != 'Tecnici' || (Auth::user()['gruppo'] == 'Tecnici' && setting('Mostra i prezzi al tecnico'));
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="table table-striped table-hover table-condensed table-bordered">
|
<table class="table table-striped table-hover table-condensed table-bordered">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th width="5" class="text-center">';
|
||||||
|
if (!$block_edit && sizeof($righe) > 0) {
|
||||||
|
echo '
|
||||||
|
<input id="check_all" type="checkbox"/>';
|
||||||
|
}
|
||||||
|
echo '
|
||||||
|
</th>
|
||||||
<th>'.tr('Descrizione').'</th>
|
<th>'.tr('Descrizione').'</th>
|
||||||
<th class="text-center" width="80">'.tr('Q.tà').'</th>';
|
<th class="text-center" width="80">'.tr('Q.tà').'</th>';
|
||||||
|
|
||||||
@@ -47,7 +55,7 @@ $righe = $intervento->getRighe();
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
<tbody class="sortable">';
|
<tbody class="sortable" id="righe">';
|
||||||
|
|
||||||
foreach ($righe as $riga) {
|
foreach ($righe as $riga) {
|
||||||
$extra = '';
|
$extra = '';
|
||||||
@@ -59,6 +67,13 @@ $righe = $intervento->getRighe();
|
|||||||
|
|
||||||
echo '
|
echo '
|
||||||
<tr data-id="'.$riga->id.'" data-type="'.get_class($riga).'" '.$extra.'>
|
<tr data-id="'.$riga->id.'" data-type="'.get_class($riga).'" '.$extra.'>
|
||||||
|
<td class="text-center">';
|
||||||
|
if (!$block_edit) {
|
||||||
|
echo '
|
||||||
|
<input class="check" type="checkbox"/>';
|
||||||
|
}
|
||||||
|
echo '
|
||||||
|
</td>
|
||||||
<td>';
|
<td>';
|
||||||
|
|
||||||
// Informazioni aggiuntive sulla destra
|
// Informazioni aggiuntive sulla destra
|
||||||
@@ -155,7 +170,7 @@ $righe = $intervento->getRighe();
|
|||||||
<i class="fa fa-edit"></i>
|
<i class="fa fa-edit"></i>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a class="btn btn-xs btn-danger" title="'.tr('Rimuovi riga').'" onclick="rimuoviRiga(this)">
|
<a class="btn btn-xs btn-danger" title="'.tr('Rimuovi riga').'" onclick="rimuoviRiga([$(this).closest(\'tr\').data(\'id\')])">
|
||||||
<i class="fa fa-trash"></i>
|
<i class="fa fa-trash"></i>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
@@ -179,7 +194,7 @@ $righe = $intervento->getRighe();
|
|||||||
// IMPONIBILE
|
// IMPONIBILE
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="'.((!$record['flag_completato']) ? 5 : 4).'" class="text-right">
|
<td colspan="'.((!$record['flag_completato']) ? 6 : 5).'" class="text-right">
|
||||||
<b>'.tr('Imponibile', [], ['upper' => true]).':</b>
|
<b>'.tr('Imponibile', [], ['upper' => true]).':</b>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@@ -192,7 +207,7 @@ $righe = $intervento->getRighe();
|
|||||||
if (!empty($intervento->sconto)) {
|
if (!empty($intervento->sconto)) {
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="'.((!$record['flag_completato']) ? 5 : 4).'" class="text-right">
|
<td colspan="'.((!$record['flag_completato']) ? 6 : 5).'" class="text-right">
|
||||||
<b><span class="tip" title="'.tr('Un importo positivo indica uno sconto, mentre uno negativo indica una maggiorazione').'"> <i class="fa fa-question-circle-o"></i> '.tr('Sconto/maggiorazione', [], ['upper' => true]).':</span></b>
|
<b><span class="tip" title="'.tr('Un importo positivo indica uno sconto, mentre uno negativo indica una maggiorazione').'"> <i class="fa fa-question-circle-o"></i> '.tr('Sconto/maggiorazione', [], ['upper' => true]).':</span></b>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@@ -204,7 +219,7 @@ $righe = $intervento->getRighe();
|
|||||||
// Totale imponibile scontato
|
// Totale imponibile scontato
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="'.((!$record['flag_completato']) ? 5 : 4).'" class="text-right">
|
<td colspan="'.((!$record['flag_completato']) ? 6 : 5).'" class="text-right">
|
||||||
<b>'.tr('Totale imponibile', [], ['upper' => true]).':</b>
|
<b>'.tr('Totale imponibile', [], ['upper' => true]).':</b>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@@ -217,10 +232,22 @@ $righe = $intervento->getRighe();
|
|||||||
}
|
}
|
||||||
|
|
||||||
echo'
|
echo'
|
||||||
</table>
|
</table>';
|
||||||
</div>';
|
if (!$block_edit && sizeof($righe) > 0) {
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
|
<div class="btn-group">
|
||||||
|
<button type="button" class="btn btn-xs btn-default disabled" id="elimina_righe" onclick="duplicaRiga(getSelectData());">
|
||||||
|
<i class="fa fa-copy"></i>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button type="button" class="btn btn-xs btn-default disabled" id="duplica_righe" onclick="rimuoviRiga(getSelectData());">
|
||||||
|
<i class="fa fa-trash"></i>
|
||||||
|
</button>
|
||||||
|
</div>';
|
||||||
|
}
|
||||||
|
echo '
|
||||||
|
</div>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
async function modificaRiga(button) {
|
async function modificaRiga(button) {
|
||||||
let riga = $(button).closest("tr");
|
let riga = $(button).closest("tr");
|
||||||
@@ -238,18 +265,24 @@ async function modificaRiga(button) {
|
|||||||
openModal("'.tr('Modifica sessione').'", "'.$module->fileurl('row-edit.php').'?id_module=" + globals.id_module + "&id_record=" + globals.id_record + "&riga_id=" + id + "&riga_type=" + type);
|
openModal("'.tr('Modifica sessione').'", "'.$module->fileurl('row-edit.php').'?id_module=" + globals.id_module + "&id_record=" + globals.id_record + "&riga_id=" + id + "&riga_type=" + type);
|
||||||
}
|
}
|
||||||
|
|
||||||
function rimuoviRiga(button) {
|
// Estraggo le righe spuntate
|
||||||
|
function getSelectData() {
|
||||||
|
let data=new Array();
|
||||||
|
$(\'#righe\').find(\'.check:checked\').each(function (){
|
||||||
|
data.push($(this).closest(\'tr\').data(\'id\'));
|
||||||
|
});
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
function rimuoviRiga(id) {
|
||||||
swal({
|
swal({
|
||||||
title: "'.tr('Rimuovere questa riga?').'",
|
title: "'.tr('Rimuovere queste righe?').'",
|
||||||
html: "'.tr('Sei sicuro di volere rimuovere questa riga dal documento?').' '.tr("L'operazione è irreversibile").'.",
|
html: "'.tr('Sei sicuro di volere rimuovere queste righe dal documento?').' '.tr("L'operazione è irreversibile").'.",
|
||||||
type: "warning",
|
type: "warning",
|
||||||
showCancelButton: true,
|
showCancelButton: true,
|
||||||
confirmButtonText: "'.tr('Sì').'"
|
confirmButtonText: "'.tr('Sì').'"
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
let riga = $(button).closest("tr");
|
|
||||||
let id = riga.data("id");
|
|
||||||
let type = riga.data("type");
|
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: globals.rootdir + "/actions.php",
|
url: globals.rootdir + "/actions.php",
|
||||||
type: "POST",
|
type: "POST",
|
||||||
@@ -258,8 +291,35 @@ function rimuoviRiga(button) {
|
|||||||
id_module: globals.id_module,
|
id_module: globals.id_module,
|
||||||
id_record: globals.id_record,
|
id_record: globals.id_record,
|
||||||
op: "delete_riga",
|
op: "delete_riga",
|
||||||
riga_type: type,
|
righe: id,
|
||||||
riga_id: id,
|
},
|
||||||
|
success: function (response) {
|
||||||
|
location.reload();
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
location.reload();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}).catch(swal.noop);
|
||||||
|
}
|
||||||
|
|
||||||
|
function duplicaRiga(id) {
|
||||||
|
swal({
|
||||||
|
title: "'.tr('Duplicare queste righe?').'",
|
||||||
|
html: "'.tr('Sei sicuro di volere queste righe del documento?').'",
|
||||||
|
type: "warning",
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonText: "'.tr('Sì').'"
|
||||||
|
}).then(function () {
|
||||||
|
$.ajax({
|
||||||
|
url: globals.rootdir + "/actions.php",
|
||||||
|
type: "POST",
|
||||||
|
dataType: "json",
|
||||||
|
data: {
|
||||||
|
id_module: globals.id_module,
|
||||||
|
id_record: globals.id_record,
|
||||||
|
op: "copy_riga",
|
||||||
|
righe: id,
|
||||||
},
|
},
|
||||||
success: function (response) {
|
success: function (response) {
|
||||||
location.reload();
|
location.reload();
|
||||||
@@ -297,4 +357,37 @@ $(document).ready(function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(".check").on("change", function() {
|
||||||
|
let checked = 0;
|
||||||
|
$(".check").each(function() {
|
||||||
|
if ($(this).is(":checked")) {
|
||||||
|
checked = 1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (checked) {
|
||||||
|
$("#elimina_righe").removeClass("disabled");
|
||||||
|
$("#duplica_righe").removeClass("disabled");
|
||||||
|
} else {
|
||||||
|
$("#elimina_righe").addClass("disabled");
|
||||||
|
$("#duplica_righe").addClass("disabled");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#check_all").click(function(){
|
||||||
|
if( $(this).is(":checked") ){
|
||||||
|
$(".check").each(function(){
|
||||||
|
if( !$(this).is(":checked") ){
|
||||||
|
$(this).trigger("click");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
$(".check").each(function(){
|
||||||
|
if( $(this).is(":checked") ){
|
||||||
|
$(this).trigger("click");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>';
|
</script>';
|
||||||
|
@@ -322,22 +322,47 @@ switch (post('op')) {
|
|||||||
|
|
||||||
// Scollegamento riga generica da ordine
|
// Scollegamento riga generica da ordine
|
||||||
case 'delete_riga':
|
case 'delete_riga':
|
||||||
$id_riga = post('riga_id');
|
$id_righe = (array)post('righe');
|
||||||
$type = post('riga_type');
|
|
||||||
$riga = $ordine->getRiga($type, $id_riga);
|
foreach ($id_righe as $id_riga) {
|
||||||
|
$riga = Articolo::find($id_riga) ?: Riga::find($id_riga);
|
||||||
|
$riga = $riga ?: Descrizione::find($id_riga);
|
||||||
|
$riga = $riga ?: Sconto::find($id_riga);
|
||||||
|
|
||||||
if (!empty($riga)) {
|
|
||||||
try {
|
try {
|
||||||
$riga->delete();
|
$riga->delete();
|
||||||
|
|
||||||
flash()->info(tr('Riga rimossa!'));
|
|
||||||
} catch (InvalidArgumentException $e) {
|
} catch (InvalidArgumentException $e) {
|
||||||
flash()->error(tr('Alcuni serial number sono già stati utilizzati!'));
|
flash()->error(tr('Alcuni serial number sono già stati utilizzati!'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$riga = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
ricalcola_costiagg_ordine($id_record);
|
ricalcola_costiagg_ordine($id_record);
|
||||||
|
|
||||||
|
flash()->info(tr('Righe eliminate!'));
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Duplicazione riga
|
||||||
|
case 'copy_riga':
|
||||||
|
$id_righe = (array)post('righe');
|
||||||
|
|
||||||
|
foreach ($id_righe as $id_riga) {
|
||||||
|
$riga = Articolo::find($id_riga) ?: Riga::find($id_riga);
|
||||||
|
$riga = $riga ?: Descrizione::find($id_riga);
|
||||||
|
$riga = $riga ?: Sconto::find($id_riga);
|
||||||
|
|
||||||
|
$new_riga = $riga->replicate();
|
||||||
|
$new_riga->setDocument($ordine);
|
||||||
|
$new_riga->qta_evasa = 0;
|
||||||
|
$new_riga->save();
|
||||||
|
|
||||||
|
$riga = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
flash()->info(tr('Righe duplicate!'));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Eliminazione ordine
|
// Eliminazione ordine
|
||||||
|
@@ -19,11 +19,21 @@
|
|||||||
|
|
||||||
include_once __DIR__.'/init.php';
|
include_once __DIR__.'/init.php';
|
||||||
|
|
||||||
|
$block_edit = $record['flag_completato'];
|
||||||
|
$righe = $ordine->getRighe();
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="table table-striped table-hover table-condensed table-bordered">
|
<table class="table table-striped table-hover table-condensed table-bordered">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th width="5" class="text-center">';
|
||||||
|
if (!$block_edit && sizeof($righe) > 0) {
|
||||||
|
echo '
|
||||||
|
<input id="check_all" type="checkbox"/>';
|
||||||
|
}
|
||||||
|
echo '
|
||||||
|
</th>
|
||||||
<th width="35" class="text-center" >'.tr('#').'</th>
|
<th width="35" class="text-center" >'.tr('#').'</th>
|
||||||
<th>'.tr('Descrizione').'</th>
|
<th>'.tr('Descrizione').'</th>
|
||||||
<th width="120">'.tr('Prev. evasione').'</th>
|
<th width="120">'.tr('Prev. evasione').'</th>
|
||||||
@@ -35,12 +45,11 @@ echo '
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
<tbody class="sortable">';
|
<tbody class="sortable" id="righe">';
|
||||||
|
|
||||||
// Righe documento
|
// Righe documento
|
||||||
$today = new Carbon\Carbon();
|
$today = new Carbon\Carbon();
|
||||||
$today = $today->startOfDay();
|
$today = $today->startOfDay();
|
||||||
$righe = $ordine->getRighe();
|
|
||||||
$num = 0;
|
$num = 0;
|
||||||
foreach ($righe as $riga) {
|
foreach ($righe as $riga) {
|
||||||
++$num;
|
++$num;
|
||||||
@@ -62,6 +71,14 @@ foreach ($righe as $riga) {
|
|||||||
|
|
||||||
echo '
|
echo '
|
||||||
<tr data-id="'.$riga->id.'" data-type="'.get_class($riga).'" '.$extra.'>
|
<tr data-id="'.$riga->id.'" data-type="'.get_class($riga).'" '.$extra.'>
|
||||||
|
<td class="text-center">';
|
||||||
|
if (!$block_edit) {
|
||||||
|
echo '
|
||||||
|
<input class="check" type="checkbox"/>';
|
||||||
|
}
|
||||||
|
echo '
|
||||||
|
</td>
|
||||||
|
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
'.$num.'
|
'.$num.'
|
||||||
</td>
|
</td>
|
||||||
@@ -213,7 +230,7 @@ foreach ($righe as $riga) {
|
|||||||
<i class="fa fa-edit"></i>
|
<i class="fa fa-edit"></i>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a class="btn btn-xs btn-danger" title="'.tr('Rimuovi riga').'" onclick="rimuoviRiga(this)">
|
<a class="btn btn-xs btn-danger" title="'.tr('Rimuovi riga').'" onclick="rimuoviRiga([$(this).closest(\'tr\').data(\'id\')])">
|
||||||
<i class="fa fa-trash"></i>
|
<i class="fa fa-trash"></i>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
@@ -243,7 +260,7 @@ $netto_a_pagare = $ordine->netto;
|
|||||||
// IMPONIBILE
|
// IMPONIBILE
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="6" class="text-right">
|
<td colspan="7" class="text-right">
|
||||||
<b>'.tr('Imponibile', [], ['upper' => true]).':</b>
|
<b>'.tr('Imponibile', [], ['upper' => true]).':</b>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@@ -256,7 +273,7 @@ echo '
|
|||||||
if (!empty($sconto)) {
|
if (!empty($sconto)) {
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="6" class="text-right">
|
<td colspan="7" class="text-right">
|
||||||
<b><span class="tip" title="'.tr('Un importo positivo indica uno sconto, mentre uno negativo indica una maggiorazione').'"> <i class="fa fa-question-circle-o"></i> '.tr('Sconto/maggiorazione', [], ['upper' => true]).':</span></b>
|
<b><span class="tip" title="'.tr('Un importo positivo indica uno sconto, mentre uno negativo indica una maggiorazione').'"> <i class="fa fa-question-circle-o"></i> '.tr('Sconto/maggiorazione', [], ['upper' => true]).':</span></b>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@@ -268,7 +285,7 @@ if (!empty($sconto)) {
|
|||||||
// TOTALE IMPONIBILE
|
// TOTALE IMPONIBILE
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="6" class="text-right">
|
<td colspan="7" class="text-right">
|
||||||
<b>'.tr('Totale imponibile', [], ['upper' => true]).':</b>
|
<b>'.tr('Totale imponibile', [], ['upper' => true]).':</b>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@@ -281,7 +298,7 @@ if (!empty($sconto)) {
|
|||||||
// IVA
|
// IVA
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="6" class="text-right">
|
<td colspan="7" class="text-right">
|
||||||
<b>'.tr('Iva', [], ['upper' => true]).':</b>
|
<b>'.tr('Iva', [], ['upper' => true]).':</b>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@@ -293,7 +310,7 @@ echo '
|
|||||||
// TOTALE
|
// TOTALE
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="6" class="text-right">
|
<td colspan="7" class="text-right">
|
||||||
<b>'.tr('Totale', [], ['upper' => true]).':</b>
|
<b>'.tr('Totale', [], ['upper' => true]).':</b>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@@ -306,7 +323,7 @@ echo '
|
|||||||
if (!empty($sconto_finale)) {
|
if (!empty($sconto_finale)) {
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="6" class="text-right">
|
<td colspan="7" class="text-right">
|
||||||
<b>'.tr('Sconto in fattura', [], ['upper' => true]).':</b>
|
<b>'.tr('Sconto in fattura', [], ['upper' => true]).':</b>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@@ -320,7 +337,7 @@ if (!empty($sconto_finale)) {
|
|||||||
if ($totale != $netto_a_pagare) {
|
if ($totale != $netto_a_pagare) {
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="6" class="text-right">
|
<td colspan="7" class="text-right">
|
||||||
<b>'.tr('Netto a pagare', [], ['upper' => true]).':</b>
|
<b>'.tr('Netto a pagare', [], ['upper' => true]).':</b>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@@ -331,10 +348,22 @@ if ($totale != $netto_a_pagare) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
</table>
|
</table>';
|
||||||
</div>';
|
if (!$block_edit && sizeof($righe) > 0) {
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
|
<div class="btn-group">
|
||||||
|
<button type="button" class="btn btn-xs btn-default disabled" id="elimina_righe" onclick="duplicaRiga(getSelectData());">
|
||||||
|
<i class="fa fa-copy"></i>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button type="button" class="btn btn-xs btn-default disabled" id="duplica_righe" onclick="rimuoviRiga(getSelectData());">
|
||||||
|
<i class="fa fa-trash"></i>
|
||||||
|
</button>
|
||||||
|
</div>';
|
||||||
|
}
|
||||||
|
echo '
|
||||||
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
async function modificaRiga(button) {
|
async function modificaRiga(button) {
|
||||||
let riga = $(button).closest("tr");
|
let riga = $(button).closest("tr");
|
||||||
@@ -352,18 +381,24 @@ async function modificaRiga(button) {
|
|||||||
openModal("'.tr('Modifica riga').'", "'.$module->fileurl('row-edit.php').'?id_module=" + globals.id_module + "&id_record=" + globals.id_record + "&riga_id=" + id + "&riga_type=" + type);
|
openModal("'.tr('Modifica riga').'", "'.$module->fileurl('row-edit.php').'?id_module=" + globals.id_module + "&id_record=" + globals.id_record + "&riga_id=" + id + "&riga_type=" + type);
|
||||||
}
|
}
|
||||||
|
|
||||||
function rimuoviRiga(button) {
|
// Estraggo le righe spuntate
|
||||||
|
function getSelectData() {
|
||||||
|
let data=new Array();
|
||||||
|
$(\'#righe\').find(\'.check:checked\').each(function (){
|
||||||
|
data.push($(this).closest(\'tr\').data(\'id\'));
|
||||||
|
});
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
function rimuoviRiga(id) {
|
||||||
swal({
|
swal({
|
||||||
title: "'.tr('Rimuovere questa riga?').'",
|
title: "'.tr('Rimuovere queste righe?').'",
|
||||||
html: "'.tr('Sei sicuro di volere rimuovere questa riga dal documento?').' '.tr("L'operazione è irreversibile").'.",
|
html: "'.tr('Sei sicuro di volere rimuovere queste righe dal documento?').' '.tr("L'operazione è irreversibile").'.",
|
||||||
type: "warning",
|
type: "warning",
|
||||||
showCancelButton: true,
|
showCancelButton: true,
|
||||||
confirmButtonText: "'.tr('Sì').'"
|
confirmButtonText: "'.tr('Sì').'"
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
let riga = $(button).closest("tr");
|
|
||||||
let id = riga.data("id");
|
|
||||||
let type = riga.data("type");
|
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: globals.rootdir + "/actions.php",
|
url: globals.rootdir + "/actions.php",
|
||||||
type: "POST",
|
type: "POST",
|
||||||
@@ -372,8 +407,35 @@ function rimuoviRiga(button) {
|
|||||||
id_module: globals.id_module,
|
id_module: globals.id_module,
|
||||||
id_record: globals.id_record,
|
id_record: globals.id_record,
|
||||||
op: "delete_riga",
|
op: "delete_riga",
|
||||||
riga_type: type,
|
righe: id,
|
||||||
riga_id: id,
|
},
|
||||||
|
success: function (response) {
|
||||||
|
location.reload();
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
location.reload();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}).catch(swal.noop);
|
||||||
|
}
|
||||||
|
|
||||||
|
function duplicaRiga(id) {
|
||||||
|
swal({
|
||||||
|
title: "'.tr('Duplicare queste righe?').'",
|
||||||
|
html: "'.tr('Sei sicuro di volere queste righe del documento?').'",
|
||||||
|
type: "warning",
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonText: "'.tr('Sì').'"
|
||||||
|
}).then(function () {
|
||||||
|
$.ajax({
|
||||||
|
url: globals.rootdir + "/actions.php",
|
||||||
|
type: "POST",
|
||||||
|
dataType: "json",
|
||||||
|
data: {
|
||||||
|
id_module: globals.id_module,
|
||||||
|
id_record: globals.id_record,
|
||||||
|
op: "copy_riga",
|
||||||
|
righe: id,
|
||||||
},
|
},
|
||||||
success: function (response) {
|
success: function (response) {
|
||||||
location.reload();
|
location.reload();
|
||||||
@@ -419,4 +481,37 @@ $(document).ready(function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(".check").on("change", function() {
|
||||||
|
let checked = 0;
|
||||||
|
$(".check").each(function() {
|
||||||
|
if ($(this).is(":checked")) {
|
||||||
|
checked = 1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (checked) {
|
||||||
|
$("#elimina_righe").removeClass("disabled");
|
||||||
|
$("#duplica_righe").removeClass("disabled");
|
||||||
|
} else {
|
||||||
|
$("#elimina_righe").addClass("disabled");
|
||||||
|
$("#duplica_righe").addClass("disabled");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#check_all").click(function(){
|
||||||
|
if( $(this).is(":checked") ){
|
||||||
|
$(".check").each(function(){
|
||||||
|
if( !$(this).is(":checked") ){
|
||||||
|
$(this).trigger("click");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
$(".check").each(function(){
|
||||||
|
if( $(this).is(":checked") ){
|
||||||
|
$(this).trigger("click");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>';
|
</script>';
|
||||||
|
@@ -354,17 +354,40 @@ switch (post('op')) {
|
|||||||
|
|
||||||
// Eliminazione riga
|
// Eliminazione riga
|
||||||
case 'delete_riga':
|
case 'delete_riga':
|
||||||
$id_riga = post('riga_id');
|
$id_righe = (array)post('righe');
|
||||||
$type = post('riga_type');
|
|
||||||
|
|
||||||
$riga = $preventivo->getRiga($type, $id_riga);
|
foreach ($id_righe as $id_riga) {
|
||||||
|
$riga = Articolo::find($id_riga) ?: Riga::find($id_riga);
|
||||||
if (!empty($riga)) {
|
$riga = $riga ?: Descrizione::find($id_riga);
|
||||||
|
$riga = $riga ?: Sconto::find($id_riga);
|
||||||
$riga->delete();
|
$riga->delete();
|
||||||
|
|
||||||
flash()->info(tr('Riga eliminata!'));
|
$riga = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
flash()->info(tr('Righe eliminate!'));
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Duplicazione riga
|
||||||
|
case 'copy_riga':
|
||||||
|
$id_righe = (array)post('righe');
|
||||||
|
|
||||||
|
foreach ($id_righe as $id_riga) {
|
||||||
|
$riga = Articolo::find($id_riga) ?: Riga::find($id_riga);
|
||||||
|
$riga = $riga ?: Descrizione::find($id_riga);
|
||||||
|
$riga = $riga ?: Sconto::find($id_riga);
|
||||||
|
|
||||||
|
$new_riga = $riga->replicate();
|
||||||
|
$new_riga->setDocument($preventivo);
|
||||||
|
$new_riga->qta_evasa = 0;
|
||||||
|
$new_riga->save();
|
||||||
|
|
||||||
|
$riga = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
flash()->info(tr('Righe duplicate!'));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'add_revision':
|
case 'add_revision':
|
||||||
|
@@ -19,11 +19,21 @@
|
|||||||
|
|
||||||
include_once __DIR__.'/init.php';
|
include_once __DIR__.'/init.php';
|
||||||
|
|
||||||
|
$block_edit = $record['is_completato'];
|
||||||
|
$righe = $preventivo->getRighe();
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="table table-striped table-hover table-condensed table-bordered">
|
<table class="table table-striped table-hover table-condensed table-bordered">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th width="5" class="text-center">';
|
||||||
|
if (!$block_edit && sizeof($righe) > 0) {
|
||||||
|
echo '
|
||||||
|
<input id="check_all" type="checkbox"/>';
|
||||||
|
}
|
||||||
|
echo '
|
||||||
|
</th>
|
||||||
<th width="35" class="text-center" >'.tr('#').'</th>
|
<th width="35" class="text-center" >'.tr('#').'</th>
|
||||||
<th>'.tr('Descrizione').'</th>
|
<th>'.tr('Descrizione').'</th>
|
||||||
<th width="120">'.tr('Prev. evasione').'</th>
|
<th width="120">'.tr('Prev. evasione').'</th>
|
||||||
@@ -34,18 +44,25 @@ echo '
|
|||||||
<th width="100"></th>
|
<th width="100"></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody class="sortable">';
|
<tbody class="sortable" id="righe">';
|
||||||
|
|
||||||
// Righe documento
|
// Righe documento
|
||||||
$today = new Carbon\Carbon();
|
$today = new Carbon\Carbon();
|
||||||
$today = $today->startOfDay();
|
$today = $today->startOfDay();
|
||||||
$righe = $preventivo->getRighe();
|
|
||||||
$num = 0;
|
$num = 0;
|
||||||
foreach ($righe as $riga) {
|
foreach ($righe as $riga) {
|
||||||
++$num;
|
++$num;
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
<tr data-id="'.$riga->id.'" data-type="'.get_class($riga).'">
|
<tr data-id="'.$riga->id.'" data-type="'.get_class($riga).'">
|
||||||
|
<td class="text-center">';
|
||||||
|
if (!$block_edit) {
|
||||||
|
echo '
|
||||||
|
<input class="check" type="checkbox"/>';
|
||||||
|
}
|
||||||
|
echo '
|
||||||
|
</td>
|
||||||
|
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
'.$num.'
|
'.$num.'
|
||||||
</td>
|
</td>
|
||||||
@@ -165,7 +182,7 @@ foreach ($righe as $riga) {
|
|||||||
<i class="fa fa-edit"></i>
|
<i class="fa fa-edit"></i>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a class="btn btn-xs btn-danger" title="'.tr('Rimuovi riga').'" onclick="rimuoviRiga(this)">
|
<a class="btn btn-xs btn-danger" title="'.tr('Rimuovi riga').'" onclick="rimuoviRiga([$(this).closest(\'tr\').data(\'id\')])">
|
||||||
<i class="fa fa-trash"></i>
|
<i class="fa fa-trash"></i>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
@@ -195,7 +212,7 @@ $netto_a_pagare = $preventivo->netto;
|
|||||||
// Totale imponibile scontato
|
// Totale imponibile scontato
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="6" class="text-right">
|
<td colspan="7" class="text-right">
|
||||||
<b>'.tr('Imponibile', [], ['upper' => true]).':</b>
|
<b>'.tr('Imponibile', [], ['upper' => true]).':</b>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@@ -208,7 +225,7 @@ echo '
|
|||||||
if (!empty($sconto)) {
|
if (!empty($sconto)) {
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="6" class="text-right">
|
<td colspan="7" class="text-right">
|
||||||
<b><span class="tip" title="'.tr('Un importo positivo indica uno sconto, mentre uno negativo indica una maggiorazione').'"> <i class="fa fa-question-circle-o"></i> '.tr('Sconto/maggiorazione', [], ['upper' => true]).':</span></b>
|
<b><span class="tip" title="'.tr('Un importo positivo indica uno sconto, mentre uno negativo indica una maggiorazione').'"> <i class="fa fa-question-circle-o"></i> '.tr('Sconto/maggiorazione', [], ['upper' => true]).':</span></b>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@@ -220,7 +237,7 @@ if (!empty($sconto)) {
|
|||||||
// Totale imponibile scontato
|
// Totale imponibile scontato
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="6" class="text-right">
|
<td colspan="7" class="text-right">
|
||||||
<b>'.tr('Totale imponibile', [], ['upper' => true]).':</b>
|
<b>'.tr('Totale imponibile', [], ['upper' => true]).':</b>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@@ -233,7 +250,7 @@ if (!empty($sconto)) {
|
|||||||
// Totale iva
|
// Totale iva
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="6" class="text-right">
|
<td colspan="7" class="text-right">
|
||||||
<b>'.tr('Iva', [], ['upper' => true]).':</b>
|
<b>'.tr('Iva', [], ['upper' => true]).':</b>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@@ -245,7 +262,7 @@ echo '
|
|||||||
// Totale
|
// Totale
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="6" class="text-right">
|
<td colspan="7" class="text-right">
|
||||||
<b>'.tr('Totale', [], ['upper' => true]).':</b>
|
<b>'.tr('Totale', [], ['upper' => true]).':</b>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@@ -258,7 +275,7 @@ echo '
|
|||||||
if (!empty($sconto_finale)) {
|
if (!empty($sconto_finale)) {
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="6" class="text-right">
|
<td colspan="7" class="text-right">
|
||||||
<b>'.tr('Sconto in fattura', [], ['upper' => true]).':</b>
|
<b>'.tr('Sconto in fattura', [], ['upper' => true]).':</b>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@@ -272,7 +289,7 @@ if (!empty($sconto_finale)) {
|
|||||||
if ($totale != $netto_a_pagare) {
|
if ($totale != $netto_a_pagare) {
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="6" class="text-right">
|
<td colspan="7" class="text-right">
|
||||||
<b>'.tr('Netto a pagare', [], ['upper' => true]).':</b>
|
<b>'.tr('Netto a pagare', [], ['upper' => true]).':</b>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@@ -289,7 +306,7 @@ $margine_icon = ($margine <= 0 and $preventivo->totale > 0) ? 'warning' : 'check
|
|||||||
|
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="6" class="text-right">
|
<td colspan="7" class="text-right">
|
||||||
'.tr('Costi').':
|
'.tr('Costi').':
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
@@ -299,7 +316,7 @@ echo '
|
|||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="6" class="text-right">
|
<td colspan="7" class="text-right">
|
||||||
'.tr('Margine (_PRC_%)', [
|
'.tr('Margine (_PRC_%)', [
|
||||||
'_PRC_' => numberFormat($preventivo->margine_percentuale),
|
'_PRC_' => numberFormat($preventivo->margine_percentuale),
|
||||||
]).':
|
]).':
|
||||||
@@ -311,10 +328,22 @@ echo '
|
|||||||
</tr>';
|
</tr>';
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
</table>
|
</table>';
|
||||||
</div>';
|
if (!$block_edit && sizeof($righe) > 0) {
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
|
<div class="btn-group">
|
||||||
|
<button type="button" class="btn btn-xs btn-default disabled" id="elimina_righe" onclick="duplicaRiga(getSelectData());">
|
||||||
|
<i class="fa fa-copy"></i>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button type="button" class="btn btn-xs btn-default disabled" id="duplica_righe" onclick="rimuoviRiga(getSelectData());">
|
||||||
|
<i class="fa fa-trash"></i>
|
||||||
|
</button>
|
||||||
|
</div>';
|
||||||
|
}
|
||||||
|
echo '
|
||||||
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
async function modificaRiga(button) {
|
async function modificaRiga(button) {
|
||||||
let riga = $(button).closest("tr");
|
let riga = $(button).closest("tr");
|
||||||
@@ -332,18 +361,24 @@ async function modificaRiga(button) {
|
|||||||
openModal("'.tr('Modifica riga').'", "'.$module->fileurl('row-edit.php').'?id_module=" + globals.id_module + "&id_record=" + globals.id_record + "&riga_id=" + id + "&riga_type=" + type);
|
openModal("'.tr('Modifica riga').'", "'.$module->fileurl('row-edit.php').'?id_module=" + globals.id_module + "&id_record=" + globals.id_record + "&riga_id=" + id + "&riga_type=" + type);
|
||||||
}
|
}
|
||||||
|
|
||||||
function rimuoviRiga(button) {
|
// Estraggo le righe spuntate
|
||||||
|
function getSelectData() {
|
||||||
|
let data=new Array();
|
||||||
|
$(\'#righe\').find(\'.check:checked\').each(function (){
|
||||||
|
data.push($(this).closest(\'tr\').data(\'id\'));
|
||||||
|
});
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
function rimuoviRiga(id) {
|
||||||
swal({
|
swal({
|
||||||
title: "'.tr('Rimuovere questa riga?').'",
|
title: "'.tr('Rimuovere queste righe?').'",
|
||||||
html: "'.tr('Sei sicuro di volere rimuovere questa riga dal documento?').' '.tr("L'operazione è irreversibile").'.",
|
html: "'.tr('Sei sicuro di volere rimuovere queste righe dal documento?').' '.tr("L'operazione è irreversibile").'.",
|
||||||
type: "warning",
|
type: "warning",
|
||||||
showCancelButton: true,
|
showCancelButton: true,
|
||||||
confirmButtonText: "'.tr('Sì').'"
|
confirmButtonText: "'.tr('Sì').'"
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
let riga = $(button).closest("tr");
|
|
||||||
let id = riga.data("id");
|
|
||||||
let type = riga.data("type");
|
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: globals.rootdir + "/actions.php",
|
url: globals.rootdir + "/actions.php",
|
||||||
type: "POST",
|
type: "POST",
|
||||||
@@ -352,8 +387,35 @@ function rimuoviRiga(button) {
|
|||||||
id_module: globals.id_module,
|
id_module: globals.id_module,
|
||||||
id_record: globals.id_record,
|
id_record: globals.id_record,
|
||||||
op: "delete_riga",
|
op: "delete_riga",
|
||||||
riga_type: type,
|
righe: id,
|
||||||
riga_id: id,
|
},
|
||||||
|
success: function (response) {
|
||||||
|
location.reload();
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
location.reload();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}).catch(swal.noop);
|
||||||
|
}
|
||||||
|
|
||||||
|
function duplicaRiga(id) {
|
||||||
|
swal({
|
||||||
|
title: "'.tr('Duplicare queste righe?').'",
|
||||||
|
html: "'.tr('Sei sicuro di volere queste righe del documento?').'",
|
||||||
|
type: "warning",
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonText: "'.tr('Sì').'"
|
||||||
|
}).then(function () {
|
||||||
|
$.ajax({
|
||||||
|
url: globals.rootdir + "/actions.php",
|
||||||
|
type: "POST",
|
||||||
|
dataType: "json",
|
||||||
|
data: {
|
||||||
|
id_module: globals.id_module,
|
||||||
|
id_record: globals.id_record,
|
||||||
|
op: "copy_riga",
|
||||||
|
righe: id,
|
||||||
},
|
},
|
||||||
success: function (response) {
|
success: function (response) {
|
||||||
location.reload();
|
location.reload();
|
||||||
@@ -383,4 +445,37 @@ $(document).ready(function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(".check").on("change", function() {
|
||||||
|
let checked = 0;
|
||||||
|
$(".check").each(function() {
|
||||||
|
if ($(this).is(":checked")) {
|
||||||
|
checked = 1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (checked) {
|
||||||
|
$("#elimina_righe").removeClass("disabled");
|
||||||
|
$("#duplica_righe").removeClass("disabled");
|
||||||
|
} else {
|
||||||
|
$("#elimina_righe").addClass("disabled");
|
||||||
|
$("#duplica_righe").addClass("disabled");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#check_all").click(function(){
|
||||||
|
if( $(this).is(":checked") ){
|
||||||
|
$(".check").each(function(){
|
||||||
|
if( !$(this).is(":checked") ){
|
||||||
|
$(this).trigger("click");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
$(".check").each(function(){
|
||||||
|
if( $(this).is(":checked") ){
|
||||||
|
$(this).trigger("click");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>';
|
</script>';
|
||||||
|
Reference in New Issue
Block a user