Skip to content

Commit

Permalink
new: add warehouseId parameters inselect_produit to limit result to e…
Browse files Browse the repository at this point in the history
…xisting product in select
  • Loading branch information
FHenry committed Jul 26, 2024
1 parent 0886b84 commit f6dda48
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions htdocs/core/class/html.form.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2667,7 +2667,7 @@ public function select_produits($selected = 0, $htmlname = 'productid', $filtert
// mode=1 means customers products
$urloption = ($socid > 0 ? 'socid=' . $socid . '&' : '') . 'htmlname=' . $htmlname . '&outjson=1&price_level=' . $price_level . '&type=' . $filtertype . '&mode=1&status=' . $status . '&status_purchase=' . $status_purchase . '&finished=' . $finished . '&hidepriceinlabel=' . $hidepriceinlabel . '&warehousestatus=' . $warehouseStatus;
if ((int) $warehouseId>0) {
$urloption .= '&warehouseId=' . $warehouseId;
$urloption .= '&warehouseid=' . (int) $warehouseId;
}
$out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT . '/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 1, $ajaxoptions);

Expand Down Expand Up @@ -2991,7 +2991,7 @@ public function select_produits_list($selected = 0, $htmlname = 'productid', $fi
$sql .= ' AND e.statut IN (' . $this->db->sanitize($this->db->escape(implode(',', $warehouseStatusArray))) . ')'; // Return line if product is inside the selected stock. If not, an empty line will be returned so we will count 0.
}
if (((int) $warehouseId) > 0) {
$sql .= " AND e.rowid = " . (int) $warehouseIds . ")";
$sql .= " AND e.rowid = " . (int) $warehouseId . " AND ps.reel>0";
}
}

Expand Down
3 changes: 2 additions & 1 deletion htdocs/product/ajax/products.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
$alsoproductwithnosupplierprice = GETPOSTINT('alsoproductwithnosupplierprice');
$warehouseStatus = GETPOST('warehousestatus', 'alpha');
$hidepriceinlabel = GETPOSTINT('hidepriceinlabel');
$warehouseId = GETPOST('warehouseid', 'int');

// Security check
restrictedArea($user, 'produit|service|commande|propal|facture', 0, 'product&product');
Expand Down Expand Up @@ -308,7 +309,7 @@
}

if (empty($mode) || $mode == 1) { // mode=1: customer
$arrayresult = $form->select_produits_list("", $htmlname, $type, 0, $price_level, $searchkey, $status, $finished, $outjson, $socid, '1', 0, '', $hidepriceinlabel, $warehouseStatus, $status_purchase);
$arrayresult = $form->select_produits_list("", $htmlname, $type, 0, $price_level, $searchkey, $status, $finished, $outjson, $socid, '1', 0, '', $hidepriceinlabel, $warehouseStatus, $status_purchase, $warehouseId);
} elseif ($mode == 2) { // mode=2: supplier
$arrayresult = $form->select_produits_fournisseurs_list($socid, "", $htmlname, $type, "", $searchkey, $status, $outjson, 0, $alsoproductwithnosupplierprice);
}
Expand Down

0 comments on commit f6dda48

Please sign in to comment.