diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index 1ebadc6541d14..b90d55d2aa63b 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -54,6 +54,7 @@ $category = GETPOST('category', 'alphanohtml'); // Can be id of category or 'supplements' $action = GETPOST('action', 'aZ09'); $term = GETPOST('term', 'alpha'); +$search_term = GETPOST('search_term', 'alpha'); $id = GETPOSTINT('id'); $search_start = GETPOSTINT('search_start'); $search_limit = GETPOSTINT('search_limit'); @@ -130,11 +131,11 @@ } else { echo 'Failed to load category with id='.dol_escape_htmltag($category); } -} elseif ($action == 'search' && $term != '' && $user->hasRight('takepos', 'run')) { +} elseif ($action == 'search' && $search_term != '' && $user->hasRight('takepos', 'run')) { top_httphead('application/json'); // Search barcode into thirdparties. If found, it means we want to change thirdparties. - $result = $thirdparty->fetch('', '', '', $term); + $result = $thirdparty->fetch('', '', '', $search_term); if ($result && $thirdparty->id > 0) { $rows = array(); @@ -187,7 +188,7 @@ $barcode_value_list = array(); $barcode_offset = 0; - $barcode_length = dol_strlen($term); + $barcode_length = dol_strlen($search_term); if ($barcode_length == $barcode_char_nb) { $rows = array(); @@ -195,7 +196,7 @@ foreach ($barcode_rules_list as $barcode_rule_arr) { $code = $barcode_rule_arr['code']; $char_nb = $barcode_rule_arr['char_nb']; - $barcode_value_list[$code] = substr($term, $barcode_offset, $char_nb); + $barcode_value_list[$code] = substr($search_term, $barcode_offset, $char_nb); $barcode_offset += $char_nb; } @@ -209,7 +210,7 @@ $sql .= " AND EXISTS (SELECT cp.fk_product FROM " . $db->prefix() . "categorie_product as cp WHERE cp.fk_product = p.rowid AND cp.fk_categorie IN (".$db->sanitize($filteroncategids)."))"; } $sql .= " AND tosell = 1"; - $sql .= " AND (barcode IS NULL OR barcode <> '" . $db->escape($term) . "')"; + $sql .= " AND (barcode IS NULL OR barcode <> '" . $db->escape($search_term) . "')"; $resql = $db->query($sql); if ($resql && $db->num_rows($resql) == 1) { @@ -249,7 +250,7 @@ 'label' => $obj->label, 'tosell' => $obj->tosell, 'tobuy' => $obj->tobuy, - 'barcode' => $term, // there is only one product matches the barcode rule and so the term is considered as the barcode of this product + 'barcode' => $search_term, // there is only one product matches the barcode rule and so the term is considered as the barcode of this product 'price' => empty($objProd->multiprices[$pricelevel]) ? $obj->price : $objProd->multiprices[$pricelevel], 'price_ttc' => empty($objProd->multiprices_ttc[$pricelevel]) ? $obj->price_ttc : $objProd->multiprices_ttc[$pricelevel], 'object' => 'product', @@ -317,7 +318,7 @@ if (getDolGlobalInt('TAKEPOS_PRODUCT_IN_STOCK') == 1 && getDolGlobalInt('CASHDESK_ID_WAREHOUSE'.$_SESSION['takeposterminal'])) { $sql .= ' AND ps.reel > 0'; } - $sql .= natural_search(array('ref', 'label', 'barcode'), $term); + $sql .= natural_search(array('ref', 'label', 'barcode'), $search_term); // Add where from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 62a1d45ce34c0..0656fddcb9734 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -744,7 +744,7 @@ function Search2(keyCodeForEnter, moreorless) { pageproducts = 0; jQuery(".wrapper2 .catwatermark").hide(); var nbsearchresults = 0; - $.getJSON('/takepos/ajax/ajax.php?action=search&token=&term=' + search_term + '&thirdpartyid=' + jQuery('#thirdpartyid').val() + '&search_start=' + search_start + '&search_limit=' + search_limit, function (data) { + $.getJSON('/takepos/ajax/ajax.php?action=search&token=&search_term=' + search_term + '&thirdpartyid=' + jQuery('#thirdpartyid').val() + '&search_start=' + search_start + '&search_limit=' + search_limit, function (data) { for (i = 0; i < ; i++) { if (typeof (data[i]) == "undefined") { $("#prowatermark" + i).html("");