From 0aecc4f836d4184608b8d0ac2a584f26976d4407 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Jun 2010 19:18:01 +0000 Subject: [PATCH] Fix: Can edit state in foundation members cards --- htdocs/adherents/class/adherent.class.php | 17 +- htdocs/adherents/fiche.php | 161 ++++++++++++------ htdocs/contact/class/contact.class.php | 8 +- htdocs/core/class/html.form.class.php | 96 +++-------- .../install/mysql/migration/2.8.0-2.9.0.sql | 4 +- htdocs/install/mysql/tables/llx_adherent.sql | 1 + htdocs/install/mysql/tables/llx_entrepot.sql | 1 + htdocs/install/mysql/tables/llx_socpeople.sql | 2 +- 8 files changed, 162 insertions(+), 128 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 8fc520e6f11..54b696cfdc5 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -57,6 +57,11 @@ class Adherent extends CommonObject var $adresse; var $cp; var $ville; + + var $fk_departement; // Id of department + var $departement_code; // Code of department + var $departement; // Label of department + var $pays_id; var $pays_code; var $pays; @@ -401,7 +406,8 @@ class Adherent extends CommonObject $sql.= ", adresse=" .($this->adresse?"'".addslashes($this->adresse)."'":"null"); $sql.= ", cp=" .($this->cp?"'".addslashes($this->cp)."'":"null"); $sql.= ", ville=" .($this->ville?"'".addslashes($this->ville)."'":"null"); - $sql.= ", pays=" ."'".$this->pays_id."'"; + $sql.= ", pays=" .($this->pays_id>0?"'".$this->pays_id."'":"null"); + $sql.= ", fk_departement=".($this->fk_departement>0?"'".$this->fk_departement."'":"null"); $sql.= ", email=" ."'".$this->email."'"; $sql.= ", phone=" .($this->phone?"'".addslashes($this->phone)."'":"null"); $sql.= ", phone_perso=" .($this->phone_perso?"'".addslashes($this->phone_perso)."'":"null"); @@ -939,11 +945,14 @@ class Adherent extends CommonObject $sql.= " d.naiss as datenaiss,"; $sql.= " d.datevalid as datev,"; $sql.= " d.pays,"; + $sql.= " d.fk_departement,"; $sql.= " p.rowid as pays_id, p.code as pays_code, p.libelle as pays_lib,"; + $sql.= " dep.nom as departement, dep.code_departement as departement_code,"; $sql.= " t.libelle as type, t.cotisation as cotisation,"; $sql.= " u.rowid as user_id, u.login as user_login"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_pays as p ON d.pays = p.rowid"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as dep ON d.fk_departement = dep.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON d.rowid = u.fk_member"; $sql.= " WHERE d.fk_adherent_type = t.rowid"; $sql.= " AND d.entity = ".$conf->entity; @@ -972,11 +981,17 @@ class Adherent extends CommonObject $this->adresse = $obj->adresse; $this->cp = $obj->cp; $this->ville = $obj->ville; + + $this->fk_departement = $obj->fk_departement; + $this->departement_code = $obj->fk_departement?$obj->departement_code:''; + $this->departement = $obj->fk_departement?$obj->departement:''; + $this->pays_id = $obj->pays_id; $this->pays_code = $obj->pays_code; if ($langs->trans("Country".$obj->pays_code) != "Country".$obj->pays_code) $this->pays = $langs->trans("Country".$obj->pays_code); elseif ($obj->pays_lib) $this->pays=$obj->pays_lib; else $this->pays=$obj->pays; + $this->phone = $obj->phone; $this->phone_perso = $obj->phone_perso; $this->phone_mobile = $obj->phone_mobile; diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php index d7421a22dc4..052c93a0f5a 100644 --- a/htdocs/adherents/fiche.php +++ b/htdocs/adherents/fiche.php @@ -239,7 +239,9 @@ if ($_REQUEST["action"] == 'update' && ! $_POST["cancel"] && $user->rights->adhe $adh->adresse = trim($_POST["adresse"]); $adh->cp = trim($_POST["cp"]); $adh->ville = trim($_POST["ville"]); - $adh->pays_id = $_POST["pays"]; + + $adh->fk_departement = $_POST["departement_id"]; + $adh->pays_id = $_POST["pays"]; $adh->phone = trim($_POST["phone"]); $adh->phone_perso = trim($_POST["phone_perso"]); @@ -357,6 +359,7 @@ if ($_POST["action"] == 'add' && $user->rights->adherent->creer) $adresse=$_POST["adresse"]; $cp=$_POST["cp"]; $ville=$_POST["ville"]; + $departement_id=$_POST["departement_id"]; $pays_id=$_POST["pays_id"]; $phone=$_POST["phone"]; @@ -381,6 +384,7 @@ if ($_POST["action"] == 'add' && $user->rights->adherent->creer) $adh->adresse = $adresse; $adh->cp = $cp; $adh->ville = $ville; + $adh->fk_departement = $departement_id; $adh->pays_id = $pays_id; $adh->phone = $phone; $adh->phone_perso = $phone_perso; @@ -660,6 +664,8 @@ $htmlcompany = new FormCompany($db); // fetch optionals attributes and labels $adho->fetch_name_optionals_label(); +$countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; + if ($action == 'edit') { @@ -682,9 +688,24 @@ if ($action == 'edit') $adht->fetch($adh->typeid); - /* - * Affichage onglets - */ + // We set pays_id, and pays_code label of the chosen country + if ($adh->pays_id) + { + $sql = "SELECT code, libelle from ".MAIN_DB_PREFIX."c_pays where rowid = ".(isset($_POST["pays"])?$_POST["pays"]:$adh->pays_id); + $resql=$db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + } + else + { + dol_print_error($db); + } + $adh->pays_code=$obj->code; + $adh->pays=$langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->libelle; + } + + $head = member_prepare_head($adh); dol_fiche_head($head, 'general', $langs->trans("Member"), 0, 'user'); @@ -696,11 +717,11 @@ if ($action == 'edit') if ($mesg) print '
'.$mesg.'
'; - $rowspan=15; + $rowspan=17; $rowspan+=sizeof($adho->attribute_label); if ($conf->societe->enabled) $rowspan++; - print '
'; + print ''; print ''; print ""; print ""; @@ -715,20 +736,20 @@ if ($action == 'edit') $morphys["phy"] = $langs->trans("Physical"); $morphys["mor"] = $langs->trans("Morale"); print ''.$langs->trans("Person").''; - $html->select_array("morphy", $morphys, $adh->morphy); + $html->select_array("morphy", $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$adh->morphy); print ""; // Societe - print ''.$langs->trans("Company").''; + print ''.$langs->trans("Company").'societe).'">'; // Civilite print ''.$langs->trans("UserTitle").''; - print $htmlcompany->select_civilite($adh->civilite_id); + print $htmlcompany->select_civilite(isset($_POST["civilite_id"])?$_POST["civilite_id"]:$adh->civilite_id)."\n"; print ''; // Photo print ''; - print $html->showphoto('memberphoto',$adh); + print $html->showphoto('memberphoto',$adh)."\n"; if ($caneditfieldmember) { print '

