1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2024-12-23 22:03:18 +01:00

Migliorie tabella listini

This commit is contained in:
MatteoPistorello 2023-01-12 16:27:33 +01:00
parent cd0b84d606
commit b3845575e1
3 changed files with 50 additions and 63 deletions

View File

@ -31,5 +31,32 @@ switch ($resource) {
$search_fields[] = 'nome LIKE '.prepare('%'.$search.'%');
}
break;
case 'articoli_listino':
// Gestione campi di ricerca
if (!empty($search)) {
$search_fields[] = '|table_listini|.data_scadenza LIKE '.prepare('%'.$search.'%');
$search_fields[] = '|table_listini|.prezzo_unitario LIKE '.prepare('%'.$search.'%');
$search_fields[] = '|table_listini|.prezzo_unitario_ivato LIKE '.prepare('%'.$search.'%');
$search_fields[] = '|table_listini|.sconto_percentuale LIKE '.prepare('%'.$search.'%');
$search_fields[] = '|table_articoli|.codice LIKE '.prepare('%'.$search.'%');
$search_fields[] = '|table_articoli|.descrizione LIKE '.prepare('%'.$search.'%');
$search_fields[] = ($prezzi_ivati ? '|table_articoli|.minimo_vendita_ivato' : '|table_articoli|.minimo_vendita').' LIKE '.prepare('%'.$search.'%');
}
// Aggiunta filtri di ricerca
$where = empty($search_fields) ? '1=1' : '('.implode(' OR ', $search_fields).')';
$query = 'SELECT mg_listini_articoli.*, mg_articoli.codice, mg_articoli.descrizione, mg_articoli.'.($prezzi_ivati ? 'minimo_vendita_ivato' : 'minimo_vendita').' AS minimo_vendita FROM mg_listini_articoli LEFT JOIN mg_articoli ON mg_listini_articoli.id_articolo=mg_articoli.id WHERE id_listino='.prepare($id_listino).' AND 1=1 LIMIT '.$start.', '.$length;
$query = str_replace('1=1', !empty($where) ? replace($where, [
'|table_listini|' => 'mg_listini_articoli',
'|table_articoli|' => 'mg_articoli',
]) : '', $query);
$articoli = $database->fetchArray($query);
$results = $articoli;
break;
}

View File

@ -3,9 +3,20 @@
include_once __DIR__.'/../../../core.php';
$id_listino = filter('id_listino');
$search = filter('search') ? filter('search')['value'] : null;
$start = filter('start');
$length = filter('length');
$tot_articoli = $dbo->select('mg_listini_articoli', '*', ['id_listino' => $id_listino]);
$articoli = $dbo->fetchArray('SELECT mg_listini_articoli.*, mg_articoli.codice, mg_articoli.descrizione, mg_articoli.'.($prezzi_ivati ? 'minimo_vendita_ivato' : 'minimo_vendita').' AS minimo_vendita FROM mg_listini_articoli LEFT JOIN mg_articoli ON mg_listini_articoli.id_articolo=mg_articoli.id WHERE id_listino='.prepare($id_listino).' LIMIT '.filter('start').', '.filter('length'));
if (empty($search)) {
$articoli = $dbo->fetchArray('SELECT mg_listini_articoli.*, mg_articoli.codice, mg_articoli.descrizione, mg_articoli.'.($prezzi_ivati ? 'minimo_vendita_ivato' : 'minimo_vendita').' AS minimo_vendita FROM mg_listini_articoli LEFT JOIN mg_articoli ON mg_listini_articoli.id_articolo=mg_articoli.id WHERE id_listino='.prepare($id_listino).' LIMIT '.$start.', '.$length);
} else {
$resource = 'articoli_listino';
include_once __DIR__.'/select.php';
$articoli = $results;
}
foreach ($articoli as $articolo) {
$riga = [

View File

@ -63,11 +63,11 @@ echo '
</div>
<hr>
<div class="row">
<div class="col-md-offset-7 col-md-3">
<div class="col-md-5">
{[ "type":"select", "label":"'.tr('Articolo').'", "ajax-source": "articoli", "select-options": {"permetti_movimento_a_zero": 1, "id_listino": '.$id_record.'} ]}
</div>
<div class="col-md-2">
<div class="col-md-1">
<div class="btn-group btn-group-flex">
<button type="button" class="btn btn-primary" style="margin-top:25px;" onclick="aggiungiArticolo(this, true)">
<i class="fa fa-plus"></i> '.tr('Aggiungi').'
@ -82,35 +82,14 @@ echo '
<th class="text-center">
<br><input id="check_all" type="checkbox"/>
</th>
<th class="text-center">
'.tr('Codice').'<br>
{[ "type": "text", "size": "10", "name": "search_sconto", "placeholder": "'.tr('Filtra').'..." ]}
</th>
<th class="text-center">
'.tr('Descrizione').'<br>
{[ "type": "text", "size": "30", "name": "search_sconto", "placeholder": "'.tr('Filtra').'..." ]}
</th>
<th class="text-center">
'.tr('Data scadenza').'<br>
{[ "type": "text", "size": "3", "name": "search_sconto", "placeholder": "'.tr('Filtra').'..." ]}
</th>
<th class="text-center">
'.tr('Minimo').'<br>
{[ "type": "text", "size": "3", "name": "search_sconto", "placeholder": "'.tr('Filtra').'..." ]}
</th>
<th class="text-center">
'.tr('Prezzo di listino').'<br>
{[ "type": "text", "size": "3", "name": "search_sconto", "placeholder": "'.tr('Filtra').'..." ]}
</th>
<th class="text-center">
'.tr('Prezzo ivato').'<br>
{[ "type": "text", "size": "3", "name": "search_sconto", "placeholder": "'.tr('Filtra').'..." ]}
</th>
<th class="text-center">
'.tr('Sconto').'<br>
{[ "type": "text", "size": "3", "name": "search_sconto", "placeholder": "'.tr('Filtra').'..." ]}
</th>
<th class="text-center"></th>
<th class="text-center" width="200">'.tr('Codice').'</th>
<th class="text-center" width="350">'.tr('Descrizione').'</th>
<th class="text-center" width="95">'.tr('Data scadenza').'</th>
<th class="text-center">'.tr('Minimo').'</th>
<th class="text-center">'.tr('Prezzo di listino').'</th>
<th class="text-center">'.tr('Prezzo ivato').'</th>
<th class="text-center">'.tr('Sconto').'</th>
<th class="text-center" width="40"></th>
</tr>
</thead>
</table>
@ -184,7 +163,7 @@ echo '
language: globals.translations.datatables,
retrieve: true,
ordering: false,
searching: false,
searching: true,
paging: true,
order: [],
lengthChange: false,
@ -206,36 +185,6 @@ echo '
$("#mini-loader").hide();
}
});
$("input[id^=\'search_\']").keyup(function() {
$("#tablelistini tr").each(function(){
$(this).show();
});
$("input[id^=\'search_\']").each(function(){
var position = $(this).closest("th").index();
var filter = $(this).val().toUpperCase();
var tr = $("#tablelistini tr");
if(filter!=""){
for (i = 0; i < tr.length; i++) {
td = tr[i].getElementsByTagName("td")[position];
if (td) {
if (td.innerText.toUpperCase().indexOf(filter) <= -1) {
tr[i].style.display = "none";
}
}
}
}
});
if ($("#check_all").is(":checked")) {
$("#check_all").trigger("click");
$(".check").each(function(){
if ($(this).is(":checked")) {
$(this).trigger("click");
}
});
}
});
});
// Estraggo le righe spuntate