38require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
40require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/class/commonpeople.class.php';
54 public $element =
'member';
59 public $table_element =
'adherent';
65 public $ismultientitymanaged = 1;
70 public $isextrafieldmanaged = 1;
75 public $picto =
'member';
93 public $pass_indatabase;
98 public $pass_indatabase_crypted;
109 public $civility_code;
139 public $socialnetworks;
159 public $phone_mobile;
185 public $default_lang;
228 public $need_subscription;
245 public $first_subscription_date;
247 public $first_subscription_date_start;
249 public $first_subscription_date_end;
251 public $first_subscription_amount;
253 public $last_subscription_date;
255 public $last_subscription_date_start;
257 public $last_subscription_date_end;
259 public $last_subscription_amount;
261 public $subscriptions = array();
270 public $partnerships = array();
281 public $fields = array(
282 'rowid' => array(
'type' =>
'integer',
'label' =>
'TechnicalID',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 10),
283 'ref' => array(
'type' =>
'varchar(30)',
'label' =>
'Ref',
'default' => 1,
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'position' => 12,
'index' => 1),
284 'entity' => array(
'type' =>
'integer',
'label' =>
'Entity',
'default' => 1,
'enabled' => 1,
'visible' => -2,
'notnull' => 1,
'position' => 15,
'index' => 1),
285 'ref_ext' => array(
'type' =>
'varchar(128)',
'label' =>
'Ref ext',
'enabled' => 1,
'visible' => 0,
'position' => 20),
286 'civility' => array(
'type' =>
'varchar(6)',
'label' =>
'Civility',
'enabled' => 1,
'visible' => -1,
'position' => 25),
287 'lastname' => array(
'type' =>
'varchar(50)',
'label' =>
'Lastname',
'enabled' => 1,
'visible' => 1,
'position' => 30,
'showoncombobox'=>1),
288 'firstname' => array(
'type' =>
'varchar(50)',
'label' =>
'Firstname',
'enabled' => 1,
'visible' => 1,
'position' => 35,
'showoncombobox'=>1),
289 'login' => array(
'type' =>
'varchar(50)',
'label' =>
'Login',
'enabled' => 1,
'visible' => 1,
'position' => 40),
290 'pass' => array(
'type' =>
'varchar(50)',
'label' =>
'Pass',
'enabled' => 1,
'visible' => -1,
'position' => 45),
291 'pass_crypted' => array(
'type' =>
'varchar(128)',
'label' =>
'Pass crypted',
'enabled' => 1,
'visible' => -1,
'position' => 50),
292 'morphy' => array(
'type' =>
'varchar(3)',
'label' =>
'MemberNature',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'position' => 55),
293 'fk_adherent_type' => array(
'type' =>
'integer',
'label' =>
'Fk adherent type',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'position' => 60),
294 'societe' => array(
'type' =>
'varchar(128)',
'label' =>
'Societe',
'enabled' => 1,
'visible' => 1,
'position' => 65,
'showoncombobox'=>2),
295 'fk_soc' => array(
'type' =>
'integer:Societe:societe/class/societe.class.php',
'label' =>
'ThirdParty',
'enabled' => 1,
'visible' => 1,
'position' => 70),
296 'address' => array(
'type' =>
'text',
'label' =>
'Address',
'enabled' => 1,
'visible' => -1,
'position' => 75),
297 'zip' => array(
'type' =>
'varchar(10)',
'label' =>
'Zip',
'enabled' => 1,
'visible' => -1,
'position' => 80),
298 'town' => array(
'type' =>
'varchar(50)',
'label' =>
'Town',
'enabled' => 1,
'visible' => -1,
'position' => 85),
299 'state_id' => array(
'type' =>
'integer',
'label' =>
'State id',
'enabled' => 1,
'visible' => -1,
'position' => 90),
300 'country' => array(
'type' =>
'integer:Ccountry:core/class/ccountry.class.php',
'label' =>
'Country',
'enabled' => 1,
'visible' => 1,
'position' => 95),
301 'phone' => array(
'type' =>
'varchar(30)',
'label' =>
'Phone',
'enabled' => 1,
'visible' => -1,
'position' => 115),
302 'phone_perso' => array(
'type' =>
'varchar(30)',
'label' =>
'Phone perso',
'enabled' => 1,
'visible' => -1,
'position' => 120),
303 'phone_mobile' => array(
'type' =>
'varchar(30)',
'label' =>
'Phone mobile',
'enabled' => 1,
'visible' => -1,
'position' => 125),
304 'email' => array(
'type' =>
'varchar(255)',
'label' =>
'Email',
'enabled' => 1,
'visible' => 1,
'position' => 126),
305 'url' =>array(
'type'=>
'varchar(255)',
'label'=>
'Url',
'enabled'=>1,
'visible'=>-1,
'position'=>127),
306 'socialnetworks' => array(
'type' =>
'text',
'label' =>
'Socialnetworks',
'enabled' => 1,
'visible' => -1,
'position' => 128),
307 'birth' => array(
'type' =>
'date',
'label' =>
'DateOfBirth',
'enabled' => 1,
'visible' => -1,
'position' => 130),
308 'gender' => array(
'type' =>
'varchar(10)',
'label' =>
'Gender',
'enabled' => 1,
'visible' => -1,
'position' => 132),
309 'photo' => array(
'type' =>
'varchar(255)',
'label' =>
'Photo',
'enabled' => 1,
'visible' => -1,
'position' => 135),
310 'public' => array(
'type' =>
'smallint(6)',
'label' =>
'Public',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 145),
311 'datefin' => array(
'type' =>
'datetime',
'label' =>
'DateEnd',
'enabled' => 1,
'visible' => 1,
'position' => 150),
312 'default_lang' =>array(
'type'=>
'varchar(6)',
'label'=>
'Default lang',
'enabled'=>1,
'visible'=>-1,
'position'=> 153),
313 'note_public' => array(
'type' =>
'text',
'label' =>
'NotePublic',
'enabled' => 1,
'visible' => 0,
'position' => 155),
314 'note_private' => array(
'type' =>
'text',
'label' =>
'NotePrivate',
'enabled' => 1,
'visible' => 0,
'position' => 160),
315 'datevalid' => array(
'type' =>
'datetime',
'label' =>
'DateValidation',
'enabled' => 1,
'visible' => -1,
'position' => 165),
316 'datec' => array(
'type' =>
'datetime',
'label' =>
'DateCreation',
'enabled' => 1,
'visible' => -1,
'position' => 170),
317 'tms' => array(
'type' =>
'timestamp',
'label' =>
'DateModification',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 175),
318 'fk_user_author' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'Fk user author',
'enabled' => 1,
'visible' => -1,
'position' => 180),
319 'fk_user_mod' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'Fk user mod',
'enabled' => 1,
'visible' => -1,
'position' => 185),
320 'fk_user_valid' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'UserValidation',
'enabled' => 1,
'visible' => -1,
'position' => 190),
321 'canvas' => array(
'type' =>
'varchar(32)',
'label' =>
'Canvas',
'enabled' => 1,
'visible' => -1,
'position' => 195),
322 'statut' => array(
'type' =>
'smallint(6)',
'label' =>
'Statut',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'position' => 500,
'arrayofkeyval' => array(-1 =>
'Draft', 1 =>
'Validated', 0 =>
'MemberStatusResiliatedShort', -2 =>
'MemberStatusExcludedShort')),
323 'model_pdf' => array(
'type' =>
'varchar(255)',
'label' =>
'Model pdf',
'enabled' => 1,
'visible' => 0,
'position' => 800),
324 'import_key' => array(
'type' =>
'varchar(14)',
'label' =>
'ImportId',
'enabled' => 1,
'visible' => -2,
'position' => 805)
358 $this->array_options = array();
381 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 =
'')
384 dol_syslog(
'Warning using deprecated Adherent::send_an_email', LOG_WARNING);
386 return $this->
sendEmail($text, $subject, $filename_list, $mimetype_list, $mimefilename_list, $addr_cc, $addr_bcc, $deliveryreceipt, $msgishtml, $errors_to, $moreinheader);
406 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 =
'')
408 global $conf, $langs;
411 if ($msgishtml == -1) {
418 dol_syslog(
'sendEmail msgishtml='.$msgishtml);
427 $from = $conf->email_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";
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, $mysoc;
586 $this->import_key = trim($this->import_key);
590 $langs->load(
"errors");
591 $this->error = $langs->trans(
"ErrorBadEMail", $this->email);
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");
629 $this->
ref = (string) $id;
634 require_once $modfile;
636 $modCodeMember =
new $modname();
637 $this->
ref = $modCodeMember->getNextValue($mysoc, $this);
645 $result = $this->
update($user, 1, 1, 0, 0,
'add');
647 $this->db->rollback();
652 if ($this->user_id) {
654 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET";
655 $sql .=
" fk_member = ".((int) $this->
id);
656 $sql .=
" WHERE rowid = ".((int) $this->user_id);
657 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
658 $resql = $this->db->query($sql);
660 $this->error =
'Failed to update user to make link with member';
661 $this->db->rollback();
675 if (count($this->errors)) {
676 dol_syslog(get_class($this).
"::create ".implode(
',', $this->errors), LOG_ERR);
677 $this->db->rollback();
684 $this->error =
'Failed to get last insert id';
685 dol_syslog(get_class($this).
"::create ".$this->error, LOG_ERR);
686 $this->db->rollback();
690 $this->error = $this->db->error();
691 $this->db->rollback();
708 public function update($user, $notrigger = 0, $nosyncuser = 0, $nosyncuserpass = 0, $nosyncthirdparty = 0, $action =
'update')
710 global $langs, $hookmanager;
712 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
717 dol_syslog(get_class($this).
"::update notrigger=".$notrigger.
", nosyncuser=".$nosyncuser.
", nosyncuserpass=".$nosyncuserpass.
" nosyncthirdparty=".$nosyncthirdparty.
", email=".$this->email);
720 $this->lastname = trim($this->lastname) ? trim($this->lastname) : trim($this->lastname);
721 $this->firstname = trim($this->firstname) ? trim($this->firstname) : trim($this->firstname);
722 $this->gender = trim($this->gender);
723 $this->address = ($this->address ? $this->address : $this->address);
724 $this->zip = ($this->zip ? $this->zip : $this->zip);
725 $this->town = ($this->town ? $this->town : $this->town);
726 $this->country_id = ($this->country_id > 0 ? $this->country_id : $this->country_id);
727 $this->state_id = ($this->state_id > 0 ? $this->state_id : $this->state_id);
728 $this->note_public = ($this->note_public ? $this->note_public : $this->note_public);
729 $this->note_private = ($this->note_private ? $this->note_private : $this->note_private);
730 $this->url = $this->url ?
clean_url($this->url, 0) :
'';
734 $langs->load(
"errors");
735 $this->error = $langs->trans(
"ErrorBadEMail", $this->email);
741 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
742 $sql .=
" ref = '".$this->db->escape($this->
ref).
"'";
743 $sql .=
", civility = ".($this->civility_id ?
"'".$this->db->escape($this->civility_id).
"'" :
"null");
744 $sql .=
", firstname = ".($this->firstname ?
"'".$this->db->escape($this->firstname).
"'" :
"null");
745 $sql .=
", lastname = ".($this->lastname ?
"'".$this->db->escape($this->lastname).
"'" :
"null");
746 $sql .=
", gender = ".($this->gender != -1 ?
"'".$this->db->escape($this->gender).
"'" :
"null");
747 $sql .=
", login = ".($this->login ?
"'".$this->db->escape($this->login).
"'" :
"null");
748 $sql .=
", societe = ".($this->company ?
"'".$this->db->escape($this->company).
"'" : ($this->societe ?
"'".$this->db->escape($this->societe).
"'" :
"null"));
750 $sql .=
", fk_soc = ".($this->socid > 0 ? $this->db->escape($this->socid) :
"null");
752 $sql .=
", address = ".($this->address ?
"'".$this->db->escape($this->address).
"'" :
"null");
753 $sql .=
", zip = ".($this->zip ?
"'".$this->db->escape($this->zip).
"'" :
"null");
754 $sql .=
", town = ".($this->town ?
"'".$this->db->escape($this->town).
"'" :
"null");
755 $sql .=
", country = ".($this->country_id > 0 ? $this->db->escape($this->country_id) :
"null");
756 $sql .=
", state_id = ".($this->state_id > 0 ? $this->db->escape($this->state_id) :
"null");
757 $sql .=
", email = '".$this->db->escape($this->email).
"'";
758 $sql .=
", url = ".(!empty($this->url) ?
"'".$this->db->escape($this->url).
"'" :
"null");
759 $sql .=
", socialnetworks = ".($this->socialnetworks ?
"'".$this->db->escape(json_encode($this->socialnetworks)).
"'" :
"null");
760 $sql .=
", phone = ".($this->phone ?
"'".$this->db->escape($this->phone).
"'" :
"null");
761 $sql .=
", phone_perso = ".($this->phone_perso ?
"'".$this->db->escape($this->phone_perso).
"'" :
"null");
762 $sql .=
", phone_mobile = ".($this->phone_mobile ?
"'".$this->db->escape($this->phone_mobile).
"'" :
"null");
763 $sql .=
", note_private = ".($this->note_private ?
"'".$this->db->escape($this->note_private).
"'" :
"null");
764 $sql .=
", note_public = ".($this->note_public ?
"'".$this->db->escape($this->note_public).
"'" :
"null");
765 $sql .=
", photo = ".($this->photo ?
"'".$this->db->escape($this->photo).
"'" :
"null");
766 $sql .=
", public = '".$this->db->escape($this->
public).
"'";
767 $sql .=
", statut = ".$this->db->escape($this->
statut);
768 $sql .=
", default_lang = ".(!empty($this->default_lang) ?
"'".$this->db->escape($this->default_lang).
"'" :
"null");
769 $sql .=
", fk_adherent_type = ".$this->db->escape($this->
typeid);
770 $sql .=
", morphy = '".$this->db->escape($this->morphy).
"'";
771 $sql .=
", birth = ".($this->birth ?
"'".$this->db->idate($this->birth).
"'" :
"null");
773 if ($this->datefin) {
774 $sql .=
", datefin = '".$this->db->idate($this->datefin).
"'";
776 if ($this->datevalid) {
777 $sql .=
", datevalid = '".$this->db->idate($this->datevalid).
"'";
779 $sql .=
", fk_user_mod = ".($user->id > 0 ? $user->id :
'null');
780 $sql .=
" WHERE rowid = ".((int) $this->
id);
783 if (!empty($this->oldcopy) && $this->
typeid != $this->oldcopy->typeid) {
784 $sql2 =
"SELECT libelle as label";
785 $sql2 .=
" FROM ".MAIN_DB_PREFIX.
"adherent_type";
786 $sql2 .=
" WHERE rowid = ".((int) $this->
typeid);
787 $resql2 = $this->db->query($sql2);
789 while ($obj = $this->db->fetch_object($resql2)) {
790 $this->
type = $obj->label;
795 dol_syslog(get_class($this).
"::update update member", LOG_DEBUG);
796 $resql = $this->db->query($sql);
798 unset($this->country_code);
799 unset($this->country);
800 unset($this->state_code);
803 $nbrowsaffected += $this->db->affected_rows($resql);
816 if (!$error && $this->pass) {
817 dol_syslog(get_class($this).
"::update update password");
818 if ($this->pass != $this->pass_indatabase && $this->pass != $this->pass_indatabase_crypted) {
822 $result = $this->
setPassword($user, $this->pass, $isencrypted, $notrigger, $nosyncuserpass);
823 if (!$nbrowsaffected) {
831 dol_syslog(get_class($this).
"::update update link to user");
832 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = NULL WHERE fk_member = ".((int) $this->
id);
833 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
834 $resql = $this->db->query($sql);
836 $this->error = $this->db->error();
837 $this->db->rollback();
841 if ($this->user_id > 0) {
842 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = ".((int) $this->
id).
" WHERE rowid = ".((int) $this->user_id);
843 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
844 $resql = $this->db->query($sql);
846 $this->error = $this->db->error();
847 $this->db->rollback();
853 if (!$error && $nbrowsaffected) {
855 if (!$error && $this->user_id > 0 && !$nosyncuser) {
856 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
858 dol_syslog(get_class($this).
"::update update linked user");
860 $luser =
new User($this->db);
861 $result = $luser->fetch($this->user_id);
869 $luser->login = $this->login;
872 $luser->ref = $this->ref;
873 $luser->civility_id = $this->civility_id;
874 $luser->firstname = $this->firstname;
875 $luser->lastname = $this->lastname;
876 $luser->gender = $this->gender;
877 $luser->pass = $this->pass;
880 $luser->birth = $this->birth;
882 $luser->address = $this->address;
883 $luser->zip = $this->zip;
884 $luser->town = $this->town;
885 $luser->country_id = $this->country_id;
886 $luser->state_id = $this->state_id;
888 $luser->email = $this->email;
889 $luser->socialnetworks = $this->socialnetworks;
890 $luser->office_phone = $this->phone;
891 $luser->user_mobile = $this->phone_mobile;
893 $luser->lang = $this->default_lang;
895 $luser->fk_member = $this->id;
897 $result = $luser->update($user, 0, 1, 1);
899 $this->error = $luser->error;
900 dol_syslog(get_class($this).
"::update ".$this->error, LOG_ERR);
904 $this->error = $luser->error;
910 if (!$error && $this->fk_soc > 0 && !$nosyncthirdparty) {
911 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
913 dol_syslog(get_class($this).
"::update update linked thirdparty");
917 $lthirdparty =
new Societe($this->db);
918 $result = $lthirdparty->fetch($this->fk_soc);
921 $lthirdparty->address = $this->address;
922 $lthirdparty->zip = $this->zip;
923 $lthirdparty->town = $this->town;
924 $lthirdparty->email = $this->email;
925 $lthirdparty->socialnetworks = $this->socialnetworks;
926 $lthirdparty->phone = $this->phone;
927 $lthirdparty->state_id = $this->state_id;
928 $lthirdparty->country_id = $this->country_id;
930 $lthirdparty->default_lang = $this->default_lang;
932 $result = $lthirdparty->update($this->fk_soc, $user, 0, 1, 1,
'update');
935 $this->error = $lthirdparty->error;
936 $this->errors = $lthirdparty->errors;
937 dol_syslog(get_class($this).
"::update ".$this->error, LOG_ERR);
940 } elseif ($result < 0) {
941 $this->error = $lthirdparty->error;
947 if (!$error && !$notrigger) {
958 return $nbrowsaffected;
960 $this->db->rollback();
964 $this->db->rollback();
965 $this->error = $this->db->lasterror();
985 $sql =
"SELECT rowid, datec as dateop, dateadh as datedeb, datef as datefin";
986 $sql .=
" FROM ".MAIN_DB_PREFIX.
"subscription";
987 $sql .=
" WHERE fk_adherent = ".((int) $this->
id);
988 $sql .=
" ORDER by dateadh DESC";
990 dol_syslog(get_class($this).
"::update_end_date", LOG_DEBUG);
991 $resql = $this->db->query($sql);
993 $obj = $this->db->fetch_object($resql);
994 $dateop = $this->db->jdate($obj->dateop);
995 $datedeb = $this->db->jdate($obj->datedeb);
996 $datefin = $this->db->jdate($obj->datefin);
998 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
999 $sql .=
" datefin=".($datefin !=
'' ?
"'".$this->db->idate($datefin).
"'" :
"null");
1000 $sql .=
" WHERE rowid = ".((int) $this->
id);
1002 dol_syslog(get_class($this).
"::update_end_date", LOG_DEBUG);
1003 $resql = $this->db->query($sql);
1005 $this->last_subscription_date = $dateop;
1006 $this->last_subscription_date_start = $datedeb;
1007 $this->last_subscription_date_end = $datefin;
1008 $this->datefin = $datefin;
1009 $this->db->commit();
1012 $this->db->rollback();
1016 $this->error = $this->db->lasterror();
1017 $this->db->rollback();
1030 public function delete($rowid, $user, $notrigger = 0)
1037 if (empty($rowid)) {
1043 if (!$error && !$notrigger) {
1053 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"categorie_member WHERE fk_member = ".((int) $rowid);
1054 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1055 $resql = $this->db->query($sql);
1058 $this->error .= $this->db->lasterror();
1064 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"subscription WHERE fk_adherent = ".((int) $rowid);
1065 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1066 $resql = $this->db->query($sql);
1069 $this->error .= $this->db->lasterror();
1079 $this->error .= $this->db->lasterror();
1090 dol_syslog(get_class($this).
"::delete erreur ".$errorflag.
" ".$this->error, LOG_ERR);
1096 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"adherent WHERE rowid = ".((int) $rowid);
1097 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1098 $resql = $this->db->query($sql);
1101 $this->error .= $this->db->lasterror();
1107 $this->db->commit();
1110 $this->db->rollback();
1126 public function setPassword($user, $password =
'', $isencrypted = 0, $notrigger = 0, $nosyncuser = 0)
1128 global $conf, $langs;
1132 dol_syslog(get_class($this).
"::setPassword user=".$user->id.
" password=".preg_replace(
'/./i',
'*', $password).
" isencrypted=".$isencrypted);
1136 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
1141 $password_crypted =
dol_hash($password);
1143 $password_indatabase =
'';
1144 if (!$isencrypted) {
1145 $password_indatabase = $password;
1151 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent";
1152 $sql .=
" SET pass_crypted = '".$this->db->escape($password_crypted).
"'";
1154 $sql .=
", pass = null";
1156 $sql .=
", pass = '".$this->db->escape($password_indatabase).
"'";
1158 $sql .=
" WHERE rowid = ".((int) $this->
id);
1161 dol_syslog(get_class($this).
"::setPassword", LOG_DEBUG);
1162 $result = $this->db->query($sql);
1164 $nbaffectedrows = $this->db->affected_rows($result);
1166 if ($nbaffectedrows) {
1167 $this->pass = $password;
1168 $this->pass_indatabase = $password_indatabase;
1169 $this->pass_indatabase_crypted = $password_crypted;
1171 if ($this->user_id && !$nosyncuser) {
1172 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
1176 $luser =
new User($this->db);
1177 $result = $luser->fetch($this->user_id);
1180 $result = $luser->setPassword($user, $this->pass, 0, 0, 1);
1181 if (is_int($result) && $result < 0) {
1182 $this->error = $luser->error;
1183 dol_syslog(get_class($this).
"::setPassword ".$this->error, LOG_ERR);
1187 $this->error = $luser->error;
1192 if (!$error && !$notrigger) {
1194 $result = $this->
call_trigger(
'MEMBER_NEW_PASSWORD', $user);
1197 $this->db->rollback();
1203 $this->db->commit();
1206 $this->db->rollback();
1210 $this->db->rollback();
1225 global $conf, $langs;
1230 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = NULL WHERE fk_member = ".((int) $this->
id);
1231 dol_syslog(get_class($this).
"::setUserId", LOG_DEBUG);
1232 $resql = $this->db->query($sql);
1234 $this->error = $this->db->error();
1235 $this->db->rollback();
1241 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = ".((int) $this->
id);
1242 $sql .=
" WHERE rowid = ".((int) $userid);
1243 dol_syslog(get_class($this).
"::setUserId", LOG_DEBUG);
1244 $resql = $this->db->query($sql);
1246 $this->error = $this->db->error();
1247 $this->db->rollback();
1252 $this->db->commit();
1266 global $conf, $langs;
1271 if ($thirdpartyid > 0) {
1272 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET fk_soc = null";
1273 $sql .=
" WHERE fk_soc = ".((int) $thirdpartyid);
1274 $sql .=
" AND entity = ".$conf->entity;
1275 dol_syslog(get_class($this).
"::setThirdPartyId", LOG_DEBUG);
1276 $resql = $this->db->query($sql);
1280 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET fk_soc = ".($thirdpartyid > 0 ? $thirdpartyid :
'null');
1281 $sql .=
" WHERE rowid = ".((int) $this->
id);
1283 dol_syslog(get_class($this).
"::setThirdPartyId", LOG_DEBUG);
1284 $resql = $this->db->query($sql);
1286 $this->db->commit();
1289 $this->error = $this->db->error();
1290 $this->db->rollback();
1308 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"adherent";
1309 $sql .=
" WHERE login='".$this->db->escape($login).
"'";
1310 $sql .=
" AND entity = ".$conf->entity;
1312 $resql = $this->db->query($sql);
1314 if ($this->db->num_rows($resql)) {
1315 $obj = $this->db->fetch_object($resql);
1316 $this->
fetch($obj->rowid);
1336 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"adherent";
1337 $sql .=
" WHERE firstname='".$this->db->escape($firstname).
"'";
1338 $sql .=
" AND lastname='".$this->db->escape($lastname).
"'";
1339 $sql .=
" AND entity = ".$conf->entity;
1341 $resql = $this->db->query($sql);
1343 if ($this->db->num_rows($resql)) {
1344 $obj = $this->db->fetch_object($resql);
1345 $this->
fetch($obj->rowid);
1363 public function fetch($rowid, $ref =
'', $fk_soc = 0, $ref_ext =
'', $fetch_optionals =
true, $fetch_subscriptions =
true)
1367 $sql =
"SELECT d.rowid, d.ref, d.ref_ext, d.civility as civility_code, d.gender, d.firstname, d.lastname,";
1368 $sql .=
" d.societe as company, d.fk_soc, d.statut, d.public, d.address, d.zip, d.town, d.note_private,";
1369 $sql .=
" d.note_public,";
1370 $sql .=
" d.email, d.url, d.socialnetworks, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass, d.pass_crypted,";
1371 $sql .=
" d.photo, d.fk_adherent_type, d.morphy, d.entity,";
1372 $sql .=
" d.datec as datec,";
1373 $sql .=
" d.tms as datem,";
1374 $sql .=
" d.datefin as datefin, d.default_lang,";
1375 $sql .=
" d.birth as birthday,";
1376 $sql .=
" d.datevalid as datev,";
1377 $sql .=
" d.country,";
1378 $sql .=
" d.state_id,";
1379 $sql .=
" d.model_pdf,";
1380 $sql .=
" c.rowid as country_id, c.code as country_code, c.label as country,";
1381 $sql .=
" dep.nom as state, dep.code_departement as state_code,";
1382 $sql .=
" t.libelle as type, t.subscription as subscription,";
1383 $sql .=
" u.rowid as user_id, u.login as user_login";
1384 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent_type as t, ".MAIN_DB_PREFIX.
"adherent as d";
1385 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as c ON d.country = c.rowid";
1386 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as dep ON d.state_id = dep.rowid";
1387 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON d.rowid = u.fk_member";
1388 $sql .=
" WHERE d.fk_adherent_type = t.rowid";
1390 $sql .=
" AND d.rowid=".((int) $rowid);
1391 } elseif ($ref || $fk_soc) {
1392 $sql .=
" AND d.entity IN (".getEntity(
'adherent').
")";
1394 $sql .=
" AND d.ref='".$this->db->escape($ref).
"'";
1395 } elseif ($fk_soc > 0) {
1396 $sql .=
" AND d.fk_soc=".((int) $fk_soc);
1398 } elseif ($ref_ext) {
1399 $sql .=
" AND d.ref_ext='".$this->db->escape($ref_ext).
"'";
1402 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
1403 $resql = $this->db->query($sql);
1405 if ($this->db->num_rows($resql)) {
1406 $obj = $this->db->fetch_object($resql);
1408 $this->entity = $obj->entity;
1409 $this->
id = $obj->rowid;
1410 $this->
ref = $obj->ref;
1411 $this->ref_ext = $obj->ref_ext;
1413 $this->civility_id = $obj->civility_code;
1414 $this->civility_code = $obj->civility_code;
1415 $this->civility = $obj->civility_code ? ($langs->trans(
"Civility".$obj->civility_code) !=
"Civility".$obj->civility_code ? $langs->trans(
"Civility".$obj->civility_code) : $obj->civility_code) :
'';
1417 $this->firstname = $obj->firstname;
1418 $this->lastname = $obj->lastname;
1419 $this->gender = $obj->gender;
1420 $this->login = $obj->login;
1421 $this->societe = $obj->company;
1422 $this->company = $obj->company;
1423 $this->socid = $obj->fk_soc;
1424 $this->fk_soc = $obj->fk_soc;
1425 $this->address = $obj->address;
1426 $this->zip = $obj->zip;
1427 $this->town = $obj->town;
1429 $this->pass = $obj->pass;
1430 $this->pass_indatabase = $obj->pass;
1431 $this->pass_indatabase_crypted = $obj->pass_crypted;
1433 $this->state_id = $obj->state_id;
1434 $this->state_code = $obj->state_id ? $obj->state_code :
'';
1435 $this->state = $obj->state_id ? $obj->state :
'';
1437 $this->country_id = $obj->country_id;
1438 $this->country_code = $obj->country_code;
1439 if ($langs->trans(
"Country".$obj->country_code) !=
"Country".$obj->country_code) {
1440 $this->country = $langs->transnoentitiesnoconv(
"Country".$obj->country_code);
1442 $this->country = $obj->country;
1445 $this->phone = $obj->phone;
1446 $this->phone_perso = $obj->phone_perso;
1447 $this->phone_mobile = $obj->phone_mobile;
1448 $this->email = $obj->email;
1449 $this->url = $obj->url;
1451 $this->socialnetworks = ($obj->socialnetworks ? (array) json_decode($obj->socialnetworks,
true) : array());
1453 $this->photo = $obj->photo;
1454 $this->
statut = $obj->statut;
1455 $this->
status = $obj->statut;
1456 $this->
public = $obj->public;
1458 $this->datec = $this->db->jdate($obj->datec);
1459 $this->date_creation = $this->db->jdate($obj->datec);
1460 $this->datem = $this->db->jdate($obj->datem);
1461 $this->date_modification = $this->db->jdate($obj->datem);
1462 $this->datefin = $this->db->jdate($obj->datefin);
1463 $this->datevalid = $this->db->jdate($obj->datev);
1464 $this->date_validation = $this->db->jdate($obj->datev);
1465 $this->birth = $this->db->jdate($obj->birthday);
1467 $this->default_lang = $obj->default_lang;
1469 $this->note_private = $obj->note_private;
1470 $this->note_public = $obj->note_public;
1471 $this->morphy = $obj->morphy;
1473 $this->
typeid = $obj->fk_adherent_type;
1474 $this->
type = $obj->type;
1475 $this->need_subscription = $obj->subscription;
1477 $this->user_id = $obj->user_id;
1478 $this->user_login = $obj->user_login;
1480 $this->model_pdf = $obj->model_pdf;
1484 if ($fetch_optionals) {
1489 if ($fetch_subscriptions) {
1498 $this->error = $this->db->lasterror();
1518 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
1520 $sql =
"SELECT c.rowid, c.fk_adherent, c.fk_type, c.subscription, c.note as note_public, c.fk_bank,";
1521 $sql .=
" c.tms as datem,";
1522 $sql .=
" c.datec as datec,";
1523 $sql .=
" c.dateadh as dateh,";
1524 $sql .=
" c.datef as datef";
1525 $sql .=
" FROM ".MAIN_DB_PREFIX.
"subscription as c";
1526 $sql .=
" WHERE c.fk_adherent = ".((int) $this->
id);
1527 $sql .=
" ORDER BY c.dateadh";
1528 dol_syslog(get_class($this).
"::fetch_subscriptions", LOG_DEBUG);
1530 $resql = $this->db->query($sql);
1532 $this->subscriptions = array();
1535 while ($obj = $this->db->fetch_object($resql)) {
1537 $this->first_subscription_date = $this->db->jdate($obj->datec);
1538 $this->first_subscription_date_start = $this->db->jdate($obj->dateh);
1539 $this->first_subscription_date_end = $this->db->jdate($obj->datef);
1540 $this->first_subscription_amount = $obj->subscription;
1542 $this->last_subscription_date = $this->db->jdate($obj->datec);
1543 $this->last_subscription_date_start = $this->db->jdate($obj->dateh);
1544 $this->last_subscription_date_end = $this->db->jdate($obj->datef);
1545 $this->last_subscription_amount = $obj->subscription;
1548 $subscription->id = $obj->rowid;
1549 $subscription->fk_adherent = $obj->fk_adherent;
1550 $subscription->fk_type = $obj->fk_type;
1551 $subscription->amount = $obj->subscription;
1552 $subscription->note = $obj->note_public;
1553 $subscription->note_public = $obj->note_public;
1554 $subscription->fk_bank = $obj->fk_bank;
1555 $subscription->datem = $this->db->jdate($obj->datem);
1556 $subscription->datec = $this->db->jdate($obj->datec);
1557 $subscription->dateh = $this->db->jdate($obj->dateh);
1558 $subscription->datef = $this->db->jdate($obj->datef);
1560 $this->subscriptions[] = $subscription;
1566 $this->error = $this->db->error().
' sql='.$sql;
1582 require_once DOL_DOCUMENT_ROOT.
'/partnership/class/partnership.class.php';
1585 $this->partnerships[] = array();
1606 public function subscription($date, $amount, $accountid = 0, $operation =
'', $label =
'', $num_chq =
'', $emetteur_nom =
'', $emetteur_banque =
'', $datesubend = 0, $fk_type =
null)
1608 global $conf, $langs, $user;
1610 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
1622 $datefin = $datesubend;
1631 $subscription->fk_adherent = $this->id;
1632 $subscription->dateh = $date;
1633 $subscription->datef = $datefin;
1634 $subscription->amount = $amount;
1635 $subscription->note = $label;
1636 $subscription->note_public = $label;
1637 $subscription->fk_type = $fk_type;
1639 $rowid = $subscription->create($user);
1646 $this->last_subscription_date =
dol_now();
1647 $this->last_subscription_date_start = $date;
1648 $this->last_subscription_date_end = $datefin;
1649 $this->last_subscription_amount = $amount;
1653 $this->db->commit();
1656 $this->db->rollback();
1661 $this->db->rollback();
1686 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 =
'')
1688 global $conf, $langs, $user, $mysoc;
1692 $this->invoice =
null;
1694 dol_syslog(
"subscriptionComplementaryActions subscriptionid=".$subscriptionid.
" option=".$option.
" accountid=".$accountid.
" datesubscription=".$datesubscription.
" paymentdate=".
1695 $paymentdate.
" label=".$label.
" amount=".$amount.
" num_chq=".$num_chq.
" autocreatethirdparty=".$autocreatethirdparty);
1698 if ($option ==
'bankdirect' && $accountid) {
1699 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
1701 $acct =
new Account($this->db);
1702 $result = $acct->fetch($accountid);
1704 $dateop = $paymentdate;
1706 $insertid = $acct->addline($dateop, $operation, $label, $amount, $num_chq,
'', $user, $emetteur_nom, $emetteur_banque);
1707 if ($insertid > 0) {
1708 $inserturlid = $acct->add_url_line($insertid, $this->
id, DOL_URL_ROOT.
'/adherents/card.php?rowid=', $this->getFullname($langs),
'member');
1709 if ($inserturlid > 0) {
1711 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"subscription SET fk_bank=".((int) $insertid);
1712 $sql .=
" WHERE rowid=".((int) $subscriptionid);
1714 dol_syslog(
"subscription::subscription", LOG_DEBUG);
1715 $resql = $this->db->query($sql);
1718 $this->error = $this->db->lasterror();
1719 $this->errors[] = $this->error;
1732 if (($option ==
'bankviainvoice' && $accountid) || $option ==
'invoiceonly') {
1733 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1734 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/paymentterm.class.php';
1736 $invoice =
new Facture($this->db);
1737 $customer =
new Societe($this->db);
1740 if (!($this->fk_soc > 0)) {
1741 if ($autocreatethirdparty) {
1746 if ($this->morphy ==
'mor') {
1747 $companyname = $this->company;
1748 if (!empty($fullname)) {
1749 $companyalias = $fullname;
1752 $companyname = $fullname;
1753 if (!empty($this->company)) {
1754 $companyalias = $this->company;
1758 $result = $customer->create_from_member($this, $companyname, $companyalias);
1760 $this->error = $customer->error;
1761 $this->errors = $customer->errors;
1764 $this->fk_soc = $result;
1767 $langs->load(
"errors");
1768 $this->error = $langs->trans(
"ErrorMemberNotLinkedToAThirpartyLinkOrCreateFirst");
1769 $this->errors[] = $this->error;
1775 $result = $customer->fetch($this->fk_soc);
1777 $this->error = $customer->error;
1778 $this->errors = $customer->errors;
1786 $invoice->cond_reglement_id = $customer->cond_reglement_id;
1787 if (empty($invoice->cond_reglement_id)) {
1789 $invoice->cond_reglement_id = $paymenttermstatic->getDefaultId();
1790 if (empty($invoice->cond_reglement_id)) {
1792 $this->error =
'ErrorNoPaymentTermRECEPFound';
1793 $this->errors[] = $this->error;
1796 $invoice->socid = $this->fk_soc;
1801 $invoice->linked_objects[
'subscription'] = $subscriptionid;
1802 if (!empty($_POST[
'other_linked_objects']) && is_array($_POST[
'other_linked_objects'])) {
1803 $invoice->linked_objects = array_merge($invoice->linked_objects, $_POST[
'other_linked_objects']);
1806 $result = $invoice->create($user);
1808 $this->error = $invoice->error;
1809 $this->errors = $invoice->errors;
1812 $this->invoice = $invoice;
1818 $idprodsubscription = 0;
1819 if (
getDolGlobalString(
'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS') && (isModEnabled(
"product") || isModEnabled(
"service"))) {
1820 $idprodsubscription = $conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS;
1824 if (
getDolGlobalString(
'ADHERENT_VAT_FOR_SUBSCRIPTIONS') ==
'defaultforfoundationcountry') {
1828 $result = $invoice->addline($label, 0, 1, $vattouse, 0, 0, $idprodsubscription, 0, $datesubscription,
'', 0, 0,
'',
'TTC', $amount, 1);
1830 $this->error = $invoice->error;
1831 $this->errors = $invoice->errors;
1838 $result = $invoice->validate($user);
1840 $this->error = $invoice->error;
1841 $this->errors = $invoice->errors;
1851 if (!$error && $option ==
'bankviainvoice' && $accountid) {
1852 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1853 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
1854 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions.lib.php';
1857 $amounts[$invoice->id] =
price2num($amount);
1859 $paiement =
new Paiement($this->db);
1860 $paiement->datepaye = $paymentdate;
1861 $paiement->amounts = $amounts;
1862 $paiement->paiementcode = $operation;
1863 $paiement->paiementid =
dol_getIdFromCode($this->db, $operation,
'c_paiement',
'code',
'id', 1);
1864 $paiement->num_payment = $num_chq;
1865 $paiement->note_public = $label;
1866 $paiement->ext_payment_id = $ext_payment_id;
1867 $paiement->ext_payment_site = $ext_payment_site;
1871 $paiement_id = $paiement->create($user);
1872 if (!($paiement_id > 0)) {
1873 $this->error = $paiement->error;
1874 $this->errors = $paiement->errors;
1881 $bank_line_id = $paiement->addPaymentToBank($user,
'payment',
'(SubscriptionPayment)', $accountid, $emetteur_nom, $emetteur_banque);
1882 if (!($bank_line_id > 0)) {
1883 $this->error = $paiement->error;
1884 $this->errors = $paiement->errors;
1889 if (!$error && !empty($bank_line_id)) {
1891 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'subscription SET fk_bank='.((int) $bank_line_id);
1892 $sql .=
' WHERE rowid='.((int) $subscriptionid);
1894 $result = $this->db->query($sql);
1902 $invoice->setPaid($user);
1908 $outputlangs = $langs;
1910 $lang_id =
GETPOST(
'lang_id');
1911 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && !empty($lang_id)) {
1912 $newlang = $lang_id;
1915 $newlang = $customer->default_lang;
1917 if (!empty($newlang)) {
1918 $outputlangs =
new Translate(
"", $conf);
1919 $outputlangs->setDefaultLang($newlang);
1924 $invoice->generateDocument($invoice->model_pdf, $outputlangs);
1944 global $langs, $conf;
1950 if ($this->
statut == self::STATUS_VALIDATED) {
1951 dol_syslog(get_class($this).
"::validate statut of member does not allow this", LOG_WARNING);
1957 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
1958 $sql .=
" statut = ".self::STATUS_VALIDATED;
1959 $sql .=
", datevalid = '".$this->db->idate($now).
"'";
1960 $sql .=
", fk_user_valid = ".((int) $user->id);
1961 $sql .=
" WHERE rowid = ".((int) $this->
id);
1963 dol_syslog(get_class($this).
"::validate", LOG_DEBUG);
1964 $result = $this->db->query($sql);
1969 $result = $this->
call_trigger(
'MEMBER_VALIDATE', $user);
1972 $this->db->rollback();
1977 $this->datevalid = $now;
1979 $this->db->commit();
1982 $this->error = $this->db->error();
1983 $this->db->rollback();
1997 global $langs, $conf;
2002 if ($this->
statut == self::STATUS_RESILIATED) {
2003 dol_syslog(get_class($this).
"::resiliate statut of member does not allow this", LOG_WARNING);
2009 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
2010 $sql .=
" statut = ".self::STATUS_RESILIATED;
2011 $sql .=
", fk_user_valid=".$user->id;
2012 $sql .=
" WHERE rowid = ".((int) $this->
id);
2014 $result = $this->db->query($sql);
2019 $result = $this->
call_trigger(
'MEMBER_RESILIATE', $user);
2022 $this->db->rollback();
2027 $this->db->commit();
2030 $this->error = $this->db->error();
2031 $this->db->rollback();
2050 if ($this->
statut == self::STATUS_EXCLUDED) {
2051 dol_syslog(get_class($this).
"::resiliate statut of member does not allow this", LOG_WARNING);
2057 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
2058 $sql .=
" statut = ".self::STATUS_EXCLUDED;
2059 $sql .=
", fk_user_valid=".$user->id;
2060 $sql .=
" WHERE rowid = ".((int) $this->
id);
2062 $result = $this->db->query($sql);
2067 $result = $this->
call_trigger(
'MEMBER_EXCLUDE', $user);
2070 $this->db->rollback();
2075 $this->db->commit();
2078 $this->error = $this->db->error();
2079 $this->db->rollback();
2095 include_once DOL_DOCUMENT_ROOT.
'/mailmanspip/class/mailmanspip.class.php';
2102 $result = $mailmanspip->add_to_mailman($this);
2105 if (!empty($mailmanspip->error)) {
2106 $this->errors[] = $mailmanspip->error;
2110 foreach ($mailmanspip->mladded_ko as $tmplist => $tmpemail) {
2111 $langs->load(
"errors");
2112 $this->errors[] = $langs->trans(
"ErrorFailedToAddToMailmanList", $tmpemail, $tmplist);
2114 foreach ($mailmanspip->mladded_ok as $tmplist => $tmpemail) {
2115 $langs->load(
"mailmanspip");
2116 $this->mesgs[] = $langs->trans(
"SuccessToAddToMailmanList", $tmpemail, $tmplist);
2122 $result = $mailmanspip->add_to_spip($this);
2124 $this->errors[] = $mailmanspip->error;
2145 global $conf, $langs;
2147 include_once DOL_DOCUMENT_ROOT.
'/mailmanspip/class/mailmanspip.class.php';
2154 $result = $mailmanspip->del_to_mailman($this);
2156 if (!empty($mailmanspip->error)) {
2157 $this->errors[] = $mailmanspip->error;
2162 foreach ($mailmanspip->mlremoved_ko as $tmplist => $tmpemail) {
2163 $langs->load(
"errors");
2164 $this->errors[] = $langs->trans(
"ErrorFailedToRemoveToMailmanList", $tmpemail, $tmplist);
2166 foreach ($mailmanspip->mlremoved_ok as $tmplist => $tmpemail) {
2167 $langs->load(
"mailmanspip");
2168 $this->mesgs[] = $langs->trans(
"SuccessToRemoveToMailmanList", $tmpemail, $tmplist);
2172 if ($conf->global->ADHERENT_USE_SPIP && isModEnabled(
'mailmanspip')) {
2173 $result = $mailmanspip->del_to_spip($this);
2175 $this->errors[] = $mailmanspip->error;
2196 $langs->load(
"dict");
2198 $code = (empty($this->civility_id) ?
'' : $this->civility_id);
2202 return $langs->getLabelFromKey($this->db,
"Civility".$code,
"c_civility",
"code",
"label", $code);
2215 $langs->loadLangs([
'members',
'companies']);
2216 $nofetch = !empty($params[
'nofetch']);
2221 $langs->load(
"users");
2222 return [
'optimize' => $langs->trans(
"ShowUser")];
2224 if (!empty($this->photo)) {
2225 $photo =
'<div class="photointooltip floatright">';
2226 $photo .=
Form::showphoto(
'memberphoto', $this, 80, 0, 0,
'photoref photowithmargin photologintooltip',
'small', 0, 1);
2228 $datas[
'photo'] = $photo;
2231 $datas[
'divopen'] =
'<div class="centpercent">';
2232 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <u class="paddingrightonly">'.$langs->trans(
"Member").
'</u> '.$this->
getLibStatut(4);
2233 if (!empty($this->morphy)) {
2234 $datas[
'picto'] .=
' ' . $this->
getmorphylib(
'', 1);
2236 if (!empty($this->
ref)) {
2237 $datas[
'ref'] =
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
2239 if (!empty($this->login)) {
2240 $datas[
'login'] =
'<br><b>'.$langs->trans(
'Login').
':</b> '.$this->login;
2242 if (!empty($this->firstname) || !empty($this->lastname)) {
2243 $datas[
'name'] =
'<br><b>'.$langs->trans(
'Name').
':</b> '.$this->
getFullName($langs);
2245 if (!empty($this->company)) {
2246 $datas[
'company'] =
'<br><b>'.$langs->trans(
'Company').
':</b> '.$this->company;
2248 if (!empty($this->email)) {
2249 $datas[
'email'] =
'<br><b>'.$langs->trans(
"EMail").
':</b> '.$this->email;
2251 $datas[
'address'] =
'<br><b>'.$langs->trans(
"Address").
':</b> '.
dol_format_address($this, 1,
' ', $langs);
2253 if (isModEnabled(
'categorie') && !$nofetch) {
2254 require_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
2255 $form =
new Form($this->db);
2256 $datas[
'categories'] =
'<br>' . $form->showCategories($this->
id, Categorie::TYPE_MEMBER, 1);
2258 $datas[
'divclose'] =
'</div>';
2276 public function getNomUrl($withpictoimg = 0, $maxlen = 0, $option =
'card', $mode =
'', $morecss =
'', $save_lastsearch_value = -1, $notooltip = 0, $addlinktonotes = 0)
2278 global $conf, $langs, $hookmanager;
2287 $classfortooltip =
'classfortooltip';
2291 'objecttype' => $this->element,
2292 'option' => $option,
2296 $classfortooltip =
'classforajaxtooltip';
2297 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
2303 $url = DOL_URL_ROOT.
'/adherents/card.php?rowid='.((int) $this->
id);
2304 if ($option ==
'subscription') {
2305 $url = DOL_URL_ROOT.
'/adherents/subscription.php?rowid='.((int) $this->
id);
2308 if ($option !=
'nolink') {
2310 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
2311 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
2312 $add_save_lastsearch_values = 1;
2314 if ($add_save_lastsearch_values) {
2315 $url .=
'&save_lastsearch_values=1';
2319 $linkstart .=
'<a href="'.$url.
'"';
2321 if (empty($notooltip)) {
2323 $langs->load(
"users");
2324 $label = $langs->trans(
"ShowUser");
2325 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
2327 $linkclose .= ($label ?
' title="'.dol_escape_htmltag($label, 1).
'"' :
' title="tocomplete"');
2328 $linkclose .= $dataparams.
' class="'.$classfortooltip.($morecss ?
' '.$morecss :
'').
'"';
2331 $linkstart .= $linkclose.
'>';
2334 $result .= $linkstart;
2335 if ($withpictoimg) {
2336 $result .=
'<div class="inline-block nopadding valignmiddle">';
2338 if ($withpictoimg) {
2339 $paddafterimage =
'';
2340 if (abs($withpictoimg) == 1 || abs($withpictoimg) == 4) {
2341 $morecss .=
' paddingrightonly';
2344 if ($withpictoimg > 0) {
2345 $picto =
'<span class="nopadding'.($morecss ?
' userimg'.$morecss :
'').
'">'.
img_object(
'',
'user', $paddafterimage.
' '.($notooltip ?
'' : $dataparams), 0, 0, $notooltip ? 0 : 1).
'</span>';
2348 $picto =
'<span class="nopadding'.($morecss ?
' userimg'.$morecss :
'').
'"'.($paddafterimage ?
' '.$paddafterimage :
'').
'>';
2349 $picto .=
Form::showphoto(
'memberphoto', $this, 0, 0, 0,
'userphoto'.(($withpictoimg == -3 || $withpictoimg == -4) ?
'small' :
''),
'mini', 0, 1);
2350 $picto .=
'</span>';
2354 if (($withpictoimg > -2 && $withpictoimg != 2) || $withpictoimg == -4) {
2356 $result .=
'<span class="nopadding valignmiddle'.((!isset($this->
statut) || $this->statut) ?
'' :
' strikefordisabled').
2357 ($morecss ?
' usertext'.$morecss :
'').
'">';
2359 if ($mode ==
'login') {
2360 $result .=
dol_trunc($this->login, $maxlen);
2361 } elseif ($mode ==
'ref') {
2362 $result .= $this->ref;
2364 $result .= $this->
getFullName($langs,
'', ($mode ==
'firstname' ? 2 : ($mode ==
'lastname' ? 4 : -1)), $maxlen);
2367 $result .=
'</span>';
2370 if ($withpictoimg) {
2371 $result .=
'</div>';
2373 $result .= $linkend;
2375 if ($addlinktonotes) {
2376 if ($this->note_private) {
2377 $notetoshow = $langs->trans(
"ViewPrivateNote").
':<br>'.
dol_string_nohtmltag($this->note_private, 1);
2378 $result .=
' <span class="note inline-block">';
2379 $result .=
'<a href="'.DOL_URL_ROOT.
'/adherents/note.php?id='.$this->
id.
'" class="classfortooltip" title="'.
dol_escape_htmltag($notetoshow).
'">';
2382 $result .=
'</span>';
2386 $hookmanager->initHooks(array($this->element .
'dao'));
2387 $parameters = array(
'id'=>$this->
id,
'getnomurl' => &$result);
2388 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
2390 $result = $hookmanager->resPrint;
2392 $result .= $hookmanager->resPrint;
2405 return $this->
LibStatut($this->
statut, $this->need_subscription, $this->datefin, $mode);
2418 public function LibStatut($status, $need_subscription, $date_end_subscription, $mode = 0)
2422 $langs->load(
"members");
2426 $labelStatusShort =
'';
2428 if ($status == self::STATUS_DRAFT) {
2429 $statusType =
'status0';
2430 $labelStatus = $langs->trans(
"MemberStatusDraft");
2431 $labelStatusShort = $langs->trans(
"MemberStatusDraftShort");
2432 } elseif ($status >= self::STATUS_VALIDATED) {
2433 if ($need_subscription === 0) {
2434 $statusType =
'status4';
2435 $labelStatus = $langs->trans(
"MemberStatusNoSubscription");
2436 $labelStatusShort = $langs->trans(
"MemberStatusNoSubscriptionShort");
2437 } elseif (!$date_end_subscription) {
2438 $statusType =
'status1';
2439 $labelStatus = $langs->trans(
"WaitingSubscription");
2440 $labelStatusShort = $langs->trans(
"WaitingSubscriptionShort");
2441 } elseif ($date_end_subscription <
dol_now()) {
2442 $statusType =
'status8';
2443 $labelStatus = $langs->trans(
"MemberStatusActiveLate");
2444 $labelStatusShort = $langs->trans(
"MemberStatusActiveLateShort");
2446 $statusType =
'status4';
2447 $labelStatus = $langs->trans(
"MemberStatusPaid");
2448 $labelStatusShort = $langs->trans(
"MemberStatusPaidShort");
2450 } elseif ($status == self::STATUS_RESILIATED) {
2451 $statusType =
'status6';
2452 $labelStatus = $langs->transnoentitiesnoconv(
"MemberStatusResiliated");
2453 $labelStatusShort = $langs->transnoentitiesnoconv(
"MemberStatusResiliatedShort");
2454 } elseif ($status == self::STATUS_EXCLUDED) {
2455 $statusType =
'status10';
2456 $labelStatus = $langs->transnoentitiesnoconv(
"MemberStatusExcluded");
2457 $labelStatusShort = $langs->transnoentitiesnoconv(
"MemberStatusExcludedShort");
2460 return dolGetStatus($labelStatus, $labelStatusShort,
'', $statusType, $mode);
2475 $this->nb = array();
2477 $sql =
"SELECT count(a.rowid) as nb";
2478 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as a";
2479 $sql .=
" WHERE a.statut > 0";
2480 $sql .=
" AND a.entity IN (".getEntity(
'adherent').
")";
2482 $resql = $this->db->query($sql);
2484 while ($obj = $this->db->fetch_object($resql)) {
2485 $this->nb[
"members"] = $obj->nb;
2487 $this->db->free($resql);
2491 $this->error = $this->db->error();
2507 global $conf, $langs;
2515 $sql =
"SELECT a.rowid, a.datefin, a.statut";
2516 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as a";
2517 $sql .=
", ".MAIN_DB_PREFIX.
"adherent_type as t";
2518 $sql .=
" WHERE a.fk_adherent_type = t.rowid";
2519 if ($mode ==
'expired') {
2520 $sql .=
" AND a.statut = ".self::STATUS_VALIDATED;
2521 $sql .=
" AND a.entity IN (".getEntity(
'adherent').
")";
2522 $sql .=
" AND ((a.datefin IS NULL or a.datefin < '".$this->db->idate($now).
"') AND t.subscription = '1')";
2523 } elseif ($mode ==
'shift') {
2524 $sql .=
" AND a.statut = ".self::STATUS_DRAFT;
2525 $sql .=
" AND a.entity IN (".getEntity(
'adherent').
")";
2528 $resql = $this->db->query($sql);
2530 $langs->load(
"members");
2537 if ($mode ==
'expired') {
2538 $warning_delay = $conf->adherent->subscription->warning_delay / 60 / 60 / 24;
2539 $label = $langs->trans(
"MembersWithSubscriptionToReceive");
2540 $labelShort = $langs->trans(
"MembersWithSubscriptionToReceiveShort");
2541 $url = DOL_URL_ROOT.
'/adherents/list.php?mainmenu=members&statut='.self::STATUS_VALIDATED.
'&filter=outofdate';
2542 } elseif ($mode ==
'shift') {
2543 $warning_delay = $conf->adherent->subscription->warning_delay / 60 / 60 / 24;
2544 $url = DOL_URL_ROOT.
'/adherents/list.php?mainmenu=members&statut='.
self::STATUS_DRAFT;
2545 $label = $langs->trans(
"MembersListToValid");
2546 $labelShort = $langs->trans(
"ToValidate");
2550 $response->warning_delay = $warning_delay;
2551 $response->label = $label;
2552 $response->labelShort = $labelShort;
2553 $response->url = $url;
2556 $adherentstatic =
new Adherent($this->db);
2558 while ($obj = $this->db->fetch_object($resql)) {
2559 $response->nbtodo++;
2561 $adherentstatic->datefin = $this->db->jdate($obj->datefin);
2562 $adherentstatic->statut = $obj->statut;
2564 if ($adherentstatic->hasDelay()) {
2565 $response->nbtodolate++;
2572 $this->error = $this->db->error();
2589 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams =
null)
2591 global $conf, $langs;
2593 $langs->load(
"orders");
2596 $modele =
'standard';
2598 if ($this->model_pdf) {
2599 $modele = $this->model_pdf;
2601 $modele = $conf->global->ADHERENT_ADDON_PDF;
2605 $modelpath =
"core/modules/member/doc/";
2607 return $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
2620 global $user, $langs;
2625 $this->
ref =
'ABC001';
2627 $this->specimen = 1;
2628 $this->civility_id = 0;
2629 $this->lastname =
'DOLIBARR';
2630 $this->firstname =
'SPECIMEN';
2631 $this->gender =
'man';
2632 $this->login =
'dolibspec';
2633 $this->pass =
'dolibspec';
2634 $this->company =
'Societe ABC';
2635 $this->address =
'61 jump street';
2636 $this->zip =
'75000';
2637 $this->town =
'Paris';
2638 $this->country_id = 1;
2639 $this->country_code =
'FR';
2640 $this->country =
'France';
2641 $this->morphy =
'mor';
2642 $this->email =
'specimen@specimen.com';
2643 $this->socialnetworks = array(
2644 'skype' =>
'skypepseudo',
2645 'twitter' =>
'twitterpseudo',
2646 'facebook' =>
'facebookpseudo',
2647 'linkedin' =>
'linkedinpseudo',
2649 $this->phone =
'0999999999';
2650 $this->phone_perso =
'0999999998';
2651 $this->phone_mobile =
'0999999997';
2652 $this->note_public =
'This is a public note';
2653 $this->note_private =
'This is a private note';
2654 $this->birth = $now;
2659 $this->datefin = $now;
2660 $this->datevalid = $now;
2661 $this->default_lang =
'';
2664 $this->
type =
'Type adherent';
2665 $this->need_subscription = 0;
2667 $this->first_subscription_date = $now;
2668 $this->first_subscription_date_start = $this->first_subscription_date;
2669 $this->first_subscription_date_end =
dol_time_plus_duree($this->first_subscription_date_start, 1,
'y');
2670 $this->first_subscription_amount = 10;
2672 $this->last_subscription_date = $this->first_subscription_date;
2673 $this->last_subscription_date_start = $this->first_subscription_date;
2674 $this->last_subscription_date_end =
dol_time_plus_duree($this->last_subscription_date_start, 1,
'y');
2675 $this->last_subscription_amount = 10;
2700 $dn = $conf->global->LDAP_MEMBER_DN;
2719 global $conf, $langs;
2723 $keymodified =
false;
2731 if ($this->morphy ==
'mor' && (empty($this->fullname) || $this->fullname == $this->company)) {
2732 $this->fullname = $this->company;
2733 $this->lastname = $this->company;
2738 'LDAP_MEMBER_FIELD_FULLNAME' =>
'fullname',
2739 'LDAP_MEMBER_FIELD_NAME' =>
'lastname',
2740 'LDAP_MEMBER_FIELD_LOGIN' =>
'login',
2741 'LDAP_MEMBER_FIELD_LOGIN_SAMBA' =>
'login',
2742 'LDAP_MEMBER_FIELD_MAIL' =>
'email'
2746 foreach ($ldapkey as $constname => $varname) {
2752 if (!empty($this->oldcopy) && $this->$varname != $this->oldcopy->$varname) {
2753 $keymodified =
true;
2779 foreach ($socialnetworks as $key => $value) {
2780 if ($this->socialnetworks[$value[
'label']] &&
getDolGlobalString(
'LDAP_MEMBER_FIELD_'.strtoupper($value[
'label']))) {
2781 $info[
getDolGlobalString(
'LDAP_MEMBER_FIELD_'.strtoupper($value[
'label']))] = $this->socialnetworks[$value[
'label']];
2808 if ($this->datefin &&
getDolGlobalString(
'LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION')) {
2813 if (!empty($this->pass)) {
2826 if ($this->pass_indatabase_crypted &&
getDolGlobalString(
'LDAP_MEMBER_FIELD_PASSWORD_CRYPTED')) {
2832 } elseif (!empty($this->pass_indatabase)) {
2844 if ($this->first_subscription_date &&
getDolGlobalString(
'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE')) {
2847 if (isset($this->first_subscription_amount) &&
getDolGlobalString(
'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT')) {
2848 $info[
getDolGlobalString(
'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT')] = $this->first_subscription_amount;
2850 if ($this->last_subscription_date &&
getDolGlobalString(
'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE')) {
2853 if (isset($this->last_subscription_amount) &&
getDolGlobalString(
'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT')) {
2854 $info[
getDolGlobalString(
'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT')] = $this->last_subscription_amount;
2869 $sql =
'SELECT a.rowid, a.datec as datec,';
2870 $sql .=
' a.datevalid as datev,';
2871 $sql .=
' a.tms as datem,';
2872 $sql .=
' a.fk_user_author, a.fk_user_valid, a.fk_user_mod';
2873 $sql .=
' FROM '.MAIN_DB_PREFIX.
'adherent as a';
2874 $sql .=
' WHERE a.rowid = '.((int) $id);
2876 dol_syslog(get_class($this).
"::info", LOG_DEBUG);
2877 $result = $this->db->query($sql);
2879 if ($this->db->num_rows($result)) {
2880 $obj = $this->db->fetch_object($result);
2882 $this->
id = $obj->rowid;
2884 $this->user_creation_id = $obj->fk_user_author;
2885 $this->user_validation_id = $obj->fk_user_valid;
2886 $this->user_modification_id = $obj->fk_user_mod;
2887 $this->date_creation = $this->db->jdate($obj->datec);
2888 $this->date_validation = $this->db->jdate($obj->datev);
2889 $this->date_modification = $this->db->jdate($obj->datem);
2892 $this->db->free($result);
2905 $sql =
"SELECT count(mc.email) as nb";
2906 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mailing_cibles as mc";
2907 $sql .=
" WHERE mc.email = '".$this->db->escape($this->email).
"'";
2908 $sql .=
" AND mc.statut NOT IN (-1,0)";
2910 $resql = $this->db->query($sql);
2912 $obj = $this->db->fetch_object($resql);
2915 $this->db->free($resql);
2918 $this->error = $this->db->error();
2935 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
2936 return parent::setCategoriesCommon($categories, Categorie::TYPE_MEMBER);
2949 $tables = array(
'adherent');
2964 if ($this->
statut != self::STATUS_VALIDATED) {
2967 if (!$this->datefin) {
2973 return $this->datefin < ($now - $conf->adherent->subscription->warning_delay);
2986 global $conf, $langs, $mysoc, $user;
2992 $blockingerrormsg =
'';
2994 if (!isModEnabled(
'adherent')) {
2995 $langs->load(
"agenda");
2996 $this->output = $langs->trans(
'ModuleNotEnabled', $langs->transnoentitiesnoconv(
"Adherent"));
3000 $langs->load(
"agenda");
3001 $this->output = $langs->trans(
'EventRemindersByEmailNotEnabled', $langs->transnoentitiesnoconv(
"Adherent"));
3009 $listofmembersok = array();
3010 $listofmembersko = array();
3012 $arraydaysbeforeend = explode(
';', $daysbeforeendlist);
3013 foreach ($arraydaysbeforeend as $daysbeforeend) {
3014 dol_syslog(__METHOD__.
' - Process delta = '.$daysbeforeend, LOG_DEBUG);
3016 if (!is_numeric($daysbeforeend)) {
3017 $blockingerrormsg =
"Value for delta is not a numeric value";
3025 $sql =
'SELECT rowid FROM '.MAIN_DB_PREFIX.
'adherent';
3026 $sql .=
" WHERE entity = ".((int) $conf->entity);
3027 $sql .=
" AND statut = 1";
3028 $sql .=
" AND datefin = '".$this->db->idate($datetosearchfor).
"'";
3031 $resql = $this->db->query($sql);
3033 $num_rows = $this->db->num_rows($resql);
3035 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
3036 $adherent =
new Adherent($this->db);
3037 $formmail =
new FormMail($this->db);
3040 while ($i < $num_rows) {
3041 $obj = $this->db->fetch_object($resql);
3043 $adherent->fetch($obj->rowid,
'',
'',
'',
true,
true);
3045 if (empty($adherent->email)) {
3047 $listofmembersko[$adherent->id] = $adherent->id;
3049 $adherent->fetch_thirdparty();
3052 $languagefromcountrycode =
getLanguageCodeFromCountryCode($adherent->country_code ? $adherent->country_code : $adherent->thirdparty->country_code);
3053 $languagecodeformember = (empty($adherent->thirdparty->default_lang) ? ($languagefromcountrycode ? $languagefromcountrycode : $mysoc->default_lang) : $adherent->thirdparty->default_lang);
3056 $outputlangs =
new Translate(
'', $conf);
3057 $outputlangs->setDefaultLang($languagecodeformember);
3058 $outputlangs->loadLangs(array(
"main",
"members"));
3059 dol_syslog(
"sendReminderForExpiredSubscription Language for member id ".$adherent->id.
" set to ".$outputlangs->defaultlang.
" mysoc->default_lang=".$mysoc->default_lang);
3061 $arraydefaultmessage =
null;
3064 if (!empty($labeltouse)) {
3065 $arraydefaultmessage = $formmail->getEMailTemplate($this->db,
'member', $user, $outputlangs, 0, 1, $labeltouse);
3068 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
3073 $subject =
make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs);
3074 $msg =
make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs);
3076 $to = $adherent->email;
3079 $trackid =
'mem'.$adherent->id;
3080 $moreinheader =
'X-Dolibarr-Info: sendReminderForExpiredSubscription'.
"\r\n";
3082 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
3083 $cmail =
new CMailFile($subject, $to, $from, $msg, array(), array(), array(), $cc,
'', 0, 1,
'',
'', $trackid, $moreinheader);
3084 $result = $cmail->sendfile();
3087 $this->error .= $cmail->error.
' ';
3088 if (!is_null($cmail->errors)) {
3089 $this->errors += $cmail->errors;
3092 $listofmembersko[$adherent->id] = $adherent->id;
3095 $listofmembersok[$adherent->id] = $adherent->id;
3101 $actioncode =
'EMAIL';
3112 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic').
": ".$subject);
3113 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody').
":");
3117 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
3122 $actioncomm->type_code =
'AC_OTH_AUTO';
3123 $actioncomm->code =
'AC_'.$actioncode;
3124 $actioncomm->label = $actionmsg2;
3125 $actioncomm->note_private = $actionmsg;
3126 $actioncomm->fk_project = 0;
3127 $actioncomm->datep = $now;
3128 $actioncomm->datef = $now;
3129 $actioncomm->percentage = -1;
3130 $actioncomm->socid = $adherent->thirdparty->id;
3131 $actioncomm->contact_id = 0;
3132 $actioncomm->authorid = $user->id;
3133 $actioncomm->userownerid = $user->id;
3135 $actioncomm->email_msgid = $cmail->msgid;
3136 $actioncomm->email_from = $from;
3137 $actioncomm->email_sender =
'';
3138 $actioncomm->email_to = $to;
3139 $actioncomm->email_tocc = $sendtocc;
3140 $actioncomm->email_tobcc = $sendtobcc;
3141 $actioncomm->email_subject = $subject;
3142 $actioncomm->errors_to =
'';
3144 $actioncomm->fk_element = $adherent->id;
3145 $actioncomm->elementtype = $adherent->element;
3147 $actioncomm->extraparams = $extraparams;
3149 $actioncomm->create($user);
3155 $this->error .=
"Can't find email template with label=".$labeltouse.
", to use for the reminding email ";
3158 $listofmembersko[$adherent->id] = $adherent->id;
3167 $this->error = $this->db->lasterror();
3172 if ($blockingerrormsg) {
3173 $this->error = $blockingerrormsg;
3176 $this->output =
'Found '.($nbok + $nbko).
' members to send reminder to.';
3177 $this->output .=
' Send email successfuly to '.$nbok.
' members';
3178 if (is_array($listofmembersok)) {
3181 foreach ($listofmembersok as $idmember) {
3183 $listofids .=
', ...';
3186 if (empty($listofids)) {
3191 $listofids .= $idmember;
3198 $this->output .= ($listofids ?
' ids='.$listofids :
'');
3201 $this->output .=
' - Canceled for '.$nbko.
' member (no email or email sending error)';
3202 if (is_array($listofmembersko)) {
3205 foreach ($listofmembersko as $idmember) {
3207 $listofids .=
', ...';
3210 if (empty($listofids)) {
3215 $listofids .= $idmember;
3221 $this->output .= ($listofids ?
' ids='.$listofids :
'');
3238 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
3240 $return =
'<div class="box-flex-item box-flex-grow-zero">';
3241 $return .=
'<div class="info-box info-box-sm">';
3242 $return .=
'<span class="info-box-icon bg-infobox-action">';
3243 if (property_exists($this,
'photo') || !empty($this->photo)) {
3244 $return.=
Form::showphoto(
'memberphoto', $this, 0, 60, 0,
'photokanban photoref photowithmargin photologintooltip',
'small', 0, 1);
3248 $return .=
'</span>';
3249 $return .=
'<div class="info-box-content">';
3250 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this,
'getNomUrl') ? $this->
getNomUrl() : $this->ref).
'</span>';
3251 if ($selected >= 0) {
3252 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
3254 if (property_exists($this,
'type')) {
3255 $return .=
'<br><span class="info-box-label opacitymedium">'.$this->type.
'</span>';
3257 if (method_exists($this,
'getmorphylib')) {
3258 $return .=
'<br><span class="info-box-label">'.$this->getmorphylib(
'', 2).
'</span>';
3260 if (method_exists($this,
'getLibStatut')) {
3261 $return .=
'<br><div class="info-box-status">'.$this->getLibStatut(3).
'</div>';
3263 $return .=
'</div>';
3264 $return .=
'</div>';
3265 $return .=
'</div>';
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
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.
getTooltipContentArray($params)
getTooltipContentArray
getNbOfEMailings()
Return number of mass Emailing received by this member with its email.
update_end_date($user)
Update denormalized last subscription date.
static replaceThirdparty($db, $origin_id, $dest_id)
Function used to replace a thirdparty id with another one.
makeSubstitution($text)
Make substitution of tags into text with value of current object.
const STATUS_EXCLUDED
Excluded.
LibStatut($status, $need_subscription, $date_end_subscription, $mode=0)
Renvoi le libelle d'un statut donne.
fetch_name($firstname, $lastname)
Method to load member from its name.
initAsSpecimen()
Initialise an instance with random values.
fetch($rowid, $ref='', $fk_soc=0, $ref_ext='', $fetch_optionals=true, $fetch_subscriptions=true)
Load member from database.
del_to_abo()
Function to delete a member from external tools like mailing-list, spip, etc.
resiliate($user)
Fonction qui resilie un adherent.
getCivilityLabel()
Return civility label of a member.
getmorphylib($morphy='', $addbadge=0)
Return translated label by the nature of a adherent (physical or moral)
sendEmail($text, $subject, $filename_list=array(), $mimetype_list=array(), $mimefilename_list=array(), $addr_cc="", $addr_bcc="", $deliveryreceipt=0, $msgishtml=-1, $errors_to='', $moreinheader='')
Function sending an email to the current member with the text supplied in parameter.
fetchPartnerships($mode)
Function to get partnerships array.
load_board($user, $mode)
Load indicators for dashboard (this->nbtodo and this->nbtodolate)
setPassword($user, $password='', $isencrypted=0, $notrigger=0, $nosyncuser=0)
Change password of a user.
getKanbanView($option='', $arraydata=null)
Return clicable link of object (with eventually picto)
const STATUS_DRAFT
Draft status.
const STATUS_RESILIATED
Resiliated.
fetch_login($login)
Method to load member from its login.
create($user, $notrigger=0)
Create a member into database.
_load_ldap_info()
Initialise tableau info (tableau des 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.
const STATUS_VALIDATED
Validated status.
fetch_subscriptions()
Function to get member subscriptions data: subscriptions, first_subscription_date,...
validate($user)
Function that validate a member.
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
static getValidAddress($address, $format, $encode=0, $maxnumberofemail=0)
Return a formatted address string for SMTP protocol.
Parent class of all other business classes (invoices, contracts, proposals, orders,...
fetch_optionals($rowid=null, $optionsArray=null)
Function to get extra fields of an object into $this->array_options This method is in most cases call...
commonGenerateDocument($modelspath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams=null)
Common function for all objects extending CommonObject for generating documents.
setErrorsFromObject($object)
setErrorsFromObject
deleteExtraFields()
Delete all extra fields values for the current object.
static commonReplaceThirdparty(DoliDB $dbs, $origin_id, $dest_id, array $tables, $ignoreerrors=0)
Function used to replace a thirdparty id with another one.
insertExtraFields($trigger='', $userused=null)
Add/Update all extra fields values for the current object.
call_trigger($triggerName, $user)
Call trigger based on this instance.
Class to manage invoices.
const TYPE_STANDARD
Standard invoice.
Class to manage mailman and spip.
Class to manage payments of customer invoices.
Class to manage payment terms records in dictionary.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage subscriptions of foundation members.
Class to manage translations.
Class to manage Dolibarr users.
trait CommonPeople
Superclass for thirdparties, contacts, members or users.
getFullName($langs, $option=0, $nameorder=-1, $maxlen=0)
Return full name (civility+' '+name+' '+lastname)
setUpperOrLowerCase()
Set to upper or ucwords/lower if needed.
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
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.
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_format_address($object, $withcountry=0, $sep="\n", $outputlangs='', $mode=0, $extralangcode='')
Return a formated address (part address/zip/town/state) according to country rules.
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 a 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...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
getArrayOfSocialNetworks()
Get array of social network dictionary.
dol_textishtml($msg, $option=0)
Return if a text is a html content.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null, $include=null)
Return array of possible common substitutions.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that return vat rate of a product line (according to seller, buyer and product vat rate) VAT...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
publicphonebutton2 phonegreen basiclayout basiclayout TotalHT VATCode TotalVAT TotalLT1 TotalLT2 TotalTTC TotalHT clearboth nowraponall right right takeposterminal SELECT e e e e e statut
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
getRandomPassword($generic=false, $replaceambiguouschars=null, $length=32)
Return a generated password using default module.
dolGetLdapPasswordHash($password, $type='md5')
Returns a specific ldap hash of a password.
dol_hash($chain, $type='0', $nosalt=0)
Returns a hash (non reversible encryption) of a string.