FIX making search in takepos broken when TAKEPOS_PRODUCT_IN_STOCK is set
This commit is contained in:
parent
6cb1424824
commit
ad07f3b7e8
@ -169,7 +169,7 @@ if ($action == 'getProducts') {
|
||||
$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($term) . "')";
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql && $db->num_rows($resql) == 1) {
|
||||
@ -241,9 +241,10 @@ if ($action == 'getProducts') {
|
||||
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'product as p';
|
||||
if (getDolGlobalInt('TAKEPOS_PRODUCT_IN_STOCK') == 1) {
|
||||
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as ps';
|
||||
$sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'product_stock as ps';
|
||||
$sql .= ' ON (p.rowid = ps.fk_product';
|
||||
$sql .= " AND ps.fk_entrepot = ".((int) getDolGlobalInt("CASHDESK_ID_WAREHOUSE".$_SESSION['takeposterminal']));
|
||||
$sql .= ')';
|
||||
}
|
||||
|
||||
// Add tables from hooks
|
||||
@ -257,7 +258,7 @@ if ($action == 'getProducts') {
|
||||
if ($filteroncategids) {
|
||||
$sql .= ' AND EXISTS (SELECT cp.fk_product FROM '.MAIN_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 p.tosell = 1';
|
||||
if (getDolGlobalInt('TAKEPOS_PRODUCT_IN_STOCK') == 1) {
|
||||
$sql .= ' AND ps.reel > 0';
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user