Fix: Can autoselect warehouse if only one warehouse
This commit is contained in:
parent
31f2d8922d
commit
cba1d73dd4
@ -106,7 +106,7 @@ if (! empty($conf->stock->enabled))
|
|||||||
print '<td>';
|
print '<td>';
|
||||||
$disabled=0;
|
$disabled=0;
|
||||||
if (! empty($conf->global->CASHDESK_ID_WAREHOUSE)) $disabled=1; // If a particular stock is defined, we disable choice
|
if (! empty($conf->global->CASHDESK_ID_WAREHOUSE)) $disabled=1; // If a particular stock is defined, we disable choice
|
||||||
print $formproduct->selectWarehouses(GETPOST('warehouseid')?GETPOST('warehouseid'):$conf->global->CASHDESK_ID_WAREHOUSE,'warehouseid','',!$disabled,$disabled);
|
print $formproduct->selectWarehouses((GETPOST('warehouseid')?GETPOST('warehouseid'):(empty($conf->global->CASHDESK_ID_WAREHOUSE)?'ifone':$conf->global->CASHDESK_ID_WAREHOUSE)),'warehouseid','',!$disabled,$disabled);
|
||||||
//print '<input name="warehouse_id" class="texte_login" type="warehouse_id" value="" />';
|
//print '<input name="warehouse_id" class="texte_login" type="warehouse_id" value="" />';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|||||||
@ -101,9 +101,9 @@ class FormProduct
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return list of possible payments modes
|
* Return list of warehouses
|
||||||
*
|
*
|
||||||
* @param int $selected Id du mode de paiement pre-selectionne
|
* @param int $selected Id of preselected warehouse ('' for no value, 'ifone'=select value if one value otherwise no value)
|
||||||
* @param string $htmlname Name of html select html
|
* @param string $htmlname Name of html select html
|
||||||
* @param string $filtertype For filter
|
* @param string $filtertype For filter
|
||||||
* @param int $empty 1=Can be empty, 0 if not
|
* @param int $empty 1=Can be empty, 0 if not
|
||||||
@ -119,23 +119,22 @@ class FormProduct
|
|||||||
dol_syslog(get_class($this)."::selectWarehouses $selected, $htmlname, $filtertype, $empty, $disabled, $fk_product",LOG_DEBUG);
|
dol_syslog(get_class($this)."::selectWarehouses $selected, $htmlname, $filtertype, $empty, $disabled, $fk_product",LOG_DEBUG);
|
||||||
|
|
||||||
$this->loadWarehouses($fk_product);
|
$this->loadWarehouses($fk_product);
|
||||||
|
$nbofwarehouses=count($this->cache_warehouses);
|
||||||
|
|
||||||
$out='<select class="flat"'.($disabled?' disabled="disabled"':'').' id="'.$htmlname.'" name="'.($htmlname.($disabled?'_disabled':'')).'">';
|
$out='<select class="flat"'.($disabled?' disabled="disabled"':'').' id="'.$htmlname.'" name="'.($htmlname.($disabled?'_disabled':'')).'">';
|
||||||
if ($empty) $out.='<option value="-1">'.($empty_label?$empty_label:' ').'</option>';
|
if ($empty) $out.='<option value="-1">'.($empty_label?$empty_label:' ').'</option>';
|
||||||
foreach($this->cache_warehouses as $id => $arraytypes)
|
foreach($this->cache_warehouses as $id => $arraytypes)
|
||||||
{
|
{
|
||||||
$out.='<option value="'.$id.'"';
|
$out.='<option value="'.$id.'"';
|
||||||
// Si selected est text, on compare avec code, sinon avec id
|
if ($selected == $id || ($selected == 'ifone' && $nbofwarehouses == 1)) $out.=' selected="selected"';
|
||||||
if ($selected == $id) $out.=' selected="selected"';
|
|
||||||
$out.='>';
|
$out.='>';
|
||||||
$out.=$arraytypes['label'];
|
$out.=$arraytypes['label'];
|
||||||
if ($fk_product) $out.=' ('.$langs->trans("Stock").': '.($arraytypes['stock']>0?$arraytypes['stock']:'?').')';
|
if ($fk_product) $out.=' ('.$langs->trans("Stock").': '.($arraytypes['stock']>0?$arraytypes['stock']:'?').')';
|
||||||
$out.='</option>';
|
$out.='</option>';
|
||||||
}
|
}
|
||||||
$out.='</select>';
|
$out.='</select>';
|
||||||
if ($disabled) $out.='<input type="hidden" name="'.$htmlname.'" value="'.$selected.'">';
|
if ($disabled) $out.='<input type="hidden" name="'.$htmlname.'" value="'.(($selected>0)?$selected:'').'">';
|
||||||
|
|
||||||
//count($this->cache_warehouses);
|
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user