New: The combo list of juridical status is now sorted

This commit is contained in:
Laurent Destailleur 2014-05-04 23:46:36 +02:00
parent b2da98ea18
commit bcdf3e8a51
5 changed files with 55 additions and 47 deletions

View File

@ -47,20 +47,21 @@ For users:
whatever is its status.
- New: Add filter date in bank writing list page.
- New: Extrafields can be used as substitution key %EXTRA_XXX% into emails texts for members.
- Fix: Project Task numbering customs rule works.
- Fix: Add actions events not implemented.
- Fix: Price min of composition is not supplier price min by quantity.
- Fix: [ bug #1356 ] Bank accountancy number is limited to 8 numbers.
- New: Add categories translation.
- New: Enable option "clone target emailing".
- New: Improved tax module: Add specific page for salaries payment
- New: Add composer.json file so Dolibarr can be publish onto packagist.org.
TODO
- New: Predefined product and free product use same form.
- New: The combo list of juridical status is now sorted
- New: [ task #926 ] Add extrafield feature on order lines.
- New: [ task #927 ] Add extrafield feature on Proposal lines.
- New: [ task #928 ] Add extrafield feature on invoice lines.
- Fix: Project Task numbering customs rule works.
- Fix: Add actions events not implemented.
- Fix: Price min of composition is not supplier price min by quantity.
- Fix: [ bug #1356 ] Bank accountancy number is limited to 8 numbers.
TODO
- New: Predefined product and free product use same form.
For translators:
- Update language files.

View File

@ -392,7 +392,7 @@ if ($action == 'edit' || $action == 'updateedit')
print '<tr '.$bc[$var].'><td>'.$langs->trans("JuridicalStatus").'</td><td>';
if ($mysoc->country_code)
{
$formcompany->select_forme_juridique($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE,$mysoc->country_code);
print $formcompany->select_juridicalstatus($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE,$mysoc->country_code);
}
else
{

View File

@ -415,6 +415,7 @@ class FormCompany
* @param mixed $country_codeid 0=liste tous pays confondus, sinon code du pays a afficher
* @param string $filter Add a SQL filter on list
* @return void
* @deprecated Use print xxx->select_juridicalstatus instead
*/
function select_forme_juridique($selected='', $country_codeid=0, $filter='')
{
@ -425,8 +426,8 @@ class FormCompany
* Retourne la liste deroulante des formes juridiques tous pays confondus ou pour un pays donne.
* Dans le cas d'une liste tous pays confondu, on affiche une rupture sur le pays
*
* @param string $selected Code forme juridique a pre-selectionne
* @param int $country_codeid 0=liste tous pays confondus, sinon code du pays a afficher
* @param string $selected Preselected code of juridical type
* @param int $country_codeid 0=list for all countries, otherwise list only country requested
* @param string $filter Add a SQL filter on list
* @return string String with HTML select
*/
@ -438,56 +439,62 @@ class FormCompany
$out='';
// On recherche les formes juridiques actives des pays actifs
$sql = "SELECT f.rowid, f.code as code , f.libelle as nom, f.active, p.libelle as country, p.code as country_code";
$sql = "SELECT f.rowid, f.code as code , f.libelle as label, f.active, p.libelle as country, p.code as country_code";
$sql .= " FROM ".MAIN_DB_PREFIX."c_forme_juridique as f, ".MAIN_DB_PREFIX."c_pays as p";
$sql .= " WHERE f.fk_pays=p.rowid";
$sql .= " AND f.active = 1 AND p.active = 1";
if ($country_codeid) $sql .= " AND p.code = '".$country_codeid."'";
if ($filter) $sql .= " ".$filter;
$sql .= " ORDER BY p.code, f.code";
$sql .= " ORDER BY p.code";
dol_syslog("Form::select_forme_juridique sql=".$sql);
$result=$this->db->query($sql);
if ($result)
dol_syslog(get_class($this)."::select_juridicalstatus sql=".$sql);
$resql=$this->db->query($sql);
if ($resql)
{
$out.= '<div id="particulier2" class="visible">';
$out.= '<select class="flat" name="forme_juridique_code">';
if ($country_codeid) $out.= '<option value="0">&nbsp;</option>';
$num = $this->db->num_rows($result);
$i = 0;
$num = $this->db->num_rows($resql);
if ($num)
{
$country='';
$i = 0;
$country=''; $arraydata=array();
while ($i < $num)
{
$obj = $this->db->fetch_object($result);
if ($obj->code == 0) {
$out.= '<option value="0">&nbsp;</option>';
}
else {
if (! $country || $country != $obj->country) {
// Affiche la rupture si on est en mode liste multipays
if (! $country_codeid && $obj->country_code) {
$out.= '<option value="0">----- '.$obj->country." -----</option>\n";
$country=$obj->country;
}
}
if ($selected > 0 && $selected == $obj->code)
{
$out.= '<option value="'.$obj->code.'" selected="selected">';
}
else
{
$out.= '<option value="'.$obj->code.'">';
}
// Si translation exists, we use it, otherwise we use default label in database
$out.= $obj->code . ' - ';
$out.= ($langs->trans("JuridicalStatus".$obj->code)!="JuridicalStatus".$obj->code?$langs->trans("JuridicalStatus".$obj->code):($obj->nom!='-'?$obj->nom:'')); // $obj->nom is alreay in output charset (converted by database driver)
$out.= '</option>';
}
$obj = $this->db->fetch_object($resql);
$labelcountry=(($langs->trans("Country".$obj->country_code)!="Country".$obj->country_code) ? $langs->trans("Country".$obj->country_code) : $obj->country);
$labeljs=(($langs->trans("JuridicalStatus".$obj->code)!="JuridicalStatus".$obj->code) ? $langs->trans("JuridicalStatus".$obj->code) : ($obj->label!='-'?$obj->label:'')); // $obj->label is already in output charset (converted by database driver)
$arraydata[$obj->code]=array('code'=>$obj->code, 'label'=>$labeljs, 'label_sort'=>$labelcountry.'_'.$labeljs, 'country_code'=>$obj->country_code, 'country'=>$labelcountry);
$i++;
}
$arraydata=dol_sort_array($arraydata, 'label_sort', 'ASC');
foreach($arraydata as $key => $val)
{
if (! $country || $country != $val['country'])
{
// Show break when we are in multi country mode
if (empty($country_codeid) && $val['country_code'])
{
$out.= '<option value="0">----- '.$val['country']." -----</option>\n";
$country=$val['country'];
}
}
if ($selected > 0 && $selected == $val['code'])
{
$out.= '<option value="'.$val['code'].'" selected="selected">';
}
else
{
$out.= '<option value="'.$val['code'].'">';
}
// If translation exists, we use it, otherwise we use default label in database
$out.= $val['label'];
$out.= '</option>';
}
}
$out.= '</select>';
if ($user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);

View File

@ -4102,7 +4102,7 @@ function dol_htmloutput_errors($mesgstring='', $mesgarray='', $keepembedded=0)
* @param array &$array Array to sort (array of array('key','otherkey1','otherkey2'...))
* @param string $index Key in array to use for sorting criteria
* @param int $order Sort order
* @param int $natsort 1=use "natural" sort (natsort), 0=use "standard sort (asort)
* @param int $natsort 1=use "natural" sort (natsort), 0=use "standard" sort (asort)
* @param int $case_sensitive 1=sort is case sensitive, 0=not case sensitive
* @return array Sorted array
*/

View File

@ -969,7 +969,7 @@ else
print '<td colspan="3" class="maxwidthonsmartphone">';
if ($object->country_id)
{
$formcompany->select_forme_juridique($object->forme_juridique_code,$object->country_code);
print $formcompany->select_juridicalstatus($object->forme_juridique_code,$object->country_code);
}
else
{
@ -1422,7 +1422,7 @@ else
print '</td></tr>';
print '<tr><td>'.$langs->trans('JuridicalStatus').'</td><td colspan="3">';
$formcompany->select_forme_juridique($object->forme_juridique_code,$object->country_code);
print $formcompany->select_juridicalstatus($object->forme_juridique_code,$object->country_code);
print '</td></tr>';
// Capital