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;
159 public $socialnetworks;
207 public $phone_mobile;
233 public $default_lang;
276 public $need_subscription;
293 public $first_subscription_date;
295 public $first_subscription_amount;
297 public $last_subscription_date;
299 public $last_subscription_date_start;
301 public $last_subscription_date_end;
303 public $last_subscription_amount;
305 public $subscriptions = array();
310 public $partnerships = array();
326 public $fields = array(
327 'rowid' => array(
'type' =>
'integer',
'label' =>
'TechnicalID',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 10),
328 'ref' => array(
'type' =>
'varchar(30)',
'label' =>
'Ref',
'default' => 1,
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 12,
'index' => 1),
329 'entity' => array(
'type' =>
'integer',
'label' =>
'Entity',
'default' => 1,
'enabled' => 1,
'visible' => -2,
'notnull' => 1,
'position' => 15,
'index' => 1),
330 'ref_ext' => array(
'type' =>
'varchar(128)',
'label' =>
'Ref ext',
'enabled' => 1,
'visible' => 0,
'position' => 20),
331 'civility' => array(
'type' =>
'varchar(6)',
'label' =>
'Civility',
'enabled' => 1,
'visible' => -1,
'position' => 25),
332 'lastname' => array(
'type' =>
'varchar(50)',
'label' =>
'Lastname',
'enabled' => 1,
'visible' => -1,
'position' => 30,
'showoncombobox'=>1),
333 'firstname' => array(
'type' =>
'varchar(50)',
'label' =>
'Firstname',
'enabled' => 1,
'visible' => -1,
'position' => 35,
'showoncombobox'=>1),
334 'login' => array(
'type' =>
'varchar(50)',
'label' =>
'Login',
'enabled' => 1,
'visible' => -1,
'position' => 40),
335 'gender' => array(
'type' =>
'varchar(10)',
'label' =>
'Gender',
'enabled' => 1,
'visible' => -1,
'position' => 250),
336 'pass' => array(
'type' =>
'varchar(50)',
'label' =>
'Pass',
'enabled' => 1,
'visible' => -1,
'position' => 45),
337 'pass_crypted' => array(
'type' =>
'varchar(128)',
'label' =>
'Pass crypted',
'enabled' => 1,
'visible' => -1,
'position' => 50),
338 'fk_adherent_type' => array(
'type' =>
'integer',
'label' =>
'Fk adherent type',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 55),
339 'morphy' => array(
'type' =>
'varchar(3)',
'label' =>
'MorPhy',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 60),
340 'societe' => array(
'type' =>
'varchar(128)',
'label' =>
'Societe',
'enabled' => 1,
'visible' => -1,
'position' => 65,
'showoncombobox'=>2),
341 'fk_soc' => array(
'type' =>
'integer:Societe:societe/class/societe.class.php',
'label' =>
'ThirdParty',
'enabled' => 1,
'visible' => -1,
'position' => 70),
342 'address' => array(
'type' =>
'text',
'label' =>
'Address',
'enabled' => 1,
'visible' => -1,
'position' => 75),
343 'zip' => array(
'type' =>
'varchar(10)',
'label' =>
'Zip',
'enabled' => 1,
'visible' => -1,
'position' => 80),
344 'town' => array(
'type' =>
'varchar(50)',
'label' =>
'Town',
'enabled' => 1,
'visible' => -1,
'position' => 85),
345 'state_id' => array(
'type' =>
'integer',
'label' =>
'State id',
'enabled' => 1,
'visible' => -1,
'position' => 90),
346 'country' => array(
'type' =>
'integer:Ccountry:core/class/ccountry.class.php',
'label' =>
'Country',
'enabled' => 1,
'visible' => -1,
'position' => 95),
347 'email' => array(
'type' =>
'varchar(255)',
'label' =>
'Email',
'enabled' => 1,
'visible' => -1,
'position' => 100),
348 'url' =>array(
'type'=>
'varchar(255)',
'label'=>
'Url',
'enabled'=>1,
'visible'=>-1,
'position'=>110),
349 'socialnetworks' => array(
'type' =>
'text',
'label' =>
'Socialnetworks',
'enabled' => 1,
'visible' => -1,
'position' => 105),
350 'phone' => array(
'type' =>
'varchar(30)',
'label' =>
'Phone',
'enabled' => 1,
'visible' => -1,
'position' => 115),
351 'phone_perso' => array(
'type' =>
'varchar(30)',
'label' =>
'Phone perso',
'enabled' => 1,
'visible' => -1,
'position' => 120),
352 'phone_mobile' => array(
'type' =>
'varchar(30)',
'label' =>
'Phone mobile',
'enabled' => 1,
'visible' => -1,
'position' => 125),
353 'birth' => array(
'type' =>
'date',
'label' =>
'DateOfBirth',
'enabled' => 1,
'visible' => -1,
'position' => 130),
354 'photo' => array(
'type' =>
'varchar(255)',
'label' =>
'Photo',
'enabled' => 1,
'visible' => -1,
'position' => 135),
355 'public' => array(
'type' =>
'smallint(6)',
'label' =>
'Public',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 145),
356 'datefin' => array(
'type' =>
'datetime',
'label' =>
'DateEnd',
'enabled' => 1,
'visible' => -1,
'position' => 150),
357 'default_lang' =>array(
'type'=>
'varchar(6)',
'label'=>
'Default lang',
'enabled'=>1,
'visible'=>-1,
'position'=> 153),
358 'note_public' => array(
'type' =>
'text',
'label' =>
'NotePublic',
'enabled' => 1,
'visible' => 0,
'position' => 155),
359 'note_private' => array(
'type' =>
'text',
'label' =>
'NotePrivate',
'enabled' => 1,
'visible' => 0,
'position' => 160),
360 'datevalid' => array(
'type' =>
'datetime',
'label' =>
'DateValidation',
'enabled' => 1,
'visible' => -1,
'position' => 165),
361 'datec' => array(
'type' =>
'datetime',
'label' =>
'DateCreation',
'enabled' => 1,
'visible' => -1,
'position' => 170),
362 'tms' => array(
'type' =>
'timestamp',
'label' =>
'DateModification',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 175),
363 'fk_user_author' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'Fk user author',
'enabled' => 1,
'visible' => -1,
'position' => 180),
364 'fk_user_mod' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'Fk user mod',
'enabled' => 1,
'visible' => -1,
'position' => 185),
365 'fk_user_valid' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'UserValidation',
'enabled' => 1,
'visible' => -1,
'position' => 190),
366 'canvas' => array(
'type' =>
'varchar(32)',
'label' =>
'Canvas',
'enabled' => 1,
'visible' => -1,
'position' => 195),
367 'statut' => array(
'type' =>
'smallint(6)',
'label' =>
'Statut',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 500,
368 'arrayofkeyval' => array(-1 =>
'Draft', 1 =>
'Validated', 0 =>
'MemberStatusResiliatedShort', -2 =>
'MemberStatusExcludedShort')),
369 'model_pdf' => array(
'type' =>
'varchar(255)',
'label' =>
'Model pdf',
'enabled' => 1,
'visible' => 0,
'position' => 800),
370 'import_key' => array(
'type' =>
'varchar(14)',
'label' =>
'ImportId',
'enabled' => 1,
'visible' => -2,
'position' => 805)
400 $this->status = $this->statut;
404 $this->array_options = array();
425 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 =
'')
428 global $conf, $langs;
431 if ($msgishtml == -1) {
438 dol_syslog(
'send_an_email msgishtml='.$msgishtml);
447 $from = $conf->email_from;
452 $trackid =
'mem'.$this->id;
455 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
456 $mailfile =
new CMailFile($subjecttosend, $this->email, $from, $texttosend, $filename_list, $mimetype_list, $mimefilename_list, $addr_cc, $addr_bcc, $deliveryreceipt, $msgishtml,
'',
'', $trackid, $moreinheader);
457 if ($mailfile->sendfile()) {
460 $this->error = $langs->trans(
"ErrorFailedToSendMail", $from, $this->email).
'. '.$mailfile->error;
474 global $conf, $langs;
484 if ($this->civility_id) {
485 $infos .= $langs->transnoentities(
"UserTitle").
": ".$this->
getCivilityLabel().
"\n";
487 $infos .= $langs->transnoentities(
"id").
": ".$this->
id.
"\n";
488 $infos .= $langs->transnoentities(
"ref").
": ".$this->
ref.
"\n";
489 $infos .= $langs->transnoentities(
"Lastname").
": ".$this->lastname.
"\n";
490 $infos .= $langs->transnoentities(
"Firstname").
": ".$this->firstname.
"\n";
491 $infos .= $langs->transnoentities(
"Company").
": ".$this->company.
"\n";
492 $infos .= $langs->transnoentities(
"Address").
": ".$this->address.
"\n";
493 $infos .= $langs->transnoentities(
"Zip").
": ".$this->zip.
"\n";
494 $infos .= $langs->transnoentities(
"Town").
": ".$this->town.
"\n";
495 $infos .= $langs->transnoentities(
"Country").
": ".$this->country.
"\n";
496 $infos .= $langs->transnoentities(
"EMail").
": ".$this->email.
"\n";
497 $infos .= $langs->transnoentities(
"PhonePro").
": ".$this->phone.
"\n";
498 $infos .= $langs->transnoentities(
"PhonePerso").
": ".$this->phone_perso.
"\n";
499 $infos .= $langs->transnoentities(
"PhoneMobile").
": ".$this->phone_mobile.
"\n";
500 if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
501 $infos .= $langs->transnoentities(
"Login").
": ".$this->login.
"\n";
502 $infos .= $langs->transnoentities(
"Password").
": ".$this->pass.
"\n";
504 $infos .= $langs->transnoentities(
"Birthday").
": ".$birthday.
"\n";
505 $infos .= $langs->transnoentities(
"Photo").
": ".$this->photo.
"\n";
506 $infos .= $langs->transnoentities(
"Public").
": ".
yn($this->
public);
509 $substitutionarray = array(
510 '__ID__' => $this->
id,
511 '__REF__' => $this->
ref,
512 '__MEMBER_ID__' => $this->
id,
514 '__FIRSTNAME__' => $msgishtml ?
dol_htmlentitiesbr($this->firstname) : ($this->firstname ? $this->firstname :
''),
515 '__LASTNAME__' => $msgishtml ?
dol_htmlentitiesbr($this->lastname) : ($this->lastname ? $this->lastname :
''),
517 '__COMPANY__' => $msgishtml ?
dol_htmlentitiesbr($this->company) : ($this->company ? $this->company :
''),
518 '__ADDRESS__' => $msgishtml ?
dol_htmlentitiesbr($this->address) : ($this->address ? $this->address :
''),
519 '__ZIP__' => $msgishtml ?
dol_htmlentitiesbr($this->zip) : ($this->zip ? $this->zip :
''),
520 '__TOWN__' => $msgishtml ?
dol_htmlentitiesbr($this->town) : ($this->town ? $this->town :
''),
521 '__COUNTRY__' => $msgishtml ?
dol_htmlentitiesbr($this->country) : ($this->country ? $this->country :
''),
522 '__EMAIL__' => $msgishtml ?
dol_htmlentitiesbr($this->email) : ($this->email ? $this->email :
''),
523 '__BIRTH__' => $msgishtml ?
dol_htmlentitiesbr($birthday) : ($birthday ? $birthday :
''),
524 '__PHOTO__' => $msgishtml ?
dol_htmlentitiesbr($this->photo) : ($this->photo ? $this->photo :
''),
525 '__LOGIN__' => $msgishtml ?
dol_htmlentitiesbr($this->login) : ($this->login ? $this->login :
''),
526 '__PASSWORD__' => $msgishtml ?
dol_htmlentitiesbr($this->pass) : ($this->pass ? $this->pass :
''),
527 '__PHONE__' => $msgishtml ?
dol_htmlentitiesbr($this->phone) : ($this->phone ? $this->phone :
''),
528 '__PHONEPRO__' => $msgishtml ?
dol_htmlentitiesbr($this->phone_perso) : ($this->phone_perso ? $this->phone_perso :
''),
529 '__PHONEMOBILE__' => $msgishtml ?
dol_htmlentitiesbr($this->phone_mobile) : ($this->phone_mobile ? $this->phone_mobile :
''),
552 $morphy = $this->morphy;
557 $labeltoshowm = $langs->trans(
"Moral");
558 $labeltoshowp = $langs->trans(
"Physical");
559 if ($morphy ==
'phy') {
560 $labeltoshow = $labeltoshowp;
561 if ($addbadge == 2) {
567 $s .=
'<span class="member-individual-back paddingleftimp paddingrightimp" title="'.$langs->trans(
"Physical").
'">'.$labeltoshow.
'</span>';
569 if ($morphy ==
'mor') {
570 $labeltoshow = $labeltoshowm;
571 if ($addbadge == 2) {
577 $s .=
'<span class="member-company-back paddingleftimp paddingrightimp" title="'.$langs->trans(
"Moral").
'">'.$labeltoshow.
'</span>';
580 if ($morphy ==
'phy') {
581 $s = $langs->trans(
"Physical");
582 } elseif ($morphy ==
'mor') {
583 $s = $langs->trans(
"Moral");
597 public function create($user, $notrigger = 0)
599 global $conf, $langs, $mysoc;
606 $this->import_key = trim($this->import_key);
609 if (!empty($conf->global->ADHERENT_MAIL_REQUIRED) && !isValidEMail($this->email)) {
610 $langs->load(
"errors");
611 $this->error = $langs->trans(
"ErrorBadEMail", $this->email);
617 if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
618 if (empty($this->login)) {
619 $this->error = $langs->trans(
"ErrorWrongValueForParameterX",
"Login");
627 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"adherent";
628 $sql .=
" (ref, datec,login,fk_user_author,fk_user_mod,fk_user_valid,morphy,fk_adherent_type,entity,import_key, ip)";
631 $sql .=
", '".$this->db->idate($this->datec).
"'";
632 $sql .=
", ".($this->login ?
"'".$this->db->escape($this->login).
"'" :
"null");
633 $sql .=
", ".($user->id > 0 ? $user->id :
"null");
634 $sql .=
", null, null, '".$this->db->escape($this->morphy).
"'";
635 $sql .=
", ".((int) $this->
typeid);
636 $sql .=
", ".$conf->entity;
637 $sql .=
", ".(!empty($this->import_key) ?
"'".$this->db->escape($this->import_key).
"'" :
"null");
638 $sql .=
", ".(!empty($this->ip) ?
"'".$this->db->escape($this->ip).
"'" :
"null");
641 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
642 $result = $this->
db->query($sql);
644 $id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
"adherent");
649 $this->
ref = (string) $id;
654 require_once $modfile;
656 $modCodeMember =
new $modname;
657 $this->
ref = $modCodeMember->getNextValue($mysoc, $this);
665 $result = $this->
update($user, 1, 1, 0, 0,
'add');
667 $this->
db->rollback();
672 if ($this->user_id) {
674 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET";
675 $sql .=
" fk_member = ".((int) $this->
id);
676 $sql .=
" WHERE rowid = ".((int) $this->user_id);
677 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
680 $this->error =
'Failed to update user to make link with member';
681 $this->
db->rollback();
695 if (count($this->errors)) {
696 dol_syslog(get_class($this).
"::create ".implode(
',', $this->errors), LOG_ERR);
697 $this->
db->rollback();
704 $this->error =
'Failed to get last insert id';
705 dol_syslog(get_class($this).
"::create ".$this->error, LOG_ERR);
706 $this->
db->rollback();
710 $this->error = $this->
db->error();
711 $this->
db->rollback();
728 public function update($user, $notrigger = 0, $nosyncuser = 0, $nosyncuserpass = 0, $nosyncthirdparty = 0, $action =
'update')
730 global $conf, $langs, $hookmanager;
732 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
737 dol_syslog(get_class($this).
"::update notrigger=".$notrigger.
", nosyncuser=".$nosyncuser.
", nosyncuserpass=".$nosyncuserpass.
" nosyncthirdparty=".$nosyncthirdparty.
", email=".$this->email);
740 $this->lastname = trim($this->lastname) ? trim($this->lastname) : trim($this->lastname);
741 $this->firstname = trim($this->firstname) ? trim($this->firstname) : trim($this->firstname);
742 $this->gender = trim($this->gender);
743 $this->address = ($this->address ? $this->address : $this->address);
744 $this->zip = ($this->zip ? $this->zip : $this->zip);
745 $this->town = ($this->town ? $this->town : $this->town);
746 $this->country_id = ($this->country_id > 0 ? $this->country_id : $this->country_id);
747 $this->state_id = ($this->state_id > 0 ? $this->state_id : $this->state_id);
748 $this->note_public = ($this->note_public ? $this->note_public : $this->note_public);
749 $this->note_private = ($this->note_private ? $this->note_private : $this->note_private);
750 $this->url = $this->url ?
clean_url($this->url, 0) :
'';
753 if (!empty($conf->global->ADHERENT_MAIL_REQUIRED) && !isValidEMail($this->email)) {
754 $langs->load(
"errors");
755 $this->error = $langs->trans(
"ErrorBadEMail", $this->email);
761 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
762 $sql .=
" ref = '".$this->db->escape($this->
ref).
"'";
763 $sql .=
", civility = ".($this->civility_id ?
"'".$this->db->escape($this->civility_id).
"'" :
"null");
764 $sql .=
", firstname = ".($this->firstname ?
"'".$this->db->escape($this->firstname).
"'" :
"null");
765 $sql .=
", lastname = ".($this->lastname ?
"'".$this->db->escape($this->lastname).
"'" :
"null");
766 $sql .=
", gender = ".($this->gender != -1 ?
"'".$this->db->escape($this->gender).
"'" :
"null");
767 $sql .=
", login = ".($this->login ?
"'".$this->db->escape($this->login).
"'" :
"null");
768 $sql .=
", societe = ".($this->company ?
"'".$this->db->escape($this->company).
"'" : ($this->societe ?
"'".$this->db->escape($this->societe).
"'" :
"null"));
770 $sql .=
", fk_soc = ".($this->socid > 0 ? $this->
db->escape($this->socid) :
"null");
772 $sql .=
", address = ".($this->address ?
"'".$this->db->escape($this->address).
"'" :
"null");
773 $sql .=
", zip = ".($this->zip ?
"'".$this->db->escape($this->zip).
"'" :
"null");
774 $sql .=
", town = ".($this->town ?
"'".$this->db->escape($this->town).
"'" :
"null");
775 $sql .=
", country = ".($this->country_id > 0 ? $this->
db->escape($this->country_id) :
"null");
776 $sql .=
", state_id = ".($this->state_id > 0 ? $this->
db->escape($this->state_id) :
"null");
777 $sql .=
", email = '".$this->db->escape($this->email).
"'";
778 $sql .=
", url = ".(!empty($this->url) ?
"'".$this->db->escape($this->url).
"'" :
"null");
779 $sql .=
", socialnetworks = ".($this->socialnetworks ?
"'".$this->db->escape(json_encode($this->socialnetworks)).
"'" :
"null");
780 $sql .=
", phone = ".($this->phone ?
"'".$this->db->escape($this->phone).
"'" :
"null");
781 $sql .=
", phone_perso = ".($this->phone_perso ?
"'".$this->db->escape($this->phone_perso).
"'" :
"null");
782 $sql .=
", phone_mobile = ".($this->phone_mobile ?
"'".$this->db->escape($this->phone_mobile).
"'" :
"null");
783 $sql .=
", note_private = ".($this->note_private ?
"'".$this->db->escape($this->note_private).
"'" :
"null");
784 $sql .=
", note_public = ".($this->note_public ?
"'".$this->db->escape($this->note_public).
"'" :
"null");
785 $sql .=
", photo = ".($this->photo ?
"'".$this->db->escape($this->photo).
"'" :
"null");
786 $sql .=
", public = '".$this->db->escape($this->
public).
"'";
787 $sql .=
", statut = ".$this->db->escape($this->statut);
788 $sql .=
", default_lang = ".(!empty($this->default_lang) ?
"'".$this->db->escape($this->default_lang).
"'" :
"null");
789 $sql .=
", fk_adherent_type = ".$this->db->escape($this->
typeid);
790 $sql .=
", morphy = '".$this->db->escape($this->morphy).
"'";
791 $sql .=
", birth = ".($this->birth ?
"'".$this->db->idate($this->birth).
"'" :
"null");
793 if ($this->datefin) {
794 $sql .=
", datefin = '".$this->db->idate($this->datefin).
"'";
796 if ($this->datevalid) {
797 $sql .=
", datevalid = '".$this->db->idate($this->datevalid).
"'";
799 $sql .=
", fk_user_mod = ".($user->id > 0 ? $user->id :
'null');
800 $sql .=
" WHERE rowid = ".((int) $this->
id);
803 if (!empty($this->oldcopy) && $this->
typeid != $this->oldcopy->typeid) {
804 $sql2 =
"SELECT libelle as label";
805 $sql2 .=
" FROM ".MAIN_DB_PREFIX.
"adherent_type";
806 $sql2 .=
" WHERE rowid = ".((int) $this->
typeid);
807 $resql2 = $this->
db->query($sql2);
809 while ($obj = $this->
db->fetch_object($resql2)) {
810 $this->
type = $obj->label;
815 dol_syslog(get_class($this).
"::update update member", LOG_DEBUG);
818 unset($this->country_code);
819 unset($this->country);
820 unset($this->state_code);
823 $nbrowsaffected += $this->
db->affected_rows(
$resql);
836 if (!$error && $this->pass) {
837 dol_syslog(get_class($this).
"::update update password");
838 if ($this->pass != $this->pass_indatabase && $this->pass != $this->pass_indatabase_crypted) {
839 $isencrypted = empty($conf->global->DATABASE_PWD_ENCRYPTED) ? 0 : 1;
842 $result = $this->
setPassword($user, $this->pass, $isencrypted, $notrigger, $nosyncuserpass);
843 if (!$nbrowsaffected) {
851 dol_syslog(get_class($this).
"::update update link to user");
852 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = NULL WHERE fk_member = ".((int) $this->
id);
853 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
856 $this->error = $this->
db->error();
857 $this->
db->rollback();
861 if ($this->user_id > 0) {
862 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = ".((int) $this->
id).
" WHERE rowid = ".((int) $this->user_id);
863 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
866 $this->error = $this->
db->error();
867 $this->
db->rollback();
873 if (!$error && $nbrowsaffected) {
875 if (!$error && $this->user_id > 0 && !$nosyncuser) {
876 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
878 dol_syslog(get_class($this).
"::update update linked user");
880 $luser =
new User($this->
db);
881 $result = $luser->fetch($this->user_id);
888 if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
889 $luser->login = $this->login;
892 $luser->ref = $this->ref;
893 $luser->civility_id = $this->civility_id;
894 $luser->firstname = $this->firstname;
895 $luser->lastname = $this->lastname;
896 $luser->gender = $this->gender;
897 $luser->pass = $this->pass;
900 $luser->birth = $this->birth;
902 $luser->address = $this->address;
903 $luser->zip = $this->zip;
904 $luser->town = $this->town;
905 $luser->country_id = $this->country_id;
906 $luser->state_id = $this->state_id;
908 $luser->email = $this->email;
909 $luser->socialnetworks = $this->socialnetworks;
910 $luser->office_phone = $this->phone;
911 $luser->user_mobile = $this->phone_mobile;
913 $luser->lang = $this->default_lang;
915 $luser->fk_member = $this->id;
917 $result = $luser->update($user, 0, 1, 1);
919 $this->error = $luser->error;
920 dol_syslog(get_class($this).
"::update ".$this->error, LOG_ERR);
924 $this->error = $luser->error;
930 if (!$error && $this->fk_soc > 0 && !$nosyncthirdparty) {
931 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
933 dol_syslog(get_class($this).
"::update update linked thirdparty");
938 $result = $lthirdparty->fetch($this->fk_soc);
941 $lthirdparty->address = $this->address;
942 $lthirdparty->zip = $this->zip;
943 $lthirdparty->town = $this->town;
944 $lthirdparty->email = $this->email;
945 $lthirdparty->socialnetworks = $this->socialnetworks;
946 $lthirdparty->phone = $this->phone;
947 $lthirdparty->state_id = $this->state_id;
948 $lthirdparty->country_id = $this->country_id;
950 $lthirdparty->default_lang = $this->default_lang;
952 $result = $lthirdparty->update($this->fk_soc, $user, 0, 1, 1,
'update');
955 $this->error = $lthirdparty->error;
956 $this->errors = $lthirdparty->errors;
957 dol_syslog(get_class($this).
"::update ".$this->error, LOG_ERR);
960 } elseif ($result < 0) {
961 $this->error = $lthirdparty->error;
967 if (!$error && !$notrigger) {
978 return $nbrowsaffected;
980 $this->
db->rollback();
984 $this->
db->rollback();
985 $this->error = $this->
db->lasterror();
1005 $sql =
"SELECT rowid, datec as dateop, dateadh as datedeb, datef as datefin";
1006 $sql .=
" FROM ".MAIN_DB_PREFIX.
"subscription";
1007 $sql .=
" WHERE fk_adherent = ".((int) $this->
id);
1008 $sql .=
" ORDER by dateadh DESC";
1010 dol_syslog(get_class($this).
"::update_end_date", LOG_DEBUG);
1013 $obj = $this->
db->fetch_object(
$resql);
1014 $dateop = $this->
db->jdate($obj->dateop);
1015 $datedeb = $this->
db->jdate($obj->datedeb);
1016 $datefin = $this->
db->jdate($obj->datefin);
1018 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
1019 $sql .=
" datefin=".($datefin !=
'' ?
"'".$this->db->idate($datefin).
"'" :
"null");
1020 $sql .=
" WHERE rowid = ".((int) $this->
id);
1022 dol_syslog(get_class($this).
"::update_end_date", LOG_DEBUG);
1025 $this->last_subscription_date = $dateop;
1026 $this->last_subscription_date_start = $datedeb;
1027 $this->last_subscription_date_end = $datefin;
1028 $this->datefin = $datefin;
1029 $this->
db->commit();
1032 $this->
db->rollback();
1036 $this->error = $this->
db->lasterror();
1037 $this->
db->rollback();
1050 public function delete($rowid, $user, $notrigger = 0)
1052 global $conf, $langs;
1059 if (empty($rowid)) {
1065 if (!$error && !$notrigger) {
1075 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"categorie_member WHERE fk_member = ".((int) $rowid);
1076 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1080 $this->error .= $this->
db->lasterror();
1086 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"subscription WHERE fk_adherent = ".((int) $rowid);
1087 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1091 $this->error .= $this->
db->lasterror();
1101 $this->error .= $this->
db->lasterror();
1112 dol_syslog(get_class($this).
"::delete erreur ".$errorflag.
" ".$this->error, LOG_ERR);
1118 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"adherent WHERE rowid = ".((int) $rowid);
1119 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1123 $this->error .= $this->
db->lasterror();
1129 $this->
db->commit();
1132 $this->
db->rollback();
1148 public function setPassword($user, $password =
'', $isencrypted = 0, $notrigger = 0, $nosyncuser = 0)
1150 global $conf, $langs;
1154 dol_syslog(get_class($this).
"::setPassword user=".$user->id.
" password=".preg_replace(
'/./i',
'*', $password).
" isencrypted=".$isencrypted);
1158 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
1163 $password_crypted =
dol_hash($password);
1165 $password_indatabase =
'';
1166 if (!$isencrypted) {
1167 $password_indatabase = $password;
1173 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent";
1174 $sql .=
" SET pass_crypted = '".$this->db->escape($password_crypted).
"'";
1177 $sql .=
", pass = null";
1179 $sql .=
", pass = '".$this->db->escape($password_indatabase).
"'";
1181 $sql .=
" WHERE rowid = ".((int) $this->
id);
1184 dol_syslog(get_class($this).
"::setPassword", LOG_DEBUG);
1185 $result = $this->
db->query($sql);
1187 $nbaffectedrows = $this->
db->affected_rows($result);
1189 if ($nbaffectedrows) {
1190 $this->pass = $password;
1191 $this->pass_indatabase = $password_indatabase;
1192 $this->pass_indatabase_crypted = $password_crypted;
1194 if ($this->user_id && !$nosyncuser) {
1195 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
1199 $luser =
new User($this->
db);
1200 $result = $luser->fetch($this->user_id);
1203 $result = $luser->setPassword($user, $this->pass, 0, 0, 1);
1205 $this->error = $luser->error;
1206 dol_syslog(get_class($this).
"::setPassword ".$this->error, LOG_ERR);
1210 $this->error = $luser->error;
1215 if (!$error && !$notrigger) {
1217 $result = $this->
call_trigger(
'MEMBER_NEW_PASSWORD', $user);
1220 $this->
db->rollback();
1226 $this->
db->commit();
1229 $this->
db->rollback();
1233 $this->
db->rollback();
1248 global $conf, $langs;
1253 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = NULL WHERE fk_member = ".((int) $this->
id);
1254 dol_syslog(get_class($this).
"::setUserId", LOG_DEBUG);
1257 $this->error = $this->
db->error();
1258 $this->
db->rollback();
1264 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = ".((int) $this->
id);
1265 $sql .=
" WHERE rowid = ".((int) $userid);
1266 dol_syslog(get_class($this).
"::setUserId", LOG_DEBUG);
1269 $this->error = $this->
db->error();
1270 $this->
db->rollback();
1275 $this->
db->commit();
1289 global $conf, $langs;
1294 if ($thirdpartyid > 0) {
1295 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET fk_soc = null";
1296 $sql .=
" WHERE fk_soc = ".((int) $thirdpartyid);
1297 $sql .=
" AND entity = ".$conf->entity;
1298 dol_syslog(get_class($this).
"::setThirdPartyId", LOG_DEBUG);
1303 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET fk_soc = ".($thirdpartyid > 0 ? $thirdpartyid :
'null');
1304 $sql .=
" WHERE rowid = ".((int) $this->
id);
1306 dol_syslog(get_class($this).
"::setThirdPartyId", LOG_DEBUG);
1309 $this->
db->commit();
1312 $this->error = $this->
db->error();
1313 $this->
db->rollback();
1331 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"adherent";
1332 $sql .=
" WHERE login='".$this->db->escape($login).
"'";
1333 $sql .=
" AND entity = ".$conf->entity;
1338 $obj = $this->
db->fetch_object(
$resql);
1339 $this->
fetch($obj->rowid);
1359 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"adherent";
1360 $sql .=
" WHERE firstname='".$this->db->escape($firstname).
"'";
1361 $sql .=
" AND lastname='".$this->db->escape($lastname).
"'";
1362 $sql .=
" AND entity = ".$conf->entity;
1367 $obj = $this->
db->fetch_object(
$resql);
1368 $this->
fetch($obj->rowid);
1386 public function fetch($rowid, $ref =
'', $fk_soc =
'', $ref_ext =
'', $fetch_optionals =
true, $fetch_subscriptions =
true)
1390 $sql =
"SELECT d.rowid, d.ref, d.ref_ext, d.civility as civility_code, d.gender, d.firstname, d.lastname,";
1391 $sql .=
" d.societe as company, d.fk_soc, d.statut, d.public, d.address, d.zip, d.town, d.note_private,";
1392 $sql .=
" d.note_public,";
1393 $sql .=
" d.email, d.url, d.socialnetworks, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass, d.pass_crypted,";
1394 $sql .=
" d.photo, d.fk_adherent_type, d.morphy, d.entity,";
1395 $sql .=
" d.datec as datec,";
1396 $sql .=
" d.tms as datem,";
1397 $sql .=
" d.datefin as datefin, d.default_lang,";
1398 $sql .=
" d.birth as birthday,";
1399 $sql .=
" d.datevalid as datev,";
1400 $sql .=
" d.country,";
1401 $sql .=
" d.state_id,";
1402 $sql .=
" d.model_pdf,";
1403 $sql .=
" c.rowid as country_id, c.code as country_code, c.label as country,";
1404 $sql .=
" dep.nom as state, dep.code_departement as state_code,";
1405 $sql .=
" t.libelle as type, t.subscription as subscription,";
1406 $sql .=
" u.rowid as user_id, u.login as user_login";
1407 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent_type as t, ".MAIN_DB_PREFIX.
"adherent as d";
1408 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as c ON d.country = c.rowid";
1409 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as dep ON d.state_id = dep.rowid";
1410 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON d.rowid = u.fk_member";
1411 $sql .=
" WHERE d.fk_adherent_type = t.rowid";
1413 $sql .=
" AND d.rowid=".((int) $rowid);
1414 } elseif ($ref || $fk_soc) {
1415 $sql .=
" AND d.entity IN (".getEntity(
'adherent').
")";
1417 $sql .=
" AND d.ref='".$this->db->escape($ref).
"'";
1418 } elseif ($fk_soc > 0) {
1419 $sql .=
" AND d.fk_soc=".((int) $fk_soc);
1421 } elseif ($ref_ext) {
1422 $sql .=
" AND d.ref_ext='".$this->db->escape($ref_ext).
"'";
1425 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
1429 $obj = $this->
db->fetch_object(
$resql);
1431 $this->entity = $obj->entity;
1432 $this->
id = $obj->rowid;
1433 $this->
ref = $obj->ref;
1434 $this->ref_ext = $obj->ref_ext;
1436 $this->civility_id = $obj->civility_code;
1437 $this->civility_code = $obj->civility_code;
1438 $this->civility = $obj->civility_code ? ($langs->trans(
"Civility".$obj->civility_code) != (
"Civility".$obj->civility_code) ? $langs->trans(
"Civility".$obj->civility_code) : $obj->civility_code) :
'';
1440 $this->firstname = $obj->firstname;
1441 $this->lastname = $obj->lastname;
1442 $this->gender = $obj->gender;
1443 $this->login = $obj->login;
1444 $this->societe = $obj->company;
1445 $this->company = $obj->company;
1446 $this->socid = $obj->fk_soc;
1447 $this->fk_soc = $obj->fk_soc;
1448 $this->address = $obj->address;
1449 $this->zip = $obj->zip;
1450 $this->town = $obj->town;
1452 $this->pass = $obj->pass;
1453 $this->pass_indatabase = $obj->pass;
1454 $this->pass_indatabase_crypted = $obj->pass_crypted;
1456 $this->state_id = $obj->state_id;
1457 $this->state_code = $obj->state_id ? $obj->state_code :
'';
1458 $this->state = $obj->state_id ? $obj->state :
'';
1460 $this->country_id = $obj->country_id;
1461 $this->country_code = $obj->country_code;
1462 if ($langs->trans(
"Country".$obj->country_code) !=
"Country".$obj->country_code) {
1463 $this->country = $langs->transnoentitiesnoconv(
"Country".$obj->country_code);
1465 $this->country = $obj->country;
1468 $this->phone = $obj->phone;
1469 $this->phone_perso = $obj->phone_perso;
1470 $this->phone_mobile = $obj->phone_mobile;
1471 $this->email = $obj->email;
1472 $this->url = $obj->url;
1474 $this->socialnetworks = ($obj->socialnetworks ? (array) json_decode($obj->socialnetworks,
true) : array());
1476 $this->photo = $obj->photo;
1477 $this->statut = $obj->statut;
1478 $this->status = $obj->statut;
1479 $this->
public = $obj->public;
1481 $this->datec = $this->
db->jdate($obj->datec);
1482 $this->date_creation = $this->
db->jdate($obj->datec);
1483 $this->datem = $this->
db->jdate($obj->datem);
1484 $this->date_modification = $this->
db->jdate($obj->datem);
1485 $this->datefin = $this->
db->jdate($obj->datefin);
1486 $this->datevalid = $this->
db->jdate($obj->datev);
1487 $this->date_validation = $this->
db->jdate($obj->datev);
1488 $this->birth = $this->
db->jdate($obj->birthday);
1490 $this->default_lang = $obj->default_lang;
1492 $this->note_private = $obj->note_private;
1493 $this->note_public = $obj->note_public;
1494 $this->morphy = $obj->morphy;
1496 $this->
typeid = $obj->fk_adherent_type;
1497 $this->
type = $obj->type;
1498 $this->need_subscription = $obj->subscription;
1500 $this->user_id = $obj->user_id;
1501 $this->user_login = $obj->user_login;
1503 $this->model_pdf = $obj->model_pdf;
1507 if ($fetch_optionals) {
1512 if ($fetch_subscriptions) {
1521 $this->error = $this->
db->lasterror();
1541 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
1543 $sql =
"SELECT c.rowid, c.fk_adherent, c.fk_type, c.subscription, c.note as note_public, c.fk_bank,";
1544 $sql .=
" c.tms as datem,";
1545 $sql .=
" c.datec as datec,";
1546 $sql .=
" c.dateadh as dateh,";
1547 $sql .=
" c.datef as datef";
1548 $sql .=
" FROM ".MAIN_DB_PREFIX.
"subscription as c";
1549 $sql .=
" WHERE c.fk_adherent = ".((int) $this->
id);
1550 $sql .=
" ORDER BY c.dateadh";
1551 dol_syslog(get_class($this).
"::fetch_subscriptions", LOG_DEBUG);
1555 $this->subscriptions = array();
1558 while ($obj = $this->
db->fetch_object(
$resql)) {
1560 $this->first_subscription_date = $this->
db->jdate($obj->datec);
1561 $this->first_subscription_date_start = $this->
db->jdate($obj->dateh);
1562 $this->first_subscription_date_end = $this->
db->jdate($obj->datef);
1563 $this->first_subscription_amount = $obj->subscription;
1565 $this->last_subscription_date = $this->
db->jdate($obj->datec);
1566 $this->last_subscription_date_start = $this->
db->jdate($obj->dateh);
1567 $this->last_subscription_date_end = $this->
db->jdate($obj->datef);
1568 $this->last_subscription_amount = $obj->subscription;
1571 $subscription->id = $obj->rowid;
1572 $subscription->fk_adherent = $obj->fk_adherent;
1573 $subscription->fk_type = $obj->fk_type;
1574 $subscription->amount = $obj->subscription;
1575 $subscription->note = $obj->note_public;
1576 $subscription->note_public = $obj->note_public;
1577 $subscription->fk_bank = $obj->fk_bank;
1578 $subscription->datem = $this->
db->jdate($obj->datem);
1579 $subscription->datec = $this->
db->jdate($obj->datec);
1580 $subscription->dateh = $this->
db->jdate($obj->dateh);
1581 $subscription->datef = $this->
db->jdate($obj->datef);
1583 $this->subscriptions[] = $subscription;
1589 $this->error = $this->
db->error().
' sql='.$sql;
1605 require_once DOL_DOCUMENT_ROOT.
'/partnership/class/partnership.class.php';
1608 $this->partnerships[] = array();
1629 public function subscription($date, $amount, $accountid = 0, $operation =
'', $label =
'', $num_chq =
'', $emetteur_nom =
'', $emetteur_banque =
'', $datesubend = 0, $fk_type =
null)
1631 global $conf, $langs, $user;
1633 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
1645 $datefin = $datesubend;
1654 $subscription->fk_adherent = $this->id;
1655 $subscription->dateh = $date;
1656 $subscription->datef = $datefin;
1657 $subscription->amount = $amount;
1658 $subscription->note = $label;
1659 $subscription->note_public = $label;
1660 $subscription->fk_type = $fk_type;
1662 $rowid = $subscription->create($user);
1669 $this->last_subscription_date =
dol_now();
1670 $this->last_subscription_date_start = $date;
1671 $this->last_subscription_date_end = $datefin;
1672 $this->last_subscription_amount = $amount;
1676 $this->
db->commit();
1679 $this->
db->rollback();
1683 $this->error = $subscription->error;
1684 $this->errors = $subscription->errors;
1685 $this->
db->rollback();
1710 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 =
'')
1712 global $conf, $langs, $user, $mysoc;
1716 $this->invoice =
null;
1718 dol_syslog(
"subscriptionComplementaryActions subscriptionid=".$subscriptionid.
" option=".$option.
" accountid=".$accountid.
" datesubscription=".$datesubscription.
" paymentdate=".
1719 $paymentdate.
" label=".$label.
" amount=".$amount.
" num_chq=".$num_chq.
" autocreatethirdparty=".$autocreatethirdparty);
1722 if ($option ==
'bankdirect' && $accountid) {
1723 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
1726 $result = $acct->fetch($accountid);
1728 $dateop = $paymentdate;
1730 $insertid = $acct->addline($dateop, $operation, $label, $amount, $num_chq,
'', $user, $emetteur_nom, $emetteur_banque);
1731 if ($insertid > 0) {
1732 $inserturlid = $acct->add_url_line($insertid, $this->
id, DOL_URL_ROOT.
'/adherents/card.php?rowid=', $this->getFullname($langs),
'member');
1733 if ($inserturlid > 0) {
1735 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"subscription SET fk_bank=".((int) $insertid);
1736 $sql .=
" WHERE rowid=".((int) $subscriptionid);
1738 dol_syslog(
"subscription::subscription", LOG_DEBUG);
1742 $this->error = $this->
db->lasterror();
1743 $this->errors[] = $this->error;
1747 $this->error = $acct->error;
1748 $this->errors = $acct->errors;
1752 $this->error = $acct->error;
1753 $this->errors = $acct->errors;
1758 if (($option ==
'bankviainvoice' && $accountid) || $option ==
'invoiceonly') {
1759 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1760 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/paymentterm.class.php';
1766 if (!($this->fk_soc > 0)) {
1767 if ($autocreatethirdparty) {
1772 if ($this->morphy ==
'mor') {
1773 $companyname = $this->company;
1774 if (!empty($fullname)) {
1775 $companyalias = $fullname;
1778 $companyname = $fullname;
1779 if (!empty($this->company)) {
1780 $companyalias = $this->company;
1784 $result = $customer->create_from_member($this, $companyname, $companyalias);
1786 $this->error = $customer->error;
1787 $this->errors = $customer->errors;
1790 $this->fk_soc = $result;
1793 $langs->load(
"errors");
1794 $this->error = $langs->trans(
"ErrorMemberNotLinkedToAThirpartyLinkOrCreateFirst");
1795 $this->errors[] = $this->error;
1801 $result = $customer->fetch($this->fk_soc);
1803 $this->error = $customer->error;
1804 $this->errors = $customer->errors;
1812 $invoice->cond_reglement_id = $customer->cond_reglement_id;
1813 if (empty($invoice->cond_reglement_id)) {
1815 $invoice->cond_reglement_id = $paymenttermstatic->getDefaultId();
1816 if (empty($invoice->cond_reglement_id)) {
1818 $this->error =
'ErrorNoPaymentTermRECEPFound';
1819 $this->errors[] = $this->error;
1822 $invoice->socid = $this->fk_soc;
1827 $invoice->linked_objects[
'subscription'] = $subscriptionid;
1828 if (!empty($_POST[
'other_linked_objects']) && is_array($_POST[
'other_linked_objects'])) {
1829 $invoice->linked_objects = array_merge($invoice->linked_objects, $_POST[
'other_linked_objects']);
1832 $result = $invoice->create($user);
1834 $this->error = $invoice->error;
1835 $this->errors = $invoice->errors;
1838 $this->invoice = $invoice;
1844 $idprodsubscription = 0;
1845 if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (
isModEnabled(
"product") ||
isModEnabled(
"service"))) {
1846 $idprodsubscription = $conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS;
1850 if (isset($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) && $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS ==
'defaultforfoundationcountry') {
1854 $result = $invoice->addline($label, 0, 1, $vattouse, 0, 0, $idprodsubscription, 0, $datesubscription,
'', 0, 0,
'',
'TTC', $amount, 1);
1856 $this->error = $invoice->error;
1857 $this->errors = $invoice->errors;
1864 $result = $invoice->validate($user);
1866 $this->error = $invoice->error;
1867 $this->errors = $invoice->errors;
1877 if (!$error && $option ==
'bankviainvoice' && $accountid) {
1878 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1879 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
1880 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions.lib.php';
1883 $amounts[$invoice->id] =
price2num($amount);
1886 $paiement->datepaye = $paymentdate;
1887 $paiement->amounts = $amounts;
1888 $paiement->paiementcode = $operation;
1889 $paiement->paiementid =
dol_getIdFromCode($this->
db, $operation,
'c_paiement',
'code',
'id', 1);
1890 $paiement->num_payment = $num_chq;
1891 $paiement->note_public = $label;
1892 $paiement->ext_payment_id = $ext_payment_id;
1893 $paiement->ext_payment_site = $ext_payment_site;
1897 $paiement_id = $paiement->create($user);
1898 if (!($paiement_id > 0)) {
1899 $this->error = $paiement->error;
1900 $this->errors = $paiement->errors;
1907 $bank_line_id = $paiement->addPaymentToBank($user,
'payment',
'(SubscriptionPayment)', $accountid, $emetteur_nom, $emetteur_banque);
1908 if (!($bank_line_id > 0)) {
1909 $this->error = $paiement->error;
1910 $this->errors = $paiement->errors;
1915 if (!$error && !empty($bank_line_id)) {
1917 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'subscription SET fk_bank='.((int) $bank_line_id);
1918 $sql .=
' WHERE rowid='.((int) $subscriptionid);
1920 $result = $this->
db->query($sql);
1928 $invoice->setPaid($user);
1934 $outputlangs = $langs;
1936 $lang_id =
GETPOST(
'lang_id');
1937 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && !empty($lang_id)) {
1938 $newlang = $lang_id;
1941 $newlang = $customer->default_lang;
1943 if (!empty($newlang)) {
1944 $outputlangs =
new Translate(
"", $conf);
1945 $outputlangs->setDefaultLang($newlang);
1950 $invoice->generateDocument($invoice->model_pdf, $outputlangs);
1970 global $langs, $conf;
1976 if ($this->statut == self::STATUS_VALIDATED) {
1977 dol_syslog(get_class($this).
"::validate statut of member does not allow this", LOG_WARNING);
1983 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
1984 $sql .=
" statut = ".self::STATUS_VALIDATED;
1985 $sql .=
", datevalid = '".$this->db->idate($now).
"'";
1986 $sql .=
", fk_user_valid = ".((int) $user->id);
1987 $sql .=
" WHERE rowid = ".((int) $this->
id);
1989 dol_syslog(get_class($this).
"::validate", LOG_DEBUG);
1990 $result = $this->
db->query($sql);
1995 $result = $this->
call_trigger(
'MEMBER_VALIDATE', $user);
1998 $this->
db->rollback();
2003 $this->datevalid = $now;
2005 $this->
db->commit();
2008 $this->error = $this->
db->error();
2009 $this->
db->rollback();
2023 global $langs, $conf;
2028 if ($this->statut == self::STATUS_RESILIATED) {
2029 dol_syslog(get_class($this).
"::resiliate statut of member does not allow this", LOG_WARNING);
2035 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
2036 $sql .=
" statut = ".self::STATUS_RESILIATED;
2037 $sql .=
", fk_user_valid=".$user->id;
2038 $sql .=
" WHERE rowid = ".((int) $this->
id);
2040 $result = $this->
db->query($sql);
2045 $result = $this->
call_trigger(
'MEMBER_RESILIATE', $user);
2048 $this->
db->rollback();
2053 $this->
db->commit();
2056 $this->error = $this->
db->error();
2057 $this->
db->rollback();
2073 global $langs, $conf;
2078 if ($this->statut == self::STATUS_EXCLUDED) {
2079 dol_syslog(get_class($this).
"::resiliate statut of member does not allow this", LOG_WARNING);
2085 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
2086 $sql .=
" statut = ".self::STATUS_EXCLUDED;
2087 $sql .=
", fk_user_valid=".$user->id;
2088 $sql .=
" WHERE rowid = ".((int) $this->
id);
2090 $result = $this->
db->query($sql);
2095 $result = $this->
call_trigger(
'MEMBER_EXCLUDE', $user);
2098 $this->
db->rollback();
2103 $this->
db->commit();
2106 $this->error = $this->
db->error();
2107 $this->
db->rollback();
2121 global $conf, $langs;
2123 include_once DOL_DOCUMENT_ROOT.
'/mailmanspip/class/mailmanspip.class.php';
2129 if (!empty($conf->global->ADHERENT_USE_MAILMAN) &&
isModEnabled(
'mailmanspip')) {
2130 $result = $mailmanspip->add_to_mailman($this);
2133 if (!empty($mailmanspip->error)) {
2134 $this->errors[] = $mailmanspip->error;
2138 foreach ($mailmanspip->mladded_ko as $tmplist => $tmpemail) {
2139 $langs->load(
"errors");
2140 $this->errors[] = $langs->trans(
"ErrorFailedToAddToMailmanList", $tmpemail, $tmplist);
2142 foreach ($mailmanspip->mladded_ok as $tmplist => $tmpemail) {
2143 $langs->load(
"mailmanspip");
2144 $this->mesgs[] = $langs->trans(
"SuccessToAddToMailmanList", $tmpemail, $tmplist);
2149 if (!empty($conf->global->ADHERENT_USE_SPIP) &&
isModEnabled(
'mailmanspip')) {
2150 $result = $mailmanspip->add_to_spip($this);
2152 $this->errors[] = $mailmanspip->error;
2173 global $conf, $langs;
2175 include_once DOL_DOCUMENT_ROOT.
'/mailmanspip/class/mailmanspip.class.php';
2181 if (!empty($conf->global->ADHERENT_USE_MAILMAN)) {
2182 $result = $mailmanspip->del_to_mailman($this);
2184 if (!empty($mailmanspip->error)) {
2185 $this->errors[] = $mailmanspip->error;
2190 foreach ($mailmanspip->mlremoved_ko as $tmplist => $tmpemail) {
2191 $langs->load(
"errors");
2192 $this->errors[] = $langs->trans(
"ErrorFailedToRemoveToMailmanList", $tmpemail, $tmplist);
2194 foreach ($mailmanspip->mlremoved_ok as $tmplist => $tmpemail) {
2195 $langs->load(
"mailmanspip");
2196 $this->mesgs[] = $langs->trans(
"SuccessToRemoveToMailmanList", $tmpemail, $tmplist);
2200 if ($conf->global->ADHERENT_USE_SPIP &&
isModEnabled(
'mailmanspip')) {
2201 $result = $mailmanspip->del_to_spip($this);
2203 $this->errors[] = $mailmanspip->error;
2224 $langs->load(
"dict");
2226 $code = (empty($this->civility_id) ?
'' : $this->civility_id);
2230 return $langs->getLabelFromKey($this->
db,
"Civility".$code,
"c_civility",
"code",
"label", $code);
2246 public function getNomUrl($withpictoimg = 0, $maxlen = 0, $option =
'card', $mode =
'', $morecss =
'', $save_lastsearch_value = -1, $notooltip = 0, $addlinktonotes = 0)
2248 global $conf, $langs, $hookmanager;
2250 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpictoimg) {
2259 if (!empty($this->photo)) {
2260 $label .=
'<div class="photointooltip floatright">';
2261 $label .=
Form::showphoto(
'memberphoto', $this, 80, 0, 0,
'photoref photowithmargin photologintooltip',
'small', 0, 1);
2266 $label .=
'<div class="centpercent">';
2267 $label .=
img_picto(
'', $this->picto).
' <u class="paddingrightonly">'.$langs->trans(
"Member").
'</u>';
2268 $label .=
' '.$this->getLibStatut(4);
2269 if (!empty($this->
ref)) {
2270 $label .=
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
2272 if (!empty($this->login)) {
2273 $label .=
'<br><b>'.$langs->trans(
'Login').
':</b> '.$this->login;
2275 if (!empty($this->firstname) || !empty($this->lastname)) {
2276 $label .=
'<br><b>'.$langs->trans(
'Name').
':</b> '.$this->
getFullName($langs);
2278 if (!empty($this->company)) {
2279 $label .=
'<br><b>'.$langs->trans(
'Company').
':</b> '.$this->company;
2283 $url = DOL_URL_ROOT.
'/adherents/card.php?rowid='.((int) $this->
id);
2284 if ($option ==
'subscription') {
2285 $url = DOL_URL_ROOT.
'/adherents/subscription.php?rowid='.((int) $this->
id);
2288 if ($option !=
'nolink') {
2290 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
2291 if ($save_lastsearch_value == -1 && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
2292 $add_save_lastsearch_values = 1;
2294 if ($add_save_lastsearch_values) {
2295 $url .=
'&save_lastsearch_values=1';
2299 $linkstart .=
'<a href="'.$url.
'"';
2301 if (empty($notooltip)) {
2302 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
2303 $langs->load(
"users");
2304 $label = $langs->trans(
"ShowUser");
2305 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
2307 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
2308 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
2311 $linkstart .= $linkclose.
'>';
2314 $result .= $linkstart;
2315 if ($withpictoimg) {
2316 $result .=
'<div class="inline-block nopadding valignmiddle">';
2318 if ($withpictoimg) {
2319 $paddafterimage =
'';
2320 if (abs($withpictoimg) == 1) {
2321 $paddafterimage =
'style="margin-right: 3px;"';
2324 if ($withpictoimg > 0) {
2325 $picto =
'<span class="nopadding'.($morecss ?
' userimg'.$morecss :
'').
'">'.
2326 img_object(
'',
'user', $paddafterimage.
' '.($notooltip ?
'' :
'class="classfortooltip"'), 0, 0, $notooltip ? 0 : 1).
'</span>';
2329 $picto =
'<span class="nopadding'.($morecss ?
' userimg'.$morecss :
'').
'"'.($paddafterimage ?
' '.$paddafterimage :
'').
'>';
2330 $picto .=
Form::showphoto(
'memberphoto', $this, 0, 0, 0,
'userphoto'.($withpictoimg == -3 ?
'small' :
''),
'mini', 0, 1);
2331 $picto .=
'</span>';
2335 if ($withpictoimg > -2 && $withpictoimg != 2) {
2336 if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
2337 $result .=
'<span class="nopadding valignmiddle'.((!isset($this->statut) || $this->statut) ?
'' :
' strikefordisabled').
2338 ($morecss ?
' usertext'.$morecss :
'').
'">';
2340 if ($mode ==
'login') {
2341 $result .=
dol_trunc($this->login, $maxlen);
2342 } elseif ($mode ==
'ref') {
2343 $result .= $this->ref;
2345 $result .= $this->
getFullName($langs,
'', ($mode ==
'firstname' ? 2 : ($mode ==
'lastname' ? 4 : -1)), $maxlen);
2347 if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
2348 $result .=
'</span>';
2351 if ($withpictoimg) {
2352 $result .=
'</div>';
2354 $result .= $linkend;
2356 if ($addlinktonotes) {
2357 if ($this->note_private) {
2358 $notetoshow = $langs->trans(
"ViewPrivateNote").
':<br>'.
dol_string_nohtmltag($this->note_private, 1);
2359 $result .=
' <span class="note inline-block">';
2360 $result .=
'<a href="'.DOL_URL_ROOT.
'/adherents/note.php?id='.$this->
id.
'" class="classfortooltip" title="'.
dol_escape_htmltag($notetoshow).
'">';
2363 $result .=
'</span>';
2367 $hookmanager->initHooks(array($this->element .
'dao'));
2368 $parameters = array(
'id'=>$this->
id,
'getnomurl' => &$result);
2369 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
2371 $result = $hookmanager->resPrint;
2373 $result .= $hookmanager->resPrint;
2386 return $this->
LibStatut($this->statut, $this->need_subscription, $this->datefin, $mode);
2399 public function LibStatut($status, $need_subscription, $date_end_subscription, $mode = 0)
2403 $langs->load(
"members");
2407 $labelStatusShort =
'';
2409 if ($status == self::STATUS_DRAFT) {
2410 $statusType =
'status0';
2411 $labelStatus = $langs->trans(
"MemberStatusDraft");
2412 $labelStatusShort = $langs->trans(
"MemberStatusDraftShort");
2413 } elseif ($status >= self::STATUS_VALIDATED) {
2414 if ($need_subscription === 0) {
2415 $statusType =
'status4';
2416 $labelStatus = $langs->trans(
"MemberStatusNoSubscription");
2417 $labelStatusShort = $langs->trans(
"MemberStatusNoSubscriptionShort");
2418 } elseif (!$date_end_subscription) {
2419 $statusType =
'status1';
2420 $labelStatus = $langs->trans(
"MemberStatusActive");
2421 $labelStatusShort = $langs->trans(
"MemberStatusActiveShort");
2422 } elseif ($date_end_subscription <
dol_now()) {
2423 $statusType =
'status8';
2424 $labelStatus = $langs->trans(
"MemberStatusActiveLate");
2425 $labelStatusShort = $langs->trans(
"MemberStatusActiveLateShort");
2427 $statusType =
'status4';
2428 $labelStatus = $langs->trans(
"MemberStatusPaid");
2429 $labelStatusShort = $langs->trans(
"MemberStatusPaidShort");
2431 } elseif ($status == self::STATUS_RESILIATED) {
2432 $statusType =
'status6';
2433 $labelStatus = $langs->transnoentitiesnoconv(
"MemberStatusResiliated");
2434 $labelStatusShort = $langs->transnoentitiesnoconv(
"MemberStatusResiliatedShort");
2435 } elseif ($status == self::STATUS_EXCLUDED) {
2436 $statusType =
'status10';
2437 $labelStatus = $langs->transnoentitiesnoconv(
"MemberStatusExcluded");
2438 $labelStatusShort = $langs->transnoentitiesnoconv(
"MemberStatusExcludedShort");
2441 return dolGetStatus($labelStatus, $labelStatusShort,
'', $statusType, $mode);
2456 $this->nb = array();
2458 $sql =
"SELECT count(a.rowid) as nb";
2459 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as a";
2460 $sql .=
" WHERE a.statut > 0";
2461 $sql .=
" AND a.entity IN (".getEntity(
'adherent').
")";
2465 while ($obj = $this->
db->fetch_object(
$resql)) {
2466 $this->nb[
"members"] = $obj->nb;
2472 $this->error = $this->
db->error();
2488 global $conf, $langs;
2496 $sql =
"SELECT a.rowid, a.datefin, a.statut";
2497 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as a";
2498 $sql .=
", ".MAIN_DB_PREFIX.
"adherent_type as t";
2499 $sql .=
" WHERE a.fk_adherent_type = t.rowid";
2500 if ($mode ==
'expired') {
2501 $sql .=
" AND a.statut = ".self::STATUS_VALIDATED;
2502 $sql .=
" AND a.entity IN (".getEntity(
'adherent').
")";
2503 $sql .=
" AND ((a.datefin IS NULL or a.datefin < '".$this->db->idate($now).
"') AND t.subscription = '1')";
2504 } elseif ($mode ==
'shift') {
2505 $sql .=
" AND a.statut = ".self::STATUS_DRAFT;
2506 $sql .=
" AND a.entity IN (".getEntity(
'adherent').
")";
2511 $langs->load(
"members");
2518 if ($mode ==
'expired') {
2519 $warning_delay = $conf->adherent->subscription->warning_delay / 60 / 60 / 24;
2520 $label = $langs->trans(
"MembersWithSubscriptionToReceive");
2521 $labelShort = $langs->trans(
"MembersWithSubscriptionToReceiveShort");
2522 $url = DOL_URL_ROOT.
'/adherents/list.php?mainmenu=members&statut='.self::STATUS_VALIDATED.
'&filter=outofdate';
2523 } elseif ($mode ==
'shift') {
2524 $warning_delay = $conf->adherent->subscription->warning_delay / 60 / 60 / 24;
2525 $url = DOL_URL_ROOT.
'/adherents/list.php?mainmenu=members&statut='.
self::STATUS_DRAFT;
2526 $label = $langs->trans(
"MembersListToValid");
2527 $labelShort = $langs->trans(
"ToValidate");
2531 $response->warning_delay = $warning_delay;
2532 $response->label = $label;
2533 $response->labelShort = $labelShort;
2534 $response->url = $url;
2539 while ($obj = $this->
db->fetch_object(
$resql)) {
2540 $response->nbtodo++;
2542 $adherentstatic->datefin = $this->
db->jdate($obj->datefin);
2543 $adherentstatic->statut = $obj->statut;
2545 if ($adherentstatic->hasDelay()) {
2546 $response->nbtodolate++;
2553 $this->error = $this->
db->error();
2570 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams =
null)
2572 global $conf, $langs;
2574 $langs->load(
"orders");
2577 $modele =
'standard';
2579 if ($this->model_pdf) {
2580 $modele = $this->model_pdf;
2581 } elseif (!empty($conf->global->ADHERENT_ADDON_PDF)) {
2582 $modele = $conf->global->ADHERENT_ADDON_PDF;
2586 $modelpath =
"core/modules/member/doc/";
2588 return $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
2601 global $user, $langs;
2606 $this->
ref =
'ABC001';
2608 $this->specimen = 1;
2609 $this->civility_id = 0;
2610 $this->lastname =
'DOLIBARR';
2611 $this->firstname =
'SPECIMEN';
2612 $this->gender =
'man';
2613 $this->login =
'dolibspec';
2614 $this->pass =
'dolibspec';
2615 $this->company =
'Societe ABC';
2616 $this->address =
'61 jump street';
2617 $this->zip =
'75000';
2618 $this->town =
'Paris';
2619 $this->country_id = 1;
2620 $this->country_code =
'FR';
2621 $this->country =
'France';
2622 $this->morphy =
'mor';
2623 $this->email =
'specimen@specimen.com';
2624 $this->socialnetworks = array(
2625 'skype' =>
'skypepseudo',
2626 'twitter' =>
'twitterpseudo',
2627 'facebook' =>
'facebookpseudo',
2628 'linkedin' =>
'linkedinpseudo',
2630 $this->phone =
'0999999999';
2631 $this->phone_perso =
'0999999998';
2632 $this->phone_mobile =
'0999999997';
2633 $this->note_public =
'This is a public note';
2634 $this->note_private =
'This is a private note';
2635 $this->birth = $now;
2640 $this->datefin = $now;
2641 $this->datevalid = $now;
2642 $this->default_lang =
'';
2645 $this->
type =
'Type adherent';
2646 $this->need_subscription = 0;
2648 $this->first_subscription_date = $now;
2649 $this->first_subscription_date_start = $this->first_subscription_date;
2650 $this->first_subscription_date_end =
dol_time_plus_duree($this->first_subscription_date_start, 1,
'y');
2651 $this->first_subscription_amount = 10;
2653 $this->last_subscription_date = $this->first_subscription_date;
2654 $this->last_subscription_date_start = $this->first_subscription_date;
2655 $this->last_subscription_date_end =
dol_time_plus_duree($this->last_subscription_date_start, 1,
'y');
2656 $this->last_subscription_amount = 10;
2678 $dn = $conf->global->LDAP_KEY_MEMBERS.
"=".$info[$conf->global->LDAP_KEY_MEMBERS].
",".$conf->global->LDAP_MEMBER_DN;
2681 $dn = $conf->global->LDAP_MEMBER_DN;
2684 $dn = $conf->global->LDAP_KEY_MEMBERS.
"=".$info[$conf->global->LDAP_KEY_MEMBERS];
2700 global $conf, $langs;
2704 $keymodified =
false;
2707 $info[
"objectclass"] = explode(
',', $conf->global->LDAP_MEMBER_OBJECT_CLASS);
2712 if ($this->morphy ==
'mor' && (empty($this->fullname) || $this->fullname == $this->company)) {
2713 $this->fullname = $this->company;
2714 $this->lastname = $this->company;
2719 'LDAP_MEMBER_FIELD_FULLNAME' =>
'fullname',
2720 'LDAP_MEMBER_FIELD_NAME' =>
'lastname',
2721 'LDAP_MEMBER_FIELD_LOGIN' =>
'login',
2722 'LDAP_MEMBER_FIELD_LOGIN_SAMBA' =>
'login',
2723 'LDAP_MEMBER_FIELD_MAIL' =>
'email'
2727 foreach ($ldapkey as $constname => $varname) {
2728 if (!empty($this->$varname) && !empty($conf->global->$constname)) {
2729 $info[$conf->global->$constname] = $this->$varname;
2732 if (!empty($conf->global->LDAP_KEY_MEMBERS) && $conf->global->LDAP_KEY_MEMBERS == $conf->global->$constname) {
2733 if (!empty($this->oldcopy) && $this->$varname != $this->oldcopy->$varname) {
2734 $keymodified =
true;
2739 if ($this->firstname && !empty($conf->global->LDAP_MEMBER_FIELD_FIRSTNAME)) {
2740 $info[$conf->global->LDAP_MEMBER_FIELD_FIRSTNAME] = $this->firstname;
2742 if ($this->poste && !empty($conf->global->LDAP_MEMBER_FIELD_TITLE)) {
2743 $info[$conf->global->LDAP_MEMBER_FIELD_TITLE] = $this->poste;
2745 if ($this->company && !empty($conf->global->LDAP_MEMBER_FIELD_COMPANY)) {
2746 $info[$conf->global->LDAP_MEMBER_FIELD_COMPANY] = $this->company;
2748 if ($this->address && !empty($conf->global->LDAP_MEMBER_FIELD_ADDRESS)) {
2749 $info[$conf->global->LDAP_MEMBER_FIELD_ADDRESS] = $this->address;
2751 if ($this->zip && !empty($conf->global->LDAP_MEMBER_FIELD_ZIP)) {
2752 $info[$conf->global->LDAP_MEMBER_FIELD_ZIP] = $this->zip;
2754 if ($this->town && !empty($conf->global->LDAP_MEMBER_FIELD_TOWN)) {
2755 $info[$conf->global->LDAP_MEMBER_FIELD_TOWN] = $this->town;
2757 if ($this->country_code && !empty($conf->global->LDAP_MEMBER_FIELD_COUNTRY)) {
2758 $info[$conf->global->LDAP_MEMBER_FIELD_COUNTRY] = $this->country_code;
2760 foreach ($socialnetworks as $key => $value) {
2761 if ($this->socialnetworks[$value[
'label']] && !empty($conf->global->{
'LDAP_MEMBER_FIELD_'.strtoupper($value[
'label'])})) {
2762 $info[$conf->global->{
'LDAP_MEMBER_FIELD_'.strtoupper($value[
'label'])}] = $this->socialnetworks[$value[
'label']];
2765 if ($this->phone && !empty($conf->global->LDAP_MEMBER_FIELD_PHONE)) {
2766 $info[$conf->global->LDAP_MEMBER_FIELD_PHONE] = $this->phone;
2768 if ($this->phone_perso && !empty($conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO)) {
2769 $info[$conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO] = $this->phone_perso;
2771 if ($this->phone_mobile && !empty($conf->global->LDAP_MEMBER_FIELD_MOBILE)) {
2772 $info[$conf->global->LDAP_MEMBER_FIELD_MOBILE] = $this->phone_mobile;
2774 if ($this->fax && !empty($conf->global->LDAP_MEMBER_FIELD_FAX)) {
2775 $info[$conf->global->LDAP_MEMBER_FIELD_FAX] = $this->fax;
2777 if ($this->note_private && !empty($conf->global->LDAP_MEMBER_FIELD_DESCRIPTION)) {
2778 $info[$conf->global->LDAP_MEMBER_FIELD_DESCRIPTION] =
dol_string_nohtmltag($this->note_private, 2);
2780 if ($this->note_public && !empty($conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC)) {
2781 $info[$conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC] =
dol_string_nohtmltag($this->note_public, 2);
2783 if ($this->birth && !empty($conf->global->LDAP_MEMBER_FIELD_BIRTHDATE)) {
2784 $info[$conf->global->LDAP_MEMBER_FIELD_BIRTHDATE] =
dol_print_date($this->birth,
'dayhourldap');
2786 if (isset($this->statut) && !empty($conf->global->LDAP_FIELD_MEMBER_STATUS)) {
2787 $info[$conf->global->LDAP_FIELD_MEMBER_STATUS] = $this->statut;
2789 if ($this->datefin && !empty($conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION)) {
2790 $info[$conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION] =
dol_print_date($this->datefin,
'dayhourldap');
2794 if (!empty($this->pass)) {
2795 if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD)) {
2796 $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD] = $this->pass;
2798 if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) {
2799 $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] =
dol_hash($this->pass,
'openldap');
2801 } elseif ($conf->global->LDAP_SERVER_PROTOCOLVERSION !==
'3') {
2804 if (!empty($conf->global->DATABASE_PWD_ENCRYPTED)) {
2806 if (empty($conf->global->MAIN_SECURITY_HASH_ALGO)) {
2807 if ($this->pass_indatabase_crypted && !empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) {
2810 $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] =
dolGetLdapPasswordHash($this->pass_indatabase_crypted,
'md5frommd5');
2813 } elseif (!empty($this->pass_indatabase)) {
2815 if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD)) {
2816 $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD] = $this->pass_indatabase;
2818 if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) {
2819 $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] =
dol_hash($this->pass_indatabase,
'openldap');
2825 if ($this->first_subscription_date && !empty($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE)) {
2826 $info[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE] =
dol_print_date($this->first_subscription_date,
'dayhourldap');
2828 if (isset($this->first_subscription_amount) && !empty($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT)) {
2829 $info[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT] = $this->first_subscription_amount;
2831 if ($this->last_subscription_date && !empty($conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE)) {
2832 $info[$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE] =
dol_print_date($this->last_subscription_date,
'dayhourldap');
2834 if (isset($this->last_subscription_amount) && !empty($conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT)) {
2835 $info[$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT] = $this->last_subscription_amount;
2850 $sql =
'SELECT a.rowid, a.datec as datec,';
2851 $sql .=
' a.datevalid as datev,';
2852 $sql .=
' a.tms as datem,';
2853 $sql .=
' a.fk_user_author, a.fk_user_valid, a.fk_user_mod';
2854 $sql .=
' FROM '.MAIN_DB_PREFIX.
'adherent as a';
2855 $sql .=
' WHERE a.rowid = '.((int) $id);
2857 dol_syslog(get_class($this).
"::info", LOG_DEBUG);
2858 $result = $this->
db->query($sql);
2860 if ($this->
db->num_rows($result)) {
2861 $obj = $this->
db->fetch_object($result);
2862 $this->
id = $obj->rowid;
2864 $this->user_creation_id = $obj->fk_user_author;
2865 $this->user_validation_id = $obj->fk_user_valid;
2866 $this->user_modification_id = $obj->fk_user_mod;
2867 $this->date_creation = $this->
db->jdate($obj->datec);
2868 $this->date_validation = $this->
db->jdate($obj->datev);
2869 $this->date_modification = $this->
db->jdate($obj->datem);
2872 $this->
db->free($result);
2885 $sql =
"SELECT count(mc.email) as nb";
2886 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mailing_cibles as mc";
2887 $sql .=
" WHERE mc.email = '".$this->db->escape($this->email).
"'";
2888 $sql .=
" AND mc.statut NOT IN (-1,0)";
2892 $obj = $this->
db->fetch_object(
$resql);
2898 $this->error = $this->
db->error();
2915 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
2916 return parent::setCategoriesCommon($categories, Categorie::TYPE_MEMBER);
2929 $tables = array(
'adherent');
2944 if ($this->statut != self::STATUS_VALIDATED) {
2947 if (!$this->datefin) {
2953 return $this->datefin < ($now - $conf->adherent->subscription->warning_delay);
2966 global $conf, $langs, $mysoc, $user;
2972 $blockingerrormsg =
'';
2974 if (empty($conf->adherent->enabled)) {
2975 $langs->load(
"agenda");
2976 $this->output = $langs->trans(
'ModuleNotEnabled', $langs->transnoentitiesnoconv(
"Adherent"));
2979 if (empty($conf->global->MEMBER_REMINDER_EMAIL)) {
2980 $langs->load(
"agenda");
2981 $this->output = $langs->trans(
'EventRemindersByEmailNotEnabled', $langs->transnoentitiesnoconv(
"Adherent"));
2989 $listofmembersok = array();
2990 $listofmembersko = array();
2992 $arraydaysbeforeend = explode(
';', $daysbeforeendlist);
2993 foreach ($arraydaysbeforeend as $daysbeforeend) {
2994 dol_syslog(__METHOD__.
' - Process delta = '.$daysbeforeend, LOG_DEBUG);
2996 if (!is_numeric($daysbeforeend)) {
2997 $blockingerrormsg =
"Value for delta is not a numeric value";
3005 $sql =
'SELECT rowid FROM '.MAIN_DB_PREFIX.
'adherent';
3006 $sql .=
" WHERE entity = ".((int) $conf->entity);
3007 $sql .=
" AND datefin = '".$this->db->idate($datetosearchfor).
"'";
3012 $num_rows = $this->
db->num_rows(
$resql);
3014 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
3019 while ($i < $num_rows) {
3020 $obj = $this->
db->fetch_object(
$resql);
3022 $adherent->fetch($obj->rowid,
'',
'',
'',
true,
true);
3024 if (empty($adherent->email)) {
3026 $listofmembersko[$adherent->id] = $adherent->id;
3028 $adherent->fetch_thirdparty();
3031 $languagefromcountrycode =
getLanguageCodeFromCountryCode($adherent->country_code ? $adherent->country_code : $adherent->thirdparty->country_code);
3032 $languagecodeformember = (empty($adherent->thirdparty->default_lang) ? ($languagefromcountrycode ? $languagefromcountrycode : $mysoc->default_lang) : $adherent->thirdparty->default_lang);
3035 $outputlangs =
new Translate(
'', $conf);
3036 $outputlangs->setDefaultLang($languagecodeformember);
3037 $outputlangs->loadLangs(array(
"main",
"members"));
3038 dol_syslog(
"sendReminderForExpiredSubscription Language for member id ".$adherent->id.
" set to ".$outputlangs->defaultlang.
" mysoc->default_lang=".$mysoc->default_lang);
3040 $arraydefaultmessage =
null;
3043 if (!empty($labeltouse)) {
3044 $arraydefaultmessage = $formmail->getEMailTemplate($this->
db,
'member', $user, $outputlangs, 0, 1, $labeltouse);
3047 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
3052 $subject =
make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs);
3053 $msg =
make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs);
3055 $to = $adherent->email;
3057 $trackid =
'mem'.$adherent->id;
3058 $moreinheader =
'X-Dolibarr-Info: sendReminderForExpiredSubscription'.
"\r\n";
3060 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
3061 $cmail =
new CMailFile($subject, $to, $from, $msg, array(), array(), array(),
'',
'', 0, 1,
'',
'', $trackid, $moreinheader);
3062 $result = $cmail->sendfile();
3065 $this->error .= $cmail->error.
' ';
3066 if (!is_null($cmail->errors)) {
3067 $this->errors += $cmail->errors;
3070 $listofmembersko[$adherent->id] = $adherent->id;
3073 $listofmembersok[$adherent->id] = $adherent->id;
3079 $actioncode =
'EMAIL';
3090 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic').
": ".$subject);
3091 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody').
":");
3095 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
3100 $actioncomm->type_code =
'AC_OTH_AUTO';
3101 $actioncomm->code =
'AC_'.$actioncode;
3102 $actioncomm->label = $actionmsg2;
3103 $actioncomm->note_private = $actionmsg;
3104 $actioncomm->fk_project = 0;
3105 $actioncomm->datep = $now;
3106 $actioncomm->datef = $now;
3107 $actioncomm->percentage = -1;
3108 $actioncomm->socid = $adherent->thirdparty->id;
3109 $actioncomm->contact_id = 0;
3110 $actioncomm->authorid = $user->id;
3111 $actioncomm->userownerid = $user->id;
3113 $actioncomm->email_msgid = $cmail->msgid;
3114 $actioncomm->email_from = $from;
3115 $actioncomm->email_sender =
'';
3116 $actioncomm->email_to = $to;
3117 $actioncomm->email_tocc = $sendtocc;
3118 $actioncomm->email_tobcc = $sendtobcc;
3119 $actioncomm->email_subject = $subject;
3120 $actioncomm->errors_to =
'';
3122 $actioncomm->fk_element = $adherent->id;
3123 $actioncomm->elementtype = $adherent->element;
3125 $actioncomm->extraparams = $extraparams;
3127 $actioncomm->create($user);
3133 $this->error .=
"Can't find email template with label=".$labeltouse.
", to use for the reminding email ";
3136 $listofmembersko[$adherent->id] = $adherent->id;
3145 $this->error = $this->
db->lasterror();
3150 if ($blockingerrormsg) {
3151 $this->error = $blockingerrormsg;
3154 $this->output =
'Found '.($nbok + $nbko).
' members to send reminder to.';
3155 $this->output .=
' Send email successfuly to '.$nbok.
' members';
3156 if (is_array($listofmembersok)) {
3159 foreach ($listofmembersok as $idmember) {
3161 $listofids .=
', ...';
3164 if (empty($listofids)) {
3169 $listofids .= $idmember;
3176 $this->output .= ($listofids ?
' ids='.$listofids :
'');
3179 $this->output .=
' - Canceled for '.$nbko.
' member (no email or email sending error)';
3180 if (is_array($listofmembersko)) {
3183 foreach ($listofmembersko as $idmember) {
3185 $listofids .=
', ...';
3188 if (empty($listofids)) {
3193 $listofids .= $idmember;
3199 $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 $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.
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.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
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.