Skip to content

Commit d0251de

Browse files
committed
refactor: modulo Listini cliente
1 parent c04b28a commit d0251de

2 files changed

Lines changed: 71 additions & 44 deletions

File tree

modules/listini_cliente/ajax/table.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@
2121

2222
foreach ($articoli as $articolo) {
2323
$riga = [
24-
'<input class="check" type="checkbox" id="'.$articolo['id'].'"/>',
25-
Modules::link('Articoli', $articolo['id_articolo'], $articolo['codice'], null, ''),
26-
$articolo['descrizione'],
27-
$articolo['data_scadenza'] ? '<p class="text-center">'.dateFormat($articolo['data_scadenza']).'</p>' : '<p class="text-muted text-center">'.dateFormat($listino['data_scadenza_predefinita']).'</p>',
28-
'<p class="text-right">'.($articolo['minimo_vendita'] != 0 ? moneyFormat($articolo['minimo_vendita']) : '-').'</p>',
29-
'<p class="text-right">'.moneyFormat($articolo['prezzo_unitario']).'</p>',
30-
'<p class="text-right">'.moneyFormat($articolo['prezzo_unitario_ivato']).'</p>',
31-
'<p class="text-right">'.($articolo['sconto_percentuale'] != 0 ? numberFormat($articolo['sconto_percentuale']).' %' : '-').'</p>',
32-
'<div class="text-center">
24+
'<div class="text-center align-middle"><input class="check" type="checkbox" id="'.$articolo['id'].'"/></div>',
25+
'<div class="align-middle">'.Modules::link('Articoli', $articolo['id_articolo'], $articolo['codice'], null, '').'</div>',
26+
'<div class="align-middle">'.$articolo['descrizione'].'</div>',
27+
'<div class="text-center align-middle">'.($articolo['data_scadenza'] ? dateFormat($articolo['data_scadenza']) : '<span class="text-muted">'.dateFormat($listino['data_scadenza_predefinita']).'</span>').'</div>',
28+
'<div class="text-right align-middle">'.($articolo['minimo_vendita'] != 0 ? moneyFormat($articolo['minimo_vendita']) : '-').'</div>',
29+
'<div class="text-right align-middle">'.moneyFormat($articolo['prezzo_unitario']).'</div>',
30+
'<div class="text-right align-middle">'.moneyFormat($articolo['prezzo_unitario_ivato']).'</div>',
31+
'<div class="text-right align-middle">'.($articolo['sconto_percentuale'] != 0 ? numberFormat($articolo['sconto_percentuale']).' %' : '-').'</div>',
32+
'<div class="text-center align-middle">
3333
<a class="btn btn-xs btn-warning" title="'.tr('Modifica articolo').'" onclick="modificaArticolo($(this), '.$articolo['id'].')">
3434
<i class="fa fa-edit"></i>
3535
</a>

modules/listini_cliente/edit.php

Lines changed: 62 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
{[ "type":"date", "label":"'.tr('Data scadenza predefinita').'", "name":"data_scadenza_predefinita", "value":"$data_scadenza_predefinita$", "required":"1" ]}
4747
</div>
4848
</div>
49-
49+
5050
<div class="row">
5151
<div class="col-md-6">
5252
{[ "type":"checkbox", "label":"'.tr('Sempre visibile').'", "name":"is_sempre_visibile", "value":"$is_sempre_visibile$", "help": "'.tr('Se impostato il valore sarà sempre visibile sull\'articolo se il listino è attivo e la data di scadenza è ancora valida').'" ]}
@@ -63,37 +63,64 @@
6363
</div>
6464
</div>
6565
<hr>
66-
<div class="row">
67-
<div class="col-md-5">
68-
{[ "type":"select", "label":"'.tr('Articolo').'", "ajax-source": "articoli", "select-options": {"permetti_movimento_a_zero": 1, "id_listino": '.$id_record.'} ]}
66+
<div class="card card-info">
67+
<div class="card-header">
68+
<h3 class="card-title">
69+
<i class="fa fa-list-alt"></i> '.tr('Gestione Articoli').'
70+
</h3>
6971
</div>
70-
71-
<div class="col-md-1">
72-
<div class="btn-group btn-group-flex">
73-
<button type="button" class="btn btn-primary" style="margin-top:25px;" onclick="aggiungiArticolo(this, true)">
74-
<i class="fa fa-plus"></i> '.tr('Aggiungi').'
75-
</button>
72+
<div class="card-body">
73+
<div class="row">
74+
<div class="col-md-8">
75+
{[ "type":"select", "label":"'.tr('Seleziona Articolo').'", "ajax-source": "articoli", "select-options": {"permetti_movimento_a_zero": 1, "id_listino": '.$id_record.'} ]}
76+
</div>
77+
<div class="col-md-4">
78+
<label>&nbsp;</label>
79+
<div class="form-group">
80+
<button type="button" class="btn btn-success btn-block" onclick="aggiungiArticolo(this, true)">
81+
<i class="fa fa-plus"></i> '.tr('Aggiungi Articolo').'
82+
</button>
83+
</div>
84+
</div>
7685
</div>
7786
</div>
7887
</div>
7988
80-
<table class="table table-hover table-sm table-bordered" id="tablelistini" width="100%">
81-
<thead>
82-
<tr>
83-
<th class="text-center">
84-
<br><input id="check_all" type="checkbox"/>
85-
</th>
86-
<th class="text-center">'.tr('Codice').'</th>
87-
<th class="text-center">'.tr('Descrizione').'</th>
88-
<th class="text-center">'.tr('Data scadenza').'</th>
89-
<th class="text-center">'.tr('Minimo').'</th>
90-
<th class="text-center">'.tr('Prezzo di listino').'</th>
91-
<th class="text-center">'.tr('Prezzo ivato').'</th>
92-
<th class="text-center">'.tr('Sconto').'</th>
93-
<th class="text-center"></th>
94-
</tr>
95-
</thead>
96-
</table>
89+
<div class="table-responsive">
90+
<table class="table table-hover table-sm table-bordered" id="tablelistini" width="100%">
91+
<thead>
92+
<tr>
93+
<th class="text-center align-middle" width="50">
94+
<input id="check_all" type="checkbox"/>
95+
</th>
96+
<th class="text-center">
97+
<i class="fa fa-barcode text-muted"></i> '.tr('Codice').'
98+
</th>
99+
<th class="text-center">
100+
<i class="fa fa-file-text-o text-muted"></i> '.tr('Descrizione').'
101+
</th>
102+
<th class="text-center">
103+
<i class="fa fa-calendar text-muted"></i> '.tr('Data scadenza').'
104+
</th>
105+
<th class="text-center">
106+
<i class="fa fa-sort-numeric-asc text-muted"></i> '.tr('Minimo').'
107+
</th>
108+
<th class="text-center">
109+
<i class="fa fa-euro text-muted"></i> '.tr('Prezzo di listino').'
110+
</th>
111+
<th class="text-center">
112+
<i class="fa fa-euro text-muted"></i> '.tr('Prezzo ivato').'
113+
</th>
114+
<th class="text-center">
115+
<i class="fa fa-percent text-muted"></i> '.tr('Sconto').'
116+
</th>
117+
<th class="text-center" width="100">
118+
<i class="fa fa-cogs text-muted"></i> '.tr('Azioni').'
119+
</th>
120+
</tr>
121+
</thead>
122+
</table>
123+
</div>
97124
98125
<div class="btn-group">
99126
<button type="button" class="btn btn-xs btn-default disabled" id="elimina_righe" onclick="rimuoviArticolo(getSelectData());">
@@ -122,15 +149,15 @@ function aggiungiArticolo(button) {
122149
123150
async function modificaArticolo(button, id) {
124151
let riga = $(button).closest("tr");
125-
152+
126153
// Chiusura tooltip
127154
if ($(button).hasClass("tooltipstered"))
128155
$(button).tooltipster("close");
129-
156+
130157
// Apertura modal
131158
openModal("'.tr('Listino articolo').'", "'.$structure->fileurl('modals/manage_articolo.php').'?id_module='.$id_module.'&id_record='.$id_record.'&id=" + id);
132159
}
133-
160+
134161
function rimuoviArticolo(id) {
135162
swal({
136163
title: "'.tr('Rimuovere questo articolo?').'",
@@ -178,7 +205,7 @@ function rimuoviArticolo(id) {
178205
searchDelay: 500,
179206
pageLength: 15,
180207
});
181-
208+
182209
table.on("processing.dt", function (e, settings, processing) {
183210
if (processing) {
184211
$("#mini-loader").show();
@@ -191,7 +218,7 @@ function rimuoviArticolo(id) {
191218
// Estraggo le righe spuntate
192219
function getSelectData() {
193220
let data=new Array();
194-
$(\'#tablelistini\').find(\'.check:checked\').each(function (){
221+
$(\'#tablelistini\').find(\'.check:checked\').each(function (){
195222
data.push($(this).attr(\'id\'));
196223
});
197224
@@ -206,16 +233,16 @@ function getSelectData() {
206233
checked = 1;
207234
}
208235
});
209-
236+
210237
if (checked) {
211238
$("#elimina_righe").removeClass("disabled");
212239
} else {
213240
$("#elimina_righe").addClass("disabled");
214241
}
215242
});
216243
}, 1000);
217-
218-
$("#check_all").click(function(){
244+
245+
$("#check_all").click(function(){
219246
if( $(this).is(":checked") ){
220247
$(".check").each(function(){
221248
if( !$(this).is(":checked") ){

0 commit comments

Comments
 (0)