From 8650054c34e8ced41ecf0a1ce69ae2e960f7ddf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 10 Nov 2020 22:11:03 +0100 Subject: [PATCH 01/11] Update llx_adherent.sql --- htdocs/install/mysql/tables/llx_adherent.sql | 47 ++++++++++---------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/htdocs/install/mysql/tables/llx_adherent.sql b/htdocs/install/mysql/tables/llx_adherent.sql index 6b5490b282d..41646dc7d01 100644 --- a/htdocs/install/mysql/tables/llx_adherent.sql +++ b/htdocs/install/mysql/tables/llx_adherent.sql @@ -27,6 +27,7 @@ create table llx_adherent ( rowid integer AUTO_INCREMENT PRIMARY KEY, + ref varchar(30) NOT NULL, -- member reference number entity integer DEFAULT 1 NOT NULL, -- multi company id ref_ext varchar(128), -- reference into an external system (not used by dolibarr) @@ -34,13 +35,13 @@ create table llx_adherent civility varchar(6), lastname varchar(50), firstname varchar(50), - login varchar(50), -- login - pass varchar(50), -- password + login varchar(50), -- login + pass varchar(50), -- password pass_crypted varchar(128), fk_adherent_type integer NOT NULL, - morphy varchar(3) NOT NULL, -- personne morale / personne physique - societe varchar(128), -- company name (should be same length than societe.name). No more used. - fk_soc integer NULL, -- Link to third party linked to member + morphy varchar(3) NOT NULL, -- personne morale / personne physique + societe varchar(128), -- company name (should be same length than societe.name). No more used. + fk_soc integer NULL, -- Link to third party linked to member address text, zip varchar(30), town varchar(50), @@ -48,34 +49,34 @@ create table llx_adherent country integer, email varchar(255), - socialnetworks text DEFAULT NULL, -- json with socialnetworks - skype varchar(255), - twitter varchar(255), -- - facebook varchar(255), -- - linkedin varchar(255), -- - instagram varchar(255), -- - snapchat varchar(255), -- - googleplus varchar(255), -- - youtube varchar(255), -- - whatsapp varchar(255), -- + socialnetworks text DEFAULT NULL, -- json with socialnetworks + skype varchar(255), -- deprecated + twitter varchar(255), -- deprecated + facebook varchar(255), -- deprecated + linkedin varchar(255), -- deprecated + instagram varchar(255), -- deprecated + snapchat varchar(255), -- deprecated + googleplus varchar(255), -- deprecated + youtube varchar(255), -- deprecated + whatsapp varchar(255), -- deprecated phone varchar(30), phone_perso varchar(30), phone_mobile varchar(30), - birth date, -- birthday - photo varchar(255), -- filename or url of photo + birth date, -- birthday + photo varchar(255), -- filename or url of photo statut smallint NOT NULL DEFAULT 0, public smallint NOT NULL DEFAULT 0, -- certain champ de la fiche sont ils public ou pas ? - datefin datetime, -- date de fin de validite de la cotisation + datefin datetime, -- date de fin de validite de la cotisation note_private text DEFAULT NULL, note_public text DEFAULT NULL, - model_pdf varchar(255), - datevalid datetime, -- date de validation - datec datetime, -- date de creation + model_pdf varchar(255), + datevalid datetime, -- date de validation + datec datetime, -- date de creation tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, -- last modification date - fk_user_author integer, -- can be null because member can be create by a guest + fk_user_author integer, -- can be null because member can be create by a guest fk_user_mod integer, fk_user_valid integer, - canvas varchar(32), -- type of canvas if used (null by default) + canvas varchar(32), -- type of canvas if used (null by default) import_key varchar(14) -- Import key )ENGINE=innodb; From 87678bff7fcd43995d7642d69816907016976043 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 10 Nov 2020 22:14:37 +0100 Subject: [PATCH 02/11] Update 12.0.0-13.0.0.sql --- htdocs/install/mysql/migration/12.0.0-13.0.0.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql index e0fd93aa005..c8567cbee4b 100644 --- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql +++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql @@ -58,6 +58,9 @@ ALTER TABLE llx_mrp_mo_extrafields ADD INDEX idx_mrp_mo_fk_object(fk_object); -- For v13 +-- members +ALTER TABLE llx_adherent ADD COLUMN ref varchar(30) NOT NULL AFTER rowid; +UPDATE llx_adherent SET ref=rowid; ALTER TABLE llx_bom_bom ADD COLUMN bomtype integer DEFAULT 0; From 22713ae9fb17dd9c7cf35775a6bcd50942423531 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 10 Nov 2020 22:19:21 +0100 Subject: [PATCH 03/11] Update llx_adherent.key.sql --- htdocs/install/mysql/tables/llx_adherent.key.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/install/mysql/tables/llx_adherent.key.sql b/htdocs/install/mysql/tables/llx_adherent.key.sql index 2b176bef2d1..750caff808a 100644 --- a/htdocs/install/mysql/tables/llx_adherent.key.sql +++ b/htdocs/install/mysql/tables/llx_adherent.key.sql @@ -19,6 +19,7 @@ ALTER TABLE llx_adherent ADD UNIQUE INDEX uk_adherent_login (login, entity); +ALTER TABLE llx_adherent ADD UNIQUE INDEX uk_adherent_ref (ref, entity); ALTER TABLE llx_adherent ADD UNIQUE INDEX uk_adherent_fk_soc (fk_soc); ALTER TABLE llx_adherent ADD INDEX idx_adherent_fk_adherent_type (fk_adherent_type); From 016c9915ef329f8bd8c450c7a80833b1211fbd2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 10 Nov 2020 22:19:58 +0100 Subject: [PATCH 04/11] Update 12.0.0-13.0.0.sql add ref in class add ref in getNomUrl add ref on card --- htdocs/adherents/card.php | 2 +- htdocs/adherents/class/adherent.class.php | 26 +++++++++++++------ htdocs/adherents/list.php | 25 +++++++++++------- .../install/mysql/migration/12.0.0-13.0.0.sql | 1 + htdocs/install/mysql/tables/llx_adherent.sql | 6 ++--- 5 files changed, 39 insertions(+), 21 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index bd3ad481cd8..ecfcc9caad3 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -1066,7 +1066,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; // Ref - print ''; + print ''; // Login if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 009c73cf318..539524756c9 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -287,6 +287,7 @@ class Adherent extends CommonObject */ public $fields = array( 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 10), + 'ref' => array('type' => 'varchar(30)', 'label' => 'Ref', 'default' => 1, 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 12, 'index' => 1), 'entity' => array('type' => 'integer', 'label' => 'Entity', 'default' => 1, 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'position' => 15, 'index' => 1), 'ref_ext' => array('type' => 'varchar(128)', 'label' => 'Ref ext', 'enabled' => 1, 'visible' => 0, 'position' => 20), 'civility' => array('type' => 'varchar(6)', 'label' => 'Civility', 'enabled' => 1, 'visible' => -1, 'position' => 25), @@ -416,6 +417,7 @@ class Adherent extends CommonObject $infos = ''; if ($this->civility_id) $infos .= $langs->transnoentities("UserTitle").": ".$this->getCivilityLabel()."\n"; $infos .= $langs->transnoentities("id").": ".$this->id."\n"; + $infos .= $langs->transnoentities("ref").": ".$this->ref."\n"; $infos .= $langs->transnoentities("Lastname").": ".$this->lastname."\n"; $infos .= $langs->transnoentities("Firstname").": ".$this->firstname."\n"; $infos .= $langs->transnoentities("Company").": ".$this->company."\n"; @@ -437,15 +439,20 @@ class Adherent extends CommonObject // Substitutions $substitutionarray = array( - '__ID__' => $this->id, '__MEMBER_ID__' => $this->id, '__CIVILITY__' => $this->getCivilityLabel(), + '__ID__' => $this->id, + '__REF__' => $this->ref, + '__MEMBER_ID__' => $this->id, + '__CIVILITY__' => $this->getCivilityLabel(), '__FIRSTNAME__' => $msgishtml ? dol_htmlentitiesbr($this->firstname) : ($this->firstname ? $this->firstname : ''), '__LASTNAME__' => $msgishtml ? dol_htmlentitiesbr($this->lastname) : ($this->lastname ? $this->lastname : ''), '__FULLNAME__' => $msgishtml ? dol_htmlentitiesbr($this->getFullName($langs)) : $this->getFullName($langs), '__COMPANY__' => $msgishtml ? dol_htmlentitiesbr($this->company) : ($this->company ? $this->company : ''), '__ADDRESS__' => $msgishtml ? dol_htmlentitiesbr($this->address) : ($this->address ? $this->address : ''), - '__ZIP__' => $msgishtml ? dol_htmlentitiesbr($this->zip) : ($this->zip ? $this->zip : ''), '__TOWN__' => $msgishtml ? dol_htmlentitiesbr($this->town) : ($this->town ? $this->town : ''), + '__ZIP__' => $msgishtml ? dol_htmlentitiesbr($this->zip) : ($this->zip ? $this->zip : ''), + '__TOWN__' => $msgishtml ? dol_htmlentitiesbr($this->town) : ($this->town ? $this->town : ''), '__COUNTRY__' => $msgishtml ? dol_htmlentitiesbr($this->country) : ($this->country ? $this->country : ''), - '__EMAIL__' => $msgishtml ? dol_htmlentitiesbr($this->email) : ($this->email ? $this->email : ''), '__BIRTH__' => $msgishtml ? dol_htmlentitiesbr($birthday) : ($birthday ? $birthday : ''), + '__EMAIL__' => $msgishtml ? dol_htmlentitiesbr($this->email) : ($this->email ? $this->email : ''), + '__BIRTH__' => $msgishtml ? dol_htmlentitiesbr($birthday) : ($birthday ? $birthday : ''), '__PHOTO__' => $msgishtml ? dol_htmlentitiesbr($this->photo) : ($this->photo ? $this->photo : ''), '__LOGIN__' => $msgishtml ? dol_htmlentitiesbr($this->login) : ($this->login ? $this->login : ''), '__PASSWORD__' => $msgishtml ? dol_htmlentitiesbr($this->pass) : ($this->pass ? $this->pass : ''), @@ -634,7 +641,8 @@ class Adherent extends CommonObject $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET"; - $sql .= " civility = ".($this->civility_id ? "'".$this->db->escape($this->civility_id)."'" : "null"); + $sql .= " ref = '".$this->db->escape($this->ref)."'"; + $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' @@ -751,6 +759,7 @@ class Adherent extends CommonObject // If option ADHERENT_LOGIN_NOT_REQUIRED is on, there is no login of member, so we do not overwrite user login to keep existing one. if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $luser->login = $this->login; + $luser->ref = $this->ref; $luser->civility_id = $this->civility_id; $luser->firstname = $this->firstname; $luser->lastname = $this->lastname; @@ -1241,7 +1250,8 @@ class Adherent extends CommonObject { global $langs; - $sql = "SELECT d.rowid, d.ref_ext, d.civility as civility_code, 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 = "SELECT d.rowid, d.ref, d.ref_ext, d.civility as civility_code, d.gender, d.firstname, d.lastname,"; + $sql .= " 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.socialnetworks, 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,"; @@ -1267,7 +1277,7 @@ class Adherent extends CommonObject elseif ($ref || $fk_soc) { $sql .= " AND d.entity IN (".getEntity('adherent').")"; if ($ref) - $sql .= " AND d.rowid='".$this->db->escape($ref)."'"; + $sql .= " AND d.ref='".$this->db->escape($ref)."'"; elseif ($fk_soc > 0) $sql .= " AND d.fk_soc=".$fk_soc; } elseif ($ref_ext) { @@ -1281,8 +1291,8 @@ class Adherent extends CommonObject $obj = $this->db->fetch_object($resql); $this->entity = $obj->entity; - $this->ref = $obj->rowid; $this->id = $obj->rowid; + $this->ref = $obj->ref; $this->ref_ext = $obj->ref_ext; $this->civility_id = $obj->civility_code; // Bad. Kept for backard compatibility @@ -2070,7 +2080,7 @@ class Adherent extends CommonObject if ($mode == 'login') { $result .= dol_trunc($this->login, $maxlen); } elseif ($mode == 'ref') { - $result .= $this->id; + $result .= $this->ref; } else { $result .= $this->getFullName($langs, '', ($mode == 'firstname' ? 2 : -1), $maxlen); } diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index c9aaa856d22..1af60db5bee 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -101,7 +101,7 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen // List of fields to search into when doing a "search in all" $fieldstosearchall = array( - 'd.rowid'=>'Ref', + 'd.ref'=>'Ref', 'd.login'=>'Login', 'd.lastname'=>'Lastname', 'd.firstname'=>'Firstname', @@ -251,7 +251,7 @@ $memberstatic = new Adherent($db); $now = dol_now(); -$sql = "SELECT d.rowid, d.login, d.lastname, d.firstname, d.gender, d.societe as company, d.fk_soc,"; +$sql = "SELECT d.rowid, d.ref, 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,"; @@ -268,8 +268,13 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // N $sql .= preg_replace('/^,/', '', $hookmanager->resPrint); $sql = preg_replace('/,\s*$/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (d.rowid = ef.fk_object)"; -if (!empty($search_categ) || !empty($catid)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_member as cm ON d.rowid = cm.fk_member"; // We need this table joined to the select in order to filter by categ +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (d.rowid = ef.fk_object)"; +} +if (!empty($search_categ) || !empty($catid)) { + // We need this table joined to the select in order to filter by categ + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_member as cm ON d.rowid = cm.fk_member"; +} $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = d.country)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = d.state_id)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on (s.rowid = d.fk_soc)"; @@ -285,10 +290,12 @@ if ($search_type > 0) $sql .= " AND t.rowid=".$db->escape($search_type); if ($search_filter == 'withoutsubscription') $sql .= " AND (datefin IS NULL OR t.subscription = 0)"; if ($search_filter == 'uptodate') $sql .= " AND (datefin >= '".$db->idate($now)."' OR t.subscription = 0)"; if ($search_filter == 'outofdate') $sql .= " AND (datefin < '".$db->idate($now)."' AND t.subscription = 1)"; -if ($search_status != '') $sql .= " AND d.statut in (".$db->sanitize($db->escape($search_status)).")"; // Peut valoir un nombre ou liste de nombre separes par virgules +if ($search_status != '') { + // Peut valoir un nombre ou liste de nombre separes par virgules + $sql .= " AND d.statut in (".$db->sanitize($db->escape($search_status)).")"; +} if ($search_ref) { - if (is_numeric($search_ref)) $sql .= " AND (d.rowid = ".$db->escape($search_ref).")"; - else $sql .= " AND 1 = 2"; // Always wrong + $sql .= natural_search("d.ref", $search_ref); } if ($search_civility) $sql .= natural_search("d.civility", $search_civility); if ($search_firstname) $sql .= natural_search("d.firstname", $search_firstname); @@ -607,7 +614,7 @@ print "\n"; print ''; if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) print_liste_field_titre("ID", $_SERVER["PHP_SELF"], '', '', $param, 'align="center"', $sortfield, $sortorder); -if (!empty($arrayfields['d.ref']['checked'])) print_liste_field_titre($arrayfields['d.ref']['label'], $_SERVER["PHP_SELF"], 'd.rowid', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['d.ref']['checked'])) print_liste_field_titre($arrayfields['d.ref']['label'], $_SERVER["PHP_SELF"], 'd.ref', '', $param, '', $sortfield, $sortorder); 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); @@ -647,7 +654,7 @@ while ($i < min($num, $limit)) { $datefin = $db->jdate($obj->datefin); $memberstatic->id = $obj->rowid; - $memberstatic->ref = $obj->rowid; + $memberstatic->ref = $obj->ref; $memberstatic->civility_id = $obj->civility; $memberstatic->lastname = $obj->lastname; $memberstatic->firstname = $obj->firstname; diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql index c8567cbee4b..67a0aba6cba 100644 --- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql +++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql @@ -61,6 +61,7 @@ ALTER TABLE llx_mrp_mo_extrafields ADD INDEX idx_mrp_mo_fk_object(fk_object); -- members ALTER TABLE llx_adherent ADD COLUMN ref varchar(30) NOT NULL AFTER rowid; UPDATE llx_adherent SET ref=rowid; +ALTER TABLE llx_adherent ADD UNIQUE INDEX uk_adherent_ref (ref, entity); ALTER TABLE llx_bom_bom ADD COLUMN bomtype integer DEFAULT 0; diff --git a/htdocs/install/mysql/tables/llx_adherent.sql b/htdocs/install/mysql/tables/llx_adherent.sql index 41646dc7d01..787a2b15bd7 100644 --- a/htdocs/install/mysql/tables/llx_adherent.sql +++ b/htdocs/install/mysql/tables/llx_adherent.sql @@ -27,8 +27,8 @@ create table llx_adherent ( rowid integer AUTO_INCREMENT PRIMARY KEY, - ref varchar(30) NOT NULL, -- member reference number - entity integer DEFAULT 1 NOT NULL, -- multi company id + ref varchar(30) NOT NULL, -- member reference number + 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), @@ -77,6 +77,6 @@ create table llx_adherent fk_user_author integer, -- can be null because member can be create by a guest fk_user_mod integer, fk_user_valid integer, - canvas varchar(32), -- type of canvas if used (null by default) + canvas varchar(32), -- type of canvas if used (null by default) import_key varchar(14) -- Import key )ENGINE=innodb; From c796d3e3e7e76810da6427b7987d79b89455409e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 10 Nov 2020 23:10:42 +0100 Subject: [PATCH 05/11] do not reset ref if already entered --- htdocs/install/mysql/migration/12.0.0-13.0.0.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql index 67a0aba6cba..1a42a065af4 100644 --- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql +++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql @@ -60,7 +60,7 @@ ALTER TABLE llx_mrp_mo_extrafields ADD INDEX idx_mrp_mo_fk_object(fk_object); -- For v13 -- members ALTER TABLE llx_adherent ADD COLUMN ref varchar(30) NOT NULL AFTER rowid; -UPDATE llx_adherent SET ref=rowid; +UPDATE llx_adherent SET ref=rowid WHERE ref = ''; ALTER TABLE llx_adherent ADD UNIQUE INDEX uk_adherent_ref (ref, entity); ALTER TABLE llx_bom_bom ADD COLUMN bomtype integer DEFAULT 0; @@ -408,7 +408,7 @@ ALTER TABLE llx_projet_task_time MODIFY COLUMN tms timestamp DEFAULT CURRENT_TIM ALTER TABLE llx_projet_task_time MODIFY COLUMN datec datetime; -DELETE FROM llx_user_rights WHERE fk_id IN (SELECT id FROM llx_rights_def where module = 'holiday' and perms = 'lire_tous'); +DELETE FROM llx_user_rights WHERE fk_id IN (SELECT id FROM llx_rights_def where module = 'holiday' and perms = 'lire_tous'); DELETE FROM llx_rights_def where module = 'holiday' and perms = 'lire_tous'; CREATE TABLE llx_c_product_nature ( From d4f633ee7422a1643112c82ed5e005aacbebeeef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 10 Nov 2020 23:41:15 +0100 Subject: [PATCH 06/11] check in card pdf --- htdocs/adherents/cartes/carte.php | 34 +++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/htdocs/adherents/cartes/carte.php b/htdocs/adherents/cartes/carte.php index b62f58117a2..ca194f8d51d 100644 --- a/htdocs/adherents/cartes/carte.php +++ b/htdocs/adherents/cartes/carte.php @@ -63,19 +63,24 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) { $arrayofmembers = array(); // request taking into account member with up to date subscriptions - $sql = "SELECT d.rowid, d.firstname, d.lastname, d.login, d.societe as company, d.datefin,"; + $sql = "SELECT d.rowid, d.ref, d.firstname, d.lastname, d.login, d.societe as company, d.datefin,"; $sql .= " d.address, d.zip, d.town, d.country, d.birth, d.email, d.photo,"; $sql .= " t.libelle as type,"; $sql .= " c.code as country_code, c.label as country"; // Add fields from extrafields - if (!empty($extrafields->attributes[$object->table_element]['label'])) - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); + if (!empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); + } + } $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.country = c.rowid"; - if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_extrafields as ef on (d.rowid = ef.fk_object)"; + if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_extrafields as ef on (d.rowid = ef.fk_object)"; + } $sql .= " WHERE d.fk_adherent_type = t.rowid AND d.statut = 1"; $sql .= " AND d.entity IN (".getEntity('adherent').")"; - if (is_numeric($foruserid)) $sql .= " AND d.rowid=".$foruserid; + if (is_numeric($foruserid)) $sql .= " AND d.rowid=".(int) $foruserid; if ($foruserlogin) $sql .= " AND d.login='".$db->escape($foruserlogin)."'"; $sql .= " ORDER BY d.rowid ASC"; @@ -90,6 +95,7 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) { if ($objp->country == '-') $objp->country = ''; $adherentstatic->id = $objp->rowid; + $adherentstatic->ref = $objp->ref; $adherentstatic->lastname = $objp->lastname; $adherentstatic->firstname = $objp->firstname; @@ -110,6 +116,7 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) { // List of values to scan for a replacement $substitutionarray = array( '__ID__'=>$objp->rowid, + '__REF__'=>$objp->ref, '__LOGIN__'=>$objp->login, '__FIRSTNAME__'=>$objp->firstname, '__LASTNAME__'=>$objp->lastname, @@ -149,6 +156,7 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) { 'textfooter'=>$textfooter, 'textright'=>$textright, 'id'=>$objp->rowid, + 'ref'=>$objp->ref, 'photo'=>$objp->photo ); } @@ -159,6 +167,7 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) { 'textfooter'=>$textfooter, 'textright'=>$textright, 'id'=>$objp->rowid, + 'ref'=>$objp->ref, 'photo'=>$objp->photo ); } @@ -172,12 +181,15 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) { $textfooter = ''; $textright = ''; - $arrayofmembers[] = array('textleft'=>$textleft, - 'textheader'=>$textheader, - 'textfooter'=>$textfooter, - 'textright'=>$textright, - 'id'=>$objp->rowid, - 'photo'=>$objp->photo); + $arrayofmembers[] = array( + 'textleft'=>$textleft, + 'textheader'=>$textheader, + 'textfooter'=>$textfooter, + 'textright'=>$textright, + 'id'=>$objp->rowid, + 'ref'=>$objp->ref, + 'photo'=>$objp->photo, + ); } $i++; From c7557fdb8af54ae4745986dd8f19ffd492d1213b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 11 Nov 2020 11:12:19 +0100 Subject: [PATCH 07/11] specimen --- htdocs/adherents/class/adherent.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 539524756c9..967002b0b6e 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -2325,6 +2325,7 @@ class Adherent extends CommonObject // Initialise parametres $this->id = 0; + $this->ref = 'ABC001'; $this->entity = 1; $this->specimen = 1; $this->civility_id = 0; From 073599383936029a3adf5cc1c8776c59f97901be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 11 Nov 2020 12:17:23 +0100 Subject: [PATCH 08/11] set ref at create --- htdocs/adherents/class/adherent.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 967002b0b6e..76f7fd8485c 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -525,9 +525,10 @@ class Adherent extends CommonObject // Insert member $sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent"; - $sql .= " (datec,login,fk_user_author,fk_user_mod,fk_user_valid,morphy,fk_adherent_type,entity,import_key)"; + $sql .= " (ref, datec,login,fk_user_author,fk_user_mod,fk_user_valid,morphy,fk_adherent_type,entity,import_key)"; $sql .= " VALUES ("; - $sql .= " '".$this->db->idate($this->datec)."'"; + $sql .= " '(PROV)'"; + $sql .= ", '".$this->db->idate($this->datec)."'"; $sql .= ", ".($this->login ? "'".$this->db->escape($this->login)."'" : "null"); $sql .= ", ".($user->id > 0 ? $user->id : "null"); // Can be null because member can be created by a guest or a script $sql .= ", null, null, '".$this->db->escape($this->morphy)."'"; From 7d6e70c4c05dac91f46fa43ae0f110e2c4da165d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 11 Nov 2020 13:14:39 +0100 Subject: [PATCH 09/11] add log --- test/phpunit/AdherentTest.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/phpunit/AdherentTest.php b/test/phpunit/AdherentTest.php index f19e88c36a6..0e0cdf3f962 100644 --- a/test/phpunit/AdherentTest.php +++ b/test/phpunit/AdherentTest.php @@ -180,7 +180,10 @@ class AdherentTest extends PHPUnit\Framework\TestCase $localobject->initAsSpecimen(); $localobject->typeid=$fk_adherent_type; $result=$localobject->create($user); - print __METHOD__." result=".$result."\n"; + print __METHOD__." result=".$result."\n"; + if ($result < 0) { + print $localobject->error; + } $this->assertLessThan($result, 0); return $result; From 1b6dfee2bd0224b56e2d78fa71f37be0eb20233d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 11 Nov 2020 13:56:45 +0100 Subject: [PATCH 10/11] modify sql --- htdocs/install/mysql/migration/12.0.0-13.0.0.sql | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql index 1a42a065af4..ec0abb5f597 100644 --- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql +++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql @@ -59,8 +59,9 @@ ALTER TABLE llx_mrp_mo_extrafields ADD INDEX idx_mrp_mo_fk_object(fk_object); -- For v13 -- members -ALTER TABLE llx_adherent ADD COLUMN ref varchar(30) NOT NULL AFTER rowid; -UPDATE llx_adherent SET ref=rowid WHERE ref = ''; +ALTER TABLE llx_adherent ADD COLUMN ref varchar(30) AFTER rowid; +UPDATE llx_adherent SET ref = rowid WHERE ref = ''; +ALTER TABLE llx_adherent MODIFY COLUMN ref varchar(30) NOT NULL; ALTER TABLE llx_adherent ADD UNIQUE INDEX uk_adherent_ref (ref, entity); ALTER TABLE llx_bom_bom ADD COLUMN bomtype integer DEFAULT 0; From 4c9a597c8afd5a112044a7e4dd05130fa15f240a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 27 Dec 2020 15:13:20 +0100 Subject: [PATCH 11/11] Update 12.0.0-13.0.0.sql --- htdocs/install/mysql/migration/12.0.0-13.0.0.sql | 6 ------ 1 file changed, 6 deletions(-) diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql index be0e25db693..c6ca487de43 100644 --- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql +++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql @@ -60,12 +60,6 @@ ALTER TABLE llx_mrp_mo_extrafields ADD INDEX idx_mrp_mo_fk_object(fk_object); -- For v13 --- members -ALTER TABLE llx_adherent ADD COLUMN ref varchar(30) AFTER rowid; -UPDATE llx_adherent SET ref = rowid WHERE ref = ''; -ALTER TABLE llx_adherent MODIFY COLUMN ref varchar(30) NOT NULL; -ALTER TABLE llx_adherent ADD UNIQUE INDEX uk_adherent_ref (ref, entity); - insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (111,11, '0','0','No Sales Tax',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (112,11, '4','0','Sales Tax 4%',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (113,11, '6','0','Sales Tax 6%',1);
'.$langs->trans("Ref").''.$object->id.'
'.$langs->trans("Ref").''.$object->ref.'