38 require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
40 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
51 public $element =
'member';
56 public $table_element =
'adherent';
62 public $ismultientitymanaged = 1;
67 public $picto =
'member';
85 public $pass_indatabase;
90 public $pass_indatabase_crypted;
152 public $socialnetworks;
196 public $phone_mobile;
256 public $need_subscription;
267 public $first_subscription_date;
269 public $first_subscription_amount;
271 public $last_subscription_date;
273 public $last_subscription_date_start;
275 public $last_subscription_date_end;
277 public $last_subscription_amount;
279 public $subscriptions = array();
284 public $partnerships = array();
300 public $fields = array(
301 'rowid' => array(
'type' =>
'integer',
'label' =>
'TechnicalID',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 10),
302 'ref' => array(
'type' =>
'varchar(30)',
'label' =>
'Ref',
'default' => 1,
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 12,
'index' => 1),
303 'entity' => array(
'type' =>
'integer',
'label' =>
'Entity',
'default' => 1,
'enabled' => 1,
'visible' => -2,
'notnull' => 1,
'position' => 15,
'index' => 1),
304 'ref_ext' => array(
'type' =>
'varchar(128)',
'label' =>
'Ref ext',
'enabled' => 1,
'visible' => 0,
'position' => 20),
305 'civility' => array(
'type' =>
'varchar(6)',
'label' =>
'Civility',
'enabled' => 1,
'visible' => -1,
'position' => 25),
306 'lastname' => array(
'type' =>
'varchar(50)',
'label' =>
'Lastname',
'enabled' => 1,
'visible' => -1,
'position' => 30,
'showoncombobox'=>1),
307 'firstname' => array(
'type' =>
'varchar(50)',
'label' =>
'Firstname',
'enabled' => 1,
'visible' => -1,
'position' => 35,
'showoncombobox'=>1),
308 'login' => array(
'type' =>
'varchar(50)',
'label' =>
'Login',
'enabled' => 1,
'visible' => -1,
'position' => 40),
309 'gender' => array(
'type' =>
'varchar(10)',
'label' =>
'Gender',
'enabled' => 1,
'visible' => -1,
'position' => 250),
310 'pass' => array(
'type' =>
'varchar(50)',
'label' =>
'Pass',
'enabled' => 1,
'visible' => -1,
'position' => 45),
311 'pass_crypted' => array(
'type' =>
'varchar(128)',
'label' =>
'Pass crypted',
'enabled' => 1,
'visible' => -1,
'position' => 50),
312 'fk_adherent_type' => array(
'type' =>
'integer',
'label' =>
'Fk adherent type',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 55),
313 'morphy' => array(
'type' =>
'varchar(3)',
'label' =>
'MorPhy',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 60),
314 'societe' => array(
'type' =>
'varchar(128)',
'label' =>
'Societe',
'enabled' => 1,
'visible' => -1,
'position' => 65,
'showoncombobox'=>2),
315 'fk_soc' => array(
'type' =>
'integer:Societe:societe/class/societe.class.php',
'label' =>
'ThirdParty',
'enabled' => 1,
'visible' => -1,
'position' => 70),
316 'address' => array(
'type' =>
'text',
'label' =>
'Address',
'enabled' => 1,
'visible' => -1,
'position' => 75),
317 'zip' => array(
'type' =>
'varchar(10)',
'label' =>
'Zip',
'enabled' => 1,
'visible' => -1,
'position' => 80),
318 'town' => array(
'type' =>
'varchar(50)',
'label' =>
'Town',
'enabled' => 1,
'visible' => -1,
'position' => 85),
319 'state_id' => array(
'type' =>
'integer',
'label' =>
'State id',
'enabled' => 1,
'visible' => -1,
'position' => 90),
320 'country' => array(
'type' =>
'integer:Ccountry:core/class/ccountry.class.php',
'label' =>
'Country',
'enabled' => 1,
'visible' => -1,
'position' => 95),
321 'email' => array(
'type' =>
'varchar(255)',
'label' =>
'Email',
'enabled' => 1,
'visible' => -1,
'position' => 100),
322 'url' =>array(
'type'=>
'varchar(255)',
'label'=>
'Url',
'enabled'=>1,
'visible'=>-1,
'position'=>110),
323 'socialnetworks' => array(
'type' =>
'text',
'label' =>
'Socialnetworks',
'enabled' => 1,
'visible' => -1,
'position' => 105),
324 'phone' => array(
'type' =>
'varchar(30)',
'label' =>
'Phone',
'enabled' => 1,
'visible' => -1,
'position' => 115),
325 'phone_perso' => array(
'type' =>
'varchar(30)',
'label' =>
'Phone perso',
'enabled' => 1,
'visible' => -1,
'position' => 120),
326 'phone_mobile' => array(
'type' =>
'varchar(30)',
'label' =>
'Phone mobile',
'enabled' => 1,
'visible' => -1,
'position' => 125),
327 'birth' => array(
'type' =>
'date',
'label' =>
'DateOfBirth',
'enabled' => 1,
'visible' => -1,
'position' => 130),
328 'photo' => array(
'type' =>
'varchar(255)',
'label' =>
'Photo',
'enabled' => 1,
'visible' => -1,
'position' => 135),
329 'public' => array(
'type' =>
'smallint(6)',
'label' =>
'Public',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 145),
330 'datefin' => array(
'type' =>
'datetime',
'label' =>
'DateEnd',
'enabled' => 1,
'visible' => -1,
'position' => 150),
331 'note_private' => array(
'type' =>
'text',
'label' =>
'NotePrivate',
'enabled' => 1,
'visible' => 0,
'position' => 155),
332 'note_public' => array(
'type' =>
'text',
'label' =>
'NotePublic',
'enabled' => 1,
'visible' => 0,
'position' => 160),
333 'datevalid' => array(
'type' =>
'datetime',
'label' =>
'DateValidation',
'enabled' => 1,
'visible' => -1,
'position' => 165),
334 'datec' => array(
'type' =>
'datetime',
'label' =>
'DateCreation',
'enabled' => 1,
'visible' => -1,
'position' => 170),
335 'tms' => array(
'type' =>
'timestamp',
'label' =>
'DateModification',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 175),
336 'fk_user_author' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'Fk user author',
'enabled' => 1,
'visible' => -1,
'position' => 180),
337 'fk_user_mod' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'Fk user mod',
'enabled' => 1,
'visible' => -1,
'position' => 185),
338 'fk_user_valid' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'UserValidation',
'enabled' => 1,
'visible' => -1,
'position' => 190),
339 'canvas' => array(
'type' =>
'varchar(32)',
'label' =>
'Canvas',
'enabled' => 1,
'visible' => -1,
'position' => 195),
340 'statut' => array(
'type' =>
'smallint(6)',
'label' =>
'Statut',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 500,
341 'arrayofkeyval' => array(-1 =>
'Draft', 1 =>
'Validated', 0 =>
'MemberStatusResiliatedShort', -2 =>
'MemberStatusExcludedShort')),
342 'model_pdf' => array(
'type' =>
'varchar(255)',
'label' =>
'Model pdf',
'enabled' => 1,
'visible' => 0,
'position' => 800),
343 'import_key' => array(
'type' =>
'varchar(14)',
'label' =>
'ImportId',
'enabled' => 1,
'visible' => -2,
'position' => 805)
373 $this->status = $this->statut;
377 $this->array_options = array();
398 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 =
'')
401 global $conf, $langs;
404 if ($msgishtml == -1) {
411 dol_syslog(
'send_an_email msgishtml='.$msgishtml);
420 $from = $conf->email_from;
421 if (!empty($conf->global->ADHERENT_MAIL_FROM)) {
422 $from = $conf->global->ADHERENT_MAIL_FROM;
425 $trackid =
'mem'.$this->id;
428 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
429 $mailfile =
new CMailFile($subjecttosend, $this->email, $from, $texttosend, $filename_list, $mimetype_list, $mimefilename_list, $addr_cc, $addr_bcc, $deliveryreceipt, $msgishtml,
'',
'', $trackid, $moreinheader);
430 if ($mailfile->sendfile()) {
433 $this->error = $langs->trans(
"ErrorFailedToSendMail", $from, $this->email).
'. '.$mailfile->error;
447 global $conf, $langs;
457 if ($this->civility_id) {
458 $infos .= $langs->transnoentities(
"UserTitle").
": ".$this->
getCivilityLabel().
"\n";
460 $infos .= $langs->transnoentities(
"id").
": ".$this->
id.
"\n";
461 $infos .= $langs->transnoentities(
"ref").
": ".$this->
ref.
"\n";
462 $infos .= $langs->transnoentities(
"Lastname").
": ".$this->lastname.
"\n";
463 $infos .= $langs->transnoentities(
"Firstname").
": ".$this->firstname.
"\n";
464 $infos .= $langs->transnoentities(
"Company").
": ".$this->company.
"\n";
465 $infos .= $langs->transnoentities(
"Address").
": ".$this->address.
"\n";
466 $infos .= $langs->transnoentities(
"Zip").
": ".$this->zip.
"\n";
467 $infos .= $langs->transnoentities(
"Town").
": ".$this->town.
"\n";
468 $infos .= $langs->transnoentities(
"Country").
": ".$this->country.
"\n";
469 $infos .= $langs->transnoentities(
"EMail").
": ".$this->email.
"\n";
470 $infos .= $langs->transnoentities(
"PhonePro").
": ".$this->phone.
"\n";
471 $infos .= $langs->transnoentities(
"PhonePerso").
": ".$this->phone_perso.
"\n";
472 $infos .= $langs->transnoentities(
"PhoneMobile").
": ".$this->phone_mobile.
"\n";
473 if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
474 $infos .= $langs->transnoentities(
"Login").
": ".$this->login.
"\n";
475 $infos .= $langs->transnoentities(
"Password").
": ".$this->pass.
"\n";
477 $infos .= $langs->transnoentities(
"Birthday").
": ".$birthday.
"\n";
478 $infos .= $langs->transnoentities(
"Photo").
": ".$this->photo.
"\n";
479 $infos .= $langs->transnoentities(
"Public").
": ".
yn($this->
public);
482 $substitutionarray = array(
483 '__ID__' => $this->
id,
484 '__REF__' => $this->
ref,
485 '__MEMBER_ID__' => $this->
id,
487 '__FIRSTNAME__' => $msgishtml ?
dol_htmlentitiesbr($this->firstname) : ($this->firstname ? $this->firstname :
''),
488 '__LASTNAME__' => $msgishtml ?
dol_htmlentitiesbr($this->lastname) : ($this->lastname ? $this->lastname :
''),
490 '__COMPANY__' => $msgishtml ?
dol_htmlentitiesbr($this->company) : ($this->company ? $this->company :
''),
491 '__ADDRESS__' => $msgishtml ?
dol_htmlentitiesbr($this->address) : ($this->address ? $this->address :
''),
492 '__ZIP__' => $msgishtml ?
dol_htmlentitiesbr($this->zip) : ($this->zip ? $this->zip :
''),
493 '__TOWN__' => $msgishtml ?
dol_htmlentitiesbr($this->town) : ($this->town ? $this->town :
''),
494 '__COUNTRY__' => $msgishtml ?
dol_htmlentitiesbr($this->country) : ($this->country ? $this->country :
''),
495 '__EMAIL__' => $msgishtml ?
dol_htmlentitiesbr($this->email) : ($this->email ? $this->email :
''),
496 '__BIRTH__' => $msgishtml ?
dol_htmlentitiesbr($birthday) : ($birthday ? $birthday :
''),
497 '__PHOTO__' => $msgishtml ?
dol_htmlentitiesbr($this->photo) : ($this->photo ? $this->photo :
''),
498 '__LOGIN__' => $msgishtml ?
dol_htmlentitiesbr($this->login) : ($this->login ? $this->login :
''),
499 '__PASSWORD__' => $msgishtml ?
dol_htmlentitiesbr($this->pass) : ($this->pass ? $this->pass :
''),
500 '__PHONE__' => $msgishtml ?
dol_htmlentitiesbr($this->phone) : ($this->phone ? $this->phone :
''),
501 '__PHONEPRO__' => $msgishtml ?
dol_htmlentitiesbr($this->phone_perso) : ($this->phone_perso ? $this->phone_perso :
''),
502 '__PHONEMOBILE__' => $msgishtml ?
dol_htmlentitiesbr($this->phone_mobile) : ($this->phone_mobile ? $this->phone_mobile :
''),
522 $morphy = $this->morphy;
524 if ($morphy ==
'phy') {
525 return $langs->trans(
"Physical");
527 if ($morphy ==
'mor') {
528 return $langs->trans(
"Moral");
540 public function create($user, $notrigger = 0)
542 global $conf, $langs;
549 $this->import_key = trim($this->import_key);
552 if (!empty($conf->global->ADHERENT_MAIL_REQUIRED) && !isValidEMail($this->email)) {
553 $langs->load(
"errors");
554 $this->error = $langs->trans(
"ErrorBadEMail", $this->email);
560 if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
561 if (empty($this->login)) {
562 $this->error = $langs->trans(
"ErrorWrongValueForParameterX",
"Login");
570 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"adherent";
571 $sql .=
" (ref, datec,login,fk_user_author,fk_user_mod,fk_user_valid,morphy,fk_adherent_type,entity,import_key)";
574 $sql .=
", '".$this->db->idate($this->datec).
"'";
575 $sql .=
", ".($this->login ?
"'".$this->db->escape($this->login).
"'" :
"null");
576 $sql .=
", ".($user->id > 0 ? $user->id :
"null");
577 $sql .=
", null, null, '".$this->db->escape($this->morphy).
"'";
578 $sql .=
", ".((int) $this->
typeid);
579 $sql .=
", ".$conf->entity;
580 $sql .=
", ".(!empty($this->import_key) ?
"'".$this->db->escape($this->import_key).
"'" :
"null");
583 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
584 $result = $this->
db->query($sql);
586 $id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
"adherent");
589 $this->
ref = (string) $id;
592 $result = $this->
update($user, 1, 1, 0, 0,
'add');
594 $this->
db->rollback();
599 if ($this->user_id) {
601 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET";
602 $sql .=
" fk_member = ".((int) $this->
id);
603 $sql .=
" WHERE rowid = ".((int) $this->user_id);
604 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
607 $this->error =
'Failed to update user to make link with member';
608 $this->
db->rollback();
622 if (count($this->errors)) {
623 dol_syslog(get_class($this).
"::create ".implode(
',', $this->errors), LOG_ERR);
624 $this->
db->rollback();
631 $this->error =
'Failed to get last insert id';
632 dol_syslog(get_class($this).
"::create ".$this->error, LOG_ERR);
633 $this->
db->rollback();
637 $this->error = $this->
db->error();
638 $this->
db->rollback();
655 public function update($user, $notrigger = 0, $nosyncuser = 0, $nosyncuserpass = 0, $nosyncthirdparty = 0, $action =
'update')
657 global $conf, $langs, $hookmanager;
659 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
664 dol_syslog(get_class($this).
"::update notrigger=".$notrigger.
", nosyncuser=".$nosyncuser.
", nosyncuserpass=".$nosyncuserpass.
" nosyncthirdparty=".$nosyncthirdparty.
", email=".$this->email);
667 $this->lastname = trim($this->lastname) ? trim($this->lastname) : trim($this->lastname);
668 $this->firstname = trim($this->firstname) ? trim($this->firstname) : trim($this->firstname);
669 $this->gender = trim($this->gender);
670 $this->address = ($this->address ? $this->address : $this->address);
671 $this->zip = ($this->zip ? $this->zip : $this->zip);
672 $this->town = ($this->town ? $this->town : $this->town);
673 $this->country_id = ($this->country_id > 0 ? $this->country_id : $this->country_id);
674 $this->state_id = ($this->state_id > 0 ? $this->state_id : $this->state_id);
676 $this->note_public = ($this->note_public ? $this->note_public : $this->note_public);
677 $this->note_private = ($this->note_private ? $this->note_private : $this->note_private);
678 $this->url = $this->url ?
clean_url($this->url, 0) :
'';
681 if (!empty($conf->global->ADHERENT_MAIL_REQUIRED) && !isValidEMail($this->email)) {
682 $langs->load(
"errors");
683 $this->error = $langs->trans(
"ErrorBadEMail", $this->email);
689 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
690 $sql .=
" ref = '".$this->db->escape($this->
ref).
"'";
691 $sql .=
", civility = ".($this->civility_id ?
"'".$this->db->escape($this->civility_id).
"'" :
"null");
692 $sql .=
", firstname = ".($this->firstname ?
"'".$this->db->escape($this->firstname).
"'" :
"null");
693 $sql .=
", lastname = ".($this->lastname ?
"'".$this->db->escape($this->lastname).
"'" :
"null");
694 $sql .=
", gender = ".($this->gender != -1 ?
"'".$this->db->escape($this->gender).
"'" :
"null");
695 $sql .=
", login = ".($this->login ?
"'".$this->db->escape($this->login).
"'" :
"null");
696 $sql .=
", societe = ".($this->company ?
"'".$this->db->escape($this->company).
"'" : ($this->societe ?
"'".$this->db->escape($this->societe).
"'" :
"null"));
698 $sql .=
", fk_soc = ".($this->socid > 0 ? $this->
db->escape($this->socid) :
"null");
700 $sql .=
", address = ".($this->address ?
"'".$this->db->escape($this->address).
"'" :
"null");
701 $sql .=
", zip = ".($this->zip ?
"'".$this->db->escape($this->zip).
"'" :
"null");
702 $sql .=
", town = ".($this->town ?
"'".$this->db->escape($this->town).
"'" :
"null");
703 $sql .=
", country = ".($this->country_id > 0 ? $this->
db->escape($this->country_id) :
"null");
704 $sql .=
", state_id = ".($this->state_id > 0 ? $this->
db->escape($this->state_id) :
"null");
705 $sql .=
", email = '".$this->db->escape($this->email).
"'";
706 $sql .=
", url = ".(!empty($this->url) ?
"'".$this->db->escape($this->url).
"'" :
"null");
707 $sql .=
", socialnetworks = ".($this->socialnetworks ?
"'".$this->db->escape(json_encode($this->socialnetworks)).
"'" :
"null");
708 $sql .=
", phone = ".($this->phone ?
"'".$this->db->escape($this->phone).
"'" :
"null");
709 $sql .=
", phone_perso = ".($this->phone_perso ?
"'".$this->db->escape($this->phone_perso).
"'" :
"null");
710 $sql .=
", phone_mobile = ".($this->phone_mobile ?
"'".$this->db->escape($this->phone_mobile).
"'" :
"null");
711 $sql .=
", note_private = ".($this->note_private ?
"'".$this->db->escape($this->note_private).
"'" :
"null");
712 $sql .=
", note_public = ".($this->note_public ?
"'".$this->db->escape($this->note_public).
"'" :
"null");
713 $sql .=
", photo = ".($this->photo ?
"'".$this->db->escape($this->photo).
"'" :
"null");
714 $sql .=
", public = '".$this->db->escape($this->
public).
"'";
715 $sql .=
", statut = ".$this->db->escape($this->statut);
716 $sql .=
", fk_adherent_type = ".$this->db->escape($this->
typeid);
717 $sql .=
", morphy = '".$this->db->escape($this->morphy).
"'";
718 $sql .=
", birth = ".($this->birth ?
"'".$this->db->idate($this->birth).
"'" :
"null");
719 if ($this->datefin) {
720 $sql .=
", datefin = '".$this->db->idate($this->datefin).
"'";
722 if ($this->datevalid) {
723 $sql .=
", datevalid = '".$this->db->idate($this->datevalid).
"'";
725 $sql .=
", fk_user_mod = ".($user->id > 0 ? $user->id :
'null');
726 $sql .=
" WHERE rowid = ".((int) $this->
id);
729 if (!empty($this->oldcopy) && $this->
typeid != $this->oldcopy->typeid) {
730 $sql2 =
"SELECT libelle as label";
731 $sql2 .=
" FROM ".MAIN_DB_PREFIX.
"adherent_type";
732 $sql2 .=
" WHERE rowid = ".((int) $this->
typeid);
733 $resql2 = $this->
db->query($sql2);
735 while ($obj = $this->
db->fetch_object($resql2)) {
736 $this->
type = $obj->label;
741 dol_syslog(get_class($this).
"::update update member", LOG_DEBUG);
744 unset($this->country_code);
745 unset($this->country);
746 unset($this->state_code);
749 $nbrowsaffected += $this->
db->affected_rows(
$resql);
762 if (!$error && $this->pass) {
763 dol_syslog(get_class($this).
"::update update password");
764 if ($this->pass != $this->pass_indatabase && $this->pass != $this->pass_indatabase_crypted) {
765 $isencrypted = empty($conf->global->DATABASE_PWD_ENCRYPTED) ? 0 : 1;
768 $result = $this->
setPassword($user, $this->pass, $isencrypted, $notrigger, $nosyncuserpass);
769 if (!$nbrowsaffected) {
777 dol_syslog(get_class($this).
"::update update link to user");
778 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = NULL WHERE fk_member = ".((int) $this->
id);
779 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
782 $this->error = $this->
db->error();
783 $this->
db->rollback();
787 if ($this->user_id > 0) {
788 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = ".((int) $this->
id).
" WHERE rowid = ".((int) $this->user_id);
789 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
792 $this->error = $this->
db->error();
793 $this->
db->rollback();
799 if (!$error && $nbrowsaffected) {
801 if (!$error && $this->user_id > 0 && !$nosyncuser) {
802 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
804 dol_syslog(get_class($this).
"::update update linked user");
806 $luser =
new User($this->
db);
807 $result = $luser->fetch($this->user_id);
814 if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
815 $luser->login = $this->login;
818 $luser->ref = $this->ref;
819 $luser->civility_id = $this->civility_id;
820 $luser->firstname = $this->firstname;
821 $luser->lastname = $this->lastname;
822 $luser->gender = $this->gender;
823 $luser->pass = $this->pass;
826 $luser->birth = $this->birth;
828 $luser->address = $this->address;
829 $luser->zip = $this->zip;
830 $luser->town = $this->town;
831 $luser->country_id = $this->country_id;
832 $luser->state_id = $this->state_id;
834 $luser->email = $this->email;
835 $luser->socialnetworks = $this->socialnetworks;
836 $luser->office_phone = $this->phone;
837 $luser->user_mobile = $this->phone_mobile;
839 $luser->fk_member = $this->id;
841 $result = $luser->update($user, 0, 1, 1);
843 $this->error = $luser->error;
844 dol_syslog(get_class($this).
"::update ".$this->error, LOG_ERR);
848 $this->error = $luser->error;
854 if (!$error && $this->fk_soc > 0 && !$nosyncthirdparty) {
855 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
857 dol_syslog(get_class($this).
"::update update linked thirdparty");
862 $result = $lthirdparty->fetch($this->fk_soc);
865 $lthirdparty->address = $this->address;
866 $lthirdparty->zip = $this->zip;
867 $lthirdparty->town = $this->town;
868 $lthirdparty->email = $this->email;
869 $lthirdparty->socialnetworks = $this->socialnetworks;
870 $lthirdparty->phone = $this->phone;
871 $lthirdparty->state_id = $this->state_id;
872 $lthirdparty->country_id = $this->country_id;
875 $result = $lthirdparty->update($this->fk_soc, $user, 0, 1, 1,
'update');
878 $this->error = $lthirdparty->error;
879 $this->errors = $lthirdparty->errors;
880 dol_syslog(get_class($this).
"::update ".$this->error, LOG_ERR);
883 } elseif ($result < 0) {
884 $this->error = $lthirdparty->error;
890 if (!$error && !$notrigger) {
901 return $nbrowsaffected;
903 $this->
db->rollback();
907 $this->
db->rollback();
908 $this->error = $this->
db->lasterror();
928 $sql =
"SELECT rowid, datec as dateop, dateadh as datedeb, datef as datefin";
929 $sql .=
" FROM ".MAIN_DB_PREFIX.
"subscription";
930 $sql .=
" WHERE fk_adherent = ".((int) $this->
id);
931 $sql .=
" ORDER by dateadh DESC";
933 dol_syslog(get_class($this).
"::update_end_date", LOG_DEBUG);
936 $obj = $this->
db->fetch_object(
$resql);
937 $dateop = $this->
db->jdate($obj->dateop);
938 $datedeb = $this->
db->jdate($obj->datedeb);
939 $datefin = $this->
db->jdate($obj->datefin);
941 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
942 $sql .=
" datefin=".($datefin !=
'' ?
"'".$this->db->idate($datefin).
"'" :
"null");
943 $sql .=
" WHERE rowid = ".((int) $this->
id);
945 dol_syslog(get_class($this).
"::update_end_date", LOG_DEBUG);
948 $this->last_subscription_date = $dateop;
949 $this->last_subscription_date_start = $datedeb;
950 $this->last_subscription_date_end = $datefin;
951 $this->datefin = $datefin;
955 $this->
db->rollback();
959 $this->error = $this->
db->lasterror();
960 $this->
db->rollback();
973 public function delete($rowid, $user, $notrigger = 0)
975 global $conf, $langs;
988 if (!$error && !$notrigger) {
998 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"categorie_member WHERE fk_member = ".((int) $rowid);
999 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1003 $this->error .= $this->
db->lasterror();
1009 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"subscription WHERE fk_adherent = ".((int) $rowid);
1010 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1014 $this->error .= $this->
db->lasterror();
1024 $this->error .= $this->
db->lasterror();
1035 dol_syslog(get_class($this).
"::delete erreur ".$errorflag.
" ".$this->error, LOG_ERR);
1041 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"adherent WHERE rowid = ".((int) $rowid);
1042 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1046 $this->error .= $this->
db->lasterror();
1052 $this->
db->commit();
1055 $this->
db->rollback();
1071 public function setPassword($user, $password =
'', $isencrypted = 0, $notrigger = 0, $nosyncuser = 0)
1073 global $conf, $langs;
1077 dol_syslog(get_class($this).
"::setPassword user=".$user->id.
" password=".preg_replace(
'/./i',
'*', $password).
" isencrypted=".$isencrypted);
1081 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
1086 $password_crypted =
dol_hash($password);
1088 $password_indatabase =
'';
1089 if (!$isencrypted) {
1090 $password_indatabase = $password;
1096 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent";
1097 $sql .=
" SET pass_crypted = '".$this->db->escape($password_crypted).
"'";
1100 $sql .=
", pass = null";
1102 $sql .=
", pass = '".$this->db->escape($password_indatabase).
"'";
1104 $sql .=
" WHERE rowid = ".((int) $this->
id);
1107 dol_syslog(get_class($this).
"::setPassword", LOG_DEBUG);
1108 $result = $this->
db->query($sql);
1110 $nbaffectedrows = $this->
db->affected_rows($result);
1112 if ($nbaffectedrows) {
1113 $this->pass = $password;
1114 $this->pass_indatabase = $password_indatabase;
1115 $this->pass_indatabase_crypted = $password_crypted;
1117 if ($this->user_id && !$nosyncuser) {
1118 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
1122 $luser =
new User($this->
db);
1123 $result = $luser->fetch($this->user_id);
1126 $result = $luser->setPassword($user, $this->pass, 0, 0, 1);
1128 $this->error = $luser->error;
1129 dol_syslog(get_class($this).
"::setPassword ".$this->error, LOG_ERR);
1133 $this->error = $luser->error;
1138 if (!$error && !$notrigger) {
1140 $result = $this->
call_trigger(
'MEMBER_NEW_PASSWORD', $user);
1143 $this->
db->rollback();
1149 $this->
db->commit();
1152 $this->
db->rollback();
1156 $this->
db->rollback();
1171 global $conf, $langs;
1176 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = NULL WHERE fk_member = ".((int) $this->
id);
1177 dol_syslog(get_class($this).
"::setUserId", LOG_DEBUG);
1180 $this->error = $this->
db->error();
1181 $this->
db->rollback();
1187 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = ".((int) $this->
id);
1188 $sql .=
" WHERE rowid = ".((int) $userid);
1189 dol_syslog(get_class($this).
"::setUserId", LOG_DEBUG);
1192 $this->error = $this->
db->error();
1193 $this->
db->rollback();
1198 $this->
db->commit();
1212 global $conf, $langs;
1217 if ($thirdpartyid > 0) {
1218 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET fk_soc = null";
1219 $sql .=
" WHERE fk_soc = ".((int) $thirdpartyid);
1220 $sql .=
" AND entity = ".$conf->entity;
1221 dol_syslog(get_class($this).
"::setThirdPartyId", LOG_DEBUG);
1226 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET fk_soc = ".($thirdpartyid > 0 ? $thirdpartyid :
'null');
1227 $sql .=
" WHERE rowid = ".((int) $this->
id);
1229 dol_syslog(get_class($this).
"::setThirdPartyId", LOG_DEBUG);
1232 $this->
db->commit();
1235 $this->error = $this->
db->error();
1236 $this->
db->rollback();
1254 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"adherent";
1255 $sql .=
" WHERE login='".$this->db->escape($login).
"'";
1256 $sql .=
" AND entity = ".$conf->entity;
1261 $obj = $this->
db->fetch_object(
$resql);
1262 $this->
fetch($obj->rowid);
1282 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"adherent";
1283 $sql .=
" WHERE firstname='".$this->db->escape($firstname).
"'";
1284 $sql .=
" AND lastname='".$this->db->escape($lastname).
"'";
1285 $sql .=
" AND entity = ".$conf->entity;
1290 $obj = $this->
db->fetch_object(
$resql);
1291 $this->
fetch($obj->rowid);
1309 public function fetch($rowid, $ref =
'', $fk_soc =
'', $ref_ext =
'', $fetch_optionals =
true, $fetch_subscriptions =
true)
1313 $sql =
"SELECT d.rowid, d.ref, d.ref_ext, d.civility as civility_code, d.gender, d.firstname, d.lastname,";
1314 $sql .=
" d.societe as company, d.fk_soc, d.statut, d.public, d.address, d.zip, d.town, d.note_private,";
1315 $sql .=
" d.note_public,";
1316 $sql .=
" d.email, d.url, d.socialnetworks, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass, d.pass_crypted,";
1317 $sql .=
" d.photo, d.fk_adherent_type, d.morphy, d.entity,";
1318 $sql .=
" d.datec as datec,";
1319 $sql .=
" d.tms as datem,";
1320 $sql .=
" d.datefin as datefin,";
1321 $sql .=
" d.birth as birthday,";
1322 $sql .=
" d.datevalid as datev,";
1323 $sql .=
" d.country,";
1324 $sql .=
" d.state_id,";
1325 $sql .=
" d.model_pdf,";
1326 $sql .=
" c.rowid as country_id, c.code as country_code, c.label as country,";
1327 $sql .=
" dep.nom as state, dep.code_departement as state_code,";
1328 $sql .=
" t.libelle as type, t.subscription as subscription,";
1329 $sql .=
" u.rowid as user_id, u.login as user_login";
1330 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent_type as t, ".MAIN_DB_PREFIX.
"adherent as d";
1331 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as c ON d.country = c.rowid";
1332 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as dep ON d.state_id = dep.rowid";
1333 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON d.rowid = u.fk_member";
1334 $sql .=
" WHERE d.fk_adherent_type = t.rowid";
1336 $sql .=
" AND d.rowid=".((int) $rowid);
1337 } elseif ($ref || $fk_soc) {
1338 $sql .=
" AND d.entity IN (".getEntity(
'adherent').
")";
1340 $sql .=
" AND d.ref='".$this->db->escape($ref).
"'";
1341 } elseif ($fk_soc > 0) {
1342 $sql .=
" AND d.fk_soc=".((int) $fk_soc);
1344 } elseif ($ref_ext) {
1345 $sql .=
" AND d.ref_ext='".$this->db->escape($ref_ext).
"'";
1348 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
1352 $obj = $this->
db->fetch_object(
$resql);
1354 $this->entity = $obj->entity;
1355 $this->
id = $obj->rowid;
1356 $this->
ref = $obj->ref;
1357 $this->ref_ext = $obj->ref_ext;
1359 $this->civility_id = $obj->civility_code;
1360 $this->civility_code = $obj->civility_code;
1361 $this->civility = $obj->civility_code ? ($langs->trans(
"Civility".$obj->civility_code) != (
"Civility".$obj->civility_code) ? $langs->trans(
"Civility".$obj->civility_code) : $obj->civility_code) :
'';
1363 $this->firstname = $obj->firstname;
1364 $this->lastname = $obj->lastname;
1365 $this->gender = $obj->gender;
1366 $this->login = $obj->login;
1367 $this->societe = $obj->company;
1368 $this->company = $obj->company;
1369 $this->socid = $obj->fk_soc;
1370 $this->fk_soc = $obj->fk_soc;
1371 $this->address = $obj->address;
1372 $this->zip = $obj->zip;
1373 $this->town = $obj->town;
1375 $this->pass = $obj->pass;
1376 $this->pass_indatabase = $obj->pass;
1377 $this->pass_indatabase_crypted = $obj->pass_crypted;
1379 $this->state_id = $obj->state_id;
1380 $this->state_code = $obj->state_id ? $obj->state_code :
'';
1381 $this->state = $obj->state_id ? $obj->state :
'';
1383 $this->country_id = $obj->country_id;
1384 $this->country_code = $obj->country_code;
1385 if ($langs->trans(
"Country".$obj->country_code) !=
"Country".$obj->country_code) {
1386 $this->country = $langs->transnoentitiesnoconv(
"Country".$obj->country_code);
1388 $this->country = $obj->country;
1391 $this->phone = $obj->phone;
1392 $this->phone_perso = $obj->phone_perso;
1393 $this->phone_mobile = $obj->phone_mobile;
1394 $this->email = $obj->email;
1395 $this->url = $obj->url;
1397 $this->socialnetworks = (array) json_decode($obj->socialnetworks,
true);
1399 $this->photo = $obj->photo;
1400 $this->statut = $obj->statut;
1401 $this->status = $obj->statut;
1402 $this->
public = $obj->public;
1404 $this->datec = $this->
db->jdate($obj->datec);
1405 $this->date_creation = $this->
db->jdate($obj->datec);
1406 $this->datem = $this->
db->jdate($obj->datem);
1407 $this->date_modification = $this->
db->jdate($obj->datem);
1408 $this->datefin = $this->
db->jdate($obj->datefin);
1409 $this->datevalid = $this->
db->jdate($obj->datev);
1410 $this->date_validation = $this->
db->jdate($obj->datev);
1411 $this->birth = $this->
db->jdate($obj->birthday);
1413 $this->note_private = $obj->note_private;
1414 $this->note_public = $obj->note_public;
1415 $this->morphy = $obj->morphy;
1417 $this->
typeid = $obj->fk_adherent_type;
1418 $this->
type = $obj->type;
1419 $this->need_subscription = $obj->subscription;
1421 $this->user_id = $obj->user_id;
1422 $this->user_login = $obj->user_login;
1424 $this->model_pdf = $obj->model_pdf;
1428 if ($fetch_optionals) {
1433 if ($fetch_subscriptions) {
1442 $this->error = $this->
db->lasterror();
1462 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
1464 $sql =
"SELECT c.rowid, c.fk_adherent, c.fk_type, c.subscription, c.note, c.fk_bank,";
1465 $sql .=
" c.tms as datem,";
1466 $sql .=
" c.datec as datec,";
1467 $sql .=
" c.dateadh as dateh,";
1468 $sql .=
" c.datef as datef";
1469 $sql .=
" FROM ".MAIN_DB_PREFIX.
"subscription as c";
1470 $sql .=
" WHERE c.fk_adherent = ".((int) $this->
id);
1471 $sql .=
" ORDER BY c.dateadh";
1472 dol_syslog(get_class($this).
"::fetch_subscriptions", LOG_DEBUG);
1476 $this->subscriptions = array();
1479 while ($obj = $this->
db->fetch_object(
$resql)) {
1481 $this->first_subscription_date = $this->
db->jdate($obj->datec);
1482 $this->first_subscription_date_start = $this->
db->jdate($obj->dateh);
1483 $this->first_subscription_date_end = $this->
db->jdate($obj->datef);
1484 $this->first_subscription_amount = $obj->subscription;
1486 $this->last_subscription_date = $this->
db->jdate($obj->datec);
1487 $this->last_subscription_date_start = $this->
db->jdate($obj->dateh);
1488 $this->last_subscription_date_end = $this->
db->jdate($obj->datef);
1489 $this->last_subscription_amount = $obj->subscription;
1492 $subscription->id = $obj->rowid;
1493 $subscription->fk_adherent = $obj->fk_adherent;
1494 $subscription->fk_type = $obj->fk_type;
1495 $subscription->amount = $obj->subscription;
1496 $subscription->note = $obj->note;
1497 $subscription->fk_bank = $obj->fk_bank;
1498 $subscription->datem = $this->
db->jdate($obj->datem);
1499 $subscription->datec = $this->
db->jdate($obj->datec);
1500 $subscription->dateh = $this->
db->jdate($obj->dateh);
1501 $subscription->datef = $this->
db->jdate($obj->datef);
1503 $this->subscriptions[] = $subscription;
1509 $this->error = $this->
db->error().
' sql='.$sql;
1525 require_once DOL_DOCUMENT_ROOT.
'/partnership/class/partnership.class.php';
1528 $this->partnerships[] = array();
1549 public function subscription($date, $amount, $accountid = 0, $operation =
'', $label =
'', $num_chq =
'', $emetteur_nom =
'', $emetteur_banque =
'', $datesubend = 0, $fk_type =
null)
1551 global $conf, $langs, $user;
1553 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
1565 $datefin = $datesubend;
1574 $subscription->fk_adherent = $this->id;
1575 $subscription->dateh = $date;
1576 $subscription->datef = $datefin;
1577 $subscription->amount = $amount;
1578 $subscription->note = $label;
1579 $subscription->note_public = $label;
1580 $subscription->fk_type = $fk_type;
1582 $rowid = $subscription->create($user);
1589 $this->last_subscription_date =
dol_now();
1590 $this->last_subscription_date_start = $date;
1591 $this->last_subscription_date_end = $datefin;
1592 $this->last_subscription_amount = $amount;
1596 $this->
db->commit();
1599 $this->
db->rollback();
1603 $this->error = $subscription->error;
1604 $this->errors = $subscription->errors;
1605 $this->
db->rollback();
1630 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 =
'')
1632 global $conf, $langs, $user, $mysoc;
1636 $this->invoice =
null;
1638 dol_syslog(
"subscriptionComplementaryActions subscriptionid=".$subscriptionid.
" option=".$option.
" accountid=".$accountid.
" datesubscription=".$datesubscription.
" paymentdate=".
1639 $paymentdate.
" label=".$label.
" amount=".$amount.
" num_chq=".$num_chq.
" autocreatethirdparty=".$autocreatethirdparty);
1642 if ($option ==
'bankdirect' && $accountid) {
1643 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
1646 $result = $acct->fetch($accountid);
1648 $dateop = $paymentdate;
1650 $insertid = $acct->addline($dateop, $operation, $label, $amount, $num_chq,
'', $user, $emetteur_nom, $emetteur_banque);
1651 if ($insertid > 0) {
1652 $inserturlid = $acct->add_url_line($insertid, $this->
id, DOL_URL_ROOT.
'/adherents/card.php?rowid=', $this->getFullname($langs),
'member');
1653 if ($inserturlid > 0) {
1655 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"subscription SET fk_bank=".((int) $insertid);
1656 $sql .=
" WHERE rowid=".((int) $subscriptionid);
1658 dol_syslog(
"subscription::subscription", LOG_DEBUG);
1662 $this->error = $this->
db->lasterror();
1663 $this->errors[] = $this->error;
1667 $this->error = $acct->error;
1668 $this->errors = $acct->errors;
1672 $this->error = $acct->error;
1673 $this->errors = $acct->errors;
1678 if (($option ==
'bankviainvoice' && $accountid) || $option ==
'invoiceonly') {
1679 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1680 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/paymentterm.class.php';
1686 if (!($this->fk_soc > 0)) {
1687 if ($autocreatethirdparty) {
1692 if ($this->morphy ==
'mor') {
1693 $companyname = $this->company;
1694 if (!empty($fullname)) {
1695 $companyalias = $fullname;
1698 $companyname = $fullname;
1699 if (!empty($this->company)) {
1700 $companyalias = $this->company;
1704 $result = $customer->create_from_member($this, $companyname, $companyalias);
1706 $this->error = $customer->error;
1707 $this->errors = $customer->errors;
1710 $this->fk_soc = $result;
1713 $langs->load(
"errors");
1714 $this->error = $langs->trans(
"ErrorMemberNotLinkedToAThirpartyLinkOrCreateFirst");
1715 $this->errors[] = $this->error;
1721 $result = $customer->fetch($this->fk_soc);
1723 $this->error = $customer->error;
1724 $this->errors = $customer->errors;
1732 $invoice->cond_reglement_id = $customer->cond_reglement_id;
1733 if (empty($invoice->cond_reglement_id)) {
1735 $invoice->cond_reglement_id = $paymenttermstatic->getDefaultId();
1736 if (empty($invoice->cond_reglement_id)) {
1738 $this->error =
'ErrorNoPaymentTermRECEPFound';
1739 $this->errors[] = $this->error;
1742 $invoice->socid = $this->fk_soc;
1747 $invoice->linked_objects[
'subscription'] = $subscriptionid;
1748 if (!empty($_POST[
'other_linked_objects']) && is_array($_POST[
'other_linked_objects'])) {
1749 $invoice->linked_objects = array_merge($invoice->linked_objects, $_POST[
'other_linked_objects']);
1752 $result = $invoice->create($user);
1754 $this->error = $invoice->error;
1755 $this->errors = $invoice->errors;
1758 $this->invoice = $invoice;
1764 $idprodsubscription = 0;
1765 if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) {
1766 $idprodsubscription = $conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS;
1770 if (isset($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) && $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS ==
'defaultforfoundationcountry') {
1774 $result = $invoice->addline($label, 0, 1, $vattouse, 0, 0, $idprodsubscription, 0, $datesubscription,
'', 0, 0,
'',
'TTC', $amount, 1);
1776 $this->error = $invoice->error;
1777 $this->errors = $invoice->errors;
1784 $result = $invoice->validate($user);
1786 $this->error = $invoice->error;
1787 $this->errors = $invoice->errors;
1797 if (!$error && $option ==
'bankviainvoice' && $accountid) {
1798 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1799 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
1800 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions.lib.php';
1803 $amounts[$invoice->id] =
price2num($amount);
1806 $paiement->datepaye = $paymentdate;
1807 $paiement->amounts = $amounts;
1808 $paiement->paiementcode = $operation;
1809 $paiement->paiementid =
dol_getIdFromCode($this->
db, $operation,
'c_paiement',
'code',
'id', 1);
1810 $paiement->num_payment = $num_chq;
1811 $paiement->note_public = $label;
1812 $paiement->ext_payment_id = $ext_payment_id;
1813 $paiement->ext_payment_site = $ext_payment_site;
1817 $paiement_id = $paiement->create($user);
1818 if (!($paiement_id > 0)) {
1819 $this->error = $paiement->error;
1820 $this->errors = $paiement->errors;
1827 $bank_line_id = $paiement->addPaymentToBank($user,
'payment',
'(SubscriptionPayment)', $accountid, $emetteur_nom, $emetteur_banque);
1828 if (!($bank_line_id > 0)) {
1829 $this->error = $paiement->error;
1830 $this->errors = $paiement->errors;
1835 if (!$error && !empty($bank_line_id)) {
1837 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'subscription SET fk_bank='.((int) $bank_line_id);
1838 $sql .=
' WHERE rowid='.((int) $subscriptionid);
1840 $result = $this->
db->query($sql);
1848 $invoice->setPaid($user);
1854 $outputlangs = $langs;
1856 $lang_id =
GETPOST(
'lang_id');
1857 if ($conf->global->MAIN_MULTILANGS && empty($newlang) && !empty($lang_id)) {
1858 $newlang = $lang_id;
1860 if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
1861 $newlang = $customer->default_lang;
1863 if (!empty($newlang)) {
1864 $outputlangs =
new Translate(
"", $conf);
1865 $outputlangs->setDefaultLang($newlang);
1870 $invoice->generateDocument($invoice->model_pdf, $outputlangs);
1890 global $langs, $conf;
1896 if ($this->statut == self::STATUS_VALIDATED) {
1897 dol_syslog(get_class($this).
"::validate statut of member does not allow this", LOG_WARNING);
1903 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
1904 $sql .=
" statut = ".self::STATUS_VALIDATED;
1905 $sql .=
", datevalid = '".$this->db->idate($now).
"'";
1906 $sql .=
", fk_user_valid = ".((int) $user->id);
1907 $sql .=
" WHERE rowid = ".((int) $this->
id);
1909 dol_syslog(get_class($this).
"::validate", LOG_DEBUG);
1910 $result = $this->
db->query($sql);
1915 $result = $this->
call_trigger(
'MEMBER_VALIDATE', $user);
1918 $this->
db->rollback();
1923 $this->datevalid = $now;
1925 $this->
db->commit();
1928 $this->error = $this->
db->error();
1929 $this->
db->rollback();
1943 global $langs, $conf;
1948 if ($this->statut == self::STATUS_RESILIATED) {
1949 dol_syslog(get_class($this).
"::resiliate statut of member does not allow this", LOG_WARNING);
1955 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
1956 $sql .=
" statut = ".self::STATUS_RESILIATED;
1957 $sql .=
", fk_user_valid=".$user->id;
1958 $sql .=
" WHERE rowid = ".((int) $this->
id);
1960 $result = $this->
db->query($sql);
1965 $result = $this->
call_trigger(
'MEMBER_RESILIATE', $user);
1968 $this->
db->rollback();
1973 $this->
db->commit();
1976 $this->error = $this->
db->error();
1977 $this->
db->rollback();
1993 global $langs, $conf;
1998 if ($this->statut == self::STATUS_EXCLUDED) {
1999 dol_syslog(get_class($this).
"::resiliate statut of member does not allow this", LOG_WARNING);
2005 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
2006 $sql .=
" statut = ".self::STATUS_EXCLUDED;
2007 $sql .=
", fk_user_valid=".$user->id;
2008 $sql .=
" WHERE rowid = ".((int) $this->
id);
2010 $result = $this->
db->query($sql);
2015 $result = $this->
call_trigger(
'MEMBER_EXCLUDE', $user);
2018 $this->
db->rollback();
2023 $this->
db->commit();
2026 $this->error = $this->
db->error();
2027 $this->
db->rollback();
2041 global $conf, $langs;
2043 include_once DOL_DOCUMENT_ROOT.
'/mailmanspip/class/mailmanspip.class.php';
2049 if (!empty($conf->global->ADHERENT_USE_MAILMAN) && !empty($conf->mailmanspip->enabled)) {
2050 $result = $mailmanspip->add_to_mailman($this);
2053 if (!empty($mailmanspip->error)) {
2054 $this->errors[] = $mailmanspip->error;
2058 foreach ($mailmanspip->mladded_ko as $tmplist => $tmpemail) {
2059 $langs->load(
"errors");
2060 $this->errors[] = $langs->trans(
"ErrorFailedToAddToMailmanList", $tmpemail, $tmplist);
2062 foreach ($mailmanspip->mladded_ok as $tmplist => $tmpemail) {
2063 $langs->load(
"mailmanspip");
2064 $this->mesgs[] = $langs->trans(
"SuccessToAddToMailmanList", $tmpemail, $tmplist);
2069 if (!empty($conf->global->ADHERENT_USE_SPIP) && !empty($conf->mailmanspip->enabled)) {
2070 $result = $mailmanspip->add_to_spip($this);
2072 $this->errors[] = $mailmanspip->error;
2093 global $conf, $langs;
2095 include_once DOL_DOCUMENT_ROOT.
'/mailmanspip/class/mailmanspip.class.php';
2101 if (!empty($conf->global->ADHERENT_USE_MAILMAN)) {
2102 $result = $mailmanspip->del_to_mailman($this);
2104 if (!empty($mailmanspip->error)) {
2105 $this->errors[] = $mailmanspip->error;
2110 foreach ($mailmanspip->mlremoved_ko as $tmplist => $tmpemail) {
2111 $langs->load(
"errors");
2112 $this->errors[] = $langs->trans(
"ErrorFailedToRemoveToMailmanList", $tmpemail, $tmplist);
2114 foreach ($mailmanspip->mlremoved_ok as $tmplist => $tmpemail) {
2115 $langs->load(
"mailmanspip");
2116 $this->mesgs[] = $langs->trans(
"SuccessToRemoveToMailmanList", $tmpemail, $tmplist);
2120 if ($conf->global->ADHERENT_USE_SPIP && !empty($conf->mailmanspip->enabled)) {
2121 $result = $mailmanspip->del_to_spip($this);
2123 $this->errors[] = $mailmanspip->error;
2144 $langs->load(
"dict");
2146 $code = (empty($this->civility_id) ?
'' : $this->civility_id);
2150 return $langs->getLabelFromKey($this->
db,
"Civility".$code,
"c_civility",
"code",
"label", $code);
2166 public function getNomUrl($withpictoimg = 0, $maxlen = 0, $option =
'card', $mode =
'', $morecss =
'', $save_lastsearch_value = -1, $notooltip = 0, $addlinktonotes = 0)
2168 global $conf, $langs, $hookmanager;
2170 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpictoimg) {
2179 if (!empty($this->photo)) {
2180 $label .=
'<div class="photointooltip floatright">';
2181 $label .=
Form::showphoto(
'memberphoto', $this, 80, 0, 0,
'photoref photowithmargin photologintooltip',
'small', 0, 1);
2186 $label .=
'<div class="centpercent">';
2187 $label .=
img_picto(
'', $this->picto).
' <u class="paddingrightonly">'.$langs->trans(
"Member").
'</u>';
2188 $label .=
' '.$this->getLibStatut(4);
2189 if (!empty($this->
ref)) {
2190 $label .=
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
2192 if (!empty($this->login)) {
2193 $label .=
'<br><b>'.$langs->trans(
'Login').
':</b> '.$this->login;
2195 if (!empty($this->firstname) || !empty($this->lastname)) {
2196 $label .=
'<br><b>'.$langs->trans(
'Name').
':</b> '.$this->
getFullName($langs);
2198 if (!empty($this->company)) {
2199 $label .=
'<br><b>'.$langs->trans(
'Company').
':</b> '.$this->company;
2203 $url = DOL_URL_ROOT.
'/adherents/card.php?rowid='.((int) $this->
id);
2204 if ($option ==
'subscription') {
2205 $url = DOL_URL_ROOT.
'/adherents/subscription.php?rowid='.((int) $this->
id);
2208 if ($option !=
'nolink') {
2210 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
2211 if ($save_lastsearch_value == -1 && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
2212 $add_save_lastsearch_values = 1;
2214 if ($add_save_lastsearch_values) {
2215 $url .=
'&save_lastsearch_values=1';
2219 $linkstart .=
'<a href="'.$url.
'"';
2221 if (empty($notooltip)) {
2222 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
2223 $langs->load(
"users");
2224 $label = $langs->trans(
"ShowUser");
2225 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
2227 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
2228 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
2231 $linkstart .= $linkclose.
'>';
2234 $result .= $linkstart;
2235 if ($withpictoimg) {
2236 $result .=
'<div class="inline-block nopadding valignmiddle">';
2238 if ($withpictoimg) {
2239 $paddafterimage =
'';
2240 if (abs($withpictoimg) == 1) {
2241 $paddafterimage =
'style="margin-right: 3px;"';
2244 if ($withpictoimg > 0) {
2245 $picto =
'<span class="nopadding'.($morecss ?
' userimg'.$morecss :
'').
'">'.
2246 img_object(
'',
'user', $paddafterimage.
' '.($notooltip ?
'' :
'class="classfortooltip"'), 0, 0, $notooltip ? 0 : 1).
'</span>';
2249 $picto =
'<span class="nopadding'.($morecss ?
' userimg'.$morecss :
'').
'"'.($paddafterimage ?
' '.$paddafterimage :
'').
'>';
2250 $picto .=
Form::showphoto(
'memberphoto', $this, 0, 0, 0,
'userphoto'.($withpictoimg == -3 ?
'small' :
''),
'mini', 0, 1);
2251 $picto .=
'</span>';
2255 if ($withpictoimg > -2 && $withpictoimg != 2) {
2256 if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
2257 $result .=
'<span class="nopadding valignmiddle'.((!isset($this->statut) || $this->statut) ?
'' :
' strikefordisabled').
2258 ($morecss ?
' usertext'.$morecss :
'').
'">';
2260 if ($mode ==
'login') {
2261 $result .=
dol_trunc($this->login, $maxlen);
2262 } elseif ($mode ==
'ref') {
2263 $result .= $this->ref;
2265 $result .= $this->
getFullName($langs,
'', ($mode ==
'firstname' ? 2 : ($mode ==
'lastname' ? 4 : -1)), $maxlen);
2267 if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
2268 $result .=
'</span>';
2271 if ($withpictoimg) {
2272 $result .=
'</div>';
2274 $result .= $linkend;
2276 if ($addlinktonotes) {
2277 if ($this->note_private) {
2278 $notetoshow = $langs->trans(
"ViewPrivateNote").
':<br>'.
dol_string_nohtmltag($this->note_private, 1);
2279 $result .=
' <span class="note inline-block">';
2280 $result .=
'<a href="'.DOL_URL_ROOT.
'/adherents/note.php?id='.$this->
id.
'" class="classfortooltip" title="'.
dol_escape_htmltag($notetoshow).
'">';
2283 $result .=
'</span>';
2287 $hookmanager->initHooks(array($this->element .
'dao'));
2288 $parameters = array(
'id'=>$this->
id,
'getnomurl' => &$result);
2289 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
2291 $result = $hookmanager->resPrint;
2293 $result .= $hookmanager->resPrint;
2306 return $this->
LibStatut($this->statut, $this->need_subscription, $this->datefin, $mode);
2319 public function LibStatut($status, $need_subscription, $date_end_subscription, $mode = 0)
2323 $langs->load(
"members");
2327 $labelStatusShort =
'';
2329 if ($status == self::STATUS_DRAFT) {
2330 $statusType =
'status0';
2331 $labelStatus = $langs->trans(
"MemberStatusDraft");
2332 $labelStatusShort = $langs->trans(
"MemberStatusDraftShort");
2333 } elseif ($status >= self::STATUS_VALIDATED) {
2334 if ($need_subscription === 0) {
2335 $statusType =
'status4';
2336 $labelStatus = $langs->trans(
"MemberStatusNoSubscription");
2337 $labelStatusShort = $langs->trans(
"MemberStatusNoSubscriptionShort");
2338 } elseif (!$date_end_subscription) {
2339 $statusType =
'status1';
2340 $labelStatus = $langs->trans(
"MemberStatusActive");
2341 $labelStatusShort = $langs->trans(
"MemberStatusActiveShort");
2342 } elseif ($date_end_subscription <
dol_now()) {
2343 $statusType =
'status3';
2344 $labelStatus = $langs->trans(
"MemberStatusActiveLate");
2345 $labelStatusShort = $langs->trans(
"MemberStatusActiveLateShort");
2347 $statusType =
'status4';
2348 $labelStatus = $langs->trans(
"MemberStatusPaid");
2349 $labelStatusShort = $langs->trans(
"MemberStatusPaidShort");
2351 } elseif ($status == self::STATUS_RESILIATED) {
2352 $statusType =
'status6';
2353 $labelStatus = $langs->transnoentitiesnoconv(
"MemberStatusResiliated");
2354 $labelStatusShort = $langs->transnoentitiesnoconv(
"MemberStatusResiliatedShort");
2355 } elseif ($status == self::STATUS_EXCLUDED) {
2356 $statusType =
'status10';
2357 $labelStatus = $langs->transnoentitiesnoconv(
"MemberStatusExcluded");
2358 $labelStatusShort = $langs->transnoentitiesnoconv(
"MemberStatusExcludedShort");
2361 return dolGetStatus($labelStatus, $labelStatusShort,
'', $statusType, $mode);
2376 $this->nb = array();
2378 $sql =
"SELECT count(a.rowid) as nb";
2379 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as a";
2380 $sql .=
" WHERE a.statut > 0";
2381 $sql .=
" AND a.entity IN (".getEntity(
'adherent').
")";
2385 while ($obj = $this->
db->fetch_object(
$resql)) {
2386 $this->nb[
"members"] = $obj->nb;
2392 $this->error = $this->
db->error();
2408 global $conf, $langs;
2416 $sql =
"SELECT a.rowid, a.datefin, a.statut";
2417 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as a";
2418 $sql .=
", ".MAIN_DB_PREFIX.
"adherent_type as t";
2419 $sql .=
" WHERE a.fk_adherent_type = t.rowid";
2420 if ($mode ==
'expired') {
2421 $sql .=
" AND a.statut = ".self::STATUS_VALIDATED;
2422 $sql .=
" AND a.entity IN (".getEntity(
'adherent').
")";
2423 $sql .=
" AND ((a.datefin IS NULL or a.datefin < '".$this->db->idate($now).
"') AND t.subscription = '1')";
2424 } elseif ($mode ==
'shift') {
2425 $sql .=
" AND a.statut = ".self::STATUS_DRAFT;
2426 $sql .=
" AND a.entity IN (".getEntity(
'adherent').
")";
2431 $langs->load(
"members");
2438 if ($mode ==
'expired') {
2439 $warning_delay = $conf->adherent->subscription->warning_delay / 60 / 60 / 24;
2440 $label = $langs->trans(
"MembersWithSubscriptionToReceive");
2441 $labelShort = $langs->trans(
"MembersWithSubscriptionToReceiveShort");
2442 $url = DOL_URL_ROOT.
'/adherents/list.php?mainmenu=members&statut='.self::STATUS_VALIDATED.
'&filter=outofdate';
2443 } elseif ($mode ==
'shift') {
2444 $warning_delay = $conf->adherent->subscription->warning_delay / 60 / 60 / 24;
2445 $url = DOL_URL_ROOT.
'/adherents/list.php?mainmenu=members&statut='.
self::STATUS_DRAFT;
2446 $label = $langs->trans(
"MembersListToValid");
2447 $labelShort = $langs->trans(
"ToValidate");
2451 $response->warning_delay = $warning_delay;
2452 $response->label = $label;
2453 $response->labelShort = $labelShort;
2454 $response->url = $url;
2459 while ($obj = $this->
db->fetch_object(
$resql)) {
2460 $response->nbtodo++;
2462 $adherentstatic->datefin = $this->
db->jdate($obj->datefin);
2463 $adherentstatic->statut = $obj->statut;
2465 if ($adherentstatic->hasDelay()) {
2466 $response->nbtodolate++;
2473 $this->error = $this->
db->error();
2490 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams =
null)
2492 global $conf, $langs;
2494 $langs->load(
"orders");
2497 $modele =
'standard';
2499 if ($this->model_pdf) {
2500 $modele = $this->model_pdf;
2501 } elseif (!empty($conf->global->ADHERENT_ADDON_PDF)) {
2502 $modele = $conf->global->ADHERENT_ADDON_PDF;
2506 $modelpath =
"core/modules/member/doc/";
2508 return $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
2521 global $user, $langs;
2526 $this->
ref =
'ABC001';
2528 $this->specimen = 1;
2529 $this->civility_id = 0;
2530 $this->lastname =
'DOLIBARR';
2531 $this->firstname =
'SPECIMEN';
2532 $this->gender =
'man';
2533 $this->login =
'dolibspec';
2534 $this->pass =
'dolibspec';
2535 $this->company =
'Societe ABC';
2536 $this->address =
'61 jump street';
2537 $this->zip =
'75000';
2538 $this->town =
'Paris';
2539 $this->country_id = 1;
2540 $this->country_code =
'FR';
2541 $this->country =
'France';
2542 $this->morphy =
'mor';
2543 $this->email =
'specimen@specimen.com';
2544 $this->socialnetworks = array(
2545 'skype' =>
'skypepseudo',
2546 'twitter' =>
'twitterpseudo',
2547 'facebook' =>
'facebookpseudo',
2548 'linkedin' =>
'linkedinpseudo',
2550 $this->phone =
'0999999999';
2551 $this->phone_perso =
'0999999998';
2552 $this->phone_mobile =
'0999999997';
2553 $this->note_public =
'This is a public note';
2554 $this->note_private =
'This is a private note';
2555 $this->birth = $now;
2560 $this->datefin = $now;
2561 $this->datevalid = $now;
2564 $this->
type =
'Type adherent';
2565 $this->need_subscription = 0;
2567 $this->first_subscription_date = $now;
2568 $this->first_subscription_date_start = $this->first_subscription_date;
2569 $this->first_subscription_date_end =
dol_time_plus_duree($this->first_subscription_date_start, 1,
'y');
2570 $this->first_subscription_amount = 10;
2572 $this->last_subscription_date = $this->first_subscription_date;
2573 $this->last_subscription_date_start = $this->first_subscription_date;
2574 $this->last_subscription_date_end =
dol_time_plus_duree($this->last_subscription_date_start, 1,
'y');
2575 $this->last_subscription_amount = 10;
2597 $dn = $conf->global->LDAP_KEY_MEMBERS.
"=".$info[$conf->global->LDAP_KEY_MEMBERS].
",".$conf->global->LDAP_MEMBER_DN;
2600 $dn = $conf->global->LDAP_MEMBER_DN;
2603 $dn = $conf->global->LDAP_KEY_MEMBERS.
"=".$info[$conf->global->LDAP_KEY_MEMBERS];
2619 global $conf, $langs;
2623 $keymodified =
false;
2626 $info[
"objectclass"] = explode(
',', $conf->global->LDAP_MEMBER_OBJECT_CLASS);
2631 if ($this->morphy ==
'mor' && (empty($this->fullname) || $this->fullname == $this->company)) {
2632 $this->fullname = $this->company;
2633 $this->lastname = $this->company;
2638 'LDAP_MEMBER_FIELD_FULLNAME' =>
'fullname',
2639 'LDAP_MEMBER_FIELD_NAME' =>
'lastname',
2640 'LDAP_MEMBER_FIELD_LOGIN' =>
'login',
2641 'LDAP_MEMBER_FIELD_LOGIN_SAMBA' =>
'login',
2642 'LDAP_MEMBER_FIELD_MAIL' =>
'email'
2646 foreach ($ldapkey as $constname => $varname) {
2647 if (!empty($this->$varname) && !empty($conf->global->$constname)) {
2648 $info[$conf->global->$constname] = $this->$varname;
2651 if (!empty($conf->global->LDAP_KEY_MEMBERS) && $conf->global->LDAP_KEY_MEMBERS == $conf->global->$constname) {
2652 if (!empty($this->oldcopy) && $this->$varname != $this->oldcopy->$varname) {
2653 $keymodified =
true;
2658 if ($this->firstname && !empty($conf->global->LDAP_MEMBER_FIELD_FIRSTNAME)) {
2659 $info[$conf->global->LDAP_MEMBER_FIELD_FIRSTNAME] = $this->firstname;
2661 if ($this->poste && !empty($conf->global->LDAP_MEMBER_FIELD_TITLE)) {
2662 $info[$conf->global->LDAP_MEMBER_FIELD_TITLE] = $this->poste;
2664 if ($this->company && !empty($conf->global->LDAP_MEMBER_FIELD_COMPANY)) {
2665 $info[$conf->global->LDAP_MEMBER_FIELD_COMPANY] = $this->company;
2667 if ($this->address && !empty($conf->global->LDAP_MEMBER_FIELD_ADDRESS)) {
2668 $info[$conf->global->LDAP_MEMBER_FIELD_ADDRESS] = $this->address;
2670 if ($this->zip && !empty($conf->global->LDAP_MEMBER_FIELD_ZIP)) {
2671 $info[$conf->global->LDAP_MEMBER_FIELD_ZIP] = $this->zip;
2673 if ($this->town && !empty($conf->global->LDAP_MEMBER_FIELD_TOWN)) {
2674 $info[$conf->global->LDAP_MEMBER_FIELD_TOWN] = $this->town;
2676 if ($this->country_code && !empty($conf->global->LDAP_MEMBER_FIELD_COUNTRY)) {
2677 $info[$conf->global->LDAP_MEMBER_FIELD_COUNTRY] = $this->country_code;
2679 foreach ($socialnetworks as $key => $value) {
2680 if ($this->socialnetworks[$value[
'label']] && !empty($conf->global->{
'LDAP_MEMBER_FIELD_'.strtoupper($value[
'label'])})) {
2681 $info[$conf->global->{
'LDAP_MEMBER_FIELD_'.strtoupper($value[
'label'])}] = $this->socialnetworks[$value[
'label']];
2684 if ($this->phone && !empty($conf->global->LDAP_MEMBER_FIELD_PHONE)) {
2685 $info[$conf->global->LDAP_MEMBER_FIELD_PHONE] = $this->phone;
2687 if ($this->phone_perso && !empty($conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO)) {
2688 $info[$conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO] = $this->phone_perso;
2690 if ($this->phone_mobile && !empty($conf->global->LDAP_MEMBER_FIELD_MOBILE)) {
2691 $info[$conf->global->LDAP_MEMBER_FIELD_MOBILE] = $this->phone_mobile;
2693 if ($this->fax && !empty($conf->global->LDAP_MEMBER_FIELD_FAX)) {
2694 $info[$conf->global->LDAP_MEMBER_FIELD_FAX] = $this->fax;
2696 if ($this->note_private && !empty($conf->global->LDAP_MEMBER_FIELD_DESCRIPTION)) {
2697 $info[$conf->global->LDAP_MEMBER_FIELD_DESCRIPTION] =
dol_string_nohtmltag($this->note_private, 2);
2699 if ($this->note_public && !empty($conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC)) {
2700 $info[$conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC] =
dol_string_nohtmltag($this->note_public, 2);
2702 if ($this->birth && !empty($conf->global->LDAP_MEMBER_FIELD_BIRTHDATE)) {
2703 $info[$conf->global->LDAP_MEMBER_FIELD_BIRTHDATE] =
dol_print_date($this->birth,
'dayhourldap');
2705 if (isset($this->statut) && !empty($conf->global->LDAP_FIELD_MEMBER_STATUS)) {
2706 $info[$conf->global->LDAP_FIELD_MEMBER_STATUS] = $this->statut;
2708 if ($this->datefin && !empty($conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION)) {
2709 $info[$conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION] =
dol_print_date($this->datefin,
'dayhourldap');
2713 if (!empty($this->pass)) {
2714 if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD)) {
2715 $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD] = $this->pass;
2717 if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) {
2718 $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] =
dol_hash($this->pass,
'openldap');
2720 } elseif ($conf->global->LDAP_SERVER_PROTOCOLVERSION !==
'3') {
2723 if (!empty($conf->global->DATABASE_PWD_ENCRYPTED)) {
2725 if (empty($conf->global->MAIN_SECURITY_HASH_ALGO)) {
2726 if ($this->pass_indatabase_crypted && !empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) {
2729 $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] =
dolGetLdapPasswordHash($this->pass_indatabase_crypted,
'md5frommd5');
2732 } elseif (!empty($this->pass_indatabase)) {
2734 if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD)) {
2735 $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD] = $this->pass_indatabase;
2737 if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) {
2738 $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] =
dol_hash($this->pass_indatabase,
'openldap');
2744 if ($this->first_subscription_date && !empty($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE)) {
2745 $info[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE] =
dol_print_date($this->first_subscription_date,
'dayhourldap');
2747 if (isset($this->first_subscription_amount) && !empty($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT)) {
2748 $info[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT] = $this->first_subscription_amount;
2750 if ($this->last_subscription_date && !empty($conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE)) {
2751 $info[$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE] =
dol_print_date($this->last_subscription_date,
'dayhourldap');
2753 if (isset($this->last_subscription_amount) && !empty($conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT)) {
2754 $info[$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT] = $this->last_subscription_amount;
2769 $sql =
'SELECT a.rowid, a.datec as datec,';
2770 $sql .=
' a.datevalid as datev,';
2771 $sql .=
' a.tms as datem,';
2772 $sql .=
' a.fk_user_author, a.fk_user_valid, a.fk_user_mod';
2773 $sql .=
' FROM '.MAIN_DB_PREFIX.
'adherent as a';
2774 $sql .=
' WHERE a.rowid = '.((int) $id);
2776 dol_syslog(get_class($this).
"::info", LOG_DEBUG);
2777 $result = $this->
db->query($sql);
2779 if ($this->
db->num_rows($result)) {
2780 $obj = $this->
db->fetch_object($result);
2781 $this->
id = $obj->rowid;
2783 $this->user_creation_id = $obj->fk_user_author;
2784 $this->user_validation_id = $obj->fk_user_valid;
2785 $this->user_modification_id = $obj->fk_user_mod;
2786 $this->date_creation = $this->
db->jdate($obj->datec);
2787 $this->date_validation = $this->
db->jdate($obj->datev);
2788 $this->date_modification = $this->
db->jdate($obj->datem);
2791 $this->
db->free($result);
2804 $sql =
"SELECT count(mc.email) as nb";
2805 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mailing_cibles as mc";
2806 $sql .=
" WHERE mc.email = '".$this->db->escape($this->email).
"'";
2807 $sql .=
" AND mc.statut NOT IN (-1,0)";
2811 $obj = $this->
db->fetch_object(
$resql);
2817 $this->error = $this->
db->error();
2834 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
2835 return parent::setCategoriesCommon($categories, Categorie::TYPE_MEMBER);
2848 $tables = array(
'adherent');
2863 if ($this->statut != self::STATUS_VALIDATED) {
2866 if (!$this->datefin) {
2872 return $this->datefin < ($now - $conf->adherent->subscription->warning_delay);
2885 global $conf, $langs, $mysoc, $user;
2891 $blockingerrormsg =
'';
2893 if (empty($conf->adherent->enabled)) {
2894 $langs->load(
"agenda");
2895 $this->output = $langs->trans(
'ModuleNotEnabled', $langs->transnoentitiesnoconv(
"Adherent"));
2898 if (empty($conf->global->MEMBER_REMINDER_EMAIL)) {
2899 $langs->load(
"agenda");
2900 $this->output = $langs->trans(
'EventRemindersByEmailNotEnabled', $langs->transnoentitiesnoconv(
"Adherent"));
2908 $listofmembersok = array();
2909 $listofmembersko = array();
2911 $arraydaysbeforeend = explode(
';', $daysbeforeendlist);
2912 foreach ($arraydaysbeforeend as $daysbeforeend) {
2913 dol_syslog(__METHOD__.
' - Process delta = '.$daysbeforeend, LOG_DEBUG);
2915 if (!is_numeric($daysbeforeend)) {
2916 $blockingerrormsg =
"Value for delta is not a numeric value";
2924 $sql =
'SELECT rowid FROM '.MAIN_DB_PREFIX.
'adherent';
2925 $sql .=
" WHERE entity = ".((int) $conf->entity);
2926 $sql .=
" AND datefin = '".$this->db->idate($datetosearchfor).
"'";
2931 $num_rows = $this->
db->num_rows(
$resql);
2933 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
2938 while ($i < $num_rows) {
2939 $obj = $this->
db->fetch_object(
$resql);
2941 $adherent->fetch($obj->rowid,
'',
'',
'',
true,
true);
2943 if (empty($adherent->email)) {
2945 $listofmembersko[$adherent->id] = $adherent->id;
2947 $adherent->fetch_thirdparty();
2950 $languagefromcountrycode =
getLanguageCodeFromCountryCode($adherent->country_code ? $adherent->country_code : $adherent->thirdparty->country_code);
2951 $languagecodeformember = (empty($adherent->thirdparty->default_lang) ? ($languagefromcountrycode ? $languagefromcountrycode : $mysoc->default_lang) : $adherent->thirdparty->default_lang);
2954 $outputlangs =
new Translate(
'', $conf);
2955 $outputlangs->setDefaultLang($languagecodeformember);
2956 $outputlangs->loadLangs(array(
"main",
"members"));
2957 dol_syslog(
"sendReminderForExpiredSubscription Language for member id ".$adherent->id.
" set to ".$outputlangs->defaultlang.
" mysoc->default_lang=".$mysoc->default_lang);
2959 $arraydefaultmessage =
null;
2962 if (!empty($labeltouse)) {
2963 $arraydefaultmessage = $formmail->getEMailTemplate($this->
db,
'member', $user, $outputlangs, 0, 1, $labeltouse);
2966 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
2971 $subject =
make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs);
2972 $msg =
make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs);
2973 $from = $conf->global->ADHERENT_MAIL_FROM;
2974 $to = $adherent->email;
2976 $trackid =
'mem'.$adherent->id;
2977 $moreinheader =
'X-Dolibarr-Info: sendReminderForExpiredSubscription'.
"\r\n";
2979 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
2980 $cmail =
new CMailFile($subject, $to, $from, $msg, array(), array(), array(),
'',
'', 0, 1,
'',
'', $trackid, $moreinheader);
2981 $result = $cmail->sendfile();
2984 $this->error .= $cmail->error.
' ';
2985 if (!is_null($cmail->errors)) {
2986 $this->errors += $cmail->errors;
2989 $listofmembersko[$adherent->id] = $adherent->id;
2992 $listofmembersok[$adherent->id] = $adherent->id;
2998 $actioncode =
'EMAIL';
3009 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic').
": ".$subject);
3010 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody').
":");
3014 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
3019 $actioncomm->type_code =
'AC_OTH_AUTO';
3020 $actioncomm->code =
'AC_'.$actioncode;
3021 $actioncomm->label = $actionmsg2;
3022 $actioncomm->note_private = $actionmsg;
3023 $actioncomm->fk_project = 0;
3024 $actioncomm->datep = $now;
3025 $actioncomm->datef = $now;
3026 $actioncomm->percentage = -1;
3027 $actioncomm->socid = $adherent->thirdparty->id;
3028 $actioncomm->contact_id = 0;
3029 $actioncomm->authorid = $user->id;
3030 $actioncomm->userownerid = $user->id;
3032 $actioncomm->email_msgid = $cmail->msgid;
3033 $actioncomm->email_from = $from;
3034 $actioncomm->email_sender =
'';
3035 $actioncomm->email_to = $to;
3036 $actioncomm->email_tocc = $sendtocc;
3037 $actioncomm->email_tobcc = $sendtobcc;
3038 $actioncomm->email_subject = $subject;
3039 $actioncomm->errors_to =
'';
3041 $actioncomm->fk_element = $adherent->id;
3042 $actioncomm->elementtype = $adherent->element;
3044 $actioncomm->extraparams = $extraparams;
3046 $actioncomm->create($user);
3052 $this->error .=
"Can't find email template with label=".$labeltouse.
", to use for the reminding email ";
3055 $listofmembersko[$adherent->id] = $adherent->id;
3064 $this->error = $this->
db->lasterror();
3069 if ($blockingerrormsg) {
3070 $this->error = $blockingerrormsg;
3073 $this->output =
'Found '.($nbok + $nbko).
' members to send reminder to.';
3074 $this->output .=
' Send email successfuly to '.$nbok.
' members';
3075 if (is_array($listofmembersok)) {
3078 foreach ($listofmembersok as $idmember) {
3080 $listofids .=
', ...';
3083 if (empty($listofids)) {
3088 $listofids .= $idmember;
3094 $this->output .= ($listofids ?
' ids='.$listofids :
'');
3097 $this->output .=
' - Canceled for '.$nbko.
' member (no email or email sending error)';
3098 if (is_array($listofmembersko)) {
3101 foreach ($listofmembersko as $idmember) {
3103 $listofids .=
', ...';
3106 if (empty($listofids)) {
3111 $listofids .= $idmember;
3117 $this->output .= ($listofids ?
' ids='.$listofids :
'');