Preselected supplier when there's only one

This commit is contained in:
Cédric Salvador 2013-06-10 18:10:06 +02:00
parent 5f526fd84a
commit 8666725c62

View File

@ -1829,7 +1829,7 @@ class Form
* @param string $htmlname Name of HTML field * @param string $htmlname Name of HTML field
* @return void * @return void
*/ */
function select_product_fourn_price($productid,$htmlname='productfournpriceid') function select_product_fourn_price($productid,$htmlname='productfournpriceid', $showempty=0)
{ {
global $langs,$conf; global $langs,$conf;
@ -1860,9 +1860,15 @@ class Form
{ {
$form.= '<option value="0">-- '.$langs->trans("NoSupplierPriceDefinedForThisProduct").' --</option>'; $form.= '<option value="0">-- '.$langs->trans("NoSupplierPriceDefinedForThisProduct").' --</option>';
} }
else if ($num == 1) {
$objp = $this->db->fetch_object($result);
$form = $objp->nom;
$form .= '<input type="hidden" name="'.$htmlname.'" value="'.$objp->idprodfournprice.'">';
}
else else
{ {
$form.= '<option value="0">&nbsp;</option>'; $form = '<select class="flat" name="'.$htmlname.'">';
if($showempty) $form.= '<option value="0">&nbsp;</option>';
$i = 0; $i = 0;
while ($i < $num) while ($i < $num)