New: Sort combo list for type of thirdparties.
This commit is contained in:
parent
93c5720579
commit
953f638cb4
@ -3719,9 +3719,10 @@ class Form
|
||||
* @param int $translate Translate and encode value
|
||||
* @param int $maxlen Length maximum for labels
|
||||
* @param int $disabled Html select box is disabled
|
||||
* @param int $sort 'ASC' or 'DESC' =Sort on label, '' or 'NONE'=Do not sort
|
||||
* @return string HTML select string
|
||||
*/
|
||||
function selectarray($htmlname, $array, $id='', $show_empty=0, $key_in_label=0, $value_as_key=0, $option='', $translate=0, $maxlen=0, $disabled=0)
|
||||
function selectarray($htmlname, $array, $id='', $show_empty=0, $key_in_label=0, $value_as_key=0, $option='', $translate=0, $maxlen=0, $disabled=0, $sort='')
|
||||
{
|
||||
global $langs;
|
||||
|
||||
@ -3736,28 +3737,30 @@ class Form
|
||||
|
||||
if (is_array($array))
|
||||
{
|
||||
// Translate
|
||||
if ($translate)
|
||||
{
|
||||
foreach($array as $key => $value) $array[$key]=$langs->trans($value);
|
||||
}
|
||||
|
||||
// Sort
|
||||
if ($sort == 'ASC') asort($array);
|
||||
elseif ($sort == 'DESC') arsort($array);
|
||||
|
||||
foreach($array as $key => $value)
|
||||
{
|
||||
$out.='<option value="'.$key.'"';
|
||||
// Si il faut pre-selectionner une valeur
|
||||
if ($id != '' && $id == $key)
|
||||
{
|
||||
$out.=' selected="selected"';
|
||||
}
|
||||
|
||||
if ($id != '' && $id == $key) $out.=' selected="selected"'; // To preselect a value
|
||||
$out.='>';
|
||||
|
||||
$newval=($translate?$langs->trans(ucfirst($value)):$value);
|
||||
if ($key_in_label)
|
||||
{
|
||||
$selectOptionValue = dol_htmlentitiesbr($key.' - '.($maxlen?dol_trunc($newval,$maxlen):$newval));
|
||||
$selectOptionValue = dol_htmlentitiesbr($key.' - '.($maxlen?dol_trunc($value,$maxlen):$value));
|
||||
}
|
||||
else
|
||||
{
|
||||
$selectOptionValue = dol_htmlentitiesbr($maxlen?dol_trunc($newval,$maxlen):$newval);
|
||||
if ($value == '' || $value == '-') {
|
||||
$selectOptionValue=' ';
|
||||
}
|
||||
$selectOptionValue = dol_htmlentitiesbr($maxlen?dol_trunc($value,$maxlen):$value);
|
||||
if ($value == '' || $value == '-') $selectOptionValue=' ';
|
||||
}
|
||||
$out.=$selectOptionValue;
|
||||
$out.="</option>\n";
|
||||
|
||||
@ -910,11 +910,11 @@ else
|
||||
|
||||
// Type - Size
|
||||
print '<tr><td>'.$langs->trans("ThirdPartyType").'</td><td>'."\n";
|
||||
print $form->selectarray("typent_id",$formcompany->typent_array(0), $object->typent_id);
|
||||
print $form->selectarray("typent_id", $formcompany->typent_array(0), $object->typent_id, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT));
|
||||
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
|
||||
print '</td>';
|
||||
print '<td>'.$langs->trans("Staff").'</td><td>';
|
||||
print $form->selectarray("effectif_id",$formcompany->effectif_array(0), $object->effectif_id);
|
||||
print $form->selectarray("effectif_id", $formcompany->effectif_array(0), $object->effectif_id);
|
||||
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
|
||||
print '</td></tr>';
|
||||
|
||||
@ -1360,7 +1360,7 @@ else
|
||||
|
||||
// Type - Size
|
||||
print '<tr><td>'.$langs->trans("ThirdPartyType").'</td><td>';
|
||||
print $form->selectarray("typent_id",$formcompany->typent_array(0), $object->typent_id);
|
||||
print $form->selectarray("typent_id",$formcompany->typent_array(0), $object->typent_id, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT));
|
||||
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
|
||||
print '</td>';
|
||||
print '<td>'.$langs->trans("Staff").'</td><td>';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user