From 2d55666a0bbfde187bba42c4572906c8f51667ee Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 18 Nov 2018 21:50:58 +0100 Subject: [PATCH] NEW Add gender in member card --- htdocs/adherents/card.php | 32 ++++++++++++++-- htdocs/adherents/class/adherent.class.php | 38 +++++++++++-------- htdocs/adherents/list.php | 31 +++++++++++++-- htdocs/core/modules/modAdherent.class.php | 23 +++++------ .../install/mysql/migration/9.0.0-10.0.0.sql | 30 +++++++++++++++ htdocs/install/mysql/tables/llx_adherent.sql | 1 + 6 files changed, 120 insertions(+), 35 deletions(-) create mode 100644 htdocs/install/mysql/migration/9.0.0-10.0.0.sql diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 347c29fc30d..dec2ef6ec2e 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -5,7 +5,7 @@ * Copyright (C) 2005-2018 Regis Houssin * Copyright (C) 2012 Marcos García * Copyright (C) 2012-2018 Philippe Grand - * Copyright (C) 2015-2016 Alexandre Spangaro + * Copyright (C) 2015-2018 Alexandre Spangaro * Copyright (C) 2018 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -23,9 +23,9 @@ */ /** - * \file htdocs/adherents/card.php - * \ingroup member - * \brief Page of member + * \file htdocs/adherents/card.php + * \ingroup member + * \brief Page of member */ require '../main.inc.php'; @@ -249,6 +249,7 @@ if (empty($reshook)) } $lastname=$_POST["lastname"]; $firstname=$_POST["firstname"]; + $gender = $_POST["gender"]; $societe=$_POST["societe"]; $morphy=$_POST["morphy"]; $login=$_POST["login"]; @@ -284,6 +285,7 @@ if (empty($reshook)) $object->civility_id = trim(GETPOST("civility_id",'alpha')); $object->firstname = trim(GETPOST("firstname",'alpha')); $object->lastname = trim(GETPOST("lastname",'alpha')); + $object->gender = trim(GETPOST("gender",'alpha')); $object->login = trim(GETPOST("login",'alpha')); $object->pass = trim(GETPOST("pass",'alpha')); @@ -434,6 +436,7 @@ if (empty($reshook)) $civility_id=GETPOST("civility_id",'int'); $lastname=GETPOST("lastname",'alpha'); $firstname=GETPOST("firstname",'alpha'); + $gender=GETPOST("gender",'alpha'); $societe=GETPOST("societe",'alpha'); $address=GETPOST("address",'alpha'); $zip=GETPOST("zipcode",'alpha'); @@ -462,6 +465,7 @@ if (empty($reshook)) $object->civility_id = $civility_id; $object->firstname = $firstname; $object->lastname = $lastname; + $object->gender = $gender; $object->societe = $societe; $object->address = $address; $object->zip = $zip; @@ -954,6 +958,13 @@ else print ''.$langs->trans("Firstname").''; print ''; + // Gender + print ''.$langs->trans("Gender").''; + print ''; + $arraygender=array('man'=>$langs->trans("Genderman"),'woman'=>$langs->trans("Genderwoman")); + print $form->selectarray('gender', $arraygender, GETPOST('gender'), 1); + print ''; + // EMail print ''.($conf->global->ADHERENT_MAIL_REQUIRED?'':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'':'').''; @@ -1196,6 +1207,13 @@ else print ''.$langs->trans("Firstname").'firstname).'">'; print ''; + // Gender + print ''.$langs->trans("Gender").''; + print ''; + $arraygender=array('man'=>$langs->trans("Genderman"),'woman'=>$langs->trans("Genderwoman")); + print $form->selectarray('gender', $arraygender, GETPOST('gender')?GETPOST('gender'):$object->gender, 1); + print ''; + // Photo print ''.$langs->trans("Photo").''; print ''; @@ -1580,6 +1598,12 @@ else print ''.$langs->trans("Nature").''.$object->getmorphylib().''; print ''; + // Gender + print ''.$langs->trans("Gender").''; + print ''; + if ($object->gender) print $langs->trans("Gender".$object->gender); + print ''; + // Company print ''.$langs->trans("Company").''.$object->societe.''; diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 9d6c5d02bb4..ed058d823da 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -5,7 +5,7 @@ * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2009-2017 Regis Houssin - * Copyright (C) 2014-2016 Alexandre Spangaro + * Copyright (C) 2014-2018 Alexandre Spangaro * Copyright (C) 2015 Marcos García * Copyright (C) 2015-2018 Frédéric France * Copyright (C) 2015 Raphaël Doursenaud @@ -127,6 +127,7 @@ class Adherent extends CommonObject public $datem; public $datevalid; + public $gender; public $birth; public $note_public; @@ -457,17 +458,18 @@ class Adherent extends CommonObject dol_syslog(get_class($this)."::update notrigger=".$notrigger.", nosyncuser=".$nosyncuser.", nosyncuserpass=".$nosyncuserpass." nosyncthirdparty=".$nosyncthirdparty.", email=".$this->email); // Clean parameters - $this->lastname=trim($this->lastname)?trim($this->lastname):trim($this->lastname); - $this->firstname=trim($this->firstname)?trim($this->firstname):trim($this->firstname); - $this->address=($this->address?$this->address:$this->address); - $this->zip=($this->zip?$this->zip:$this->zip); - $this->town=($this->town?$this->town:$this->town); - $this->country_id=($this->country_id > 0?$this->country_id:$this->country_id); - $this->state_id=($this->state_id > 0?$this->state_id:$this->state_id); + $this->lastname = trim($this->lastname)?trim($this->lastname):trim($this->lastname); + $this->firstname = trim($this->firstname)?trim($this->firstname):trim($this->firstname); + $this->gender = trim($this->gender); + $this->address = ($this->address?$this->address:$this->address); + $this->zip = ($this->zip?$this->zip:$this->zip); + $this->town = ($this->town?$this->town:$this->town); + $this->country_id = ($this->country_id > 0?$this->country_id:$this->country_id); + $this->state_id = ($this->state_id > 0?$this->state_id:$this->state_id); if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname=ucwords(trim($this->lastname)); if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname=ucwords(trim($this->firstname)); - $this->note_public=($this->note_public?$this->note_public:$this->note_public); - $this->note_private=($this->note_private?$this->note_private:$this->note_private); + $this->note_public = ($this->note_public?$this->note_public:$this->note_public); + $this->note_private = ($this->note_private?$this->note_private:$this->note_private); // Check parameters if (! empty($conf->global->ADHERENT_MAIL_REQUIRED) && ! isValidEMail($this->email)) @@ -483,6 +485,7 @@ class Adherent extends CommonObject $sql.= " civility = ".($this->civility_id?"'".$this->db->escape($this->civility_id)."'":"null"); $sql.= ", firstname = ".($this->firstname?"'".$this->db->escape($this->firstname)."'":"null"); $sql.= ", lastname = ".($this->lastname?"'".$this->db->escape($this->lastname)."'":"null"); + $sql.= ", gender = ".($this->gender != -1 ? "'".$this->db->escape($this->gender)."'" : "null"); // 'man' or 'woman' $sql.= ", login = ".($this->login?"'".$this->db->escape($this->login)."'":"null"); $sql.= ", societe = ".($this->societe?"'".$this->db->escape($this->societe)."'":"null"); $sql.= ", fk_soc = ".($this->fk_soc > 0?$this->db->escape($this->fk_soc):"null"); @@ -589,15 +592,16 @@ class Adherent extends CommonObject $luser->civility_id=$this->civility_id; $luser->firstname=$this->firstname; $luser->lastname=$this->lastname; + $luser->gender=$this->gender; $luser->pass=$this->pass; $luser->societe_id=$this->societe; $luser->birth=$this->birth; - $luser->address=$this->address; - $luser->zip=$this->zip; - $luser->town=$this->town; - $luser->country_id=$this->country_id; - $luser->state_id=$this->state_id; + $luser->address=$this->address; + $luser->zip=$this->zip; + $luser->town=$this->town; + $luser->country_id=$this->country_id; + $luser->state_id=$this->state_id; $luser->email=$this->email; $luser->skype=$this->skype; @@ -1129,7 +1133,7 @@ class Adherent extends CommonObject { global $langs; - $sql = "SELECT d.rowid, d.ref_ext, d.civility as civility_id, d.firstname, d.lastname, d.societe as company, d.fk_soc, d.statut, d.public, d.address, d.zip, d.town, d.note_private,"; + $sql = "SELECT d.rowid, d.ref_ext, d.civility as civility_id, d.gender, d.firstname, d.lastname, d.societe as company, d.fk_soc, d.statut, d.public, d.address, d.zip, d.town, d.note_private,"; $sql.= " d.note_public,"; $sql.= " d.email, d.skype, d.twitter, d.facebook, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass, d.pass_crypted,"; $sql.= " d.photo, d.fk_adherent_type, d.morphy, d.entity,"; @@ -1176,6 +1180,7 @@ class Adherent extends CommonObject $this->civility_id = $obj->civility_id; $this->firstname = $obj->firstname; $this->lastname = $obj->lastname; + $this->gender = $obj->gender; $this->login = $obj->login; $this->societe = $obj->company; $this->company = $obj->company; @@ -2288,6 +2293,7 @@ class Adherent extends CommonObject $this->civility_id = 0; $this->lastname = 'DOLIBARR'; $this->firstname = 'SPECIMEN'; + $this->gender='man'; $this->login='dolibspec'; $this->pass='dolibspec'; $this->societe = 'Societe ABC'; diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 39d0069ac7c..5156926d293 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -4,6 +4,7 @@ * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2013-2015 Raphaël Doursenaud * Copyright (C) 2014-2016 Juanjo Menent + * Copyright (C) 2018 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,9 +21,9 @@ */ /** - * \file htdocs/adherents/list.php - * \ingroup member - * \brief Page to list all members of foundation + * \file htdocs/adherents/list.php + * \ingroup member + * \brief Page to list all members of foundation */ require '../main.inc.php'; @@ -48,6 +49,7 @@ $search=GETPOST("search",'alpha'); $search_ref=GETPOST("search_ref",'alpha'); $search_lastname=GETPOST("search_lastname",'alpha'); $search_firstname=GETPOST("search_firstname",'alpha'); +$search_gender=GETPOST("search_gender",'alpha'); $search_civility=GETPOST("search_civility",'alpha'); $search_login=GETPOST("search_login",'alpha'); $search_address=GETPOST("search_address",'alpha'); @@ -109,6 +111,7 @@ $arrayfields=array( 'd.civility'=>array('label'=>$langs->trans("Civility"), 'checked'=>0), 'd.lastname'=>array('label'=>$langs->trans("Lastname"), 'checked'=>1), 'd.firstname'=>array('label'=>$langs->trans("Firstname"), 'checked'=>1), + 'd.gender'=>array('label'=>$langs->trans("Gender"), 'checked'=>0), 'd.company'=>array('label'=>$langs->trans("Company"), 'checked'=>1), 'd.login'=>array('label'=>$langs->trans("Login"), 'checked'=>1), 'd.morphy'=>array('label'=>$langs->trans("MorPhy"), 'checked'=>1), @@ -162,6 +165,7 @@ if (empty($reshook)) $search_ref=""; $search_lastname=""; $search_firstname=""; + $search_gender=""; $search_civility=""; $search_login=""; $search_company=""; @@ -205,7 +209,7 @@ $memberstatic=new Adherent($db); $now=dol_now(); -$sql = "SELECT d.rowid, d.login, d.lastname, d.firstname, d.societe as company, d.fk_soc,"; +$sql = "SELECT d.rowid, d.login, d.lastname, d.firstname, d.gender, d.societe as company, d.fk_soc,"; $sql.= " d.civility, d.datefin, d.address, d.zip, d.town, d.state_id, d.country,"; $sql.= " d.email, d.phone, d.phone_perso, d.phone_mobile, d.skype, d.birth, d.public, d.photo,"; $sql.= " d.fk_adherent_type as type_id, d.morphy, d.statut, d.datec as date_creation, d.tms as date_update,"; @@ -240,6 +244,7 @@ if ($search_ref) if ($search_civility) $sql.= natural_search("d.civility", $search_civility); if ($search_firstname) $sql.= natural_search("d.firstname", $search_firstname); if ($search_lastname) $sql.= natural_search(array("d.firstname", "d.lastname", "d.societe"), $search_lastname); +if ($search_gender != '' && $search_gender != '-1') $sql.= " AND d.gender = '".$search_gender."'"; if ($search_login) $sql.= natural_search("d.login", $search_login); if ($search_email) $sql.= natural_search("d.email", $search_email); if ($search_town) $sql.= natural_search("d.town",$search_town); @@ -329,6 +334,7 @@ if ($search_nom) $param.="&search_nom=".urlencode($search_nom); if ($search_civility) $param.="&search_civility=".urlencode($search_civility); if ($search_firstname) $param.="&search_firstname=".urlencode($search_firstname); if ($search_lastname) $param.="&search_lastname=".urlencode($search_lastname); +if ($search_gender) $param.="&search_gender=".urlencode($search_gender); if ($search_login) $param.="&search_login=".urlencode($search_login); if ($search_email) $param.="&search_email=".urlencode($search_email); if ($search_company) $param.="&search_company=".urlencode($search_company); @@ -447,6 +453,13 @@ if (! empty($arrayfields['d.lastname']['checked'])) print ''; print ''; } +if (! empty($arrayfields['d.gender']['checked'])) +{ + print ''; + $arraygender=array('man'=>$langs->trans("Genderman"),'woman'=>$langs->trans("Genderwoman")); + print $form->selectarray('search_gender', $arraygender, $search_gender, 1); + print ''; +} if (! empty($arrayfields['d.company']['checked'])) { print ''; @@ -575,6 +588,7 @@ if (! empty($arrayfields['d.ref']['checked'])) print_liste_field_titr if (! empty($arrayfields['d.civility']['checked'])) print_liste_field_titre($arrayfields['d.civility']['label'],$_SERVER["PHP_SELF"],'d.civility','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['d.firstname']['checked'])) print_liste_field_titre($arrayfields['d.firstname']['label'],$_SERVER["PHP_SELF"],'d.firstname','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['d.lastname']['checked'])) print_liste_field_titre($arrayfields['d.lastname']['label'],$_SERVER["PHP_SELF"],'d.lastname','',$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['d.gender']['checked'])) print_liste_field_titre($arrayfields['d.gender']['label'],$_SERVER['PHP_SELF'],'d.gender',$param,"","",$sortfield,$sortorder); if (! empty($arrayfields['d.company']['checked'])) print_liste_field_titre($arrayfields['d.company']['label'],$_SERVER["PHP_SELF"],'d.societe','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['d.login']['checked'])) print_liste_field_titre($arrayfields['d.login']['label'],$_SERVER["PHP_SELF"],'d.login','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['d.morphy']['checked'])) print_liste_field_titre($arrayfields['d.morphy']['label'],$_SERVER["PHP_SELF"],'d.morphy','',$param,'',$sortfield,$sortorder); @@ -613,6 +627,7 @@ while ($i < min($num, $limit)) $memberstatic->civility_id=$obj->civility; $memberstatic->lastname=$obj->lastname; $memberstatic->firstname=$obj->firstname; + $memberstatic->gender=$obj->gender; $memberstatic->statut=$obj->statut; $memberstatic->datefin= $datefin; $memberstatic->socid = $obj->fk_soc; @@ -661,6 +676,14 @@ while ($i < min($num, $limit)) print $obj->lastname; print "\n"; } + // Gender + if (! empty($arrayfields['d.gender']['checked'])) + { + print ''; + if ($obj->gender) print $langs->trans("Gender".$obj->gender); + print ''; + if (! $i) $totalarray['nbfield']++; + } // Company if (! empty($arrayfields['d.company']['checked'])) { diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php index 9f09c01bfc7..71e99ea3de1 100644 --- a/htdocs/core/modules/modAdherent.class.php +++ b/htdocs/core/modules/modAdherent.class.php @@ -1,11 +1,12 @@ - * Copyright (C) 2003 Jean-Louis Bergamo - * Copyright (C) 2004-2012 Laurent Destailleur - * Copyright (C) 2004 Sebastien Di Cintio - * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2013 Juanjo Menent - * Copyright (C) 2014-2015 Raphaël Doursenaud +/* Copyright (C) 2003,2005 Rodolphe Quiedeville + * Copyright (C) 2003 Jean-Louis Bergamo + * Copyright (C) 2004-2012 Laurent Destailleur + * Copyright (C) 2004 Sebastien Di Cintio + * Copyright (C) 2004 Benoit Mortier + * Copyright (C) 2013 Juanjo Menent + * Copyright (C) 2014-2015 Raphaël Doursenaud + * Copyright (C) 2018 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -268,7 +269,7 @@ class modAdherent extends DolibarrModules $this->export_label[$r]='MembersAndSubscriptions'; $this->export_permission[$r]=array(array("adherent","export")); $this->export_fields_array[$r]=array( - 'a.rowid'=>'Id','a.civility'=>"UserTitle",'a.lastname'=>"Lastname",'a.firstname'=>"Firstname",'a.login'=>"Login",'a.morphy'=>'Nature', + 'a.rowid'=>'Id','a.civility'=>"UserTitle",'a.lastname'=>"Lastname",'a.firstname'=>"Firstname",'a.login'=>"Login",'a.gender'=>"Gender",'a.morphy'=>'Nature', 'a.societe'=>'Company','a.address'=>"Address",'a.zip'=>"Zip",'a.town'=>"Town",'d.nom'=>"State",'co.code'=>"CountryCode",'co.label'=>"Country", 'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile",'a.email'=>"Email",'a.birth'=>"Birthday",'a.statut'=>"Status", 'a.photo'=>"Photo",'a.note_public'=>"NotePublic",'a.note_private'=>"NotePrivate",'a.datec'=>'DateCreation','a.datevalid'=>'DateValidation', @@ -276,13 +277,13 @@ class modAdherent extends DolibarrModules 'c.rowid'=>'SubscriptionId','c.dateadh'=>'DateSubscription','c.subscription'=>'Amount' ); $this->export_TypeFields_array[$r]=array( - 'a.civility'=>"Text",'a.lastname'=>"Text",'a.firstname'=>"Text",'a.login'=>"Text",'a.morphy'=>'Text','a.societe'=>'Text','a.address'=>"Text", + 'a.civility'=>"Text",'a.lastname'=>"Text",'a.firstname'=>"Text",'a.login'=>"Text",'a.gender'=>'Text','a.morphy'=>'Text','a.societe'=>'Text','a.address'=>"Text", 'a.zip'=>"Text",'a.town'=>"Text",'d.nom'=>"Text",'co.code'=>'Text','co.label'=>"Text",'a.phone'=>"Text",'a.phone_perso'=>"Text",'a.phone_mobile'=>"Text", 'a.email'=>"Text",'a.birth'=>"Date",'a.statut'=>"Status",'a.note_public'=>"Text",'a.note_private'=>"Text",'a.datec'=>'Date','a.datevalid'=>'Date', 'a.tms'=>'Date','a.datefin'=>'Date','ta.rowid'=>'List:adherent_type:libelle','ta.libelle'=>'Text','c.rowid'=>'Numeric','c.dateadh'=>'Date','c.subscription'=>'Numeric' ); $this->export_entities_array[$r]=array( - 'a.rowid'=>'member','a.civility'=>"member",'a.lastname'=>"member",'a.firstname'=>"member",'a.login'=>"member",'a.morphy'=>'member', + 'a.rowid'=>'member','a.civility'=>"member",'a.lastname'=>"member",'a.firstname'=>"member",'a.login'=>"member",'a.gender'=>'member','a.morphy'=>'member', 'a.societe'=>'member','a.address'=>"member",'a.zip'=>"member",'a.town'=>"member",'d.nom'=>"member",'co.code'=>"member",'co.label'=>"member", 'a.phone'=>"member",'a.phone_perso'=>"member",'a.phone_mobile'=>"member",'a.email'=>"member",'a.birth'=>"member",'a.statut'=>"member", 'a.photo'=>"member",'a.note_public'=>"member",'a.note_private'=>"member",'a.datec'=>'member','a.datevalid'=>'member','a.tms'=>'member', @@ -316,7 +317,7 @@ class modAdherent extends DolibarrModules $this->import_tables_array[$r]=array('a'=>MAIN_DB_PREFIX.'adherent','extra'=>MAIN_DB_PREFIX.'adherent_extrafields'); $this->import_tables_creator_array[$r]=array('a'=>'fk_user_author'); // Fields to store import user id $this->import_fields_array[$r]=array( - 'a.civility'=>"UserTitle",'a.lastname'=>"Lastname*",'a.firstname'=>"Firstname",'a.login'=>"Login*","a.pass"=>"Password", + 'a.civility'=>"UserTitle",'a.lastname'=>"Lastname*",'a.firstname'=>"Firstname",'a.gender'=>"Gender",'a.login'=>"Login*","a.pass"=>"Password", "a.fk_adherent_type"=>"MemberType*",'a.morphy'=>'Nature*','a.societe'=>'Company','a.address'=>"Address",'a.zip'=>"Zip",'a.town'=>"Town", 'a.state_id'=>'StateId','a.country'=>"CountryId",'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile", 'a.email'=>"Email",'a.birth'=>"Birthday",'a.statut'=>"Status*",'a.photo'=>"Photo",'a.note_public'=>"NotePublic",'a.note_private'=>"NotePrivate", diff --git a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql new file mode 100644 index 00000000000..c4e18c30672 --- /dev/null +++ b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql @@ -0,0 +1,30 @@ +-- +-- Be carefull to requests order. +-- This file must be loaded by calling /install/index.php page +-- when current version is 10.0.0 or higher. +-- +-- To restrict request to Mysql version x.y minimum use -- VMYSQLx.y +-- To restrict request to Pgsql version x.y minimum use -- VPGSQLx.y +-- To rename a table: ALTER TABLE llx_table RENAME TO llx_table_new; +-- To add a column: ALTER TABLE llx_table ADD COLUMN newcol varchar(60) NOT NULL DEFAULT '0' AFTER existingcol; +-- To rename a column: ALTER TABLE llx_table CHANGE COLUMN oldname newname varchar(60); +-- To drop a column: ALTER TABLE llx_table DROP COLUMN oldname; +-- To change type of field: ALTER TABLE llx_table MODIFY COLUMN name varchar(60); +-- To drop a foreign key: ALTER TABLE llx_table DROP FOREIGN KEY fk_name; +-- To create a unique index ALTER TABLE llx_table ADD UNIQUE INDEX uk_table_field (field); +-- To drop an index: -- VMYSQL4.1 DROP INDEX nomindex on llx_table +-- To drop an index: -- VPGSQL8.2 DROP INDEX nomindex +-- To make pk to be auto increment (mysql): -- VMYSQL4.3 ALTER TABLE llx_table CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT; +-- To make pk to be auto increment (postgres): +-- -- VPGSQL8.2 CREATE SEQUENCE llx_table_rowid_seq OWNED BY llx_table.rowid; +-- -- VPGSQL8.2 ALTER TABLE llx_table ADD PRIMARY KEY (rowid); +-- -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN rowid SET DEFAULT nextval('llx_table_rowid_seq'); +-- -- VPGSQL8.2 SELECT setval('llx_table_rowid_seq', MAX(rowid)) FROM llx_table; +-- To set a field as NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NULL; +-- To set a field as NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name DROP NOT NULL; +-- To set a field as NOT NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NOT NULL; +-- To set a field as NOT NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET NOT NULL; +-- To set a field as default NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET DEFAULT NULL; +-- Note: fields with type BLOB/TEXT can't have default value. + +ALTER TABLE llx_adherent ADD gender VARCHAR(10); diff --git a/htdocs/install/mysql/tables/llx_adherent.sql b/htdocs/install/mysql/tables/llx_adherent.sql index 96da4ffb326..ede4de2e487 100644 --- a/htdocs/install/mysql/tables/llx_adherent.sql +++ b/htdocs/install/mysql/tables/llx_adherent.sql @@ -30,6 +30,7 @@ create table llx_adherent entity integer DEFAULT 1 NOT NULL, -- multi company id ref_ext varchar(128), -- reference into an external system (not used by dolibarr) + gender varchar(10), civility varchar(6), lastname varchar(50), firstname varchar(50),