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;
101 public $civility_code;
171 public $socialnetworks;
219 public $phone_mobile;
245 public $default_lang;
288 public $need_subscription;
305 public $first_subscription_date;
307 public $first_subscription_date_start;
309 public $first_subscription_date_end;
311 public $first_subscription_amount;
313 public $last_subscription_date;
315 public $last_subscription_date_start;
317 public $last_subscription_date_end;
319 public $last_subscription_amount;
321 public $subscriptions = array();
330 public $partnerships = array();
346 public $fields = array(
347 'rowid' => array(
'type' =>
'integer',
'label' =>
'TechnicalID',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 10),
348 'ref' => array(
'type' =>
'varchar(30)',
'label' =>
'Ref',
'default' => 1,
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 12,
'index' => 1),
349 'entity' => array(
'type' =>
'integer',
'label' =>
'Entity',
'default' => 1,
'enabled' => 1,
'visible' => -2,
'notnull' => 1,
'position' => 15,
'index' => 1),
350 'ref_ext' => array(
'type' =>
'varchar(128)',
'label' =>
'Ref ext',
'enabled' => 1,
'visible' => 0,
'position' => 20),
351 'civility' => array(
'type' =>
'varchar(6)',
'label' =>
'Civility',
'enabled' => 1,
'visible' => -1,
'position' => 25),
352 'lastname' => array(
'type' =>
'varchar(50)',
'label' =>
'Lastname',
'enabled' => 1,
'visible' => -1,
'position' => 30,
'showoncombobox'=>1),
353 'firstname' => array(
'type' =>
'varchar(50)',
'label' =>
'Firstname',
'enabled' => 1,
'visible' => -1,
'position' => 35,
'showoncombobox'=>1),
354 'login' => array(
'type' =>
'varchar(50)',
'label' =>
'Login',
'enabled' => 1,
'visible' => -1,
'position' => 40),
355 'gender' => array(
'type' =>
'varchar(10)',
'label' =>
'Gender',
'enabled' => 1,
'visible' => -1,
'position' => 250),
356 'pass' => array(
'type' =>
'varchar(50)',
'label' =>
'Pass',
'enabled' => 1,
'visible' => -1,
'position' => 45),
357 'pass_crypted' => array(
'type' =>
'varchar(128)',
'label' =>
'Pass crypted',
'enabled' => 1,
'visible' => -1,
'position' => 50),
358 'fk_adherent_type' => array(
'type' =>
'integer',
'label' =>
'Fk adherent type',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 55),
359 'morphy' => array(
'type' =>
'varchar(3)',
'label' =>
'MorPhy',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 60),
360 'societe' => array(
'type' =>
'varchar(128)',
'label' =>
'Societe',
'enabled' => 1,
'visible' => -1,
'position' => 65,
'showoncombobox'=>2),
361 'fk_soc' => array(
'type' =>
'integer:Societe:societe/class/societe.class.php',
'label' =>
'ThirdParty',
'enabled' => 1,
'visible' => -1,
'position' => 70),
362 'address' => array(
'type' =>
'text',
'label' =>
'Address',
'enabled' => 1,
'visible' => -1,
'position' => 75),
363 'zip' => array(
'type' =>
'varchar(10)',
'label' =>
'Zip',
'enabled' => 1,
'visible' => -1,
'position' => 80),
364 'town' => array(
'type' =>
'varchar(50)',
'label' =>
'Town',
'enabled' => 1,
'visible' => -1,
'position' => 85),
365 'state_id' => array(
'type' =>
'integer',
'label' =>
'State id',
'enabled' => 1,
'visible' => -1,
'position' => 90),
366 'country' => array(
'type' =>
'integer:Ccountry:core/class/ccountry.class.php',
'label' =>
'Country',
'enabled' => 1,
'visible' => -1,
'position' => 95),
367 'email' => array(
'type' =>
'varchar(255)',
'label' =>
'Email',
'enabled' => 1,
'visible' => -1,
'position' => 100),
368 'url' =>array(
'type'=>
'varchar(255)',
'label'=>
'Url',
'enabled'=>1,
'visible'=>-1,
'position'=>110),
369 'socialnetworks' => array(
'type' =>
'text',
'label' =>
'Socialnetworks',
'enabled' => 1,
'visible' => -1,
'position' => 105),
370 'phone' => array(
'type' =>
'varchar(30)',
'label' =>
'Phone',
'enabled' => 1,
'visible' => -1,
'position' => 115),
371 'phone_perso' => array(
'type' =>
'varchar(30)',
'label' =>
'Phone perso',
'enabled' => 1,
'visible' => -1,
'position' => 120),
372 'phone_mobile' => array(
'type' =>
'varchar(30)',
'label' =>
'Phone mobile',
'enabled' => 1,
'visible' => -1,
'position' => 125),
373 'birth' => array(
'type' =>
'date',
'label' =>
'DateOfBirth',
'enabled' => 1,
'visible' => -1,
'position' => 130),
374 'photo' => array(
'type' =>
'varchar(255)',
'label' =>
'Photo',
'enabled' => 1,
'visible' => -1,
'position' => 135),
375 'public' => array(
'type' =>
'smallint(6)',
'label' =>
'Public',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 145),
376 'datefin' => array(
'type' =>
'datetime',
'label' =>
'DateEnd',
'enabled' => 1,
'visible' => -1,
'position' => 150),
377 'default_lang' =>array(
'type'=>
'varchar(6)',
'label'=>
'Default lang',
'enabled'=>1,
'visible'=>-1,
'position'=> 153),
378 'note_public' => array(
'type' =>
'text',
'label' =>
'NotePublic',
'enabled' => 1,
'visible' => 0,
'position' => 155),
379 'note_private' => array(
'type' =>
'text',
'label' =>
'NotePrivate',
'enabled' => 1,
'visible' => 0,
'position' => 160),
380 'datevalid' => array(
'type' =>
'datetime',
'label' =>
'DateValidation',
'enabled' => 1,
'visible' => -1,
'position' => 165),
381 'datec' => array(
'type' =>
'datetime',
'label' =>
'DateCreation',
'enabled' => 1,
'visible' => -1,
'position' => 170),
382 'tms' => array(
'type' =>
'timestamp',
'label' =>
'DateModification',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 175),
383 'fk_user_author' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'Fk user author',
'enabled' => 1,
'visible' => -1,
'position' => 180),
384 'fk_user_mod' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'Fk user mod',
'enabled' => 1,
'visible' => -1,
'position' => 185),
385 'fk_user_valid' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'UserValidation',
'enabled' => 1,
'visible' => -1,
'position' => 190),
386 'canvas' => array(
'type' =>
'varchar(32)',
'label' =>
'Canvas',
'enabled' => 1,
'visible' => -1,
'position' => 195),
387 'statut' => array(
'type' =>
'smallint(6)',
'label' =>
'Statut',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 500,
388 'arrayofkeyval' => array(-1 =>
'Draft', 1 =>
'Validated', 0 =>
'MemberStatusResiliatedShort', -2 =>
'MemberStatusExcludedShort')),
389 'model_pdf' => array(
'type' =>
'varchar(255)',
'label' =>
'Model pdf',
'enabled' => 1,
'visible' => 0,
'position' => 800),
390 'import_key' => array(
'type' =>
'varchar(14)',
'label' =>
'ImportId',
'enabled' => 1,
'visible' => -2,
'position' => 805)
420 $this->status = $this->statut;
424 $this->array_options = array();
447 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 =
'')
450 dol_syslog(
'Warning using deprecated Adherent::send_an_email', LOG_WARNING);
452 return $this->
sendEmail($text, $subject, $filename_list, $mimetype_list, $mimefilename_list, $addr_cc, $addr_bcc, $deliveryreceipt, $msgishtml, $errors_to, $moreinheader);
472 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 =
'')
474 global $conf, $langs;
477 if ($msgishtml == -1) {
484 dol_syslog(
'send_an_email msgishtml='.$msgishtml);
493 $from = $conf->email_from;
498 $trackid =
'mem'.$this->id;
501 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
502 $mailfile =
new CMailFile($subjecttosend, $this->email, $from, $texttosend, $filename_list, $mimetype_list, $mimefilename_list, $addr_cc, $addr_bcc, $deliveryreceipt, $msgishtml,
'',
'', $trackid, $moreinheader);
503 if ($mailfile->sendfile()) {
506 $this->error = $langs->trans(
"ErrorFailedToSendMail", $from, $this->email).
'. '.$mailfile->error;
520 global $conf, $langs;
530 if ($this->civility_id) {
531 $infos .= $langs->transnoentities(
"UserTitle").
": ".$this->
getCivilityLabel().
"\n";
533 $infos .= $langs->transnoentities(
"id").
": ".$this->
id.
"\n";
534 $infos .= $langs->transnoentities(
"ref").
": ".$this->
ref.
"\n";
535 $infos .= $langs->transnoentities(
"Lastname").
": ".$this->lastname.
"\n";
536 $infos .= $langs->transnoentities(
"Firstname").
": ".$this->firstname.
"\n";
537 $infos .= $langs->transnoentities(
"Company").
": ".$this->company.
"\n";
538 $infos .= $langs->transnoentities(
"Address").
": ".$this->address.
"\n";
539 $infos .= $langs->transnoentities(
"Zip").
": ".$this->zip.
"\n";
540 $infos .= $langs->transnoentities(
"Town").
": ".$this->town.
"\n";
541 $infos .= $langs->transnoentities(
"Country").
": ".$this->country.
"\n";
542 $infos .= $langs->transnoentities(
"EMail").
": ".$this->email.
"\n";
543 $infos .= $langs->transnoentities(
"PhonePro").
": ".$this->phone.
"\n";
544 $infos .= $langs->transnoentities(
"PhonePerso").
": ".$this->phone_perso.
"\n";
545 $infos .= $langs->transnoentities(
"PhoneMobile").
": ".$this->phone_mobile.
"\n";
546 if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
547 $infos .= $langs->transnoentities(
"Login").
": ".$this->login.
"\n";
548 $infos .= $langs->transnoentities(
"Password").
": ".$this->pass.
"\n";
550 $infos .= $langs->transnoentities(
"Birthday").
": ".$birthday.
"\n";
551 $infos .= $langs->transnoentities(
"Photo").
": ".$this->photo.
"\n";
552 $infos .= $langs->transnoentities(
"Public").
": ".
yn($this->
public);
555 $substitutionarray = array(
556 '__ID__' => $this->
id,
557 '__REF__' => $this->
ref,
558 '__MEMBER_ID__' => $this->
id,
560 '__FIRSTNAME__' => $msgishtml ?
dol_htmlentitiesbr($this->firstname) : ($this->firstname ? $this->firstname :
''),
561 '__LASTNAME__' => $msgishtml ?
dol_htmlentitiesbr($this->lastname) : ($this->lastname ? $this->lastname :
''),
563 '__COMPANY__' => $msgishtml ?
dol_htmlentitiesbr($this->company) : ($this->company ? $this->company :
''),
564 '__ADDRESS__' => $msgishtml ?
dol_htmlentitiesbr($this->address) : ($this->address ? $this->address :
''),
565 '__ZIP__' => $msgishtml ?
dol_htmlentitiesbr($this->zip) : ($this->zip ? $this->zip :
''),
566 '__TOWN__' => $msgishtml ?
dol_htmlentitiesbr($this->town) : ($this->town ? $this->town :
''),
567 '__COUNTRY__' => $msgishtml ?
dol_htmlentitiesbr($this->country) : ($this->country ? $this->country :
''),
568 '__EMAIL__' => $msgishtml ?
dol_htmlentitiesbr($this->email) : ($this->email ? $this->email :
''),
569 '__BIRTH__' => $msgishtml ?
dol_htmlentitiesbr($birthday) : ($birthday ? $birthday :
''),
570 '__PHOTO__' => $msgishtml ?
dol_htmlentitiesbr($this->photo) : ($this->photo ? $this->photo :
''),
571 '__LOGIN__' => $msgishtml ?
dol_htmlentitiesbr($this->login) : ($this->login ? $this->login :
''),
572 '__PASSWORD__' => $msgishtml ?
dol_htmlentitiesbr($this->pass) : ($this->pass ? $this->pass :
''),
573 '__PHONE__' => $msgishtml ?
dol_htmlentitiesbr($this->phone) : ($this->phone ? $this->phone :
''),
574 '__PHONEPRO__' => $msgishtml ?
dol_htmlentitiesbr($this->phone_perso) : ($this->phone_perso ? $this->phone_perso :
''),
575 '__PHONEMOBILE__' => $msgishtml ?
dol_htmlentitiesbr($this->phone_mobile) : ($this->phone_mobile ? $this->phone_mobile :
''),
598 $morphy = $this->morphy;
603 $labeltoshowm = $langs->trans(
"Moral");
604 $labeltoshowp = $langs->trans(
"Physical");
605 if ($morphy ==
'phy') {
606 $labeltoshow = $labeltoshowp;
607 if ($addbadge == 2) {
613 $s .=
'<span class="member-individual-back paddingleftimp paddingrightimp" title="'.$langs->trans(
"Physical").
'">'.$labeltoshow.
'</span>';
615 if ($morphy ==
'mor') {
616 $labeltoshow = $labeltoshowm;
617 if ($addbadge == 2) {
623 $s .=
'<span class="member-company-back paddingleftimp paddingrightimp" title="'.$langs->trans(
"Moral").
'">'.$labeltoshow.
'</span>';
626 if ($morphy ==
'phy') {
627 $s = $langs->trans(
"Physical");
628 } elseif ($morphy ==
'mor') {
629 $s = $langs->trans(
"Moral");
643 public function create($user, $notrigger = 0)
645 global $conf, $langs, $mysoc;
652 $this->import_key = trim($this->import_key);
655 if (!empty($conf->global->ADHERENT_MAIL_REQUIRED) && !isValidEMail($this->email)) {
656 $langs->load(
"errors");
657 $this->error = $langs->trans(
"ErrorBadEMail", $this->email);
663 if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
664 if (empty($this->login)) {
665 $this->error = $langs->trans(
"ErrorWrongValueForParameterX",
"Login");
673 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"adherent";
674 $sql .=
" (ref, datec,login,fk_user_author,fk_user_mod,fk_user_valid,morphy,fk_adherent_type,entity,import_key, ip)";
677 $sql .=
", '".$this->db->idate($this->datec).
"'";
678 $sql .=
", ".($this->login ?
"'".$this->db->escape($this->login).
"'" :
"null");
679 $sql .=
", ".($user->id > 0 ? $user->id :
"null");
680 $sql .=
", null, null, '".$this->db->escape($this->morphy).
"'";
681 $sql .=
", ".((int) $this->
typeid);
682 $sql .=
", ".$conf->entity;
683 $sql .=
", ".(!empty($this->import_key) ?
"'".$this->db->escape($this->import_key).
"'" :
"null");
684 $sql .=
", ".(!empty($this->ip) ?
"'".$this->db->escape($this->ip).
"'" :
"null");
687 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
688 $result = $this->
db->query(
$sql);
690 $id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
"adherent");
695 $this->
ref = (string) $id;
700 require_once $modfile;
702 $modCodeMember =
new $modname;
703 $this->
ref = $modCodeMember->getNextValue($mysoc, $this);
711 $result = $this->
update($user, 1, 1, 0, 0,
'add');
713 $this->
db->rollback();
718 if ($this->user_id) {
720 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET";
721 $sql .=
" fk_member = ".((int) $this->
id);
722 $sql .=
" WHERE rowid = ".((int) $this->user_id);
723 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
724 $resql = $this->
db->query(
$sql);
726 $this->error =
'Failed to update user to make link with member';
727 $this->
db->rollback();
741 if (count($this->errors)) {
742 dol_syslog(get_class($this).
"::create ".implode(
',', $this->errors), LOG_ERR);
743 $this->
db->rollback();
750 $this->error =
'Failed to get last insert id';
751 dol_syslog(get_class($this).
"::create ".$this->error, LOG_ERR);
752 $this->
db->rollback();
756 $this->error = $this->
db->error();
757 $this->
db->rollback();
774 public function update($user, $notrigger = 0, $nosyncuser = 0, $nosyncuserpass = 0, $nosyncthirdparty = 0, $action =
'update')
776 global $conf, $langs, $hookmanager;
778 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
783 dol_syslog(get_class($this).
"::update notrigger=".$notrigger.
", nosyncuser=".$nosyncuser.
", nosyncuserpass=".$nosyncuserpass.
" nosyncthirdparty=".$nosyncthirdparty.
", email=".$this->email);
786 $this->lastname = trim($this->lastname) ? trim($this->lastname) : trim($this->lastname);
787 $this->firstname = trim($this->firstname) ? trim($this->firstname) : trim($this->firstname);
788 $this->gender = trim($this->gender);
789 $this->address = ($this->address ? $this->address : $this->address);
790 $this->zip = ($this->zip ? $this->zip : $this->zip);
791 $this->town = ($this->town ? $this->town : $this->town);
792 $this->country_id = ($this->country_id > 0 ? $this->country_id : $this->country_id);
793 $this->state_id = ($this->state_id > 0 ? $this->state_id : $this->state_id);
794 $this->note_public = ($this->note_public ? $this->note_public : $this->note_public);
795 $this->note_private = ($this->note_private ? $this->note_private : $this->note_private);
796 $this->url = $this->url ?
clean_url($this->url, 0) :
'';
799 if (!empty($conf->global->ADHERENT_MAIL_REQUIRED) && !isValidEMail($this->email)) {
800 $langs->load(
"errors");
801 $this->error = $langs->trans(
"ErrorBadEMail", $this->email);
807 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
808 $sql .=
" ref = '".$this->db->escape($this->
ref).
"'";
809 $sql .=
", civility = ".($this->civility_id ?
"'".$this->db->escape($this->civility_id).
"'" :
"null");
810 $sql .=
", firstname = ".($this->firstname ?
"'".$this->db->escape($this->firstname).
"'" :
"null");
811 $sql .=
", lastname = ".($this->lastname ?
"'".$this->db->escape($this->lastname).
"'" :
"null");
812 $sql .=
", gender = ".($this->gender != -1 ?
"'".$this->db->escape($this->gender).
"'" :
"null");
813 $sql .=
", login = ".($this->login ?
"'".$this->db->escape($this->login).
"'" :
"null");
814 $sql .=
", societe = ".($this->company ?
"'".$this->db->escape($this->company).
"'" : ($this->societe ?
"'".$this->db->escape($this->societe).
"'" :
"null"));
816 $sql .=
", fk_soc = ".($this->socid > 0 ? $this->
db->escape($this->socid) :
"null");
818 $sql .=
", address = ".($this->address ?
"'".$this->db->escape($this->address).
"'" :
"null");
819 $sql .=
", zip = ".($this->zip ?
"'".$this->db->escape($this->zip).
"'" :
"null");
820 $sql .=
", town = ".($this->town ?
"'".$this->db->escape($this->town).
"'" :
"null");
821 $sql .=
", country = ".($this->country_id > 0 ? $this->
db->escape($this->country_id) :
"null");
822 $sql .=
", state_id = ".($this->state_id > 0 ? $this->
db->escape($this->state_id) :
"null");
823 $sql .=
", email = '".$this->db->escape($this->email).
"'";
824 $sql .=
", url = ".(!empty($this->url) ?
"'".$this->db->escape($this->url).
"'" :
"null");
825 $sql .=
", socialnetworks = ".($this->socialnetworks ?
"'".$this->db->escape(json_encode($this->socialnetworks)).
"'" :
"null");
826 $sql .=
", phone = ".($this->phone ?
"'".$this->db->escape($this->phone).
"'" :
"null");
827 $sql .=
", phone_perso = ".($this->phone_perso ?
"'".$this->db->escape($this->phone_perso).
"'" :
"null");
828 $sql .=
", phone_mobile = ".($this->phone_mobile ?
"'".$this->db->escape($this->phone_mobile).
"'" :
"null");
829 $sql .=
", note_private = ".($this->note_private ?
"'".$this->db->escape($this->note_private).
"'" :
"null");
830 $sql .=
", note_public = ".($this->note_public ?
"'".$this->db->escape($this->note_public).
"'" :
"null");
831 $sql .=
", photo = ".($this->photo ?
"'".$this->db->escape($this->photo).
"'" :
"null");
832 $sql .=
", public = '".$this->db->escape($this->
public).
"'";
833 $sql .=
", statut = ".$this->db->escape($this->statut);
834 $sql .=
", default_lang = ".(!empty($this->default_lang) ?
"'".$this->db->escape($this->default_lang).
"'" :
"null");
835 $sql .=
", fk_adherent_type = ".$this->db->escape($this->
typeid);
836 $sql .=
", morphy = '".$this->db->escape($this->morphy).
"'";
837 $sql .=
", birth = ".($this->birth ?
"'".$this->db->idate($this->birth).
"'" :
"null");
839 if ($this->datefin) {
840 $sql .=
", datefin = '".$this->db->idate($this->datefin).
"'";
842 if ($this->datevalid) {
843 $sql .=
", datevalid = '".$this->db->idate($this->datevalid).
"'";
845 $sql .=
", fk_user_mod = ".($user->id > 0 ? $user->id :
'null');
846 $sql .=
" WHERE rowid = ".((int) $this->
id);
849 if (!empty($this->oldcopy) && $this->
typeid != $this->oldcopy->typeid) {
850 $sql2 =
"SELECT libelle as label";
851 $sql2 .=
" FROM ".MAIN_DB_PREFIX.
"adherent_type";
852 $sql2 .=
" WHERE rowid = ".((int) $this->
typeid);
853 $resql2 = $this->
db->query($sql2);
855 while ($obj = $this->
db->fetch_object($resql2)) {
856 $this->
type = $obj->label;
861 dol_syslog(get_class($this).
"::update update member", LOG_DEBUG);
862 $resql = $this->
db->query(
$sql);
864 unset($this->country_code);
865 unset($this->country);
866 unset($this->state_code);
869 $nbrowsaffected += $this->
db->affected_rows($resql);
882 if (!$error && $this->pass) {
883 dol_syslog(get_class($this).
"::update update password");
884 if ($this->pass != $this->pass_indatabase && $this->pass != $this->pass_indatabase_crypted) {
885 $isencrypted = empty($conf->global->DATABASE_PWD_ENCRYPTED) ? 0 : 1;
888 $result = $this->
setPassword($user, $this->pass, $isencrypted, $notrigger, $nosyncuserpass);
889 if (!$nbrowsaffected) {
897 dol_syslog(get_class($this).
"::update update link to user");
898 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = NULL WHERE fk_member = ".((int) $this->
id);
899 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
900 $resql = $this->
db->query(
$sql);
902 $this->error = $this->
db->error();
903 $this->
db->rollback();
907 if ($this->user_id > 0) {
908 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = ".((int) $this->
id).
" WHERE rowid = ".((int) $this->user_id);
909 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
910 $resql = $this->
db->query(
$sql);
912 $this->error = $this->
db->error();
913 $this->
db->rollback();
919 if (!$error && $nbrowsaffected) {
921 if (!$error && $this->user_id > 0 && !$nosyncuser) {
922 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
924 dol_syslog(get_class($this).
"::update update linked user");
926 $luser =
new User($this->
db);
927 $result = $luser->fetch($this->user_id);
934 if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
935 $luser->login = $this->login;
938 $luser->ref = $this->ref;
939 $luser->civility_id = $this->civility_id;
940 $luser->firstname = $this->firstname;
941 $luser->lastname = $this->lastname;
942 $luser->gender = $this->gender;
943 $luser->pass = $this->pass;
946 $luser->birth = $this->birth;
948 $luser->address = $this->address;
949 $luser->zip = $this->zip;
950 $luser->town = $this->town;
951 $luser->country_id = $this->country_id;
952 $luser->state_id = $this->state_id;
954 $luser->email = $this->email;
955 $luser->socialnetworks = $this->socialnetworks;
956 $luser->office_phone = $this->phone;
957 $luser->user_mobile = $this->phone_mobile;
959 $luser->lang = $this->default_lang;
961 $luser->fk_member = $this->id;
963 $result = $luser->update($user, 0, 1, 1);
965 $this->error = $luser->error;
966 dol_syslog(get_class($this).
"::update ".$this->error, LOG_ERR);
970 $this->error = $luser->error;
976 if (!$error && $this->fk_soc > 0 && !$nosyncthirdparty) {
977 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
979 dol_syslog(get_class($this).
"::update update linked thirdparty");
984 $result = $lthirdparty->fetch($this->fk_soc);
987 $lthirdparty->address = $this->address;
988 $lthirdparty->zip = $this->zip;
989 $lthirdparty->town = $this->town;
990 $lthirdparty->email = $this->email;
991 $lthirdparty->socialnetworks = $this->socialnetworks;
992 $lthirdparty->phone = $this->phone;
993 $lthirdparty->state_id = $this->state_id;
994 $lthirdparty->country_id = $this->country_id;
996 $lthirdparty->default_lang = $this->default_lang;
998 $result = $lthirdparty->update($this->fk_soc, $user, 0, 1, 1,
'update');
1001 $this->error = $lthirdparty->error;
1002 $this->errors = $lthirdparty->errors;
1003 dol_syslog(get_class($this).
"::update ".$this->error, LOG_ERR);
1006 } elseif ($result < 0) {
1007 $this->error = $lthirdparty->error;
1013 if (!$error && !$notrigger) {
1023 $this->
db->commit();
1024 return $nbrowsaffected;
1026 $this->
db->rollback();
1030 $this->
db->rollback();
1031 $this->error = $this->
db->lasterror();
1051 $sql =
"SELECT rowid, datec as dateop, dateadh as datedeb, datef as datefin";
1052 $sql .=
" FROM ".MAIN_DB_PREFIX.
"subscription";
1053 $sql .=
" WHERE fk_adherent = ".((int) $this->
id);
1054 $sql .=
" ORDER by dateadh DESC";
1056 dol_syslog(get_class($this).
"::update_end_date", LOG_DEBUG);
1057 $resql = $this->
db->query(
$sql);
1059 $obj = $this->
db->fetch_object($resql);
1060 $dateop = $this->
db->jdate($obj->dateop);
1061 $datedeb = $this->
db->jdate($obj->datedeb);
1062 $datefin = $this->
db->jdate($obj->datefin);
1064 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
1065 $sql .=
" datefin=".($datefin !=
'' ?
"'".$this->db->idate($datefin).
"'" :
"null");
1066 $sql .=
" WHERE rowid = ".((int) $this->
id);
1068 dol_syslog(get_class($this).
"::update_end_date", LOG_DEBUG);
1069 $resql = $this->
db->query(
$sql);
1071 $this->last_subscription_date = $dateop;
1072 $this->last_subscription_date_start = $datedeb;
1073 $this->last_subscription_date_end = $datefin;
1074 $this->datefin = $datefin;
1075 $this->
db->commit();
1078 $this->
db->rollback();
1082 $this->error = $this->
db->lasterror();
1083 $this->
db->rollback();
1096 public function delete($rowid, $user, $notrigger = 0)
1098 global $conf, $langs;
1105 if (empty($rowid)) {
1111 if (!$error && !$notrigger) {
1121 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"categorie_member WHERE fk_member = ".((int) $rowid);
1122 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1123 $resql = $this->
db->query(
$sql);
1126 $this->error .= $this->
db->lasterror();
1132 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"subscription WHERE fk_adherent = ".((int) $rowid);
1133 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1134 $resql = $this->
db->query(
$sql);
1137 $this->error .= $this->
db->lasterror();
1147 $this->error .= $this->
db->lasterror();
1158 dol_syslog(get_class($this).
"::delete erreur ".$errorflag.
" ".$this->error, LOG_ERR);
1164 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"adherent WHERE rowid = ".((int) $rowid);
1165 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1166 $resql = $this->
db->query(
$sql);
1169 $this->error .= $this->
db->lasterror();
1175 $this->
db->commit();
1178 $this->
db->rollback();
1194 public function setPassword($user, $password =
'', $isencrypted = 0, $notrigger = 0, $nosyncuser = 0)
1196 global $conf, $langs;
1200 dol_syslog(get_class($this).
"::setPassword user=".$user->id.
" password=".preg_replace(
'/./i',
'*', $password).
" isencrypted=".$isencrypted);
1204 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
1209 $password_crypted =
dol_hash($password);
1211 $password_indatabase =
'';
1212 if (!$isencrypted) {
1213 $password_indatabase = $password;
1219 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent";
1220 $sql .=
" SET pass_crypted = '".$this->db->escape($password_crypted).
"'";
1223 $sql .=
", pass = null";
1225 $sql .=
", pass = '".$this->db->escape($password_indatabase).
"'";
1227 $sql .=
" WHERE rowid = ".((int) $this->
id);
1230 dol_syslog(get_class($this).
"::setPassword", LOG_DEBUG);
1231 $result = $this->
db->query(
$sql);
1233 $nbaffectedrows = $this->
db->affected_rows($result);
1235 if ($nbaffectedrows) {
1236 $this->pass = $password;
1237 $this->pass_indatabase = $password_indatabase;
1238 $this->pass_indatabase_crypted = $password_crypted;
1240 if ($this->user_id && !$nosyncuser) {
1241 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
1245 $luser =
new User($this->
db);
1246 $result = $luser->fetch($this->user_id);
1249 $result = $luser->setPassword($user, $this->pass, 0, 0, 1);
1251 $this->error = $luser->error;
1252 dol_syslog(get_class($this).
"::setPassword ".$this->error, LOG_ERR);
1256 $this->error = $luser->error;
1261 if (!$error && !$notrigger) {
1263 $result = $this->
call_trigger(
'MEMBER_NEW_PASSWORD', $user);
1266 $this->
db->rollback();
1272 $this->
db->commit();
1275 $this->
db->rollback();
1279 $this->
db->rollback();
1294 global $conf, $langs;
1299 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = NULL WHERE fk_member = ".((int) $this->
id);
1300 dol_syslog(get_class($this).
"::setUserId", LOG_DEBUG);
1301 $resql = $this->
db->query(
$sql);
1303 $this->error = $this->
db->error();
1304 $this->
db->rollback();
1310 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = ".((int) $this->
id);
1311 $sql .=
" WHERE rowid = ".((int) $userid);
1312 dol_syslog(get_class($this).
"::setUserId", LOG_DEBUG);
1313 $resql = $this->
db->query(
$sql);
1315 $this->error = $this->
db->error();
1316 $this->
db->rollback();
1321 $this->
db->commit();
1335 global $conf, $langs;
1340 if ($thirdpartyid > 0) {
1341 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET fk_soc = null";
1342 $sql .=
" WHERE fk_soc = ".((int) $thirdpartyid);
1343 $sql .=
" AND entity = ".$conf->entity;
1344 dol_syslog(get_class($this).
"::setThirdPartyId", LOG_DEBUG);
1345 $resql = $this->
db->query(
$sql);
1349 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET fk_soc = ".($thirdpartyid > 0 ? $thirdpartyid :
'null');
1350 $sql .=
" WHERE rowid = ".((int) $this->
id);
1352 dol_syslog(get_class($this).
"::setThirdPartyId", LOG_DEBUG);
1353 $resql = $this->
db->query(
$sql);
1355 $this->
db->commit();
1358 $this->error = $this->
db->error();
1359 $this->
db->rollback();
1377 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"adherent";
1378 $sql .=
" WHERE login='".$this->db->escape($login).
"'";
1379 $sql .=
" AND entity = ".$conf->entity;
1381 $resql = $this->
db->query(
$sql);
1383 if ($this->
db->num_rows($resql)) {
1384 $obj = $this->
db->fetch_object($resql);
1385 $this->
fetch($obj->rowid);
1405 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"adherent";
1406 $sql .=
" WHERE firstname='".$this->db->escape($firstname).
"'";
1407 $sql .=
" AND lastname='".$this->db->escape($lastname).
"'";
1408 $sql .=
" AND entity = ".$conf->entity;
1410 $resql = $this->
db->query(
$sql);
1412 if ($this->
db->num_rows($resql)) {
1413 $obj = $this->
db->fetch_object($resql);
1414 $this->
fetch($obj->rowid);
1432 public function fetch($rowid, $ref =
'', $fk_soc =
'', $ref_ext =
'', $fetch_optionals =
true, $fetch_subscriptions =
true)
1436 $sql =
"SELECT d.rowid, d.ref, d.ref_ext, d.civility as civility_code, d.gender, d.firstname, d.lastname,";
1437 $sql .=
" d.societe as company, d.fk_soc, d.statut, d.public, d.address, d.zip, d.town, d.note_private,";
1438 $sql .=
" d.note_public,";
1439 $sql .=
" d.email, d.url, d.socialnetworks, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass, d.pass_crypted,";
1440 $sql .=
" d.photo, d.fk_adherent_type, d.morphy, d.entity,";
1441 $sql .=
" d.datec as datec,";
1442 $sql .=
" d.tms as datem,";
1443 $sql .=
" d.datefin as datefin, d.default_lang,";
1444 $sql .=
" d.birth as birthday,";
1445 $sql .=
" d.datevalid as datev,";
1446 $sql .=
" d.country,";
1447 $sql .=
" d.state_id,";
1448 $sql .=
" d.model_pdf,";
1449 $sql .=
" c.rowid as country_id, c.code as country_code, c.label as country,";
1450 $sql .=
" dep.nom as state, dep.code_departement as state_code,";
1451 $sql .=
" t.libelle as type, t.subscription as subscription,";
1452 $sql .=
" u.rowid as user_id, u.login as user_login";
1453 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent_type as t, ".MAIN_DB_PREFIX.
"adherent as d";
1454 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as c ON d.country = c.rowid";
1455 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as dep ON d.state_id = dep.rowid";
1456 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON d.rowid = u.fk_member";
1457 $sql .=
" WHERE d.fk_adherent_type = t.rowid";
1459 $sql .=
" AND d.rowid=".((int) $rowid);
1460 } elseif ($ref || $fk_soc) {
1461 $sql .=
" AND d.entity IN (".getEntity(
'adherent').
")";
1463 $sql .=
" AND d.ref='".$this->db->escape($ref).
"'";
1464 } elseif ($fk_soc > 0) {
1465 $sql .=
" AND d.fk_soc=".((int) $fk_soc);
1467 } elseif ($ref_ext) {
1468 $sql .=
" AND d.ref_ext='".$this->db->escape($ref_ext).
"'";
1471 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
1472 $resql = $this->
db->query(
$sql);
1474 if ($this->
db->num_rows($resql)) {
1475 $obj = $this->
db->fetch_object($resql);
1477 $this->entity = $obj->entity;
1478 $this->
id = $obj->rowid;
1479 $this->
ref = $obj->ref;
1480 $this->ref_ext = $obj->ref_ext;
1482 $this->civility_id = $obj->civility_code;
1483 $this->civility_code = $obj->civility_code;
1484 $this->civility = $obj->civility_code ? ($langs->trans(
"Civility".$obj->civility_code) != (
"Civility".$obj->civility_code) ? $langs->trans(
"Civility".$obj->civility_code) : $obj->civility_code) :
'';
1486 $this->firstname = $obj->firstname;
1487 $this->lastname = $obj->lastname;
1488 $this->gender = $obj->gender;
1489 $this->login = $obj->login;
1490 $this->societe = $obj->company;
1491 $this->company = $obj->company;
1492 $this->socid = $obj->fk_soc;
1493 $this->fk_soc = $obj->fk_soc;
1494 $this->address = $obj->address;
1495 $this->zip = $obj->zip;
1496 $this->town = $obj->town;
1498 $this->pass = $obj->pass;
1499 $this->pass_indatabase = $obj->pass;
1500 $this->pass_indatabase_crypted = $obj->pass_crypted;
1502 $this->state_id = $obj->state_id;
1503 $this->state_code = $obj->state_id ? $obj->state_code :
'';
1504 $this->state = $obj->state_id ? $obj->state :
'';
1506 $this->country_id = $obj->country_id;
1507 $this->country_code = $obj->country_code;
1508 if ($langs->trans(
"Country".$obj->country_code) !=
"Country".$obj->country_code) {
1509 $this->country = $langs->transnoentitiesnoconv(
"Country".$obj->country_code);
1511 $this->country = $obj->country;
1514 $this->phone = $obj->phone;
1515 $this->phone_perso = $obj->phone_perso;
1516 $this->phone_mobile = $obj->phone_mobile;
1517 $this->email = $obj->email;
1518 $this->url = $obj->url;
1520 $this->socialnetworks = ($obj->socialnetworks ? (array) json_decode($obj->socialnetworks,
true) : array());
1522 $this->photo = $obj->photo;
1523 $this->statut = $obj->statut;
1524 $this->status = $obj->statut;
1525 $this->
public = $obj->public;
1527 $this->datec = $this->
db->jdate($obj->datec);
1528 $this->date_creation = $this->
db->jdate($obj->datec);
1529 $this->datem = $this->
db->jdate($obj->datem);
1530 $this->date_modification = $this->
db->jdate($obj->datem);
1531 $this->datefin = $this->
db->jdate($obj->datefin);
1532 $this->datevalid = $this->
db->jdate($obj->datev);
1533 $this->date_validation = $this->
db->jdate($obj->datev);
1534 $this->birth = $this->
db->jdate($obj->birthday);
1536 $this->default_lang = $obj->default_lang;
1538 $this->note_private = $obj->note_private;
1539 $this->note_public = $obj->note_public;
1540 $this->morphy = $obj->morphy;
1542 $this->
typeid = $obj->fk_adherent_type;
1543 $this->
type = $obj->type;
1544 $this->need_subscription = $obj->subscription;
1546 $this->user_id = $obj->user_id;
1547 $this->user_login = $obj->user_login;
1549 $this->model_pdf = $obj->model_pdf;
1553 if ($fetch_optionals) {
1558 if ($fetch_subscriptions) {
1567 $this->error = $this->
db->lasterror();
1587 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
1589 $sql =
"SELECT c.rowid, c.fk_adherent, c.fk_type, c.subscription, c.note as note_public, c.fk_bank,";
1590 $sql .=
" c.tms as datem,";
1591 $sql .=
" c.datec as datec,";
1592 $sql .=
" c.dateadh as dateh,";
1593 $sql .=
" c.datef as datef";
1594 $sql .=
" FROM ".MAIN_DB_PREFIX.
"subscription as c";
1595 $sql .=
" WHERE c.fk_adherent = ".((int) $this->
id);
1596 $sql .=
" ORDER BY c.dateadh";
1597 dol_syslog(get_class($this).
"::fetch_subscriptions", LOG_DEBUG);
1599 $resql = $this->
db->query(
$sql);
1601 $this->subscriptions = array();
1604 while ($obj = $this->
db->fetch_object($resql)) {
1606 $this->first_subscription_date = $this->
db->jdate($obj->datec);
1607 $this->first_subscription_date_start = $this->
db->jdate($obj->dateh);
1608 $this->first_subscription_date_end = $this->
db->jdate($obj->datef);
1609 $this->first_subscription_amount = $obj->subscription;
1611 $this->last_subscription_date = $this->
db->jdate($obj->datec);
1612 $this->last_subscription_date_start = $this->
db->jdate($obj->dateh);
1613 $this->last_subscription_date_end = $this->
db->jdate($obj->datef);
1614 $this->last_subscription_amount = $obj->subscription;
1617 $subscription->id = $obj->rowid;
1618 $subscription->fk_adherent = $obj->fk_adherent;
1619 $subscription->fk_type = $obj->fk_type;
1620 $subscription->amount = $obj->subscription;
1621 $subscription->note = $obj->note_public;
1622 $subscription->note_public = $obj->note_public;
1623 $subscription->fk_bank = $obj->fk_bank;
1624 $subscription->datem = $this->
db->jdate($obj->datem);
1625 $subscription->datec = $this->
db->jdate($obj->datec);
1626 $subscription->dateh = $this->
db->jdate($obj->dateh);
1627 $subscription->datef = $this->
db->jdate($obj->datef);
1629 $this->subscriptions[] = $subscription;
1635 $this->error = $this->
db->error().
' sql='.
$sql;
1651 require_once DOL_DOCUMENT_ROOT.
'/partnership/class/partnership.class.php';
1654 $this->partnerships[] = array();
1675 public function subscription($date, $amount, $accountid = 0, $operation =
'', $label =
'', $num_chq =
'', $emetteur_nom =
'', $emetteur_banque =
'', $datesubend = 0, $fk_type =
null)
1677 global $conf, $langs, $user;
1679 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
1691 $datefin = $datesubend;
1700 $subscription->fk_adherent = $this->id;
1701 $subscription->dateh = $date;
1702 $subscription->datef = $datefin;
1703 $subscription->amount = $amount;
1704 $subscription->note = $label;
1705 $subscription->note_public = $label;
1706 $subscription->fk_type = $fk_type;
1708 $rowid = $subscription->create($user);
1715 $this->last_subscription_date =
dol_now();
1716 $this->last_subscription_date_start = $date;
1717 $this->last_subscription_date_end = $datefin;
1718 $this->last_subscription_amount = $amount;
1722 $this->
db->commit();
1725 $this->
db->rollback();
1730 $this->
db->rollback();
1755 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 =
'')
1757 global $conf, $langs, $user, $mysoc;
1761 $this->invoice =
null;
1763 dol_syslog(
"subscriptionComplementaryActions subscriptionid=".$subscriptionid.
" option=".$option.
" accountid=".$accountid.
" datesubscription=".$datesubscription.
" paymentdate=".
1764 $paymentdate.
" label=".$label.
" amount=".$amount.
" num_chq=".$num_chq.
" autocreatethirdparty=".$autocreatethirdparty);
1767 if ($option ==
'bankdirect' && $accountid) {
1768 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
1771 $result = $acct->fetch($accountid);
1773 $dateop = $paymentdate;
1775 $insertid = $acct->addline($dateop, $operation, $label, $amount, $num_chq,
'', $user, $emetteur_nom, $emetteur_banque);
1776 if ($insertid > 0) {
1777 $inserturlid = $acct->add_url_line($insertid, $this->
id, DOL_URL_ROOT.
'/adherents/card.php?rowid=', $this->getFullname($langs),
'member');
1778 if ($inserturlid > 0) {
1780 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"subscription SET fk_bank=".((int) $insertid);
1781 $sql .=
" WHERE rowid=".((int) $subscriptionid);
1783 dol_syslog(
"subscription::subscription", LOG_DEBUG);
1784 $resql = $this->
db->query(
$sql);
1787 $this->error = $this->
db->lasterror();
1788 $this->errors[] = $this->error;
1801 if (($option ==
'bankviainvoice' && $accountid) || $option ==
'invoiceonly') {
1802 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1803 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/paymentterm.class.php';
1809 if (!($this->fk_soc > 0)) {
1810 if ($autocreatethirdparty) {
1815 if ($this->morphy ==
'mor') {
1816 $companyname = $this->company;
1817 if (!empty($fullname)) {
1818 $companyalias = $fullname;
1821 $companyname = $fullname;
1822 if (!empty($this->company)) {
1823 $companyalias = $this->company;
1827 $result = $customer->create_from_member($this, $companyname, $companyalias);
1829 $this->error = $customer->error;
1830 $this->errors = $customer->errors;
1833 $this->fk_soc = $result;
1836 $langs->load(
"errors");
1837 $this->error = $langs->trans(
"ErrorMemberNotLinkedToAThirpartyLinkOrCreateFirst");
1838 $this->errors[] = $this->error;
1844 $result = $customer->fetch($this->fk_soc);
1846 $this->error = $customer->error;
1847 $this->errors = $customer->errors;
1855 $invoice->cond_reglement_id = $customer->cond_reglement_id;
1856 if (empty($invoice->cond_reglement_id)) {
1858 $invoice->cond_reglement_id = $paymenttermstatic->getDefaultId();
1859 if (empty($invoice->cond_reglement_id)) {
1861 $this->error =
'ErrorNoPaymentTermRECEPFound';
1862 $this->errors[] = $this->error;
1865 $invoice->socid = $this->fk_soc;
1870 $invoice->linked_objects[
'subscription'] = $subscriptionid;
1871 if (!empty($_POST[
'other_linked_objects']) && is_array($_POST[
'other_linked_objects'])) {
1872 $invoice->linked_objects = array_merge($invoice->linked_objects, $_POST[
'other_linked_objects']);
1875 $result = $invoice->create($user);
1877 $this->error = $invoice->error;
1878 $this->errors = $invoice->errors;
1881 $this->invoice = $invoice;
1887 $idprodsubscription = 0;
1888 if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (
isModEnabled(
"product") ||
isModEnabled(
"service"))) {
1889 $idprodsubscription = $conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS;
1893 if (isset($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) && $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS ==
'defaultforfoundationcountry') {
1897 $result = $invoice->addline($label, 0, 1, $vattouse, 0, 0, $idprodsubscription, 0, $datesubscription,
'', 0, 0,
'',
'TTC', $amount, 1);
1899 $this->error = $invoice->error;
1900 $this->errors = $invoice->errors;
1907 $result = $invoice->validate($user);
1909 $this->error = $invoice->error;
1910 $this->errors = $invoice->errors;
1920 if (!$error && $option ==
'bankviainvoice' && $accountid) {
1921 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1922 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
1923 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions.lib.php';
1926 $amounts[$invoice->id] =
price2num($amount);
1929 $paiement->datepaye = $paymentdate;
1930 $paiement->amounts = $amounts;
1931 $paiement->paiementcode = $operation;
1932 $paiement->paiementid =
dol_getIdFromCode($this->
db, $operation,
'c_paiement',
'code',
'id', 1);
1933 $paiement->num_payment = $num_chq;
1934 $paiement->note_public = $label;
1935 $paiement->ext_payment_id = $ext_payment_id;
1936 $paiement->ext_payment_site = $ext_payment_site;
1940 $paiement_id = $paiement->create($user);
1941 if (!($paiement_id > 0)) {
1942 $this->error = $paiement->error;
1943 $this->errors = $paiement->errors;
1950 $bank_line_id = $paiement->addPaymentToBank($user,
'payment',
'(SubscriptionPayment)', $accountid, $emetteur_nom, $emetteur_banque);
1951 if (!($bank_line_id > 0)) {
1952 $this->error = $paiement->error;
1953 $this->errors = $paiement->errors;
1958 if (!$error && !empty($bank_line_id)) {
1960 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'subscription SET fk_bank='.((int) $bank_line_id);
1961 $sql .=
' WHERE rowid='.((int) $subscriptionid);
1963 $result = $this->
db->query(
$sql);
1971 $invoice->setPaid($user);
1977 $outputlangs = $langs;
1979 $lang_id =
GETPOST(
'lang_id');
1980 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && !empty($lang_id)) {
1981 $newlang = $lang_id;
1984 $newlang = $customer->default_lang;
1986 if (!empty($newlang)) {
1987 $outputlangs =
new Translate(
"", $conf);
1988 $outputlangs->setDefaultLang($newlang);
1993 $invoice->generateDocument($invoice->model_pdf, $outputlangs);
2013 global $langs, $conf;
2019 if ($this->statut == self::STATUS_VALIDATED) {
2020 dol_syslog(get_class($this).
"::validate statut of member does not allow this", LOG_WARNING);
2026 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
2027 $sql .=
" statut = ".self::STATUS_VALIDATED;
2028 $sql .=
", datevalid = '".$this->db->idate($now).
"'";
2029 $sql .=
", fk_user_valid = ".((int) $user->id);
2030 $sql .=
" WHERE rowid = ".((int) $this->
id);
2032 dol_syslog(get_class($this).
"::validate", LOG_DEBUG);
2033 $result = $this->
db->query(
$sql);
2038 $result = $this->
call_trigger(
'MEMBER_VALIDATE', $user);
2041 $this->
db->rollback();
2046 $this->datevalid = $now;
2048 $this->
db->commit();
2051 $this->error = $this->
db->error();
2052 $this->
db->rollback();
2066 global $langs, $conf;
2071 if ($this->statut == self::STATUS_RESILIATED) {
2072 dol_syslog(get_class($this).
"::resiliate statut of member does not allow this", LOG_WARNING);
2078 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
2079 $sql .=
" statut = ".self::STATUS_RESILIATED;
2080 $sql .=
", fk_user_valid=".$user->id;
2081 $sql .=
" WHERE rowid = ".((int) $this->
id);
2083 $result = $this->
db->query(
$sql);
2088 $result = $this->
call_trigger(
'MEMBER_RESILIATE', $user);
2091 $this->
db->rollback();
2096 $this->
db->commit();
2099 $this->error = $this->
db->error();
2100 $this->
db->rollback();
2116 global $langs, $conf;
2121 if ($this->statut == self::STATUS_EXCLUDED) {
2122 dol_syslog(get_class($this).
"::resiliate statut of member does not allow this", LOG_WARNING);
2128 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
2129 $sql .=
" statut = ".self::STATUS_EXCLUDED;
2130 $sql .=
", fk_user_valid=".$user->id;
2131 $sql .=
" WHERE rowid = ".((int) $this->
id);
2133 $result = $this->
db->query(
$sql);
2138 $result = $this->
call_trigger(
'MEMBER_EXCLUDE', $user);
2141 $this->
db->rollback();
2146 $this->
db->commit();
2149 $this->error = $this->
db->error();
2150 $this->
db->rollback();
2164 global $conf, $langs;
2166 include_once DOL_DOCUMENT_ROOT.
'/mailmanspip/class/mailmanspip.class.php';
2172 if (!empty($conf->global->ADHERENT_USE_MAILMAN) &&
isModEnabled(
'mailmanspip')) {
2173 $result = $mailmanspip->add_to_mailman($this);
2176 if (!empty($mailmanspip->error)) {
2177 $this->errors[] = $mailmanspip->error;
2181 foreach ($mailmanspip->mladded_ko as $tmplist => $tmpemail) {
2182 $langs->load(
"errors");
2183 $this->errors[] = $langs->trans(
"ErrorFailedToAddToMailmanList", $tmpemail, $tmplist);
2185 foreach ($mailmanspip->mladded_ok as $tmplist => $tmpemail) {
2186 $langs->load(
"mailmanspip");
2187 $this->mesgs[] = $langs->trans(
"SuccessToAddToMailmanList", $tmpemail, $tmplist);
2192 if (!empty($conf->global->ADHERENT_USE_SPIP) &&
isModEnabled(
'mailmanspip')) {
2193 $result = $mailmanspip->add_to_spip($this);
2195 $this->errors[] = $mailmanspip->error;
2216 global $conf, $langs;
2218 include_once DOL_DOCUMENT_ROOT.
'/mailmanspip/class/mailmanspip.class.php';
2224 if (!empty($conf->global->ADHERENT_USE_MAILMAN)) {
2225 $result = $mailmanspip->del_to_mailman($this);
2227 if (!empty($mailmanspip->error)) {
2228 $this->errors[] = $mailmanspip->error;
2233 foreach ($mailmanspip->mlremoved_ko as $tmplist => $tmpemail) {
2234 $langs->load(
"errors");
2235 $this->errors[] = $langs->trans(
"ErrorFailedToRemoveToMailmanList", $tmpemail, $tmplist);
2237 foreach ($mailmanspip->mlremoved_ok as $tmplist => $tmpemail) {
2238 $langs->load(
"mailmanspip");
2239 $this->mesgs[] = $langs->trans(
"SuccessToRemoveToMailmanList", $tmpemail, $tmplist);
2243 if ($conf->global->ADHERENT_USE_SPIP &&
isModEnabled(
'mailmanspip')) {
2244 $result = $mailmanspip->del_to_spip($this);
2246 $this->errors[] = $mailmanspip->error;
2267 $langs->load(
"dict");
2269 $code = (empty($this->civility_id) ?
'' : $this->civility_id);
2273 return $langs->getLabelFromKey($this->
db,
"Civility".$code,
"c_civility",
"code",
"label", $code);
2284 global $conf, $langs;
2286 $langs->loadLangs([
'members',
'companies']);
2287 $nofetch = !empty($params[
'nofetch']);
2291 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
2292 $langs->load(
"users");
2293 return [
'optimize' => $langs->trans(
"ShowUser")];
2295 if (!empty($this->photo)) {
2296 $photo =
'<div class="photointooltip floatright">';
2297 $photo .=
Form::showphoto(
'memberphoto', $this, 80, 0, 0,
'photoref photowithmargin photologintooltip',
'small', 0, 1);
2299 $datas[
'photo'] = $photo;
2302 $datas[
'divopen'] =
'<div class="centpercent">';
2303 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <u class="paddingrightonly">'.$langs->trans(
"Member").
'</u> '.$this->
getLibStatut(4);
2304 if (!empty($this->morphy)) {
2305 $datas[
'picto'] .=
' ' . $this->
getmorphylib(
'', 1);
2307 if (!empty($this->
ref)) {
2308 $datas[
'ref'] =
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
2310 if (!empty($this->login)) {
2311 $datas[
'login'] =
'<br><b>'.$langs->trans(
'Login').
':</b> '.$this->login;
2313 if (!empty($this->firstname) || !empty($this->lastname)) {
2314 $datas[
'name'] =
'<br><b>'.$langs->trans(
'Name').
':</b> '.$this->
getFullName($langs);
2316 if (!empty($this->company)) {
2317 $datas[
'company'] =
'<br><b>'.$langs->trans(
'Company').
':</b> '.$this->company;
2319 if (!empty($this->email)) {
2320 $datas[
'email'] =
'<br><b>'.$langs->trans(
"EMail").
':</b> '.$this->email;
2322 $datas[
'address'] =
'<br><b>'.$langs->trans(
"Address").
':</b> '.
dol_format_address($this, 1,
' ', $langs);
2325 require_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
2327 $datas[
'categories'] =
'<br>' .
$form->showCategories($this->
id, Categorie::TYPE_MEMBER, 1);
2329 $datas[
'divclose'] =
'</div>';
2347 public function getNomUrl($withpictoimg = 0, $maxlen = 0, $option =
'card', $mode =
'', $morecss =
'', $save_lastsearch_value = -1, $notooltip = 0, $addlinktonotes = 0)
2349 global $conf, $langs, $hookmanager;
2351 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpictoimg) {
2358 $classfortooltip =
'classfortooltip';
2362 'objecttype' => $this->element,
2363 'option' => $option,
2367 $classfortooltip =
'classforajaxtooltip';
2368 $dataparams =
' data-params='.json_encode($params);
2373 $url = DOL_URL_ROOT.
'/adherents/card.php?rowid='.((int) $this->
id);
2374 if ($option ==
'subscription') {
2375 $url = DOL_URL_ROOT.
'/adherents/subscription.php?rowid='.((int) $this->
id);
2378 if ($option !=
'nolink') {
2380 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
2381 if ($save_lastsearch_value == -1 && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
2382 $add_save_lastsearch_values = 1;
2384 if ($add_save_lastsearch_values) {
2385 $url .=
'&save_lastsearch_values=1';
2389 $linkstart .=
'<a href="'.$url.
'"';
2391 if (empty($notooltip)) {
2392 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
2393 $langs->load(
"users");
2394 $label = $langs->trans(
"ShowUser");
2395 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
2397 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
2398 $linkclose .= $dataparams.
' class="'.$classfortooltip.($morecss ?
' '.$morecss :
'').
'"';
2401 $linkstart .= $linkclose.
'>';
2404 $result .= $linkstart;
2405 if ($withpictoimg) {
2406 $result .=
'<div class="inline-block nopadding valignmiddle">';
2408 if ($withpictoimg) {
2409 $paddafterimage =
'';
2410 if (abs($withpictoimg) == 1) {
2411 $morecss .=
' paddingrightonly';
2414 if ($withpictoimg > 0) {
2415 $picto =
'<span class="nopadding'.($morecss ?
' userimg'.$morecss :
'').
'">'.
2416 img_object(
'',
'user', $paddafterimage.
' '.($notooltip ?
'' : $dataparams.
' class="'.$classfortooltip.
'"'), 0, 0, $notooltip ? 0 : 1).
'</span>';
2419 $picto =
'<span class="nopadding'.($morecss ?
' userimg'.$morecss :
'').
'"'.($paddafterimage ?
' '.$paddafterimage :
'').
'>';
2420 $picto .=
Form::showphoto(
'memberphoto', $this, 0, 0, 0,
'userphoto'.($withpictoimg == -3 ?
'small' :
''),
'mini', 0, 1);
2421 $picto .=
'</span>';
2425 if ($withpictoimg > -2 && $withpictoimg != 2) {
2426 if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
2427 $result .=
'<span class="nopadding valignmiddle'.((!isset($this->statut) || $this->statut) ?
'' :
' strikefordisabled').
2428 ($morecss ?
' usertext'.$morecss :
'').
'">';
2430 if ($mode ==
'login') {
2431 $result .=
dol_trunc($this->login, $maxlen);
2432 } elseif ($mode ==
'ref') {
2433 $result .= $this->ref;
2435 $result .= $this->
getFullName($langs,
'', ($mode ==
'firstname' ? 2 : ($mode ==
'lastname' ? 4 : -1)), $maxlen);
2437 if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
2438 $result .=
'</span>';
2441 if ($withpictoimg) {
2442 $result .=
'</div>';
2444 $result .= $linkend;
2446 if ($addlinktonotes) {
2447 if ($this->note_private) {
2448 $notetoshow = $langs->trans(
"ViewPrivateNote").
':<br>'.
dol_string_nohtmltag($this->note_private, 1);
2449 $result .=
' <span class="note inline-block">';
2450 $result .=
'<a href="'.DOL_URL_ROOT.
'/adherents/note.php?id='.$this->
id.
'" class="classfortooltip" title="'.
dol_escape_htmltag($notetoshow).
'">';
2453 $result .=
'</span>';
2457 $hookmanager->initHooks(array($this->element .
'dao'));
2458 $parameters = array(
'id'=>$this->
id,
'getnomurl' => &$result);
2459 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
2461 $result = $hookmanager->resPrint;
2463 $result .= $hookmanager->resPrint;
2476 return $this->
LibStatut($this->statut, $this->need_subscription, $this->datefin, $mode);
2489 public function LibStatut($status, $need_subscription, $date_end_subscription, $mode = 0)
2493 $langs->load(
"members");
2497 $labelStatusShort =
'';
2499 if ($status == self::STATUS_DRAFT) {
2500 $statusType =
'status0';
2501 $labelStatus = $langs->trans(
"MemberStatusDraft");
2502 $labelStatusShort = $langs->trans(
"MemberStatusDraftShort");
2503 } elseif ($status >= self::STATUS_VALIDATED) {
2504 if ($need_subscription === 0) {
2505 $statusType =
'status4';
2506 $labelStatus = $langs->trans(
"MemberStatusNoSubscription");
2507 $labelStatusShort = $langs->trans(
"MemberStatusNoSubscriptionShort");
2508 } elseif (!$date_end_subscription) {
2509 $statusType =
'status1';
2510 $labelStatus = $langs->trans(
"MemberStatusActive");
2511 $labelStatusShort = $langs->trans(
"MemberStatusActiveShort");
2512 } elseif ($date_end_subscription <
dol_now()) {
2513 $statusType =
'status8';
2514 $labelStatus = $langs->trans(
"MemberStatusActiveLate");
2515 $labelStatusShort = $langs->trans(
"MemberStatusActiveLateShort");
2517 $statusType =
'status4';
2518 $labelStatus = $langs->trans(
"MemberStatusPaid");
2519 $labelStatusShort = $langs->trans(
"MemberStatusPaidShort");
2521 } elseif ($status == self::STATUS_RESILIATED) {
2522 $statusType =
'status6';
2523 $labelStatus = $langs->transnoentitiesnoconv(
"MemberStatusResiliated");
2524 $labelStatusShort = $langs->transnoentitiesnoconv(
"MemberStatusResiliatedShort");
2525 } elseif ($status == self::STATUS_EXCLUDED) {
2526 $statusType =
'status10';
2527 $labelStatus = $langs->transnoentitiesnoconv(
"MemberStatusExcluded");
2528 $labelStatusShort = $langs->transnoentitiesnoconv(
"MemberStatusExcludedShort");
2531 return dolGetStatus($labelStatus, $labelStatusShort,
'', $statusType, $mode);
2546 $this->nb = array();
2548 $sql =
"SELECT count(a.rowid) as nb";
2549 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as a";
2550 $sql .=
" WHERE a.statut > 0";
2551 $sql .=
" AND a.entity IN (".getEntity(
'adherent').
")";
2553 $resql = $this->
db->query(
$sql);
2555 while ($obj = $this->
db->fetch_object($resql)) {
2556 $this->nb[
"members"] = $obj->nb;
2558 $this->
db->free($resql);
2562 $this->error = $this->
db->error();
2578 global $conf, $langs;
2586 $sql =
"SELECT a.rowid, a.datefin, a.statut";
2587 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as a";
2588 $sql .=
", ".MAIN_DB_PREFIX.
"adherent_type as t";
2589 $sql .=
" WHERE a.fk_adherent_type = t.rowid";
2590 if ($mode ==
'expired') {
2591 $sql .=
" AND a.statut = ".self::STATUS_VALIDATED;
2592 $sql .=
" AND a.entity IN (".getEntity(
'adherent').
")";
2593 $sql .=
" AND ((a.datefin IS NULL or a.datefin < '".$this->db->idate($now).
"') AND t.subscription = '1')";
2594 } elseif ($mode ==
'shift') {
2595 $sql .=
" AND a.statut = ".self::STATUS_DRAFT;
2596 $sql .=
" AND a.entity IN (".getEntity(
'adherent').
")";
2599 $resql = $this->
db->query(
$sql);
2601 $langs->load(
"members");
2608 if ($mode ==
'expired') {
2609 $warning_delay = $conf->adherent->subscription->warning_delay / 60 / 60 / 24;
2610 $label = $langs->trans(
"MembersWithSubscriptionToReceive");
2611 $labelShort = $langs->trans(
"MembersWithSubscriptionToReceiveShort");
2612 $url = DOL_URL_ROOT.
'/adherents/list.php?mainmenu=members&statut='.self::STATUS_VALIDATED.
'&filter=outofdate';
2613 } elseif ($mode ==
'shift') {
2614 $warning_delay = $conf->adherent->subscription->warning_delay / 60 / 60 / 24;
2615 $url = DOL_URL_ROOT.
'/adherents/list.php?mainmenu=members&statut='.
self::STATUS_DRAFT;
2616 $label = $langs->trans(
"MembersListToValid");
2617 $labelShort = $langs->trans(
"ToValidate");
2621 $response->warning_delay = $warning_delay;
2622 $response->label = $label;
2623 $response->labelShort = $labelShort;
2624 $response->url = $url;
2629 while ($obj = $this->
db->fetch_object($resql)) {
2630 $response->nbtodo++;
2632 $adherentstatic->datefin = $this->
db->jdate($obj->datefin);
2633 $adherentstatic->statut = $obj->statut;
2635 if ($adherentstatic->hasDelay()) {
2636 $response->nbtodolate++;
2643 $this->error = $this->
db->error();
2660 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams =
null)
2662 global $conf, $langs;
2664 $langs->load(
"orders");
2667 $modele =
'standard';
2669 if ($this->model_pdf) {
2670 $modele = $this->model_pdf;
2671 } elseif (!empty($conf->global->ADHERENT_ADDON_PDF)) {
2672 $modele = $conf->global->ADHERENT_ADDON_PDF;
2676 $modelpath =
"core/modules/member/doc/";
2678 return $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
2691 global $user, $langs;
2696 $this->
ref =
'ABC001';
2698 $this->specimen = 1;
2699 $this->civility_id = 0;
2700 $this->lastname =
'DOLIBARR';
2701 $this->firstname =
'SPECIMEN';
2702 $this->gender =
'man';
2703 $this->login =
'dolibspec';
2704 $this->pass =
'dolibspec';
2705 $this->company =
'Societe ABC';
2706 $this->address =
'61 jump street';
2707 $this->zip =
'75000';
2708 $this->town =
'Paris';
2709 $this->country_id = 1;
2710 $this->country_code =
'FR';
2711 $this->country =
'France';
2712 $this->morphy =
'mor';
2713 $this->email =
'specimen@specimen.com';
2714 $this->socialnetworks = array(
2715 'skype' =>
'skypepseudo',
2716 'twitter' =>
'twitterpseudo',
2717 'facebook' =>
'facebookpseudo',
2718 'linkedin' =>
'linkedinpseudo',
2720 $this->phone =
'0999999999';
2721 $this->phone_perso =
'0999999998';
2722 $this->phone_mobile =
'0999999997';
2723 $this->note_public =
'This is a public note';
2724 $this->note_private =
'This is a private note';
2725 $this->birth = $now;
2730 $this->datefin = $now;
2731 $this->datevalid = $now;
2732 $this->default_lang =
'';
2735 $this->
type =
'Type adherent';
2736 $this->need_subscription = 0;
2738 $this->first_subscription_date = $now;
2739 $this->first_subscription_date_start = $this->first_subscription_date;
2740 $this->first_subscription_date_end =
dol_time_plus_duree($this->first_subscription_date_start, 1,
'y');
2741 $this->first_subscription_amount = 10;
2743 $this->last_subscription_date = $this->first_subscription_date;
2744 $this->last_subscription_date_start = $this->first_subscription_date;
2745 $this->last_subscription_date_end =
dol_time_plus_duree($this->last_subscription_date_start, 1,
'y');
2746 $this->last_subscription_amount = 10;
2768 $dn = $conf->global->LDAP_KEY_MEMBERS.
"=".$info[$conf->global->LDAP_KEY_MEMBERS].
",".$conf->global->LDAP_MEMBER_DN;
2771 $dn = $conf->global->LDAP_MEMBER_DN;
2774 $dn = $conf->global->LDAP_KEY_MEMBERS.
"=".$info[$conf->global->LDAP_KEY_MEMBERS];
2790 global $conf, $langs;
2794 $keymodified =
false;
2797 $info[
"objectclass"] = explode(
',', $conf->global->LDAP_MEMBER_OBJECT_CLASS);
2802 if ($this->morphy ==
'mor' && (empty($this->fullname) || $this->fullname == $this->company)) {
2803 $this->fullname = $this->company;
2804 $this->lastname = $this->company;
2809 'LDAP_MEMBER_FIELD_FULLNAME' =>
'fullname',
2810 'LDAP_MEMBER_FIELD_NAME' =>
'lastname',
2811 'LDAP_MEMBER_FIELD_LOGIN' =>
'login',
2812 'LDAP_MEMBER_FIELD_LOGIN_SAMBA' =>
'login',
2813 'LDAP_MEMBER_FIELD_MAIL' =>
'email'
2817 foreach ($ldapkey as $constname => $varname) {
2818 if (!empty($this->$varname) && !empty($conf->global->$constname)) {
2819 $info[$conf->global->$constname] = $this->$varname;
2822 if (!empty($conf->global->LDAP_KEY_MEMBERS) && $conf->global->LDAP_KEY_MEMBERS == $conf->global->$constname) {
2823 if (!empty($this->oldcopy) && $this->$varname != $this->oldcopy->$varname) {
2824 $keymodified =
true;
2829 if ($this->firstname && !empty($conf->global->LDAP_MEMBER_FIELD_FIRSTNAME)) {
2830 $info[$conf->global->LDAP_MEMBER_FIELD_FIRSTNAME] = $this->firstname;
2832 if ($this->poste && !empty($conf->global->LDAP_MEMBER_FIELD_TITLE)) {
2833 $info[$conf->global->LDAP_MEMBER_FIELD_TITLE] = $this->poste;
2835 if ($this->company && !empty($conf->global->LDAP_MEMBER_FIELD_COMPANY)) {
2836 $info[$conf->global->LDAP_MEMBER_FIELD_COMPANY] = $this->company;
2838 if ($this->address && !empty($conf->global->LDAP_MEMBER_FIELD_ADDRESS)) {
2839 $info[$conf->global->LDAP_MEMBER_FIELD_ADDRESS] = $this->address;
2841 if ($this->zip && !empty($conf->global->LDAP_MEMBER_FIELD_ZIP)) {
2842 $info[$conf->global->LDAP_MEMBER_FIELD_ZIP] = $this->zip;
2844 if ($this->town && !empty($conf->global->LDAP_MEMBER_FIELD_TOWN)) {
2845 $info[$conf->global->LDAP_MEMBER_FIELD_TOWN] = $this->town;
2847 if ($this->country_code && !empty($conf->global->LDAP_MEMBER_FIELD_COUNTRY)) {
2848 $info[$conf->global->LDAP_MEMBER_FIELD_COUNTRY] = $this->country_code;
2850 foreach ($socialnetworks as $key => $value) {
2851 if ($this->socialnetworks[$value[
'label']] && !empty($conf->global->{
'LDAP_MEMBER_FIELD_'.strtoupper($value[
'label'])})) {
2852 $info[$conf->global->{
'LDAP_MEMBER_FIELD_'.strtoupper($value[
'label'])}] = $this->socialnetworks[$value[
'label']];
2855 if ($this->phone && !empty($conf->global->LDAP_MEMBER_FIELD_PHONE)) {
2856 $info[$conf->global->LDAP_MEMBER_FIELD_PHONE] = $this->phone;
2858 if ($this->phone_perso && !empty($conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO)) {
2859 $info[$conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO] = $this->phone_perso;
2861 if ($this->phone_mobile && !empty($conf->global->LDAP_MEMBER_FIELD_MOBILE)) {
2862 $info[$conf->global->LDAP_MEMBER_FIELD_MOBILE] = $this->phone_mobile;
2864 if ($this->fax && !empty($conf->global->LDAP_MEMBER_FIELD_FAX)) {
2865 $info[$conf->global->LDAP_MEMBER_FIELD_FAX] = $this->fax;
2867 if ($this->note_private && !empty($conf->global->LDAP_MEMBER_FIELD_DESCRIPTION)) {
2868 $info[$conf->global->LDAP_MEMBER_FIELD_DESCRIPTION] =
dol_string_nohtmltag($this->note_private, 2);
2870 if ($this->note_public && !empty($conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC)) {
2871 $info[$conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC] =
dol_string_nohtmltag($this->note_public, 2);
2873 if ($this->birth && !empty($conf->global->LDAP_MEMBER_FIELD_BIRTHDATE)) {
2874 $info[$conf->global->LDAP_MEMBER_FIELD_BIRTHDATE] =
dol_print_date($this->birth,
'dayhourldap');
2876 if (isset($this->statut) && !empty($conf->global->LDAP_FIELD_MEMBER_STATUS)) {
2877 $info[$conf->global->LDAP_FIELD_MEMBER_STATUS] = $this->statut;
2879 if ($this->datefin && !empty($conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION)) {
2880 $info[$conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION] =
dol_print_date($this->datefin,
'dayhourldap');
2884 if (!empty($this->pass)) {
2885 if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD)) {
2886 $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD] = $this->pass;
2888 if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) {
2889 $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] =
dol_hash($this->pass,
'openldap');
2891 } elseif ($conf->global->LDAP_SERVER_PROTOCOLVERSION !==
'3') {
2894 if (!empty($conf->global->DATABASE_PWD_ENCRYPTED)) {
2896 if (empty($conf->global->MAIN_SECURITY_HASH_ALGO)) {
2897 if ($this->pass_indatabase_crypted && !empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) {
2900 $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] =
dolGetLdapPasswordHash($this->pass_indatabase_crypted,
'md5frommd5');
2903 } elseif (!empty($this->pass_indatabase)) {
2905 if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD)) {
2906 $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD] = $this->pass_indatabase;
2908 if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) {
2909 $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] =
dol_hash($this->pass_indatabase,
'openldap');
2915 if ($this->first_subscription_date && !empty($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE)) {
2916 $info[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE] =
dol_print_date($this->first_subscription_date,
'dayhourldap');
2918 if (isset($this->first_subscription_amount) && !empty($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT)) {
2919 $info[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT] = $this->first_subscription_amount;
2921 if ($this->last_subscription_date && !empty($conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE)) {
2922 $info[$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE] =
dol_print_date($this->last_subscription_date,
'dayhourldap');
2924 if (isset($this->last_subscription_amount) && !empty($conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT)) {
2925 $info[$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT] = $this->last_subscription_amount;
2940 $sql =
'SELECT a.rowid, a.datec as datec,';
2941 $sql .=
' a.datevalid as datev,';
2942 $sql .=
' a.tms as datem,';
2943 $sql .=
' a.fk_user_author, a.fk_user_valid, a.fk_user_mod';
2944 $sql .=
' FROM '.MAIN_DB_PREFIX.
'adherent as a';
2945 $sql .=
' WHERE a.rowid = '.((int) $id);
2947 dol_syslog(get_class($this).
"::info", LOG_DEBUG);
2948 $result = $this->
db->query(
$sql);
2950 if ($this->
db->num_rows($result)) {
2951 $obj = $this->
db->fetch_object($result);
2952 $this->
id = $obj->rowid;
2954 $this->user_creation_id = $obj->fk_user_author;
2955 $this->user_validation_id = $obj->fk_user_valid;
2956 $this->user_modification_id = $obj->fk_user_mod;
2957 $this->date_creation = $this->
db->jdate($obj->datec);
2958 $this->date_validation = $this->
db->jdate($obj->datev);
2959 $this->date_modification = $this->
db->jdate($obj->datem);
2962 $this->
db->free($result);
2975 $sql =
"SELECT count(mc.email) as nb";
2976 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mailing_cibles as mc";
2977 $sql .=
" WHERE mc.email = '".$this->db->escape($this->email).
"'";
2978 $sql .=
" AND mc.statut NOT IN (-1,0)";
2980 $resql = $this->
db->query(
$sql);
2982 $obj = $this->
db->fetch_object($resql);
2985 $this->
db->free($resql);
2988 $this->error = $this->
db->error();
3005 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
3006 return parent::setCategoriesCommon($categories, Categorie::TYPE_MEMBER);
3019 $tables = array(
'adherent');
3034 if ($this->statut != self::STATUS_VALIDATED) {
3037 if (!$this->datefin) {
3043 return $this->datefin < ($now - $conf->adherent->subscription->warning_delay);
3056 global $conf, $langs, $mysoc, $user;
3062 $blockingerrormsg =
'';
3064 if (empty($conf->adherent->enabled)) {
3065 $langs->load(
"agenda");
3066 $this->output = $langs->trans(
'ModuleNotEnabled', $langs->transnoentitiesnoconv(
"Adherent"));
3069 if (empty($conf->global->MEMBER_REMINDER_EMAIL)) {
3070 $langs->load(
"agenda");
3071 $this->output = $langs->trans(
'EventRemindersByEmailNotEnabled', $langs->transnoentitiesnoconv(
"Adherent"));
3079 $listofmembersok = array();
3080 $listofmembersko = array();
3082 $arraydaysbeforeend = explode(
';', $daysbeforeendlist);
3083 foreach ($arraydaysbeforeend as $daysbeforeend) {
3084 dol_syslog(__METHOD__.
' - Process delta = '.$daysbeforeend, LOG_DEBUG);
3086 if (!is_numeric($daysbeforeend)) {
3087 $blockingerrormsg =
"Value for delta is not a numeric value";
3095 $sql =
'SELECT rowid FROM '.MAIN_DB_PREFIX.
'adherent';
3096 $sql .=
" WHERE entity = ".((int) $conf->entity);
3097 $sql .=
" AND datefin = '".$this->db->idate($datetosearchfor).
"'";
3100 $resql = $this->
db->query(
$sql);
3102 $num_rows = $this->
db->num_rows($resql);
3104 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
3109 while ($i < $num_rows) {
3110 $obj = $this->
db->fetch_object($resql);
3112 $adherent->fetch($obj->rowid,
'',
'',
'',
true,
true);
3114 if (empty($adherent->email)) {
3116 $listofmembersko[$adherent->id] = $adherent->id;
3118 $adherent->fetch_thirdparty();
3121 $languagefromcountrycode =
getLanguageCodeFromCountryCode($adherent->country_code ? $adherent->country_code : $adherent->thirdparty->country_code);
3122 $languagecodeformember = (empty($adherent->thirdparty->default_lang) ? ($languagefromcountrycode ? $languagefromcountrycode : $mysoc->default_lang) : $adherent->thirdparty->default_lang);
3125 $outputlangs =
new Translate(
'', $conf);
3126 $outputlangs->setDefaultLang($languagecodeformember);
3127 $outputlangs->loadLangs(array(
"main",
"members"));
3128 dol_syslog(
"sendReminderForExpiredSubscription Language for member id ".$adherent->id.
" set to ".$outputlangs->defaultlang.
" mysoc->default_lang=".$mysoc->default_lang);
3130 $arraydefaultmessage =
null;
3133 if (!empty($labeltouse)) {
3134 $arraydefaultmessage = $formmail->getEMailTemplate($this->
db,
'member', $user, $outputlangs, 0, 1, $labeltouse);
3137 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
3142 $subject =
make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs);
3143 $msg =
make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs);
3145 $to = $adherent->email;
3147 $trackid =
'mem'.$adherent->id;
3148 $moreinheader =
'X-Dolibarr-Info: sendReminderForExpiredSubscription'.
"\r\n";
3150 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
3151 $cmail =
new CMailFile($subject, $to, $from, $msg, array(), array(), array(),
'',
'', 0, 1,
'',
'', $trackid, $moreinheader);
3152 $result = $cmail->sendfile();
3155 $this->error .= $cmail->error.
' ';
3156 if (!is_null($cmail->errors)) {
3157 $this->errors += $cmail->errors;
3160 $listofmembersko[$adherent->id] = $adherent->id;
3163 $listofmembersok[$adherent->id] = $adherent->id;
3169 $actioncode =
'EMAIL';
3180 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic').
": ".$subject);
3181 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody').
":");
3185 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
3190 $actioncomm->type_code =
'AC_OTH_AUTO';
3191 $actioncomm->code =
'AC_'.$actioncode;
3192 $actioncomm->label = $actionmsg2;
3193 $actioncomm->note_private = $actionmsg;
3194 $actioncomm->fk_project = 0;
3195 $actioncomm->datep = $now;
3196 $actioncomm->datef = $now;
3197 $actioncomm->percentage = -1;
3198 $actioncomm->socid = $adherent->thirdparty->id;
3199 $actioncomm->contact_id = 0;
3200 $actioncomm->authorid = $user->id;
3201 $actioncomm->userownerid = $user->id;
3203 $actioncomm->email_msgid = $cmail->msgid;
3204 $actioncomm->email_from = $from;
3205 $actioncomm->email_sender =
'';
3206 $actioncomm->email_to = $to;
3207 $actioncomm->email_tocc = $sendtocc;
3208 $actioncomm->email_tobcc = $sendtobcc;
3209 $actioncomm->email_subject = $subject;
3210 $actioncomm->errors_to =
'';
3212 $actioncomm->fk_element = $adherent->id;
3213 $actioncomm->elementtype = $adherent->element;
3215 $actioncomm->extraparams = $extraparams;
3217 $actioncomm->create($user);
3223 $this->error .=
"Can't find email template with label=".$labeltouse.
", to use for the reminding email ";
3226 $listofmembersko[$adherent->id] = $adherent->id;
3235 $this->error = $this->
db->lasterror();
3240 if ($blockingerrormsg) {
3241 $this->error = $blockingerrormsg;
3244 $this->output =
'Found '.($nbok + $nbko).
' members to send reminder to.';
3245 $this->output .=
' Send email successfuly to '.$nbok.
' members';
3246 if (is_array($listofmembersok)) {
3249 foreach ($listofmembersok as $idmember) {
3251 $listofids .=
', ...';
3254 if (empty($listofids)) {
3259 $listofids .= $idmember;
3266 $this->output .= ($listofids ?
' ids='.$listofids :
'');
3269 $this->output .=
' - Canceled for '.$nbko.
' member (no email or email sending error)';
3270 if (is_array($listofmembersko)) {
3273 foreach ($listofmembersko as $idmember) {
3275 $listofids .=
', ...';
3278 if (empty($listofids)) {
3283 $listofids .= $idmember;
3289 $this->output .= ($listofids ?
' ids='.$listofids :
'');
3307 $return =
'<div class="box-flex-item box-flex-grow-zero">';
3308 $return .=
'<div class="info-box info-box-sm">';
3309 $return .=
'<span class="info-box-icon bg-infobox-action">';
3311 if (property_exists($this,
'photo') || !empty($this->photo)) {
3312 $return.=
Form::showphoto(
'memberphoto', $this, 0, 60, 0,
'photokanban photoref photowithmargin photologintooltip',
'small', 0, 1);
3316 $return .=
'</span>';
3317 $return .=
'<div class="info-box-content">';
3318 $return .=
'<span class="info-box-ref">'.(method_exists($this,
'getNomUrl') ? $this->getNomUrl() : $this->ref).
'</span>';
3319 if (property_exists($this,
'type')) {
3320 $return .=
'<br><span class="info-box-label opacitymedium">'.$this->type.
'</span>';
3322 if (method_exists($this,
'getmorphylib')) {
3323 $return .=
'<br><span class="info-box-label">'.$this->getmorphylib(
'', 2).
'</span>';
3325 if (method_exists($this,
'getLibStatut')) {
3326 $return .=
'<br><div class="info-box-status margintoponly">'.$this->getLibStatut(5).
'</div>';
3328 $return .=
'</div>';
3329 $return .=
'</div>';
3330 $return .=
'</div>';