Merge pull request #15550 from OPEN-DSI/new-supplier-product-list-with-stock
NEW show stock in supplier product select list
This commit is contained in:
commit
084b2411df
@ -2743,7 +2743,7 @@ class Form
|
||||
public function select_produits_fournisseurs_list($socid, $selected = '', $htmlname = 'productid', $filtertype = '', $filtre = '', $filterkey = '', $statut = -1, $outputmode = 0, $limit = 100, $alsoproductwithnosupplierprice = 0, $morecss = '')
|
||||
{
|
||||
// phpcs:enable
|
||||
global $langs, $conf, $db;
|
||||
global $langs, $conf, $db, $user;
|
||||
|
||||
$out = '';
|
||||
$outarray = array();
|
||||
@ -2757,6 +2757,9 @@ class Form
|
||||
}
|
||||
|
||||
$sql = "SELECT p.rowid, p.ref, p.label, p.price, p.duration, p.fk_product_type,";
|
||||
if (!empty($conf->stock->enabled)) {
|
||||
$sql .= " p.stock,";
|
||||
}
|
||||
$sql .= " pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.remise_percent, pfp.remise, pfp.unitprice,";
|
||||
$sql .= " pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, pfp.fk_soc, s.nom as name,";
|
||||
$sql .= " pfp.supplier_reputation";
|
||||
@ -2974,6 +2977,43 @@ class Form
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($conf->stock->enabled) && isset($objp->stock) && ($objp->fk_product_type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)))
|
||||
{
|
||||
if (!empty($user->rights->stock->lire)) {
|
||||
$optlabel .= ' - '.$langs->trans("Stock").':'.$objp->stock;
|
||||
|
||||
if ($objp->stock > 0) {
|
||||
$outval .= ' - <span class="product_line_stock_ok">';
|
||||
} elseif ($objp->stock <= 0) {
|
||||
$outval .= ' - <span class="product_line_stock_too_low">';
|
||||
}
|
||||
$outval .= $langs->transnoentities("Stock").':'.$objp->stock;
|
||||
$outval .= '</span>';
|
||||
if (empty($novirtualstock) && !empty($conf->global->STOCK_SHOW_VIRTUAL_STOCK_IN_PRODUCTS_COMBO)) // Warning, this option may slow down combo list generation
|
||||
{
|
||||
$langs->load("stocks");
|
||||
|
||||
$tmpproduct = new Product($this->db);
|
||||
$tmpproduct->fetch($objp->rowid, '', '', '', 1, 1, 1); // Load product without lang and prices arrays (we just need to make ->virtual_stock() after)
|
||||
$tmpproduct->load_virtual_stock();
|
||||
$virtualstock = $tmpproduct->stock_theorique;
|
||||
|
||||
$optlabel .= ' - '.$langs->trans("VirtualStock").':'.$virtualstock;
|
||||
|
||||
$outval .= ' - '.$langs->transnoentities("VirtualStock").':';
|
||||
if ($virtualstock > 0) {
|
||||
$outval .= '<span class="product_line_stock_ok">';
|
||||
} elseif ($virtualstock <= 0) {
|
||||
$outval .= '<span class="product_line_stock_too_low">';
|
||||
}
|
||||
$outval .= $virtualstock;
|
||||
$outval .= '</span>';
|
||||
|
||||
unset($tmpproduct);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$opt = '<option value="'.$outkey.'"';
|
||||
if ($selected && $selected == $objp->idprodfournprice) $opt .= ' selected';
|
||||
if (empty($objp->idprodfournprice) && empty($alsoproductwithnosupplierprice)) $opt .= ' disabled';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user