Merge pull request #14586 from ptibogxiv/patch-353
NEW change thirdparty with barcode scan in takepos
This commit is contained in:
commit
d11d02a23a
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2004 Andreu Bisquerra <jove@bisquerra.com>
|
||||
/* Copyright (C) 2020 Thibault FOUCART <support@ptibogxiv.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -68,6 +69,24 @@ if ($action == 'getProducts') {
|
||||
echo 'Failed to load category with id='.$category;
|
||||
}
|
||||
} elseif ($action == 'search' && $term != '') {
|
||||
// Change thirdparty with barcode
|
||||
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
|
||||
|
||||
$thirdparty = new Societe($db);
|
||||
$result = $thirdparty->fetch('', '', '', $term);
|
||||
|
||||
if ( $result && $thirdparty->id > 0) {
|
||||
$rows = array();
|
||||
$rows[] = array(
|
||||
'rowid' => $thirdparty->id,
|
||||
'name' => $thirdparty->name,
|
||||
'barcode' => $thirdparty->barcode,
|
||||
'object' => 'thirdparty'
|
||||
);
|
||||
echo json_encode($rows);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Define $filteroncategids, the filter on category ID if there is a Root category defined.
|
||||
$filteroncategids = '';
|
||||
if ($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0) { // A root category is defined, we must filter on products inside this category tree
|
||||
@ -101,7 +120,8 @@ if ($action == 'getProducts') {
|
||||
'tosell' => $obj->tosell,
|
||||
'tobuy' => $obj->tobuy,
|
||||
'barcode' => $obj->barcode,
|
||||
'price' => $obj->price
|
||||
'price' => $obj->price,
|
||||
'object' => 'product'
|
||||
//'price_formated' => price(price2num($obj->price, 'MU'), 1, $langs, 1, -1, -1, $conf->currency)
|
||||
);
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2018 Andreu Bisquerra <jove@bisquerra.com>
|
||||
* Copyright (C) 2019 Josep Lluís Amador <joseplluis@lliuretic.cat>
|
||||
* Copyright (C) 2020 Thibault FOUCART <support@ptibogxiv.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -406,6 +407,15 @@ function ClickProduct(position) {
|
||||
ClearSearch();
|
||||
}
|
||||
|
||||
function ChangeThirdparty(idcustomer) {
|
||||
console.log("ChangeThirdparty");
|
||||
// Call page list.php to change customer
|
||||
$("#poslines").load("../societe/list.php?action=change&contextpage=poslist&idcustomer="+idcustomer+"&place="+place+"", function() {
|
||||
});
|
||||
|
||||
ClearSearch();
|
||||
}
|
||||
|
||||
function deleteline() {
|
||||
console.log("Delete line");
|
||||
$("#poslines").load("invoice.php?action=deleteline&place="+place+"&idline="+selectedline, function() {
|
||||
@ -531,7 +541,11 @@ function Search2(keyCodeForEnter) {
|
||||
// If there is only 1 answer
|
||||
if ($('#search').val().length > 0 && data.length == 1) {
|
||||
console.log($('#search').val()+' - '+data[0]['barcode']);
|
||||
if ($('#search').val() == data[0]['barcode']) {
|
||||
if ($('#search').val() == data[0]['barcode'] && 'thirdparty' == data[0]['object']) {
|
||||
console.log("There is only 1 answer with barcode matching the search, so we change the thirdparty "+data[0]['rowid']);
|
||||
ChangeThirdparty(data[0]['rowid']);
|
||||
}
|
||||
else if ($('#search').val() == data[0]['barcode'] && 'product' == data[0]['object']) {
|
||||
console.log("There is only 1 answer with barcode matching the search, so we add the product in basket");
|
||||
ClickProduct(0);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user