39require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
41require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/class/commonpeople.class.php';
55 public $element =
'member';
60 public $table_element =
'adherent';
65 public $picto =
'member';
85 public $pass_indatabase;
90 public $pass_indatabase_crypted;
107 public $civility_code;
141 public $socialnetworks;
161 public $phone_mobile;
187 public $default_lang;
236 public $need_subscription;
259 public $first_subscription_date;
264 public $first_subscription_date_start;
269 public $first_subscription_date_end;
274 public $first_subscription_amount;
279 public $last_subscription_date;
284 public $last_subscription_date_start;
289 public $last_subscription_date_end;
294 public $last_subscription_amount;
299 public $subscriptions = array();
311 public $partnerships = array();
322 public $fields = array(
323 'rowid' => array(
'type' =>
'integer',
'label' =>
'TechnicalID',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 10),
324 'ref' => array(
'type' =>
'varchar(30)',
'label' =>
'Ref',
'default' =>
'1',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'position' => 12,
'index' => 1),
325 'entity' => array(
'type' =>
'integer',
'label' =>
'Entity',
'default' =>
'1',
'enabled' => 1,
'visible' => -2,
'notnull' => 1,
'position' => 15,
'index' => 1),
326 'ref_ext' => array(
'type' =>
'varchar(128)',
'label' =>
'Ref ext',
'enabled' => 1,
'visible' => 0,
'position' => 20),
327 'civility' => array(
'type' =>
'varchar(6)',
'label' =>
'Civility',
'enabled' => 1,
'visible' => -1,
'position' => 25),
328 'lastname' => array(
'type' =>
'varchar(50)',
'label' =>
'Lastname',
'enabled' => 1,
'visible' => 1,
'position' => 30,
'showoncombobox' => 1),
329 'firstname' => array(
'type' =>
'varchar(50)',
'label' =>
'Firstname',
'enabled' => 1,
'visible' => 1,
'position' => 35,
'showoncombobox' => 1),
330 'login' => array(
'type' =>
'varchar(50)',
'label' =>
'Login',
'enabled' => 1,
'visible' => 1,
'position' => 40),
331 'pass' => array(
'type' =>
'varchar(50)',
'label' =>
'Pass',
'enabled' => 1,
'visible' => -1,
'position' => 45),
332 'pass_crypted' => array(
'type' =>
'varchar(128)',
'label' =>
'Pass crypted',
'enabled' => 1,
'visible' => -1,
'position' => 50),
333 'morphy' => array(
'type' =>
'varchar(3)',
'label' =>
'MemberNature',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'position' => 55),
334 'fk_adherent_type' => array(
'type' =>
'integer',
'label' =>
'Fk adherent type',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'position' => 60),
335 'societe' => array(
'type' =>
'varchar(128)',
'label' =>
'Societe',
'enabled' => 1,
'visible' => 1,
'position' => 65,
'showoncombobox' => 2),
336 'fk_soc' => array(
'type' =>
'integer:Societe:societe/class/societe.class.php',
'label' =>
'ThirdParty',
'enabled' => 1,
'visible' => 1,
'position' => 70),
337 'address' => array(
'type' =>
'text',
'label' =>
'Address',
'enabled' => 1,
'visible' => -1,
'position' => 75),
338 'zip' => array(
'type' =>
'varchar(10)',
'label' =>
'Zip',
'enabled' => 1,
'visible' => -1,
'position' => 80),
339 'town' => array(
'type' =>
'varchar(50)',
'label' =>
'Town',
'enabled' => 1,
'visible' => -1,
'position' => 85),
340 'state_id' => array(
'type' =>
'integer',
'label' =>
'State id',
'enabled' => 1,
'visible' => -1,
'position' => 90),
341 'country' => array(
'type' =>
'integer:Ccountry:core/class/ccountry.class.php',
'label' =>
'Country',
'enabled' => 1,
'visible' => 1,
'position' => 95),
342 'phone' => array(
'type' =>
'varchar(30)',
'label' =>
'Phone',
'enabled' => 1,
'visible' => -1,
'position' => 115),
343 'phone_perso' => array(
'type' =>
'varchar(30)',
'label' =>
'Phone perso',
'enabled' => 1,
'visible' => -1,
'position' => 120),
344 'phone_mobile' => array(
'type' =>
'varchar(30)',
'label' =>
'Phone mobile',
'enabled' => 1,
'visible' => -1,
'position' => 125),
345 'email' => array(
'type' =>
'varchar(255)',
'label' =>
'Email',
'enabled' => 1,
'visible' => 1,
'position' => 126),
346 'url' => array(
'type' =>
'varchar(255)',
'label' =>
'Url',
'enabled' => 1,
'visible' => -1,
'position' => 127),
347 'socialnetworks' => array(
'type' =>
'text',
'label' =>
'Socialnetworks',
'enabled' => 1,
'visible' => -1,
'position' => 128),
348 'birth' => array(
'type' =>
'date',
'label' =>
'DateOfBirth',
'enabled' => 1,
'visible' => -1,
'position' => 130),
349 'gender' => array(
'type' =>
'varchar(10)',
'label' =>
'Gender',
'enabled' => 1,
'visible' => -1,
'position' => 132),
350 'photo' => array(
'type' =>
'varchar(255)',
'label' =>
'Photo',
'enabled' => 1,
'visible' => -1,
'position' => 135),
351 'public' => array(
'type' =>
'smallint(6)',
'label' =>
'Public',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 145),
352 'datefin' => array(
'type' =>
'datetime',
'label' =>
'DateEnd',
'enabled' => 1,
'visible' => 1,
'position' => 150),
353 'default_lang' => array(
'type' =>
'varchar(6)',
'label' =>
'Default lang',
'enabled' => 1,
'visible' => -1,
'position' => 153),
354 'note_public' => array(
'type' =>
'text',
'label' =>
'NotePublic',
'enabled' => 1,
'visible' => 0,
'position' => 155),
355 'note_private' => array(
'type' =>
'text',
'label' =>
'NotePrivate',
'enabled' => 1,
'visible' => 0,
'position' => 160),
356 'datevalid' => array(
'type' =>
'datetime',
'label' =>
'DateValidation',
'enabled' => 1,
'visible' => -1,
'position' => 165),
357 'datec' => array(
'type' =>
'datetime',
'label' =>
'DateCreation',
'enabled' => 1,
'visible' => -1,
'position' => 170),
358 'tms' => array(
'type' =>
'timestamp',
'label' =>
'DateModification',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 175),
359 'fk_user_author' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'Fk user author',
'enabled' => 1,
'visible' => -1,
'position' => 180),
360 'fk_user_mod' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'Fk user mod',
'enabled' => 1,
'visible' => -1,
'position' => 185),
361 'fk_user_valid' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'UserValidation',
'enabled' => 1,
'visible' => -1,
'position' => 190),
362 'canvas' => array(
'type' =>
'varchar(32)',
'label' =>
'Canvas',
'enabled' => 1,
'visible' => -1,
'position' => 195),
363 'statut' => array(
'type' =>
'smallint(6)',
'label' =>
'Statut',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'position' => 500,
'arrayofkeyval' => array(-1 =>
'Draft', 1 =>
'Validated', 0 =>
'MemberStatusResiliatedShort', -2 =>
'MemberStatusExcludedShort')),
364 'model_pdf' => array(
'type' =>
'varchar(255)',
'label' =>
'Model pdf',
'enabled' => 1,
'visible' => 0,
'position' => 800),
365 'import_key' => array(
'type' =>
'varchar(14)',
'label' =>
'ImportId',
'enabled' => 1,
'visible' => -2,
'position' => 805)
398 $this->ismultientitymanaged = 1;
399 $this->isextrafieldmanaged = 1;
401 $this->array_options = array();
424 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 =
'')
427 dol_syslog(
'Warning using deprecated Adherent::send_an_email', LOG_WARNING);
429 return $this->
sendEmail($text, $subject, $filename_list, $mimetype_list, $mimefilename_list, $addr_cc, $addr_bcc, $deliveryreceipt, $msgishtml, $errors_to, $moreinheader);
449 public function sendEmail($text, $subject, $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array(), $addr_cc =
"", $addr_bcc =
"", $deliveryreceipt = 0, $msgishtml = -1, $errors_to =
'', $moreinheader =
'')
451 global $conf, $langs;
454 if ($msgishtml == -1) {
461 dol_syslog(
'sendEmail msgishtml='.$msgishtml);
470 $from = $conf->email_from;
475 $trackid =
'mem'.$this->id;
478 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
479 $mailfile =
new CMailFile($subjecttosend, $this->
email, $from, $texttosend, $filename_list, $mimetype_list, $mimefilename_list, $addr_cc, $addr_bcc, $deliveryreceipt, $msgishtml,
'',
'', $trackid, $moreinheader);
480 if ($mailfile->sendfile()) {
483 $this->error = $langs->trans(
"ErrorFailedToSendMail", $from, $this->
email).
'. '.$mailfile->error;
507 if ($this->civility_id) {
508 $infos .= $langs->transnoentities(
"UserTitle").
": ".$this->
getCivilityLabel().
"\n";
510 $infos .= $langs->transnoentities(
"id").
": ".$this->
id.
"\n";
511 $infos .= $langs->transnoentities(
"ref").
": ".$this->
ref.
"\n";
512 $infos .= $langs->transnoentities(
"Lastname").
": ".$this->lastname.
"\n";
513 $infos .= $langs->transnoentities(
"Firstname").
": ".$this->firstname.
"\n";
514 $infos .= $langs->transnoentities(
"Company").
": ".$this->company.
"\n";
515 $infos .= $langs->transnoentities(
"Address").
": ".$this->
address.
"\n";
516 $infos .= $langs->transnoentities(
"Zip").
": ".$this->zip.
"\n";
517 $infos .= $langs->transnoentities(
"Town").
": ".$this->town.
"\n";
518 $infos .= $langs->transnoentities(
"Country").
": ".$this->country.
"\n";
519 $infos .= $langs->transnoentities(
"EMail").
": ".$this->
email.
"\n";
520 $infos .= $langs->transnoentities(
"PhonePro").
": ".$this->phone.
"\n";
521 $infos .= $langs->transnoentities(
"PhonePerso").
": ".$this->phone_perso.
"\n";
522 $infos .= $langs->transnoentities(
"PhoneMobile").
": ".$this->phone_mobile.
"\n";
524 $infos .= $langs->transnoentities(
"Login").
": ".$this->login.
"\n";
525 $infos .= $langs->transnoentities(
"Password").
": ".$this->pass.
"\n";
527 $infos .= $langs->transnoentities(
"Birthday").
": ".$birthday.
"\n";
528 $infos .= $langs->transnoentities(
"Photo").
": ".$this->photo.
"\n";
529 $infos .= $langs->transnoentities(
"Public").
": ".
yn($this->
public);
532 $substitutionarray = array(
533 '__ID__' => $this->
id,
534 '__REF__' => $this->
ref,
535 '__MEMBER_ID__' => $this->
id,
537 '__FIRSTNAME__' => $msgishtml ?
dol_htmlentitiesbr($this->firstname) : ($this->firstname ? $this->firstname :
''),
538 '__LASTNAME__' => $msgishtml ?
dol_htmlentitiesbr($this->lastname) : ($this->lastname ? $this->lastname :
''),
540 '__COMPANY__' => $msgishtml ?
dol_htmlentitiesbr($this->company) : ($this->company ? $this->company :
''),
542 '__ZIP__' => $msgishtml ?
dol_htmlentitiesbr($this->zip) : ($this->zip ? $this->zip :
''),
543 '__TOWN__' => $msgishtml ?
dol_htmlentitiesbr($this->town) : ($this->town ? $this->town :
''),
544 '__COUNTRY__' => $msgishtml ?
dol_htmlentitiesbr($this->country) : ($this->country ? $this->country :
''),
546 '__BIRTH__' => $msgishtml ?
dol_htmlentitiesbr($birthday) : ($birthday ? $birthday :
''),
547 '__PHOTO__' => $msgishtml ?
dol_htmlentitiesbr($this->photo) : ($this->photo ? $this->photo :
''),
548 '__LOGIN__' => $msgishtml ?
dol_htmlentitiesbr($this->login) : ($this->login ? $this->login :
''),
549 '__PASSWORD__' => $msgishtml ?
dol_htmlentitiesbr($this->pass) : ($this->pass ? $this->pass :
''),
550 '__PHONE__' => $msgishtml ?
dol_htmlentitiesbr($this->phone) : ($this->phone ? $this->phone :
''),
551 '__PHONEPRO__' => $msgishtml ?
dol_htmlentitiesbr($this->phone_perso) : ($this->phone_perso ? $this->phone_perso :
''),
552 '__PHONEMOBILE__' => $msgishtml ?
dol_htmlentitiesbr($this->phone_mobile) : ($this->phone_mobile ? $this->phone_mobile :
''),
576 $morphy = $this->morphy;
580 $labeltoshowm = $langs->trans(
"Moral");
581 $labeltoshowp = $langs->trans(
"Physical");
582 if ($morphy ==
'phy') {
583 $labeltoshow = $labeltoshowp;
584 if ($addbadge == 2) {
590 $s .=
'<span class="member-individual-back paddingleftimp paddingrightimp" title="'.$langs->trans(
"Physical").
'">'.$labeltoshow.
'</span>';
592 if ($morphy ==
'mor') {
593 $labeltoshow = $labeltoshowm;
594 if ($addbadge == 2) {
600 $s .=
'<span class="member-company-back paddingleftimp paddingrightimp" title="'.$langs->trans(
"Moral").
'">'.$labeltoshow.
'</span>';
603 if ($morphy ==
'phy') {
604 $s = $langs->trans(
"Physical");
605 } elseif ($morphy ==
'mor') {
606 $s = $langs->trans(
"Moral");
620 public function create($user, $notrigger = 0)
622 global $conf, $langs, $mysoc;
629 $this->import_key = trim($this->import_key);
633 $langs->load(
"errors");
634 $this->error = $langs->trans(
"ErrorBadEMail", $this->
email);
641 if (empty($this->login)) {
642 $this->error = $langs->trans(
"ErrorWrongValueForParameterX",
"Login");
650 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"adherent";
651 $sql .=
" (ref, datec,login,fk_user_author,fk_user_mod,fk_user_valid,morphy,fk_adherent_type,entity,import_key, ip)";
654 $sql .=
", '".$this->db->idate($this->datec).
"'";
655 $sql .=
", ".($this->login ?
"'".$this->db->escape($this->login).
"'" :
"null");
656 $sql .=
", ".($user->id > 0 ? $user->id :
"null");
657 $sql .=
", null, null, '".$this->db->escape($this->morphy).
"'";
658 $sql .=
", ".((int) $this->
typeid);
659 $sql .=
", ".$conf->entity;
660 $sql .=
", ".(!empty($this->import_key) ?
"'".$this->db->escape($this->import_key).
"'" :
"null");
661 $sql .=
", ".(!empty($this->ip) ?
"'".$this->db->escape($this->ip).
"'" :
"null");
664 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
665 $result = $this->db->query($sql);
667 $id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"adherent");
672 $this->
ref = (string) $id;
677 require_once $modfile;
679 $modCodeMember =
new $modname();
680 '@phan-var-force ModeleNumRefMembers $modCodeMember';
681 $this->
ref = $modCodeMember->getNextValue($mysoc, $this);
689 $result = $this->
update($user, 1, 1, 0, 0,
'add');
691 $this->db->rollback();
696 if ($this->user_id) {
698 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET";
699 $sql .=
" fk_member = ".((int) $this->
id);
700 $sql .=
" WHERE rowid = ".((int) $this->user_id);
701 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
702 $resql = $this->db->query($sql);
704 $this->error =
'Failed to update user to make link with member';
705 $this->db->rollback();
719 if (count($this->errors)) {
720 dol_syslog(get_class($this).
"::create ".implode(
',', $this->errors), LOG_ERR);
721 $this->db->rollback();
728 $this->error =
'Failed to get last insert id';
729 dol_syslog(get_class($this).
"::create ".$this->error, LOG_ERR);
730 $this->db->rollback();
734 $this->error = $this->db->error();
735 $this->db->rollback();
752 public function update($user, $notrigger = 0, $nosyncuser = 0, $nosyncuserpass = 0, $nosyncthirdparty = 0, $action =
'update')
754 global $langs, $hookmanager;
756 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
761 dol_syslog(get_class($this).
"::update notrigger=".$notrigger.
", nosyncuser=".$nosyncuser.
", nosyncuserpass=".$nosyncuserpass.
" nosyncthirdparty=".$nosyncthirdparty.
", email=".$this->email);
764 $this->lastname = trim($this->lastname) ? trim($this->lastname) : trim($this->lastname);
765 $this->firstname = trim($this->firstname) ? trim($this->firstname) : trim($this->firstname);
766 $this->gender = trim($this->gender);
774 $this->url = $this->url ?
clean_url($this->url, 0) :
'';
778 $langs->load(
"errors");
779 $this->error = $langs->trans(
"ErrorBadEMail", $this->
email);
785 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
786 $sql .=
" ref = '".$this->db->escape($this->
ref).
"'";
787 $sql .=
", civility = ".($this->civility_id ?
"'".$this->db->escape($this->civility_id).
"'" :
"null");
788 $sql .=
", firstname = ".($this->firstname ?
"'".$this->db->escape($this->firstname).
"'" :
"null");
789 $sql .=
", lastname = ".($this->lastname ?
"'".$this->db->escape($this->lastname).
"'" :
"null");
790 $sql .=
", gender = ".($this->gender != -1 ?
"'".$this->db->escape($this->gender).
"'" :
"null");
791 $sql .=
", login = ".($this->login ?
"'".$this->db->escape($this->login).
"'" :
"null");
792 $sql .=
", societe = ".($this->company ?
"'".$this->db->escape($this->company).
"'" : ($this->societe ?
"'".$this->db->escape($this->societe).
"'" :
"null"));
794 $sql .=
", fk_soc = ".($this->socid > 0 ? (int) $this->socid :
"null");
796 $sql .=
", address = ".($this->address ?
"'".$this->db->escape($this->
address).
"'" :
"null");
797 $sql .=
", zip = ".($this->zip ?
"'".$this->db->escape($this->zip).
"'" :
"null");
798 $sql .=
", town = ".($this->town ?
"'".$this->db->escape($this->town).
"'" :
"null");
799 $sql .=
", country = ".($this->country_id > 0 ? (int) $this->country_id :
"null");
800 $sql .=
", state_id = ".($this->state_id > 0 ? (int) $this->state_id :
"null");
801 $sql .=
", email = '".$this->db->escape($this->
email).
"'";
802 $sql .=
", url = ".(!empty($this->url) ?
"'".$this->db->escape($this->url).
"'" :
"null");
803 $sql .=
", socialnetworks = ".($this->socialnetworks ?
"'".$this->db->escape(json_encode($this->socialnetworks)).
"'" :
"null");
804 $sql .=
", phone = ".($this->phone ?
"'".$this->db->escape($this->phone).
"'" :
"null");
805 $sql .=
", phone_perso = ".($this->phone_perso ?
"'".$this->db->escape($this->phone_perso).
"'" :
"null");
806 $sql .=
", phone_mobile = ".($this->phone_mobile ?
"'".$this->db->escape($this->phone_mobile).
"'" :
"null");
807 $sql .=
", note_private = ".($this->note_private ?
"'".$this->db->escape($this->note_private).
"'" :
"null");
808 $sql .=
", note_public = ".($this->note_public ?
"'".$this->db->escape($this->note_public).
"'" :
"null");
809 $sql .=
", photo = ".($this->photo ?
"'".$this->db->escape($this->photo).
"'" :
"null");
810 $sql .=
", public = ".(int) $this->
public;
811 $sql .=
", statut = ".(int) $this->statut;
812 $sql .=
", default_lang = ".(!empty($this->default_lang) ?
"'".$this->db->escape($this->default_lang).
"'" :
"null");
813 $sql .=
", fk_adherent_type = ".(int) $this->
typeid;
814 $sql .=
", morphy = '".$this->db->escape($this->morphy).
"'";
815 $sql .=
", birth = ".($this->birth ?
"'".$this->db->idate($this->birth).
"'" :
"null");
817 if ($this->datefin) {
818 $sql .=
", datefin = '".$this->db->idate($this->datefin).
"'";
820 if ($this->datevalid) {
821 $sql .=
", datevalid = '".$this->db->idate($this->datevalid).
"'";
823 $sql .=
", fk_user_mod = ".($user->id > 0 ? $user->id :
'null');
824 $sql .=
" WHERE rowid = ".((int) $this->
id);
827 if (!empty($this->oldcopy) && $this->
typeid != $this->oldcopy->typeid) {
828 $sql2 =
"SELECT libelle as label";
829 $sql2 .=
" FROM ".MAIN_DB_PREFIX.
"adherent_type";
830 $sql2 .=
" WHERE rowid = ".((int) $this->
typeid);
831 $resql2 = $this->db->query($sql2);
833 while ($obj = $this->db->fetch_object($resql2)) {
834 $this->
type = $obj->label;
839 dol_syslog(get_class($this).
"::update update member", LOG_DEBUG);
840 $resql = $this->db->query($sql);
842 unset($this->country_code);
843 unset($this->country);
844 unset($this->state_code);
847 $nbrowsaffected += $this->db->affected_rows($resql);
860 if (!$error && $this->pass) {
861 dol_syslog(get_class($this).
"::update update password");
862 if ($this->pass != $this->pass_indatabase && $this->pass != $this->pass_indatabase_crypted) {
866 $result = $this->
setPassword($user, $this->pass, $isencrypted, $notrigger, $nosyncuserpass);
867 if (!$nbrowsaffected) {
875 dol_syslog(get_class($this).
"::update update link to user");
876 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = NULL WHERE fk_member = ".((int) $this->
id);
877 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
878 $resql = $this->db->query($sql);
880 $this->error = $this->db->error();
881 $this->db->rollback();
885 if ($this->user_id > 0) {
886 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = ".((int) $this->
id).
" WHERE rowid = ".((int) $this->user_id);
887 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
888 $resql = $this->db->query($sql);
890 $this->error = $this->db->error();
891 $this->db->rollback();
897 if (!$error && $nbrowsaffected) {
899 if (!$error && $this->user_id > 0 && !$nosyncuser) {
900 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
902 dol_syslog(get_class($this).
"::update update linked user");
904 $luser =
new User($this->db);
905 $result = $luser->fetch($this->user_id);
913 $luser->login = $this->login;
916 $luser->ref = $this->ref;
917 $luser->civility_id = $this->civility_id;
918 $luser->firstname = $this->firstname;
919 $luser->lastname = $this->lastname;
920 $luser->gender = $this->gender;
921 $luser->pass = $this->pass;
924 $luser->birth = $this->birth;
926 $luser->address = $this->address;
927 $luser->zip = $this->zip;
928 $luser->town = $this->town;
929 $luser->country_id = $this->country_id;
930 $luser->state_id = $this->state_id;
932 $luser->email = $this->email;
933 $luser->socialnetworks = $this->socialnetworks;
934 $luser->office_phone = $this->phone;
935 $luser->user_mobile = $this->phone_mobile;
937 $luser->lang = $this->default_lang;
939 $luser->fk_member = $this->id;
941 $result = $luser->update($user, 0, 1, 1);
943 $this->error = $luser->error;
944 dol_syslog(get_class($this).
"::update ".$this->error, LOG_ERR);
948 $this->error = $luser->error;
954 if (!$error && $this->fk_soc > 0 && !$nosyncthirdparty) {
955 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
957 dol_syslog(get_class($this).
"::update update linked thirdparty");
961 $lthirdparty =
new Societe($this->db);
962 $result = $lthirdparty->fetch($this->fk_soc);
965 $lthirdparty->address = $this->address;
966 $lthirdparty->zip = $this->zip;
967 $lthirdparty->town = $this->town;
968 $lthirdparty->email = $this->email;
969 $lthirdparty->socialnetworks = $this->socialnetworks;
970 $lthirdparty->phone = $this->phone;
971 $lthirdparty->state_id = $this->state_id;
972 $lthirdparty->country_id = $this->country_id;
974 $lthirdparty->default_lang = $this->default_lang;
976 $result = $lthirdparty->update($this->fk_soc, $user, 0, 1, 1,
'update');
979 $this->error = $lthirdparty->error;
980 $this->errors = $lthirdparty->errors;
981 dol_syslog(get_class($this).
"::update ".$this->error, LOG_ERR);
984 } elseif ($result < 0) {
985 $this->error = $lthirdparty->error;
991 if (!$error && !$notrigger) {
1001 $this->db->commit();
1002 return $nbrowsaffected;
1004 $this->db->rollback();
1008 $this->db->rollback();
1009 $this->error = $this->db->lasterror();
1029 $sql =
"SELECT rowid, datec as dateop, dateadh as datedeb, datef as datefin";
1030 $sql .=
" FROM ".MAIN_DB_PREFIX.
"subscription";
1031 $sql .=
" WHERE fk_adherent = ".((int) $this->
id);
1032 $sql .=
" ORDER by dateadh DESC";
1034 dol_syslog(get_class($this).
"::update_end_date", LOG_DEBUG);
1035 $resql = $this->db->query($sql);
1037 $obj = $this->db->fetch_object($resql);
1038 $dateop = $this->db->jdate($obj->dateop);
1039 $datedeb = $this->db->jdate($obj->datedeb);
1040 $datefin = $this->db->jdate($obj->datefin);
1042 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
1043 $sql .=
" datefin=".($datefin !=
'' ?
"'".$this->db->idate($datefin).
"'" :
"null");
1044 $sql .=
" WHERE rowid = ".((int) $this->
id);
1046 dol_syslog(get_class($this).
"::update_end_date", LOG_DEBUG);
1047 $resql = $this->db->query($sql);
1049 $this->last_subscription_date = $dateop;
1050 $this->last_subscription_date_start = $datedeb;
1051 $this->last_subscription_date_end = $datefin;
1052 $this->datefin = $datefin;
1053 $this->db->commit();
1056 $this->db->rollback();
1060 $this->error = $this->db->lasterror();
1061 $this->db->rollback();
1073 public function delete($user, $notrigger = 0)
1084 if (!$error && !$notrigger) {
1094 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"categorie_member WHERE fk_member = ".((int) $rowid);
1095 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1096 $resql = $this->db->query($sql);
1099 $this->error .= $this->db->lasterror();
1105 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"subscription WHERE fk_adherent = ".((int) $rowid);
1106 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1107 $resql = $this->db->query($sql);
1110 $this->error .= $this->db->lasterror();
1120 $this->error .= $this->db->lasterror();
1131 dol_syslog(get_class($this).
"::delete erreur ".$errorflag.
" ".$this->error, LOG_ERR);
1137 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"adherent WHERE rowid = ".((int) $rowid);
1138 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1139 $resql = $this->db->query($sql);
1142 $this->error .= $this->db->lasterror();
1148 $this->db->commit();
1151 $this->db->rollback();
1167 public function setPassword($user, $password =
'', $isencrypted = 0, $notrigger = 0, $nosyncuser = 0)
1169 global $conf, $langs;
1173 dol_syslog(get_class($this).
"::setPassword user=".$user->id.
" password=".preg_replace(
'/./i',
'*', $password).
" isencrypted=".$isencrypted);
1177 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
1182 $password_crypted =
dol_hash($password);
1184 $password_indatabase =
'';
1185 if (!$isencrypted) {
1186 $password_indatabase = $password;
1192 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent";
1193 $sql .=
" SET pass_crypted = '".$this->db->escape($password_crypted).
"'";
1195 $sql .=
", pass = null";
1197 $sql .=
", pass = '".$this->db->escape($password_indatabase).
"'";
1199 $sql .=
" WHERE rowid = ".((int) $this->
id);
1202 dol_syslog(get_class($this).
"::setPassword", LOG_DEBUG);
1203 $result = $this->db->query($sql);
1205 $nbaffectedrows = $this->db->affected_rows($result);
1207 if ($nbaffectedrows) {
1208 $this->pass = $password;
1209 $this->pass_indatabase = $password_indatabase;
1210 $this->pass_indatabase_crypted = $password_crypted;
1212 if ($this->user_id && !$nosyncuser) {
1213 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
1217 $luser =
new User($this->db);
1218 $result = $luser->fetch($this->user_id);
1221 $result = $luser->setPassword($user, $this->pass, 0, 0, 1);
1222 if (is_int($result) && $result < 0) {
1223 $this->error = $luser->error;
1224 dol_syslog(get_class($this).
"::setPassword ".$this->error, LOG_ERR);
1228 $this->error = $luser->error;
1233 if (!$error && !$notrigger) {
1235 $result = $this->
call_trigger(
'MEMBER_NEW_PASSWORD', $user);
1238 $this->db->rollback();
1244 $this->db->commit();
1247 $this->db->rollback();
1251 $this->db->rollback();
1266 global $conf, $langs;
1271 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = NULL WHERE fk_member = ".((int) $this->
id);
1272 dol_syslog(get_class($this).
"::setUserId", LOG_DEBUG);
1273 $resql = $this->db->query($sql);
1275 $this->error = $this->db->error();
1276 $this->db->rollback();
1282 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = ".((int) $this->
id);
1283 $sql .=
" WHERE rowid = ".((int) $userid);
1284 dol_syslog(get_class($this).
"::setUserId", LOG_DEBUG);
1285 $resql = $this->db->query($sql);
1287 $this->error = $this->db->error();
1288 $this->db->rollback();
1293 $this->db->commit();
1307 global $conf, $langs;
1312 if ($thirdpartyid > 0) {
1313 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET fk_soc = null";
1314 $sql .=
" WHERE fk_soc = ".((int) $thirdpartyid);
1315 $sql .=
" AND entity = ".$conf->entity;
1316 dol_syslog(get_class($this).
"::setThirdPartyId", LOG_DEBUG);
1317 $resql = $this->db->query($sql);
1321 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET fk_soc = ".($thirdpartyid > 0 ? (int) $thirdpartyid :
'null');
1322 $sql .=
" WHERE rowid = ".((int) $this->
id);
1324 dol_syslog(get_class($this).
"::setThirdPartyId", LOG_DEBUG);
1325 $resql = $this->db->query($sql);
1327 $this->db->commit();
1330 $this->error = $this->db->error();
1331 $this->db->rollback();
1349 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"adherent";
1350 $sql .=
" WHERE login='".$this->db->escape($login).
"'";
1351 $sql .=
" AND entity = ".$conf->entity;
1353 $resql = $this->db->query($sql);
1355 if ($this->db->num_rows($resql)) {
1356 $obj = $this->db->fetch_object($resql);
1357 $this->
fetch($obj->rowid);
1377 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"adherent";
1378 $sql .=
" WHERE firstname='".$this->db->escape($firstname).
"'";
1379 $sql .=
" AND lastname='".$this->db->escape($lastname).
"'";
1380 $sql .=
" AND entity = ".$conf->entity;
1382 $resql = $this->db->query($sql);
1384 if ($this->db->num_rows($resql)) {
1385 $obj = $this->db->fetch_object($resql);
1386 $this->
fetch($obj->rowid);
1404 public function fetch($rowid, $ref =
'', $fk_soc = 0, $ref_ext =
'', $fetch_optionals =
true, $fetch_subscriptions =
true)
1408 $sql =
"SELECT d.rowid, d.ref, d.ref_ext, d.civility as civility_code, d.gender, d.firstname, d.lastname,";
1409 $sql .=
" d.societe as company, d.fk_soc, d.statut, d.public, d.address, d.zip, d.town, d.note_private,";
1410 $sql .=
" d.note_public,";
1411 $sql .=
" d.email, d.url, d.socialnetworks, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass, d.pass_crypted,";
1412 $sql .=
" d.photo, d.fk_adherent_type, d.morphy, d.entity,";
1413 $sql .=
" d.datec as datec,";
1414 $sql .=
" d.tms as datem,";
1415 $sql .=
" d.datefin as datefin, d.default_lang,";
1416 $sql .=
" d.birth as birthday,";
1417 $sql .=
" d.datevalid as datev,";
1418 $sql .=
" d.country,";
1419 $sql .=
" d.state_id,";
1420 $sql .=
" d.model_pdf,";
1421 $sql .=
" c.rowid as country_id, c.code as country_code, c.label as country,";
1422 $sql .=
" dep.nom as state, dep.code_departement as state_code,";
1423 $sql .=
" t.libelle as type, t.subscription as subscription,";
1424 $sql .=
" u.rowid as user_id, u.login as user_login";
1425 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent_type as t, ".MAIN_DB_PREFIX.
"adherent as d";
1426 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as c ON d.country = c.rowid";
1427 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as dep ON d.state_id = dep.rowid";
1428 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON d.rowid = u.fk_member";
1429 $sql .=
" WHERE d.fk_adherent_type = t.rowid";
1431 $sql .=
" AND d.rowid=".((int) $rowid);
1432 } elseif ($ref || $fk_soc) {
1433 $sql .=
" AND d.entity IN (".getEntity(
'adherent').
")";
1435 $sql .=
" AND d.ref='".$this->db->escape($ref).
"'";
1436 } elseif ($fk_soc > 0) {
1437 $sql .=
" AND d.fk_soc=".((int) $fk_soc);
1439 } elseif ($ref_ext) {
1440 $sql .=
" AND d.ref_ext='".$this->db->escape($ref_ext).
"'";
1443 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
1444 $resql = $this->db->query($sql);
1446 if ($this->db->num_rows($resql)) {
1447 $obj = $this->db->fetch_object($resql);
1449 $this->entity = $obj->entity;
1450 $this->
id = $obj->rowid;
1451 $this->
ref = $obj->ref;
1452 $this->ref_ext = $obj->ref_ext;
1454 $this->civility_id = $obj->civility_code;
1455 $this->civility_code = $obj->civility_code;
1456 $this->civility = $obj->civility_code ? ($langs->trans(
"Civility".$obj->civility_code) !=
"Civility".$obj->civility_code ? $langs->trans(
"Civility".$obj->civility_code) : $obj->civility_code) :
'';
1458 $this->firstname = $obj->firstname;
1459 $this->lastname = $obj->lastname;
1460 $this->gender = $obj->gender;
1461 $this->login = $obj->login;
1462 $this->societe = $obj->company;
1463 $this->company = $obj->company;
1464 $this->socid = $obj->fk_soc;
1465 $this->fk_soc = $obj->fk_soc;
1466 $this->
address = $obj->address;
1467 $this->zip = $obj->zip;
1468 $this->town = $obj->town;
1470 $this->pass = $obj->pass;
1471 $this->pass_indatabase = $obj->pass;
1472 $this->pass_indatabase_crypted = $obj->pass_crypted;
1474 $this->state_id = $obj->state_id;
1475 $this->state_code = $obj->state_id ? $obj->state_code :
'';
1476 $this->state = $obj->state_id ? $obj->state :
'';
1478 $this->country_id = $obj->country_id;
1479 $this->country_code = $obj->country_code;
1480 if ($langs->trans(
"Country".$obj->country_code) !=
"Country".$obj->country_code) {
1481 $this->country = $langs->transnoentitiesnoconv(
"Country".$obj->country_code);
1483 $this->country = $obj->country;
1486 $this->phone = $obj->phone;
1487 $this->phone_perso = $obj->phone_perso;
1488 $this->phone_mobile = $obj->phone_mobile;
1489 $this->
email = $obj->email;
1490 $this->url = $obj->url;
1492 $this->socialnetworks = ($obj->socialnetworks ? (array) json_decode($obj->socialnetworks,
true) : array());
1494 $this->photo = $obj->photo;
1495 $this->statut = $obj->statut;
1496 $this->
status = $obj->statut;
1497 $this->
public = $obj->public;
1499 $this->datec = $this->db->jdate($obj->datec);
1500 $this->date_creation = $this->db->jdate($obj->datec);
1501 $this->datem = $this->db->jdate($obj->datem);
1502 $this->date_modification = $this->db->jdate($obj->datem);
1503 $this->datefin = $this->db->jdate($obj->datefin);
1504 $this->datevalid = $this->db->jdate($obj->datev);
1505 $this->date_validation = $this->db->jdate($obj->datev);
1506 $this->birth = $this->db->jdate($obj->birthday);
1508 $this->default_lang = $obj->default_lang;
1510 $this->note_private = $obj->note_private;
1511 $this->note_public = $obj->note_public;
1512 $this->morphy = $obj->morphy;
1514 $this->
typeid = $obj->fk_adherent_type;
1515 $this->
type = $obj->type;
1516 $this->need_subscription = $obj->subscription;
1518 $this->user_id = $obj->user_id;
1519 $this->user_login = $obj->user_login;
1521 $this->model_pdf = $obj->model_pdf;
1525 if ($fetch_optionals) {
1530 if ($fetch_subscriptions) {
1539 $this->error = $this->db->lasterror();
1559 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
1561 $sql =
"SELECT c.rowid, c.fk_adherent, c.fk_type, c.subscription, c.note as note_public, c.fk_bank,";
1562 $sql .=
" c.tms as datem,";
1563 $sql .=
" c.datec as datec,";
1564 $sql .=
" c.dateadh as dateh,";
1565 $sql .=
" c.datef as datef";
1566 $sql .=
" FROM ".MAIN_DB_PREFIX.
"subscription as c";
1567 $sql .=
" WHERE c.fk_adherent = ".((int) $this->
id);
1568 $sql .=
" ORDER BY c.dateadh";
1569 dol_syslog(get_class($this).
"::fetch_subscriptions", LOG_DEBUG);
1571 $resql = $this->db->query($sql);
1573 $this->subscriptions = array();
1576 while ($obj = $this->db->fetch_object($resql)) {
1578 $this->first_subscription_date = $this->db->jdate($obj->datec);
1579 $this->first_subscription_date_start = $this->db->jdate($obj->dateh);
1580 $this->first_subscription_date_end = $this->db->jdate($obj->datef);
1581 $this->first_subscription_amount = $obj->subscription;
1583 $this->last_subscription_date = $this->db->jdate($obj->datec);
1584 $this->last_subscription_date_start = $this->db->jdate($obj->dateh);
1585 $this->last_subscription_date_end = $this->db->jdate($obj->datef);
1586 $this->last_subscription_amount = $obj->subscription;
1589 $subscription->id = $obj->rowid;
1590 $subscription->fk_adherent = $obj->fk_adherent;
1591 $subscription->fk_type = $obj->fk_type;
1592 $subscription->amount = $obj->subscription;
1593 $subscription->note = $obj->note_public;
1594 $subscription->note_public = $obj->note_public;
1595 $subscription->fk_bank = $obj->fk_bank;
1596 $subscription->datem = $this->db->jdate($obj->datem);
1597 $subscription->datec = $this->db->jdate($obj->datec);
1598 $subscription->dateh = $this->db->jdate($obj->dateh);
1599 $subscription->datef = $this->db->jdate($obj->datef);
1601 $this->subscriptions[] = $subscription;
1607 $this->error = $this->db->error().
' sql='.$sql;
1623 require_once DOL_DOCUMENT_ROOT.
'/partnership/class/partnership.class.php';
1626 $this->partnerships[] = array();
1647 public function subscription($date, $amount, $accountid = 0, $operation =
'', $label =
'', $num_chq =
'', $emetteur_nom =
'', $emetteur_banque =
'', $datesubend = 0, $fk_type =
null)
1649 global $conf, $langs, $user;
1651 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
1663 $datefin = $datesubend;
1672 $subscription->fk_adherent = $this->id;
1673 $subscription->dateh = $date;
1674 $subscription->datef = $datefin;
1675 $subscription->amount = $amount;
1676 $subscription->note = $label;
1677 $subscription->note_public = $label;
1678 $subscription->fk_type = $fk_type;
1680 $rowid = $subscription->create($user);
1687 $this->last_subscription_date =
dol_now();
1688 $this->last_subscription_date_start = $date;
1689 $this->last_subscription_date_end = $datefin;
1690 $this->last_subscription_amount = $amount;
1694 $this->db->commit();
1697 $this->db->rollback();
1702 $this->db->rollback();
1727 public function subscriptionComplementaryActions($subscriptionid, $option, $accountid, $datesubscription, $paymentdate, $operation, $label, $amount, $num_chq, $emetteur_nom =
'', $emetteur_banque =
'', $autocreatethirdparty = 0, $ext_payment_id =
'', $ext_payment_site =
'')
1729 global $conf, $langs, $user, $mysoc;
1733 $this->invoice =
null;
1735 dol_syslog(
"subscriptionComplementaryActions subscriptionid=".$subscriptionid.
" option=".$option.
" accountid=".$accountid.
" datesubscription=".$datesubscription.
" paymentdate=".
1736 $paymentdate.
" label=".$label.
" amount=".$amount.
" num_chq=".$num_chq.
" autocreatethirdparty=".$autocreatethirdparty);
1739 if ($option ==
'bankdirect' && $accountid) {
1740 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
1742 $acct =
new Account($this->db);
1743 $result = $acct->fetch($accountid);
1745 $dateop = $paymentdate;
1747 $insertid = $acct->addline($dateop, $operation, $label, $amount, $num_chq, 0, $user, $emetteur_nom, $emetteur_banque);
1748 if ($insertid > 0) {
1749 $inserturlid = $acct->add_url_line($insertid, $this->
id, DOL_URL_ROOT.
'/adherents/card.php?rowid=', $this->getFullName($langs),
'member');
1750 if ($inserturlid > 0) {
1752 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"subscription SET fk_bank=".((int) $insertid);
1753 $sql .=
" WHERE rowid=".((int) $subscriptionid);
1755 dol_syslog(
"subscription::subscription", LOG_DEBUG);
1756 $resql = $this->db->query($sql);
1759 $this->error = $this->db->lasterror();
1760 $this->errors[] = $this->error;
1773 if (($option ==
'bankviainvoice' && $accountid) || $option ==
'invoiceonly') {
1774 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1775 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/paymentterm.class.php';
1777 $invoice =
new Facture($this->db);
1778 $customer =
new Societe($this->db);
1781 if (!($this->fk_soc > 0)) {
1782 if ($autocreatethirdparty) {
1787 if ($this->morphy ==
'mor') {
1788 $companyname = $this->company;
1789 if (!empty($fullname)) {
1790 $companyalias = $fullname;
1793 $companyname = $fullname;
1794 if (!empty($this->company)) {
1795 $companyalias = $this->company;
1799 $result = $customer->create_from_member($this, $companyname, $companyalias);
1801 $this->error = $customer->error;
1802 $this->errors = $customer->errors;
1805 $this->fk_soc = $result;
1808 $langs->load(
"errors");
1809 $this->error = $langs->trans(
"ErrorMemberNotLinkedToAThirpartyLinkOrCreateFirst");
1810 $this->errors[] = $this->error;
1816 $result = $customer->fetch($this->fk_soc);
1818 $this->error = $customer->error;
1819 $this->errors = $customer->errors;
1827 $invoice->cond_reglement_id = $customer->cond_reglement_id;
1828 if (empty($invoice->cond_reglement_id)) {
1830 $invoice->cond_reglement_id = $paymenttermstatic->getDefaultId();
1831 if (empty($invoice->cond_reglement_id)) {
1833 $this->error =
'ErrorNoPaymentTermRECEPFound';
1834 $this->errors[] = $this->error;
1837 $invoice->socid = $this->fk_soc;
1842 $invoice->linked_objects[
'subscription'] = $subscriptionid;
1844 $invoice->linked_objects = array_merge($invoice->linked_objects,
GETPOST(
'other_linked_objects',
'array:int'));
1847 $result = $invoice->create($user);
1849 $this->error = $invoice->error;
1850 $this->errors = $invoice->errors;
1853 $this->invoice = $invoice;
1859 $idprodsubscription = 0;
1860 if (
getDolGlobalString(
'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS') && (isModEnabled(
"product") || isModEnabled(
"service"))) {
1865 if (
getDolGlobalString(
'ADHERENT_VAT_FOR_SUBSCRIPTIONS') ==
'defaultforfoundationcountry') {
1870 $result = $invoice->addline($label, 0, 1, $vattouse, 0, 0, $idprodsubscription, 0, $datesubscription,
'', 0, 0, 0,
'TTC', $amount, 1);
1872 $this->error = $invoice->error;
1873 $this->errors = $invoice->errors;
1880 $result = $invoice->validate($user);
1882 $this->error = $invoice->error;
1883 $this->errors = $invoice->errors;
1893 if (!$error && $option ==
'bankviainvoice' && $accountid) {
1894 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1895 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
1896 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions.lib.php';
1899 $amounts[$invoice->id] = (float)
price2num($amount);
1901 $paiement =
new Paiement($this->db);
1902 $paiement->datepaye = $paymentdate;
1903 $paiement->amounts = $amounts;
1904 $paiement->paiementcode = $operation;
1905 $paiement->paiementid =
dol_getIdFromCode($this->db, $operation,
'c_paiement',
'code',
'id', 1);
1906 $paiement->num_payment = $num_chq;
1907 $paiement->note_public = $label;
1908 $paiement->ext_payment_id = $ext_payment_id;
1909 $paiement->ext_payment_site = $ext_payment_site;
1913 $paiement_id = $paiement->create($user);
1914 if (!($paiement_id > 0)) {
1915 $this->error = $paiement->error;
1916 $this->errors = $paiement->errors;
1923 $bank_line_id = $paiement->addPaymentToBank($user,
'payment',
'(SubscriptionPayment)', $accountid, $emetteur_nom, $emetteur_banque);
1924 if (!($bank_line_id > 0)) {
1925 $this->error = $paiement->error;
1926 $this->errors = $paiement->errors;
1931 if (!$error && !empty($bank_line_id)) {
1933 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'subscription SET fk_bank='.((int) $bank_line_id);
1934 $sql .=
' WHERE rowid='.((int) $subscriptionid);
1936 $result = $this->db->query($sql);
1944 $invoice->setPaid($user);
1950 $outputlangs = $langs;
1952 $lang_id =
GETPOST(
'lang_id');
1953 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && !empty($lang_id)) {
1954 $newlang = $lang_id;
1957 $newlang = $customer->default_lang;
1959 if (!empty($newlang)) {
1960 $outputlangs =
new Translate(
"", $conf);
1961 $outputlangs->setDefaultLang($newlang);
1966 $invoice->generateDocument($invoice->model_pdf, $outputlangs);
1986 global $langs, $conf;
1992 if ($this->statut == self::STATUS_VALIDATED) {
1993 dol_syslog(get_class($this).
"::validate statut of member does not allow this", LOG_WARNING);
1999 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
2000 $sql .=
" statut = ".self::STATUS_VALIDATED;
2001 $sql .=
", datevalid = '".$this->db->idate($now).
"'";
2002 $sql .=
", fk_user_valid = ".((int) $user->id);
2003 $sql .=
" WHERE rowid = ".((int) $this->
id);
2005 dol_syslog(get_class($this).
"::validate", LOG_DEBUG);
2006 $result = $this->db->query($sql);
2011 $result = $this->
call_trigger(
'MEMBER_VALIDATE', $user);
2014 $this->db->rollback();
2019 $this->datevalid = $now;
2021 $this->db->commit();
2024 $this->error = $this->db->error();
2025 $this->db->rollback();
2039 global $langs, $conf;
2044 if ($this->statut == self::STATUS_RESILIATED) {
2045 dol_syslog(get_class($this).
"::resiliate statut of member does not allow this", LOG_WARNING);
2051 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
2052 $sql .=
" statut = ".self::STATUS_RESILIATED;
2053 $sql .=
", fk_user_valid=".$user->id;
2054 $sql .=
" WHERE rowid = ".((int) $this->
id);
2056 $result = $this->db->query($sql);
2061 $result = $this->
call_trigger(
'MEMBER_RESILIATE', $user);
2064 $this->db->rollback();
2069 $this->db->commit();
2072 $this->error = $this->db->error();
2073 $this->db->rollback();
2092 if ($this->statut == self::STATUS_EXCLUDED) {
2093 dol_syslog(get_class($this).
"::resiliate statut of member does not allow this", LOG_WARNING);
2099 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
2100 $sql .=
" statut = ".self::STATUS_EXCLUDED;
2101 $sql .=
", fk_user_valid=".$user->id;
2102 $sql .=
" WHERE rowid = ".((int) $this->
id);
2104 $result = $this->db->query($sql);
2109 $result = $this->
call_trigger(
'MEMBER_EXCLUDE', $user);
2112 $this->db->rollback();
2117 $this->db->commit();
2120 $this->error = $this->db->error();
2121 $this->db->rollback();
2137 include_once DOL_DOCUMENT_ROOT.
'/mailmanspip/class/mailmanspip.class.php';
2144 $result = $mailmanspip->add_to_mailman($this);
2147 if (!empty($mailmanspip->error)) {
2148 $this->errors[] = $mailmanspip->error;
2152 foreach ($mailmanspip->mladded_ko as $tmplist => $tmpemail) {
2153 $langs->load(
"errors");
2154 $this->errors[] = $langs->trans(
"ErrorFailedToAddToMailmanList", $tmpemail, $tmplist);
2156 foreach ($mailmanspip->mladded_ok as $tmplist => $tmpemail) {
2157 $langs->load(
"mailmanspip");
2158 $this->mesgs[] = $langs->trans(
"SuccessToAddToMailmanList", $tmpemail, $tmplist);
2164 $result = $mailmanspip->add_to_spip($this);
2166 $this->errors[] = $mailmanspip->error;
2187 global $conf, $langs;
2189 include_once DOL_DOCUMENT_ROOT.
'/mailmanspip/class/mailmanspip.class.php';
2196 $result = $mailmanspip->del_to_mailman($this);
2198 if (!empty($mailmanspip->error)) {
2199 $this->errors[] = $mailmanspip->error;
2204 foreach ($mailmanspip->mlremoved_ko as $tmplist => $tmpemail) {
2205 $langs->load(
"errors");
2206 $this->errors[] = $langs->trans(
"ErrorFailedToRemoveToMailmanList", $tmpemail, $tmplist);
2208 foreach ($mailmanspip->mlremoved_ok as $tmplist => $tmpemail) {
2209 $langs->load(
"mailmanspip");
2210 $this->mesgs[] = $langs->trans(
"SuccessToRemoveToMailmanList", $tmpemail, $tmplist);
2215 $result = $mailmanspip->del_to_spip($this);
2217 $this->errors[] = $mailmanspip->error;
2238 $langs->load(
"dict");
2240 $code = (empty($this->civility_id) ?
'' : $this->civility_id);
2244 return $langs->getLabelFromKey($this->db,
"Civility".$code,
"c_civility",
"code",
"label", $code);
2257 $langs->loadLangs([
'members',
'companies']);
2258 $nofetch = !empty($params[
'nofetch']);
2263 $langs->load(
"users");
2264 return [
'optimize' => $langs->trans(
"ShowUser")];
2266 if (!empty($this->photo)) {
2267 $photo =
'<div class="photointooltip floatright">';
2268 $photo .=
Form::showphoto(
'memberphoto', $this, 80, 0, 0,
'photoref photowithmargin photologintooltip',
'small', 0, 1);
2270 $datas[
'photo'] = $photo;
2273 $datas[
'divopen'] =
'<div class="centpercent">';
2274 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <u class="paddingrightonly">'.$langs->trans(
"Member").
'</u> '.$this->
getLibStatut(4);
2275 if (!empty($this->morphy)) {
2276 $datas[
'picto'] .=
' ' . $this->
getmorphylib(
'', 1);
2278 if (!empty($this->
ref)) {
2279 $datas[
'ref'] =
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
2281 if (!empty($this->login)) {
2282 $datas[
'login'] =
'<br><b>'.$langs->trans(
'Login').
':</b> '.$this->login;
2284 if (!empty($this->firstname) || !empty($this->lastname)) {
2285 $datas[
'name'] =
'<br><b>'.$langs->trans(
'Name').
':</b> '.$this->
getFullName($langs);
2287 if (!empty($this->company)) {
2288 $datas[
'company'] =
'<br><b>'.$langs->trans(
'Company').
':</b> '.$this->company;
2290 if (!empty($this->
email)) {
2291 $datas[
'email'] =
'<br><b>'.$langs->trans(
"EMail").
':</b> '.$this->email;
2293 $datas[
'address'] =
'<br><b>'.$langs->trans(
"Address").
':</b> '.
dol_format_address($this, 1,
' ', $langs);
2295 if (isModEnabled(
'category') && !$nofetch) {
2296 require_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
2297 $form =
new Form($this->db);
2298 $datas[
'categories'] =
'<br>' . $form->showCategories($this->
id, Categorie::TYPE_MEMBER, 1);
2300 $datas[
'divclose'] =
'</div>';
2318 public function getNomUrl($withpictoimg = 0, $maxlen = 0, $option =
'card', $mode =
'', $morecss =
'', $save_lastsearch_value = -1, $notooltip = 0, $addlinktonotes = 0)
2320 global $conf, $langs, $hookmanager;
2329 $classfortooltip =
'classfortooltip';
2333 'objecttype' => $this->element,
2334 'option' => $option,
2338 $classfortooltip =
'classforajaxtooltip';
2339 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
2345 $url = DOL_URL_ROOT.
'/adherents/card.php?rowid='.((int) $this->
id);
2346 if ($option ==
'subscription') {
2347 $url = DOL_URL_ROOT.
'/adherents/subscription.php?rowid='.((int) $this->
id);
2350 if ($option !=
'nolink') {
2352 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
2353 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
2354 $add_save_lastsearch_values = 1;
2356 if ($add_save_lastsearch_values) {
2357 $url .=
'&save_lastsearch_values=1';
2361 $linkstart .=
'<a href="'.$url.
'"';
2363 if (empty($notooltip)) {
2365 $langs->load(
"users");
2366 $label = $langs->trans(
"ShowUser");
2367 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
2369 $linkclose .= ($label ?
' title="'.dol_escape_htmltag($label, 1).
'"' :
' title="tocomplete"');
2370 $linkclose .= $dataparams.
' class="'.$classfortooltip.($morecss ?
' '.$morecss :
'').
'"';
2373 $linkstart .= $linkclose.
'>';
2376 $result .= $linkstart;
2378 if ($withpictoimg) {
2379 $paddafterimage =
'';
2380 if (abs($withpictoimg) == 1 || abs($withpictoimg) == 4) {
2381 $morecss .=
' paddingrightonly';
2384 if ($withpictoimg > 0) {
2385 $picto =
'<span class="nopadding'.($morecss ?
' userimg'.$morecss :
'').
'">'.
img_object(
'',
'user', $paddafterimage.
' '.($notooltip ?
'' : $dataparams), 0, 0, $notooltip ? 0 : 1).
'</span>';
2388 $picto =
'<span class="nopadding'.($morecss ?
' userimg'.$morecss :
'').
'"'.($paddafterimage ?
' '.$paddafterimage :
'').
'>';
2389 $picto .=
Form::showphoto(
'memberphoto', $this, 0, 0, 0,
'userphoto'.(($withpictoimg == -3 || $withpictoimg == -4) ?
'small' :
''),
'mini', 0, 1);
2390 $picto .=
'</span>';
2394 if (($withpictoimg > -2 && $withpictoimg != 2) || $withpictoimg == -4) {
2396 $result .=
'<span class="nopadding valignmiddle'.((!isset($this->statut) || $this->statut) ?
'' :
' strikefordisabled').
2397 ($morecss ?
' usertext'.$morecss :
'').
'">';
2399 if ($mode ==
'login') {
2400 $result .=
dol_trunc($this->login, $maxlen);
2401 } elseif ($mode ==
'ref') {
2402 $result .= $this->ref;
2404 $result .= $this->
getFullName($langs, 0, ($mode ==
'firstname' ? 2 : ($mode ==
'lastname' ? 4 : -1)), $maxlen);
2407 $result .=
'</span>';
2411 $result .= $linkend;
2413 if ($addlinktonotes) {
2414 if ($this->note_private) {
2415 $notetoshow = $langs->trans(
"ViewPrivateNote").
':<br>'.
dol_string_nohtmltag($this->note_private, 1);
2416 $result .=
' <span class="note inline-block">';
2417 $result .=
'<a href="'.DOL_URL_ROOT.
'/adherents/note.php?id='.$this->
id.
'" class="classfortooltip" title="'.
dol_escape_htmltag($notetoshow).
'">';
2420 $result .=
'</span>';
2424 $hookmanager->initHooks(array($this->element .
'dao'));
2425 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
2426 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
2428 $result = $hookmanager->resPrint;
2430 $result .= $hookmanager->resPrint;
2443 return $this->
LibStatut($this->statut, $this->need_subscription, $this->datefin, $mode);
2456 public function LibStatut($status, $need_subscription, $date_end_subscription, $mode = 0)
2460 $langs->load(
"members");
2464 $labelStatusShort =
'';
2466 if ($status == self::STATUS_DRAFT) {
2467 $statusType =
'status0';
2468 $labelStatus = $langs->trans(
"MemberStatusDraft");
2469 $labelStatusShort = $langs->trans(
"MemberStatusDraftShort");
2470 } elseif ($status >= self::STATUS_VALIDATED) {
2471 if ($need_subscription === 0) {
2472 $statusType =
'status4';
2473 $labelStatus = $langs->trans(
"Validated").
' - '.$langs->trans(
"MemberStatusNoSubscription");
2474 $labelStatusShort = $langs->trans(
"MemberStatusNoSubscriptionShort");
2475 } elseif (!$date_end_subscription) {
2476 $statusType =
'status1';
2477 $labelStatus = $langs->trans(
"Validated").
' - '.$langs->trans(
"WaitingSubscription");
2478 $labelStatusShort = $langs->trans(
"WaitingSubscriptionShort");
2479 } elseif ($date_end_subscription <
dol_now()) {
2480 $statusType =
'status8';
2481 $labelStatus = $langs->trans(
"Validated").
' - '.$langs->trans(
"MemberStatusActiveLate");
2482 $labelStatusShort = $langs->trans(
"MemberStatusActiveLateShort");
2484 $statusType =
'status4';
2485 $labelStatus = $langs->trans(
"Validated").
' - '.$langs->trans(
"MemberStatusPaid");
2486 $labelStatusShort = $langs->trans(
"MemberStatusPaidShort");
2488 } elseif ($status == self::STATUS_RESILIATED) {
2489 $statusType =
'status6';
2490 $labelStatus = $langs->transnoentitiesnoconv(
"MemberStatusResiliated");
2491 $labelStatusShort = $langs->transnoentitiesnoconv(
"MemberStatusResiliatedShort");
2492 } elseif ($status == self::STATUS_EXCLUDED) {
2493 $statusType =
'status10';
2494 $labelStatus = $langs->transnoentitiesnoconv(
"MemberStatusExcluded");
2495 $labelStatusShort = $langs->transnoentitiesnoconv(
"MemberStatusExcludedShort");
2498 return dolGetStatus($labelStatus, $labelStatusShort,
'', $statusType, $mode);
2511 $this->nb = array();
2513 $sql =
"SELECT count(a.rowid) as nb";
2514 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as a";
2515 $sql .=
" WHERE a.statut > 0";
2516 $sql .=
" AND a.entity IN (".getEntity(
'adherent').
")";
2518 $resql = $this->db->query($sql);
2520 while ($obj = $this->db->fetch_object($resql)) {
2521 $this->nb[
"members"] = $obj->nb;
2523 $this->db->free($resql);
2527 $this->error = $this->db->error();
2543 global $conf, $langs;
2551 $sql =
"SELECT a.rowid, a.datefin, a.statut";
2552 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as a";
2553 $sql .=
", ".MAIN_DB_PREFIX.
"adherent_type as t";
2554 $sql .=
" WHERE a.fk_adherent_type = t.rowid";
2555 if ($mode ==
'expired') {
2556 $sql .=
" AND a.statut = ".self::STATUS_VALIDATED;
2557 $sql .=
" AND a.entity IN (".getEntity(
'adherent').
")";
2558 $sql .=
" AND ((a.datefin IS NULL or a.datefin < '".$this->db->idate($now).
"') AND t.subscription = '1')";
2559 } elseif ($mode ==
'shift') {
2560 $sql .=
" AND a.statut = ".self::STATUS_DRAFT;
2561 $sql .=
" AND a.entity IN (".getEntity(
'adherent').
")";
2564 $resql = $this->db->query($sql);
2566 $langs->load(
"members");
2573 if ($mode ==
'expired') {
2574 $warning_delay = $conf->adherent->subscription->warning_delay / 60 / 60 / 24;
2575 $label = $langs->trans(
"MembersWithSubscriptionToReceive");
2576 $labelShort = $langs->trans(
"MembersWithSubscriptionToReceiveShort");
2577 $url = DOL_URL_ROOT.
'/adherents/list.php?mainmenu=members&statut='.self::STATUS_VALIDATED.
'&filter=outofdate';
2578 } elseif ($mode ==
'shift') {
2579 $warning_delay = $conf->adherent->subscription->warning_delay / 60 / 60 / 24;
2580 $url = DOL_URL_ROOT.
'/adherents/list.php?mainmenu=members&statut='.
self::STATUS_DRAFT;
2581 $label = $langs->trans(
"MembersListToValid");
2582 $labelShort = $langs->trans(
"ToValidate");
2586 $response->warning_delay = $warning_delay;
2587 $response->label = $label;
2588 $response->labelShort = $labelShort;
2589 $response->url = $url;
2592 $adherentstatic =
new Adherent($this->db);
2594 while ($obj = $this->db->fetch_object($resql)) {
2595 $response->nbtodo++;
2597 $adherentstatic->datefin = $this->db->jdate($obj->datefin);
2598 $adherentstatic->statut = $obj->statut;
2600 if ($adherentstatic->hasDelay()) {
2601 $response->nbtodolate++;
2608 $this->error = $this->db->error();
2625 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams =
null)
2627 global $conf, $langs;
2629 $langs->load(
"orders");
2632 $modele =
'standard';
2634 if ($this->model_pdf) {
2635 $modele = $this->model_pdf;
2641 $modelpath =
"core/modules/member/doc/";
2643 return $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
2656 global $user, $langs;
2661 $this->
ref =
'ABC001';
2663 $this->specimen = 1;
2664 $this->civility_id =
'MR';
2665 $this->lastname =
'DOLIBARR';
2666 $this->firstname =
'SPECIMEN';
2667 $this->gender =
'man';
2668 $this->login =
'dolibspec';
2669 $this->pass =
'dolibspec';
2670 $this->company =
'Societe ABC';
2671 $this->
address =
'61 jump street';
2672 $this->zip =
'75000';
2673 $this->town =
'Paris';
2674 $this->country_id = 1;
2675 $this->country_code =
'FR';
2676 $this->country =
'France';
2677 $this->morphy =
'mor';
2678 $this->
email =
'specimen@specimen.com';
2679 $this->socialnetworks = array(
2680 'skype' =>
'skypepseudo',
2681 'twitter' =>
'twitterpseudo',
2682 'facebook' =>
'facebookpseudo',
2683 'linkedin' =>
'linkedinpseudo',
2685 $this->phone =
'0999999999';
2686 $this->phone_perso =
'0999999998';
2687 $this->phone_mobile =
'0999999997';
2688 $this->note_public =
'This is a public note';
2689 $this->note_private =
'This is a private note';
2690 $this->birth = $now;
2696 $this->datefin = $now;
2697 $this->datevalid = $now;
2698 $this->default_lang =
'';
2701 $this->
type =
'Type adherent';
2702 $this->need_subscription = 0;
2704 $this->first_subscription_date = $now;
2705 $this->first_subscription_date_start = $this->first_subscription_date;
2706 $this->first_subscription_date_end =
dol_time_plus_duree($this->first_subscription_date_start, 1,
'y');
2707 $this->first_subscription_amount = 10;
2709 $this->last_subscription_date = $this->first_subscription_date;
2710 $this->last_subscription_date_start = $this->first_subscription_date;
2711 $this->last_subscription_date_end =
dol_time_plus_duree($this->last_subscription_date_start, 1,
'y');
2712 $this->last_subscription_amount = 10;
2756 global $conf, $langs;
2760 $keymodified =
false;
2768 if ($this->morphy ==
'mor' && (empty($this->fullname) || $this->fullname == $this->company)) {
2769 $this->fullname = $this->company;
2770 $this->lastname = $this->company;
2775 'LDAP_MEMBER_FIELD_FULLNAME' =>
'fullname',
2776 'LDAP_MEMBER_FIELD_NAME' =>
'lastname',
2777 'LDAP_MEMBER_FIELD_LOGIN' =>
'login',
2778 'LDAP_MEMBER_FIELD_LOGIN_SAMBA' =>
'login',
2779 'LDAP_MEMBER_FIELD_MAIL' =>
'email'
2783 foreach ($ldapkey as $constname => $varname) {
2789 if (!empty($this->oldcopy) && $this->$varname != $this->oldcopy->$varname) {
2790 $keymodified =
true;
2816 foreach ($socialnetworks as $key => $value) {
2817 if ($this->socialnetworks[$value[
'label']] &&
getDolGlobalString(
'LDAP_MEMBER_FIELD_'.strtoupper($value[
'label']))) {
2818 $info[
getDolGlobalString(
'LDAP_MEMBER_FIELD_'.strtoupper($value[
'label']))] = $this->socialnetworks[$value[
'label']];
2845 if ($this->datefin &&
getDolGlobalString(
'LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION')) {
2850 if (!empty($this->pass)) {
2863 if ($this->pass_indatabase_crypted &&
getDolGlobalString(
'LDAP_MEMBER_FIELD_PASSWORD_CRYPTED')) {
2869 } elseif (!empty($this->pass_indatabase)) {
2881 if ($this->first_subscription_date &&
getDolGlobalString(
'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE')) {
2884 if (isset($this->first_subscription_amount) &&
getDolGlobalString(
'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT')) {
2885 $info[
getDolGlobalString(
'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT')] = $this->first_subscription_amount;
2887 if ($this->last_subscription_date &&
getDolGlobalString(
'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE')) {
2890 if (isset($this->last_subscription_amount) &&
getDolGlobalString(
'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT')) {
2891 $info[
getDolGlobalString(
'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT')] = $this->last_subscription_amount;
2906 $sql =
'SELECT a.rowid, a.datec as datec,';
2907 $sql .=
' a.datevalid as datev,';
2908 $sql .=
' a.tms as datem,';
2909 $sql .=
' a.fk_user_author, a.fk_user_valid, a.fk_user_mod';
2910 $sql .=
' FROM '.MAIN_DB_PREFIX.
'adherent as a';
2911 $sql .=
' WHERE a.rowid = '.((int) $id);
2913 dol_syslog(get_class($this).
"::info", LOG_DEBUG);
2914 $result = $this->db->query($sql);
2916 if ($this->db->num_rows($result)) {
2917 $obj = $this->db->fetch_object($result);
2919 $this->
id = $obj->rowid;
2921 $this->user_creation_id = $obj->fk_user_author;
2922 $this->user_validation_id = $obj->fk_user_valid;
2923 $this->user_modification_id = $obj->fk_user_mod;
2924 $this->date_creation = $this->db->jdate($obj->datec);
2925 $this->date_validation = $this->db->jdate($obj->datev);
2926 $this->date_modification = $this->db->jdate($obj->datem);
2929 $this->db->free($result);
2942 $sql =
"SELECT count(mc.email) as nb";
2943 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mailing_cibles as mc";
2944 $sql .=
" WHERE mc.email = '".$this->db->escape($this->
email).
"'";
2945 $sql .=
" AND mc.statut NOT IN (-1,0)";
2947 $resql = $this->db->query($sql);
2949 $obj = $this->db->fetch_object($resql);
2952 $this->db->free($resql);
2955 $this->error = $this->db->error();
2972 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
2973 return parent::setCategoriesCommon($categories, Categorie::TYPE_MEMBER);
2986 $tables = array(
'adherent');
3001 if ($this->statut != self::STATUS_VALIDATED) {
3004 if (!$this->datefin) {
3010 return $this->datefin < ($now - $conf->adherent->subscription->warning_delay);
3023 global $conf, $langs, $mysoc, $user;
3029 $blockingerrormsg =
'';
3031 if (!isModEnabled(
'member')) {
3032 $langs->load(
"agenda");
3033 $this->output = $langs->trans(
'ModuleNotEnabled', $langs->transnoentitiesnoconv(
"Adherent"));
3037 $langs->load(
"agenda");
3038 $this->output = $langs->trans(
'EventRemindersByEmailNotEnabled', $langs->transnoentitiesnoconv(
"Adherent"));
3046 $listofmembersok = array();
3047 $listofmembersko = array();
3049 $arraydaysbeforeend = explode(
';', $daysbeforeendlist);
3050 foreach ($arraydaysbeforeend as $daysbeforeend) {
3051 dol_syslog(__METHOD__.
' - Process delta = '.$daysbeforeend, LOG_DEBUG);
3053 if (!is_numeric($daysbeforeend)) {
3054 $blockingerrormsg =
"Value for delta is not a numeric value";
3060 $datetosearchfor =
dol_time_plus_duree(
dol_mktime(0, 0, 0, $tmp[
'mon'], $tmp[
'mday'], $tmp[
'year'],
'tzserver'), (
int) $daysbeforeend,
'd');
3062 $sql =
'SELECT rowid FROM '.MAIN_DB_PREFIX.
'adherent';
3063 $sql .=
" WHERE entity = ".((int) $conf->entity);
3064 $sql .=
" AND statut = 1";
3065 $sql .=
" AND datefin = '".$this->db->idate($datetosearchfor).
"'";
3068 $resql = $this->db->query($sql);
3070 $num_rows = $this->db->num_rows($resql);
3072 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
3073 $adherent =
new Adherent($this->db);
3074 $formmail =
new FormMail($this->db);
3077 while ($i < $num_rows) {
3078 $obj = $this->db->fetch_object($resql);
3080 $adherent->fetch($obj->rowid,
'', 0,
'',
true,
true);
3082 if (empty($adherent->email)) {
3084 $listofmembersko[$adherent->id] = $adherent->id;
3086 $adherent->fetch_thirdparty();
3089 $languagefromcountrycode =
getLanguageCodeFromCountryCode($adherent->country_code ? $adherent->country_code : $adherent->thirdparty->country_code);
3090 $languagecodeformember = (empty($adherent->thirdparty->default_lang) ? ($languagefromcountrycode ? $languagefromcountrycode : $mysoc->default_lang) : $adherent->thirdparty->default_lang);
3093 $outputlangs =
new Translate(
'', $conf);
3094 $outputlangs->setDefaultLang($languagecodeformember);
3095 $outputlangs->loadLangs(array(
"main",
"members"));
3096 dol_syslog(
"sendReminderForExpiredSubscription Language for member id ".$adherent->id.
" set to ".$outputlangs->defaultlang.
" mysoc->default_lang=".$mysoc->default_lang);
3098 $arraydefaultmessage =
null;
3101 if (!empty($labeltouse)) {
3102 $arraydefaultmessage = $formmail->getEMailTemplate($this->db,
'member', $user, $outputlangs, 0, 1, $labeltouse);
3105 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
3110 $subject =
make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs);
3111 $msg =
make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs);
3113 $to = $adherent->email;
3116 $trackid =
'mem'.$adherent->id;
3117 $moreinheader =
'X-Dolibarr-Info: sendReminderForExpiredSubscription'.
"\r\n";
3119 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
3120 $cmail =
new CMailFile($subject, $to, $from, $msg, array(), array(), array(), $cc,
'', 0, 1,
'',
'', $trackid, $moreinheader);
3121 $result = $cmail->sendfile();
3124 $this->error .= $cmail->error.
' ';
3125 if (!is_null($cmail->errors)) {
3126 $this->errors += $cmail->errors;
3129 $listofmembersko[$adherent->id] = $adherent->id;
3132 $listofmembersok[$adherent->id] = $adherent->id;
3138 $actioncode =
'EMAIL';
3149 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic').
": ".$subject);
3150 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody').
":");
3154 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
3159 $actioncomm->type_code =
'AC_OTH_AUTO';
3160 $actioncomm->code =
'AC_'.$actioncode;
3161 $actioncomm->label = $actionmsg2;
3162 $actioncomm->note_private = $actionmsg;
3163 $actioncomm->fk_project = 0;
3164 $actioncomm->datep = $now;
3165 $actioncomm->datef = $now;
3166 $actioncomm->percentage = -1;
3167 $actioncomm->socid = $adherent->thirdparty->id;
3168 $actioncomm->contact_id = 0;
3169 $actioncomm->authorid = $user->id;
3170 $actioncomm->userownerid = $user->id;
3172 $actioncomm->email_msgid = $cmail->msgid;
3173 $actioncomm->email_from = $from;
3174 $actioncomm->email_sender =
'';
3175 $actioncomm->email_to = $to;
3176 $actioncomm->email_tocc = $sendtocc;
3177 $actioncomm->email_tobcc = $sendtobcc;
3178 $actioncomm->email_subject = $subject;
3179 $actioncomm->errors_to =
'';
3181 $actioncomm->fk_element = $adherent->id;
3182 $actioncomm->elementid = $adherent->id;
3183 $actioncomm->elementtype = $adherent->element;
3185 $actioncomm->extraparams = $extraparams;
3187 $actioncomm->create($user);
3193 $this->error .=
"Can't find email template with label=".$labeltouse.
", to use for the reminding email ";
3196 $listofmembersko[$adherent->id] = $adherent->id;
3205 $this->error = $this->db->lasterror();
3210 if ($blockingerrormsg) {
3211 $this->error = $blockingerrormsg;
3214 $this->output =
'Found '.($nbok + $nbko).
' members to send reminder to.';
3215 $this->output .=
' Send email successfully to '.$nbok.
' members';
3216 if (is_array($listofmembersok)) {
3219 foreach ($listofmembersok as $idmember) {
3221 $listofids .=
', ...';
3224 if (empty($listofids)) {
3229 $listofids .= $idmember;
3236 $this->output .= ($listofids ?
' ids='.$listofids :
'');
3239 $this->output .=
' - Canceled for '.$nbko.
' member (no email or email sending error)';
3240 if (is_array($listofmembersko)) {
3243 foreach ($listofmembersko as $idmember) {
3245 $listofids .=
', ...';
3248 if (empty($listofids)) {
3253 $listofids .= $idmember;
3259 $this->output .= ($listofids ?
' ids='.$listofids :
'');
3276 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
3278 $return =
'<div class="box-flex-item box-flex-grow-zero">';
3279 $return .=
'<div class="info-box info-box-sm">';
3280 $return .=
'<span class="info-box-icon bg-infobox-action">';
3281 if (property_exists($this,
'photo') || !empty($this->photo)) {
3282 $return .=
Form::showphoto(
'memberphoto', $this, 0, 60, 0,
'photokanban photoref photowithmargin photologintooltip',
'small', 0, 1);
3286 $return .=
'</span>';
3287 $return .=
'<div class="info-box-content">';
3288 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this,
'getNomUrl') ? $this->
getNomUrl() : $this->ref).
'</span>';
3289 if ($selected >= 0) {
3290 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
3292 $return .=
'<br><span class="info-box-label paddingright">'.$this->getmorphylib(
'', 2).
'</span>';
3293 $return .=
'<span class="info-box-label opacitymedium">'.$this->type.
'</span>';
3295 if (method_exists($this,
'getLibStatut')) {
3296 $return .=
'<br><div class="info-box-status paddingtop">';
3297 $return .= $this->
LibStatut($this->
status, $this->need_subscription, $this->datefin, 5);
3298 $return .=
'</div>';
3300 $return .=
'</div>';
3301 $return .=
'</div>';
3302 $return .=
'</div>';
Class to manage bank accounts.
Class to manage agenda events (actions)
Class to manage members of a foundation.
setThirdPartyId($thirdpartyid)
Set link to a third party.
hasDelay()
Return if a member is late (subscription late) or not.
exclude($user)
Functiun to exclude (set adherent.status to -2) a member TODO A private note should be added to know ...
add_to_abo()
Function to add member into external tools mailing-list, spip, etc.
loadStateBoard()
Load indicators this->nb in state board.
sendReminderForExpiredSubscription($daysbeforeendlist='10')
Send reminders by emails before subscription end CAN BE A CRON TASK.
_load_ldap_dn($info, $mode=0)
Retourne chaine DN complete dans l'annuaire LDAP pour l'objet.
update($user, $notrigger=0, $nosyncuser=0, $nosyncuserpass=0, $nosyncthirdparty=0, $action='update')
Update a member in database (standard information and password)
setCategories($categories)
Sets object to supplied categories.
getTooltipContentArray($params)
getTooltipContentArray
getNbOfEMailings()
Return number of mass Emailing received by this member with its email.
update_end_date($user)
Update denormalized last subscription date.
static replaceThirdparty($db, $origin_id, $dest_id)
Function used to replace a thirdparty id with another one.
makeSubstitution($text)
Make substitution of tags into text with value of current object.
const STATUS_EXCLUDED
Excluded.
LibStatut($status, $need_subscription, $date_end_subscription, $mode=0)
Renvoi le libelle d'un statut donne.
fetch_name($firstname, $lastname)
Method to load member from its name.
initAsSpecimen()
Initialise an instance with random values.
fetch($rowid, $ref='', $fk_soc=0, $ref_ext='', $fetch_optionals=true, $fetch_subscriptions=true)
Load member from database.
del_to_abo()
Function to delete a member from external tools like mailing-list, spip, etc.
resiliate($user)
Fonction qui resilie un adherent.
getCivilityLabel()
Return civility label of a member.
getmorphylib($morphy='', $addbadge=0)
Return translated label by the nature of a adherent (physical or moral)
sendEmail($text, $subject, $filename_list=array(), $mimetype_list=array(), $mimefilename_list=array(), $addr_cc="", $addr_bcc="", $deliveryreceipt=0, $msgishtml=-1, $errors_to='', $moreinheader='')
Function sending an email to the current member with the text supplied in parameter.
fetchPartnerships($mode)
Function to get partnerships array.
load_board($user, $mode)
Load indicators for dashboard (this->nbtodo and this->nbtodolate)
setPassword($user, $password='', $isencrypted=0, $notrigger=0, $nosyncuser=0)
Change password of a user.
getKanbanView($option='', $arraydata=null)
Return clickable link of object (with eventually picto)
const STATUS_DRAFT
Draft status.
const STATUS_RESILIATED
Resiliated.
fetch_login($login)
Method to load member from its login.
create($user, $notrigger=0)
Create a member into database.
_load_ldap_info()
Initialise tableau info (tableau des attributes LDAP)
getLibStatut($mode=0)
Retourne le libelle du statut d'un adherent (brouillon, valide, resilie, exclu)
info($id)
Load type info information in the member object.
__construct($db)
Constructor.
subscription($date, $amount, $accountid=0, $operation='', $label='', $num_chq='', $emetteur_nom='', $emetteur_banque='', $datesubend=0, $fk_type=null)
Insert subscription into database and eventually add links to banks, mailman, etc....
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='')
Function sending an email to the current member with the text supplied in parameter.
getNomUrl($withpictoimg=0, $maxlen=0, $option='card', $mode='', $morecss='', $save_lastsearch_value=-1, $notooltip=0, $addlinktonotes=0)
Return clickable name (with picto eventually)
generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=null)
Create a document onto disk according to template module.
subscriptionComplementaryActions($subscriptionid, $option, $accountid, $datesubscription, $paymentdate, $operation, $label, $amount, $num_chq, $emetteur_nom='', $emetteur_banque='', $autocreatethirdparty=0, $ext_payment_id='', $ext_payment_site='')
Do complementary actions after subscription recording.
setUserId($userid)
Set link to a user.
const STATUS_VALIDATED
Validated status.
fetch_subscriptions()
Function to get member subscriptions data: subscriptions, first_subscription_date,...
validate($user)
Function that validate a member.
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
static getValidAddress($address, $format, $encode=0, $maxnumberofemail=0)
Return a formatted address string for SMTP protocol.
Parent class of all other business classes (invoices, contracts, proposals, orders,...
fetch_optionals($rowid=null, $optionsArray=null)
Function to get extra fields of an object into $this->array_options This method is in most cases call...
commonGenerateDocument($modelspath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams=null)
Common function for all objects extending CommonObject for generating documents.
setErrorsFromObject($object)
setErrorsFromObject
deleteExtraFields()
Delete all extra fields values for the current object.
static commonReplaceThirdparty(DoliDB $dbs, $origin_id, $dest_id, array $tables, $ignoreerrors=0)
Function used to replace a thirdparty id with another one.
insertExtraFields($trigger='', $userused=null)
Add/Update all extra fields values for the current object.
call_trigger($triggerName, $user)
Call trigger based on this instance.
Class to manage invoices.
const TYPE_STANDARD
Standard invoice.
Class to manage mailman and spip.
Class to manage payments of customer invoices.
Class to manage payment terms records in dictionary.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage subscriptions of foundation members.
Class to manage translations.
Class to manage Dolibarr users.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
getFullName($langs, $option=0, $nameorder=-1, $maxlen=0)
Return full name (civility+' '+name+' '+lastname)
setUpperOrLowerCase()
Set to upper or ucwords/lower if needed.
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as p label as s rowid as s nom as s email
Sender: Who sends the email ("Sender" has sent emails on behalf of "From").
clean_url($url, $http=1)
Clean an url string.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
getLanguageCodeFromCountryCode($countrycode)
Return default language from country code.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_format_address($object, $withcountry=0, $sep="\n", $outputlangs=null, $mode=0, $extralangcode='')
Return a formatted address (part address/zip/town/state) according to country rules.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
GETPOSTISARRAY($paramname, $method=0)
Return true if the parameter $paramname is submit from a POST OR GET as an array.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
dolGetFirstLetters($s, $nbofchar=1)
Return first letters of a strings.
dol_strtoupper($string, $encoding="UTF-8")
Convert a string to upper.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
getArrayOfSocialNetworks()
Get array of social network dictionary.
dol_textishtml($msg, $option=0)
Return if a text is a html content.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null, $include=null)
Return array of possible common substitutions.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that return vat rate of a product line (according to seller, buyer and product vat rate) VAT...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
div refaddress div address
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
getRandomPassword($generic=false, $replaceambiguouschars=null, $length=32)
Return a generated password using default module.
dolGetLdapPasswordHash($password, $type='md5')
Returns a specific ldap hash of a password.
dol_hash($chain, $type='0', $nosalt=0)
Returns a hash (non reversible encryption) of a string.