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;
222 public $default_lang;
262 public $need_subscription;
273 public $first_subscription_date;
275 public $first_subscription_amount;
277 public $last_subscription_date;
279 public $last_subscription_date_start;
281 public $last_subscription_date_end;
283 public $last_subscription_amount;
285 public $subscriptions = array();
290 public $partnerships = array();
306 public $fields = array(
307 'rowid' => array(
'type' =>
'integer',
'label' =>
'TechnicalID',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 10),
308 'ref' => array(
'type' =>
'varchar(30)',
'label' =>
'Ref',
'default' => 1,
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 12,
'index' => 1),
309 'entity' => array(
'type' =>
'integer',
'label' =>
'Entity',
'default' => 1,
'enabled' => 1,
'visible' => -2,
'notnull' => 1,
'position' => 15,
'index' => 1),
310 'ref_ext' => array(
'type' =>
'varchar(128)',
'label' =>
'Ref ext',
'enabled' => 1,
'visible' => 0,
'position' => 20),
311 'civility' => array(
'type' =>
'varchar(6)',
'label' =>
'Civility',
'enabled' => 1,
'visible' => -1,
'position' => 25),
312 'lastname' => array(
'type' =>
'varchar(50)',
'label' =>
'Lastname',
'enabled' => 1,
'visible' => -1,
'position' => 30,
'showoncombobox'=>1),
313 'firstname' => array(
'type' =>
'varchar(50)',
'label' =>
'Firstname',
'enabled' => 1,
'visible' => -1,
'position' => 35,
'showoncombobox'=>1),
314 'login' => array(
'type' =>
'varchar(50)',
'label' =>
'Login',
'enabled' => 1,
'visible' => -1,
'position' => 40),
315 'gender' => array(
'type' =>
'varchar(10)',
'label' =>
'Gender',
'enabled' => 1,
'visible' => -1,
'position' => 250),
316 'pass' => array(
'type' =>
'varchar(50)',
'label' =>
'Pass',
'enabled' => 1,
'visible' => -1,
'position' => 45),
317 'pass_crypted' => array(
'type' =>
'varchar(128)',
'label' =>
'Pass crypted',
'enabled' => 1,
'visible' => -1,
'position' => 50),
318 'fk_adherent_type' => array(
'type' =>
'integer',
'label' =>
'Fk adherent type',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 55),
319 'morphy' => array(
'type' =>
'varchar(3)',
'label' =>
'MorPhy',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 60),
320 'societe' => array(
'type' =>
'varchar(128)',
'label' =>
'Societe',
'enabled' => 1,
'visible' => -1,
'position' => 65,
'showoncombobox'=>2),
321 'fk_soc' => array(
'type' =>
'integer:Societe:societe/class/societe.class.php',
'label' =>
'ThirdParty',
'enabled' => 1,
'visible' => -1,
'position' => 70),
322 'address' => array(
'type' =>
'text',
'label' =>
'Address',
'enabled' => 1,
'visible' => -1,
'position' => 75),
323 'zip' => array(
'type' =>
'varchar(10)',
'label' =>
'Zip',
'enabled' => 1,
'visible' => -1,
'position' => 80),
324 'town' => array(
'type' =>
'varchar(50)',
'label' =>
'Town',
'enabled' => 1,
'visible' => -1,
'position' => 85),
325 'state_id' => array(
'type' =>
'integer',
'label' =>
'State id',
'enabled' => 1,
'visible' => -1,
'position' => 90),
326 'country' => array(
'type' =>
'integer:Ccountry:core/class/ccountry.class.php',
'label' =>
'Country',
'enabled' => 1,
'visible' => -1,
'position' => 95),
327 'email' => array(
'type' =>
'varchar(255)',
'label' =>
'Email',
'enabled' => 1,
'visible' => -1,
'position' => 100),
328 'url' =>array(
'type'=>
'varchar(255)',
'label'=>
'Url',
'enabled'=>1,
'visible'=>-1,
'position'=>110),
329 'socialnetworks' => array(
'type' =>
'text',
'label' =>
'Socialnetworks',
'enabled' => 1,
'visible' => -1,
'position' => 105),
330 'phone' => array(
'type' =>
'varchar(30)',
'label' =>
'Phone',
'enabled' => 1,
'visible' => -1,
'position' => 115),
331 'phone_perso' => array(
'type' =>
'varchar(30)',
'label' =>
'Phone perso',
'enabled' => 1,
'visible' => -1,
'position' => 120),
332 'phone_mobile' => array(
'type' =>
'varchar(30)',
'label' =>
'Phone mobile',
'enabled' => 1,
'visible' => -1,
'position' => 125),
333 'birth' => array(
'type' =>
'date',
'label' =>
'DateOfBirth',
'enabled' => 1,
'visible' => -1,
'position' => 130),
334 'photo' => array(
'type' =>
'varchar(255)',
'label' =>
'Photo',
'enabled' => 1,
'visible' => -1,
'position' => 135),
335 'public' => array(
'type' =>
'smallint(6)',
'label' =>
'Public',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 145),
336 'datefin' => array(
'type' =>
'datetime',
'label' =>
'DateEnd',
'enabled' => 1,
'visible' => -1,
'position' => 150),
337 'default_lang' =>array(
'type'=>
'varchar(6)',
'label'=>
'Default lang',
'enabled'=>1,
'visible'=>-1,
'position'=> 153),
338 'note_public' => array(
'type' =>
'text',
'label' =>
'NotePublic',
'enabled' => 1,
'visible' => 0,
'position' => 155),
339 'note_private' => array(
'type' =>
'text',
'label' =>
'NotePrivate',
'enabled' => 1,
'visible' => 0,
'position' => 160),
340 'datevalid' => array(
'type' =>
'datetime',
'label' =>
'DateValidation',
'enabled' => 1,
'visible' => -1,
'position' => 165),
341 'datec' => array(
'type' =>
'datetime',
'label' =>
'DateCreation',
'enabled' => 1,
'visible' => -1,
'position' => 170),
342 'tms' => array(
'type' =>
'timestamp',
'label' =>
'DateModification',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 175),
343 'fk_user_author' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'Fk user author',
'enabled' => 1,
'visible' => -1,
'position' => 180),
344 'fk_user_mod' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'Fk user mod',
'enabled' => 1,
'visible' => -1,
'position' => 185),
345 'fk_user_valid' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'UserValidation',
'enabled' => 1,
'visible' => -1,
'position' => 190),
346 'canvas' => array(
'type' =>
'varchar(32)',
'label' =>
'Canvas',
'enabled' => 1,
'visible' => -1,
'position' => 195),
347 'statut' => array(
'type' =>
'smallint(6)',
'label' =>
'Statut',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 500,
348 'arrayofkeyval' => array(-1 =>
'Draft', 1 =>
'Validated', 0 =>
'MemberStatusResiliatedShort', -2 =>
'MemberStatusExcludedShort')),
349 'model_pdf' => array(
'type' =>
'varchar(255)',
'label' =>
'Model pdf',
'enabled' => 1,
'visible' => 0,
'position' => 800),
350 'import_key' => array(
'type' =>
'varchar(14)',
'label' =>
'ImportId',
'enabled' => 1,
'visible' => -2,
'position' => 805)
380 $this->status = $this->statut;
384 $this->array_options = array();
405 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 =
'')
408 global $conf, $langs;
411 if ($msgishtml == -1) {
418 dol_syslog(
'send_an_email msgishtml='.$msgishtml);
427 $from = $conf->email_from;
428 if (!empty($conf->global->ADHERENT_MAIL_FROM)) {
429 $from = $conf->global->ADHERENT_MAIL_FROM;
432 $trackid =
'mem'.$this->id;
435 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
436 $mailfile =
new CMailFile($subjecttosend, $this->email, $from, $texttosend, $filename_list, $mimetype_list, $mimefilename_list, $addr_cc, $addr_bcc, $deliveryreceipt, $msgishtml,
'',
'', $trackid, $moreinheader);
437 if ($mailfile->sendfile()) {
440 $this->error = $langs->trans(
"ErrorFailedToSendMail", $from, $this->email).
'. '.$mailfile->error;
454 global $conf, $langs;
464 if ($this->civility_id) {
465 $infos .= $langs->transnoentities(
"UserTitle").
": ".$this->
getCivilityLabel().
"\n";
467 $infos .= $langs->transnoentities(
"id").
": ".$this->
id.
"\n";
468 $infos .= $langs->transnoentities(
"ref").
": ".$this->
ref.
"\n";
469 $infos .= $langs->transnoentities(
"Lastname").
": ".$this->lastname.
"\n";
470 $infos .= $langs->transnoentities(
"Firstname").
": ".$this->firstname.
"\n";
471 $infos .= $langs->transnoentities(
"Company").
": ".$this->company.
"\n";
472 $infos .= $langs->transnoentities(
"Address").
": ".$this->address.
"\n";
473 $infos .= $langs->transnoentities(
"Zip").
": ".$this->zip.
"\n";
474 $infos .= $langs->transnoentities(
"Town").
": ".$this->town.
"\n";
475 $infos .= $langs->transnoentities(
"Country").
": ".$this->country.
"\n";
476 $infos .= $langs->transnoentities(
"EMail").
": ".$this->email.
"\n";
477 $infos .= $langs->transnoentities(
"PhonePro").
": ".$this->phone.
"\n";
478 $infos .= $langs->transnoentities(
"PhonePerso").
": ".$this->phone_perso.
"\n";
479 $infos .= $langs->transnoentities(
"PhoneMobile").
": ".$this->phone_mobile.
"\n";
480 if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
481 $infos .= $langs->transnoentities(
"Login").
": ".$this->login.
"\n";
482 $infos .= $langs->transnoentities(
"Password").
": ".$this->pass.
"\n";
484 $infos .= $langs->transnoentities(
"Birthday").
": ".$birthday.
"\n";
485 $infos .= $langs->transnoentities(
"Photo").
": ".$this->photo.
"\n";
486 $infos .= $langs->transnoentities(
"Public").
": ".
yn($this->
public);
489 $substitutionarray = array(
490 '__ID__' => $this->
id,
491 '__REF__' => $this->
ref,
492 '__MEMBER_ID__' => $this->
id,
494 '__FIRSTNAME__' => $msgishtml ?
dol_htmlentitiesbr($this->firstname) : ($this->firstname ? $this->firstname :
''),
495 '__LASTNAME__' => $msgishtml ?
dol_htmlentitiesbr($this->lastname) : ($this->lastname ? $this->lastname :
''),
497 '__COMPANY__' => $msgishtml ?
dol_htmlentitiesbr($this->company) : ($this->company ? $this->company :
''),
498 '__ADDRESS__' => $msgishtml ?
dol_htmlentitiesbr($this->address) : ($this->address ? $this->address :
''),
499 '__ZIP__' => $msgishtml ?
dol_htmlentitiesbr($this->zip) : ($this->zip ? $this->zip :
''),
500 '__TOWN__' => $msgishtml ?
dol_htmlentitiesbr($this->town) : ($this->town ? $this->town :
''),
501 '__COUNTRY__' => $msgishtml ?
dol_htmlentitiesbr($this->country) : ($this->country ? $this->country :
''),
502 '__EMAIL__' => $msgishtml ?
dol_htmlentitiesbr($this->email) : ($this->email ? $this->email :
''),
503 '__BIRTH__' => $msgishtml ?
dol_htmlentitiesbr($birthday) : ($birthday ? $birthday :
''),
504 '__PHOTO__' => $msgishtml ?
dol_htmlentitiesbr($this->photo) : ($this->photo ? $this->photo :
''),
505 '__LOGIN__' => $msgishtml ?
dol_htmlentitiesbr($this->login) : ($this->login ? $this->login :
''),
506 '__PASSWORD__' => $msgishtml ?
dol_htmlentitiesbr($this->pass) : ($this->pass ? $this->pass :
''),
507 '__PHONE__' => $msgishtml ?
dol_htmlentitiesbr($this->phone) : ($this->phone ? $this->phone :
''),
508 '__PHONEPRO__' => $msgishtml ?
dol_htmlentitiesbr($this->phone_perso) : ($this->phone_perso ? $this->phone_perso :
''),
509 '__PHONEMOBILE__' => $msgishtml ?
dol_htmlentitiesbr($this->phone_mobile) : ($this->phone_mobile ? $this->phone_mobile :
''),
532 $morphy = $this->morphy;
537 $labeltoshowm = $langs->trans(
"Moral");
538 $labeltoshowp = $langs->trans(
"Physical");
539 if ($morphy ==
'phy') {
540 $labeltoshow = $labeltoshowp;
541 if ($addbadge == 2) {
547 $s .=
'<span class="member-individual-back paddingleftimp paddingrightimp" title="'.$langs->trans(
"Physical").
'">'.$labeltoshow.
'</span>';
549 if ($morphy ==
'mor') {
550 $labeltoshow = $labeltoshowm;
551 if ($addbadge == 2) {
557 $s .=
'<span class="member-company-back paddingleftimp paddingrightimp" title="'.$langs->trans(
"Moral").
'">'.$labeltoshow.
'</span>';
560 if ($morphy ==
'phy') {
561 $s = $langs->trans(
"Physical");
562 } elseif ($morphy ==
'mor') {
563 $s = $langs->trans(
"Moral");
577 public function create($user, $notrigger = 0)
579 global $conf, $langs;
586 $this->import_key = trim($this->import_key);
589 if (!empty($conf->global->ADHERENT_MAIL_REQUIRED) && !isValidEMail($this->email)) {
590 $langs->load(
"errors");
591 $this->error = $langs->trans(
"ErrorBadEMail", $this->email);
597 if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
598 if (empty($this->login)) {
599 $this->error = $langs->trans(
"ErrorWrongValueForParameterX",
"Login");
607 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"adherent";
608 $sql .=
" (ref, datec,login,fk_user_author,fk_user_mod,fk_user_valid,morphy,fk_adherent_type,entity,import_key, ip)";
611 $sql .=
", '".$this->db->idate($this->datec).
"'";
612 $sql .=
", ".($this->login ?
"'".$this->db->escape($this->login).
"'" :
"null");
613 $sql .=
", ".($user->id > 0 ? $user->id :
"null");
614 $sql .=
", null, null, '".$this->db->escape($this->morphy).
"'";
615 $sql .=
", ".((int) $this->
typeid);
616 $sql .=
", ".$conf->entity;
617 $sql .=
", ".(!empty($this->import_key) ?
"'".$this->db->escape($this->import_key).
"'" :
"null");
618 $sql .=
", ".(!empty($this->ip) ?
"'".$this->db->escape($this->ip).
"'" :
"null");
621 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
622 $result = $this->
db->query($sql);
624 $id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
"adherent");
627 $this->
ref = (string) $id;
630 $result = $this->
update($user, 1, 1, 0, 0,
'add');
632 $this->
db->rollback();
637 if ($this->user_id) {
639 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET";
640 $sql .=
" fk_member = ".((int) $this->
id);
641 $sql .=
" WHERE rowid = ".((int) $this->user_id);
642 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
645 $this->error =
'Failed to update user to make link with member';
646 $this->
db->rollback();
660 if (count($this->errors)) {
661 dol_syslog(get_class($this).
"::create ".implode(
',', $this->errors), LOG_ERR);
662 $this->
db->rollback();
669 $this->error =
'Failed to get last insert id';
670 dol_syslog(get_class($this).
"::create ".$this->error, LOG_ERR);
671 $this->
db->rollback();
675 $this->error = $this->
db->error();
676 $this->
db->rollback();
693 public function update($user, $notrigger = 0, $nosyncuser = 0, $nosyncuserpass = 0, $nosyncthirdparty = 0, $action =
'update')
695 global $conf, $langs, $hookmanager;
697 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
702 dol_syslog(get_class($this).
"::update notrigger=".$notrigger.
", nosyncuser=".$nosyncuser.
", nosyncuserpass=".$nosyncuserpass.
" nosyncthirdparty=".$nosyncthirdparty.
", email=".$this->email);
705 $this->lastname = trim($this->lastname) ? trim($this->lastname) : trim($this->lastname);
706 $this->firstname = trim($this->firstname) ? trim($this->firstname) : trim($this->firstname);
707 $this->gender = trim($this->gender);
708 $this->address = ($this->address ? $this->address : $this->address);
709 $this->zip = ($this->zip ? $this->zip : $this->zip);
710 $this->town = ($this->town ? $this->town : $this->town);
711 $this->country_id = ($this->country_id > 0 ? $this->country_id : $this->country_id);
712 $this->state_id = ($this->state_id > 0 ? $this->state_id : $this->state_id);
713 $this->note_public = ($this->note_public ? $this->note_public : $this->note_public);
714 $this->note_private = ($this->note_private ? $this->note_private : $this->note_private);
715 $this->url = $this->url ?
clean_url($this->url, 0) :
'';
718 if (!empty($conf->global->ADHERENT_MAIL_REQUIRED) && !isValidEMail($this->email)) {
719 $langs->load(
"errors");
720 $this->error = $langs->trans(
"ErrorBadEMail", $this->email);
726 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
727 $sql .=
" ref = '".$this->db->escape($this->
ref).
"'";
728 $sql .=
", civility = ".($this->civility_id ?
"'".$this->db->escape($this->civility_id).
"'" :
"null");
729 $sql .=
", firstname = ".($this->firstname ?
"'".$this->db->escape($this->firstname).
"'" :
"null");
730 $sql .=
", lastname = ".($this->lastname ?
"'".$this->db->escape($this->lastname).
"'" :
"null");
731 $sql .=
", gender = ".($this->gender != -1 ?
"'".$this->db->escape($this->gender).
"'" :
"null");
732 $sql .=
", login = ".($this->login ?
"'".$this->db->escape($this->login).
"'" :
"null");
733 $sql .=
", societe = ".($this->company ?
"'".$this->db->escape($this->company).
"'" : ($this->societe ?
"'".$this->db->escape($this->societe).
"'" :
"null"));
735 $sql .=
", fk_soc = ".($this->socid > 0 ? $this->
db->escape($this->socid) :
"null");
737 $sql .=
", address = ".($this->address ?
"'".$this->db->escape($this->address).
"'" :
"null");
738 $sql .=
", zip = ".($this->zip ?
"'".$this->db->escape($this->zip).
"'" :
"null");
739 $sql .=
", town = ".($this->town ?
"'".$this->db->escape($this->town).
"'" :
"null");
740 $sql .=
", country = ".($this->country_id > 0 ? $this->
db->escape($this->country_id) :
"null");
741 $sql .=
", state_id = ".($this->state_id > 0 ? $this->
db->escape($this->state_id) :
"null");
742 $sql .=
", email = '".$this->db->escape($this->email).
"'";
743 $sql .=
", url = ".(!empty($this->url) ?
"'".$this->db->escape($this->url).
"'" :
"null");
744 $sql .=
", socialnetworks = ".($this->socialnetworks ?
"'".$this->db->escape(json_encode($this->socialnetworks)).
"'" :
"null");
745 $sql .=
", phone = ".($this->phone ?
"'".$this->db->escape($this->phone).
"'" :
"null");
746 $sql .=
", phone_perso = ".($this->phone_perso ?
"'".$this->db->escape($this->phone_perso).
"'" :
"null");
747 $sql .=
", phone_mobile = ".($this->phone_mobile ?
"'".$this->db->escape($this->phone_mobile).
"'" :
"null");
748 $sql .=
", note_private = ".($this->note_private ?
"'".$this->db->escape($this->note_private).
"'" :
"null");
749 $sql .=
", note_public = ".($this->note_public ?
"'".$this->db->escape($this->note_public).
"'" :
"null");
750 $sql .=
", photo = ".($this->photo ?
"'".$this->db->escape($this->photo).
"'" :
"null");
751 $sql .=
", public = '".$this->db->escape($this->
public).
"'";
752 $sql .=
", statut = ".$this->db->escape($this->statut);
753 $sql .=
", default_lang = ".(!empty($this->default_lang) ?
"'".$this->db->escape($this->default_lang).
"'" :
"null");
754 $sql .=
", fk_adherent_type = ".$this->db->escape($this->
typeid);
755 $sql .=
", morphy = '".$this->db->escape($this->morphy).
"'";
756 $sql .=
", birth = ".($this->birth ?
"'".$this->db->idate($this->birth).
"'" :
"null");
758 if ($this->datefin) {
759 $sql .=
", datefin = '".$this->db->idate($this->datefin).
"'";
761 if ($this->datevalid) {
762 $sql .=
", datevalid = '".$this->db->idate($this->datevalid).
"'";
764 $sql .=
", fk_user_mod = ".($user->id > 0 ? $user->id :
'null');
765 $sql .=
" WHERE rowid = ".((int) $this->
id);
768 if (!empty($this->oldcopy) && $this->
typeid != $this->oldcopy->typeid) {
769 $sql2 =
"SELECT libelle as label";
770 $sql2 .=
" FROM ".MAIN_DB_PREFIX.
"adherent_type";
771 $sql2 .=
" WHERE rowid = ".((int) $this->
typeid);
772 $resql2 = $this->
db->query($sql2);
774 while ($obj = $this->
db->fetch_object($resql2)) {
775 $this->
type = $obj->label;
780 dol_syslog(get_class($this).
"::update update member", LOG_DEBUG);
783 unset($this->country_code);
784 unset($this->country);
785 unset($this->state_code);
788 $nbrowsaffected += $this->
db->affected_rows(
$resql);
801 if (!$error && $this->pass) {
802 dol_syslog(get_class($this).
"::update update password");
803 if ($this->pass != $this->pass_indatabase && $this->pass != $this->pass_indatabase_crypted) {
804 $isencrypted = empty($conf->global->DATABASE_PWD_ENCRYPTED) ? 0 : 1;
807 $result = $this->
setPassword($user, $this->pass, $isencrypted, $notrigger, $nosyncuserpass);
808 if (!$nbrowsaffected) {
816 dol_syslog(get_class($this).
"::update update link to user");
817 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = NULL WHERE fk_member = ".((int) $this->
id);
818 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
821 $this->error = $this->
db->error();
822 $this->
db->rollback();
826 if ($this->user_id > 0) {
827 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = ".((int) $this->
id).
" WHERE rowid = ".((int) $this->user_id);
828 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
831 $this->error = $this->
db->error();
832 $this->
db->rollback();
838 if (!$error && $nbrowsaffected) {
840 if (!$error && $this->user_id > 0 && !$nosyncuser) {
841 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
843 dol_syslog(get_class($this).
"::update update linked user");
845 $luser =
new User($this->
db);
846 $result = $luser->fetch($this->user_id);
853 if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
854 $luser->login = $this->login;
857 $luser->ref = $this->ref;
858 $luser->civility_id = $this->civility_id;
859 $luser->firstname = $this->firstname;
860 $luser->lastname = $this->lastname;
861 $luser->gender = $this->gender;
862 $luser->pass = $this->pass;
865 $luser->birth = $this->birth;
867 $luser->address = $this->address;
868 $luser->zip = $this->zip;
869 $luser->town = $this->town;
870 $luser->country_id = $this->country_id;
871 $luser->state_id = $this->state_id;
873 $luser->email = $this->email;
874 $luser->socialnetworks = $this->socialnetworks;
875 $luser->office_phone = $this->phone;
876 $luser->user_mobile = $this->phone_mobile;
878 $luser->lang = $this->default_lang;
880 $luser->fk_member = $this->id;
882 $result = $luser->update($user, 0, 1, 1);
884 $this->error = $luser->error;
885 dol_syslog(get_class($this).
"::update ".$this->error, LOG_ERR);
889 $this->error = $luser->error;
895 if (!$error && $this->fk_soc > 0 && !$nosyncthirdparty) {
896 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
898 dol_syslog(get_class($this).
"::update update linked thirdparty");
903 $result = $lthirdparty->fetch($this->fk_soc);
906 $lthirdparty->address = $this->address;
907 $lthirdparty->zip = $this->zip;
908 $lthirdparty->town = $this->town;
909 $lthirdparty->email = $this->email;
910 $lthirdparty->socialnetworks = $this->socialnetworks;
911 $lthirdparty->phone = $this->phone;
912 $lthirdparty->state_id = $this->state_id;
913 $lthirdparty->country_id = $this->country_id;
915 $lthirdparty->default_lang = $this->default_lang;
917 $result = $lthirdparty->update($this->fk_soc, $user, 0, 1, 1,
'update');
920 $this->error = $lthirdparty->error;
921 $this->errors = $lthirdparty->errors;
922 dol_syslog(get_class($this).
"::update ".$this->error, LOG_ERR);
925 } elseif ($result < 0) {
926 $this->error = $lthirdparty->error;
932 if (!$error && !$notrigger) {
943 return $nbrowsaffected;
945 $this->
db->rollback();
949 $this->
db->rollback();
950 $this->error = $this->
db->lasterror();
970 $sql =
"SELECT rowid, datec as dateop, dateadh as datedeb, datef as datefin";
971 $sql .=
" FROM ".MAIN_DB_PREFIX.
"subscription";
972 $sql .=
" WHERE fk_adherent = ".((int) $this->
id);
973 $sql .=
" ORDER by dateadh DESC";
975 dol_syslog(get_class($this).
"::update_end_date", LOG_DEBUG);
978 $obj = $this->
db->fetch_object(
$resql);
979 $dateop = $this->
db->jdate($obj->dateop);
980 $datedeb = $this->
db->jdate($obj->datedeb);
981 $datefin = $this->
db->jdate($obj->datefin);
983 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
984 $sql .=
" datefin=".($datefin !=
'' ?
"'".$this->db->idate($datefin).
"'" :
"null");
985 $sql .=
" WHERE rowid = ".((int) $this->
id);
987 dol_syslog(get_class($this).
"::update_end_date", LOG_DEBUG);
990 $this->last_subscription_date = $dateop;
991 $this->last_subscription_date_start = $datedeb;
992 $this->last_subscription_date_end = $datefin;
993 $this->datefin = $datefin;
997 $this->
db->rollback();
1001 $this->error = $this->
db->lasterror();
1002 $this->
db->rollback();
1015 public function delete($rowid, $user, $notrigger = 0)
1017 global $conf, $langs;
1024 if (empty($rowid)) {
1030 if (!$error && !$notrigger) {
1040 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"categorie_member WHERE fk_member = ".((int) $rowid);
1041 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1045 $this->error .= $this->
db->lasterror();
1051 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"subscription WHERE fk_adherent = ".((int) $rowid);
1052 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1056 $this->error .= $this->
db->lasterror();
1066 $this->error .= $this->
db->lasterror();
1077 dol_syslog(get_class($this).
"::delete erreur ".$errorflag.
" ".$this->error, LOG_ERR);
1083 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"adherent WHERE rowid = ".((int) $rowid);
1084 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1088 $this->error .= $this->
db->lasterror();
1094 $this->
db->commit();
1097 $this->
db->rollback();
1113 public function setPassword($user, $password =
'', $isencrypted = 0, $notrigger = 0, $nosyncuser = 0)
1115 global $conf, $langs;
1119 dol_syslog(get_class($this).
"::setPassword user=".$user->id.
" password=".preg_replace(
'/./i',
'*', $password).
" isencrypted=".$isencrypted);
1123 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
1128 $password_crypted =
dol_hash($password);
1130 $password_indatabase =
'';
1131 if (!$isencrypted) {
1132 $password_indatabase = $password;
1138 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent";
1139 $sql .=
" SET pass_crypted = '".$this->db->escape($password_crypted).
"'";
1142 $sql .=
", pass = null";
1144 $sql .=
", pass = '".$this->db->escape($password_indatabase).
"'";
1146 $sql .=
" WHERE rowid = ".((int) $this->
id);
1149 dol_syslog(get_class($this).
"::setPassword", LOG_DEBUG);
1150 $result = $this->
db->query($sql);
1152 $nbaffectedrows = $this->
db->affected_rows($result);
1154 if ($nbaffectedrows) {
1155 $this->pass = $password;
1156 $this->pass_indatabase = $password_indatabase;
1157 $this->pass_indatabase_crypted = $password_crypted;
1159 if ($this->user_id && !$nosyncuser) {
1160 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
1164 $luser =
new User($this->
db);
1165 $result = $luser->fetch($this->user_id);
1168 $result = $luser->setPassword($user, $this->pass, 0, 0, 1);
1169 if (is_numeric($result) && $result < 0) {
1170 $this->error = $luser->error;
1171 dol_syslog(get_class($this).
"::setPassword ".$this->error, LOG_ERR);
1175 $this->error = $luser->error;
1180 if (!$error && !$notrigger) {
1182 $result = $this->
call_trigger(
'MEMBER_NEW_PASSWORD', $user);
1185 $this->
db->rollback();
1191 $this->
db->commit();
1194 $this->
db->rollback();
1198 $this->
db->rollback();
1213 global $conf, $langs;
1218 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = NULL WHERE fk_member = ".((int) $this->
id);
1219 dol_syslog(get_class($this).
"::setUserId", LOG_DEBUG);
1222 $this->error = $this->
db->error();
1223 $this->
db->rollback();
1229 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = ".((int) $this->
id);
1230 $sql .=
" WHERE rowid = ".((int) $userid);
1231 dol_syslog(get_class($this).
"::setUserId", LOG_DEBUG);
1234 $this->error = $this->
db->error();
1235 $this->
db->rollback();
1240 $this->
db->commit();
1254 global $conf, $langs;
1259 if ($thirdpartyid > 0) {
1260 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET fk_soc = null";
1261 $sql .=
" WHERE fk_soc = ".((int) $thirdpartyid);
1262 $sql .=
" AND entity = ".$conf->entity;
1263 dol_syslog(get_class($this).
"::setThirdPartyId", LOG_DEBUG);
1268 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET fk_soc = ".($thirdpartyid > 0 ? $thirdpartyid :
'null');
1269 $sql .=
" WHERE rowid = ".((int) $this->
id);
1271 dol_syslog(get_class($this).
"::setThirdPartyId", LOG_DEBUG);
1274 $this->
db->commit();
1277 $this->error = $this->
db->error();
1278 $this->
db->rollback();
1296 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"adherent";
1297 $sql .=
" WHERE login='".$this->db->escape($login).
"'";
1298 $sql .=
" AND entity = ".$conf->entity;
1303 $obj = $this->
db->fetch_object(
$resql);
1304 $this->
fetch($obj->rowid);
1324 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"adherent";
1325 $sql .=
" WHERE firstname='".$this->db->escape($firstname).
"'";
1326 $sql .=
" AND lastname='".$this->db->escape($lastname).
"'";
1327 $sql .=
" AND entity = ".$conf->entity;
1332 $obj = $this->
db->fetch_object(
$resql);
1333 $this->
fetch($obj->rowid);
1351 public function fetch($rowid, $ref =
'', $fk_soc =
'', $ref_ext =
'', $fetch_optionals =
true, $fetch_subscriptions =
true)
1355 $sql =
"SELECT d.rowid, d.ref, d.ref_ext, d.civility as civility_code, d.gender, d.firstname, d.lastname,";
1356 $sql .=
" d.societe as company, d.fk_soc, d.statut, d.public, d.address, d.zip, d.town, d.note_private,";
1357 $sql .=
" d.note_public,";
1358 $sql .=
" d.email, d.url, d.socialnetworks, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass, d.pass_crypted,";
1359 $sql .=
" d.photo, d.fk_adherent_type, d.morphy, d.entity,";
1360 $sql .=
" d.datec as datec,";
1361 $sql .=
" d.tms as datem,";
1362 $sql .=
" d.datefin as datefin, d.default_lang,";
1363 $sql .=
" d.birth as birthday,";
1364 $sql .=
" d.datevalid as datev,";
1365 $sql .=
" d.country,";
1366 $sql .=
" d.state_id,";
1367 $sql .=
" d.model_pdf,";
1368 $sql .=
" c.rowid as country_id, c.code as country_code, c.label as country,";
1369 $sql .=
" dep.nom as state, dep.code_departement as state_code,";
1370 $sql .=
" t.libelle as type, t.subscription as subscription,";
1371 $sql .=
" u.rowid as user_id, u.login as user_login";
1372 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent_type as t, ".MAIN_DB_PREFIX.
"adherent as d";
1373 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as c ON d.country = c.rowid";
1374 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as dep ON d.state_id = dep.rowid";
1375 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON d.rowid = u.fk_member";
1376 $sql .=
" WHERE d.fk_adherent_type = t.rowid";
1378 $sql .=
" AND d.rowid=".((int) $rowid);
1379 } elseif ($ref || $fk_soc) {
1380 $sql .=
" AND d.entity IN (".getEntity(
'adherent').
")";
1382 $sql .=
" AND d.ref='".$this->db->escape($ref).
"'";
1383 } elseif ($fk_soc > 0) {
1384 $sql .=
" AND d.fk_soc=".((int) $fk_soc);
1386 } elseif ($ref_ext) {
1387 $sql .=
" AND d.ref_ext='".$this->db->escape($ref_ext).
"'";
1390 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
1394 $obj = $this->
db->fetch_object(
$resql);
1396 $this->entity = $obj->entity;
1397 $this->
id = $obj->rowid;
1398 $this->
ref = $obj->ref;
1399 $this->ref_ext = $obj->ref_ext;
1401 $this->civility_id = $obj->civility_code;
1402 $this->civility_code = $obj->civility_code;
1403 $this->civility = $obj->civility_code ? ($langs->trans(
"Civility".$obj->civility_code) != (
"Civility".$obj->civility_code) ? $langs->trans(
"Civility".$obj->civility_code) : $obj->civility_code) :
'';
1405 $this->firstname = $obj->firstname;
1406 $this->lastname = $obj->lastname;
1407 $this->gender = $obj->gender;
1408 $this->login = $obj->login;
1409 $this->societe = $obj->company;
1410 $this->company = $obj->company;
1411 $this->socid = $obj->fk_soc;
1412 $this->fk_soc = $obj->fk_soc;
1413 $this->address = $obj->address;
1414 $this->zip = $obj->zip;
1415 $this->town = $obj->town;
1417 $this->pass = $obj->pass;
1418 $this->pass_indatabase = $obj->pass;
1419 $this->pass_indatabase_crypted = $obj->pass_crypted;
1421 $this->state_id = $obj->state_id;
1422 $this->state_code = $obj->state_id ? $obj->state_code :
'';
1423 $this->state = $obj->state_id ? $obj->state :
'';
1425 $this->country_id = $obj->country_id;
1426 $this->country_code = $obj->country_code;
1427 if ($langs->trans(
"Country".$obj->country_code) !=
"Country".$obj->country_code) {
1428 $this->country = $langs->transnoentitiesnoconv(
"Country".$obj->country_code);
1430 $this->country = $obj->country;
1433 $this->phone = $obj->phone;
1434 $this->phone_perso = $obj->phone_perso;
1435 $this->phone_mobile = $obj->phone_mobile;
1436 $this->email = $obj->email;
1437 $this->url = $obj->url;
1439 $this->socialnetworks = ($obj->socialnetworks ? (array) json_decode($obj->socialnetworks,
true) : array());
1441 $this->photo = $obj->photo;
1442 $this->statut = $obj->statut;
1443 $this->status = $obj->statut;
1444 $this->
public = $obj->public;
1446 $this->datec = $this->
db->jdate($obj->datec);
1447 $this->date_creation = $this->
db->jdate($obj->datec);
1448 $this->datem = $this->
db->jdate($obj->datem);
1449 $this->date_modification = $this->
db->jdate($obj->datem);
1450 $this->datefin = $this->
db->jdate($obj->datefin);
1451 $this->datevalid = $this->
db->jdate($obj->datev);
1452 $this->date_validation = $this->
db->jdate($obj->datev);
1453 $this->birth = $this->
db->jdate($obj->birthday);
1455 $this->default_lang = $obj->default_lang;
1457 $this->note_private = $obj->note_private;
1458 $this->note_public = $obj->note_public;
1459 $this->morphy = $obj->morphy;
1461 $this->
typeid = $obj->fk_adherent_type;
1462 $this->
type = $obj->type;
1463 $this->need_subscription = $obj->subscription;
1465 $this->user_id = $obj->user_id;
1466 $this->user_login = $obj->user_login;
1468 $this->model_pdf = $obj->model_pdf;
1472 if ($fetch_optionals) {
1477 if ($fetch_subscriptions) {
1486 $this->error = $this->
db->lasterror();
1506 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
1508 $sql =
"SELECT c.rowid, c.fk_adherent, c.fk_type, c.subscription, c.note, c.fk_bank,";
1509 $sql .=
" c.tms as datem,";
1510 $sql .=
" c.datec as datec,";
1511 $sql .=
" c.dateadh as dateh,";
1512 $sql .=
" c.datef as datef";
1513 $sql .=
" FROM ".MAIN_DB_PREFIX.
"subscription as c";
1514 $sql .=
" WHERE c.fk_adherent = ".((int) $this->
id);
1515 $sql .=
" ORDER BY c.dateadh";
1516 dol_syslog(get_class($this).
"::fetch_subscriptions", LOG_DEBUG);
1520 $this->subscriptions = array();
1523 while ($obj = $this->
db->fetch_object(
$resql)) {
1525 $this->first_subscription_date = $this->
db->jdate($obj->datec);
1526 $this->first_subscription_date_start = $this->
db->jdate($obj->dateh);
1527 $this->first_subscription_date_end = $this->
db->jdate($obj->datef);
1528 $this->first_subscription_amount = $obj->subscription;
1530 $this->last_subscription_date = $this->
db->jdate($obj->datec);
1531 $this->last_subscription_date_start = $this->
db->jdate($obj->dateh);
1532 $this->last_subscription_date_end = $this->
db->jdate($obj->datef);
1533 $this->last_subscription_amount = $obj->subscription;
1536 $subscription->id = $obj->rowid;
1537 $subscription->fk_adherent = $obj->fk_adherent;
1538 $subscription->fk_type = $obj->fk_type;
1539 $subscription->amount = $obj->subscription;
1540 $subscription->note = $obj->note;
1541 $subscription->fk_bank = $obj->fk_bank;
1542 $subscription->datem = $this->
db->jdate($obj->datem);
1543 $subscription->datec = $this->
db->jdate($obj->datec);
1544 $subscription->dateh = $this->
db->jdate($obj->dateh);
1545 $subscription->datef = $this->
db->jdate($obj->datef);
1547 $this->subscriptions[] = $subscription;
1553 $this->error = $this->
db->error().
' sql='.$sql;
1569 require_once DOL_DOCUMENT_ROOT.
'/partnership/class/partnership.class.php';
1572 $this->partnerships[] = array();
1593 public function subscription($date, $amount, $accountid = 0, $operation =
'', $label =
'', $num_chq =
'', $emetteur_nom =
'', $emetteur_banque =
'', $datesubend = 0, $fk_type =
null)
1595 global $conf, $langs, $user;
1597 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
1609 $datefin = $datesubend;
1618 $subscription->fk_adherent = $this->id;
1619 $subscription->dateh = $date;
1620 $subscription->datef = $datefin;
1621 $subscription->amount = $amount;
1622 $subscription->note = $label;
1623 $subscription->note_public = $label;
1624 $subscription->fk_type = $fk_type;
1626 $rowid = $subscription->create($user);
1633 $this->last_subscription_date =
dol_now();
1634 $this->last_subscription_date_start = $date;
1635 $this->last_subscription_date_end = $datefin;
1636 $this->last_subscription_amount = $amount;
1640 $this->
db->commit();
1643 $this->
db->rollback();
1647 $this->error = $subscription->error;
1648 $this->errors = $subscription->errors;
1649 $this->
db->rollback();
1674 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 =
'')
1676 global $conf, $langs, $user, $mysoc;
1680 $this->invoice =
null;
1682 dol_syslog(
"subscriptionComplementaryActions subscriptionid=".$subscriptionid.
" option=".$option.
" accountid=".$accountid.
" datesubscription=".$datesubscription.
" paymentdate=".
1683 $paymentdate.
" label=".$label.
" amount=".$amount.
" num_chq=".$num_chq.
" autocreatethirdparty=".$autocreatethirdparty);
1686 if ($option ==
'bankdirect' && $accountid) {
1687 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
1690 $result = $acct->fetch($accountid);
1692 $dateop = $paymentdate;
1694 $insertid = $acct->addline($dateop, $operation, $label, $amount, $num_chq,
'', $user, $emetteur_nom, $emetteur_banque);
1695 if ($insertid > 0) {
1696 $inserturlid = $acct->add_url_line($insertid, $this->
id, DOL_URL_ROOT.
'/adherents/card.php?rowid=', $this->getFullname($langs),
'member');
1697 if ($inserturlid > 0) {
1699 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"subscription SET fk_bank=".((int) $insertid);
1700 $sql .=
" WHERE rowid=".((int) $subscriptionid);
1702 dol_syslog(
"subscription::subscription", LOG_DEBUG);
1706 $this->error = $this->
db->lasterror();
1707 $this->errors[] = $this->error;
1711 $this->error = $acct->error;
1712 $this->errors = $acct->errors;
1716 $this->error = $acct->error;
1717 $this->errors = $acct->errors;
1722 if (($option ==
'bankviainvoice' && $accountid) || $option ==
'invoiceonly') {
1723 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1724 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/paymentterm.class.php';
1730 if (!($this->fk_soc > 0)) {
1731 if ($autocreatethirdparty) {
1736 if ($this->morphy ==
'mor') {
1737 $companyname = $this->company;
1738 if (!empty($fullname)) {
1739 $companyalias = $fullname;
1742 $companyname = $fullname;
1743 if (!empty($this->company)) {
1744 $companyalias = $this->company;
1748 $result = $customer->create_from_member($this, $companyname, $companyalias);
1750 $this->error = $customer->error;
1751 $this->errors = $customer->errors;
1754 $this->fk_soc = $result;
1757 $langs->load(
"errors");
1758 $this->error = $langs->trans(
"ErrorMemberNotLinkedToAThirpartyLinkOrCreateFirst");
1759 $this->errors[] = $this->error;
1765 $result = $customer->fetch($this->fk_soc);
1767 $this->error = $customer->error;
1768 $this->errors = $customer->errors;
1776 $invoice->cond_reglement_id = $customer->cond_reglement_id;
1777 if (empty($invoice->cond_reglement_id)) {
1779 $invoice->cond_reglement_id = $paymenttermstatic->getDefaultId();
1780 if (empty($invoice->cond_reglement_id)) {
1782 $this->error =
'ErrorNoPaymentTermRECEPFound';
1783 $this->errors[] = $this->error;
1786 $invoice->socid = $this->fk_soc;
1791 $invoice->linked_objects[
'subscription'] = $subscriptionid;
1792 if (!empty($_POST[
'other_linked_objects']) && is_array($_POST[
'other_linked_objects'])) {
1793 $invoice->linked_objects = array_merge($invoice->linked_objects, $_POST[
'other_linked_objects']);
1796 $result = $invoice->create($user);
1798 $this->error = $invoice->error;
1799 $this->errors = $invoice->errors;
1802 $this->invoice = $invoice;
1808 $idprodsubscription = 0;
1809 if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (
isModEnabled(
"product") ||
isModEnabled(
"service"))) {
1810 $idprodsubscription = $conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS;
1814 if (isset($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) && $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS ==
'defaultforfoundationcountry') {
1818 $result = $invoice->addline($label, 0, 1, $vattouse, 0, 0, $idprodsubscription, 0, $datesubscription,
'', 0, 0,
'',
'TTC', $amount, 1);
1820 $this->error = $invoice->error;
1821 $this->errors = $invoice->errors;
1828 $result = $invoice->validate($user);
1830 $this->error = $invoice->error;
1831 $this->errors = $invoice->errors;
1841 if (!$error && $option ==
'bankviainvoice' && $accountid) {
1842 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1843 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
1844 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions.lib.php';
1847 $amounts[$invoice->id] =
price2num($amount);
1850 $paiement->datepaye = $paymentdate;
1851 $paiement->amounts = $amounts;
1852 $paiement->paiementcode = $operation;
1853 $paiement->paiementid =
dol_getIdFromCode($this->
db, $operation,
'c_paiement',
'code',
'id', 1);
1854 $paiement->num_payment = $num_chq;
1855 $paiement->note_public = $label;
1856 $paiement->ext_payment_id = $ext_payment_id;
1857 $paiement->ext_payment_site = $ext_payment_site;
1861 $paiement_id = $paiement->create($user);
1862 if (!($paiement_id > 0)) {
1863 $this->error = $paiement->error;
1864 $this->errors = $paiement->errors;
1871 $bank_line_id = $paiement->addPaymentToBank($user,
'payment',
'(SubscriptionPayment)', $accountid, $emetteur_nom, $emetteur_banque);
1872 if (!($bank_line_id > 0)) {
1873 $this->error = $paiement->error;
1874 $this->errors = $paiement->errors;
1879 if (!$error && !empty($bank_line_id)) {
1881 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'subscription SET fk_bank='.((int) $bank_line_id);
1882 $sql .=
' WHERE rowid='.((int) $subscriptionid);
1884 $result = $this->
db->query($sql);
1892 $invoice->setPaid($user);
1898 $outputlangs = $langs;
1900 $lang_id =
GETPOST(
'lang_id');
1901 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && !empty($lang_id)) {
1902 $newlang = $lang_id;
1905 $newlang = $customer->default_lang;
1907 if (!empty($newlang)) {
1908 $outputlangs =
new Translate(
"", $conf);
1909 $outputlangs->setDefaultLang($newlang);
1914 $invoice->generateDocument($invoice->model_pdf, $outputlangs);
1934 global $langs, $conf;
1940 if ($this->statut == self::STATUS_VALIDATED) {
1941 dol_syslog(get_class($this).
"::validate statut of member does not allow this", LOG_WARNING);
1947 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
1948 $sql .=
" statut = ".self::STATUS_VALIDATED;
1949 $sql .=
", datevalid = '".$this->db->idate($now).
"'";
1950 $sql .=
", fk_user_valid = ".((int) $user->id);
1951 $sql .=
" WHERE rowid = ".((int) $this->
id);
1953 dol_syslog(get_class($this).
"::validate", LOG_DEBUG);
1954 $result = $this->
db->query($sql);
1959 $result = $this->
call_trigger(
'MEMBER_VALIDATE', $user);
1962 $this->
db->rollback();
1967 $this->datevalid = $now;
1969 $this->
db->commit();
1972 $this->error = $this->
db->error();
1973 $this->
db->rollback();
1987 global $langs, $conf;
1992 if ($this->statut == self::STATUS_RESILIATED) {
1993 dol_syslog(get_class($this).
"::resiliate statut of member does not allow this", LOG_WARNING);
1999 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
2000 $sql .=
" statut = ".self::STATUS_RESILIATED;
2001 $sql .=
", fk_user_valid=".$user->id;
2002 $sql .=
" WHERE rowid = ".((int) $this->
id);
2004 $result = $this->
db->query($sql);
2009 $result = $this->
call_trigger(
'MEMBER_RESILIATE', $user);
2012 $this->
db->rollback();
2017 $this->
db->commit();
2020 $this->error = $this->
db->error();
2021 $this->
db->rollback();
2037 global $langs, $conf;
2042 if ($this->statut == self::STATUS_EXCLUDED) {
2043 dol_syslog(get_class($this).
"::resiliate statut of member does not allow this", LOG_WARNING);
2049 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
2050 $sql .=
" statut = ".self::STATUS_EXCLUDED;
2051 $sql .=
", fk_user_valid=".$user->id;
2052 $sql .=
" WHERE rowid = ".((int) $this->
id);
2054 $result = $this->
db->query($sql);
2059 $result = $this->
call_trigger(
'MEMBER_EXCLUDE', $user);
2062 $this->
db->rollback();
2067 $this->
db->commit();
2070 $this->error = $this->
db->error();
2071 $this->
db->rollback();
2085 global $conf, $langs;
2087 include_once DOL_DOCUMENT_ROOT.
'/mailmanspip/class/mailmanspip.class.php';
2093 if (!empty($conf->global->ADHERENT_USE_MAILMAN) &&
isModEnabled(
'mailmanspip')) {
2094 $result = $mailmanspip->add_to_mailman($this);
2097 if (!empty($mailmanspip->error)) {
2098 $this->errors[] = $mailmanspip->error;
2102 foreach ($mailmanspip->mladded_ko as $tmplist => $tmpemail) {
2103 $langs->load(
"errors");
2104 $this->errors[] = $langs->trans(
"ErrorFailedToAddToMailmanList", $tmpemail, $tmplist);
2106 foreach ($mailmanspip->mladded_ok as $tmplist => $tmpemail) {
2107 $langs->load(
"mailmanspip");
2108 $this->mesgs[] = $langs->trans(
"SuccessToAddToMailmanList", $tmpemail, $tmplist);
2113 if (!empty($conf->global->ADHERENT_USE_SPIP) &&
isModEnabled(
'mailmanspip')) {
2114 $result = $mailmanspip->add_to_spip($this);
2116 $this->errors[] = $mailmanspip->error;
2137 global $conf, $langs;
2139 include_once DOL_DOCUMENT_ROOT.
'/mailmanspip/class/mailmanspip.class.php';
2145 if (!empty($conf->global->ADHERENT_USE_MAILMAN)) {
2146 $result = $mailmanspip->del_to_mailman($this);
2148 if (!empty($mailmanspip->error)) {
2149 $this->errors[] = $mailmanspip->error;
2154 foreach ($mailmanspip->mlremoved_ko as $tmplist => $tmpemail) {
2155 $langs->load(
"errors");
2156 $this->errors[] = $langs->trans(
"ErrorFailedToRemoveToMailmanList", $tmpemail, $tmplist);
2158 foreach ($mailmanspip->mlremoved_ok as $tmplist => $tmpemail) {
2159 $langs->load(
"mailmanspip");
2160 $this->mesgs[] = $langs->trans(
"SuccessToRemoveToMailmanList", $tmpemail, $tmplist);
2164 if ($conf->global->ADHERENT_USE_SPIP &&
isModEnabled(
'mailmanspip')) {
2165 $result = $mailmanspip->del_to_spip($this);
2167 $this->errors[] = $mailmanspip->error;
2188 $langs->load(
"dict");
2190 $code = (empty($this->civility_id) ?
'' : $this->civility_id);
2194 return $langs->getLabelFromKey($this->
db,
"Civility".$code,
"c_civility",
"code",
"label", $code);
2210 public function getNomUrl($withpictoimg = 0, $maxlen = 0, $option =
'card', $mode =
'', $morecss =
'', $save_lastsearch_value = -1, $notooltip = 0, $addlinktonotes = 0)
2212 global $conf, $langs, $hookmanager;
2214 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpictoimg) {
2223 if (!empty($this->photo)) {
2224 $label .=
'<div class="photointooltip floatright">';
2225 $label .=
Form::showphoto(
'memberphoto', $this, 80, 0, 0,
'photoref photowithmargin photologintooltip',
'small', 0, 1);
2230 $label .=
'<div class="centpercent">';
2231 $label .=
img_picto(
'', $this->picto).
' <u class="paddingrightonly">'.$langs->trans(
"Member").
'</u>';
2233 $label .=
' '.$this->getLibStatut(4);
2234 if (!empty($this->
ref)) {
2235 $label .=
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
2237 if (!empty($this->login)) {
2238 $label .=
'<br><b>'.$langs->trans(
'Login').
':</b> '.$this->login;
2240 if (!empty($this->email)) {
2241 $label .=
'<br><b>'.$langs->trans(
'Email').
':</b> '.$this->email;
2243 if (!empty($this->firstname) || !empty($this->lastname)) {
2244 $label .=
'<br><b>'.$langs->trans(
'Name').
':</b> '.$this->
getFullName($langs);
2246 if (!empty($this->company)) {
2247 $label .=
'<br><b>'.$langs->trans(
'Company').
':</b> '.$this->company;
2251 $url = DOL_URL_ROOT.
'/adherents/card.php?rowid='.((int) $this->
id);
2252 if ($option ==
'subscription') {
2253 $url = DOL_URL_ROOT.
'/adherents/subscription.php?rowid='.((int) $this->
id);
2256 if ($option !=
'nolink') {
2258 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
2259 if ($save_lastsearch_value == -1 && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
2260 $add_save_lastsearch_values = 1;
2262 if ($add_save_lastsearch_values) {
2263 $url .=
'&save_lastsearch_values=1';
2267 $linkstart .=
'<a href="'.$url.
'"';
2269 if (empty($notooltip)) {
2270 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
2271 $langs->load(
"users");
2272 $label = $langs->trans(
"ShowUser");
2273 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
2275 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
2276 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
2279 $linkstart .= $linkclose.
'>';
2282 $result .= $linkstart;
2283 if ($withpictoimg) {
2284 $result .=
'<div class="inline-block nopadding valignmiddle">';
2286 if ($withpictoimg) {
2287 $paddafterimage =
'';
2288 if (abs($withpictoimg) == 1) {
2289 $paddafterimage =
'style="margin-right: 3px;"';
2292 if ($withpictoimg > 0) {
2293 $picto =
'<span class="nopadding'.($morecss ?
' userimg'.$morecss :
'').
'">'.
2294 img_object(
'',
'user', $paddafterimage.
' '.($notooltip ?
'' :
'class="classfortooltip"'), 0, 0, $notooltip ? 0 : 1).
'</span>';
2297 $picto =
'<span class="nopadding'.($morecss ?
' userimg'.$morecss :
'').
'"'.($paddafterimage ?
' '.$paddafterimage :
'').
'>';
2298 $picto .=
Form::showphoto(
'memberphoto', $this, 0, 0, 0,
'userphoto'.($withpictoimg == -3 ?
'small' :
''),
'mini', 0, 1);
2299 $picto .=
'</span>';
2303 if ($withpictoimg > -2 && $withpictoimg != 2) {
2304 if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
2305 $result .=
'<span class="nopadding valignmiddle'.((!isset($this->statut) || $this->statut) ?
'' :
' strikefordisabled').
2306 ($morecss ?
' usertext'.$morecss :
'').
'">';
2308 if ($mode ==
'login') {
2309 $result .=
dol_trunc($this->login, $maxlen);
2310 } elseif ($mode ==
'ref') {
2311 $result .= $this->ref;
2313 $result .= $this->
getFullName($langs,
'', ($mode ==
'firstname' ? 2 : ($mode ==
'lastname' ? 4 : -1)), $maxlen);
2315 if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
2316 $result .=
'</span>';
2319 if ($withpictoimg) {
2320 $result .=
'</div>';
2322 $result .= $linkend;
2324 if ($addlinktonotes) {
2325 if ($this->note_private) {
2326 $notetoshow = $langs->trans(
"ViewPrivateNote").
':<br>'.
dol_string_nohtmltag($this->note_private, 1);
2327 $result .=
' <span class="note inline-block">';
2328 $result .=
'<a href="'.DOL_URL_ROOT.
'/adherents/note.php?id='.$this->
id.
'" class="classfortooltip" title="'.
dol_escape_htmltag($notetoshow).
'">';
2331 $result .=
'</span>';
2335 $hookmanager->initHooks(array($this->element .
'dao'));
2336 $parameters = array(
'id'=>$this->
id,
'getnomurl' => &$result);
2337 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
2339 $result = $hookmanager->resPrint;
2341 $result .= $hookmanager->resPrint;
2354 return $this->
LibStatut($this->statut, $this->need_subscription, $this->datefin, $mode);
2367 public function LibStatut($status, $need_subscription, $date_end_subscription, $mode = 0)
2371 $langs->load(
"members");
2375 $labelStatusShort =
'';
2377 if ($status == self::STATUS_DRAFT) {
2378 $statusType =
'status0';
2379 $labelStatus = $langs->trans(
"MemberStatusDraft");
2380 $labelStatusShort = $langs->trans(
"MemberStatusDraftShort");
2381 } elseif ($status >= self::STATUS_VALIDATED) {
2382 if ($need_subscription === 0) {
2383 $statusType =
'status4';
2384 $labelStatus = $langs->trans(
"MemberStatusNoSubscription");
2385 $labelStatusShort = $langs->trans(
"MemberStatusNoSubscriptionShort");
2386 } elseif (!$date_end_subscription) {
2387 $statusType =
'status1';
2388 $labelStatus = $langs->trans(
"MemberStatusActive");
2389 $labelStatusShort = $langs->trans(
"MemberStatusActiveShort");
2390 } elseif ($date_end_subscription <
dol_now()) {
2391 $statusType =
'status8';
2392 $labelStatus = $langs->trans(
"MemberStatusActiveLate");
2393 $labelStatusShort = $langs->trans(
"MemberStatusActiveLateShort");
2395 $statusType =
'status4';
2396 $labelStatus = $langs->trans(
"MemberStatusPaid");
2397 $labelStatusShort = $langs->trans(
"MemberStatusPaidShort");
2399 } elseif ($status == self::STATUS_RESILIATED) {
2400 $statusType =
'status6';
2401 $labelStatus = $langs->transnoentitiesnoconv(
"MemberStatusResiliated");
2402 $labelStatusShort = $langs->transnoentitiesnoconv(
"MemberStatusResiliatedShort");
2403 } elseif ($status == self::STATUS_EXCLUDED) {
2404 $statusType =
'status10';
2405 $labelStatus = $langs->transnoentitiesnoconv(
"MemberStatusExcluded");
2406 $labelStatusShort = $langs->transnoentitiesnoconv(
"MemberStatusExcludedShort");
2409 return dolGetStatus($labelStatus, $labelStatusShort,
'', $statusType, $mode);
2424 $this->nb = array();
2426 $sql =
"SELECT count(a.rowid) as nb";
2427 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as a";
2428 $sql .=
" WHERE a.statut > 0";
2429 $sql .=
" AND a.entity IN (".getEntity(
'adherent').
")";
2433 while ($obj = $this->
db->fetch_object(
$resql)) {
2434 $this->nb[
"members"] = $obj->nb;
2440 $this->error = $this->
db->error();
2456 global $conf, $langs;
2464 $sql =
"SELECT a.rowid, a.datefin, a.statut";
2465 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as a";
2466 $sql .=
", ".MAIN_DB_PREFIX.
"adherent_type as t";
2467 $sql .=
" WHERE a.fk_adherent_type = t.rowid";
2468 if ($mode ==
'expired') {
2469 $sql .=
" AND a.statut = ".self::STATUS_VALIDATED;
2470 $sql .=
" AND a.entity IN (".getEntity(
'adherent').
")";
2471 $sql .=
" AND ((a.datefin IS NULL or a.datefin < '".$this->db->idate($now).
"') AND t.subscription = '1')";
2472 } elseif ($mode ==
'shift') {
2473 $sql .=
" AND a.statut = ".self::STATUS_DRAFT;
2474 $sql .=
" AND a.entity IN (".getEntity(
'adherent').
")";
2479 $langs->load(
"members");
2486 if ($mode ==
'expired') {
2487 $warning_delay = $conf->adherent->subscription->warning_delay / 60 / 60 / 24;
2488 $label = $langs->trans(
"MembersWithSubscriptionToReceive");
2489 $labelShort = $langs->trans(
"MembersWithSubscriptionToReceiveShort");
2490 $url = DOL_URL_ROOT.
'/adherents/list.php?mainmenu=members&statut='.self::STATUS_VALIDATED.
'&filter=outofdate';
2491 } elseif ($mode ==
'shift') {
2492 $warning_delay = $conf->adherent->subscription->warning_delay / 60 / 60 / 24;
2493 $url = DOL_URL_ROOT.
'/adherents/list.php?mainmenu=members&statut='.
self::STATUS_DRAFT;
2494 $label = $langs->trans(
"MembersListToValid");
2495 $labelShort = $langs->trans(
"ToValidate");
2499 $response->warning_delay = $warning_delay;
2500 $response->label = $label;
2501 $response->labelShort = $labelShort;
2502 $response->url = $url;
2507 while ($obj = $this->
db->fetch_object(
$resql)) {
2508 $response->nbtodo++;
2510 $adherentstatic->datefin = $this->
db->jdate($obj->datefin);
2511 $adherentstatic->statut = $obj->statut;
2513 if ($adherentstatic->hasDelay()) {
2514 $response->nbtodolate++;
2521 $this->error = $this->
db->error();
2538 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams =
null)
2540 global $conf, $langs;
2542 $langs->load(
"orders");
2545 $modele =
'standard';
2547 if ($this->model_pdf) {
2548 $modele = $this->model_pdf;
2549 } elseif (!empty($conf->global->ADHERENT_ADDON_PDF)) {
2550 $modele = $conf->global->ADHERENT_ADDON_PDF;
2554 $modelpath =
"core/modules/member/doc/";
2556 return $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
2569 global $user, $langs;
2574 $this->
ref =
'ABC001';
2576 $this->specimen = 1;
2577 $this->civility_id = 0;
2578 $this->lastname =
'DOLIBARR';
2579 $this->firstname =
'SPECIMEN';
2580 $this->gender =
'man';
2581 $this->login =
'dolibspec';
2582 $this->pass =
'dolibspec';
2583 $this->company =
'Societe ABC';
2584 $this->address =
'61 jump street';
2585 $this->zip =
'75000';
2586 $this->town =
'Paris';
2587 $this->country_id = 1;
2588 $this->country_code =
'FR';
2589 $this->country =
'France';
2590 $this->morphy =
'mor';
2591 $this->email =
'specimen@specimen.com';
2592 $this->socialnetworks = array(
2593 'skype' =>
'skypepseudo',
2594 'twitter' =>
'twitterpseudo',
2595 'facebook' =>
'facebookpseudo',
2596 'linkedin' =>
'linkedinpseudo',
2598 $this->phone =
'0999999999';
2599 $this->phone_perso =
'0999999998';
2600 $this->phone_mobile =
'0999999997';
2601 $this->note_public =
'This is a public note';
2602 $this->note_private =
'This is a private note';
2603 $this->birth = $now;
2608 $this->datefin = $now;
2609 $this->datevalid = $now;
2610 $this->default_lang =
'';
2613 $this->
type =
'Type adherent';
2614 $this->need_subscription = 0;
2616 $this->first_subscription_date = $now;
2617 $this->first_subscription_date_start = $this->first_subscription_date;
2618 $this->first_subscription_date_end =
dol_time_plus_duree($this->first_subscription_date_start, 1,
'y');
2619 $this->first_subscription_amount = 10;
2621 $this->last_subscription_date = $this->first_subscription_date;
2622 $this->last_subscription_date_start = $this->first_subscription_date;
2623 $this->last_subscription_date_end =
dol_time_plus_duree($this->last_subscription_date_start, 1,
'y');
2624 $this->last_subscription_amount = 10;
2646 $dn = $conf->global->LDAP_KEY_MEMBERS.
"=".$info[$conf->global->LDAP_KEY_MEMBERS].
",".$conf->global->LDAP_MEMBER_DN;
2649 $dn = $conf->global->LDAP_MEMBER_DN;
2652 $dn = $conf->global->LDAP_KEY_MEMBERS.
"=".$info[$conf->global->LDAP_KEY_MEMBERS];
2668 global $conf, $langs;
2672 $keymodified =
false;
2675 $info[
"objectclass"] = explode(
',', $conf->global->LDAP_MEMBER_OBJECT_CLASS);
2680 if ($this->morphy ==
'mor' && (empty($this->fullname) || $this->fullname == $this->company)) {
2681 $this->fullname = $this->company;
2682 $this->lastname = $this->company;
2687 'LDAP_MEMBER_FIELD_FULLNAME' =>
'fullname',
2688 'LDAP_MEMBER_FIELD_NAME' =>
'lastname',
2689 'LDAP_MEMBER_FIELD_LOGIN' =>
'login',
2690 'LDAP_MEMBER_FIELD_LOGIN_SAMBA' =>
'login',
2691 'LDAP_MEMBER_FIELD_MAIL' =>
'email'
2695 foreach ($ldapkey as $constname => $varname) {
2696 if (!empty($this->$varname) && !empty($conf->global->$constname)) {
2697 $info[$conf->global->$constname] = $this->$varname;
2700 if (!empty($conf->global->LDAP_KEY_MEMBERS) && $conf->global->LDAP_KEY_MEMBERS == $conf->global->$constname) {
2701 if (!empty($this->oldcopy) && $this->$varname != $this->oldcopy->$varname) {
2702 $keymodified =
true;
2707 if ($this->firstname && !empty($conf->global->LDAP_MEMBER_FIELD_FIRSTNAME)) {
2708 $info[$conf->global->LDAP_MEMBER_FIELD_FIRSTNAME] = $this->firstname;
2710 if ($this->poste && !empty($conf->global->LDAP_MEMBER_FIELD_TITLE)) {
2711 $info[$conf->global->LDAP_MEMBER_FIELD_TITLE] = $this->poste;
2713 if ($this->company && !empty($conf->global->LDAP_MEMBER_FIELD_COMPANY)) {
2714 $info[$conf->global->LDAP_MEMBER_FIELD_COMPANY] = $this->company;
2716 if ($this->address && !empty($conf->global->LDAP_MEMBER_FIELD_ADDRESS)) {
2717 $info[$conf->global->LDAP_MEMBER_FIELD_ADDRESS] = $this->address;
2719 if ($this->zip && !empty($conf->global->LDAP_MEMBER_FIELD_ZIP)) {
2720 $info[$conf->global->LDAP_MEMBER_FIELD_ZIP] = $this->zip;
2722 if ($this->town && !empty($conf->global->LDAP_MEMBER_FIELD_TOWN)) {
2723 $info[$conf->global->LDAP_MEMBER_FIELD_TOWN] = $this->town;
2725 if ($this->country_code && !empty($conf->global->LDAP_MEMBER_FIELD_COUNTRY)) {
2726 $info[$conf->global->LDAP_MEMBER_FIELD_COUNTRY] = $this->country_code;
2728 foreach ($socialnetworks as $key => $value) {
2729 if ($this->socialnetworks[$value[
'label']] && !empty($conf->global->{
'LDAP_MEMBER_FIELD_'.strtoupper($value[
'label'])})) {
2730 $info[$conf->global->{
'LDAP_MEMBER_FIELD_'.strtoupper($value[
'label'])}] = $this->socialnetworks[$value[
'label']];
2733 if ($this->phone && !empty($conf->global->LDAP_MEMBER_FIELD_PHONE)) {
2734 $info[$conf->global->LDAP_MEMBER_FIELD_PHONE] = $this->phone;
2736 if ($this->phone_perso && !empty($conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO)) {
2737 $info[$conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO] = $this->phone_perso;
2739 if ($this->phone_mobile && !empty($conf->global->LDAP_MEMBER_FIELD_MOBILE)) {
2740 $info[$conf->global->LDAP_MEMBER_FIELD_MOBILE] = $this->phone_mobile;
2742 if ($this->fax && !empty($conf->global->LDAP_MEMBER_FIELD_FAX)) {
2743 $info[$conf->global->LDAP_MEMBER_FIELD_FAX] = $this->fax;
2745 if ($this->note_private && !empty($conf->global->LDAP_MEMBER_FIELD_DESCRIPTION)) {
2746 $info[$conf->global->LDAP_MEMBER_FIELD_DESCRIPTION] =
dol_string_nohtmltag($this->note_private, 2);
2748 if ($this->note_public && !empty($conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC)) {
2749 $info[$conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC] =
dol_string_nohtmltag($this->note_public, 2);
2751 if ($this->birth && !empty($conf->global->LDAP_MEMBER_FIELD_BIRTHDATE)) {
2752 $info[$conf->global->LDAP_MEMBER_FIELD_BIRTHDATE] =
dol_print_date($this->birth,
'dayhourldap');
2754 if (isset($this->statut) && !empty($conf->global->LDAP_FIELD_MEMBER_STATUS)) {
2755 $info[$conf->global->LDAP_FIELD_MEMBER_STATUS] = $this->statut;
2757 if ($this->datefin && !empty($conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION)) {
2758 $info[$conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION] =
dol_print_date($this->datefin,
'dayhourldap');
2762 if (!empty($this->pass)) {
2763 if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD)) {
2764 $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD] = $this->pass;
2766 if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) {
2767 $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] =
dol_hash($this->pass,
'openldap');
2769 } elseif ($conf->global->LDAP_SERVER_PROTOCOLVERSION !==
'3') {
2772 if (!empty($conf->global->DATABASE_PWD_ENCRYPTED)) {
2774 if (empty($conf->global->MAIN_SECURITY_HASH_ALGO)) {
2775 if ($this->pass_indatabase_crypted && !empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) {
2778 $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] =
dolGetLdapPasswordHash($this->pass_indatabase_crypted,
'md5frommd5');
2781 } elseif (!empty($this->pass_indatabase)) {
2783 if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD)) {
2784 $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD] = $this->pass_indatabase;
2786 if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) {
2787 $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] =
dol_hash($this->pass_indatabase,
'openldap');
2793 if ($this->first_subscription_date && !empty($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE)) {
2794 $info[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE] =
dol_print_date($this->first_subscription_date,
'dayhourldap');
2796 if (isset($this->first_subscription_amount) && !empty($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT)) {
2797 $info[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT] = $this->first_subscription_amount;
2799 if ($this->last_subscription_date && !empty($conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE)) {
2800 $info[$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE] =
dol_print_date($this->last_subscription_date,
'dayhourldap');
2802 if (isset($this->last_subscription_amount) && !empty($conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT)) {
2803 $info[$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT] = $this->last_subscription_amount;
2818 $sql =
'SELECT a.rowid, a.datec as datec,';
2819 $sql .=
' a.datevalid as datev,';
2820 $sql .=
' a.tms as datem,';
2821 $sql .=
' a.fk_user_author, a.fk_user_valid, a.fk_user_mod';
2822 $sql .=
' FROM '.MAIN_DB_PREFIX.
'adherent as a';
2823 $sql .=
' WHERE a.rowid = '.((int) $id);
2825 dol_syslog(get_class($this).
"::info", LOG_DEBUG);
2826 $result = $this->
db->query($sql);
2828 if ($this->
db->num_rows($result)) {
2829 $obj = $this->
db->fetch_object($result);
2830 $this->
id = $obj->rowid;
2832 $this->user_creation_id = $obj->fk_user_author;
2833 $this->user_validation_id = $obj->fk_user_valid;
2834 $this->user_modification_id = $obj->fk_user_mod;
2835 $this->date_creation = $this->
db->jdate($obj->datec);
2836 $this->date_validation = $this->
db->jdate($obj->datev);
2837 $this->date_modification = $this->
db->jdate($obj->datem);
2840 $this->
db->free($result);
2853 $sql =
"SELECT count(mc.email) as nb";
2854 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mailing_cibles as mc";
2855 $sql .=
" WHERE mc.email = '".$this->db->escape($this->email).
"'";
2856 $sql .=
" AND mc.statut NOT IN (-1,0)";
2860 $obj = $this->
db->fetch_object(
$resql);
2866 $this->error = $this->
db->error();
2883 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
2884 return parent::setCategoriesCommon($categories, Categorie::TYPE_MEMBER);
2897 $tables = array(
'adherent');
2912 if ($this->statut != self::STATUS_VALIDATED) {
2915 if (!$this->datefin) {
2921 return $this->datefin < ($now - $conf->adherent->subscription->warning_delay);
2934 global $conf, $langs, $mysoc, $user;
2940 $blockingerrormsg =
'';
2942 if (empty($conf->adherent->enabled)) {
2943 $langs->load(
"agenda");
2944 $this->output = $langs->trans(
'ModuleNotEnabled', $langs->transnoentitiesnoconv(
"Adherent"));
2947 if (empty($conf->global->MEMBER_REMINDER_EMAIL)) {
2948 $langs->load(
"agenda");
2949 $this->output = $langs->trans(
'EventRemindersByEmailNotEnabled', $langs->transnoentitiesnoconv(
"Adherent"));
2957 $listofmembersok = array();
2958 $listofmembersko = array();
2960 $arraydaysbeforeend = explode(
';', $daysbeforeendlist);
2961 foreach ($arraydaysbeforeend as $daysbeforeend) {
2962 dol_syslog(__METHOD__.
' - Process delta = '.$daysbeforeend, LOG_DEBUG);
2964 if (!is_numeric($daysbeforeend)) {
2965 $blockingerrormsg =
"Value for delta is not a numeric value";
2973 $sql =
'SELECT rowid FROM '.MAIN_DB_PREFIX.
'adherent';
2974 $sql .=
" WHERE entity = ".((int) $conf->entity);
2975 $sql .=
" AND datefin = '".$this->db->idate($datetosearchfor).
"'";
2980 $num_rows = $this->
db->num_rows(
$resql);
2982 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
2987 while ($i < $num_rows) {
2988 $obj = $this->
db->fetch_object(
$resql);
2990 $adherent->fetch($obj->rowid,
'',
'',
'',
true,
true);
2992 if (empty($adherent->email)) {
2994 $listofmembersko[$adherent->id] = $adherent->id;
2996 $adherent->fetch_thirdparty();
2999 $languagefromcountrycode =
getLanguageCodeFromCountryCode($adherent->country_code ? $adherent->country_code : $adherent->thirdparty->country_code);
3000 $languagecodeformember = (empty($adherent->thirdparty->default_lang) ? ($languagefromcountrycode ? $languagefromcountrycode : $mysoc->default_lang) : $adherent->thirdparty->default_lang);
3003 $outputlangs =
new Translate(
'', $conf);
3004 $outputlangs->setDefaultLang($languagecodeformember);
3005 $outputlangs->loadLangs(array(
"main",
"members"));
3006 dol_syslog(
"sendReminderForExpiredSubscription Language for member id ".$adherent->id.
" set to ".$outputlangs->defaultlang.
" mysoc->default_lang=".$mysoc->default_lang);
3008 $arraydefaultmessage =
null;
3011 if (!empty($labeltouse)) {
3012 $arraydefaultmessage = $formmail->getEMailTemplate($this->
db,
'member', $user, $outputlangs, 0, 1, $labeltouse);
3015 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
3020 $subject =
make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs);
3021 $msg =
make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs);
3022 $from = $conf->global->ADHERENT_MAIL_FROM;
3023 $to = $adherent->email;
3025 $trackid =
'mem'.$adherent->id;
3026 $moreinheader =
'X-Dolibarr-Info: sendReminderForExpiredSubscription'.
"\r\n";
3028 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
3029 $cmail =
new CMailFile($subject, $to, $from, $msg, array(), array(), array(),
'',
'', 0, 1,
'',
'', $trackid, $moreinheader);
3030 $result = $cmail->sendfile();
3033 $this->error .= $cmail->error.
' ';
3034 if (!is_null($cmail->errors)) {
3035 $this->errors += $cmail->errors;
3038 $listofmembersko[$adherent->id] = $adherent->id;
3041 $listofmembersok[$adherent->id] = $adherent->id;
3047 $actioncode =
'EMAIL';
3058 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic').
": ".$subject);
3059 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody').
":");
3063 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
3068 $actioncomm->type_code =
'AC_OTH_AUTO';
3069 $actioncomm->code =
'AC_'.$actioncode;
3070 $actioncomm->label = $actionmsg2;
3071 $actioncomm->note_private = $actionmsg;
3072 $actioncomm->fk_project = 0;
3073 $actioncomm->datep = $now;
3074 $actioncomm->datef = $now;
3075 $actioncomm->percentage = -1;
3076 $actioncomm->socid = $adherent->thirdparty->id;
3077 $actioncomm->contact_id = 0;
3078 $actioncomm->authorid = $user->id;
3079 $actioncomm->userownerid = $user->id;
3081 $actioncomm->email_msgid = $cmail->msgid;
3082 $actioncomm->email_from = $from;
3083 $actioncomm->email_sender =
'';
3084 $actioncomm->email_to = $to;
3085 $actioncomm->email_tocc = $sendtocc;
3086 $actioncomm->email_tobcc = $sendtobcc;
3087 $actioncomm->email_subject = $subject;
3088 $actioncomm->errors_to =
'';
3090 $actioncomm->fk_element = $adherent->id;
3091 $actioncomm->elementtype = $adherent->element;
3093 $actioncomm->extraparams = $extraparams;
3095 $actioncomm->create($user);
3101 $this->error .=
"Can't find email template with label=".$labeltouse.
", to use for the reminding email ";
3104 $listofmembersko[$adherent->id] = $adherent->id;
3113 $this->error = $this->
db->lasterror();
3118 if ($blockingerrormsg) {
3119 $this->error = $blockingerrormsg;
3122 $this->output =
'Found '.($nbok + $nbko).
' members to send reminder to.';
3123 $this->output .=
' Send email successfuly to '.$nbok.
' members';
3124 if (is_array($listofmembersok)) {
3127 foreach ($listofmembersok as $idmember) {
3129 $listofids .=
', ...';
3132 if (empty($listofids)) {
3137 $listofids .= $idmember;
3144 $this->output .= ($listofids ?
' ids='.$listofids :
'');
3147 $this->output .=
' - Canceled for '.$nbko.
' member (no email or email sending error)';
3148 if (is_array($listofmembersko)) {
3151 foreach ($listofmembersko as $idmember) {
3153 $listofids .=
', ...';
3156 if (empty($listofids)) {
3161 $listofids .= $idmember;
3167 $this->output .= ($listofids ?
' ids='.$listofids :
'');
Class to manage bank accounts.
Class to manage agenda events (actions)
Class to manage members of a foundation.
setThirdPartyId($thirdpartyid)
Set link to a third party.
hasDelay()
Return if a member is late (subscription late) or not.
exclude($user)
Functiun to exlude (set adherent.status to -2) a member TODO A private note should be added to know w...
add_to_abo()
Function to add member into external tools mailing-list, spip, etc.
sendReminderForExpiredSubscription($daysbeforeendlist='10')
Send reminders by emails before subscription end CAN BE A CRON TASK.
_load_ldap_dn($info, $mode=0)
Retourne chaine DN complete dans l'annuaire LDAP pour l'objet.
update($user, $notrigger=0, $nosyncuser=0, $nosyncuserpass=0, $nosyncthirdparty=0, $action='update')
Update a member in database (standard information and password)
setCategories($categories)
Sets object to supplied categories.
getNbOfEMailings()
Return number of mass Emailing received by this member with its email.
update_end_date($user)
Update denormalized last subscription date.
static replaceThirdparty($db, $origin_id, $dest_id)
Function used to replace a thirdparty id with another one.
makeSubstitution($text)
Make substitution of tags into text with value of current object.
const STATUS_EXCLUDED
Excluded.
LibStatut($status, $need_subscription, $date_end_subscription, $mode=0)
Renvoi le libelle d'un statut donne.
fetch_name($firstname, $lastname)
Method to load member from its name.
initAsSpecimen()
Initialise an instance with random values.
del_to_abo()
Function to delete a member from external tools like mailing-list, spip, etc.
resiliate($user)
Fonction qui resilie un adherent.
getCivilityLabel()
Return civility label of a member.
getmorphylib($morphy='', $addbadge=0)
Return translated label by the nature of a adherent (physical or moral)
fetchPartnerships($mode)
Function to get partnerships array.
load_board($user, $mode)
Load indicators for dashboard (this->nbtodo and this->nbtodolate)
setPassword($user, $password='', $isencrypted=0, $notrigger=0, $nosyncuser=0)
Change password of a user.
const STATUS_DRAFT
Draft status.
const STATUS_RESILIATED
Resiliated.
fetch_login($login)
Method to load member from its login.
create($user, $notrigger=0)
Create a member into database.
_load_ldap_info()
Initialise tableau info (tableau des attributs LDAP)
getLibStatut($mode=0)
Retourne le libelle du statut d'un adherent (brouillon, valide, resilie, exclu)
info($id)
Load type info information in the member object.
__construct($db)
Constructor.
subscription($date, $amount, $accountid=0, $operation='', $label='', $num_chq='', $emetteur_nom='', $emetteur_banque='', $datesubend=0, $fk_type=null)
Insert subscription into database and eventually add links to banks, mailman, etc....
send_an_email($text, $subject, $filename_list=array(), $mimetype_list=array(), $mimefilename_list=array(), $addr_cc="", $addr_bcc="", $deliveryreceipt=0, $msgishtml=-1, $errors_to='', $moreinheader='')
Function sending an email to the current member with the text supplied in parameter.
getNomUrl($withpictoimg=0, $maxlen=0, $option='card', $mode='', $morecss='', $save_lastsearch_value=-1, $notooltip=0, $addlinktonotes=0)
Return clicable name (with picto eventually)
generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=null)
Create a document onto disk according to template module.
subscriptionComplementaryActions($subscriptionid, $option, $accountid, $datesubscription, $paymentdate, $operation, $label, $amount, $num_chq, $emetteur_nom='', $emetteur_banque='', $autocreatethirdparty=0, $ext_payment_id='', $ext_payment_site='')
Do complementary actions after subscription recording.
setUserId($userid)
Set link to a user.
load_state_board()
Charge indicateurs this->nb de tableau de bord.
fetch($rowid, $ref='', $fk_soc='', $ref_ext='', $fetch_optionals=true, $fetch_subscriptions=true)
Load member from database.
const STATUS_VALIDATED
Validated status.
fetch_subscriptions()
Function to get member subscriptions data: subscriptions, first_subscription_date,...
validate($user)
Function that validate a member.
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
static getValidAddress($address, $format, $encode=0, $maxnumberofemail=0)
Return a formatted address string for SMTP protocol.
Parent class of all other business classes (invoices, contracts, proposals, orders,...
fetch_optionals($rowid=null, $optionsArray=null)
Function to get extra fields of an object into $this->array_options This method is in most cases call...
setUpperOrLowerCase()
Set to upper or ucwords/lower if needed.
commonGenerateDocument($modelspath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams=null)
Common function for all objects extending CommonObject for generating documents.
getFullName($langs, $option=0, $nameorder=-1, $maxlen=0)
Return full name (civility+' '+name+' '+lastname)
deleteExtraFields()
Delete all extra fields values for the current object.
static commonReplaceThirdparty(DoliDB $db, $origin_id, $dest_id, array $tables, $ignoreerrors=0)
Function used to replace a thirdparty id with another one.
insertExtraFields($trigger='', $userused=null)
Add/Update all extra fields values for the current object.
call_trigger($triggerName, $user)
Call trigger based on this instance.
Class to manage invoices.
const TYPE_STANDARD
Standard invoice.
Class to manage mailman and spip.
Class to manage payments of customer invoices.
Class to manage payment terms records in dictionary.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage subscriptions of foundation members.
Class to manage translations.
Class to manage Dolibarr users.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
clean_url($url, $http=1)
Clean an url string.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
getLanguageCodeFromCountryCode($countrycode)
Return default language from country code.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
dolGetFirstLetters($s, $nbofchar=1)
Return first letters of a strings.
dol_strtoupper($string, $encoding="UTF-8")
Convert a string to upper.
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
dolGetStatus($statusLabel='', $statusLabelShort='', $html='', $statusType='status0', $displayMode=0, $url='', $params=array())
Output the badge of a status.
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
getArrayOfSocialNetworks()
Get array of social network dictionary.
dol_textishtml($msg, $option=0)
Return if a text is a html content.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null)
Return array of possible common substitutions.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
isModEnabled($module)
Is Dolibarr module enabled.
get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that return vat rate of a product line (according to seller, buyer and product vat rate) VAT...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
getRandomPassword($generic=false, $replaceambiguouschars=null, $length=32)
Return a generated password using default module.
dolGetLdapPasswordHash($password, $type='md5')
Returns a specific ldap hash of a password.
dol_hash($chain, $type='0')
Returns a hash (non reversible encryption) of a string.
$conf db
API class for accounts.