diff --git a/htdocs/includes/menus/barre_left/eldy_backoffice.php b/htdocs/includes/menus/barre_left/eldy_backoffice.php index a9f6de5d8d5..d656585b518 100644 --- a/htdocs/includes/menus/barre_left/eldy_backoffice.php +++ b/htdocs/includes/menus/barre_left/eldy_backoffice.php @@ -180,7 +180,7 @@ class MenuLeft { if ($user->rights->societe->creer) { $newmenu->add_submenu(DOL_URL_ROOT."/soc.php?action=create", $langs->trans("MenuNewThirdParty")); - $newmenu->add_submenu(DOL_URL_ROOT."/soc.php?action=create&private=1",$langs->trans("MenuNewPrivateIndividual")); + if (! $conf->use_javascript) $newmenu->add_submenu(DOL_URL_ROOT."/soc.php?action=create&private=1",$langs->trans("MenuNewPrivateIndividual")); } if(is_dir("societe/groupe")) diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 9366a341c60..5ce8c908493 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -29,6 +29,10 @@ ThirdPartyProspects=Prospects ThirdPartyCustomers=Customers ThirdPartyCustomersWithIdProf12=Customers with %s or %s ThirdPartySuppliers=Suppliers +ThirdPartyType=Third party type +Company/Fundation=Company/Fundation +Individual=Private individual +ToCreateContactWithSameName=Will create automatically a physical contact with same informations ParentCompany=Parent company ReportByCustomers=Report by customers ReportByQuarter=Report by quarter diff --git a/htdocs/langs/fr_FR/companies.lang b/htdocs/langs/fr_FR/companies.lang index df901c77447..20834705f57 100644 --- a/htdocs/langs/fr_FR/companies.lang +++ b/htdocs/langs/fr_FR/companies.lang @@ -29,6 +29,10 @@ ThirdPartyProspects=Prospets ThirdPartyCustomers=Clients ThirdPartyCustomersWithIdProf12=Clients avec %s ou %s ThirdPartySuppliers=Fournisseurs +ThirdPartyType=Type du tiers +Company/Fundation=Société/Association +Individual=Individu privé +ToCreateContactWithSameName=Créera automatiquement un contact physique avec info identiques ReportByCustomers=Rapport par client ReportByQuarter=Rapport par trimestre ParentCompany=Maison mère diff --git a/htdocs/lib/lib_head.js b/htdocs/lib/lib_head.js index 3a13eaa2874..90f2d91eb98 100644 --- a/htdocs/lib/lib_head.js +++ b/htdocs/lib/lib_head.js @@ -7,6 +7,13 @@ // \version $Revision$ +function dolibarr_type_reload(param) +{ + document.formsoc.action.value="create"; + document.formsoc.private.value=param; + document.formsoc.cleartype.value=1; + document.formsoc.submit(); +} /*================================================================= Purpose: Pour la fonction de saisie auto des villes diff --git a/htdocs/soc.php b/htdocs/soc.php index a948209a094..7c97f56d791 100644 --- a/htdocs/soc.php +++ b/htdocs/soc.php @@ -92,12 +92,12 @@ if ($_POST["getsuppliercode"]) if ((! $_POST["getcustomercode"] && ! $_POST["getsuppliercode"]) && ($_POST["action"] == 'add' || $_POST["action"] == 'update') && $user->rights->societe->creer) { - if ($_POST["private"] == 1) + if ($_REQUEST["private"] == 1) { $soc->nom = $_POST["nom"].' '.$_POST["prenom"]; $soc->nom_particulier = $_POST["nom"]; $soc->prenom = $_POST["prenom"]; - $soc->particulier = $_POST["private"]; + $soc->particulier = $_REQUEST["private"]; } else { @@ -128,7 +128,7 @@ if ((! $_POST["getcustomercode"] && ! $_POST["getsuppliercode"]) $soc->forme_juridique_code = $_POST["forme_juridique_code"]; $soc->effectif_id = $_POST["effectif_id"]; - if ($_POST["private"] == 1) + if ($_REQUEST["private"] == 1) { $soc->typent_id = 8; //todo prévoir autre méthode si le champs "particulier" change de rowid } @@ -240,8 +240,8 @@ if ($_POST["getcustomercode"] || $_POST["getsuppliercode"] || /* * Fiche en mode creation */ - if ($user->rights->societe->creer) - { + if ($user->rights->societe->creer) + { // Charge objet modCodeTiers $module=$conf->global->SOCIETE_CODECLIENT_ADDON; if (! $module) dolibarr_error('',$langs->trans("ErrorModuleThirdPartyCodeInCompanyModuleNotDefined")); @@ -259,327 +259,325 @@ if ($_POST["getcustomercode"] || $_POST["getsuppliercode"] || } require_once(DOL_DOCUMENT_ROOT ."/includes/modules/societe/".$module.".php"); $modCodeFournisseur = new $module; - + /* - * Fiche societe en mode création - */ - if ($_GET["type"]=='f') { $soc->fournisseur=1; } - if ($_GET["type"]=='c') { $soc->client=1; } - if ($_GET["type"]=='p') { $soc->client=2; } - if ($_GET["private"]==1) { $soc->particulier=1; } - if ($_POST["nom"]) - { - $soc->nom=$_POST["nom"]; - $soc->prenom=$_POST["prenom"]; - $soc->particulier=$_POST["private"]; - $soc->prefix_comm=$_POST["prefix_comm"]; - $soc->client=$_POST["client"]; - $soc->code_client=$_POST["code_client"]; - $soc->fournisseur=$_POST["fournisseur"]; - $soc->code_fournisseur=$_POST["code_fournisseur"]; - $soc->adresse=$_POST["adresse"]; - $soc->cp=$_POST["cp"]; - $soc->ville=$_POST["ville"]; - $soc->departement_id=$_POST["departement_id"]; - $soc->tel=$_POST["tel"]; - $soc->fax=$_POST["fax"]; - $soc->email=$_POST["email"]; - $soc->url=$_POST["url"]; - $soc->capital=$_POST["capital"]; - $soc->siren=$_POST["idprof1"]; - $soc->siret=$_POST["idprof2"]; - $soc->ape=$_POST["idprof3"]; - $soc->idprof4=$_POST["idprof4"]; - $soc->typent_id=$_POST["typent_id"]; - $soc->effectif_id=$_POST["effectif_id"]; - - $soc->tva_assuj = $_POST["assujtva_value"]; - $soc->tva_intra_code=$_POST["tva_intra_code"]; - $soc->tva_intra_num=$_POST["tva_intra_num"]; - - $soc->commercial_id=$_POST["commercial_id"]; - } + * Fiche societe en mode création + */ + if ($_GET["type"]=='f') { $soc->fournisseur=1; } + if ($_GET["type"]=='c') { $soc->client=1; } + if ($_GET["type"]=='p') { $soc->client=2; } + if ($_REQUEST["private"]==1) { $soc->particulier=1; } - // On positionne pays_id, pays_code et libelle du pays choisi - $soc->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$conf->global->MAIN_INFO_SOCIETE_PAYS; - if ($soc->pays_id) - { - $sql = "SELECT code, libelle from ".MAIN_DB_PREFIX."c_pays where rowid = ".$soc->pays_id; - $resql=$db->query($sql); - if ($resql) - { - $obj = $db->fetch_object($resql); - } - else - { - dolibarr_print_error($db); - } - $soc->pays_code=$obj->code; - $soc->pays=$obj->libelle; - } - - if (!$soc->particulier) - { - print_titre($langs->trans("NewCompany")); - } - else - { - print_titre($langs->trans("NewPrivateIndividual")); - } - print "
\n"; - - if ($soc->error) - { - print '
'; - print nl2br($soc->error); - print '
'; - } - - print '
'; - - print ''; - print ''; - - print ''; - - print ''; - print ''; - - if ($soc->particulier) - { - print ''; - print ''; - } - - // Client / Prospect - print ''; + $soc->nom=$_POST["nom"]; + $soc->prenom=$_POST["prenom"]; + $soc->particulier=$_REQUEST["private"]; + $soc->prefix_comm=$_POST["prefix_comm"]; + $soc->client=$_POST["client"]; + $soc->code_client=$_POST["code_client"]; + $soc->fournisseur=$_POST["fournisseur"]; + $soc->code_fournisseur=$_POST["code_fournisseur"]; + $soc->adresse=$_POST["adresse"]; + $soc->cp=$_POST["cp"]; + $soc->ville=$_POST["ville"]; + $soc->departement_id=$_POST["departement_id"]; + $soc->tel=$_POST["tel"]; + $soc->fax=$_POST["fax"]; + $soc->email=$_POST["email"]; + $soc->url=$_POST["url"]; + $soc->capital=$_POST["capital"]; + $soc->siren=$_POST["idprof1"]; + $soc->siret=$_POST["idprof2"]; + $soc->ape=$_POST["idprof3"]; + $soc->idprof4=$_POST["idprof4"]; + $soc->typent_id=($_POST["typent_id"]&&!$_POST["cleartype"])?$_POST["typent_id"]:($_REQUEST["private"]?'TE_PRIVATE':''); + $soc->effectif_id=($_POST["effectif_id"]&&!$_POST["cleartype"])?$_POST["effectif_id_id"]:($_REQUEST["private"]?'EF1-5':''); + + $soc->tva_assuj = $_POST["assujtva_value"]; + $soc->tva_intra_code=$_POST["tva_intra_code"]; + $soc->tva_intra_num=$_POST["tva_intra_num"]; + + $soc->commercial_id=$_POST["commercial_id"]; - print ''; + //$conf->use_javascript=0; + if ($conf->use_javascript) + { + print "
\n"; + print $langs->trans("ThirdPartyType").':   '; + print ' '.$langs->trans("Company/Fundation"); + print '     '; + print ' '.$langs->trans("Individual"); + print ' ('.$langs->trans("ToCreateContactWithSameName").')'; + print "
\n"; + print "
\n"; + } + + if ($soc->error) + { + print '
'; + print nl2br($soc->error); + print '
'; + } + + print ''; + + print ''; + print ''; + print ''; + + print '
'.$langs->trans('Name').''.$langs->trans('Prefix').'
'.$langs->trans('FirstName').' 
'.$langs->trans('ProspectCustomer').''.$langs->trans('CustomerCode').''; - print '
'; - print ''; - print ''; - $s=$langs->trans("CustomerCodeDesc").'
'; - $s.=$langs->trans("ValidityControledByModule").': '.$modCodeClient->getNom($langs).'
'; - $s.=$langs->trans("RequiredIfCustomer").': '.yn(!$modCodeClient->code_null).'
'; - $s.=$langs->trans("Example").': '.$modCodeClient->getExample($langs).''; - print $form->textwithhelp('',$s,1); - print '
'; + // On positionne pays_id, pays_code et libelle du pays choisi + $soc->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$conf->global->MAIN_INFO_SOCIETE_PAYS; + if ($soc->pays_id) + { + $sql = "SELECT code, libelle from ".MAIN_DB_PREFIX."c_pays where rowid = ".$soc->pays_id; + $resql=$db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + } + else + { + dolibarr_print_error($db); + } + $soc->pays_code=$obj->code; + $soc->pays=$obj->libelle; + } + + print_titre($langs->trans("NewCompany")); - print '
'; + + print ''; + print ''; + + if ($soc->particulier) + { + print ''; + print ''; + } + + // Client / Prospect + print ''; - // Fournisseur - print ''; - print ''; - print ''; + print ''; - if ($soc->fournisseur) - { - $load = $soc->LoadSupplierCateg(); - if ( $load == 0) - { - if (sizeof($soc->SupplierCategories) > 0) - { - print ''; - print ''; - } - } - } + // Fournisseur + print ''; + print ''; + print ''; + print ''; - print ''; - print ''; + if ($soc->fournisseur) + { + $load = $soc->LoadSupplierCateg(); + if ( $load == 0) + { + if (sizeof($soc->SupplierCategories) > 0) + { + print ''; + print ''; + } + } + } - print ''; + print ''; - print ''; + print ''; + print ''; - print ''; - print ''; + print ''; - print ''; - print ''; + print ''; - if (!$soc->particulier) - { - print ''; + print ''; + print ''; - if ($soc->pays_code == 'FR') - { - $maxlength1=9; - $maxlength2=14; - $maxlength3=4; - $maxlength4=12; - } - print ''; - print ''; - - print ''; - print ''; + print ''; + print ''; - // Forme juridique - print ''; - print ''; + print ''; - print ''; - print ''; - } + if ($soc->pays_code == 'FR') + { + $maxlength1=9; + $maxlength2=14; + $maxlength3=4; + $maxlength4=12; + } + + // Id prof + print ''; + print ''; + + print ''; + print ''; - // Assujeti TVA - $html = new Form($db); - print ''; - if ($soc->particulier) - { - print ''; + // Forme juridique + print ''; + print ''; + + print ''; + print ''; + + // Assujeti TVA + $html = new Form($db); + print ''; + print ''; - // Code TVA intra - if (!$soc->particulier) - { - if ($conf->use_javascript) - { - print "\n"; - print ''; - print "\n"; - } - print ''; - print ''; - } - print ''; - - if ($user->rights->commercial->client->voir) - { - //Affecter un commercial - print ''; - print ''; - print ''; - } + // Code TVA intra + if ($conf->use_javascript) + { + print "\n"; + print ''; + print "\n"; + } + print ''; + print ''; + + print ''; + + if ($user->rights->commercial->client->voir) + { + //Affecter un commercial + print ''; + print ''; + print ''; + } - print ''."\n"; - - print '
'.$langs->trans('Name').''.$langs->trans('Prefix').'
'.$langs->trans('FirstName').' 
'.$langs->trans('ProspectCustomer').'
'.$langs->trans('Supplier').''; - $form->selectyesnonum("fournisseur",$soc->fournisseur); - print ''.$langs->trans('SupplierCode').''; - - print '
'; - print ''; - print ''; - $s=$langs->trans("SupplierCodeDesc").'
'; - $s.=$langs->trans("ValidityControledByModule").': '.$modCodeFournisseur->getNom($langs).'
'; - $s.=$langs->trans("RequiredIfSupplier").': '.yn(!$modCodeFournisseur->code_null).'
'; - $s.=$langs->trans("Example").': '.$modCodeFournisseur->getExample($langs).''; - print $form->textwithhelp('',$s,1); - print '
'; + print '
'.$langs->trans('CustomerCode').''; + print '
'; + print ''; + print ''; + $s=$langs->trans("CustomerCodeDesc").'
'; + $s.=$langs->trans("ValidityControledByModule").': '.$modCodeClient->getNom($langs).'
'; + $s.=$langs->trans("RequiredIfCustomer").': '.yn(!$modCodeClient->code_null).'
'; + $s.=$langs->trans("Example").': '.$modCodeClient->getExample($langs).''; + print $form->textwithhelp('',$s,1); + print '
'; - print '
'.$langs->trans('SupplierCategory').''; - $form->select_array("fournisseur_categorie",$soc->SupplierCategories); - print '
'.$langs->trans('Supplier').''; + $form->selectyesnonum("fournisseur",$soc->fournisseur); + print ''.$langs->trans('SupplierCode').''; + + print '
'; + print ''; + print ''; + $s=$langs->trans("SupplierCodeDesc").'
'; + $s.=$langs->trans("ValidityControledByModule").': '.$modCodeFournisseur->getNom($langs).'
'; + $s.=$langs->trans("RequiredIfSupplier").': '.yn(!$modCodeFournisseur->code_null).'
'; + $s.=$langs->trans("Example").': '.$modCodeFournisseur->getExample($langs).''; + print $form->textwithhelp('',$s,1); + print '
'; - print '
'.$langs->trans('Address').'
'.$langs->trans('Zip').'use_javascript && $conf->global->MAIN_AUTO_FILLTOWNFROMZIP) print ' onChange="autofilltownfromzip_PopupPostalCode(cp.value,ville)"'; - print '>'; - if ($conf->use_javascript && $conf->global->MAIN_AUTO_FILLTOWNFROMZIP) print ' '; - print ''.$langs->trans('Town').'
'.$langs->trans('SupplierCategory').''; + $form->select_array("fournisseur_categorie",$soc->SupplierCategories); + print '
'.$langs->trans('Country').''; - $form->select_pays($soc->pays_id,'pays_id',$conf->use_javascript?' onChange="autofilltownfromzip_save_refresh_create()"':''); - if ($conf->use_javascript && $conf->use_ajax) print '
';//utile pour afficher la recherche des pays avec ajax - print '
'.$langs->trans('Address').'
'.$langs->trans('State').''; - if ($soc->pays_id) - { - $form->select_departement($soc->departement_id,$soc->pays_code); - } - else - { - print $countrynotdefined; - } - print '
'.$langs->trans('Zip').'use_javascript && $conf->global->MAIN_AUTO_FILLTOWNFROMZIP) print ' onChange="autofilltownfromzip_PopupPostalCode(cp.value,ville)"'; + print '>'; + if ($conf->use_javascript && $conf->global->MAIN_AUTO_FILLTOWNFROMZIP) print ' '; + print ''.$langs->trans('Town').'
'.$langs->trans('Phone').''.$langs->trans('Fax').'
'.$langs->trans('Country').''; + $form->select_pays($soc->pays_id,'pays_id',$conf->use_javascript?' onChange="autofilltownfromzip_save_refresh_create()"':''); + if ($conf->use_javascript && $conf->use_ajax) print '
';//utile pour afficher la recherche des pays avec ajax + print '
'.$langs->trans('EMail').''.$langs->trans('Web').'
'.$langs->trans('State').''; + if ($soc->pays_id) + { + $form->select_departement($soc->departement_id,$soc->pays_code); + } + else + { + print $countrynotdefined; + } + print '
'.$langs->trans('Capital').' '.$langs->trans("Currency".$conf->monnaie).'
'.$langs->trans('Phone').''.$langs->trans('Fax').'
'.($langs->transcountry("ProfId1",$soc->pays_code) != '-'?$langs->transcountry('ProfId1',$soc->pays_code):'').''; - if ($soc->pays_id) - { - if ($langs->transcountry("ProfId1",$soc->pays_code) != '-') print ''; - else print ' '; - } - else - { - print $countrynotdefined; - } - print ''.($langs->transcountry("ProfId2",$soc->pays_code) != '-'?$langs->transcountry('ProfId2',$soc->pays_code):'').''; - if ($soc->pays_id) - { - if ($langs->transcountry("ProfId2",$soc->pays_code) != '-') print ''; - else print ' '; - } - else - { - print $countrynotdefined; - } - print '
'.($langs->transcountry("ProfId3",$soc->pays_code) != '-'?$langs->transcountry('ProfId3',$soc->pays_code):'').''; - if ($soc->pays_id) - { - if ($langs->transcountry("ProfId3",$soc->pays_code) != '-') print ''; - else print ' '; - } - else - { - print $countrynotdefined; - } - print ''.($langs->transcountry("ProfId4",$soc->pays_code) != '-'?$langs->transcountry('ProfId4',$soc->pays_code):'').''; - if ($soc->pays_id) - { - if ($langs->transcountry("ProfId4",$soc->pays_code) != '-') print ''; - else print ' '; - } - else - { - print $countrynotdefined; - } - print '
'.$langs->trans('EMail').''.$langs->trans('Web').'
'.$langs->trans('JuridicalStatus').''; - if ($soc->pays_id) - { - $form->select_forme_juridique($soc->forme_juridique_code,$soc->pays_code); - } - else - { - print $countrynotdefined; - } - print '
'.$langs->trans('Capital').' '.$langs->trans("Currency".$conf->monnaie).'
'.$langs->trans("Type").''."\n"; - $form->select_array("typent_id",$soc->typent_array(), $soc->typent_id); - print ''.$langs->trans("Staff").''; - $form->select_array("effectif_id",$soc->effectif_array(), $soc->effectif_id); - print '
'.($langs->transcountry("ProfId1",$soc->pays_code) != '-'?$langs->transcountry('ProfId1',$soc->pays_code):'').''; + if ($soc->pays_id) + { + if ($langs->transcountry("ProfId1",$soc->pays_code) != '-') print ''; + else print ' '; + } + else + { + print $countrynotdefined; + } + print ''.($langs->transcountry("ProfId2",$soc->pays_code) != '-'?$langs->transcountry('ProfId2',$soc->pays_code):'').''; + if ($soc->pays_id) + { + if ($langs->transcountry("ProfId2",$soc->pays_code) != '-') print ''; + else print ' '; + } + else + { + print $countrynotdefined; + } + print '
'.($langs->transcountry("ProfId3",$soc->pays_code) != '-'?$langs->transcountry('ProfId3',$soc->pays_code):'').''; + if ($soc->pays_id) + { + if ($langs->transcountry("ProfId3",$soc->pays_code) != '-') print ''; + else print ' '; + } + else + { + print $countrynotdefined; + } + print ''.($langs->transcountry("ProfId4",$soc->pays_code) != '-'?$langs->transcountry('ProfId4',$soc->pays_code):'').''; + if ($soc->pays_id) + { + if ($langs->transcountry("ProfId4",$soc->pays_code) != '-') print ''; + else print ' '; + } + else + { + print $countrynotdefined; + } + print '
'.$langs->trans('VATIsUsed').''; - } - else - { - print ''; - } - $html->select_YesNo("1",'assujtva_value'); // Assujeti par défaut en creation - print '
'.$langs->trans('JuridicalStatus').''; + if ($soc->pays_id) + { + $form->select_forme_juridique($soc->forme_juridique_code,$soc->pays_code); + } + else + { + print $countrynotdefined; + } + print '
'.$langs->trans("Type").''."\n"; + $form->select_array("typent_id",$soc->typent_array(1), $soc->typent_id); + print ''.$langs->trans("Staff").''; + $form->select_array("effectif_id",$soc->effectif_array(1), $soc->effectif_id); + print '
'.$langs->trans('VATIsUsed').''; + $html->select_YesNo("1",'assujtva_value'); // Assujeti par défaut en creation + print ''.$langs->trans('VATIntraShort').''; - $s =''; - $s.=''; - $s.=' '; - if ($conf->use_javascript) - { - $s.=''.$langs->trans("VATIntraCheck").''; - print $form->textwithhelp($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1); - } - else - { - print $s.'id_pays).'" target="_blank" alt="'.$langs->trans("VATIntraCheckableOnEUSite").'">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').''; - } - print '
'.$langs->trans("AllocateCommercial").''; - $form->select_users($soc->commercial_id,'commercial_id',1); - print '
'.$langs->trans('VATIntraShort').''; + $s =''; + $s.=''; + $s.=' '; + if ($conf->use_javascript) + { + $s.=''.$langs->trans("VATIntraCheck").''; + print $form->textwithhelp($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1); + } + else + { + print $s.'id_pays).'" target="_blank" alt="'.$langs->trans("VATIntraCheckableOnEUSite").'">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').''; + } + print '
'.$langs->trans("AllocateCommercial").''; + $form->select_users($soc->commercial_id,'commercial_id',1); + print '
'; - print '
'."\n"; - print '
'."\n"; - - } + print ''; + print ''."\n"; + + print ''."\n"; + print ''."\n"; + + } } elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit') { diff --git a/htdocs/societe.class.php b/htdocs/societe.class.php index 11f879ac055..4d83f50cf4a 100644 --- a/htdocs/societe.class.php +++ b/htdocs/societe.class.php @@ -1308,10 +1308,11 @@ class Societe /** - * \brief Renvoie la liste des libellés traduits des types actifs de sociétés - * \return array tableau des types + * \brief Renvoie la liste des libellés traduits des types actifs de sociétés + * \param mode 0=renvoi id+libelle, 1=renvoi code+libelle + * \return array tableau des typesl */ - function typent_array() + function typent_array($mode=0) { global $langs; @@ -1330,10 +1331,13 @@ class Societe while ($i < $num) { $objp = $this->db->fetch_object($result); + if (! $mode) $key=$objp->id; + else $key=$objp->code; + if ($langs->trans($objp->code) != $objp->code) - $effs[$objp->id] = $langs->trans($objp->code); + $effs[$key] = $langs->trans($objp->code); else - $effs[$objp->id] = $objp->libelle!='-'?$objp->libelle:''; + $effs[$key] = $objp->libelle!='-'?$objp->libelle:''; $i++; } $this->db->free($result); @@ -1344,14 +1348,15 @@ class Societe /** - * \brief Renvoie la liste des types d'effectifs possibles (pas de traduction car nombre) - * \return array tableau des types d'effectifs + * \brief Renvoie la liste des types d'effectifs possibles (pas de traduction car nombre) + * \param mode 0=renvoi id+libelle, 1=renvoi code+libelle + * \return array tableau des types d'effectifs */ - function effectif_array() + function effectif_array($mode=0) { $effs = array(); - $sql = "SELECT id, libelle"; + $sql = "SELECT id, code, libelle"; $sql .= " FROM ".MAIN_DB_PREFIX."c_effectif"; $sql .= " ORDER BY id ASC"; if ($this->db->query($sql)) @@ -1362,7 +1367,10 @@ class Societe while ($i < $num) { $objp = $this->db->fetch_object(); - $effs[$objp->id] = $objp->libelle!='-'?$objp->libelle:''; + if (! $mode) $key=$objp->id; + else $key=$objp->code; + + $effs[$key] = $objp->libelle!='-'?$objp->libelle:''; $i++; } $this->db->free();