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) ); }