diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 0186ae9d8da..61edd3bee05 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -538,8 +538,6 @@ class Adherent extends CommonObject $luser->office_phone=$this->phone; $luser->user_mobile=$this->phone_mobile; - $luser->note=$this->note; - $luser->fk_member=$this->id; $result=$luser->update($user,0,1,1); // Use nosync to 1 to avoid cyclic updates diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index 5c84534f9f5..0c31a7569fa 100755 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -178,6 +178,8 @@ class HookManager // TODO. remove this. result must not be a string. we must use $actionclassinstance->resprint to return a string if (! is_array($result) && ! is_numeric($result)) $this->resPrint.=$result; } + + //print "method=".$method." results=".count($actionclassinstance->results)." resprints=".count($actionclassinstance->resprints)." result=".$result." resaction=".$resaction; } } } diff --git a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql index 43f397aedf1..3793e822102 100755 --- a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql +++ b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql @@ -20,6 +20,8 @@ DROP TABLE llx_document; DROP TABLE llx_dolibarr_modules; DROP TABLE llx_product_fournisseur; +ALTER TABLE llx_adherent ADD COLUMN canvas varchar(32); + ALTER TABLE llx_societe_rib MODIFY COLUMN bic varchar(20); ALTER TABLE llx_facture_rec ADD COLUMN usenewprice integer; diff --git a/htdocs/install/mysql/tables/llx_adherent.sql b/htdocs/install/mysql/tables/llx_adherent.sql index 34550703e28..3ab580b5de2 100644 --- a/htdocs/install/mysql/tables/llx_adherent.sql +++ b/htdocs/install/mysql/tables/llx_adherent.sql @@ -60,5 +60,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) import_key varchar(14) -- Import key )ENGINE=innodb; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 4c6af926cd9..6ea29526c00 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -375,9 +375,10 @@ class Societe extends CommonObject * @param int $allowmodcodeclient Inclut modif code client et code compta * @param int $allowmodcodefournisseur Inclut modif code fournisseur et code compta fournisseur * @param string $action 'create' or 'update' + * @param int $nosyncmember Do not synchronize info of linked member * @return int <0 if KO, >=0 if OK */ - function update($id, $user='', $call_trigger=1, $allowmodcodeclient=0, $allowmodcodefournisseur=0, $action='update') + function update($id, $user='', $call_trigger=1, $allowmodcodeclient=0, $allowmodcodefournisseur=0, $action='update', $nosyncmember=1) { global $langs,$conf; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; @@ -491,7 +492,7 @@ class Societe extends CommonObject if ($result >= 0) { - dol_syslog(get_class($this)."::Update verify ok"); + dol_syslog(get_class($this)."::update verify ok"); $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET "; $sql .= "nom = '" . $this->db->escape($this->name) ."'"; // Required @@ -564,11 +565,49 @@ class Societe extends CommonObject $resql=$this->db->query($sql); if ($resql) { - unset($this->country_code); // We clean this because it may have been changed after an update of country_id - unset($this->country); - unset($this->state_code); - unset($this->state); + unset($this->country_code); // We clean this because it may have been changed after an update of country_id + unset($this->country); + unset($this->state_code); + unset($this->state); + + $nbrowsaffected+=$this->db->affected_rows($resql); + if (! $error && $nbrowsaffected) + { + // Update information on linked member if it is an update + if (! $nosyncmember && ! empty($conf->adherent->enabled)) + { + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + + dol_syslog(get_class($this)."::update update linked member"); + + $lmember=new Adherent($this->db); + $result=$lmember->fetch(0, 0, $this->id); + + if ($result > 0) + { + $lmember->firstname=$this->firstname; + $lmember->lastname=$this->lastname; + $lmember->address=$this->address; + $lmember->email=$this->email; + $lmember->phone=$this->phone; + + $result=$lmember->update($user,0,1,1); // Use nosync to 1 to avoid cyclic updates + if ($result < 0) + { + $this->error=$lmember->error; + dol_syslog(get_class($this)."::update ".$this->error,LOG_ERR); + $error++; + } + } + else if ($result < 0) + { + $this->error=$lmember->error; + $error++; + } + } + } + // Si le fournisseur est classe on l'ajoute $this->AddFournisseurInCategory($this->fournisseur_categorie); diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 76e4ae6db0d..d2f816cd1ca 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -346,7 +346,7 @@ if (empty($reshook)) if (empty($object->fournisseur)&& empty($object->oldcopy->code_fournisseur)) $object->code_fournisseur=''; //var_dump($object);exit; - $result = $object->update($socid,$user,1,$object->oldcopy->codeclient_modifiable(),$object->oldcopy->codefournisseur_modifiable()); + $result = $object->update($socid, $user, 1, $object->oldcopy->codeclient_modifiable(), $object->oldcopy->codefournisseur_modifiable(), 'update', 0); if ($result <= 0) { $error = $object->error; $errors = $object->errors; @@ -397,6 +397,22 @@ if (empty($reshook)) } // Gestion du logo de la société + + // Update linked member + if (! $error && $object->fk_soc > 0) + { + + $sql = "UPDATE ".MAIN_DB_PREFIX."adherent"; + $sql.= " SET fk_soc = NULL WHERE fk_soc = " . $id; + dol_syslog(get_class($this)."::delete sql=".$sql, LOG_DEBUG); + if (! $this->db->query($sql)) + { + $error++; + $this->error .= $this->db->lasterror(); + dol_syslog(get_class($this)."::delete erreur -1 ".$this->error, LOG_ERR); + } + } + if (! $error && ! count($errors)) { diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php index 6a0ca1db656..6172b08c740 100644 --- a/htdocs/user/fiche.php +++ b/htdocs/user/fiche.php @@ -223,10 +223,6 @@ if ($action == 'add' && $canadduser) $object->entity = (empty($_POST["entity"]) ? 0 : $_POST["entity"]); } } - else if (! empty($_POST["admin"])) - { - $object->entity=0; - } else { $object->entity = (empty($_POST["entity"]) ? 0 : $_POST["entity"]); @@ -372,10 +368,6 @@ if ($action == 'update' && ! $_POST["cancel"]) $object->entity = (empty($_POST["entity"]) ? 0 : $_POST["entity"]); } } - else if(! empty($_POST["admin"])) - { - $object->entity=0; - } else { $object->entity = (empty($_POST["entity"]) ? 0 : $_POST["entity"]);