mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-02 17:07:01 +01:00
Aggiunta articoli barcode con ricerca anche su campo codice
This commit is contained in:
parent
a574112f4e
commit
793e541e73
@ -26,7 +26,7 @@ $intestazione_prezzo = ($options['dir'] == 'uscita' ? tr('Prezzo di acquisto') :
|
||||
echo '
|
||||
<div class="row">
|
||||
<div class="col-md-offset-4 col-md-4">
|
||||
{[ "type": "text", "label": "'.tr('Barcode').'", "name": "barcode", "value": "", "icon-before": "<i class=\"fa fa-barcode\"></i>" ]}
|
||||
{[ "type": "text", "label": "", "name": "barcode", "value": "", "icon-before": "<i class=\"fa fa-barcode\"></i>" ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -92,7 +92,7 @@ $("#barcode").off("keyup").on("keyup", function (event) {
|
||||
return;
|
||||
}
|
||||
|
||||
$.getJSON(globals.rootdir + "/ajax_select.php?op=articoli_barcode&barcode=" + barcode + "&id_anagrafica='.$options['idanagrafica'].'",
|
||||
$.getJSON(globals.rootdir + "/ajax_select.php?op=articoli_barcode&search=" + barcode + "&id_anagrafica='.$options['idanagrafica'].'",
|
||||
function(response) {
|
||||
let result = response.results[0];
|
||||
if(!result){
|
||||
|
@ -247,9 +247,13 @@ switch ($resource) {
|
||||
LEFT JOIN mg_fornitore_articolo ON mg_fornitore_articolo.id_articolo = mg_articoli.id AND mg_fornitore_articolo.deleted_at IS NULL AND mg_fornitore_articolo.id_fornitore = '.prepare($id_anagrafica).'
|
||||
|where|';
|
||||
|
||||
$where[] = 'barcode='.prepare(get('barcode'));
|
||||
$where[] = 'mg_articoli.attivo = 1';
|
||||
$where[] = 'mg_articoli.deleted_at IS NULL';
|
||||
|
||||
if (!empty($search)) {
|
||||
$search_fields[] = 'mg_articoli.codice LIKE '.prepare('%'.$search.'%');
|
||||
$search_fields[] = 'mg_articoli.barcode LIKE '.prepare('%'.$search.'%');
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -27,12 +27,12 @@ include_once __DIR__.'/../../core.php';
|
||||
<input type="hidden" name="op" value="add">
|
||||
<input type="hidden" name="backto" value="record-edit">
|
||||
|
||||
<div class="row hidden" id="barcode-row">
|
||||
<div class="col-md-12">
|
||||
{["type": "text", "label": "<?php echo tr('Barcode'); ?>", "name": "barcode", "icon-before": "<i class=\"fa fa-barcode\"></i>" ]}
|
||||
<div class="row">
|
||||
<div class="col-md-offset-4 col-md-4">
|
||||
{["type": "text", "label": "<?php echo tr('Ricerca con lettore');?>", "name": "barcode", "icon-before": "<i class=\"fa fa-barcode\"></i>" ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
{["type": "select", "label": "<?php echo tr('Articolo'); ?>", "name": "idarticolo", "ajax-source": "articoli", "value": "", "required": 1, "select-options": {"permetti_movimento_a_zero": 1, "idanagrafica": <?php echo setting('Azienda predefinita'); ?>, "idsede_partenza": 0, "idsede_destinazione": 0} ]}
|
||||
@ -94,6 +94,9 @@ echo '
|
||||
<script>
|
||||
// Lettura codici da lettore barcode
|
||||
$(document).unbind("keyup");
|
||||
$(document).ready(function(){
|
||||
$("#barcode").focus();
|
||||
});
|
||||
$(document).on("keyup", function (event) {
|
||||
if ($(":focus").is("input, textarea")) {
|
||||
return;
|
||||
@ -104,12 +107,11 @@ echo '
|
||||
let barcode = $("#barcode");
|
||||
|
||||
if (key === 13) {
|
||||
let search = barcode.val().replace(/\W/g, "");
|
||||
let search = barcode.val().replace(/[^a-z0-9\s\-\.\/\\|]+/gmi, "");
|
||||
ricercaBarcode(search);
|
||||
} else if (key === 8) {
|
||||
barcode.val(barcode.val().substr(0, barcode.val().length - 1));
|
||||
} else if(key <= 90 && key >= 48) {
|
||||
$("#barcode-row").removeClass("hidden");
|
||||
barcode.val(barcode.val() + String.fromCharCode(key));
|
||||
}
|
||||
});
|
||||
@ -166,7 +168,7 @@ echo '
|
||||
if(data.results.length === 1) {
|
||||
$("#barcode").val("");
|
||||
|
||||
var record = data.results[0].children[0];
|
||||
var record = data.results[0];
|
||||
$("#idarticolo").selectSetNew(record.id, record.text, record);
|
||||
|
||||
salva($("#aggiungi"));
|
||||
@ -189,6 +191,13 @@ echo '
|
||||
|
||||
if (valid) {
|
||||
let articolo = $("#idarticolo").selectData();
|
||||
if( articolo.descrizione==undefined ){
|
||||
articolo.descrizione = $( $("#idarticolo").selectData()["element"] ).data("descrizione");
|
||||
articolo.codice = $( $("#idarticolo").selectData()["element"] ).data("codice");
|
||||
articolo.um = $( $("#idarticolo").selectData()["element"] ).data("um");
|
||||
articolo.prezzo_acquisto = $( $("#idarticolo").selectData()["element"] ).data("prezzo_acquisto");
|
||||
articolo.prezzo_vendita = $( $("#idarticolo").selectData()["element"] ).data("prezzo_vendita");
|
||||
}
|
||||
let prezzo_acquisto = parseFloat(articolo.prezzo_acquisto);
|
||||
let prezzo_vendita = parseFloat(articolo.prezzo_vendita);
|
||||
|
||||
@ -211,16 +220,15 @@ echo '
|
||||
text = "Spostamento";
|
||||
qta_rimanente = parseFloat(articolo.qta);
|
||||
}
|
||||
|
||||
|
||||
if (articolo.descrizione) {
|
||||
let testo = $("#info-articolo").html();
|
||||
|
||||
|
||||
testo = testo.replace("|alert-type|", alert_type)
|
||||
.replace("|icon|", icon)
|
||||
.replace("|descrizione|", articolo.descrizione)
|
||||
.replace("|codice|", articolo.codice)
|
||||
.replace("|misura|", articolo.um)
|
||||
.replace("|misura|", articolo.um)
|
||||
.replace("|descrizione-movimento|", text)
|
||||
.replace("|movimento|", qta_movimento.toLocale())
|
||||
.replace("|rimanente|", qta_rimanente.toLocale())
|
||||
|
Loading…
x
Reference in New Issue
Block a user