diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 71046b400b1..9dbe3bb5928 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -46,12 +46,12 @@ class Adherent extends CommonObject /** * @var string ID to identify managed object */ - public $element='member'; + public $element = 'member'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='adherent'; + public $table_element = 'adherent'; /** * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe @@ -220,7 +220,7 @@ class Adherent extends CommonObject public $user_id; public $user_login; - public $datefin; // From member table + public $datefin; // From member table // Fields loaded by fetch_subscriptions() public $first_subscription_date; @@ -229,7 +229,7 @@ class Adherent extends CommonObject public $last_subscription_date_start; public $last_subscription_date_end; public $last_subscription_amount; - public $subscriptions=array(); + public $subscriptions = array(); /** * @var Adherent To contains a clone of this when we need to save old properties of object @@ -253,7 +253,7 @@ class Adherent extends CommonObject // l'adherent n'est pas public par defaut $this->public = 0; // les champs optionnels sont vides - $this->array_options=array(); + $this->array_options = array(); } @@ -277,7 +277,7 @@ class Adherent extends CommonObject public function send_an_email($text, $subject, $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array(), $addr_cc = "", $addr_bcc = "", $deliveryreceipt = 0, $msgishtml = -1, $errors_to = '', $moreinheader = '') { // phpcs:enable - global $conf,$langs; + global $conf, $langs; // Detect if message is HTML if ($msgishtml == -1) @@ -288,13 +288,13 @@ class Adherent extends CommonObject dol_syslog('send_an_email msgishtml='.$msgishtml); - $texttosend=$this->makeSubstitution($text); - $subjecttosend=$this->makeSubstitution($subject); - if ($msgishtml) $texttosend=dol_htmlentitiesbr($texttosend); + $texttosend = $this->makeSubstitution($text); + $subjecttosend = $this->makeSubstitution($subject); + if ($msgishtml) $texttosend = dol_htmlentitiesbr($texttosend); // Envoi mail confirmation - $from=$conf->email_from; - if (! empty($conf->global->ADHERENT_MAIL_FROM)) $from=$conf->global->ADHERENT_MAIL_FROM; + $from = $conf->email_from; + if (!empty($conf->global->ADHERENT_MAIL_FROM)) $from = $conf->global->ADHERENT_MAIL_FROM; $trackid = 'mem'.$this->id; @@ -307,7 +307,7 @@ class Adherent extends CommonObject } else { - $this->error=$langs->trans("ErrorFailedToSendMail", $from, $this->email).'. '.$mailfile->error; + $this->error = $langs->trans("ErrorFailedToSendMail", $from, $this->email).'. '.$mailfile->error; return -1; } } @@ -321,57 +321,57 @@ class Adherent extends CommonObject */ public function makeSubstitution($text) { - global $conf,$langs; + global $conf, $langs; $birthday = dol_print_date($this->birth, 'day'); $msgishtml = 0; if (dol_textishtml($text, 1)) $msgishtml = 1; - $infos=''; - if ($this->civility_id) $infos.= $langs->transnoentities("UserTitle").": ".$this->getCivilityLabel()."\n"; - $infos.= $langs->transnoentities("id").": ".$this->id."\n"; - $infos.= $langs->transnoentities("Lastname").": ".$this->lastname."\n"; - $infos.= $langs->transnoentities("Firstname").": ".$this->firstname."\n"; - $infos.= $langs->transnoentities("Company").": ".$this->company."\n"; - $infos.= $langs->transnoentities("Address").": ".$this->address."\n"; - $infos.= $langs->transnoentities("Zip").": ".$this->zip."\n"; - $infos.= $langs->transnoentities("Town").": ".$this->town."\n"; - $infos.= $langs->transnoentities("Country").": ".$this->country."\n"; - $infos.= $langs->transnoentities("EMail").": ".$this->email."\n"; - $infos.= $langs->transnoentities("PhonePro").": ".$this->phone."\n"; - $infos.= $langs->transnoentities("PhonePerso").": ".$this->phone_perso."\n"; - $infos.= $langs->transnoentities("PhoneMobile").": ".$this->phone_mobile."\n"; + $infos = ''; + if ($this->civility_id) $infos .= $langs->transnoentities("UserTitle").": ".$this->getCivilityLabel()."\n"; + $infos .= $langs->transnoentities("id").": ".$this->id."\n"; + $infos .= $langs->transnoentities("Lastname").": ".$this->lastname."\n"; + $infos .= $langs->transnoentities("Firstname").": ".$this->firstname."\n"; + $infos .= $langs->transnoentities("Company").": ".$this->company."\n"; + $infos .= $langs->transnoentities("Address").": ".$this->address."\n"; + $infos .= $langs->transnoentities("Zip").": ".$this->zip."\n"; + $infos .= $langs->transnoentities("Town").": ".$this->town."\n"; + $infos .= $langs->transnoentities("Country").": ".$this->country."\n"; + $infos .= $langs->transnoentities("EMail").": ".$this->email."\n"; + $infos .= $langs->transnoentities("PhonePro").": ".$this->phone."\n"; + $infos .= $langs->transnoentities("PhonePerso").": ".$this->phone_perso."\n"; + $infos .= $langs->transnoentities("PhoneMobile").": ".$this->phone_mobile."\n"; if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - $infos.= $langs->transnoentities("Login").": ".$this->login."\n"; - $infos.= $langs->transnoentities("Password").": ".$this->pass."\n"; + $infos .= $langs->transnoentities("Login").": ".$this->login."\n"; + $infos .= $langs->transnoentities("Password").": ".$this->pass."\n"; } - $infos.= $langs->transnoentities("Birthday").": ".$birthday."\n"; - $infos.= $langs->transnoentities("Photo").": ".$this->photo."\n"; - $infos.= $langs->transnoentities("Public").": ".yn($this->public); + $infos .= $langs->transnoentities("Birthday").": ".$birthday."\n"; + $infos .= $langs->transnoentities("Photo").": ".$this->photo."\n"; + $infos .= $langs->transnoentities("Public").": ".yn($this->public); // Substitutions - $substitutionarray=array( + $substitutionarray = array( '__ID__'=>$this->id, '__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:''), - '__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:''), - '__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:''), - '__PHONE__'=>$msgishtml?dol_htmlentitiesbr($this->phone):($this->phone?$this->phone:''), - '__PHONEPRO__'=>$msgishtml?dol_htmlentitiesbr($this->phone_perso):($this->phone_perso?$this->phone_perso:''), - '__PHONEMOBILE__'=>$msgishtml?dol_htmlentitiesbr($this->phone_mobile):($this->phone_mobile?$this->phone_mobile:'') + '__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 : ''), + '__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 : ''), + '__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 : ''), + '__PHONE__'=>$msgishtml ?dol_htmlentitiesbr($this->phone) : ($this->phone ? $this->phone : ''), + '__PHONEPRO__'=>$msgishtml ?dol_htmlentitiesbr($this->phone_perso) : ($this->phone_perso ? $this->phone_perso : ''), + '__PHONEMOBILE__'=>$msgishtml ?dol_htmlentitiesbr($this->phone_mobile) : ($this->phone_mobile ? $this->phone_mobile : '') ); complete_substitutions_array($substitutionarray, $langs, $this); @@ -389,7 +389,7 @@ class Adherent extends CommonObject public function getmorphylib($morphy = '') { global $langs; - if (! $morphy) { $morphy=$this->morphy; } + if (!$morphy) { $morphy = $this->morphy; } if ($morphy == 'phy') { return $langs->trans("Physical"); } if ($morphy == 'mor') { return $langs->trans("Moral"); } return $morphy; @@ -404,23 +404,23 @@ class Adherent extends CommonObject */ public function create($user, $notrigger = 0) { - global $conf,$langs; + global $conf, $langs; - $error=0; + $error = 0; - $now=dol_now(); + $now = dol_now(); // Clean parameters $this->import_key = trim($this->import_key); // Check parameters - if (! empty($conf->global->ADHERENT_MAIL_REQUIRED) && ! isValidEMail($this->email)) + if (!empty($conf->global->ADHERENT_MAIL_REQUIRED) && !isValidEMail($this->email)) { $langs->load("errors"); $this->error = $langs->trans("ErrorBadEMail", $this->email); return -1; } - if (! $this->datec) $this->datec=$now; + if (!$this->datec) $this->datec = $now; if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { if (empty($this->login)) @@ -434,16 +434,16 @@ 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.= " VALUES ("; - $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)."'"; - $sql.= ", ".$this->typeid; - $sql.= ", ".$conf->entity; - $sql.= ", ".(! empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'":"null"); - $sql.= ")"; + $sql .= " (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 .= ", ".($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)."'"; + $sql .= ", ".$this->typeid; + $sql .= ", ".$conf->entity; + $sql .= ", ".(!empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null"); + $sql .= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); $result = $this->db->query($sql); @@ -452,11 +452,11 @@ class Adherent extends CommonObject $id = $this->db->last_insert_id(MAIN_DB_PREFIX."adherent"); if ($id > 0) { - $this->id=$id; - $this->ref=(string) $id; + $this->id = $id; + $this->ref = (string) $id; // Update minor fields - $result=$this->update($user, 1, 1, 0, 0, 'add'); // nosync is 1 to avoid update data of user + $result = $this->update($user, 1, 1, 0, 0, 'add'); // nosync is 1 to avoid update data of user if ($result < 0) { $this->db->rollback(); @@ -468,22 +468,22 @@ class Adherent extends CommonObject { // Add link to user $sql = "UPDATE ".MAIN_DB_PREFIX."user SET"; - $sql.= " fk_member = ".$this->id; - $sql.= " WHERE rowid = ".$this->user_id; + $sql .= " fk_member = ".$this->id; + $sql .= " WHERE rowid = ".$this->user_id; dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { - $this->error='Failed to update user to make link with member'; + $this->error = 'Failed to update user to make link with member'; $this->db->rollback(); return -4; } } - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('MEMBER_CREATE', $user); + $result = $this->call_trigger('MEMBER_CREATE', $user); if ($result < 0) { $error++; } // End call triggers } @@ -502,7 +502,7 @@ class Adherent extends CommonObject } else { - $this->error='Failed to get last insert id'; + $this->error = 'Failed to get last insert id'; dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); $this->db->rollback(); return -2; @@ -510,7 +510,7 @@ class Adherent extends CommonObject } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; } @@ -532,27 +532,27 @@ class Adherent extends CommonObject { global $conf, $langs, $hookmanager; - $nbrowsaffected=0; - $error=0; + $nbrowsaffected = 0; + $error = 0; 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->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->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); // Check parameters - if (! empty($conf->global->ADHERENT_MAIL_REQUIRED) && ! isValidEMail($this->email)) + if (!empty($conf->global->ADHERENT_MAIL_REQUIRED) && !isValidEMail($this->email)) { $langs->load("errors"); $this->error = $langs->trans("ErrorBadEMail", $this->email); @@ -562,49 +562,49 @@ 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.= ", 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->company?"'".$this->db->escape($this->company)."'":($this->societe?"'".$this->db->escape($this->societe)."'":"null")); - $sql.= ", fk_soc = ".($this->socid > 0?$this->db->escape($this->socid):"null"); - $sql.= ", address = ".($this->address?"'".$this->db->escape($this->address)."'":"null"); - $sql.= ", zip = ".($this->zip?"'".$this->db->escape($this->zip)."'":"null"); - $sql.= ", town = ".($this->town?"'".$this->db->escape($this->town)."'":"null"); - $sql.= ", country = ".($this->country_id>0?$this->db->escape($this->country_id):"null"); - $sql.= ", state_id = ".($this->state_id>0?$this->db->escape($this->state_id):"null"); - $sql.= ", email = '".$this->db->escape($this->email)."'"; - $sql.= ", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks))."'"; - $sql.= ", phone = ".($this->phone?"'".$this->db->escape($this->phone)."'":"null"); - $sql.= ", phone_perso = ".($this->phone_perso?"'".$this->db->escape($this->phone_perso)."'":"null"); - $sql.= ", phone_mobile = ".($this->phone_mobile?"'".$this->db->escape($this->phone_mobile)."'":"null"); - $sql.= ", note_private = ".($this->note_private?"'".$this->db->escape($this->note_private)."'":"null"); - $sql.= ", note_public = ".($this->note_public?"'".$this->db->escape($this->note_public)."'":"null"); - $sql.= ", photo = ".($this->photo?"'".$this->db->escape($this->photo)."'":"null"); - $sql.= ", public = '".$this->db->escape($this->public)."'"; - $sql.= ", statut = ".$this->db->escape($this->statut); - $sql.= ", fk_adherent_type = ".$this->db->escape($this->typeid); - $sql.= ", morphy = '".$this->db->escape($this->morphy)."'"; - $sql.= ", birth = ".($this->birth?"'".$this->db->idate($this->birth)."'":"null"); - if ($this->socid) $sql.= ", fk_soc = '".$this->db->escape($this->socid)."'"; // Must be modified only when creating from a third-party - if ($this->datefin) $sql.= ", datefin = '".$this->db->idate($this->datefin)."'"; // Must be modified only when deleting a subscription - if ($this->datevalid) $sql.= ", datevalid = '".$this->db->idate($this->datevalid)."'"; // Must be modified only when validating a member - $sql.= ", fk_user_mod = ".($user->id>0?$user->id:'null'); // Can be null because member can be create by a guest - $sql.= " WHERE rowid = ".$this->id; + $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->company ? "'".$this->db->escape($this->company)."'" : ($this->societe ? "'".$this->db->escape($this->societe)."'" : "null")); + $sql .= ", fk_soc = ".($this->socid > 0 ? $this->db->escape($this->socid) : "null"); + $sql .= ", address = ".($this->address ? "'".$this->db->escape($this->address)."'" : "null"); + $sql .= ", zip = ".($this->zip ? "'".$this->db->escape($this->zip)."'" : "null"); + $sql .= ", town = ".($this->town ? "'".$this->db->escape($this->town)."'" : "null"); + $sql .= ", country = ".($this->country_id > 0 ? $this->db->escape($this->country_id) : "null"); + $sql .= ", state_id = ".($this->state_id > 0 ? $this->db->escape($this->state_id) : "null"); + $sql .= ", email = '".$this->db->escape($this->email)."'"; + $sql .= ", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks))."'"; + $sql .= ", phone = ".($this->phone ? "'".$this->db->escape($this->phone)."'" : "null"); + $sql .= ", phone_perso = ".($this->phone_perso ? "'".$this->db->escape($this->phone_perso)."'" : "null"); + $sql .= ", phone_mobile = ".($this->phone_mobile ? "'".$this->db->escape($this->phone_mobile)."'" : "null"); + $sql .= ", note_private = ".($this->note_private ? "'".$this->db->escape($this->note_private)."'" : "null"); + $sql .= ", note_public = ".($this->note_public ? "'".$this->db->escape($this->note_public)."'" : "null"); + $sql .= ", photo = ".($this->photo ? "'".$this->db->escape($this->photo)."'" : "null"); + $sql .= ", public = '".$this->db->escape($this->public)."'"; + $sql .= ", statut = ".$this->db->escape($this->statut); + $sql .= ", fk_adherent_type = ".$this->db->escape($this->typeid); + $sql .= ", morphy = '".$this->db->escape($this->morphy)."'"; + $sql .= ", birth = ".($this->birth ? "'".$this->db->idate($this->birth)."'" : "null"); + if ($this->socid) $sql .= ", fk_soc = '".$this->db->escape($this->socid)."'"; // Must be modified only when creating from a third-party + if ($this->datefin) $sql .= ", datefin = '".$this->db->idate($this->datefin)."'"; // Must be modified only when deleting a subscription + if ($this->datevalid) $sql .= ", datevalid = '".$this->db->idate($this->datevalid)."'"; // Must be modified only when validating a member + $sql .= ", fk_user_mod = ".($user->id > 0 ? $user->id : 'null'); // Can be null because member can be create by a guest + $sql .= " WHERE rowid = ".$this->id; // If we change the type of membership, we set also label of new type - if (! empty($this->oldcopy) && $this->typeid != $this->oldcopy->typeid) + if (!empty($this->oldcopy) && $this->typeid != $this->oldcopy->typeid) { $sql2 = "SELECT libelle as label"; - $sql2.= " FROM ".MAIN_DB_PREFIX."adherent_type"; - $sql2.= " WHERE rowid = ".$this->typeid; + $sql2 .= " FROM ".MAIN_DB_PREFIX."adherent_type"; + $sql2 .= " WHERE rowid = ".$this->typeid; $resql2 = $this->db->query($sql2); if ($resql2) { - while ($obj=$this->db->fetch_object($resql2)) + while ($obj = $this->db->fetch_object($resql2)) { - $this->type=$obj->label; + $this->type = $obj->label; } } } @@ -618,14 +618,14 @@ class Adherent extends CommonObject unset($this->state_code); unset($this->state); - $nbrowsaffected+=$this->db->affected_rows($resql); + $nbrowsaffected += $this->db->affected_rows($resql); - $action='update'; + $action = 'update'; // Actions on extra fields - if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; @@ -633,48 +633,48 @@ class Adherent extends CommonObject } // Update password - if (! $error && $this->pass) + if (!$error && $this->pass) { dol_syslog(get_class($this)."::update update password"); if ($this->pass != $this->pass_indatabase && $this->pass != $this->pass_indatabase_crypted) { - $isencrypted = empty($conf->global->DATABASE_PWD_ENCRYPTED)?0:1; + $isencrypted = empty($conf->global->DATABASE_PWD_ENCRYPTED) ? 0 : 1; // If password to set differs from the one found into database - $result=$this->setPassword($user, $this->pass, $isencrypted, $notrigger, $nosyncuserpass); - if (! $nbrowsaffected) $nbrowsaffected++; + $result = $this->setPassword($user, $this->pass, $isencrypted, $notrigger, $nosyncuserpass); + if (!$nbrowsaffected) $nbrowsaffected++; } } // Remove links to user and replace with new one - if (! $error) + if (!$error) { dol_syslog(get_class($this)."::update update link to user"); $sql = "UPDATE ".MAIN_DB_PREFIX."user SET fk_member = NULL WHERE fk_member = ".$this->id; dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { $this->error=$this->db->error(); $this->db->rollback(); return -5; } + if (!$resql) { $this->error = $this->db->error(); $this->db->rollback(); return -5; } // If there is a user linked to this member if ($this->user_id > 0) { $sql = "UPDATE ".MAIN_DB_PREFIX."user SET fk_member = ".$this->id." WHERE rowid = ".$this->user_id; dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { $this->error=$this->db->error(); $this->db->rollback(); return -5; } + if (!$resql) { $this->error = $this->db->error(); $this->db->rollback(); return -5; } } } - if (! $error && $nbrowsaffected) // If something has change in main data + if (!$error && $nbrowsaffected) // If something has change in main data { // Update information on linked user if it is an update - if (! $error && $this->user_id > 0 && ! $nosyncuser) + if (!$error && $this->user_id > 0 && !$nosyncuser) { require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; dol_syslog(get_class($this)."::update update linked user"); - $luser=new User($this->db); - $result=$luser->fetch($this->user_id); + $luser = new User($this->db); + $result = $luser->fetch($this->user_id); if ($result >= 0) { @@ -682,47 +682,47 @@ class Adherent extends CommonObject //var_dump($this->login);exit; // 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; + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $luser->login = $this->login; - $luser->civility_id=$this->civility_id; - $luser->firstname=$this->firstname; - $luser->lastname=$this->lastname; - $luser->gender=$this->gender; - $luser->pass=$this->pass; + $luser->civility_id = $this->civility_id; + $luser->firstname = $this->firstname; + $luser->lastname = $this->lastname; + $luser->gender = $this->gender; + $luser->pass = $this->pass; //$luser->socid=$this->fk_soc; // We do not enable this. This may transform a user into an external user. - $luser->birth=$this->birth; + $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->socialnetworks=$this->socialnetworks; - $luser->office_phone=$this->phone; - $luser->user_mobile=$this->phone_mobile; + $luser->email = $this->email; + $luser->socialnetworks = $this->socialnetworks; + $luser->office_phone = $this->phone; + $luser->user_mobile = $this->phone_mobile; - $luser->fk_member=$this->id; + $luser->fk_member = $this->id; - $result=$luser->update($user, 0, 1, 1); // Use nosync to 1 to avoid cyclic updates + $result = $luser->update($user, 0, 1, 1); // Use nosync to 1 to avoid cyclic updates if ($result < 0) { - $this->error=$luser->error; + $this->error = $luser->error; dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR); $error++; } } else { - $this->error=$luser->error; + $this->error = $luser->error; $error++; } } // Update information on linked thirdparty if it is an update - if (! $error && $this->fk_soc > 0 && ! $nosyncthirdparty) + if (!$error && $this->fk_soc > 0 && !$nosyncthirdparty) { require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; @@ -730,48 +730,48 @@ class Adherent extends CommonObject // This member is linked with a thirdparty, so we also update thirdparty informations // if this is an update. - $lthirdparty=new Societe($this->db); - $result=$lthirdparty->fetch($this->fk_soc); + $lthirdparty = new Societe($this->db); + $result = $lthirdparty->fetch($this->fk_soc); if ($result > 0) { - $lthirdparty->address=$this->address; - $lthirdparty->zip=$this->zip; - $lthirdparty->town=$this->town; - $lthirdparty->email=$this->email; - $lthirdparty->socialnetworks=$this->socialnetworks; - $lthirdparty->phone=$this->phone; - $lthirdparty->state_id=$this->state_id; - $lthirdparty->country_id=$this->country_id; + $lthirdparty->address = $this->address; + $lthirdparty->zip = $this->zip; + $lthirdparty->town = $this->town; + $lthirdparty->email = $this->email; + $lthirdparty->socialnetworks = $this->socialnetworks; + $lthirdparty->phone = $this->phone; + $lthirdparty->state_id = $this->state_id; + $lthirdparty->country_id = $this->country_id; //$lthirdparty->phone_mobile=$this->phone_mobile; - $result=$lthirdparty->update($this->fk_soc, $user, 0, 1, 1, 'update'); // Use sync to 0 to avoid cyclic updates + $result = $lthirdparty->update($this->fk_soc, $user, 0, 1, 1, 'update'); // Use sync to 0 to avoid cyclic updates if ($result < 0) { - $this->error=$lthirdparty->error; - $this->errors=$lthirdparty->errors; + $this->error = $lthirdparty->error; + $this->errors = $lthirdparty->errors; dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR); $error++; } } elseif ($result < 0) { - $this->error=$lthirdparty->error; + $this->error = $lthirdparty->error; $error++; } } } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('MEMBER_MODIFY', $user); + $result = $this->call_trigger('MEMBER_MODIFY', $user); if ($result < 0) { $error++; } // End call triggers } - if (! $error) + if (!$error) { $this->db->commit(); return $nbrowsaffected; @@ -785,7 +785,7 @@ class Adherent extends CommonObject else { $this->db->rollback(); - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -2; } } @@ -806,31 +806,31 @@ class Adherent extends CommonObject // Search for last subscription id and end date $sql = "SELECT rowid, datec as dateop, dateadh as datedeb, datef as datefin"; - $sql.= " FROM ".MAIN_DB_PREFIX."subscription"; - $sql.= " WHERE fk_adherent=".$this->id; - $sql.= " ORDER by dateadh DESC"; // Sort by start subscription date + $sql .= " FROM ".MAIN_DB_PREFIX."subscription"; + $sql .= " WHERE fk_adherent=".$this->id; + $sql .= " ORDER by dateadh DESC"; // Sort by start subscription date dol_syslog(get_class($this)."::update_end_date", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $obj=$this->db->fetch_object($resql); - $dateop=$this->db->jdate($obj->dateop); - $datedeb=$this->db->jdate($obj->datedeb); - $datefin=$this->db->jdate($obj->datefin); + $obj = $this->db->fetch_object($resql); + $dateop = $this->db->jdate($obj->dateop); + $datedeb = $this->db->jdate($obj->datedeb); + $datefin = $this->db->jdate($obj->datefin); $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET"; - $sql.= " datefin=".($datefin != '' ? "'".$this->db->idate($datefin)."'" : "null"); - $sql.= " WHERE rowid = ".$this->id; + $sql .= " datefin=".($datefin != '' ? "'".$this->db->idate($datefin)."'" : "null"); + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::update_end_date", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $this->last_subscription_date=$dateop; - $this->last_subscription_date_start=$datedeb; - $this->last_subscription_date_end=$datefin; - $this->datefin=$datefin; + $this->last_subscription_date = $dateop; + $this->last_subscription_date_start = $datedeb; + $this->last_subscription_date_end = $datefin; + $this->datefin = $datefin; $this->db->commit(); return 1; } @@ -842,7 +842,7 @@ class Adherent extends CommonObject } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $this->db->rollback(); return -1; } @@ -861,18 +861,18 @@ class Adherent extends CommonObject global $conf, $langs; $result = 0; - $error=0; - $errorflag=0; + $error = 0; + $errorflag = 0; // Check parameters - if (empty($rowid)) $rowid=$this->id; + if (empty($rowid)) $rowid = $this->id; $this->db->begin(); - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('MEMBER_DELETE', $user); + $result = $this->call_trigger('MEMBER_DELETE', $user); if ($result < 0) $error++; // End call triggers } @@ -880,70 +880,70 @@ class Adherent extends CommonObject // Remove category $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_member WHERE fk_member = ".$rowid; dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->error .= $this->db->lasterror(); - $errorflag=-1; + $errorflag = -1; } // Remove subscription - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."subscription WHERE fk_adherent = ".$rowid; dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->error .= $this->db->lasterror(); - $errorflag=-2; + $errorflag = -2; } } // Remove linked user - if (! $error) + if (!$error) { - $ret=$this->setUserId(0); + $ret = $this->setUserId(0); if ($ret < 0) { $error++; $this->error .= $this->db->lasterror(); - $errorflag=-3; + $errorflag = -3; } } // Removed extrafields - if (! $error) + if (!$error) { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->deleteExtraFields(); + $result = $this->deleteExtraFields(); if ($result < 0) { $error++; - $errorflag=-4; + $errorflag = -4; dol_syslog(get_class($this)."::delete erreur ".$errorflag." ".$this->error, LOG_ERR); } } } // Remove adherent - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent WHERE rowid = ".$rowid; dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->error .= $this->db->lasterror(); - $errorflag=-5; + $errorflag = -5; } } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -970,22 +970,22 @@ class Adherent extends CommonObject { global $conf, $langs; - $error=0; + $error = 0; dol_syslog(get_class($this)."::setPassword user=".$user->id." password=".preg_replace('/./i', '*', $password)." isencrypted=".$isencrypted); // If new password not provided, we generate one - if (! $password) + if (!$password) { require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; - $password=getRandomPassword(false); + $password = getRandomPassword(false); } // Crypt password $password_crypted = dol_hash($password); $password_indatabase = ''; - if (! $isencrypted) + if (!$isencrypted) { $password_indatabase = $password; } @@ -994,61 +994,61 @@ class Adherent extends CommonObject // Mise a jour $sql = "UPDATE ".MAIN_DB_PREFIX."adherent"; - $sql.= " SET pass_crypted = '".$this->db->escape($password_crypted)."'"; + $sql .= " SET pass_crypted = '".$this->db->escape($password_crypted)."'"; //if (! empty($conf->global->DATABASE_PWD_ENCRYPTED)) if ($isencrypted) { - $sql.= ", pass = null"; + $sql .= ", pass = null"; } else { - $sql.= ", pass = '".$this->db->escape($password_indatabase)."'"; + $sql .= ", pass = '".$this->db->escape($password_indatabase)."'"; } - $sql.= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".$this->id; //dol_syslog("Adherent::Password sql=hidden"); dol_syslog(get_class($this)."::setPassword", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { - $nbaffectedrows=$this->db->affected_rows($result); + $nbaffectedrows = $this->db->affected_rows($result); if ($nbaffectedrows) { - $this->pass=$password; - $this->pass_indatabase=$password_indatabase; - $this->pass_indatabase_crypted=$password_crypted; + $this->pass = $password; + $this->pass_indatabase = $password_indatabase; + $this->pass_indatabase_crypted = $password_crypted; - if ($this->user_id && ! $nosyncuser) + if ($this->user_id && !$nosyncuser) { require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; // This member is linked with a user, so we also update users informations // if this is an update. - $luser=new User($this->db); - $result=$luser->fetch($this->user_id); + $luser = new User($this->db); + $result = $luser->fetch($this->user_id); if ($result >= 0) { - $result=$luser->setPassword($user, $this->pass, 0, 0, 1); + $result = $luser->setPassword($user, $this->pass, 0, 0, 1); if ($result < 0) { - $this->error=$luser->error; + $this->error = $luser->error; dol_syslog(get_class($this)."::setPassword ".$this->error, LOG_ERR); $error++; } } else { - $this->error=$luser->error; + $this->error = $luser->error; $error++; } } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('MEMBER_NEW_PASSWORD', $user); + $result = $this->call_trigger('MEMBER_NEW_PASSWORD', $user); if ($result < 0) { $error++; $this->db->rollback(); return -1; } // End call triggers } @@ -1087,16 +1087,16 @@ class Adherent extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."user SET fk_member = NULL WHERE fk_member = ".$this->id; dol_syslog(get_class($this)."::setUserId", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { $this->error=$this->db->error(); $this->db->rollback(); return -1; } + if (!$resql) { $this->error = $this->db->error(); $this->db->rollback(); return -1; } // Set link to user if ($userid > 0) { $sql = "UPDATE ".MAIN_DB_PREFIX."user SET fk_member = ".$this->id; - $sql.= " WHERE rowid = ".$userid; + $sql .= " WHERE rowid = ".$userid; dol_syslog(get_class($this)."::setUserId", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { $this->error=$this->db->error(); $this->db->rollback(); return -2; } + if (!$resql) { $this->error = $this->db->error(); $this->db->rollback(); return -2; } } $this->db->commit(); @@ -1121,15 +1121,15 @@ class Adherent extends CommonObject if ($thirdpartyid > 0) { $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET fk_soc = null"; - $sql.= " WHERE fk_soc = '".$thirdpartyid."'"; - $sql.= " AND entity = ".$conf->entity; + $sql .= " WHERE fk_soc = '".$thirdpartyid."'"; + $sql .= " AND entity = ".$conf->entity; dol_syslog(get_class($this)."::setThirdPartyId", LOG_DEBUG); $resql = $this->db->query($sql); } // Add link to third party for current member - $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET fk_soc = ".($thirdpartyid>0 ? $thirdpartyid : 'null'); - $sql.= " WHERE rowid = ".$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET fk_soc = ".($thirdpartyid > 0 ? $thirdpartyid : 'null'); + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::setThirdPartyId", LOG_DEBUG); $resql = $this->db->query($sql); @@ -1140,7 +1140,7 @@ class Adherent extends CommonObject } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; } @@ -1160,10 +1160,10 @@ class Adherent extends CommonObject global $conf; $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."adherent"; - $sql.= " WHERE login='".$this->db->escape($login)."'"; - $sql.= " AND entity = ".$conf->entity; + $sql .= " WHERE login='".$this->db->escape($login)."'"; + $sql .= " AND entity = ".$conf->entity; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) @@ -1192,11 +1192,11 @@ class Adherent extends CommonObject global $conf; $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."adherent"; - $sql.= " WHERE firstname='".$this->db->escape($firstname)."'"; - $sql.= " AND lastname='".$this->db->escape($lastname)."'"; - $sql.= " AND entity = ".$conf->entity; + $sql .= " WHERE firstname='".$this->db->escape($firstname)."'"; + $sql .= " AND lastname='".$this->db->escape($lastname)."'"; + $sql .= " AND entity = ".$conf->entity; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) @@ -1227,113 +1227,113 @@ 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.= " 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,"; - $sql.= " d.datec as datec,"; - $sql.= " d.tms as datem,"; - $sql.= " d.datefin as datefin,"; - $sql.= " d.birth as birthday,"; - $sql.= " d.datevalid as datev,"; - $sql.= " d.country,"; - $sql.= " d.state_id,"; - $sql.= " d.model_pdf,"; - $sql.= " c.rowid as country_id, c.code as country_code, c.label as country,"; - $sql.= " dep.nom as state, dep.code_departement as state_code,"; - $sql.= " t.libelle as type, t.subscription as subscription,"; - $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_country as c ON d.country = c.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as dep ON d.state_id = 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"; - if ($rowid) $sql.= " AND d.rowid=".$rowid; + $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,"; + $sql .= " d.datec as datec,"; + $sql .= " d.tms as datem,"; + $sql .= " d.datefin as datefin,"; + $sql .= " d.birth as birthday,"; + $sql .= " d.datevalid as datev,"; + $sql .= " d.country,"; + $sql .= " d.state_id,"; + $sql .= " d.model_pdf,"; + $sql .= " c.rowid as country_id, c.code as country_code, c.label as country,"; + $sql .= " dep.nom as state, dep.code_departement as state_code,"; + $sql .= " t.libelle as type, t.subscription as subscription,"; + $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_country as c ON d.country = c.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as dep ON d.state_id = 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"; + if ($rowid) $sql .= " AND d.rowid=".$rowid; elseif ($ref || $fk_soc) { - $sql.= " AND d.entity IN (".getEntity('adherent').")"; - if ($ref) $sql.= " AND d.rowid='".$this->db->escape($ref)."'"; - elseif ($fk_soc > 0) $sql.= " AND d.fk_soc=".$fk_soc; + $sql .= " AND d.entity IN (".getEntity('adherent').")"; + if ($ref) $sql .= " AND d.rowid='".$this->db->escape($ref)."'"; + elseif ($fk_soc > 0) $sql .= " AND d.fk_soc=".$fk_soc; } elseif ($ref_ext) { - $sql.= " AND d.ref_ext='".$this->db->escape($ref_ext)."'"; + $sql .= " AND d.ref_ext='".$this->db->escape($ref_ext)."'"; } dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); - $this->entity = $obj->entity; - $this->ref = $obj->rowid; - $this->id = $obj->rowid; - $this->ref_ext = $obj->ref_ext; + $this->entity = $obj->entity; + $this->ref = $obj->rowid; + $this->id = $obj->rowid; + $this->ref_ext = $obj->ref_ext; - $this->civility_id = $obj->civility_code; // Bad. Kept for backard compatibility + $this->civility_id = $obj->civility_code; // Bad. Kept for backard compatibility $this->civility_code = $obj->civility_code; - $this->civility = $obj->civility_code?($langs->trans("Civility".$obj->civility_code) != ("Civility".$obj->civility_code) ? $langs->trans("Civility".$obj->civility_code) : $obj->civility_code):''; + $this->civility = $obj->civility_code ? ($langs->trans("Civility".$obj->civility_code) != ("Civility".$obj->civility_code) ? $langs->trans("Civility".$obj->civility_code) : $obj->civility_code) : ''; $this->firstname = $obj->firstname; $this->lastname = $obj->lastname; - $this->gender = $obj->gender; + $this->gender = $obj->gender; $this->login = $obj->login; $this->societe = $obj->company; $this->company = $obj->company; $this->socid = $obj->fk_soc; - $this->fk_soc = $obj->fk_soc; // For backward compatibility + $this->fk_soc = $obj->fk_soc; // For backward compatibility $this->address = $obj->address; - $this->zip = $obj->zip; + $this->zip = $obj->zip; $this->town = $obj->town; $this->pass = $obj->pass; - $this->pass_indatabase = $obj->pass; + $this->pass_indatabase = $obj->pass; $this->pass_indatabase_crypted = $obj->pass_crypted; - $this->state_id = $obj->state_id; - $this->state_code = $obj->state_id?$obj->state_code:''; - $this->state = $obj->state_id?$obj->state:''; + $this->state_id = $obj->state_id; + $this->state_code = $obj->state_id ? $obj->state_code : ''; + $this->state = $obj->state_id ? $obj->state : ''; $this->country_id = $obj->country_id; - $this->country_code = $obj->country_code; + $this->country_code = $obj->country_code; if ($langs->trans("Country".$obj->country_code) != "Country".$obj->country_code) $this->country = $langs->transnoentitiesnoconv("Country".$obj->country_code); else - $this->country=$obj->country; + $this->country = $obj->country; $this->phone = $obj->phone; - $this->phone_perso = $obj->phone_perso; - $this->phone_mobile = $obj->phone_mobile; + $this->phone_perso = $obj->phone_perso; + $this->phone_mobile = $obj->phone_mobile; $this->email = $obj->email; $this->socialnetworks = (array) json_decode($obj->socialnetworks, true); - $this->photo = $obj->photo; + $this->photo = $obj->photo; $this->statut = $obj->statut; $this->public = $obj->public; $this->datec = $this->db->jdate($obj->datec); $this->date_creation = $this->db->jdate($obj->datec); $this->datem = $this->db->jdate($obj->datem); - $this->date_modification= $this->db->jdate($obj->datem); - $this->datefin = $this->db->jdate($obj->datefin); - $this->datevalid = $this->db->jdate($obj->datev); - $this->date_validation = $this->db->jdate($obj->datev); - $this->birth = $this->db->jdate($obj->birthday); + $this->date_modification = $this->db->jdate($obj->datem); + $this->datefin = $this->db->jdate($obj->datefin); + $this->datevalid = $this->db->jdate($obj->datev); + $this->date_validation = $this->db->jdate($obj->datev); + $this->birth = $this->db->jdate($obj->birthday); - $this->note_private = $obj->note_private; - $this->note_public = $obj->note_public; + $this->note_private = $obj->note_private; + $this->note_public = $obj->note_public; $this->morphy = $obj->morphy; $this->typeid = $obj->fk_adherent_type; - $this->type = $obj->type; - $this->need_subscription = $obj->subscription; + $this->type = $obj->type; + $this->need_subscription = $obj->subscription; - $this->user_id = $obj->user_id; - $this->user_login = $obj->user_login; + $this->user_id = $obj->user_id; + $this->user_login = $obj->user_login; - $this->model_pdf = $obj->model_pdf; + $this->model_pdf = $obj->model_pdf; // Retreive all extrafield // fetch optionals attributes and labels @@ -1343,7 +1343,7 @@ class Adherent extends CommonObject // Load other properties if ($fetch_subscriptions) { - $result=$this->fetch_subscriptions(); + $result = $this->fetch_subscriptions(); } return $this->id; @@ -1355,7 +1355,7 @@ class Adherent extends CommonObject } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -1377,47 +1377,47 @@ class Adherent extends CommonObject require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; $sql = "SELECT c.rowid, c.fk_adherent, c.subscription, c.note, c.fk_bank,"; - $sql.= " c.tms as datem,"; - $sql.= " c.datec as datec,"; - $sql.= " c.dateadh as dateh,"; - $sql.= " c.datef as datef"; - $sql.= " FROM ".MAIN_DB_PREFIX."subscription as c"; - $sql.= " WHERE c.fk_adherent = ".$this->id; - $sql.= " ORDER BY c.dateadh"; + $sql .= " c.tms as datem,"; + $sql .= " c.datec as datec,"; + $sql .= " c.dateadh as dateh,"; + $sql .= " c.datef as datef"; + $sql .= " FROM ".MAIN_DB_PREFIX."subscription as c"; + $sql .= " WHERE c.fk_adherent = ".$this->id; + $sql .= " ORDER BY c.dateadh"; dol_syslog(get_class($this)."::fetch_subscriptions", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $this->subscriptions=array(); + $this->subscriptions = array(); - $i=0; + $i = 0; while ($obj = $this->db->fetch_object($resql)) { - if ($i==0) + if ($i == 0) { - $this->first_subscription_date=$this->db->jdate($obj->datec); - $this->first_subscription_date_start=$this->db->jdate($obj->dateh); - $this->first_subscription_date_end=$this->db->jdate($obj->datef); - $this->first_subscription_amount=$obj->subscription; + $this->first_subscription_date = $this->db->jdate($obj->datec); + $this->first_subscription_date_start = $this->db->jdate($obj->dateh); + $this->first_subscription_date_end = $this->db->jdate($obj->datef); + $this->first_subscription_amount = $obj->subscription; } - $this->last_subscription_date=$this->db->jdate($obj->datec); - $this->last_subscription_date_start=$this->db->jdate($obj->datef); - $this->last_subscription_date_end=$this->db->jdate($obj->datef); - $this->last_subscription_amount=$obj->subscription; + $this->last_subscription_date = $this->db->jdate($obj->datec); + $this->last_subscription_date_start = $this->db->jdate($obj->datef); + $this->last_subscription_date_end = $this->db->jdate($obj->datef); + $this->last_subscription_amount = $obj->subscription; - $subscription=new Subscription($this->db); - $subscription->id=$obj->rowid; - $subscription->fk_adherent=$obj->fk_adherent; - $subscription->amount=$obj->subscription; - $subscription->note=$obj->note; - $subscription->fk_bank=$obj->fk_bank; - $subscription->datem=$this->db->jdate($obj->datem); - $subscription->datec=$this->db->jdate($obj->datec); - $subscription->dateh=$this->db->jdate($obj->dateh); - $subscription->datef=$this->db->jdate($obj->datef); + $subscription = new Subscription($this->db); + $subscription->id = $obj->rowid; + $subscription->fk_adherent = $obj->fk_adherent; + $subscription->amount = $obj->subscription; + $subscription->note = $obj->note; + $subscription->fk_bank = $obj->fk_bank; + $subscription->datem = $this->db->jdate($obj->datem); + $subscription->datec = $this->db->jdate($obj->datec); + $subscription->dateh = $this->db->jdate($obj->dateh); + $subscription->datef = $this->db->jdate($obj->datef); - $this->subscriptions[]=$subscription; + $this->subscriptions[] = $subscription; $i++; } @@ -1425,7 +1425,7 @@ class Adherent extends CommonObject } else { - $this->error=$this->db->error().' sql='.$sql; + $this->error = $this->db->error().' sql='.$sql; return -1; } } @@ -1447,20 +1447,20 @@ class Adherent extends CommonObject */ public function subscription($date, $amount, $accountid = 0, $operation = '', $label = '', $num_chq = '', $emetteur_nom = '', $emetteur_banque = '', $datesubend = 0) { - global $conf,$langs,$user; + global $conf, $langs, $user; require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; - $error=0; + $error = 0; // Clean parameters - if (! $amount) $amount=0; + if (!$amount) $amount = 0; $this->db->begin(); if ($datesubend) { - $datefin=$datesubend; + $datefin = $datesubend; } else { @@ -1470,30 +1470,30 @@ class Adherent extends CommonObject } // Create subscription - $subscription=new Subscription($this->db); - $subscription->fk_adherent=$this->id; - $subscription->dateh=$date; // Date of new subscription - $subscription->datef=$datefin; // End data of new subscription - $subscription->amount=$amount; - $subscription->note=$label; // deprecated - $subscription->note_public=$label; + $subscription = new Subscription($this->db); + $subscription->fk_adherent = $this->id; + $subscription->dateh = $date; // Date of new subscription + $subscription->datef = $datefin; // End data of new subscription + $subscription->amount = $amount; + $subscription->note = $label; // deprecated + $subscription->note_public = $label; - $rowid=$subscription->create($user); + $rowid = $subscription->create($user); if ($rowid > 0) { // Update denormalized subscription end date (read database subscription to find values) // This will also update this->datefin - $result=$this->update_end_date($user); + $result = $this->update_end_date($user); if ($result > 0) { // Change properties of object (used by triggers) - $this->last_subscription_date=dol_now(); - $this->last_subscription_date_start=$date; - $this->last_subscription_date_end=$datefin; - $this->last_subscription_amount=$amount; + $this->last_subscription_date = dol_now(); + $this->last_subscription_date_start = $date; + $this->last_subscription_date_end = $datefin; + $this->last_subscription_amount = $amount; } - if (! $error) + if (!$error) { $this->db->commit(); return $rowid; @@ -1506,8 +1506,8 @@ class Adherent extends CommonObject } else { - $this->error=$subscription->error; - $this->errors=$subscription->errors; + $this->error = $subscription->error; + $this->errors = $subscription->errors; $this->db->rollback(); return -1; } @@ -1537,7 +1537,7 @@ class Adherent extends CommonObject $error = 0; - $this->invoice = null; // This will contains invoice if an invoice is created + $this->invoice = null; // This will contains invoice if an invoice is created dol_syslog("subscriptionComplementaryActions subscriptionid=".$subscriptionid." option=".$option." accountid=".$accountid." datesubscription=".$datesubscription." paymentdate=".$paymentdate." label=".$label." amount=".$amount." num_chq=".$num_chq." autocreatethirdparty=".$autocreatethirdparty); @@ -1546,42 +1546,42 @@ class Adherent extends CommonObject { require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - $acct=new Account($this->db); - $result=$acct->fetch($accountid); + $acct = new Account($this->db); + $result = $acct->fetch($accountid); - $dateop=$paymentdate; + $dateop = $paymentdate; - $insertid=$acct->addline($dateop, $operation, $label, $amount, $num_chq, '', $user, $emetteur_nom, $emetteur_banque); + $insertid = $acct->addline($dateop, $operation, $label, $amount, $num_chq, '', $user, $emetteur_nom, $emetteur_banque); if ($insertid > 0) { - $inserturlid=$acct->add_url_line($insertid, $this->id, DOL_URL_ROOT.'/adherents/card.php?rowid=', $this->getFullname($langs), 'member'); + $inserturlid = $acct->add_url_line($insertid, $this->id, DOL_URL_ROOT.'/adherents/card.php?rowid=', $this->getFullname($langs), 'member'); if ($inserturlid > 0) { // Update table subscription - $sql ="UPDATE ".MAIN_DB_PREFIX."subscription SET fk_bank=".$insertid; - $sql.=" WHERE rowid=".$subscriptionid; + $sql = "UPDATE ".MAIN_DB_PREFIX."subscription SET fk_bank=".$insertid; + $sql .= " WHERE rowid=".$subscriptionid; dol_syslog("subscription::subscription", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { $error++; - $this->error=$this->db->lasterror(); - $this->errors[]=$this->error; + $this->error = $this->db->lasterror(); + $this->errors[] = $this->error; } } else { $error++; - $this->error=$acct->error; - $this->errors=$acct->errors; + $this->error = $acct->error; + $this->errors = $acct->errors; } } else { $error++; - $this->error=$acct->error; - $this->errors=$acct->errors; + $this->error = $acct->error; + $this->errors = $acct->errors; } } @@ -1591,31 +1591,31 @@ class Adherent extends CommonObject require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/paymentterm.class.php'; - $invoice=new Facture($this->db); - $customer=new Societe($this->db); + $invoice = new Facture($this->db); + $customer = new Societe($this->db); - if (! $error) + if (!$error) { - if (! ($this->fk_soc > 0)) // If not yet linked to a company + if (!($this->fk_soc > 0)) // If not yet linked to a company { if ($autocreatethirdparty) { // Create a linked thirdparty to member - $companyalias=''; + $companyalias = ''; $fullname = $this->getFullName($langs); if ($this->morphy == 'mor') { - $companyname=$this->company; - if (! empty($fullname)) $companyalias=$fullname; + $companyname = $this->company; + if (!empty($fullname)) $companyalias = $fullname; } else { - $companyname=$fullname; - if (! empty($this->company)) $companyalias=$this->company; + $companyname = $fullname; + if (!empty($this->company)) $companyalias = $this->company; } - $result=$customer->create_from_member($this, $companyname, $companyalias); + $result = $customer->create_from_member($this, $companyname, $companyalias); if ($result < 0) { $this->error = $customer->error; @@ -1630,54 +1630,54 @@ class Adherent extends CommonObject else { $langs->load("errors"); - $this->error=$langs->trans("ErrorMemberNotLinkedToAThirpartyLinkOrCreateFirst"); - $this->errors[]=$this->error; + $this->error = $langs->trans("ErrorMemberNotLinkedToAThirpartyLinkOrCreateFirst"); + $this->errors[] = $this->error; $error++; } } } - if (! $error) + if (!$error) { - $result=$customer->fetch($this->fk_soc); + $result = $customer->fetch($this->fk_soc); if ($result <= 0) { - $this->error=$customer->error; - $this->errors=$customer->errors; + $this->error = $customer->error; + $this->errors = $customer->errors; $error++; } } - if (! $error) + if (!$error) { // Create draft invoice - $invoice->type=Facture::TYPE_STANDARD; - $invoice->cond_reglement_id=$customer->cond_reglement_id; + $invoice->type = Facture::TYPE_STANDARD; + $invoice->cond_reglement_id = $customer->cond_reglement_id; if (empty($invoice->cond_reglement_id)) { - $paymenttermstatic=new PaymentTerm($this->db); - $invoice->cond_reglement_id=$paymenttermstatic->getDefaultId(); + $paymenttermstatic = new PaymentTerm($this->db); + $invoice->cond_reglement_id = $paymenttermstatic->getDefaultId(); if (empty($invoice->cond_reglement_id)) { $error++; - $this->error='ErrorNoPaymentTermRECEPFound'; - $this->errors[]=$this->error; + $this->error = 'ErrorNoPaymentTermRECEPFound'; + $this->errors[] = $this->error; } } - $invoice->socid=$this->fk_soc; - $invoice->date=$datesubscription; + $invoice->socid = $this->fk_soc; + $invoice->date = $datesubscription; // Possibility to add external linked objects with hooks $invoice->linked_objects['subscription'] = $subscriptionid; - if (! empty($_POST['other_linked_objects']) && is_array($_POST['other_linked_objects'])) + if (!empty($_POST['other_linked_objects']) && is_array($_POST['other_linked_objects'])) { $invoice->linked_objects = array_merge($invoice->linked_objects, $_POST['other_linked_objects']); } - $result=$invoice->create($user); + $result = $invoice->create($user); if ($result <= 0) { - $this->error=$invoice->error; - $this->errors=$invoice->errors; + $this->error = $invoice->error; + $this->errors = $invoice->errors; $error++; } else @@ -1686,46 +1686,46 @@ class Adherent extends CommonObject } } - if (! $error) + if (!$error) { // Add line to draft invoice - $idprodsubscription=0; - if (! empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (! empty($conf->product->enabled) || ! empty($conf->service->enabled))) $idprodsubscription = $conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS; + $idprodsubscription = 0; + if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) $idprodsubscription = $conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS; - $vattouse=0; + $vattouse = 0; if (isset($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) && $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS == 'defaultforfoundationcountry') { - $vattouse=get_default_tva($mysoc, $mysoc, $idprodsubscription); + $vattouse = get_default_tva($mysoc, $mysoc, $idprodsubscription); } //print xx".$vattouse." - ".$mysoc." - ".$customer;exit; - $result=$invoice->addline($label, 0, 1, $vattouse, 0, 0, $idprodsubscription, 0, $datesubscription, '', 0, 0, '', 'TTC', $amount, 1); + $result = $invoice->addline($label, 0, 1, $vattouse, 0, 0, $idprodsubscription, 0, $datesubscription, '', 0, 0, '', 'TTC', $amount, 1); if ($result <= 0) { - $this->error=$invoice->error; - $this->errors=$invoice->errors; + $this->error = $invoice->error; + $this->errors = $invoice->errors; $error++; } } - if (! $error) + if (!$error) { // Validate invoice - $result=$invoice->validate($user); + $result = $invoice->validate($user); if ($result <= 0) { - $this->error=$invoice->error; - $this->errors=$invoice->errors; + $this->error = $invoice->error; + $this->errors = $invoice->errors; $error++; } } - if (! $error) + if (!$error) { // TODO Link invoice with subscription ? } // Add payment onto invoice - if (! $error && $option == 'bankviainvoice' && $accountid) + if (!$error && $option == 'bankviainvoice' && $accountid) { require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; @@ -1741,61 +1741,61 @@ class Adherent extends CommonObject $paiement->num_payment = $num_chq; $paiement->note_public = $label; - if (! $error) + if (!$error) { // Create payment line for invoice $paiement_id = $paiement->create($user); - if (! $paiement_id > 0) + if (!$paiement_id > 0) { - $this->error=$paiement->error; - $this->errors=$paiement->errors; + $this->error = $paiement->error; + $this->errors = $paiement->errors; $error++; } } - if (! $error) + if (!$error) { // Add transaction into bank account - $bank_line_id=$paiement->addPaymentToBank($user, 'payment', '(SubscriptionPayment)', $accountid, $emetteur_nom, $emetteur_banque); - if (! ($bank_line_id > 0)) + $bank_line_id = $paiement->addPaymentToBank($user, 'payment', '(SubscriptionPayment)', $accountid, $emetteur_nom, $emetteur_banque); + if (!($bank_line_id > 0)) { - $this->error=$paiement->error; - $this->errors=$paiement->errors; + $this->error = $paiement->error; + $this->errors = $paiement->errors; $error++; } } - if (! $error && !empty($bank_line_id)) + if (!$error && !empty($bank_line_id)) { // Update fk_bank into subscription table $sql = 'UPDATE '.MAIN_DB_PREFIX.'subscription SET fk_bank='.$bank_line_id; - $sql.= ' WHERE rowid='.$subscriptionid; + $sql .= ' WHERE rowid='.$subscriptionid; $result = $this->db->query($sql); - if (! $result) + if (!$result) { $error++; } } - if (! $error) + if (!$error) { // Set invoice as paid $invoice->set_paid($user); } } - if (! $error) + if (!$error) { // Define output language $outputlangs = $langs; $newlang = ''; - $lang_id=GETPOST('lang_id'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($lang_id)) + $lang_id = GETPOST('lang_id'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && !empty($lang_id)) $newlang = $lang_id; if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $customer->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } @@ -1825,10 +1825,10 @@ class Adherent extends CommonObject */ public function validate($user) { - global $langs,$conf; + global $langs, $conf; - $error=0; - $now=dol_now(); + $error = 0; + $now = dol_now(); // Check parameters if ($this->statut == 1) @@ -1840,19 +1840,19 @@ class Adherent extends CommonObject $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET"; - $sql.= " statut = 1"; - $sql.= ", datevalid = '".$this->db->idate($now)."'"; - $sql.= ", fk_user_valid=".$user->id; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " statut = 1"; + $sql .= ", datevalid = '".$this->db->idate($now)."'"; + $sql .= ", fk_user_valid=".$user->id; + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::validate", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { - $this->statut=1; + $this->statut = 1; // Call trigger - $result=$this->call_trigger('MEMBER_VALIDATE', $user); + $result = $this->call_trigger('MEMBER_VALIDATE', $user); if ($result < 0) { $error++; $this->db->rollback(); return -1; } // End call triggers @@ -1863,7 +1863,7 @@ class Adherent extends CommonObject } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; } @@ -1878,9 +1878,9 @@ class Adherent extends CommonObject */ public function resiliate($user) { - global $langs,$conf; + global $langs, $conf; - $error=0; + $error = 0; // Check parameters if ($this->statut == 0) @@ -1892,17 +1892,17 @@ class Adherent extends CommonObject $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET"; - $sql.= " statut = 0"; - $sql.= ", fk_user_valid=".$user->id; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " statut = 0"; + $sql .= ", fk_user_valid=".$user->id; + $sql .= " WHERE rowid = ".$this->id; $result = $this->db->query($sql); if ($result) { - $this->statut=0; + $this->statut = 0; // Call trigger - $result=$this->call_trigger('MEMBER_RESILIATE', $user); + $result = $this->call_trigger('MEMBER_RESILIATE', $user); if ($result < 0) { $error++; $this->db->rollback(); return -1; } // End call triggers @@ -1911,7 +1911,7 @@ class Adherent extends CommonObject } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; } @@ -1927,43 +1927,43 @@ class Adherent extends CommonObject public function add_to_abo() { // phpcs:enable - global $conf,$langs; + global $conf, $langs; include_once DOL_DOCUMENT_ROOT.'/mailmanspip/class/mailmanspip.class.php'; - $mailmanspip=new MailmanSpip($this->db); + $mailmanspip = new MailmanSpip($this->db); - $err=0; + $err = 0; // mailman - if (! empty($conf->global->ADHERENT_USE_MAILMAN) && ! empty($conf->mailmanspip->enabled)) + if (!empty($conf->global->ADHERENT_USE_MAILMAN) && !empty($conf->mailmanspip->enabled)) { - $result=$mailmanspip->add_to_mailman($this); + $result = $mailmanspip->add_to_mailman($this); if ($result < 0) { - if (! empty($mailmanspip->error)) $this->errors[]=$mailmanspip->error; - $err+=1; + if (!empty($mailmanspip->error)) $this->errors[] = $mailmanspip->error; + $err += 1; } foreach ($mailmanspip->mladded_ko as $tmplist => $tmpemail) { $langs->load("errors"); - $this->errors[]=$langs->trans("ErrorFailedToAddToMailmanList", $tmpemail, $tmplist); + $this->errors[] = $langs->trans("ErrorFailedToAddToMailmanList", $tmpemail, $tmplist); } foreach ($mailmanspip->mladded_ok as $tmplist => $tmpemail) { $langs->load("mailmanspip"); - $this->mesgs[]=$langs->trans("SuccessToAddToMailmanList", $tmpemail, $tmplist); + $this->mesgs[] = $langs->trans("SuccessToAddToMailmanList", $tmpemail, $tmplist); } } // spip - if (! empty($conf->global->ADHERENT_USE_SPIP) && ! empty($conf->mailmanspip->enabled)) + if (!empty($conf->global->ADHERENT_USE_SPIP) && !empty($conf->mailmanspip->enabled)) { - $result=$mailmanspip->add_to_spip($this); + $result = $mailmanspip->add_to_spip($this); if ($result < 0) { - $this->errors[]=$mailmanspip->error; - $err+=1; + $this->errors[] = $mailmanspip->error; + $err += 1; } } if ($err) @@ -1986,42 +1986,42 @@ class Adherent extends CommonObject public function del_to_abo() { // phpcs:enable - global $conf,$langs; + global $conf, $langs; include_once DOL_DOCUMENT_ROOT.'/mailmanspip/class/mailmanspip.class.php'; - $mailmanspip=new MailmanSpip($this->db); + $mailmanspip = new MailmanSpip($this->db); - $err=0; + $err = 0; // mailman - if (! empty($conf->global->ADHERENT_USE_MAILMAN)) + if (!empty($conf->global->ADHERENT_USE_MAILMAN)) { - $result=$mailmanspip->del_to_mailman($this); + $result = $mailmanspip->del_to_mailman($this); if ($result < 0) { - if (! empty($mailmanspip->error)) $this->errors[]=$mailmanspip->error; - $err+=1; + if (!empty($mailmanspip->error)) $this->errors[] = $mailmanspip->error; + $err += 1; } foreach ($mailmanspip->mlremoved_ko as $tmplist => $tmpemail) { $langs->load("errors"); - $this->errors[]=$langs->trans("ErrorFailedToRemoveToMailmanList", $tmpemail, $tmplist); + $this->errors[] = $langs->trans("ErrorFailedToRemoveToMailmanList", $tmpemail, $tmplist); } foreach ($mailmanspip->mlremoved_ok as $tmplist => $tmpemail) { $langs->load("mailmanspip"); - $this->mesgs[]=$langs->trans("SuccessToRemoveToMailmanList", $tmpemail, $tmplist); + $this->mesgs[] = $langs->trans("SuccessToRemoveToMailmanList", $tmpemail, $tmplist); } } - if ($conf->global->ADHERENT_USE_SPIP && ! empty($conf->mailmanspip->enabled)) + if ($conf->global->ADHERENT_USE_SPIP && !empty($conf->mailmanspip->enabled)) { - $result=$mailmanspip->del_to_spip($this); + $result = $mailmanspip->del_to_spip($this); if ($result < 0) { - $this->errors[]=$mailmanspip->error; - $err+=1; + $this->errors[] = $mailmanspip->error; + $err += 1; } } if ($err) @@ -2046,7 +2046,7 @@ class Adherent extends CommonObject global $langs; $langs->load("dict"); - $code=(empty($this->civility_id)?'':$this->civility_id); + $code = (empty($this->civility_id) ? '' : $this->civility_id); if (empty($code)) return ''; return $langs->getLabelFromKey($this->db, "Civility".$code, "c_civility", "code", "label", $code); } @@ -2067,27 +2067,27 @@ class Adherent extends CommonObject { global $conf, $langs; - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpictoimg) $withpictoimg=0; + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpictoimg) $withpictoimg = 0; - $result=''; $label=''; - $linkstart=''; $linkend=''; + $result = ''; $label = ''; + $linkstart = ''; $linkend = ''; - if (! empty($this->photo)) + if (!empty($this->photo)) { - $label.= '