'; @@ -740,24 +761,24 @@ if ($action == 'edit') print ''; // Nom - print ''; + print ''; print ''; // Prenom - print ''; + print ''; print ''; // Login - print ''; + print ''; // Password - print ''; + print ''; // Type print ''; + print ''; - // Cp - print ''; + // Zip / Town + print ''; // Country print ''; + + // Department + print ''; // Tel - print ''; + print ''; // Tel perso - print ''; + print ''; // Tel mobile - print ''; + print ''; // EMail - print ''; + print ''; // Date naissance print "\n"; // Profil public print "\n"; // Attributs supplementaires @@ -833,7 +860,7 @@ if ($action == 'edit') print ''; print ''; @@ -852,6 +879,27 @@ if ($action == 'create') /* Fiche creation */ /* */ /* ************************************************************************** */ + $adh->fk_departement = $_POST["departement_id"]; + + // We set pays_id, pays_code and label for the selected country + $adh->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$conf->global->MAIN_INFO_SOCIETE_PAYS; + if ($adh->pays_id) + { + $sql = "SELECT code, libelle"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_pays"; + $sql.= " WHERE rowid = ".$adh->pays_id; + $resql=$db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + } + else + { + dol_print_error($db); + } + $adh->pays_code=$obj->code; + $adh->pays=$obj->libelle; + } $adht = new AdherentType($db); @@ -863,7 +911,7 @@ if ($action == 'create') } if ($mesg) print '
'.$mesg.'
'; - print ''; + print ''; print ''; print ''; @@ -873,27 +921,27 @@ if ($action == 'create') $morphys["phy"] = "Physique"; $morphys["mor"] = "Morale"; print '\n"; // Company - print ''; + print ''; // Civility print ''; + print $htmlcompany->select_civilite(isset($_POST["civilite_id"])?$_POST["civilite_id"]:$adh->civilite_id,'civilite_id').''; print ''; // Nom - print ''; + print ''; print ''; // Prenom - print ''; + print ''; print ''; // Login - print ''; + print ''; // Mot de passe $generated_password=''; @@ -915,7 +963,7 @@ if ($action == 'create') $listetype=$adht->liste_array(); if (sizeof($listetype)) { - $html->select_array("typeid", $listetype, $typeid, 1); + $html->select_array("typeid", $listetype, isset($_POST["typeid"])?$_POST["typeid"]:$typeid, 1); } else { print ''.$langs->trans("NoTypeDefinedGoToSetup").''; } @@ -923,31 +971,45 @@ if ($action == 'create') // Address print ''; + print ''; // CP / Ville - print ''; + print ''; - // Pays - print ''; + // Country + $adh->pays_id=$adh->pays_id?$adh->pays_id:$mysoc->pays_id; + print ''; + + // State + print ''; // Tel pro - print ''; + print ''; // Tel perso - print ''; + print ''; // Tel mobile - print ''; + print ''; // EMail - print ''; + print ''; // Date naissance print "\n"; // Profil public @@ -958,7 +1020,7 @@ if ($action == 'create') // Attribut optionnels foreach($adho->attribute_label as $key=>$value) { - print "\n"; + print "'."\n"; } /* @@ -1159,12 +1221,15 @@ if ($rowid && $action != 'edit') // Address print ''; - // CP / Ville + // Zip / Town print ''; - // Pays + // Pays print ''; + // Department + print ''; + // Tel pro. print ''; diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index ba47b2a2304..56c663a9d4f 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -398,11 +398,13 @@ class Contact extends CommonObject $langs->load("companies"); $sql = "SELECT c.rowid, c.fk_soc, c.civilite as civilite_id, c.name, c.firstname,"; $sql.= " c.address, c.cp, c.ville,"; - $sql.= " c.fk_pays, p.libelle as pays, p.code as pays_code,"; - $sql.= " c.fk_departement, d.nom as departement, d.code_departement as departement_code,"; + $sql.= " c.fk_pays,"; + $sql.= " c.fk_departement,"; $sql.= " c.birthday,"; $sql.= " c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email, c.jabberid,"; $sql.= " c.priv, c.note, c.default_lang,"; + $sql.= " p.libelle as pays, p.code as pays_code,"; + $sql.= " d.nom as departement, d.code_departement as departement_code,"; $sql.= " u.rowid as user_id, u.login as user_login,"; $sql.= " s.nom as socname, s.address as socaddress, s.cp as soccp, s.ville as soccity, s.default_lang as socdefault_lang"; $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as c"; @@ -432,12 +434,12 @@ class Contact extends CommonObject $this->adresse = $obj->address?$obj->address:$obj->socaddress; // TODO obsolete $this->cp = $obj->cp?$obj->cp:$obj->soccp; $this->ville = $obj->ville?$obj->ville:$obj->soccity; - $this->fk_pays = $obj->fk_pays; $this->fk_departement = $obj->fk_departement; $this->departement_code = $obj->fk_departement?$obj->departement_code:''; $this->departement = $obj->fk_departement?$obj->departement:''; + $this->fk_pays = $obj->fk_pays; $this->pays_code = $obj->fk_pays?$obj->pays_code:''; $this->pays = ($obj->fk_pays > 0)?$langs->transnoentities("Country".$obj->pays_code):$langs->transnoentities("SelectCountry"); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 1dfc6300460..33705295c36 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -266,92 +266,40 @@ class Form $sql = "SELECT rowid, code, libelle, active"; $sql.= " FROM ".MAIN_DB_PREFIX."c_pays"; $sql.= " WHERE active = 1"; - // \TODO A virer - if ($conf->use_javascript_ajax && $conf->global->CODE_DE_TEST) - { - if (is_numeric($selected)) - { - $sql.= " AND rowid = ".$selected; - } - else - { - $sql.= " AND code = '".$selected."'"; - } - } $sql.= " ORDER BY code ASC"; dol_syslog("Form::select_pays sql=".$sql); $resql=$this->db->query($sql); if ($resql) { - // \TODO A virer - if ($conf->use_javascript_ajax && $conf->global->CODE_DE_TEST) + print ''; - } - else - { - print ''; - } - - print ajax_indicator($htmlname,'working'); - print ajax_autocompleter($pays_id,'pays',DOL_URL_ROOT.'/societe/ajaxcountries.php',''); - } - else - { - print ''; - return 0; } + print ''; + return 0; } else { diff --git a/htdocs/install/mysql/migration/2.8.0-2.9.0.sql b/htdocs/install/mysql/migration/2.8.0-2.9.0.sql index 603ee85df91..528e5c201dd 100755 --- a/htdocs/install/mysql/migration/2.8.0-2.9.0.sql +++ b/htdocs/install/mysql/migration/2.8.0-2.9.0.sql @@ -12,7 +12,9 @@ -- V4.1 UPDATE llx_projet_task set fk_user_valid=NULL WHERE fk_user_valid IS NOT NULL AND fk_user_valid NOT IN (SELECT rowid from llx_user); -ALTER TABLE llx_socpeople ADD COLUMN fk_departement integer DEFAULT 0 after ville; +ALTER TABLE llx_socpeople ADD COLUMN fk_departement integer DEFAULT NULL after ville; +ALTER TABLE llx_adherent ADD COLUMN fk_departement integer DEFAULT NULL after ville; +ALTER TABLE llx_entrepot ADD COLUMN fk_departement integer DEFAULT NULL after ville; ALTER TABLE llx_bookmark ADD COLUMN position integer DEFAULT 0; diff --git a/htdocs/install/mysql/tables/llx_adherent.sql b/htdocs/install/mysql/tables/llx_adherent.sql index 22a117af41e..7fff4961116 100644 --- a/htdocs/install/mysql/tables/llx_adherent.sql +++ b/htdocs/install/mysql/tables/llx_adherent.sql @@ -42,6 +42,7 @@ create table llx_adherent adresse text, cp varchar(30), ville varchar(50), + fk_departement integer, pays integer, email varchar(255), phone varchar(30), diff --git a/htdocs/install/mysql/tables/llx_entrepot.sql b/htdocs/install/mysql/tables/llx_entrepot.sql index bb32b2d065c..792607fb10e 100644 --- a/htdocs/install/mysql/tables/llx_entrepot.sql +++ b/htdocs/install/mysql/tables/llx_entrepot.sql @@ -31,6 +31,7 @@ create table llx_entrepot address varchar(255), cp varchar(10), ville varchar(50), + fk_departement integer, fk_pays integer DEFAULT 0, statut tinyint DEFAULT 1, -- 1 open, 0 close valo_pmp float(12,4), -- valoristaion du stock en PMP diff --git a/htdocs/install/mysql/tables/llx_socpeople.sql b/htdocs/install/mysql/tables/llx_socpeople.sql index 016fc0a5d42..17c08e3340d 100644 --- a/htdocs/install/mysql/tables/llx_socpeople.sql +++ b/htdocs/install/mysql/tables/llx_socpeople.sql @@ -33,7 +33,7 @@ create table llx_socpeople address varchar(255), cp varchar(25), ville varchar(255), - fk_departement integer DEFAULT 0, + fk_departement integer, fk_pays integer DEFAULT 0, birthday date, poste varchar(80),
'.$langs->trans("PhotoFile").'
'.$langs->trans("Lastname").'
'.$langs->trans("Lastname").'nom).'">
'.$langs->trans("Firstname").'
'.$langs->trans("Firstname").'prenom).'">
'.$langs->trans("Login").'
'.$langs->trans("Login").'login).'">
'.$langs->trans("Password").'
'.$langs->trans("Password").'pass).'">
'.$langs->trans("Type").''; if ($user->rights->adherent->creer) { - $html->select_array("typeid", $adht->liste_array(), $adh->typeid); + $html->select_array("typeid", $adht->liste_array(), (isset($_POST["typeid"])?$_POST["typeid"]:$adh->typeid)); } else { @@ -768,36 +789,42 @@ if ($action == 'edit') // Address print '
'.$langs->trans("Address").''; - print '
'.$langs->trans("Zip").'/'.$langs->trans("Town").'
'.$langs->trans("Zip").'/'.$langs->trans("Town").'cp).'"> ville).'">
'.$langs->trans("Country").''; - $html->select_pays($adh->pays_code?$adh->pays_code:$mysoc->pays_code,'pays'); + $html->select_pays(isset($_POST["pays"])?$_POST["pays"]:$adh->pays_id,'pays',$conf->use_javascript_ajax?' onChange="company_save_refresh_edit()"':''); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); + print '
'.$langs->trans('State').''; + $htmlcompany->select_departement($adh->fk_departement,$adh->pays_code); print '
'.$langs->trans("PhonePro").'
'.$langs->trans("PhonePro").'phone).'">
'.$langs->trans("PhonePerso").'
'.$langs->trans("PhonePerso").'phone_perso).'">
'.$langs->trans("PhoneMobile").'
'.$langs->trans("PhoneMobile").'phone_mobile).'">
'.($conf->global->ADHERENT_MAIL_REQUIRED?'':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'':'').'
'.($conf->global->ADHERENT_MAIL_REQUIRED?'':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'':'').'email).'">
".$langs->trans("Birthday")."\n"; - $html->select_date(($adh->naiss ? $adh->naiss : -1),'naiss','','',1,'update'); + $html->select_date(($adh->naiss ? $adh->naiss : -1),'naiss','','',1,'formsoc'); print "
".$langs->trans("Public")."\n"; - print $html->selectyesno("public",$adh->public,1); + print $html->selectyesno("public",(isset($_POST["public"])?$_POST["public"]:$adh->public),1); print "
'; - print ''; + print ''; print '       '; print ''; print '
'.$langs->trans("Person")."\n"; - $html->select_array("morphy", $morphys, $adh->morphy, 1); + $html->select_array("morphy", $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$adh->morphy, 1); print "
'.$langs->trans("Company").'
'.$langs->trans("Company").'societe).'">
'.$langs->trans("UserTitle").''; - print $htmlcompany->select_civilite($adh->civilite_id,'civilite_id').'
'.$langs->trans("Lastname").'
'.$langs->trans("Lastname").'nom).'" size="40">
'.$langs->trans("Firstname").'
'.$langs->trans("Firstname").'prenom).'">
'.$langs->trans("Login").'
'.$langs->trans("Login").'login).'">
'.$langs->trans("Address").''; - print '
'.$langs->trans("Zip").' / '.$langs->trans("Town").'
'.$langs->trans("Zip").' / '.$langs->trans("Town").'cp).'"> ville).'">
'.$langs->trans("Country").''; - $html->select_pays($adh->pays_id ? $adh->pays_id : $mysoc->pays_id,'pays_id'); - print '
'.$langs->trans("Country").''; + $html->select_pays(isset($_POST["pays_id"])?$_POST["pays_id"]:$adh->pays_id,'pays_id',$conf->use_javascript_ajax?' onChange="company_save_refresh_create()"':''); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); + print '
'.$langs->trans('State').''; + if ($adh->pays_id) + { + $htmlcompany->select_departement(isset($_POST["departement_id"])?$_POST["departement_id"]:$adh->fk_departement,$adh->pays_code); + } + else + { + print $countrynotdefined; + } + print '
'.$langs->trans("PhonePro").'
'.$langs->trans("PhonePro").'phone).'">
'.$langs->trans("PhonePerso").'
'.$langs->trans("PhonePerso").'phone_perso).'">
'.$langs->trans("PhoneMobile").'
'.$langs->trans("PhoneMobile").'phone_mobile).'">
'.($conf->global->ADHERENT_MAIL_REQUIRED?'':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'':'').'
'.($conf->global->ADHERENT_MAIL_REQUIRED?'':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'':'').'email).'">
".$langs->trans("Birthday")."\n"; - $html->select_date(($adh->naiss ? $adh->naiss : -1),'naiss','','',1,'add'); + $html->select_date(($adh->naiss ? $adh->naiss : -1),'naiss','','',1,'formsoc'); print "
$value
".$value.'
'.$langs->trans("Address").''.nl2br($adh->adresse).'
'.$langs->trans("Zip").' / '.$langs->trans("Town").''.$adh->cp.' '.$adh->ville.'
'.$langs->trans("Country").''.getCountryLabel($adh->pays_id).'
'.$langs->trans('State').''.$adh->departement.'
'.$langs->trans("PhonePro").''.dol_print_phone($adh->phone,$adh->pays_code,0,$adh->fk_soc,1).'