From 81535dc8682d2719fc0845f0fdd1859127256e47 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 15 Dec 2011 19:28:31 +0800 Subject: [PATCH] Fix: problem with select country Fix: uniform code --- htdocs/societe/soc.php | 205 +++++++++++++++++++++-------------------- 1 file changed, 103 insertions(+), 102 deletions(-) diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index bf8482f468a..3cc3f6dcac5 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -121,7 +121,7 @@ if (empty($reshook)) $object->address = $_POST["adresse"]; $object->zip = $_POST["zipcode"]; $object->town = $_POST["town"]; - $object->country_id = $_POST["pays_id"]; + $object->country_id = $_POST["country_id"]; $object->state_id = $_POST["departement_id"]; $object->tel = $_POST["tel"]; $object->fax = $_POST["fax"]; @@ -135,7 +135,7 @@ if (empty($reshook)) $object->code_client = $_POST["code_client"]; $object->code_fournisseur = $_POST["code_fournisseur"]; $object->capital = $_POST["capital"]; - $object->barcode = $_POST["barcode"]; + $object->barcode = $_POST["barcode"]; $object->tva_intra = $_POST["tva_intra"]; $object->tva_assuj = $_POST["assujtva_value"]; @@ -228,22 +228,22 @@ if (empty($reshook)) dol_syslog("This thirdparty is a personal people",LOG_DEBUG); $contact=new Contact($db); - $contact->civilite_id=$object->civilite_id; - $contact->name=$object->nom_particulier; - $contact->firstname=$object->prenom; - $contact->address=$object->address; - $contact->zip=$object->zip; - $contact->cp=$object->cp; - $contact->town=$object->town; - $contact->ville=$object->ville; - $contact->fk_departement=$object->state_id; - $contact->fk_pays=$object->pays_id; - $contact->socid=$object->id; // fk_soc - $contact->status=1; - $contact->email=$object->email; - $contact->phone_pro=$object->tel; - $contact->fax=$object->fax; - $contact->priv=0; + $contact->civilite_id = $object->civilite_id; + $contact->name = $object->nom_particulier; + $contact->firstname = $object->prenom; + $contact->address = $object->address; + $contact->zip = $object->zip; + $contact->cp = $object->cp; // TODO obsolete + $contact->town = $object->town; + $contact->ville = $object->ville; // TODO obsolete + $contact->fk_departement = $object->state_id; + $contact->fk_pays = $object->country_id; + $contact->socid = $object->id; // fk_soc + $contact->status = 1; + $contact->email = $object->email; + $contact->phone_pro = $object->tel; + $contact->fax = $object->fax; + $contact->priv = 0; $result=$contact->create($user); if (! $result >= 0) @@ -520,7 +520,7 @@ else $object->name = $_POST["nom"]; $object->prenom = $_POST["prenom"]; - $object->particulier = $_REQUEST["private"]; + $object->particulier = GETPOST('private', 'int'); $object->prefix_comm = $_POST["prefix_comm"]; $object->client = $_POST["client"]?$_POST["client"]:$object->client; $object->code_client = $_POST["code_client"]; @@ -535,7 +535,7 @@ else $object->email = $_POST["email"]; $object->url = $_POST["url"]; $object->capital = $_POST["capital"]; - $object->barcode = $_POST["barcode"]; + $object->barcode = $_POST["barcode"]; $object->idprof1 = $_POST["idprof1"]; $object->idprof2 = $_POST["idprof2"]; $object->idprof3 = $_POST["idprof3"]; @@ -590,11 +590,11 @@ else } // We set country_id, country_code and country for the selected country - $object->country_id=$_POST["pays_id"]?$_POST["pays_id"]:$mysoc->country_id; - $object->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$mysoc->country_id; - if ($object->pays_id) + $object->country_id=$_POST["country_id"]?$_POST["country_id"]:$mysoc->country_id; + $object->pays_id=$_POST["country_id"]?$_POST["country_id"]:$mysoc->country_id; + if ($object->country_id) { - $tmparray=getCountry($object->pays_id,'all',$db,$langs,0); + $tmparray=getCountry($object->country_id,'all',$db,$langs,0); $object->pays_code=$tmparray['code']; $object->pays=$tmparray['label']; $object->country_code=$tmparray['code']; @@ -608,33 +608,33 @@ else if ($conf->use_javascript_ajax) { print "\n".''."\n"; @@ -768,14 +768,14 @@ else // Zip / Town print ''.$langs->trans('Zip').''; - print $formcompany->select_ziptown($object->zip,'zipcode',array('town','selectpays_id','departement_id'),6); + print $formcompany->select_ziptown($object->zip,'zipcode',array('town','selectcountry_id','departement_id'),6); print ''.$langs->trans('Town').''; - print $formcompany->select_ziptown($object->town,'town',array('zipcode','selectpays_id','departement_id')); + print $formcompany->select_ziptown($object->town,'town',array('zipcode','selectcountry_id','departement_id')); print ''; // Country print ''.$langs->trans('Country').''; - $form->select_pays($object->country_id,'pays_id'); + $form->select_pays($object->country_id,'country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); print ''; @@ -884,7 +884,7 @@ else // Legal Form print ''.$langs->trans('JuridicalStatus').''; print ''; - if ($object->pays_id) + if ($object->country_id) { $formcompany->select_forme_juridique($object->forme_juridique_code,$object->pays_code); } @@ -1018,44 +1018,45 @@ else if (! empty($_POST["nom"])) { // We overwrite with values if posted - $object->name=$_POST["nom"]; - $object->prefix_comm=$_POST["prefix_comm"]; - $object->client=$_POST["client"]; - $object->code_client=$_POST["code_client"]; - $object->fournisseur=$_POST["fournisseur"]; - $object->code_fournisseur=$_POST["code_fournisseur"]; - $object->address=$_POST["adresse"]; - $object->zip=$_POST["zipcode"]; - $object->town=$_POST["town"]; - $object->country_id=$_POST["pays_id"]?$_POST["pays_id"]:$mysoc->pays_id; - $object->state_id=$_POST["departement_id"]; - $object->tel=$_POST["tel"]; - $object->fax=$_POST["fax"]; - $object->email=$_POST["email"]; - $object->url=$_POST["url"]; - $object->capital=$_POST["capital"]; - $object->siren=$_POST["idprof1"]; - $object->siret=$_POST["idprof2"]; - $object->ape=$_POST["idprof3"]; - $object->idprof4=$_POST["idprof4"]; - $object->typent_id=$_POST["typent_id"]; - $object->effectif_id=$_POST["effectif_id"]; - $object->barcode=$_POST["barcode"]; - $object->forme_juridique_code=$_POST["forme_juridique_code"]; - $object->default_lang=$_POST["default_lang"]; + $object->name = $_POST["nom"]; + $object->prefix_comm = $_POST["prefix_comm"]; + $object->client = $_POST["client"]; + $object->code_client = $_POST["code_client"]; + $object->fournisseur = $_POST["fournisseur"]; + $object->code_fournisseur = $_POST["code_fournisseur"]; + $object->address = $_POST["adresse"]; + $object->zip = $_POST["zipcode"]; + $object->town = $_POST["town"]; + $object->country_id = $_POST["country_id"]?$_POST["country_id"]:$mysoc->pays_id; + $object->state_id = $_POST["departement_id"]; + $object->tel = $_POST["tel"]; + $object->fax = $_POST["fax"]; + $object->email = $_POST["email"]; + $object->url = $_POST["url"]; + $object->capital = $_POST["capital"]; + $object->siren = $_POST["idprof1"]; + $object->siret = $_POST["idprof2"]; + $object->ape = $_POST["idprof3"]; + $object->idprof4 = $_POST["idprof4"]; + $object->typent_id = $_POST["typent_id"]; + $object->effectif_id = $_POST["effectif_id"]; + $object->barcode = $_POST["barcode"]; + $object->forme_juridique_code = $_POST["forme_juridique_code"]; + $object->default_lang = $_POST["default_lang"]; - $object->tva_assuj = $_POST["assujtva_value"]; - $object->tva_intra=$_POST["tva_intra"]; - $object->status=$_POST["status"]; + $object->tva_assuj = $_POST["assujtva_value"]; + $object->tva_intra = $_POST["tva_intra"]; + $object->status = $_POST["status"]; //Local Taxes - $object->localtax1_assuj = $_POST["localtax1assuj_value"]; - $object->localtax2_assuj = $_POST["localtax2assuj_value"]; + $object->localtax1_assuj = $_POST["localtax1assuj_value"]; + $object->localtax2_assuj = $_POST["localtax2assuj_value"]; - // We set pays_id, and pays_code label of the chosen country - if ($object->pays_id) + // We set country_id, and pays_code label of the chosen country + // TODO move to DAO class + if ($object->country_id) { - $sql = "SELECT code, libelle from ".MAIN_DB_PREFIX."c_pays where rowid = ".$object->pays_id; + $sql = "SELECT code, libelle from ".MAIN_DB_PREFIX."c_pays where rowid = ".$object->country_id; $resql=$db->query($sql); if ($resql) { @@ -1065,8 +1066,8 @@ else { dol_print_error($db); } - $object->pays_code=$obj->code; - $object->pays=$langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->libelle; + $object->country_code = $obj->code; + $object->country = $langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->libelle; } } @@ -1075,11 +1076,11 @@ else if ($conf->use_javascript_ajax) { print "\n".''."\n"; } @@ -1212,14 +1213,14 @@ else // Zip / Town print ''.$langs->trans('Zip').''; - print $formcompany->select_ziptown($object->cp,'zipcode',array('town','selectpays_id','departement_id'),6); + print $formcompany->select_ziptown($object->cp,'zipcode',array('town','selectcountry_id','departement_id'),6); print ''.$langs->trans('Town').''; - print $formcompany->select_ziptown($object->ville,'town',array('zipcode','selectpays_id','departement_id')); + print $formcompany->select_ziptown($object->ville,'town',array('zipcode','selectcountry_id','departement_id')); print ''; // Country print ''.$langs->trans('Country').''; - $form->select_pays($object->pays_id,'pays_id'); + $form->select_pays($object->country_id,'country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); print ''; @@ -1227,7 +1228,7 @@ else if (empty($conf->global->SOCIETE_DISABLE_STATE)) { print ''.$langs->trans('State').''; - $formcompany->select_departement($object->state_id,$object->pays_code); + $formcompany->select_departement($object->state_id,$object->country_code); print ''; } @@ -1241,40 +1242,40 @@ else print ''; // IdProf1 (SIREN for France) - $idprof=$langs->transcountry('ProfId1',$object->pays_code); + $idprof=$langs->transcountry('ProfId1',$object->country_code); if ($idprof!='-') { print ''.$idprof.''; - print $formcompany->get_input_id_prof(1,'idprof1',$object->siren,$object->pays_code); + print $formcompany->get_input_id_prof(1,'idprof1',$object->siren,$object->country_code); print ''; } else print '  '; // IdProf2 (SIRET for France) - $idprof=$langs->transcountry('ProfId2',$object->pays_code); + $idprof=$langs->transcountry('ProfId2',$object->country_code); if ($idprof!='-') { print ''.$idprof.''; - print $formcompany->get_input_id_prof(2,'idprof2',$object->siret,$object->pays_code); + print $formcompany->get_input_id_prof(2,'idprof2',$object->siret,$object->country_code); print ''; } else print '  '; print ''; print ''; // IdProf3 (APE for France) - $idprof=$langs->transcountry('ProfId3',$object->pays_code); + $idprof=$langs->transcountry('ProfId3',$object->country_code); if ($idprof!='-') { print ''.$idprof.''; - print $formcompany->get_input_id_prof(3,'idprof3',$object->ape,$object->pays_code); + print $formcompany->get_input_id_prof(3,'idprof3',$object->ape,$object->country_code); print ''; } else print '  '; // IdProf4 (NU for France) - $idprof=$langs->transcountry('ProfId4',$object->pays_code); + $idprof=$langs->transcountry('ProfId4',$object->country_code); if ($idprof!='-') { print ''.$idprof.''; - print $formcompany->get_input_id_prof(4,'idprof4',$object->idprof4,$object->pays_code); + print $formcompany->get_input_id_prof(4,'idprof4',$object->idprof4,$object->country_code); print ''; } else print '  '; @@ -1317,7 +1318,7 @@ else // Local Taxes // TODO add specific function by country - if($mysoc->pays_code=='ES') + if($mysoc->country_code=='ES') { if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1") {