diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 97ba9ccbcd7..f8949593e43 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -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.='\n";
diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php
index 67c58c9d664..fb273b79ab3 100644
--- a/htdocs/societe/soc.php
+++ b/htdocs/societe/soc.php
@@ -910,11 +910,11 @@ else
// Type - Size
print '
| '.$langs->trans("ThirdPartyType").' | '."\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 ' | ';
print ''.$langs->trans("Staff").' | ';
- 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 ' |
';
@@ -1360,7 +1360,7 @@ else
// Type - Size
print '| '.$langs->trans("ThirdPartyType").' | ';
- 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 ' | ';
print ''.$langs->trans("Staff").' | ';
|