Merge pull request #22807 from hregis/new_can_sort_and_preselected_best_supplier_price

NEW can sort and preselected best supplier price
This commit is contained in:
Laurent Destailleur 2022-11-12 12:56:15 +01:00 committed by GitHub
commit 98c9dd6c5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3679,7 +3679,11 @@ class Form
$sql .= " AND p.tobuy = 1";
$sql .= " AND s.fournisseur = 1";
$sql .= " AND p.rowid = ".((int) $productid);
$sql .= " ORDER BY s.nom, pfp.ref_fourn DESC";
if (empty($conf->global->PRODUCT_BEST_SUPPLIER_PRICE_PRESELECTED)) {
$sql .= " ORDER BY s.nom, pfp.ref_fourn DESC";
} else {
$sql .= " ORDER BY pfp.unitprice ASC";
}
dol_syslog(get_class($this)."::select_product_fourn_price", LOG_DEBUG);
$result = $this->db->query($sql);
@ -3701,7 +3705,7 @@ class Form
$opt = '<option value="'.$objp->idprodfournprice.'"';
//if there is only one supplier, preselect it
if ($num == 1 || ($selected_supplier > 0 && $objp->fk_soc == $selected_supplier)) {
if ($num == 1 || ($selected_supplier > 0 && $objp->fk_soc == $selected_supplier) || ($i == 0 && !empty($conf->global->PRODUCT_BEST_SUPPLIER_PRICE_PRESELECTED))) {
$opt .= ' selected';
}
$opt .= '>'.$objp->name.' - '.$objp->ref_fourn.' - ';