diff --git a/.github/workflows/stale-issues.yml b/.github/workflows/stale-issues.yml index 8afb7e8f4f8..0be87022eef 100644 --- a/.github/workflows/stale-issues.yml +++ b/.github/workflows/stale-issues.yml @@ -9,7 +9,7 @@ jobs: stale: runs-on: ubuntu-latest steps: - - uses: Dolibarr/stale@v1.1.0 + - uses: Dolibarr/stale@master with: repo-token: ${{ secrets.GITHUB_TOKEN }} stale-issue-message: 'This issue is stale because it has been open 1 year with no activity. If this is a bug, please comment to confirm it is still present on latest stable version. if this is a feature request, please comment to notify the request is still relevant and not yet covered by latest stable version. Without comment, this issue will be closed automatically by stale bot in 15 days.' @@ -17,7 +17,7 @@ jobs: exempt-issue-label: 'Priority High / Blocking' days-before-stale: 365 days-before-close: 15 - operations-per-run: 10 + operations-per-run: 30 #stale-pr-message: 'This PR is stale because it has been open 1 year with no activity. If this PR is still mergeable (no conflict, nor Continuous Integration errors), please comment to confirm this merge is still expected. Without comment, this issue will be closed automatically by stale bot in 15 days.' stale-pr-label: 'PR Stale (automatic label)' stale-pr-message: diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 203ded8cedd..6de540c43c9 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -32,10 +32,9 @@ * \ingroup member * \brief File of class to manage members of a foundation */ - -require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; /** @@ -43,6 +42,7 @@ require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; */ class Adherent extends CommonObject { + /** * @var string ID to identify managed object */ @@ -61,22 +61,24 @@ class Adherent extends CommonObject public $mesgs; - /** - * @var string login of member - */ + /** + * @var string login of member + */ public $login; //! Clear password in memory public $pass; + //! Clear password in database (defined if DATABASE_PWD_ENCRYPTED=0) public $pass_indatabase; + //! Encrypted password in database (always defined) public $pass_indatabase_crypted; - /** - * @var string company name - * @deprecated - */ + /** + * @var string company name + * @deprecated + */ public $societe; /** @@ -87,153 +89,164 @@ class Adherent extends CommonObject /** * @var int Thirdparty ID */ - public $fk_soc; + public $fk_soc; /** * @var string Address */ public $address; - /** - * @var string zipcode - */ - public $zip; + /** + * @var string zipcode + */ + public $zip; - /** - * @var string town - */ + /** + * @var string town + */ public $town; - /** - * @var int Id of state - */ - public $state_id; + /** + * @var int Id of state + */ + public $state_id; - /** - * @var string Code of state - */ - public $state_code; + /** + * @var string Code of state + */ + public $state_code; - /** - * @var string Label of state - */ + /** + * @var string Label of state + */ public $state; - /** - * @var string email - */ + /** + * @var string email + */ public $email; - /** - * @var array array of socialnetworks - */ - public $socialnetworks; + /** + * @var array array of socialnetworks + */ + public $socialnetworks; - /** - * @var string skype account + /** + * @var string skype account * @deprecated - */ - public $skype; + */ + public $skype; - /** - * @var string twitter account + /** + * @var string twitter account * @deprecated - */ - public $twitter; + */ + public $twitter; - /** - * @var string facebook account + /** + * @var string facebook account * @deprecated - */ + */ public $facebook; - /** - * @var string linkedin account + /** + * @var string linkedin account * @deprecated - */ - public $linkedin; + */ + public $linkedin; - /** - * @var string Phone number - */ + /** + * @var string Phone number + */ public $phone; - /** - * @var string Private Phone number - */ + /** + * @var string Private Phone number + */ public $phone_perso; - /** - * @var string Mobile phone number - */ + /** + * @var string Mobile phone number + */ public $phone_mobile; - /** - * @var string Fax number - */ - public $fax; + /** + * @var string Fax number + */ + public $fax; - /** - * @var string Function - */ - public $poste; + /** + * @var string Function + */ + public $poste; public $morphy; + public $public; - // -1:brouillon, 0:resilie, >=1:valide,paye - // def in common object - //public $status; - - public $photo; + // -1:brouillon, 0:resilie, >=1:valide,paye + // def in common object + //public $status; + public $photo; /** - * Date creation record (datec) - * - * @var integer - */ - public $datec; + * Date creation record (datec) + * + * @var integer + */ + public $datec; /** - * Date modification record (tms) - * - * @var integer - */ - public $datem; + * Date modification record (tms) + * + * @var integer + */ + public $datem; public $datevalid; public $gender; + public $birth; - /** - * @var int id type member - */ + /** + * @var int id type member + */ public $typeid; - /** - * @var string label type member - */ + /** + * @var string label type member + */ public $type; + public $need_subscription; 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; + public $first_subscription_amount; + public $last_subscription_date; + public $last_subscription_date_start; + public $last_subscription_date_end; + public $last_subscription_amount; + public $subscriptions = array(); - /** - * @var Adherent To contains a clone of this when we need to save old properties of object - */ + /** + * @var Adherent To contains a clone of this when we need to save old properties of object + */ public $oldcopy; /** @@ -241,60 +254,47 @@ class Adherent extends CommonObject */ public $entity; - - public $fields=array( - 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), - '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), - 'lastname' =>array('type'=>'varchar(50)', 'label'=>'Lastname', 'enabled'=>1, 'visible'=>-1, 'position'=>30), - 'firstname' =>array('type'=>'varchar(50)', 'label'=>'Firstname', 'enabled'=>1, 'visible'=>-1, 'position'=>35), - 'login' =>array('type'=>'varchar(50)', 'label'=>'Login', 'enabled'=>1, 'visible'=>-1, 'position'=>40), - 'gender' =>array('type'=>'varchar(10)', 'label'=>'Gender', 'enabled'=>1, 'visible'=>-1, 'position'=>250), - 'pass' =>array('type'=>'varchar(50)', 'label'=>'Pass', 'enabled'=>1, 'visible'=>-1, 'position'=>45), - 'pass_crypted' =>array('type'=>'varchar(128)', 'label'=>'Pass crypted', 'enabled'=>1, 'visible'=>-1, 'position'=>50), - 'fk_adherent_type' =>array('type'=>'integer', 'label'=>'Fk adherent type', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>55), - 'morphy' =>array('type'=>'varchar(3)', 'label'=>'MorPhy', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>60), - 'societe' =>array('type'=>'varchar(128)', 'label'=>'Societe', 'enabled'=>1, 'visible'=>-1, 'position'=>65), - 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'position'=>70), - 'address' =>array('type'=>'text', 'label'=>'Address', 'enabled'=>1, 'visible'=>-1, 'position'=>75), - 'zip' =>array('type'=>'varchar(10)', 'label'=>'Zip', 'enabled'=>1, 'visible'=>-1, 'position'=>80), - 'town' =>array('type'=>'varchar(50)', 'label'=>'Town', 'enabled'=>1, 'visible'=>-1, 'position'=>85), - 'state_id' =>array('type'=>'integer', 'label'=>'State id', 'enabled'=>1, 'visible'=>-1, 'position'=>90), - 'country' =>array('type'=>'integer', 'label'=>'Country', 'enabled'=>1, 'visible'=>-1, 'position'=>95), - 'email' =>array('type'=>'varchar(255)', 'label'=>'Email', 'enabled'=>1, 'visible'=>-1, 'position'=>100), - 'socialnetworks' =>array('type'=>'text', 'label'=>'Socialnetworks', 'enabled'=>1, 'visible'=>-1, 'position'=>105), - //'skype' =>array('type'=>'varchar(255)', 'label'=>'Skype', 'enabled'=>1, 'visible'=>-1, 'position'=>110), - 'phone' =>array('type'=>'varchar(30)', 'label'=>'Phone', 'enabled'=>1, 'visible'=>-1, 'position'=>115), - 'phone_perso' =>array('type'=>'varchar(30)', 'label'=>'Phone perso', 'enabled'=>1, 'visible'=>-1, 'position'=>120), - 'phone_mobile' =>array('type'=>'varchar(30)', 'label'=>'Phone mobile', 'enabled'=>1, 'visible'=>-1, 'position'=>125), - 'birth' =>array('type'=>'date', 'label'=>'DateToBirth', 'enabled'=>1, 'visible'=>-1, 'position'=>130), - 'photo' =>array('type'=>'varchar(255)', 'label'=>'Photo', 'enabled'=>1, 'visible'=>-1, 'position'=>135), - 'public' =>array('type'=>'smallint(6)', 'label'=>'Public', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>145), - 'datefin' =>array('type'=>'datetime', 'label'=>'DateEnd', 'enabled'=>1, 'visible'=>-1, 'position'=>150), - 'note_private' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>155), - 'note_public' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>160), - 'datevalid' =>array('type'=>'datetime', 'label'=>'DateValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>165), - 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>170), - 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>175), - 'fk_user_author' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fk user author', 'enabled'=>1, 'visible'=>-1, 'position'=>180), - 'fk_user_mod' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fk user mod', 'enabled'=>1, 'visible'=>-1, 'position'=>185), - 'fk_user_valid' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>190), - 'canvas' =>array('type'=>'varchar(32)', 'label'=>'Canvas', 'enabled'=>1, 'visible'=>-1, 'position'=>195), - 'statut' =>array('type'=>'smallint(6)', 'label'=>'Statut', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Validated', -1=>'MemberStatusResiliatedShort')), - 'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>1, 'visible'=>0, 'position'=>800), - 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>805), - /*'twitter' =>array('type'=>'varchar(255)', 'label'=>'Twitter', 'enabled'=>1, 'visible'=>-1, 'position'=>210), - 'facebook' =>array('type'=>'varchar(255)', 'label'=>'Facebook', 'enabled'=>1, 'visible'=>-1, 'position'=>215), - 'instagram' =>array('type'=>'varchar(255)', 'label'=>'Instagram', 'enabled'=>1, 'visible'=>-1, 'position'=>220), - 'snapchat' =>array('type'=>'varchar(255)', 'label'=>'Snapchat', 'enabled'=>1, 'visible'=>-1, 'position'=>225), - 'googleplus' =>array('type'=>'varchar(255)', 'label'=>'Googleplus', 'enabled'=>1, 'visible'=>-1, 'position'=>230), - 'youtube' =>array('type'=>'varchar(255)', 'label'=>'Youtube', 'enabled'=>1, 'visible'=>-1, 'position'=>235), - 'whatsapp' =>array('type'=>'varchar(255)', 'label'=>'Whatsapp', 'enabled'=>1, 'visible'=>-1, 'position'=>240), - 'linkedin' =>array('type'=>'varchar(255)', 'label'=>'Linkedin', 'enabled'=>1, 'visible'=>-1, 'position'=>245),*/ - ); - - + public $fields = array('rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 10), + '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), + 'lastname' => array('type' => 'varchar(50)', 'label' => 'Lastname', 'enabled' => 1, 'visible' => -1, 'position' => 30), + 'firstname' => array('type' => 'varchar(50)', 'label' => 'Firstname', 'enabled' => 1, 'visible' => -1, 'position' => 35), + 'login' => array('type' => 'varchar(50)', 'label' => 'Login', 'enabled' => 1, 'visible' => -1, 'position' => 40), + 'gender' => array('type' => 'varchar(10)', 'label' => 'Gender', 'enabled' => 1, 'visible' => -1, 'position' => 250), + 'pass' => array('type' => 'varchar(50)', 'label' => 'Pass', 'enabled' => 1, 'visible' => -1, 'position' => 45), + 'pass_crypted' => array('type' => 'varchar(128)', 'label' => 'Pass crypted', 'enabled' => 1, 'visible' => -1, 'position' => 50), + 'fk_adherent_type' => array('type' => 'integer', 'label' => 'Fk adherent type', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 55), + 'morphy' => array('type' => 'varchar(3)', 'label' => 'MorPhy', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 60), + 'societe' => array('type' => 'varchar(128)', 'label' => 'Societe', 'enabled' => 1, 'visible' => -1, 'position' => 65), + 'fk_soc' => array('type' => 'integer:Societe:societe/class/societe.class.php', 'label' => 'ThirdParty', 'enabled' => 1, 'visible' => -1, 'position' => 70), + 'address' => array('type' => 'text', 'label' => 'Address', 'enabled' => 1, 'visible' => -1, 'position' => 75), + 'zip' => array('type' => 'varchar(10)', 'label' => 'Zip', 'enabled' => 1, 'visible' => -1, 'position' => 80), + 'town' => array('type' => 'varchar(50)', 'label' => 'Town', 'enabled' => 1, 'visible' => -1, 'position' => 85), + 'state_id' => array('type' => 'integer', 'label' => 'State id', 'enabled' => 1, 'visible' => -1, 'position' => 90), + 'country' => array('type' => 'integer', 'label' => 'Country', 'enabled' => 1, 'visible' => -1, 'position' => 95), + 'email' => array('type' => 'varchar(255)', 'label' => 'Email', 'enabled' => 1, 'visible' => -1, 'position' => 100), + 'socialnetworks' => array('type' => 'text', 'label' => 'Socialnetworks', 'enabled' => 1, 'visible' => -1, 'position' => 105), + 'phone' => array('type' => 'varchar(30)', 'label' => 'Phone', 'enabled' => 1, 'visible' => -1, 'position' => 115), + 'phone_perso' => array('type' => 'varchar(30)', 'label' => 'Phone perso', 'enabled' => 1, 'visible' => -1, 'position' => 120), + 'phone_mobile' => array('type' => 'varchar(30)', 'label' => 'Phone mobile', 'enabled' => 1, 'visible' => -1, 'position' => 125), + 'birth' => array('type' => 'date', 'label' => 'DateToBirth', 'enabled' => 1, 'visible' => -1, 'position' => 130), + 'photo' => array('type' => 'varchar(255)', 'label' => 'Photo', 'enabled' => 1, 'visible' => -1, 'position' => 135), + 'public' => array('type' => 'smallint(6)', 'label' => 'Public', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 145), + 'datefin' => array('type' => 'datetime', 'label' => 'DateEnd', 'enabled' => 1, 'visible' => -1, 'position' => 150), + 'note_private' => array('type' => 'text', 'label' => 'NotePublic', 'enabled' => 1, 'visible' => 0, 'position' => 155), + 'note_public' => array('type' => 'text', 'label' => 'NotePrivate', 'enabled' => 1, 'visible' => 0, 'position' => 160), + 'datevalid' => array('type' => 'datetime', 'label' => 'DateValidation', 'enabled' => 1, 'visible' => -1, 'position' => 165), + 'datec' => array('type' => 'datetime', 'label' => 'DateCreation', 'enabled' => 1, 'visible' => -1, 'position' => 170), + 'tms' => array('type' => 'timestamp', 'label' => 'DateModification', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 175), + 'fk_user_author' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'Fk user author', 'enabled' => 1, 'visible' => -1, 'position' => 180), + 'fk_user_mod' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'Fk user mod', 'enabled' => 1, 'visible' => -1, 'position' => 185), + 'fk_user_valid' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserValidation', 'enabled' => 1, 'visible' => -1, 'position' => 190), + 'canvas' => array('type' => 'varchar(32)', 'label' => 'Canvas', 'enabled' => 1, 'visible' => -1, 'position' => 195), + 'statut' => array('type' => 'smallint(6)', 'label' => 'Statut', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 500, + 'arrayofkeyval' => array(0 => 'Draft', 1 => 'Validated', -1 => 'MemberStatusResiliatedShort')), + 'model_pdf' => array('type' => 'varchar(255)', 'label' => 'Model pdf', 'enabled' => 1, 'visible' => 0, 'position' => 800), + 'import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'visible' => -2, 'position' => 805)); /** @@ -313,7 +313,7 @@ class Adherent extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function sending an email to the current member with the text supplied in parameter. * @@ -332,17 +332,16 @@ 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 + // phpcs:enable global $conf, $langs; // Detect if message is HTML - if ($msgishtml == -1) - { + if ($msgishtml == -1) { $msgishtml = 0; if (dol_textishtml($text, 0)) $msgishtml = 1; } - dol_syslog('send_an_email msgishtml='.$msgishtml); + dol_syslog('send_an_email msgishtml=' . $msgishtml); $texttosend = $this->makeSubstitution($text); $subjecttosend = $this->makeSubstitution($subject); @@ -352,18 +351,15 @@ class Adherent extends CommonObject $from = $conf->email_from; if (!empty($conf->global->ADHERENT_MAIL_FROM)) $from = $conf->global->ADHERENT_MAIL_FROM; - $trackid = 'mem'.$this->id; + $trackid = 'mem' . $this->id; // Send email (substitutionarray must be done just before this) - include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + include_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php'; $mailfile = new CMailFile($subjecttosend, $this->email, $from, $texttosend, $filename_list, $mimetype_list, $mimefilename_list, $addr_cc, $addr_bcc, $deliveryreceipt, $msgishtml, '', '', $trackid, $moreinheader); - if ($mailfile->sendfile()) - { + if ($mailfile->sendfile()) { return 1; - } - else - { - $this->error = $langs->trans("ErrorFailedToSendMail", $from, $this->email).'. '.$mailfile->error; + } else { + $this->error = $langs->trans("ErrorFailedToSendMail", $from, $this->email) . '. ' . $mailfile->error; return -1; } } @@ -385,50 +381,43 @@ class Adherent extends CommonObject 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"; - if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) - { - $infos .= $langs->transnoentities("Login").": ".$this->login."\n"; - $infos .= $langs->transnoentities("Password").": ".$this->pass."\n"; + 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("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( - '__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 : '') - ); + $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 : '')); complete_substitutions_array($substitutionarray, $langs, $this); @@ -445,9 +434,15 @@ class Adherent extends CommonObject public function getmorphylib($morphy = '') { global $langs; - if (!$morphy) { $morphy = $this->morphy; } - if ($morphy == 'phy') { return $langs->trans("Physical"); } - if ($morphy == 'mor') { return $langs->trans("Moral"); } + if (!$morphy) { + $morphy = $this->morphy; + } + if ($morphy == 'phy') { + return $langs->trans("Physical"); + } + if ($morphy == 'mor') { + return $langs->trans("Moral"); + } return $morphy; } @@ -470,17 +465,14 @@ class Adherent extends CommonObject $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 (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) - { - if (empty($this->login)) - { + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { + if (empty($this->login)) { $this->error = $langs->trans("ErrorWrongValueForParameterX", "Login"); return -1; } @@ -489,83 +481,72 @@ class Adherent extends CommonObject $this->db->begin(); // Insert member - $sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent"; + $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 .= " '" . $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); + dol_syslog(get_class($this) . "::create", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { - $id = $this->db->last_insert_id(MAIN_DB_PREFIX."adherent"); - if ($id > 0) - { + if ($result) { + $id = $this->db->last_insert_id(MAIN_DB_PREFIX . "adherent"); + if ($id > 0) { $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 - if ($result < 0) - { + if ($result < 0) { $this->db->rollback(); return -1; } // Add link to user - if ($this->user_id) - { + if ($this->user_id) { // Add link to user - $sql = "UPDATE ".MAIN_DB_PREFIX."user SET"; - $sql .= " fk_member = ".$this->id; - $sql .= " WHERE rowid = ".$this->user_id; - dol_syslog(get_class($this)."::create", LOG_DEBUG); + $sql = "UPDATE " . MAIN_DB_PREFIX . "user SET"; + $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->db->rollback(); return -4; } } - if (!$notrigger) - { + if (!$notrigger) { // Call trigger $result = $this->call_trigger('MEMBER_CREATE', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } - if (count($this->errors)) - { - dol_syslog(get_class($this)."::create ".implode(',', $this->errors), LOG_ERR); + if (count($this->errors)) { + dol_syslog(get_class($this) . "::create " . implode(',', $this->errors), LOG_ERR); $this->db->rollback(); return -3; - } - else - { + } else { $this->db->commit(); return $this->id; } - } - else - { + } else { $this->error = 'Failed to get last insert id'; - dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); + dol_syslog(get_class($this) . "::create " . $this->error, LOG_ERR); $this->db->rollback(); return -2; } - } - else - { + } else { $this->error = $this->db->error(); $this->db->rollback(); return -1; @@ -591,25 +572,25 @@ class Adherent extends CommonObject $nbrowsaffected = 0; $error = 0; - dol_syslog(get_class($this)."::update notrigger=".$notrigger.", nosyncuser=".$nosyncuser.", nosyncuserpass=".$nosyncuserpass." nosyncthirdparty=".$nosyncthirdparty.", email=".$this->email); + 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->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); + $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_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); return -1; @@ -617,58 +598,54 @@ 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 = "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; // 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)) - { + if ($resql2) { + while ($obj = $this->db->fetch_object($resql2)) { $this->type = $obj->label; - } + } } } - dol_syslog(get_class($this)."::update update member", LOG_DEBUG); + dol_syslog(get_class($this) . "::update update member", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { unset($this->country_code); unset($this->country); unset($this->state_code); @@ -682,18 +659,15 @@ class Adherent extends CommonObject if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { $result = $this->insertExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; } } // Update password - if (!$error && $this->pass) - { - dol_syslog(get_class($this)."::update update password"); - if ($this->pass != $this->pass_indatabase && $this->pass != $this->pass_indatabase_crypted) - { + 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; // If password to set differs from the one found into database @@ -703,37 +677,41 @@ class Adherent extends CommonObject } // Remove links to user and replace with new one - 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); + 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); + 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) - { - require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; + 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"); + dol_syslog(get_class($this) . "::update update linked user"); $luser = new User($this->db); $result = $luser->fetch($this->user_id); - if ($result >= 0) - { + if ($result >= 0) { //var_dump($this->user_login);exit; //var_dump($this->login);exit; @@ -763,34 +741,29 @@ class Adherent extends CommonObject $luser->fk_member = $this->id; $result = $luser->update($user, 0, 1, 1); // Use nosync to 1 to avoid cyclic updates - if ($result < 0) - { + if ($result < 0) { $this->error = $luser->error; - dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR); + dol_syslog(get_class($this) . "::update " . $this->error, LOG_ERR); $error++; } - } - else - { + } else { $this->error = $luser->error; $error++; } } // Update information on linked thirdparty if it is an update - if (!$error && $this->fk_soc > 0 && !$nosyncthirdparty) - { - require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + if (!$error && $this->fk_soc > 0 && !$nosyncthirdparty) { + require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; - dol_syslog(get_class($this)."::update update linked thirdparty"); + dol_syslog(get_class($this) . "::update update linked thirdparty"); // 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); - if ($result > 0) - { + if ($result > 0) { $lthirdparty->address = $this->address; $lthirdparty->zip = $this->zip; $lthirdparty->town = $this->town; @@ -803,43 +776,36 @@ class Adherent extends CommonObject $result = $lthirdparty->update($this->fk_soc, $user, 0, 1, 1, 'update'); // Use sync to 0 to avoid cyclic updates - if ($result < 0) - { + if ($result < 0) { $this->error = $lthirdparty->error; $this->errors = $lthirdparty->errors; - dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR); + dol_syslog(get_class($this) . "::update " . $this->error, LOG_ERR); $error++; } - } - elseif ($result < 0) - { + } elseif ($result < 0) { $this->error = $lthirdparty->error; $error++; } } } - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('MEMBER_MODIFY', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } - if (!$error) - { + if (!$error) { $this->db->commit(); return $nbrowsaffected; - } - else - { + } else { $this->db->rollback(); return -1; } - } - else - { + } else { $this->db->rollback(); $this->error = $this->db->lasterror(); return -2; @@ -847,7 +813,7 @@ class Adherent extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update denormalized last subscription date. * This function is called when we delete a subscription for example. @@ -857,47 +823,41 @@ class Adherent extends CommonObject */ public function update_end_date($user) { - // phpcs:enable + // phpcs:enable $this->db->begin(); // 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 .= " 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); + dol_syslog(get_class($this) . "::update_end_date", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + 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); - $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET"; - $sql .= " datefin=".($datefin != '' ? "'".$this->db->idate($datefin)."'" : "null"); - $sql .= " WHERE rowid = ".$this->id; + $sql = "UPDATE " . MAIN_DB_PREFIX . "adherent SET"; + $sql .= " datefin=" . ($datefin != '' ? "'" . $this->db->idate($datefin) . "'" : "null"); + $sql .= " WHERE rowid = " . $this->id; - dol_syslog(get_class($this)."::update_end_date", LOG_DEBUG); + dol_syslog(get_class($this) . "::update_end_date", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $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; - } - else - { + } else { $this->db->rollback(); return -1; } - } - else - { + } else { $this->error = $this->db->lasterror(); $this->db->rollback(); return -1; @@ -925,8 +885,7 @@ class Adherent extends CommonObject $this->db->begin(); - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('MEMBER_DELETE', $user); if ($result < 0) $error++; @@ -934,24 +893,21 @@ 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); + $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) - { + if (!$resql) { $error++; $this->error .= $this->db->lasterror(); $errorflag = -1; } // Remove subscription - if (!$error) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."subscription WHERE fk_adherent = ".$rowid; - dol_syslog(get_class($this)."::delete", LOG_DEBUG); + 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) - { + if (!$resql) { $error++; $this->error .= $this->db->lasterror(); $errorflag = -2; @@ -959,11 +915,9 @@ class Adherent extends CommonObject } // Remove linked user - if (!$error) - { + if (!$error) { $ret = $this->setUserId(0); - if ($ret < 0) - { + if ($ret < 0) { $error++; $this->error .= $this->db->lasterror(); $errorflag = -3; @@ -971,41 +925,34 @@ class Adherent extends CommonObject } // Removed extrafields - if (!$error) - { + if (!$error) { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { $result = $this->deleteExtraFields(); - if ($result < 0) - { + if ($result < 0) { $error++; $errorflag = -4; - dol_syslog(get_class($this)."::delete erreur ".$errorflag." ".$this->error, LOG_ERR); + dol_syslog(get_class($this) . "::delete erreur " . $errorflag . " " . $this->error, LOG_ERR); } } } // Remove adherent - if (!$error) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent WHERE rowid = ".$rowid; - dol_syslog(get_class($this)."::delete", LOG_DEBUG); + 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) - { + if (!$resql) { $error++; $this->error .= $this->db->lasterror(); $errorflag = -5; } } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; - } - else - { + } else { $this->db->rollback(); return $errorflag; } @@ -1028,12 +975,11 @@ class Adherent extends CommonObject $error = 0; - dol_syslog(get_class($this)."::setPassword user=".$user->id." password=".preg_replace('/./i', '*', $password)." isencrypted=".$isencrypted); + 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) - { - require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; + if (!$password) { + require_once DOL_DOCUMENT_ROOT . '/core/lib/security2.lib.php'; $password = getRandomPassword(false); } @@ -1041,85 +987,73 @@ class Adherent extends CommonObject $password_crypted = dol_hash($password); $password_indatabase = ''; - if (!$isencrypted) - { + if (!$isencrypted) { $password_indatabase = $password; } $this->db->begin(); // Mise a jour - $sql = "UPDATE ".MAIN_DB_PREFIX."adherent"; - $sql .= " SET pass_crypted = '".$this->db->escape($password_crypted)."'"; + $sql = "UPDATE " . MAIN_DB_PREFIX . "adherent"; + $sql .= " SET pass_crypted = '" . $this->db->escape($password_crypted) . "'"; //if (! empty($conf->global->DATABASE_PWD_ENCRYPTED)) - if ($isencrypted) - { + if ($isencrypted) { $sql .= ", pass = null"; + } else { + $sql .= ", pass = '" . $this->db->escape($password_indatabase) . "'"; } - else - { - $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); + dol_syslog(get_class($this) . "::setPassword", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { + if ($result) { $nbaffectedrows = $this->db->affected_rows($result); - if ($nbaffectedrows) - { + if ($nbaffectedrows) { $this->pass = $password; $this->pass_indatabase = $password_indatabase; $this->pass_indatabase_crypted = $password_crypted; - if ($this->user_id && !$nosyncuser) - { - require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; + 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); - if ($result >= 0) - { + if ($result >= 0) { $result = $luser->setPassword($user, $this->pass, 0, 0, 1); - if ($result < 0) - { + if ($result < 0) { $this->error = $luser->error; - dol_syslog(get_class($this)."::setPassword ".$this->error, LOG_ERR); + dol_syslog(get_class($this) . "::setPassword " . $this->error, LOG_ERR); $error++; } - } - else - { + } else { $this->error = $luser->error; $error++; } } - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('MEMBER_NEW_PASSWORD', $user); - if ($result < 0) { $error++; $this->db->rollback(); return -1; } + if ($result < 0) { + $error++; + $this->db->rollback(); + return -1; + } // End call triggers } $this->db->commit(); return $this->pass; - } - else - { + } else { $this->db->rollback(); return 0; } - } - else - { + } else { $this->db->rollback(); dol_print_error($this->db); return -1; @@ -1140,19 +1074,26 @@ class Adherent extends CommonObject $this->db->begin(); // If user is linked to this member, remove old link to this member - $sql = "UPDATE ".MAIN_DB_PREFIX."user SET fk_member = NULL WHERE fk_member = ".$this->id; - dol_syslog(get_class($this)."::setUserId", LOG_DEBUG); + $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; - dol_syslog(get_class($this)."::setUserId", LOG_DEBUG); + if ($userid > 0) { + $sql = "UPDATE " . MAIN_DB_PREFIX . "user SET fk_member = " . $this->id; + $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(); @@ -1174,28 +1115,24 @@ class Adherent extends CommonObject $this->db->begin(); // Remove link to third party onto any other members - if ($thirdpartyid > 0) - { - $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET fk_soc = null"; - $sql .= " WHERE fk_soc = '".$thirdpartyid."'"; - $sql .= " AND entity = ".$conf->entity; - dol_syslog(get_class($this)."::setThirdPartyId", LOG_DEBUG); + if ($thirdpartyid > 0) { + $sql = "UPDATE " . MAIN_DB_PREFIX . "adherent SET fk_soc = null"; + $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); + dol_syslog(get_class($this) . "::setThirdPartyId", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $this->db->commit(); return 1; - } - else - { + } else { $this->error = $this->db->error(); $this->db->rollback(); return -1; @@ -1203,7 +1140,7 @@ class Adherent extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Method to load member from its login * @@ -1212,29 +1149,25 @@ class Adherent extends CommonObject */ public function fetch_login($login) { - // phpcs:enable + // phpcs:enable global $conf; - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."adherent"; - $sql .= " WHERE login='".$this->db->escape($login)."'"; - $sql .= " AND entity = ".$conf->entity; + $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "adherent"; + $sql .= " WHERE login='" . $this->db->escape($login) . "'"; + $sql .= " AND entity = " . $conf->entity; $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { + if ($resql) { + if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); $this->fetch($obj->rowid); } - } - else - { + } else { dol_print_error($this->db); } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Method to load member from its name * @@ -1244,25 +1177,21 @@ class Adherent extends CommonObject */ public function fetch_name($firstname, $lastname) { - // phpcs:enable + // phpcs:enable 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 = "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; $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { + if ($resql) { + if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); $this->fetch($obj->rowid); } - } - else - { + } else { dol_print_error($this->db); } } @@ -1298,28 +1227,27 @@ class Adherent extends CommonObject $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 .= " 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; + 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; - } - elseif ($ref_ext) - { - $sql .= " AND d.ref_ext='".$this->db->escape($ref_ext)."'"; + $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) . "'"; } - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + dol_syslog(get_class($this) . "::fetch", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { + if ($resql) { + if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); $this->entity = $obj->entity; @@ -1327,62 +1255,62 @@ class Adherent extends CommonObject $this->id = $obj->rowid; $this->ref_ext = $obj->ref_ext; - $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_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->firstname = $obj->firstname; - $this->lastname = $obj->lastname; + $this->firstname = $obj->firstname; + $this->lastname = $obj->lastname; $this->gender = $obj->gender; - $this->login = $obj->login; - $this->societe = $obj->company; - $this->company = $obj->company; - $this->socid = $obj->fk_soc; + $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->address = $obj->address; + $this->address = $obj->address; $this->zip = $obj->zip; - $this->town = $obj->town; + $this->town = $obj->town; - $this->pass = $obj->pass; + $this->pass = $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_code = $obj->state_id ? $obj->state_code : ''; $this->state = $obj->state_id ? $obj->state : ''; - $this->country_id = $obj->country_id; + $this->country_id = $obj->country_id; $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); + 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->phone = $obj->phone; + $this->phone = $obj->phone; $this->phone_perso = $obj->phone_perso; $this->phone_mobile = $obj->phone_mobile; - $this->email = $obj->email; + $this->email = $obj->email; $this->socialnetworks = (array) json_decode($obj->socialnetworks, true); $this->photo = $obj->photo; - $this->statut = $obj->statut; - $this->public = $obj->public; + $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->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->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->morphy = $obj->morphy; + $this->morphy = $obj->morphy; - $this->typeid = $obj->fk_adherent_type; + $this->typeid = $obj->fk_adherent_type; $this->type = $obj->type; $this->need_subscription = $obj->subscription; @@ -1403,21 +1331,17 @@ class Adherent extends CommonObject } return $this->id; - } - else - { + } else { return 0; } - } - else - { + } else { $this->error = $this->db->lasterror(); return -1; } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to get member subscriptions data * first_subscription_date, first_subscription_date_start, first_subscription_date_end, first_subscription_amount @@ -1427,31 +1351,28 @@ class Adherent extends CommonObject */ public function fetch_subscriptions() { - // phpcs:enable + // phpcs:enable global $langs; - require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; + 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 .= " 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); + dol_syslog(get_class($this) . "::fetch_subscriptions", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $this->subscriptions = array(); $i = 0; - while ($obj = $this->db->fetch_object($resql)) - { - if ($i == 0) - { + while ($obj = $this->db->fetch_object($resql)) { + 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); @@ -1478,10 +1399,8 @@ class Adherent extends CommonObject $i++; } return 1; - } - else - { - $this->error = $this->db->error().' sql='.$sql; + } else { + $this->error = $this->db->error() . ' sql=' . $sql; return -1; } } @@ -1505,7 +1424,7 @@ class Adherent extends CommonObject { global $conf, $langs, $user; - require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; + require_once DOL_DOCUMENT_ROOT . '/adherents/class/subscription.class.php'; $error = 0; @@ -1514,12 +1433,9 @@ class Adherent extends CommonObject $this->db->begin(); - if ($datesubend) - { + if ($datesubend) { $datefin = $datesubend; - } - else - { + } else { // If no end date, end date = date + 1 year - 1 day $datefin = dol_time_plus_duree($date, 1, 'y'); $datefin = dol_time_plus_duree($datefin, -1, 'd'); @@ -1535,13 +1451,11 @@ class Adherent extends CommonObject $subscription->note_public = $label; $rowid = $subscription->create($user); - if ($rowid > 0) - { + 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); - if ($result > 0) - { + if ($result > 0) { // Change properties of object (used by triggers) $this->last_subscription_date = dol_now(); $this->last_subscription_date_start = $date; @@ -1549,19 +1463,14 @@ class Adherent extends CommonObject $this->last_subscription_amount = $amount; } - if (!$error) - { + if (!$error) { $this->db->commit(); return $rowid; - } - else - { + } else { $this->db->rollback(); return -2; } - } - else - { + } else { $this->error = $subscription->error; $this->errors = $subscription->errors; $this->db->rollback(); @@ -1595,12 +1504,12 @@ class Adherent extends CommonObject $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); + dol_syslog("subscriptionComplementaryActions subscriptionid=" . $subscriptionid . " option=" . $option . " accountid=" . $accountid . " datesubscription=" . $datesubscription . " paymentdate=" . + $paymentdate . " label=" . $label . " amount=" . $amount . " num_chq=" . $num_chq . " autocreatethirdparty=" . $autocreatethirdparty); // Insert into bank account directlty (if option choosed for) + link to llx_subscription if option is 'bankdirect' - if ($option == 'bankdirect' && $accountid) - { - require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + if ($option == 'bankdirect' && $accountid) { + require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; $acct = new Account($this->db); $result = $acct->fetch($accountid); @@ -1608,33 +1517,26 @@ class Adherent extends CommonObject $dateop = $paymentdate; $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'); - if ($inserturlid > 0) - { + if ($insertid > 0) { + $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; } - } - else - { + } else { $error++; $this->error = $acct->error; $this->errors = $acct->errors; } - } - else - { + } else { $error++; $this->error = $acct->error; $this->errors = $acct->errors; @@ -1642,78 +1544,62 @@ class Adherent extends CommonObject } // If option choosed, we create invoice - if (($option == 'bankviainvoice' && $accountid) || $option == 'invoiceonly') - { - require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/paymentterm.class.php'; + if (($option == 'bankviainvoice' && $accountid) || $option == 'invoiceonly') { + 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); - if (!$error) - { - if (!($this->fk_soc > 0)) // If not yet linked to a company + if (!$error) { + if (!($this->fk_soc > 0)) // If not yet linked to a company { - if ($autocreatethirdparty) - { + if ($autocreatethirdparty) { // Create a linked thirdparty to member $companyalias = ''; $fullname = $this->getFullName($langs); - if ($this->morphy == 'mor') - { + if ($this->morphy == 'mor') { $companyname = $this->company; if (!empty($fullname)) $companyalias = $fullname; - } - else - { + } else { $companyname = $fullname; if (!empty($this->company)) $companyalias = $this->company; } $result = $customer->create_from_member($this, $companyname, $companyalias); - if ($result < 0) - { + if ($result < 0) { $this->error = $customer->error; $this->errors = $customer->errors; $error++; - } - else - { + } else { $this->fk_soc = $result; } - } - else - { - $langs->load("errors"); - $this->error = $langs->trans("ErrorMemberNotLinkedToAThirpartyLinkOrCreateFirst"); - $this->errors[] = $this->error; - $error++; + } else { + $langs->load("errors"); + $this->error = $langs->trans("ErrorMemberNotLinkedToAThirpartyLinkOrCreateFirst"); + $this->errors[] = $this->error; + $error++; } } } - if (!$error) - { + if (!$error) { $result = $customer->fetch($this->fk_soc); - if ($result <= 0) - { + if ($result <= 0) { $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; - if (empty($invoice->cond_reglement_id)) - { + if (empty($invoice->cond_reglement_id)) { $paymenttermstatic = new PaymentTerm($this->db); $invoice->cond_reglement_id = $paymenttermstatic->getDefaultId(); - if (empty($invoice->cond_reglement_id)) - { + if (empty($invoice->cond_reglement_id)) { $error++; $this->error = 'ErrorNoPaymentTermRECEPFound'; $this->errors[] = $this->error; @@ -1724,133 +1610,112 @@ class Adherent extends CommonObject // 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); - if ($result <= 0) - { + if ($result <= 0) { $this->error = $invoice->error; $this->errors = $invoice->errors; $error++; - } - else - { + } else { $this->invoice = $invoice; } } - 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; $vattouse = 0; - if (isset($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) && $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS == 'defaultforfoundationcountry') - { + if (isset($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) && $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS == 'defaultforfoundationcountry') { $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); - if ($result <= 0) - { + if ($result <= 0) { $this->error = $invoice->error; $this->errors = $invoice->errors; $error++; } } - if (!$error) - { + if (!$error) { // Validate invoice $result = $invoice->validate($user); - if ($result <= 0) - { + if ($result <= 0) { $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) - { - require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; - require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; + 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'; + require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php'; $amounts = array(); $amounts[$invoice->id] = price2num($amount); $paiement = new Paiement($this->db); - $paiement->datepaye = $paymentdate; - $paiement->amounts = $amounts; - $paiement->paiementid = dol_getIdFromCode($this->db, $operation, 'c_paiement', 'code', 'id', 1); - $paiement->num_payment = $num_chq; - $paiement->note_public = $label; + $paiement->datepaye = $paymentdate; + $paiement->amounts = $amounts; + $paiement->paiementid = dol_getIdFromCode($this->db, $operation, 'c_paiement', 'code', 'id', 1); + $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; $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)) - { + if (!($bank_line_id > 0)) { $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 = 'UPDATE ' . MAIN_DB_PREFIX . 'subscription SET fk_bank=' . $bank_line_id; + $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)) - $newlang = $lang_id; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $customer->default_lang; + 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)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -1862,12 +1727,9 @@ class Adherent extends CommonObject } } - if ($error) - { + if ($error) { return -1; - } - else - { + } else { return 1; } } @@ -1887,38 +1749,38 @@ class Adherent extends CommonObject $now = dol_now(); // Check parameters - if ($this->statut == 1) - { - dol_syslog(get_class($this)."::validate statut of member does not allow this", LOG_WARNING); + if ($this->statut == 1) { + dol_syslog(get_class($this) . "::validate statut of member does not allow this", LOG_WARNING); return 0; } $this->db->begin(); - $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET"; + $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 .= ", datevalid = '" . $this->db->idate($now) . "'"; + $sql .= ", fk_user_valid=" . $user->id; + $sql .= " WHERE rowid = " . $this->id; - dol_syslog(get_class($this)."::validate", LOG_DEBUG); + dol_syslog(get_class($this) . "::validate", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { + if ($result) { $this->statut = 1; // Call trigger $result = $this->call_trigger('MEMBER_VALIDATE', $user); - if ($result < 0) { $error++; $this->db->rollback(); return -1; } + if ($result < 0) { + $error++; + $this->db->rollback(); + return -1; + } // End call triggers $this->datevalid = $now; $this->db->commit(); return 1; - } - else - { + } else { $this->error = $this->db->error(); $this->db->rollback(); return -1; @@ -1939,34 +1801,34 @@ class Adherent extends CommonObject $error = 0; // Check parameters - if ($this->statut == 0) - { - dol_syslog(get_class($this)."::resiliate statut of member does not allow this", LOG_WARNING); + if ($this->statut == 0) { + dol_syslog(get_class($this) . "::resiliate statut of member does not allow this", LOG_WARNING); return 0; } $this->db->begin(); - $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET"; + $sql = "UPDATE " . MAIN_DB_PREFIX . "adherent SET"; $sql .= " statut = 0"; - $sql .= ", fk_user_valid=".$user->id; - $sql .= " WHERE rowid = ".$this->id; + $sql .= ", fk_user_valid=" . $user->id; + $sql .= " WHERE rowid = " . $this->id; $result = $this->db->query($sql); - if ($result) - { + if ($result) { $this->statut = 0; // Call trigger $result = $this->call_trigger('MEMBER_RESILIATE', $user); - if ($result < 0) { $error++; $this->db->rollback(); return -1; } + if ($result < 0) { + $error++; + $this->db->rollback(); + return -1; + } // End call triggers $this->db->commit(); return 1; - } - else - { + } else { $this->error = $this->db->error(); $this->db->rollback(); return -1; @@ -1974,7 +1836,7 @@ class Adherent extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to add member into external tools mailing-list, spip, etc. * @@ -1982,58 +1844,49 @@ class Adherent extends CommonObject */ public function add_to_abo() { - // phpcs:enable + // phpcs:enable global $conf, $langs; - include_once DOL_DOCUMENT_ROOT.'/mailmanspip/class/mailmanspip.class.php'; + include_once DOL_DOCUMENT_ROOT . '/mailmanspip/class/mailmanspip.class.php'; $mailmanspip = new MailmanSpip($this->db); $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); - if ($result < 0) - { + if ($result < 0) { if (!empty($mailmanspip->error)) $this->errors[] = $mailmanspip->error; $err += 1; } - foreach ($mailmanspip->mladded_ko as $tmplist => $tmpemail) - { + foreach ($mailmanspip->mladded_ko as $tmplist => $tmpemail) { $langs->load("errors"); $this->errors[] = $langs->trans("ErrorFailedToAddToMailmanList", $tmpemail, $tmplist); } - foreach ($mailmanspip->mladded_ok as $tmplist => $tmpemail) - { + foreach ($mailmanspip->mladded_ok as $tmplist => $tmpemail) { $langs->load("mailmanspip"); $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); - if ($result < 0) - { + if ($result < 0) { $this->errors[] = $mailmanspip->error; $err += 1; } } - if ($err) - { + if ($err) { return -$err; - } - else - { + } else { return 1; } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to delete a member from external tools like mailing-list, spip, etc. * @@ -2041,52 +1894,43 @@ class Adherent extends CommonObject */ public function del_to_abo() { - // phpcs:enable + // phpcs:enable global $conf, $langs; - include_once DOL_DOCUMENT_ROOT.'/mailmanspip/class/mailmanspip.class.php'; + include_once DOL_DOCUMENT_ROOT . '/mailmanspip/class/mailmanspip.class.php'; $mailmanspip = new MailmanSpip($this->db); $err = 0; // mailman - if (!empty($conf->global->ADHERENT_USE_MAILMAN)) - { + if (!empty($conf->global->ADHERENT_USE_MAILMAN)) { $result = $mailmanspip->del_to_mailman($this); - if ($result < 0) - { + if ($result < 0) { if (!empty($mailmanspip->error)) $this->errors[] = $mailmanspip->error; $err += 1; } - foreach ($mailmanspip->mlremoved_ko as $tmplist => $tmpemail) - { + foreach ($mailmanspip->mlremoved_ko as $tmplist => $tmpemail) { $langs->load("errors"); $this->errors[] = $langs->trans("ErrorFailedToRemoveToMailmanList", $tmpemail, $tmplist); } - foreach ($mailmanspip->mlremoved_ok as $tmplist => $tmpemail) - { + foreach ($mailmanspip->mlremoved_ok as $tmplist => $tmpemail) { $langs->load("mailmanspip"); $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); - if ($result < 0) - { + if ($result < 0) { $this->errors[] = $mailmanspip->error; $err += 1; } } - if ($err) - { + if ($err) { // error return -$err; - } - else - { + } else { return 1; } } @@ -2104,7 +1948,7 @@ class Adherent extends CommonObject $code = (empty($this->civility_id) ? '' : $this->civility_id); if (empty($code)) return ''; - return $langs->getLabelFromKey($this->db, "Civility".$code, "c_civility", "code", "label", $code); + return $langs->getLabelFromKey($this->db, "Civility" . $code, "c_civility", "code", "label", $code); } /** @@ -2125,79 +1969,77 @@ class Adherent extends CommonObject 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 .= '
'; $label .= Form::showphoto('memberphoto', $this, 80, 0, 0, 'photowithmargin photologintooltip', 'small', 0, 1); $label .= '
'; } $label .= '
'; - $label .= ''.$langs->trans("Member").''; - if (!empty($this->ref)) - $label .= '
'.$langs->trans('Ref').': '.$this->ref; - if (!empty($this->firstname) || !empty($this->lastname)) - $label .= '
'.$langs->trans('Name').': '.$this->getFullName($langs); - if (!empty($this->company)) - $label .= '
'.$langs->trans('Company').': '.$this->company; + $label .= '' . $langs->trans("Member") . ''; + if (!empty($this->ref)) $label .= '
' . $langs->trans('Ref') . ': ' . $this->ref; + if (!empty($this->firstname) || !empty($this->lastname)) $label .= '
' . $langs->trans('Name') . ': ' . $this->getFullName($langs); + if (!empty($this->company)) $label .= '
' . $langs->trans('Company') . ': ' . $this->company; $label .= '
'; - $url = DOL_URL_ROOT.'/adherents/card.php?rowid='.$this->id; - if ($option == 'subscription') - { - $url = DOL_URL_ROOT.'/adherents/subscription.php?rowid='.$this->id; + $url = DOL_URL_ROOT . '/adherents/card.php?rowid=' . $this->id; + if ($option == 'subscription') { + $url = DOL_URL_ROOT . '/adherents/subscription.php?rowid=' . $this->id; } - if ($option != 'nolink') - { + if ($option != 'nolink') { // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; } - $linkstart .= 'global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { + if (empty($notooltip)) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $langs->load("users"); $label = $langs->trans("ShowUser"); - $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' alt="' . dol_escape_htmltag($label, 1) . '"'; } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + $linkclose .= ' title="' . dol_escape_htmltag($label, 1) . '"'; + $linkclose .= ' class="classfortooltip' . ($morecss ? ' ' . $morecss : '') . '"'; } - $linkstart .= $linkclose.'>'; + $linkstart .= $linkclose . '>'; $linkend = ''; $result .= $linkstart; if ($withpictoimg) $result .= '
'; - if ($withpictoimg) - { + if ($withpictoimg) { $paddafterimage = ''; if (abs($withpictoimg) == 1) $paddafterimage = 'style="margin-right: 3px;"'; // Only picto - if ($withpictoimg > 0) $picto = ''.img_object('', 'user', $paddafterimage.' '.($notooltip ? '' : 'class="classfortooltip"'), 0, 0, $notooltip ? 0 : 1).''; + if ($withpictoimg > 0) + $picto = '' . + img_object('', 'user', $paddafterimage . ' ' . ($notooltip ? '' : 'class="classfortooltip"'), 0, 0, $notooltip ? 0 : 1) . ''; // Picto must be a photo else { - $picto = ''; - $picto .= Form::showphoto('memberphoto', $this, 0, 0, 0, 'userphoto'.($withpictoimg == -3 ? 'small' : ''), 'mini', 0, 1); + $picto = ''; + $picto .= Form::showphoto('memberphoto', $this, 0, 0, 0, 'userphoto' . ($withpictoimg == -3 ? 'small' : ''), 'mini', 0, 1); $picto .= ''; } $result .= $picto; } - if ($withpictoimg > -2 && $withpictoimg != 2) - { - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $result .= ''; - if ($mode == 'login') $result .= dol_trunc($this->login, $maxlen); - elseif ($mode == 'ref') $result .= $this->id; - else $result .= $this->getFullName($langs, '', ($mode == 'firstname' ? 2 : -1), $maxlen); + if ($withpictoimg > -2 && $withpictoimg != 2) { + if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $result .= ''; + if ($mode == 'login') + $result .= dol_trunc($this->login, $maxlen); + elseif ($mode == 'ref') + $result .= $this->id; + else + $result .= $this->getFullName($langs, '', ($mode == 'firstname' ? 2 : -1), $maxlen); if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $result .= ''; } if ($withpictoimg) $result .= '
'; @@ -2217,7 +2059,7 @@ class Adherent extends CommonObject return $this->LibStatut($this->statut, $this->need_subscription, $this->datefin, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -2229,47 +2071,37 @@ class Adherent extends CommonObject */ public function LibStatut($status, $need_subscription, $date_end_subscription, $mode = 0) { - // phpcs:enable + // phpcs:enable global $langs; $langs->load("members"); - $statusType = ''; - $labelStatus = ''; - $labelStatusShort = ''; + $statusType = ''; + $labelStatus = ''; + $labelStatusShort = ''; - if ($status == -1) - { + if ($status == -1) { $statusType = 'status0'; $labelStatus = $langs->trans("MemberStatusDraft"); $labelStatusShort = $langs->trans("MemberStatusDraftShort"); - } - elseif ($status >= 1) { - if ($need_subscription == 0) - { + } elseif ($status >= 1) { + if ($need_subscription == 0) { $statusType = 'status4'; $labelStatus = $langs->trans("MemberStatusNoSubscription"); $labelStatusShort = $langs->trans("MemberStatusNoSubscriptionShort"); - } - elseif (!$date_end_subscription) - { + } elseif (!$date_end_subscription) { $statusType = 'status1'; $labelStatus = $langs->trans("MemberStatusActive"); $labelStatusShort = $langs->trans("MemberStatusActiveShort"); - } - elseif ($date_end_subscription < time()) - { + } elseif ($date_end_subscription < time()) { $statusType = 'status3'; $labelStatus = $langs->trans("MemberStatusActiveLate"); $labelStatusShort = $langs->trans("MemberStatusActiveLateShort"); - } - else { + } else { $statusType = 'status4'; $labelStatus = $langs->trans("MemberStatusPaid"); $labelStatusShort = $langs->trans("MemberStatusPaidShort"); } - } - elseif ($status == 0) - { + } elseif ($status == 0) { $statusType = 'status6'; $labelStatus = $langs->trans("MemberStatusResiliated"); $labelStatusShort = $langs->trans("MemberStatusResiliatedShort"); @@ -2279,7 +2111,7 @@ class Adherent extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge indicateurs this->nb de tableau de bord * @@ -2287,35 +2119,31 @@ class Adherent extends CommonObject */ public function load_state_board() { - // phpcs:enable + // phpcs:enable global $conf; $this->nb = array(); $sql = "SELECT count(a.rowid) as nb"; - $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a"; + $sql .= " FROM " . MAIN_DB_PREFIX . "adherent as a"; $sql .= " WHERE a.statut > 0"; - $sql .= " AND a.entity IN (".getEntity('adherent').")"; + $sql .= " AND a.entity IN (" . getEntity('adherent') . ")"; $resql = $this->db->query($sql); - if ($resql) - { - while ($obj = $this->db->fetch_object($resql)) - { + if ($resql) { + while ($obj = $this->db->fetch_object($resql)) { $this->nb["members"] = $obj->nb; } $this->db->free($resql); return 1; - } - else - { + } else { dol_print_error($this->db); $this->error = $this->db->error(); return -1; } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * @@ -2325,32 +2153,28 @@ class Adherent extends CommonObject */ public function load_board($user, $mode) { - // phpcs:enable + // phpcs:enable global $conf, $langs; - if ($user->socid) return -1; // protection pour eviter appel par utilisateur externe + if ($user->socid) return -1; // protection pour eviter appel par utilisateur externe - $now=dol_now(); + $now = dol_now(); $sql = "SELECT a.rowid, a.datefin, a.statut"; - $sql.= " FROM ".MAIN_DB_PREFIX."adherent as a"; - $sql.= ", ".MAIN_DB_PREFIX."adherent_type as t"; - $sql.= " WHERE a.fk_adherent_type = t.rowid"; - if ($mode == 'expired') - { - $sql.= " AND a.statut = 1"; - $sql.= " AND a.entity IN (".getEntity('adherent').")"; - $sql.= " AND ((a.datefin IS NULL or a.datefin < '".$this->db->idate($now)."') AND t.subscription = 1)"; - } - elseif ($mode == 'shift') - { - $sql.= " AND a.statut = -1"; - $sql.= " AND a.entity IN (".getEntity('adherent').")"; + $sql .= " FROM " . MAIN_DB_PREFIX . "adherent as a"; + $sql .= ", " . MAIN_DB_PREFIX . "adherent_type as t"; + $sql .= " WHERE a.fk_adherent_type = t.rowid"; + if ($mode == 'expired') { + $sql .= " AND a.statut = 1"; + $sql .= " AND a.entity IN (" . getEntity('adherent') . ")"; + $sql .= " AND ((a.datefin IS NULL or a.datefin < '" . $this->db->idate($now) . "') AND t.subscription = 1)"; + } elseif ($mode == 'shift') { + $sql .= " AND a.statut = -1"; + $sql .= " AND a.entity IN (" . getEntity('adherent') . ")"; } - $resql=$this->db->query($sql); - if ($resql) - { + $resql = $this->db->query($sql); + if ($resql) { $langs->load("members"); $warning_delay = 0; @@ -2359,29 +2183,27 @@ class Adherent extends CommonObject $labelShort = ''; if ($mode == 'expired') { - $warning_delay = $conf->adherent->subscription->warning_delay/60/60/24; + $warning_delay = $conf->adherent->subscription->warning_delay / 60 / 60 / 24; $label = $langs->trans("MembersWithSubscriptionToReceive"); $labelShort = $langs->trans("MembersWithSubscriptionToReceiveShort"); - $url = DOL_URL_ROOT.'/adherents/list.php?mainmenu=members&statut=1&filter=outofdate'; - } - elseif ($mode == 'shift') { - $warning_delay = $conf->adherent->subscription->warning_delay/60/60/24; - $url = DOL_URL_ROOT.'/adherents/list.php?mainmenu=members&statut=-1'; - $label = $langs->trans("MembersListToValid"); - $labelShort = $langs->trans("ToValidate"); + $url = DOL_URL_ROOT . '/adherents/list.php?mainmenu=members&statut=1&filter=outofdate'; + } elseif ($mode == 'shift') { + $warning_delay = $conf->adherent->subscription->warning_delay / 60 / 60 / 24; + $url = DOL_URL_ROOT . '/adherents/list.php?mainmenu=members&statut=-1'; + $label = $langs->trans("MembersListToValid"); + $labelShort = $langs->trans("ToValidate"); } $response = new WorkboardResponse(); - $response->warning_delay=$warning_delay; - $response->label=$label; - $response->labelShort=$labelShort; - $response->url=$url; - $response->img=img_object('', "user"); + $response->warning_delay = $warning_delay; + $response->label = $label; + $response->labelShort = $labelShort; + $response->url = $url; + $response->img = img_object('', "user"); $adherentstatic = new Adherent($this->db); - while ($obj=$this->db->fetch_object($resql)) - { + while ($obj = $this->db->fetch_object($resql)) { $response->nbtodo++; $adherentstatic->datefin = $this->db->jdate($obj->datefin); @@ -2393,9 +2215,7 @@ class Adherent extends CommonObject } return $response; - } - else - { + } else { dol_print_error($this->db); $this->error = $this->db->error(); return -1; @@ -2411,7 +2231,7 @@ class Adherent extends CommonObject * @param int $hidedetails Hide details of lines * @param int $hidedesc Hide description * @param int $hideref Hide ref - * @param null|array $moreparams Array to provide more information + * @param null|array $moreparams Array to provide more information * @return int 0 if KO, 1 if OK */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) @@ -2465,14 +2285,9 @@ class Adherent extends CommonObject $this->country = 'France'; $this->morphy = 'mor'; $this->email = 'specimen@specimen.com'; - $this->socialnetworks = array( - 'skype' => 'skypepseudo', - 'twitter' => 'twitterpseudo', - 'facebook' => 'facebookpseudo', - 'linkedin' => 'linkedinpseudo', - ); - $this->phone = '0999999999'; - $this->phone_perso = '0999999998'; + $this->socialnetworks = array('skype' => 'skypepseudo', 'twitter' => 'twitterpseudo', 'facebook' => 'facebookpseudo', 'linkedin' => 'linkedinpseudo'); + $this->phone = '0999999999'; + $this->phone_perso = '0999999998'; $this->phone_mobile = '0999999997'; $this->note_private = 'No comment'; $this->birth = time(); @@ -2499,8 +2314,8 @@ class Adherent extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Retourne chaine DN complete dans l'annuaire LDAP pour l'objet * @@ -2512,26 +2327,26 @@ class Adherent extends CommonObject */ public function _load_ldap_dn($info, $mode = 0) { - // phpcs:enable + // phpcs:enable global $conf; $dn = ''; - if ($mode == 0) $dn = $conf->global->LDAP_KEY_MEMBERS."=".$info[$conf->global->LDAP_KEY_MEMBERS].",".$conf->global->LDAP_MEMBER_DN; + if ($mode == 0) $dn = $conf->global->LDAP_KEY_MEMBERS . "=" . $info[$conf->global->LDAP_KEY_MEMBERS] . "," . $conf->global->LDAP_MEMBER_DN; if ($mode == 1) $dn = $conf->global->LDAP_MEMBER_DN; - if ($mode == 2) $dn = $conf->global->LDAP_KEY_MEMBERS."=".$info[$conf->global->LDAP_KEY_MEMBERS]; + if ($mode == 2) $dn = $conf->global->LDAP_KEY_MEMBERS . "=" . $info[$conf->global->LDAP_KEY_MEMBERS]; return $dn; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore - /** + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + /** * Initialise tableau info (tableau des attributs LDAP) * * @return array Tableau info des attributs */ public function _load_ldap_info() { - // phpcs:enable + // phpcs:enable global $conf, $langs; $info = array(); @@ -2549,83 +2364,69 @@ class Adherent extends CommonObject } // Possible LDAP KEY (constname => varname) - $ldapkey = array( - 'LDAP_MEMBER_FIELD_FULLNAME' => 'fullname', - 'LDAP_MEMBER_FIELD_NAME' => 'lastname', - 'LDAP_MEMBER_FIELD_LOGIN' => 'login', - 'LDAP_MEMBER_FIELD_LOGIN_SAMBA' => 'login', - 'LDAP_MEMBER_FIELD_MAIL' => 'email' - ); + $ldapkey = array('LDAP_MEMBER_FIELD_FULLNAME' => 'fullname', 'LDAP_MEMBER_FIELD_NAME' => 'lastname', 'LDAP_MEMBER_FIELD_LOGIN' => 'login', 'LDAP_MEMBER_FIELD_LOGIN_SAMBA' => 'login', + 'LDAP_MEMBER_FIELD_MAIL' => 'email'); // Member - foreach ($ldapkey as $constname => $varname) - { - if (!empty($this->$varname) && !empty($conf->global->$constname)) - { + foreach ($ldapkey as $constname => $varname) { + if (!empty($this->$varname) && !empty($conf->global->$constname)) { $info[$conf->global->$constname] = $this->$varname; // Check if it is the LDAP key and if its value has been changed - if (!empty($conf->global->LDAP_KEY_MEMBERS) && $conf->global->LDAP_KEY_MEMBERS == $conf->global->$constname) - { + if (!empty($conf->global->LDAP_KEY_MEMBERS) && $conf->global->LDAP_KEY_MEMBERS == $conf->global->$constname) { if (!empty($this->oldcopy) && $this->$varname != $this->oldcopy->$varname) $keymodified = true; // For check if LDAP key has been modified } } } - if ($this->firstname && !empty($conf->global->LDAP_MEMBER_FIELD_FIRSTNAME)) $info[$conf->global->LDAP_MEMBER_FIELD_FIRSTNAME] = $this->firstname; - if ($this->poste && !empty($conf->global->LDAP_MEMBER_FIELD_TITLE)) $info[$conf->global->LDAP_MEMBER_FIELD_TITLE] = $this->poste; - if ($this->company && !empty($conf->global->LDAP_MEMBER_FIELD_COMPANY)) $info[$conf->global->LDAP_MEMBER_FIELD_COMPANY] = $this->company; - if ($this->address && !empty($conf->global->LDAP_MEMBER_FIELD_ADDRESS)) $info[$conf->global->LDAP_MEMBER_FIELD_ADDRESS] = $this->address; - if ($this->zip && !empty($conf->global->LDAP_MEMBER_FIELD_ZIP)) $info[$conf->global->LDAP_MEMBER_FIELD_ZIP] = $this->zip; - if ($this->town && !empty($conf->global->LDAP_MEMBER_FIELD_TOWN)) $info[$conf->global->LDAP_MEMBER_FIELD_TOWN] = $this->town; - if ($this->country_code && !empty($conf->global->LDAP_MEMBER_FIELD_COUNTRY)) $info[$conf->global->LDAP_MEMBER_FIELD_COUNTRY] = $this->country_code; - if ($this->skype && !empty($conf->global->LDAP_MEMBER_FIELD_SKYPE)) $info[$conf->global->LDAP_MEMBER_FIELD_SKYPE] = $this->skype; - if ($this->twitter && !empty($conf->global->LDAP_MEMBER_FIELD_TWITTER)) $info[$conf->global->LDAP_MEMBER_FIELD_TWITTER] = $this->twitter; - if ($this->facebook && !empty($conf->global->LDAP_MEMBER_FIELD_FACEBOOK)) $info[$conf->global->LDAP_MEMBER_FIELD_FACEBOOK] = $this->facebook; - if ($this->linkedin && !empty($conf->global->LDAP_MEMBER_FIELD_LINKEDIN)) $info[$conf->global->LDAP_MEMBER_FIELD_LINKEDIN] = $this->linkedin; - if ($this->phone && !empty($conf->global->LDAP_MEMBER_FIELD_PHONE)) $info[$conf->global->LDAP_MEMBER_FIELD_PHONE] = $this->phone; - if ($this->phone_perso && !empty($conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO)) $info[$conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO] = $this->phone_perso; - if ($this->phone_mobile && !empty($conf->global->LDAP_MEMBER_FIELD_MOBILE)) $info[$conf->global->LDAP_MEMBER_FIELD_MOBILE] = $this->phone_mobile; - if ($this->fax && !empty($conf->global->LDAP_MEMBER_FIELD_FAX)) $info[$conf->global->LDAP_MEMBER_FIELD_FAX] = $this->fax; - if ($this->note_private && !empty($conf->global->LDAP_MEMBER_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_MEMBER_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note_private, 2); - if ($this->note_public && !empty($conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC)) $info[$conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC] = dol_string_nohtmltag($this->note_public, 2); - if ($this->birth && !empty($conf->global->LDAP_MEMBER_FIELD_BIRTHDATE)) $info[$conf->global->LDAP_MEMBER_FIELD_BIRTHDATE] = dol_print_date($this->birth, 'dayhourldap'); - if (isset($this->statut) && !empty($conf->global->LDAP_FIELD_MEMBER_STATUS)) $info[$conf->global->LDAP_FIELD_MEMBER_STATUS] = $this->statut; - if ($this->datefin && !empty($conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION)) $info[$conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION] = dol_print_date($this->datefin, 'dayhourldap'); + if ($this->firstname && !empty($conf->global->LDAP_MEMBER_FIELD_FIRSTNAME)) $info[$conf->global->LDAP_MEMBER_FIELD_FIRSTNAME] = $this->firstname; + if ($this->poste && !empty($conf->global->LDAP_MEMBER_FIELD_TITLE)) $info[$conf->global->LDAP_MEMBER_FIELD_TITLE] = $this->poste; + if ($this->company && !empty($conf->global->LDAP_MEMBER_FIELD_COMPANY)) $info[$conf->global->LDAP_MEMBER_FIELD_COMPANY] = $this->company; + if ($this->address && !empty($conf->global->LDAP_MEMBER_FIELD_ADDRESS)) $info[$conf->global->LDAP_MEMBER_FIELD_ADDRESS] = $this->address; + if ($this->zip && !empty($conf->global->LDAP_MEMBER_FIELD_ZIP)) $info[$conf->global->LDAP_MEMBER_FIELD_ZIP] = $this->zip; + if ($this->town && !empty($conf->global->LDAP_MEMBER_FIELD_TOWN)) $info[$conf->global->LDAP_MEMBER_FIELD_TOWN] = $this->town; + if ($this->country_code && !empty($conf->global->LDAP_MEMBER_FIELD_COUNTRY)) $info[$conf->global->LDAP_MEMBER_FIELD_COUNTRY] = $this->country_code; + if ($this->skype && !empty($conf->global->LDAP_MEMBER_FIELD_SKYPE)) $info[$conf->global->LDAP_MEMBER_FIELD_SKYPE] = $this->skype; + if ($this->twitter && !empty($conf->global->LDAP_MEMBER_FIELD_TWITTER)) $info[$conf->global->LDAP_MEMBER_FIELD_TWITTER] = $this->twitter; + if ($this->facebook && !empty($conf->global->LDAP_MEMBER_FIELD_FACEBOOK)) $info[$conf->global->LDAP_MEMBER_FIELD_FACEBOOK] = $this->facebook; + if ($this->linkedin && !empty($conf->global->LDAP_MEMBER_FIELD_LINKEDIN)) $info[$conf->global->LDAP_MEMBER_FIELD_LINKEDIN] = $this->linkedin; + if ($this->phone && !empty($conf->global->LDAP_MEMBER_FIELD_PHONE)) $info[$conf->global->LDAP_MEMBER_FIELD_PHONE] = $this->phone; + if ($this->phone_perso && !empty($conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO)) $info[$conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO] = $this->phone_perso; + if ($this->phone_mobile && !empty($conf->global->LDAP_MEMBER_FIELD_MOBILE)) $info[$conf->global->LDAP_MEMBER_FIELD_MOBILE] = $this->phone_mobile; + if ($this->fax && !empty($conf->global->LDAP_MEMBER_FIELD_FAX)) $info[$conf->global->LDAP_MEMBER_FIELD_FAX] = $this->fax; + if ($this->note_private && !empty($conf->global->LDAP_MEMBER_FIELD_DESCRIPTION)) $info[$conf->global->LDAP_MEMBER_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note_private, 2); + if ($this->note_public && !empty($conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC)) $info[$conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC] = dol_string_nohtmltag($this->note_public, 2); + if ($this->birth && !empty($conf->global->LDAP_MEMBER_FIELD_BIRTHDATE)) $info[$conf->global->LDAP_MEMBER_FIELD_BIRTHDATE] = dol_print_date($this->birth, 'dayhourldap'); + if (isset($this->statut) && !empty($conf->global->LDAP_FIELD_MEMBER_STATUS)) $info[$conf->global->LDAP_FIELD_MEMBER_STATUS] = $this->statut; + if ($this->datefin && !empty($conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION)) $info[$conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION] = dol_print_date($this->datefin, 'dayhourldap'); // When password is modified - if (!empty($this->pass)) - { - if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD)) $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD] = $this->pass; // this->pass = mot de passe non crypte - if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] = dol_hash($this->pass, 4); // Create OpenLDAP MD5 password (TODO add type of encryption) - } - // Set LDAP password if possible + if (!empty($this->pass)) { + if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD)) $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD] = $this->pass; // this->pass = mot de passe non crypte + if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] = dol_hash($this->pass, 4); // Create OpenLDAP MD5 password (TODO add type of encryption) + } // Set LDAP password if possible elseif ($conf->global->LDAP_SERVER_PROTOCOLVERSION !== '3') // If ldap key is modified and LDAPv3 we use ldap_rename function for avoid lose encrypt password { - if (!empty($conf->global->DATABASE_PWD_ENCRYPTED)) - { + if (!empty($conf->global->DATABASE_PWD_ENCRYPTED)) { // Just for the default MD5 ! - if (empty($conf->global->MAIN_SECURITY_HASH_ALGO)) - { + if (empty($conf->global->MAIN_SECURITY_HASH_ALGO)) { if ($this->pass_indatabase_crypted && !empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) { // Create OpenLDAP MD5 password from Dolibarr MD5 password // Note: This suppose that "pass_indatabase_crypted" is a md5 (guaranted by the previous test if "(empty($conf->global->MAIN_SECURITY_HASH_ALGO))" - $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] = '{md5}'.base64_encode(hex2bin($this->pass_indatabase_crypted)); + $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] = '{md5}' . base64_encode(hex2bin($this->pass_indatabase_crypted)); } } - } - // Use $this->pass_indatabase value if exists - elseif (!empty($this->pass_indatabase)) - { - if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD)) $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD] = $this->pass_indatabase; // $this->pass_indatabase = mot de passe non crypte - if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] = dol_hash($this->pass_indatabase, 4); // md5 for OpenLdap TODO add type of encryption + } // Use $this->pass_indatabase value if exists + elseif (!empty($this->pass_indatabase)) { + if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD)) $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD] = $this->pass_indatabase; // $this->pass_indatabase = mot de passe non crypte + if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] = dol_hash($this->pass_indatabase, 4); // md5 for OpenLdap TODO add type of encryption } } // Subscriptions - if ($this->first_subscription_date && !empty($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE)) $info[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE] = dol_print_date($this->first_subscription_date, 'dayhourldap'); + if ($this->first_subscription_date && !empty($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE)) $info[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE] = dol_print_date($this->first_subscription_date, 'dayhourldap'); if (isset($this->first_subscription_amount) && !empty($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT)) $info[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT] = $this->first_subscription_amount; - if ($this->last_subscription_date && !empty($conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE)) $info[$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE] = dol_print_date($this->last_subscription_date, 'dayhourldap'); - if (isset($this->last_subscription_amount) && !empty($conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT)) $info[$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT] = $this->last_subscription_amount; + if ($this->last_subscription_date && !empty($conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE)) $info[$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE] = dol_print_date($this->last_subscription_date, 'dayhourldap'); + if (isset($this->last_subscription_amount) && !empty($conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT)) $info[$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT] = $this->last_subscription_amount; return $info; } @@ -2643,47 +2444,40 @@ class Adherent extends CommonObject $sql .= ' a.datevalid as datev,'; $sql .= ' a.tms as datem,'; $sql .= ' a.fk_user_author, a.fk_user_valid, a.fk_user_mod'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'adherent as a'; - $sql .= ' WHERE a.rowid = '.$id; + $sql .= ' FROM ' . MAIN_DB_PREFIX . 'adherent as a'; + $sql .= ' WHERE a.rowid = ' . $id; - dol_syslog(get_class($this)."::info", LOG_DEBUG); + dol_syslog(get_class($this) . "::info", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { + if ($result) { + if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; - if ($obj->fk_user_author) - { + if ($obj->fk_user_author) { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); $this->user_creation = $cuser; } - if ($obj->fk_user_valid) - { + if ($obj->fk_user_valid) { $vuser = new User($this->db); $vuser->fetch($obj->fk_user_valid); $this->user_validation = $vuser; } - if ($obj->fk_user_mod) - { + if ($obj->fk_user_mod) { $muser = new User($this->db); $muser->fetch($obj->fk_user_mod); $this->user_modification = $muser; } - $this->date_creation = $this->db->jdate($obj->datec); - $this->date_validation = $this->db->jdate($obj->datev); + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_validation = $this->db->jdate($obj->datev); $this->date_modification = $this->db->jdate($obj->datem); } $this->db->free($result); - } - else - { + } else { dol_print_error($this->db); } } @@ -2696,21 +2490,18 @@ class Adherent extends CommonObject public function getNbOfEMailings() { $sql = "SELECT count(mc.email) as nb"; - $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; - $sql .= " WHERE mc.email = '".$this->db->escape($this->email)."'"; + $sql .= " FROM " . MAIN_DB_PREFIX . "mailing_cibles as mc"; + $sql .= " WHERE mc.email = '" . $this->db->escape($this->email) . "'"; $sql .= " AND mc.statut NOT IN (-1,0)"; // -1 erreur, 0 non envoye, 1 envoye avec succes $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $obj = $this->db->fetch_object($resql); $nb = $obj->nb; $this->db->free($resql); return $nb; - } - else - { + } else { $this->error = $this->db->error(); return -1; } @@ -2724,7 +2515,7 @@ class Adherent extends CommonObject * Existing categories are left untouch. * * @param int[]|int $categories Category or categories IDs - * @return void + * @return void */ public function setCategories($categories) { @@ -2734,7 +2525,7 @@ class Adherent extends CommonObject } // Get current categories - require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; $c = new Categorie($this->db); $existing = $c->containing($this->id, Categorie::TYPE_MEMBER, 'id'); @@ -2772,9 +2563,7 @@ class Adherent extends CommonObject */ public static function replaceThirdparty($db, $origin_id, $dest_id) { - $tables = array( - 'adherent' - ); + $tables = array('adherent'); return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); } @@ -2798,7 +2587,6 @@ class Adherent extends CommonObject } - /** * Send reminders by emails before subscription end * CAN BE A CRON TASK @@ -2816,14 +2604,13 @@ class Adherent extends CommonObject $blockingerrormsg = ''; - if (empty($conf->adherent->enabled)) // Should not happen. If module disabled, cron job should not be visible. + if (empty($conf->adherent->enabled)) // Should not happen. If module disabled, cron job should not be visible. { $langs->load("agenda"); $this->output = $langs->trans('ModuleNotEnabled', $langs->transnoentitiesnoconv("Adherent")); return 0; } - if (empty($conf->global->MEMBER_REMINDER_EMAIL)) - { + if (empty($conf->global->MEMBER_REMINDER_EMAIL)) { $langs->load("agenda"); $this->output = $langs->trans('EventRemindersByEmailNotEnabled', $langs->transnoentitiesnoconv("Adherent")); return 0; @@ -2837,12 +2624,11 @@ class Adherent extends CommonObject $listofmembersko = array(); $arraydaysbeforeend = explode(';', $daysbeforeendlist); - foreach ($arraydaysbeforeend as $daysbeforeend) // Loop on each delay + foreach ($arraydaysbeforeend as $daysbeforeend) // Loop on each delay { - dol_syslog(__METHOD__.' - Process delta = '.$daysbeforeend, LOG_DEBUG); + dol_syslog(__METHOD__ . ' - Process delta = ' . $daysbeforeend, LOG_DEBUG); - if (!is_numeric($daysbeforeend)) - { + if (!is_numeric($daysbeforeend)) { $blockingerrormsg = "Value for delta is not a positive or negative numeric"; $nbko++; break; @@ -2851,33 +2637,28 @@ class Adherent extends CommonObject $tmp = dol_getdate($now); $datetosearchfor = dol_time_plus_duree(dol_mktime(0, 0, 0, $tmp['mon'], $tmp['mday'], $tmp['year']), $daysbeforeend, 'd'); - $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'adherent'; - $sql .= " WHERE entity = ".$conf->entity; // Do not use getEntity('adherent').")" here, we want the batch to be on its entity only; - $sql .= " AND datefin = '".$this->db->idate($datetosearchfor)."'"; + $sql = 'SELECT rowid FROM ' . MAIN_DB_PREFIX . 'adherent'; + $sql .= " WHERE entity = " . $conf->entity; // Do not use getEntity('adherent').")" here, we want the batch to be on its entity only; + $sql .= " AND datefin = '" . $this->db->idate($datetosearchfor) . "'"; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num_rows = $this->db->num_rows($resql); - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; $adherent = new Adherent($this->db); $formmail = new FormMail($this->db); $i = 0; - while ($i < $num_rows) - { + while ($i < $num_rows) { $obj = $this->db->fetch_object($resql); $adherent->fetch($obj->rowid, '', '', '', true, true); - if (empty($adherent->email)) - { + if (empty($adherent->email)) { $nbko++; $listofmembersko[$adherent->id] = $adherent->id; - } - else - { + } else { $adherent->fetch_thirdparty(); // Language code to use ($languagecodeformember) is default language of thirdparty, if no thirdparty, the language found from country of member then country of thirdparty, and if still not found we use the language of company. @@ -2888,32 +2669,30 @@ class Adherent extends CommonObject $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang($languagecodeformember); $outputlangs->loadLangs(array("main", "members")); - dol_syslog("sendReminderForExpiredSubscription Language for member id ".$adherent->id." set to ".$outputlangs->defaultlang." mysoc->default_lang=".$mysoc->default_lang); + dol_syslog("sendReminderForExpiredSubscription Language for member id " . $adherent->id . " set to " . $outputlangs->defaultlang . " mysoc->default_lang=" . $mysoc->default_lang); $arraydefaultmessage = null; $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION; if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($this->db, 'member', $user, $outputlangs, 0, 1, $labeltouse); - if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) - { + if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $adherent); //if (is_array($adherent->thirdparty)) $substitutionarraycomp = ... complete_substitutions_array($substitutionarray, $outputlangs, $adherent); $subject = make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs); - $msg = make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs); + $msg = make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs); $from = $conf->global->ADHERENT_MAIL_FROM; $to = $adherent->email; - $trackid = 'mem'.$adherent->id; - $moreinheader = 'X-Dolibarr-Info: sendReminderForExpiredSubscription'."\r\n"; + $trackid = 'mem' . $adherent->id; + $moreinheader = 'X-Dolibarr-Info: sendReminderForExpiredSubscription' . "\r\n"; - include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + include_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php'; $cmail = new CMailFile($subject, $to, $from, $msg, array(), array(), array(), '', '', 0, 1, '', '', $trackid, $moreinheader); $result = $cmail->sendfile(); - if (!$result) - { + if (!$result) { $error++; $this->error = $cmail->error; if (!is_null($cmail->errors)) { @@ -2921,9 +2700,7 @@ class Adherent extends CommonObject } $nbko++; $listofmembersko[$adherent->id] = $adherent->id; - } - else - { + } else { $nbok++; $listofmembersok[$adherent->id] = $adherent->id; @@ -2935,54 +2712,52 @@ class Adherent extends CommonObject $extraparams = ''; $actionmsg = ''; - $actionmsg2 = $langs->transnoentities('MailSentBy').' '.CMailFile::getValidAddress($from, 4, 0, 1).' '.$langs->transnoentities('To').' '.CMailFile::getValidAddress($sendto, 4, 0, 1); - if ($message) - { - $actionmsg = $langs->transnoentities('MailFrom').': '.dol_escape_htmltag($from); - $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTo').': '.dol_escape_htmltag($sendto)); - if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".dol_escape_htmltag($sendtocc)); - $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subject); - $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody').":"); + $actionmsg2 = $langs->transnoentities('MailSentBy') . ' ' . CMailFile::getValidAddress($from, 4, 0, 1) . ' ' . $langs->transnoentities('To') . ' ' . + CMailFile::getValidAddress($sendto, 4, 0, 1); + if ($message) { + $actionmsg = $langs->transnoentities('MailFrom') . ': ' . dol_escape_htmltag($from); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTo') . ': ' . dol_escape_htmltag($sendto)); + if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . dol_escape_htmltag($sendtocc)); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); $actionmsg = dol_concatdesc($actionmsg, $message); } - require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; + require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php'; - // Insert record of emails sent - $actioncomm = new ActionComm($this->db); + // Insert record of emails sent + $actioncomm = new ActionComm($this->db); - $actioncomm->type_code = 'AC_OTH_AUTO'; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) - $actioncomm->code = 'AC_'.$actioncode; - $actioncomm->label = $actionmsg2; - $actioncomm->note_private = $actionmsg; - $actioncomm->fk_project = 0; - $actioncomm->datep = $now; - $actioncomm->datef = $now; - $actioncomm->percentage = -1; // Not applicable - $actioncomm->socid = $adherent->thirdparty->id; - $actioncomm->contactid = 0; - $actioncomm->authorid = $user->id; // User saving action - $actioncomm->userownerid = $user->id; // Owner of action - // Fields when action is en email (content should be added into note) - $actioncomm->email_msgid = $cmail->msgid; - $actioncomm->email_from = $from; - $actioncomm->email_sender = ''; - $actioncomm->email_to = $to; - $actioncomm->email_tocc = $sendtocc; - $actioncomm->email_tobcc = $sendtobcc; - $actioncomm->email_subject = $subject; - $actioncomm->errors_to = ''; + $actioncomm->type_code = 'AC_OTH_AUTO'; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) + $actioncomm->code = 'AC_' . $actioncode; + $actioncomm->label = $actionmsg2; + $actioncomm->note_private = $actionmsg; + $actioncomm->fk_project = 0; + $actioncomm->datep = $now; + $actioncomm->datef = $now; + $actioncomm->percentage = -1; // Not applicable + $actioncomm->socid = $adherent->thirdparty->id; + $actioncomm->contactid = 0; + $actioncomm->authorid = $user->id; // User saving action + $actioncomm->userownerid = $user->id; // Owner of action + // Fields when action is en email (content should be added into note) + $actioncomm->email_msgid = $cmail->msgid; + $actioncomm->email_from = $from; + $actioncomm->email_sender = ''; + $actioncomm->email_to = $to; + $actioncomm->email_tocc = $sendtocc; + $actioncomm->email_tobcc = $sendtobcc; + $actioncomm->email_subject = $subject; + $actioncomm->errors_to = ''; - $actioncomm->fk_element = $adherent->id; - $actioncomm->elementtype = $adherent->element; + $actioncomm->fk_element = $adherent->id; + $actioncomm->elementtype = $adherent->element; - $actioncomm->extraparams = $extraparams; + $actioncomm->extraparams = $extraparams; - $actioncomm->create($user); + $actioncomm->create($user); } - } - else - { + } else { $blockingerrormsg = "Can't find email template, defined into member module setup, to use for reminding"; $nbko++; @@ -2994,32 +2769,30 @@ class Adherent extends CommonObject $i++; } - } - else - { + } else { $this->error = $this->db->lasterror(); return 1; } } - if ($blockingerrormsg) - { + if ($blockingerrormsg) { $this->error = $blockingerrormsg; return 1; - } - else - { - $this->output = 'Found '.($nbok + $nbko).' members to send reminder to.'; - $this->output .= ' Send email successfuly to '.$nbok.' members'; + } else { + $this->output = 'Found ' . ($nbok + $nbko) . ' members to send reminder to.'; + $this->output .= ' Send email successfuly to ' . $nbok . ' members'; if (is_array($listofmembersok)) { - $listofids = ''; $i = 0; + $listofids = ''; + $i = 0; foreach ($listofmembersok as $idmember) { if ($i > 100) { $listofids .= ', ...'; break; } - if (empty($listofids)) $listofids .= ' ['; - else $listofids .= ', '; + if (empty($listofids)) + $listofids .= ' ['; + else + $listofids .= ', '; $listofids .= $idmember; $i++; } @@ -3027,16 +2800,19 @@ class Adherent extends CommonObject $this->output .= $listofids; } if ($nbko) { - $this->output .= ' - Canceled for '.$nbko.' member (no email or email sending error)'; + $this->output .= ' - Canceled for ' . $nbko . ' member (no email or email sending error)'; if (is_array($listofmembersko)) { - $listofids = ''; $i = 0; + $listofids = ''; + $i = 0; foreach ($listofmembersko as $idmember) { if ($i > 100) { $listofids .= ', ...'; break; } - if (empty($listofids)) $listofids .= ' ['; - else $listofids .= ', '; + if (empty($listofids)) + $listofids .= ' ['; + else + $listofids .= ', '; $listofids .= $idmember; $i++; } diff --git a/htdocs/admin/const.php b/htdocs/admin/const.php index baeac243ce0..c4fa1e9240f 100644 --- a/htdocs/admin/const.php +++ b/htdocs/admin/const.php @@ -201,14 +201,14 @@ print '
'; print ''; print ''; print getTitleFieldOfList('Name', 0, $_SERVER['PHP_SELF'], 'name', '', $param, '', $sortfield, $sortorder, '')."\n"; -print ''; -print ''; -print getTitleFieldOfList('DateModificationShort', 0, $_SERVER['PHP_SELF'], 'tms', '', $param, '', $sortfield, $sortorder, 'center')."\n"; +print getTitleFieldOfList("Value", 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); +print getTitleFieldOfList("Comment", 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); +print getTitleFieldOfList('DateModificationShort', 0, $_SERVER['PHP_SELF'], 'tms', '', $param, '', $sortfield, $sortorder, 'center ')."\n"; if (! empty($conf->multicompany->enabled) && !$user->entity) { - print getTitleFieldOfList('Entity', 0, $_SERVER['PHP_SELF'], 'tms', '', $param, '', $sortfield, $sortorder, 'center')."\n"; + print getTitleFieldOfList('Entity', 0, $_SERVER['PHP_SELF'], 'tms', '', $param, '', $sortfield, $sortorder, 'center ')."\n"; } -print ''; +print getTitleFieldOfList("Action", 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); print "\n"; diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 1bd051d4b55..54dfb294975 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -536,14 +536,16 @@ abstract class CommonDocGenerator * * @param Object $line Object line * @param Translate $outputlangs Lang object to use for output + * @param int $linenumber The number of the line for the substitution of "object_line_pos" * @return array Return a substitution array */ - public function get_substitutionarray_lines($line, $outputlangs) + public function get_substitutionarray_lines($line, $outputlangs, $linenumber = 0) { // phpcs:enable global $conf; $resarray = array( + 'line_pos' => $linenumber, 'line_fulldesc'=>doc_getlinedesc($line, $outputlangs), 'line_product_ref'=>$line->product_ref, 'line_product_ref_fourn'=>$line->ref_fourn, // for supplier doc lines diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 8129c810303..f058097ca81 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1145,15 +1145,16 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename = * @param int $pictoisfullpath If 1, image path is a full path. If you set this to 1, you can use url returned by dol_buildpath('/mymodyle/img/myimg.png',1) for $picto. * @param string $morehtmlright Add more html content on right of tabs title * @param string $morecss More Css + * @param int $limittoshow Limit number of tabs to show. Use 0 to use automatic default value. * @return void */ -function dol_fiche_head($links = array(), $active = '0', $title = '', $notab = 0, $picto = '', $pictoisfullpath = 0, $morehtmlright = '', $morecss = '') +function dol_fiche_head($links = array(), $active = '0', $title = '', $notab = 0, $picto = '', $pictoisfullpath = 0, $morehtmlright = '', $morecss = '', $limittoshow = 0) { - print dol_get_fiche_head($links, $active, $title, $notab, $picto, $pictoisfullpath, $morehtmlright, $morecss); + print dol_get_fiche_head($links, $active, $title, $notab, $picto, $pictoisfullpath, $morehtmlright, $morecss, $limittoshow); } /** - * Show tab header of a card + * Show tabs of a record * * @param array $links Array of tabs * @param string $active Active tab name @@ -1163,9 +1164,10 @@ function dol_fiche_head($links = array(), $active = '0', $title = '', $notab = 0 * @param int $pictoisfullpath If 1, image path is a full path. If you set this to 1, you can use url returned by dol_buildpath('/mymodyle/img/myimg.png',1) for $picto. * @param string $morehtmlright Add more html content on right of tabs title * @param string $morecss More Css + * @param int $limittoshow Limit number of tabs to show. Use 0 to use automatic default value. * @return string */ -function dol_get_fiche_head($links = array(), $active = '', $title = '', $notab = 0, $picto = '', $pictoisfullpath = 0, $morehtmlright = '', $morecss = '') +function dol_get_fiche_head($links = array(), $active = '', $title = '', $notab = 0, $picto = '', $pictoisfullpath = 0, $morehtmlright = '', $morecss = '', $limittoshow = 0) { global $conf, $langs, $hookmanager; @@ -1202,11 +1204,13 @@ function dol_get_fiche_head($links = array(), $active = '', $title = '', $notab if (count($keys)) $maxkey = max($keys); } - if (!empty($conf->dol_optimize_smallscreen)) $conf->global->MAIN_MAXTABS_IN_CARD = 2; - // Show tabs // if =0 we don't use the feature - $limittoshow = (empty($conf->global->MAIN_MAXTABS_IN_CARD) ? 99 : $conf->global->MAIN_MAXTABS_IN_CARD); + if (empty($limittoshow)) { + $limittoshow = (empty($conf->global->MAIN_MAXTABS_IN_CARD) ? 99 : $conf->global->MAIN_MAXTABS_IN_CARD); + } + if (!empty($conf->dol_optimize_smallscreen)) $limittoshow = 2; + $displaytab = 0; $nbintab = 0; $popuptab = 0; @@ -4082,11 +4086,22 @@ function getTitleFieldOfList($name, $thead = 0, $file = "", $field = "", $begin $tmpfield = explode(',', $field); $field1 = trim($tmpfield[0]); // If $field is 'd.datep,d.id', it becomes 'd.datep' + if (empty($conf->global->MAIN_DISABLE_WRAPPING_ON_COLUMN_TITLE)) { + $prefix = 'wrapcolumntitle '.$prefix; + } //var_dump('field='.$field.' field1='.$field1.' sortfield='.$sortfield.' sortfield1='.$sortfield1); // If field is used as sort criteria we use a specific css class liste_titre_sel // Example if (sortfield,field)=("nom","xxx.nom") or (sortfield,field)=("nom","nom") - if ($field1 && ($sortfield1 == $field1 || $sortfield1 == preg_replace("/^[^\.]+\./", "", $field1))) $out .= '<'.$tag.' class="'.$prefix.'liste_titre_sel" '.$moreattrib.'>'; - else $out .= '<'.$tag.' class="'.$prefix.'liste_titre" '.$moreattrib.'>'; + if ($field1 && ($sortfield1 == $field1 || $sortfield1 == preg_replace("/^[^\.]+\./", "", $field1))) { + $out .= '<'.$tag.' class="'.$prefix.'liste_titre_sel" '.$moreattrib; + $out .= (($field && empty($conf->global->MAIN_DISABLE_WRAPPING_ON_COLUMN_TITLE) && preg_match('/^[a-zA-Z_0-9\s\.\-:]*$/', $name)) ? ' title="'.dol_escape_htmltag($langs->trans($name)).'"' : ''); + $out .= '>'; + } + else { + $out .= '<'.$tag.' class="'.$prefix.'liste_titre" '.$moreattrib; + $out .= (($field && empty($conf->global->MAIN_DISABLE_WRAPPING_ON_COLUMN_TITLE) && preg_match('/^[a-zA-Z_0-9\s\.\-:]*$/', $name)) ? ' title="'.dol_escape_htmltag($langs->trans($name)).'"' : ''); + $out .= '>'; + } if (empty($thead) && $field && empty($disablesortlink)) // If this is a sort field { @@ -4119,7 +4134,9 @@ function getTitleFieldOfList($name, $thead = 0, $file = "", $field = "", $begin } } $sortordertouseinlink = preg_replace('/,$/', '', $sortordertouseinlink); - $out .= ''; + $out .= 'global->MAIN_DISABLE_WRAPPING_ON_COLUMN_TITLE) ? ' title="'.dol_escape_htmltag($langs->trans($name)).'"' : ''); + $out .= '>'; } if ($tooltip) $out .= $form->textwithpicto($langs->trans($name), $langs->trans($tooltip)); @@ -4287,7 +4304,7 @@ function print_barre_liste($titre, $page, $file, $options = '', $sortfield = '', if ($picto && $titre) print ''; print ''; // Center diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index ddca8ef1153..3d9cd447802 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -2454,7 +2454,7 @@ function getTaskProgressView($task, $label = true, $progressNumber = true, $hide */ function getTaskProgressBadge($task, $label = '', $tooltip = '') { - global $conf; + global $conf, $langs; $out = ''; $badgeClass = ''; @@ -2472,12 +2472,15 @@ function getTaskProgressBadge($task, $label = '', $tooltip = '') if (doubleval($progressCalculated) > doubleval($task->progress * $warningRatio)) { $badgeClass .= 'badge-danger'; + if (empty($tooltip)) $tooltip = $task->progress.'% < '.$langs->trans("Expected").' '.$progressCalculated.'%'; } elseif (doubleval($progressCalculated) > doubleval($task->progress)) { // warning if close at 10% $badgeClass .= 'badge-warning'; + if (empty($tooltip)) $tooltip = $task->progress.'% < '.$langs->trans("Expected").' '.$progressCalculated.'%'; } else { $badgeClass .= 'badge-success'; + if (empty($tooltip)) $tooltip = $task->progress.'% >= '.$langs->trans("Expected").' '.$progressCalculated.'%'; } } } diff --git a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php index 6e23160baf6..9755369793e 100644 --- a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php +++ b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php @@ -411,9 +411,11 @@ class doc_generic_bom_odt extends ModelePDFBom } if ($foundtagforlines) { + $linenumber = 0; foreach ($object->lines as $line) { - $tmparray = $this->get_substitutionarray_lines($line, $outputlangs); + $linenumber++; + $tmparray = $this->get_substitutionarray_lines($line, $outputlangs, $linenumber); complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); // Call the ODTSubstitutionLine hook $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line); diff --git a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php index 4694cdaf6ee..75c5103c4ab 100644 --- a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php +++ b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php @@ -427,9 +427,11 @@ class doc_generic_order_odt extends ModelePDFCommandes } if ($foundtagforlines) { + $linenumber = 0; foreach ($object->lines as $line) { - $tmparray = $this->get_substitutionarray_lines($line, $outputlangs); + $linenumber++; + $tmparray = $this->get_substitutionarray_lines($line, $outputlangs, $linenumber); complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); // Call the ODTSubstitutionLine hook $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line); diff --git a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php index 190abd86126..c938f40cfb2 100644 --- a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php +++ b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php @@ -408,9 +408,11 @@ class doc_generic_contract_odt extends ModelePDFContract } if ($foundtagforlines) { + $linenumber = 0; foreach ($object->lines as $line) { - $tmparray = $this->get_substitutionarray_lines($line, $outputlangs); + $linenumber++; + $tmparray = $this->get_substitutionarray_lines($line, $outputlangs, $linenumber); complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); // Call the ODTSubstitutionLine hook $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line); diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index 01070a6a6c7..acbebd54da8 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -435,9 +435,11 @@ class doc_generic_invoice_odt extends ModelePDFFactures } if ($foundtagforlines) { + $linenumber = 0; foreach ($object->lines as $line) { - $tmparray = $this->get_substitutionarray_lines($line, $outputlangs); + $linenumber++; + $tmparray = $this->get_substitutionarray_lines($line, $outputlangs, $linenumber); complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); // Call the ODTSubstitutionLine hook $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line); diff --git a/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php b/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php index 398c8670a47..e276fe1f5f7 100644 --- a/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php +++ b/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php @@ -418,9 +418,11 @@ class doc_generic_mo_odt extends ModelePDFMo } if ($foundtagforlines) { + $linenumber = 0; foreach ($object->lines as $line) { - $tmparray = $this->get_substitutionarray_lines($line, $outputlangs); + $linenumber++; + $tmparray = $this->get_substitutionarray_lines($line, $outputlangs, $linenumber); complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); // Call the ODTSubstitutionLine hook $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line); diff --git a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php index fde5f08d318..33850c5d882 100644 --- a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php +++ b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php @@ -456,9 +456,11 @@ class doc_generic_proposal_odt extends ModelePDFPropales } if ($foundtagforlines) { + $linenumber = 0; foreach ($object->lines as $line) { - $tmparray = $this->get_substitutionarray_lines($line, $outputlangs); + $linenumber++; + $tmparray = $this->get_substitutionarray_lines($line, $outputlangs, $linenumber); complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); // Call the ODTSubstitutionLine hook $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line); diff --git a/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php b/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php index c71fe8f59ec..d7f48915308 100644 --- a/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php +++ b/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php @@ -421,9 +421,11 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders } if ($foundtagforlines) { + $linenumber = 0; foreach ($object->lines as $line) { - $tmparray = $this->get_substitutionarray_lines($line, $outputlangs); + $linenumber++; + $tmparray = $this->get_substitutionarray_lines($line, $outputlangs, $linenumber); complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); // Call the ODTSubstitutionLine hook $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line); diff --git a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php index 77503c4b61b..3b4a39288ea 100644 --- a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php @@ -445,9 +445,11 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal } if ($foundtagforlines) { + $linenumber = 0; foreach ($object->lines as $line) { - $tmparray = $this->get_substitutionarray_lines($line, $outputlangs); + $linenumber++; + $tmparray = $this->get_substitutionarray_lines($line, $outputlangs, $linenumber); complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); // Call the ODTSubstitutionLine hook $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line); diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 3d1a23ee26d..6e95b17eb56 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -286,99 +286,100 @@ if (empty($reshook)) $lines = $srcobject->lines; } - $fk_parent_line = 0; - $num = count($lines); + if (is_array($lines)) { + $num = count($lines); - for ($i = 0; $i < $num; $i++) - { - $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : Product::TYPE_PRODUCT); + for ($i = 0; $i < $num; $i++) + { + $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : Product::TYPE_PRODUCT); - if ($product_type == Product::TYPE_SERVICE || !empty($conf->global->FICHINTER_PRINT_PRODUCTS)) { //only services except if config includes products - $duration = 3600; // Default to one hour + if ($product_type == Product::TYPE_SERVICE || !empty($conf->global->FICHINTER_PRINT_PRODUCTS)) { //only services except if config includes products + $duration = 3600; // Default to one hour - // Predefined products & services - if ($lines[$i]->fk_product > 0) - { - $prod = new Product($db); - $prod->id = $lines[$i]->fk_product; + // Predefined products & services + if ($lines[$i]->fk_product > 0) + { + $prod = new Product($db); + $prod->id = $lines[$i]->fk_product; - // Define output language - if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { - $prod->getMultiLangs(); - // We show if duration is present on service (so we get it) - $prod->fetch($lines[$i]->fk_product); - $outputlangs = $langs; - $newlang = ''; - if (empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if (empty($newlang)) $newlang = $srcobject->thirdparty->default_lang; - if (!empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); + // Define output language + if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + $prod->getMultiLangs(); + // We show if duration is present on service (so we get it) + $prod->fetch($lines[$i]->fk_product); + $outputlangs = $langs; + $newlang = ''; + if (empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if (empty($newlang)) $newlang = $srcobject->thirdparty->default_lang; + if (!empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $label = (!empty($prod->multilangs[$outputlangs->defaultlang]["libelle"])) ? $prod->multilangs[$outputlangs->defaultlang]["libelle"] : $lines[$i]->product_label; + } else { + $prod->fetch($lines[$i]->fk_product); + $label = $lines[$i]->product_label; } - $label = (!empty($prod->multilangs[$outputlangs->defaultlang]["libelle"])) ? $prod->multilangs[$outputlangs->defaultlang]["libelle"] : $lines[$i]->product_label; - } else { - $prod->fetch($lines[$i]->fk_product); - $label = $lines[$i]->product_label; - } - if ($prod->duration_value && $conf->global->FICHINTER_USE_SERVICE_DURATION) { - switch ($prod->duration_unit) { - default: - case 'h': - $mult = 3600; - break; - case 'd': - $mult = 3600 * 24; - break; - case 'w': - $mult = 3600 * 24 * 7; - break; - case 'm': - $mult = (int) 3600 * 24 * (365 / 12); // Average month duration - break; - case 'y': - $mult = 3600 * 24 * 365; - break; + if ($prod->duration_value && $conf->global->FICHINTER_USE_SERVICE_DURATION) { + switch ($prod->duration_unit) { + default: + case 'h': + $mult = 3600; + break; + case 'd': + $mult = 3600 * 24; + break; + case 'w': + $mult = 3600 * 24 * 7; + break; + case 'm': + $mult = (int) 3600 * 24 * (365 / 12); // Average month duration + break; + case 'y': + $mult = 3600 * 24 * 365; + break; + } + $duration = $prod->duration_value * $mult * $lines[$i]->qty; } - $duration = $prod->duration_value * $mult * $lines[$i]->qty; - } - $desc = $lines[$i]->product_ref; - $desc .= ' - '; - $desc .= $label; + $desc = $lines[$i]->product_ref; + $desc .= ' - '; + $desc .= $label; + $desc .= '
'; + } + // Common part (predefined or free line) + $desc .= dol_htmlentitiesbr($lines[$i]->desc); $desc .= '
'; - } - // Common part (predefined or free line) - $desc .= dol_htmlentitiesbr($lines[$i]->desc); - $desc .= '
'; - $desc .= ' ('.$langs->trans('Quantity').': '.$lines[$i]->qty.')'; + $desc .= ' ('.$langs->trans('Quantity').': '.$lines[$i]->qty.')'; - $timearray = dol_getdate(dol_now()); - $date_intervention = dol_mktime(0, 0, 0, $timearray['mon'], $timearray['mday'], $timearray['year']); + $timearray = dol_getdate(dol_now()); + $date_intervention = dol_mktime(0, 0, 0, $timearray['mon'], $timearray['mday'], $timearray['year']); - if ($product_type == Product::TYPE_PRODUCT) { - $duration = 0; - } + if ($product_type == Product::TYPE_PRODUCT) { + $duration = 0; + } - $predef = ''; + $predef = ''; - // Extrafields - $extrafields->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafields->getOptionalsFromPost($object->table_element_line, $predef); + // Extrafields + $extrafields->fetch_name_optionals_label($object->table_element_line); + $array_options = $extrafields->getOptionalsFromPost($object->table_element_line, $predef); - $result = $object->addline( - $user, - $id, - $desc, - $date_intervention, - $duration, - $array_options - ); + $result = $object->addline( + $user, + $id, + $desc, + $date_intervention, + $duration, + $array_options + ); - if ($result < 0) - { - $error++; - break; + if ($result < 0) + { + $error++; + break; + } } } } diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 8c1cdd829de..ef09674f8aa 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1757,9 +1757,11 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead /** * Build the tooltip on user login * - * @return string HTML content + * @param int $hideloginname Hide login name. Show only the image. + * @param string $urllogout URL for logout + * @return string HTML content */ -function top_menu_user() +function top_menu_user($hideloginname = 0, $urllogout = '') { global $langs, $conf, $db, $hookmanager, $user; global $dolibarr_main_authentication, $dolibarr_main_demo; @@ -1830,9 +1832,10 @@ function top_menu_user() } } - - - $logoutLink = '
'.$langs->trans("Logout").''; + if (empty($urllogout)) { + $urllogout = DOL_URL_ROOT.'/user/logout.php'; + } + $logoutLink = ' '.$langs->trans("Logout").''; $profilLink = ' '.$langs->trans("Card").''; @@ -1857,9 +1860,12 @@ function top_menu_user() $btnUser = '
'.$langs->trans("Value").''.$langs->trans("Comment").''.$langs->trans("Action").'
'.img_picto('', $picto, 'class="valignmiddle pictotitle widthpictotitle"', $pictoisfullpath).''; print '
'.$titre; - if (!empty($titre) && $savtotalnboflines >= 0 && (string) $savtotalnboflines != '') print ' ('.$totalnboflines.')'; + if (!empty($titre) && $savtotalnboflines >= 0 && (string) $savtotalnboflines != '') print '('.$totalnboflines.')'; print '