Skip to content

Commit 03ece3d

Browse files
committed
feat: aggiunta tasto eliminazione riga prima nota
1 parent 33ba134 commit 03ece3d

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

modules/primanota/actions.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@
4141
$id_documento = post('id_documento')[$i];
4242
$dare = post('dare')[$i];
4343
$avere = post('avere')[$i];
44+
45+
if (empty($dare) && empty($avere)) {
46+
continue;
47+
}
48+
4449
$scadenza = Scadenza::find($id_scadenza);
4550
$fattura = Fattura::find($id_documento);
4651

@@ -105,6 +110,10 @@
105110
$dare = post('dare')[$i];
106111
$avere = post('avere')[$i];
107112

113+
if (empty($dare) && empty($avere)) {
114+
continue;
115+
}
116+
108117
$scadenza = Scadenza::find($id_scadenza);
109118
$fattura = Fattura::find($id_documento);
110119

modules/primanota/movimenti.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ function renderRiga($id, $riga, $totale_dare = null, $totale_avere = null)
3030
<input type="hidden" name="id_documento['.$id.']" value="'.$riga['iddocumento'].'">
3131
<input type="hidden" name="id_scadenza['.$id.']" value="'.$riga['id_scadenza'].'">
3232
33+
<td class="text-center" style="width:40px;">
34+
<button type="button" class="btn btn-danger btn-xs" onclick="deleteRiga(this)">
35+
<i class="fa fa-times"></i>
36+
</button>
37+
</td>
38+
3339
<td>
3440
{[ "type": "select", "name": "idconto['.$id.']", "id": "conto'.$id.'", "value": "'.($riga['id_conto'] ?: '').'", "ajax-source": "conti", "icon-after": '.json_encode('<button type="button" onclick="visualizzaMovimenti(this)" class="btn btn-info '.($riga['id_conto'] ? '' : 'disabled').'"><i class="fa fa-eye"></i></button>').' ]}
3541
</td>';
@@ -70,6 +76,7 @@ function renderTabella($nome, $righe, $totale_dare = null, $totale_avere = null)
7076
<table class="table table-striped table-sm table-hover table-bordered scadenze">
7177
<thead>
7278
<tr>
79+
<th width="40px"></th>
7380
<th>'.tr('Conto').'</th>
7481
<th width="20%">'.tr('Dare').'</th>
7582
<th width="20%">'.tr('Avere').'</th>
@@ -88,6 +95,7 @@ function renderTabella($nome, $righe, $totale_dare = null, $totale_avere = null)
8895
8996
<tfoot>
9097
<tr>
98+
<td></td>
9199
<td class="text-right"><b>'.tr('Totale').':</b></td>';
92100

93101
// Totale dare
@@ -391,4 +399,18 @@ function visualizzaMovimenti(button) {
391399
let id_conto = $(button).parent().parent().parent().find("select").val();
392400
openModal("'.tr('Ultimi 25 movimenti').'", "'.$module->fileurl('dettagli.php').'?id_module=" + globals.id_module + "&id_conto=" + id_conto);
393401
}
402+
403+
function deleteRiga(button) {
404+
// Get the row
405+
let row = $(button).closest("tr");
406+
407+
// Remove the row
408+
row.remove();
409+
410+
// Recalculate totals and check balance
411+
controllaConti();
412+
413+
// Trigger change event to update totals
414+
$("[id*=dare], [id*=avere]").trigger("change");
415+
}
394416
</script>';

0 commit comments

Comments
 (0)