From a963d6c0fcbcbf965387e675fd01da049f381e46 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 29 Aug 2020 16:05:14 +0200 Subject: [PATCH 1/3] NEW change thirdparty with barcode scan in takepos --- htdocs/takepos/ajax/ajax.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index 7c4471b0ec8..56a437f2f6a 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2020 Thibault FOUCART * * 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) ); } From d3024fdd1c3d0af3f7805ff989db25a764d2d8dc Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 29 Aug 2020 16:07:01 +0200 Subject: [PATCH 2/3] Update index.php --- htdocs/takepos/index.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index ee304b7438e..ca6ea987456 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -1,6 +1,7 @@ * Copyright (C) 2019 Josep LluĂ­s Amador + * Copyright (C) 2020 Thibault FOUCART * * 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 @@ -399,6 +400,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() { @@ -524,7 +534,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); } From e18b85ea872c5eef72e43b503a791c0b7e87c8a0 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sat, 29 Aug 2020 14:08:42 +0000 Subject: [PATCH 3/3] Fixing style errors. --- htdocs/takepos/ajax/ajax.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index 56a437f2f6a..7f9555c3226 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -69,13 +69,13 @@ if ($action == 'getProducts') { echo 'Failed to load category with id='.$category; } } elseif ($action == 'search' && $term != '') { - // Change thirdparty with barcode + // 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) { + $thirdparty = new Societe($db); + $result = $thirdparty->fetch('', '', '', $term); + + if ( $result && $thirdparty->id > 0) { $rows = array(); $rows[] = array( 'rowid' => $thirdparty->id, @@ -83,9 +83,9 @@ if ($action == 'getProducts') { 'barcode' => $thirdparty->barcode, 'object' => 'thirdparty' ); - echo json_encode($rows); - exit; - } + echo json_encode($rows); + exit; + } // Define $filteroncategids, the filter on category ID if there is a Root category defined. $filteroncategids = ''; @@ -121,7 +121,7 @@ if ($action == 'getProducts') { 'tobuy' => $obj->tobuy, 'barcode' => $obj->barcode, 'price' => $obj->price, - 'object' => 'product' + 'object' => 'product' //'price_formated' => price(price2num($obj->price, 'MU'), 1, $langs, 1, -1, -1, $conf->currency) ); }