diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 3c8da38dd5b..cb075d5d639 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -423,11 +423,11 @@ class Adherent extends CommonObject if (sizeof($this->array_options) > 0) { - $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."adherent_extrafields WHERE fk_member = ".$this->id; + $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."adherent_extrafields WHERE fk_object = ".$this->id; dol_syslog(get_class($this)."::update sql=".$sql_del); $this->db->query($sql_del); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent_extrafields (fk_member"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent_extrafields (fk_object"; foreach($this->array_options as $key => $value) { // Add field of attribut @@ -643,7 +643,7 @@ class Adherent extends CommonObject $this->db->begin(); // Suppression options - $sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_extrafields WHERE fk_member = ".$rowid; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_extrafields WHERE fk_object = ".$rowid; dol_syslog(get_class($this)."::delete sql=".$sql); $resql=$this->db->query($sql); @@ -1092,54 +1092,6 @@ class Adherent extends CommonObject } - /** - * Function to get extra fields of a member into $this->array_options - * @param rowid - * TODO Move this function into ExtraField class - * TODO rename field fk_member into fk_element - */ - function fetch_optionals($rowid) - { - require_once(DOL_DOCUMENT_ROOT."/core/class/extrafields.class.php"); - $options = new ExtraFields($this->db); - $optionsArray = $options->fetch_name_optionals_label(); - - $tab=array(); - - $sql = "SELECT rowid"; - foreach ($optionsArray as $name => $label) - { - $sql.= ", ".$name; - } - $sql.= " FROM ".MAIN_DB_PREFIX."adherent_extrafields"; - $sql.= " WHERE fk_member=".$rowid; - - dol_syslog(get_class($this)."::fetch_optionals sql=".$sql, LOG_DEBUG); - $result=$this->db->query( $sql); - if ($result) - { - if ($this->db->num_rows($result)) - { - $tab = $this->db->fetch_array($result); - - foreach ($tab as $key => $value) - { - if ($key != 'rowid' && $key != 'tms' && $key != 'fk_member') - { - // we can add this attribute to adherent object - $this->array_options["options_$key"]=$value; - } - } - } - } - else - { - dol_print_error($this->db); - } - - } - - /** * Fonction qui insere la cotisation dans la base de donnees * et eventuellement liens dans banques, mailman, etc... diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php index e703f6b97dd..49c6b2453e2 100644 --- a/htdocs/adherents/fiche.php +++ b/htdocs/adherents/fiche.php @@ -47,8 +47,9 @@ $langs->load("users"); if (! $user->rights->adherent->lire) accessforbidden(); $adh = new Adherent($db); -$adho = new ExtraFields($db); -$errmsg=''; +$extrafields = new ExtraFields($db); + +$errmsg=''; $errmsgs=array(); $action=GETPOST("action"); $rowid=GETPOST("rowid"); @@ -595,14 +596,15 @@ if ($user->rights->adherent->creer && $_POST["action"] == 'confirm_add_spip' && * View */ -llxHeader('',$langs->trans("Member"),'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'); +// fetch optionals attributes and labels +$extralabels=$extrafields->fetch_name_optionals_label('member'); + +$help_url='EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'; +llxHeader('',$langs->trans("Member"),$help_url); $html = new Form($db); $htmlcompany = new FormCompany($db); -// fetch optionals attributes and labels -$adho->fetch_name_optionals_label(); - $countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; if ($action == 'create') @@ -692,11 +694,11 @@ if ($action == 'create') print $htmlcompany->select_civilite(isset($_POST["civilite_id"])?$_POST["civilite_id"]:$adh->civilite_id,'civilite_id').''; print ''; - // Nom + // Lastname print '