39require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
41require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/class/commonpeople.class.php';
55 public $element =
'member';
60 public $table_element =
'adherent';
65 public $picto =
'member';
85 public $pass_indatabase;
90 public $pass_indatabase_crypted;
107 public $civility_code;
138 public $socialnetworks;
158 public $phone_mobile;
184 public $default_lang;
230 public $need_subscription;
250 public $first_subscription_date;
255 public $first_subscription_date_start;
260 public $first_subscription_date_end;
265 public $first_subscription_amount;
270 public $last_subscription_date;
275 public $last_subscription_date_start;
280 public $last_subscription_date_end;
285 public $last_subscription_amount;
290 public $subscriptions = array();
299 public $partnerships = array();
310 public $fields = array(
311 'rowid' => array(
'type' =>
'integer',
'label' =>
'TechnicalID',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 10),
312 'ref' => array(
'type' =>
'varchar(30)',
'label' =>
'Ref',
'default' =>
'1',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'position' => 12,
'index' => 1),
313 'entity' => array(
'type' =>
'integer',
'label' =>
'Entity',
'default' =>
'1',
'enabled' => 1,
'visible' => -2,
'notnull' => 1,
'position' => 15,
'index' => 1),
314 'ref_ext' => array(
'type' =>
'varchar(128)',
'label' =>
'Ref ext',
'enabled' => 1,
'visible' => 0,
'position' => 20),
315 'civility' => array(
'type' =>
'varchar(6)',
'label' =>
'Civility',
'enabled' => 1,
'visible' => -1,
'position' => 25),
316 'lastname' => array(
'type' =>
'varchar(50)',
'label' =>
'Lastname',
'enabled' => 1,
'visible' => 1,
'position' => 30,
'showoncombobox' => 1),
317 'firstname' => array(
'type' =>
'varchar(50)',
'label' =>
'Firstname',
'enabled' => 1,
'visible' => 1,
'position' => 35,
'showoncombobox' => 1),
318 'login' => array(
'type' =>
'varchar(50)',
'label' =>
'Login',
'enabled' => 1,
'visible' => 1,
'position' => 40),
319 'pass' => array(
'type' =>
'varchar(50)',
'label' =>
'Pass',
'enabled' => 1,
'visible' => -1,
'position' => 45),
320 'pass_crypted' => array(
'type' =>
'varchar(128)',
'label' =>
'Pass crypted',
'enabled' => 1,
'visible' => -1,
'position' => 50),
321 'morphy' => array(
'type' =>
'varchar(3)',
'label' =>
'MemberNature',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'position' => 55),
322 'fk_adherent_type' => array(
'type' =>
'integer',
'label' =>
'Fk adherent type',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'position' => 60),
323 'societe' => array(
'type' =>
'varchar(128)',
'label' =>
'Societe',
'enabled' => 1,
'visible' => 1,
'position' => 65,
'showoncombobox' => 2),
324 'fk_soc' => array(
'type' =>
'integer:Societe:societe/class/societe.class.php',
'label' =>
'ThirdParty',
'enabled' => 1,
'visible' => 1,
'position' => 70),
325 'address' => array(
'type' =>
'text',
'label' =>
'Address',
'enabled' => 1,
'visible' => -1,
'position' => 75),
326 'zip' => array(
'type' =>
'varchar(10)',
'label' =>
'Zip',
'enabled' => 1,
'visible' => -1,
'position' => 80),
327 'town' => array(
'type' =>
'varchar(50)',
'label' =>
'Town',
'enabled' => 1,
'visible' => -1,
'position' => 85),
328 'state_id' => array(
'type' =>
'integer',
'label' =>
'State id',
'enabled' => 1,
'visible' => -1,
'position' => 90),
329 'country' => array(
'type' =>
'integer:Ccountry:core/class/ccountry.class.php',
'label' =>
'Country',
'enabled' => 1,
'visible' => 1,
'position' => 95),
330 'phone' => array(
'type' =>
'varchar(30)',
'label' =>
'Phone',
'enabled' => 1,
'visible' => -1,
'position' => 115),
331 'phone_perso' => array(
'type' =>
'varchar(30)',
'label' =>
'Phone perso',
'enabled' => 1,
'visible' => -1,
'position' => 120),
332 'phone_mobile' => array(
'type' =>
'varchar(30)',
'label' =>
'Phone mobile',
'enabled' => 1,
'visible' => -1,
'position' => 125),
333 'email' => array(
'type' =>
'varchar(255)',
'label' =>
'Email',
'enabled' => 1,
'visible' => 1,
'position' => 126),
334 'url' => array(
'type' =>
'varchar(255)',
'label' =>
'Url',
'enabled' => 1,
'visible' => -1,
'position' => 127),
335 'socialnetworks' => array(
'type' =>
'text',
'label' =>
'Socialnetworks',
'enabled' => 1,
'visible' => -1,
'position' => 128),
336 'birth' => array(
'type' =>
'date',
'label' =>
'DateOfBirth',
'enabled' => 1,
'visible' => -1,
'position' => 130),
337 'gender' => array(
'type' =>
'varchar(10)',
'label' =>
'Gender',
'enabled' => 1,
'visible' => -1,
'position' => 132),
338 'photo' => array(
'type' =>
'varchar(255)',
'label' =>
'Photo',
'enabled' => 1,
'visible' => -1,
'position' => 135),
339 'public' => array(
'type' =>
'smallint(6)',
'label' =>
'Public',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 145),
340 'datefin' => array(
'type' =>
'datetime',
'label' =>
'DateEnd',
'enabled' => 1,
'visible' => 1,
'position' => 150),
341 'default_lang' => array(
'type' =>
'varchar(6)',
'label' =>
'Default lang',
'enabled' => 1,
'visible' => -1,
'position' => 153),
342 'note_public' => array(
'type' =>
'text',
'label' =>
'NotePublic',
'enabled' => 1,
'visible' => 0,
'position' => 155),
343 'note_private' => array(
'type' =>
'text',
'label' =>
'NotePrivate',
'enabled' => 1,
'visible' => 0,
'position' => 160),
344 'datevalid' => array(
'type' =>
'datetime',
'label' =>
'DateValidation',
'enabled' => 1,
'visible' => -1,
'position' => 165),
345 'datec' => array(
'type' =>
'datetime',
'label' =>
'DateCreation',
'enabled' => 1,
'visible' => -1,
'position' => 170),
346 'tms' => array(
'type' =>
'timestamp',
'label' =>
'DateModification',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 175),
347 'fk_user_author' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'Fk user author',
'enabled' => 1,
'visible' => -1,
'position' => 180),
348 'fk_user_mod' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'Fk user mod',
'enabled' => 1,
'visible' => -1,
'position' => 185),
349 'fk_user_valid' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'UserValidation',
'enabled' => 1,
'visible' => -1,
'position' => 190),
350 'canvas' => array(
'type' =>
'varchar(32)',
'label' =>
'Canvas',
'enabled' => 1,
'visible' => -1,
'position' => 195),
351 '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')),
352 'model_pdf' => array(
'type' =>
'varchar(255)',
'label' =>
'Model pdf',
'enabled' => 1,
'visible' => 0,
'position' => 800),
353 'import_key' => array(
'type' =>
'varchar(14)',
'label' =>
'ImportId',
'enabled' => 1,
'visible' => -2,
'position' => 805)
386 $this->ismultientitymanaged = 1;
387 $this->isextrafieldmanaged = 1;
389 $this->array_options = array();
412 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 =
'')
415 dol_syslog(
'Warning using deprecated Adherent::send_an_email', LOG_WARNING);
417 return $this->
sendEmail($text, $subject, $filename_list, $mimetype_list, $mimefilename_list, $addr_cc, $addr_bcc, $deliveryreceipt, $msgishtml, $errors_to, $moreinheader);
437 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 =
'')
439 global $conf, $langs;
442 if ($msgishtml == -1) {
449 dol_syslog(
'sendEmail msgishtml='.$msgishtml);
458 $from = $conf->email_from;
463 $trackid =
'mem'.$this->id;
466 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
467 $mailfile =
new CMailFile($subjecttosend, $this->email, $from, $texttosend, $filename_list, $mimetype_list, $mimefilename_list, $addr_cc, $addr_bcc, $deliveryreceipt, $msgishtml,
'',
'', $trackid, $moreinheader);
468 if ($mailfile->sendfile()) {
471 $this->error = $langs->trans(
"ErrorFailedToSendMail", $from, $this->email).
'. '.$mailfile->error;
495 if ($this->civility_id) {
496 $infos .= $langs->transnoentities(
"UserTitle").
": ".$this->
getCivilityLabel().
"\n";
498 $infos .= $langs->transnoentities(
"id").
": ".$this->
id.
"\n";
499 $infos .= $langs->transnoentities(
"ref").
": ".$this->
ref.
"\n";
500 $infos .= $langs->transnoentities(
"Lastname").
": ".$this->lastname.
"\n";
501 $infos .= $langs->transnoentities(
"Firstname").
": ".$this->firstname.
"\n";
502 $infos .= $langs->transnoentities(
"Company").
": ".$this->company.
"\n";
503 $infos .= $langs->transnoentities(
"Address").
": ".$this->address.
"\n";
504 $infos .= $langs->transnoentities(
"Zip").
": ".$this->zip.
"\n";
505 $infos .= $langs->transnoentities(
"Town").
": ".$this->town.
"\n";
506 $infos .= $langs->transnoentities(
"Country").
": ".$this->country.
"\n";
507 $infos .= $langs->transnoentities(
"EMail").
": ".$this->email.
"\n";
508 $infos .= $langs->transnoentities(
"PhonePro").
": ".$this->phone.
"\n";
509 $infos .= $langs->transnoentities(
"PhonePerso").
": ".$this->phone_perso.
"\n";
510 $infos .= $langs->transnoentities(
"PhoneMobile").
": ".$this->phone_mobile.
"\n";
512 $infos .= $langs->transnoentities(
"Login").
": ".$this->login.
"\n";
513 $infos .= $langs->transnoentities(
"Password").
": ".$this->pass.
"\n";
515 $infos .= $langs->transnoentities(
"Birthday").
": ".$birthday.
"\n";
516 $infos .= $langs->transnoentities(
"Photo").
": ".$this->photo.
"\n";
517 $infos .= $langs->transnoentities(
"Public").
": ".
yn($this->
public);
520 $substitutionarray = array(
521 '__ID__' => $this->
id,
522 '__REF__' => $this->
ref,
523 '__MEMBER_ID__' => $this->
id,
525 '__FIRSTNAME__' => $msgishtml ?
dol_htmlentitiesbr($this->firstname) : ($this->firstname ? $this->firstname :
''),
526 '__LASTNAME__' => $msgishtml ?
dol_htmlentitiesbr($this->lastname) : ($this->lastname ? $this->lastname :
''),
528 '__COMPANY__' => $msgishtml ?
dol_htmlentitiesbr($this->company) : ($this->company ? $this->company :
''),
529 '__ADDRESS__' => $msgishtml ?
dol_htmlentitiesbr($this->address) : ($this->address ? $this->address :
''),
530 '__ZIP__' => $msgishtml ?
dol_htmlentitiesbr($this->zip) : ($this->zip ? $this->zip :
''),
531 '__TOWN__' => $msgishtml ?
dol_htmlentitiesbr($this->town) : ($this->town ? $this->town :
''),
532 '__COUNTRY__' => $msgishtml ?
dol_htmlentitiesbr($this->country) : ($this->country ? $this->country :
''),
533 '__EMAIL__' => $msgishtml ?
dol_htmlentitiesbr($this->email) : ($this->email ? $this->email :
''),
534 '__BIRTH__' => $msgishtml ?
dol_htmlentitiesbr($birthday) : ($birthday ? $birthday :
''),
535 '__PHOTO__' => $msgishtml ?
dol_htmlentitiesbr($this->photo) : ($this->photo ? $this->photo :
''),
536 '__LOGIN__' => $msgishtml ?
dol_htmlentitiesbr($this->login) : ($this->login ? $this->login :
''),
537 '__PASSWORD__' => $msgishtml ?
dol_htmlentitiesbr($this->pass) : ($this->pass ? $this->pass :
''),
538 '__PHONE__' => $msgishtml ?
dol_htmlentitiesbr($this->phone) : ($this->phone ? $this->phone :
''),
539 '__PHONEPRO__' => $msgishtml ?
dol_htmlentitiesbr($this->phone_perso) : ($this->phone_perso ? $this->phone_perso :
''),
540 '__PHONEMOBILE__' => $msgishtml ?
dol_htmlentitiesbr($this->phone_mobile) : ($this->phone_mobile ? $this->phone_mobile :
''),
564 $morphy = $this->morphy;
568 $labeltoshowm = $langs->trans(
"Moral");
569 $labeltoshowp = $langs->trans(
"Physical");
570 if ($morphy ==
'phy') {
571 $labeltoshow = $labeltoshowp;
572 if ($addbadge == 2) {
578 $s .=
'<span class="member-individual-back paddingleftimp paddingrightimp" title="'.$langs->trans(
"Physical").
'">'.$labeltoshow.
'</span>';
580 if ($morphy ==
'mor') {
581 $labeltoshow = $labeltoshowm;
582 if ($addbadge == 2) {
588 $s .=
'<span class="member-company-back paddingleftimp paddingrightimp" title="'.$langs->trans(
"Moral").
'">'.$labeltoshow.
'</span>';
591 if ($morphy ==
'phy') {
592 $s = $langs->trans(
"Physical");
593 } elseif ($morphy ==
'mor') {
594 $s = $langs->trans(
"Moral");
608 public function create($user, $notrigger = 0)
610 global $conf, $langs, $mysoc;
617 $this->import_key = trim($this->import_key);
621 $langs->load(
"errors");
622 $this->error = $langs->trans(
"ErrorBadEMail", $this->email);
629 if (empty($this->login)) {
630 $this->error = $langs->trans(
"ErrorWrongValueForParameterX",
"Login");
638 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"adherent";
639 $sql .=
" (ref, datec,login,fk_user_author,fk_user_mod,fk_user_valid,morphy,fk_adherent_type,entity,import_key, ip)";
642 $sql .=
", '".$this->db->idate($this->datec).
"'";
643 $sql .=
", ".($this->login ?
"'".$this->db->escape($this->login).
"'" :
"null");
644 $sql .=
", ".($user->id > 0 ? $user->id :
"null");
645 $sql .=
", null, null, '".$this->db->escape($this->morphy).
"'";
646 $sql .=
", ".((int) $this->
typeid);
647 $sql .=
", ".$conf->entity;
648 $sql .=
", ".(!empty($this->import_key) ?
"'".$this->db->escape($this->import_key).
"'" :
"null");
649 $sql .=
", ".(!empty($this->ip) ?
"'".$this->db->escape($this->ip).
"'" :
"null");
652 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
653 $result = $this->db->query($sql);
655 $id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"adherent");
660 $this->
ref = (string) $id;
665 require_once $modfile;
667 $modCodeMember =
new $modname();
668 '@phan-var-force ModeleNumRefMembers $modCodeMember';
669 $this->
ref = $modCodeMember->getNextValue($mysoc, $this);
677 $result = $this->
update($user, 1, 1, 0, 0,
'add');
679 $this->db->rollback();
684 if ($this->user_id) {
686 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET";
687 $sql .=
" fk_member = ".((int) $this->
id);
688 $sql .=
" WHERE rowid = ".((int) $this->user_id);
689 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
690 $resql = $this->db->query($sql);
692 $this->error =
'Failed to update user to make link with member';
693 $this->db->rollback();
707 if (count($this->errors)) {
708 dol_syslog(get_class($this).
"::create ".implode(
',', $this->errors), LOG_ERR);
709 $this->db->rollback();
716 $this->error =
'Failed to get last insert id';
717 dol_syslog(get_class($this).
"::create ".$this->error, LOG_ERR);
718 $this->db->rollback();
722 $this->error = $this->db->error();
723 $this->db->rollback();
740 public function update($user, $notrigger = 0, $nosyncuser = 0, $nosyncuserpass = 0, $nosyncthirdparty = 0, $action =
'update')
742 global $langs, $hookmanager;
744 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
749 dol_syslog(get_class($this).
"::update notrigger=".$notrigger.
", nosyncuser=".$nosyncuser.
", nosyncuserpass=".$nosyncuserpass.
" nosyncthirdparty=".$nosyncthirdparty.
", email=".$this->email);
752 $this->lastname = trim($this->lastname) ? trim($this->lastname) : trim($this->lastname);
753 $this->firstname = trim($this->firstname) ? trim($this->firstname) : trim($this->firstname);
754 $this->gender = trim($this->gender);
762 $this->url = $this->url ?
clean_url($this->url, 0) :
'';
766 $langs->load(
"errors");
767 $this->error = $langs->trans(
"ErrorBadEMail", $this->email);
773 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
774 $sql .=
" ref = '".$this->db->escape($this->
ref).
"'";
775 $sql .=
", civility = ".($this->civility_id ?
"'".$this->db->escape($this->civility_id).
"'" :
"null");
776 $sql .=
", firstname = ".($this->firstname ?
"'".$this->db->escape($this->firstname).
"'" :
"null");
777 $sql .=
", lastname = ".($this->lastname ?
"'".$this->db->escape($this->lastname).
"'" :
"null");
778 $sql .=
", gender = ".($this->gender != -1 ?
"'".$this->db->escape($this->gender).
"'" :
"null");
779 $sql .=
", login = ".($this->login ?
"'".$this->db->escape($this->login).
"'" :
"null");
780 $sql .=
", societe = ".($this->company ?
"'".$this->db->escape($this->company).
"'" : ($this->societe ?
"'".$this->db->escape($this->societe).
"'" :
"null"));
782 $sql .=
", fk_soc = ".($this->socid > 0 ? (int) $this->socid :
"null");
784 $sql .=
", address = ".($this->address ?
"'".$this->db->escape($this->address).
"'" :
"null");
785 $sql .=
", zip = ".($this->zip ?
"'".$this->db->escape($this->zip).
"'" :
"null");
786 $sql .=
", town = ".($this->town ?
"'".$this->db->escape($this->town).
"'" :
"null");
787 $sql .=
", country = ".($this->country_id > 0 ? (int) $this->country_id :
"null");
788 $sql .=
", state_id = ".($this->state_id > 0 ? (int) $this->state_id :
"null");
789 $sql .=
", email = '".$this->db->escape($this->email).
"'";
790 $sql .=
", url = ".(!empty($this->url) ?
"'".$this->db->escape($this->url).
"'" :
"null");
791 $sql .=
", socialnetworks = ".($this->socialnetworks ?
"'".$this->db->escape(json_encode($this->socialnetworks)).
"'" :
"null");
792 $sql .=
", phone = ".($this->phone ?
"'".$this->db->escape($this->phone).
"'" :
"null");
793 $sql .=
", phone_perso = ".($this->phone_perso ?
"'".$this->db->escape($this->phone_perso).
"'" :
"null");
794 $sql .=
", phone_mobile = ".($this->phone_mobile ?
"'".$this->db->escape($this->phone_mobile).
"'" :
"null");
795 $sql .=
", note_private = ".($this->note_private ?
"'".$this->db->escape($this->note_private).
"'" :
"null");
796 $sql .=
", note_public = ".($this->note_public ?
"'".$this->db->escape($this->note_public).
"'" :
"null");
797 $sql .=
", photo = ".($this->photo ?
"'".$this->db->escape($this->photo).
"'" :
"null");
798 $sql .=
", public = '".$this->db->escape($this->
public).
"'";
799 $sql .=
", statut = ".(int) $this->
statut;
800 $sql .=
", default_lang = ".(!empty($this->default_lang) ?
"'".$this->db->escape($this->default_lang).
"'" :
"null");
801 $sql .=
", fk_adherent_type = ".(int) $this->
typeid;
802 $sql .=
", morphy = '".$this->db->escape($this->morphy).
"'";
803 $sql .=
", birth = ".($this->birth ?
"'".$this->db->idate($this->birth).
"'" :
"null");
805 if ($this->datefin) {
806 $sql .=
", datefin = '".$this->db->idate($this->datefin).
"'";
808 if ($this->datevalid) {
809 $sql .=
", datevalid = '".$this->db->idate($this->datevalid).
"'";
811 $sql .=
", fk_user_mod = ".($user->id > 0 ? $user->id :
'null');
812 $sql .=
" WHERE rowid = ".((int) $this->
id);
815 if (!empty($this->oldcopy) && $this->
typeid != $this->oldcopy->typeid) {
816 $sql2 =
"SELECT libelle as label";
817 $sql2 .=
" FROM ".MAIN_DB_PREFIX.
"adherent_type";
818 $sql2 .=
" WHERE rowid = ".((int) $this->
typeid);
819 $resql2 = $this->db->query($sql2);
821 while ($obj = $this->db->fetch_object($resql2)) {
822 $this->
type = $obj->label;
827 dol_syslog(get_class($this).
"::update update member", LOG_DEBUG);
828 $resql = $this->db->query($sql);
830 unset($this->country_code);
831 unset($this->country);
832 unset($this->state_code);
835 $nbrowsaffected += $this->db->affected_rows($resql);
848 if (!$error && $this->pass) {
849 dol_syslog(get_class($this).
"::update update password");
850 if ($this->pass != $this->pass_indatabase && $this->pass != $this->pass_indatabase_crypted) {
854 $result = $this->
setPassword($user, $this->pass, $isencrypted, $notrigger, $nosyncuserpass);
855 if (!$nbrowsaffected) {
863 dol_syslog(get_class($this).
"::update update link to user");
864 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = NULL WHERE fk_member = ".((int) $this->
id);
865 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
866 $resql = $this->db->query($sql);
868 $this->error = $this->db->error();
869 $this->db->rollback();
873 if ($this->user_id > 0) {
874 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = ".((int) $this->
id).
" WHERE rowid = ".((int) $this->user_id);
875 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
876 $resql = $this->db->query($sql);
878 $this->error = $this->db->error();
879 $this->db->rollback();
885 if (!$error && $nbrowsaffected) {
887 if (!$error && $this->user_id > 0 && !$nosyncuser) {
888 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
890 dol_syslog(get_class($this).
"::update update linked user");
892 $luser =
new User($this->db);
893 $result = $luser->fetch($this->user_id);
901 $luser->login = $this->login;
904 $luser->ref = $this->ref;
905 $luser->civility_id = $this->civility_id;
906 $luser->firstname = $this->firstname;
907 $luser->lastname = $this->lastname;
908 $luser->gender = $this->gender;
909 $luser->pass = $this->pass;
912 $luser->birth = $this->birth;
914 $luser->address = $this->address;
915 $luser->zip = $this->zip;
916 $luser->town = $this->town;
917 $luser->country_id = $this->country_id;
918 $luser->state_id = $this->state_id;
920 $luser->email = $this->email;
921 $luser->socialnetworks = $this->socialnetworks;
922 $luser->office_phone = $this->phone;
923 $luser->user_mobile = $this->phone_mobile;
925 $luser->lang = $this->default_lang;
927 $luser->fk_member = $this->id;
929 $result = $luser->update($user, 0, 1, 1);
931 $this->error = $luser->error;
932 dol_syslog(get_class($this).
"::update ".$this->error, LOG_ERR);
936 $this->error = $luser->error;
942 if (!$error && $this->fk_soc > 0 && !$nosyncthirdparty) {
943 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
945 dol_syslog(get_class($this).
"::update update linked thirdparty");
949 $lthirdparty =
new Societe($this->db);
950 $result = $lthirdparty->fetch($this->fk_soc);
953 $lthirdparty->address = $this->address;
954 $lthirdparty->zip = $this->zip;
955 $lthirdparty->town = $this->town;
956 $lthirdparty->email = $this->email;
957 $lthirdparty->socialnetworks = $this->socialnetworks;
958 $lthirdparty->phone = $this->phone;
959 $lthirdparty->state_id = $this->state_id;
960 $lthirdparty->country_id = $this->country_id;
962 $lthirdparty->default_lang = $this->default_lang;
964 $result = $lthirdparty->update($this->fk_soc, $user, 0, 1, 1,
'update');
967 $this->error = $lthirdparty->error;
968 $this->errors = $lthirdparty->errors;
969 dol_syslog(get_class($this).
"::update ".$this->error, LOG_ERR);
972 } elseif ($result < 0) {
973 $this->error = $lthirdparty->error;
979 if (!$error && !$notrigger) {
990 return $nbrowsaffected;
992 $this->db->rollback();
996 $this->db->rollback();
997 $this->error = $this->db->lasterror();
1017 $sql =
"SELECT rowid, datec as dateop, dateadh as datedeb, datef as datefin";
1018 $sql .=
" FROM ".MAIN_DB_PREFIX.
"subscription";
1019 $sql .=
" WHERE fk_adherent = ".((int) $this->
id);
1020 $sql .=
" ORDER by dateadh DESC";
1022 dol_syslog(get_class($this).
"::update_end_date", LOG_DEBUG);
1023 $resql = $this->db->query($sql);
1025 $obj = $this->db->fetch_object($resql);
1026 $dateop = $this->db->jdate($obj->dateop);
1027 $datedeb = $this->db->jdate($obj->datedeb);
1028 $datefin = $this->db->jdate($obj->datefin);
1030 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
1031 $sql .=
" datefin=".($datefin !=
'' ?
"'".$this->db->idate($datefin).
"'" :
"null");
1032 $sql .=
" WHERE rowid = ".((int) $this->
id);
1034 dol_syslog(get_class($this).
"::update_end_date", LOG_DEBUG);
1035 $resql = $this->db->query($sql);
1037 $this->last_subscription_date = $dateop;
1038 $this->last_subscription_date_start = $datedeb;
1039 $this->last_subscription_date_end = $datefin;
1040 $this->datefin = $datefin;
1041 $this->db->commit();
1044 $this->db->rollback();
1048 $this->error = $this->db->lasterror();
1049 $this->db->rollback();
1061 public function delete($user, $notrigger = 0)
1072 if (!$error && !$notrigger) {
1082 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"categorie_member WHERE fk_member = ".((int) $rowid);
1083 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1084 $resql = $this->db->query($sql);
1087 $this->error .= $this->db->lasterror();
1093 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"subscription WHERE fk_adherent = ".((int) $rowid);
1094 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1095 $resql = $this->db->query($sql);
1098 $this->error .= $this->db->lasterror();
1108 $this->error .= $this->db->lasterror();
1119 dol_syslog(get_class($this).
"::delete erreur ".$errorflag.
" ".$this->error, LOG_ERR);
1125 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"adherent WHERE rowid = ".((int) $rowid);
1126 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1127 $resql = $this->db->query($sql);
1130 $this->error .= $this->db->lasterror();
1136 $this->db->commit();
1139 $this->db->rollback();
1155 public function setPassword($user, $password =
'', $isencrypted = 0, $notrigger = 0, $nosyncuser = 0)
1157 global $conf, $langs;
1161 dol_syslog(get_class($this).
"::setPassword user=".$user->id.
" password=".preg_replace(
'/./i',
'*', $password).
" isencrypted=".$isencrypted);
1165 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
1170 $password_crypted =
dol_hash($password);
1172 $password_indatabase =
'';
1173 if (!$isencrypted) {
1174 $password_indatabase = $password;
1180 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent";
1181 $sql .=
" SET pass_crypted = '".$this->db->escape($password_crypted).
"'";
1183 $sql .=
", pass = null";
1185 $sql .=
", pass = '".$this->db->escape($password_indatabase).
"'";
1187 $sql .=
" WHERE rowid = ".((int) $this->
id);
1190 dol_syslog(get_class($this).
"::setPassword", LOG_DEBUG);
1191 $result = $this->db->query($sql);
1193 $nbaffectedrows = $this->db->affected_rows($result);
1195 if ($nbaffectedrows) {
1196 $this->pass = $password;
1197 $this->pass_indatabase = $password_indatabase;
1198 $this->pass_indatabase_crypted = $password_crypted;
1200 if ($this->user_id && !$nosyncuser) {
1201 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
1205 $luser =
new User($this->db);
1206 $result = $luser->fetch($this->user_id);
1209 $result = $luser->setPassword($user, $this->pass, 0, 0, 1);
1210 if (is_int($result) && $result < 0) {
1211 $this->error = $luser->error;
1212 dol_syslog(get_class($this).
"::setPassword ".$this->error, LOG_ERR);
1216 $this->error = $luser->error;
1221 if (!$error && !$notrigger) {
1223 $result = $this->
call_trigger(
'MEMBER_NEW_PASSWORD', $user);
1226 $this->db->rollback();
1232 $this->db->commit();
1235 $this->db->rollback();
1239 $this->db->rollback();
1254 global $conf, $langs;
1259 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = NULL WHERE fk_member = ".((int) $this->
id);
1260 dol_syslog(get_class($this).
"::setUserId", LOG_DEBUG);
1261 $resql = $this->db->query($sql);
1263 $this->error = $this->db->error();
1264 $this->db->rollback();
1270 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = ".((int) $this->
id);
1271 $sql .=
" WHERE rowid = ".((int) $userid);
1272 dol_syslog(get_class($this).
"::setUserId", LOG_DEBUG);
1273 $resql = $this->db->query($sql);
1275 $this->error = $this->db->error();
1276 $this->db->rollback();
1281 $this->db->commit();
1295 global $conf, $langs;
1300 if ($thirdpartyid > 0) {
1301 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET fk_soc = null";
1302 $sql .=
" WHERE fk_soc = ".((int) $thirdpartyid);
1303 $sql .=
" AND entity = ".$conf->entity;
1304 dol_syslog(get_class($this).
"::setThirdPartyId", LOG_DEBUG);
1305 $resql = $this->db->query($sql);
1309 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET fk_soc = ".($thirdpartyid > 0 ? (int) $thirdpartyid :
'null');
1310 $sql .=
" WHERE rowid = ".((int) $this->
id);
1312 dol_syslog(get_class($this).
"::setThirdPartyId", LOG_DEBUG);
1313 $resql = $this->db->query($sql);
1315 $this->db->commit();
1318 $this->error = $this->db->error();
1319 $this->db->rollback();
1337 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"adherent";
1338 $sql .=
" WHERE login='".$this->db->escape($login).
"'";
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);
1365 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"adherent";
1366 $sql .=
" WHERE firstname='".$this->db->escape($firstname).
"'";
1367 $sql .=
" AND lastname='".$this->db->escape($lastname).
"'";
1368 $sql .=
" AND entity = ".$conf->entity;
1370 $resql = $this->db->query($sql);
1372 if ($this->db->num_rows($resql)) {
1373 $obj = $this->db->fetch_object($resql);
1374 $this->
fetch($obj->rowid);
1392 public function fetch($rowid, $ref =
'', $fk_soc = 0, $ref_ext =
'', $fetch_optionals =
true, $fetch_subscriptions =
true)
1396 $sql =
"SELECT d.rowid, d.ref, d.ref_ext, d.civility as civility_code, d.gender, d.firstname, d.lastname,";
1397 $sql .=
" d.societe as company, d.fk_soc, d.statut, d.public, d.address, d.zip, d.town, d.note_private,";
1398 $sql .=
" d.note_public,";
1399 $sql .=
" d.email, d.url, d.socialnetworks, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass, d.pass_crypted,";
1400 $sql .=
" d.photo, d.fk_adherent_type, d.morphy, d.entity,";
1401 $sql .=
" d.datec as datec,";
1402 $sql .=
" d.tms as datem,";
1403 $sql .=
" d.datefin as datefin, d.default_lang,";
1404 $sql .=
" d.birth as birthday,";
1405 $sql .=
" d.datevalid as datev,";
1406 $sql .=
" d.country,";
1407 $sql .=
" d.state_id,";
1408 $sql .=
" d.model_pdf,";
1409 $sql .=
" c.rowid as country_id, c.code as country_code, c.label as country,";
1410 $sql .=
" dep.nom as state, dep.code_departement as state_code,";
1411 $sql .=
" t.libelle as type, t.subscription as subscription,";
1412 $sql .=
" u.rowid as user_id, u.login as user_login";
1413 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent_type as t, ".MAIN_DB_PREFIX.
"adherent as d";
1414 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as c ON d.country = c.rowid";
1415 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as dep ON d.state_id = dep.rowid";
1416 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON d.rowid = u.fk_member";
1417 $sql .=
" WHERE d.fk_adherent_type = t.rowid";
1419 $sql .=
" AND d.rowid=".((int) $rowid);
1420 } elseif ($ref || $fk_soc) {
1421 $sql .=
" AND d.entity IN (".getEntity(
'adherent').
")";
1423 $sql .=
" AND d.ref='".$this->db->escape($ref).
"'";
1424 } elseif ($fk_soc > 0) {
1425 $sql .=
" AND d.fk_soc=".((int) $fk_soc);
1427 } elseif ($ref_ext) {
1428 $sql .=
" AND d.ref_ext='".$this->db->escape($ref_ext).
"'";
1431 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
1432 $resql = $this->db->query($sql);
1434 if ($this->db->num_rows($resql)) {
1435 $obj = $this->db->fetch_object($resql);
1437 $this->entity = $obj->entity;
1438 $this->
id = $obj->rowid;
1439 $this->
ref = $obj->ref;
1440 $this->ref_ext = $obj->ref_ext;
1442 $this->civility_id = $obj->civility_code;
1443 $this->civility_code = $obj->civility_code;
1444 $this->civility = $obj->civility_code ? ($langs->trans(
"Civility".$obj->civility_code) !=
"Civility".$obj->civility_code ? $langs->trans(
"Civility".$obj->civility_code) : $obj->civility_code) :
'';
1446 $this->firstname = $obj->firstname;
1447 $this->lastname = $obj->lastname;
1448 $this->gender = $obj->gender;
1449 $this->login = $obj->login;
1450 $this->societe = $obj->company;
1451 $this->company = $obj->company;
1452 $this->socid = $obj->fk_soc;
1453 $this->fk_soc = $obj->fk_soc;
1454 $this->address = $obj->address;
1455 $this->zip = $obj->zip;
1456 $this->town = $obj->town;
1458 $this->pass = $obj->pass;
1459 $this->pass_indatabase = $obj->pass;
1460 $this->pass_indatabase_crypted = $obj->pass_crypted;
1462 $this->state_id = $obj->state_id;
1463 $this->state_code = $obj->state_id ? $obj->state_code :
'';
1464 $this->state = $obj->state_id ? $obj->state :
'';
1466 $this->country_id = $obj->country_id;
1467 $this->country_code = $obj->country_code;
1468 if ($langs->trans(
"Country".$obj->country_code) !=
"Country".$obj->country_code) {
1469 $this->country = $langs->transnoentitiesnoconv(
"Country".$obj->country_code);
1471 $this->country = $obj->country;
1474 $this->phone = $obj->phone;
1475 $this->phone_perso = $obj->phone_perso;
1476 $this->phone_mobile = $obj->phone_mobile;
1477 $this->email = $obj->email;
1478 $this->url = $obj->url;
1480 $this->socialnetworks = ($obj->socialnetworks ? (array) json_decode($obj->socialnetworks,
true) : array());
1482 $this->photo = $obj->photo;
1483 $this->
statut = $obj->statut;
1484 $this->
status = $obj->statut;
1485 $this->
public = $obj->public;
1487 $this->datec = $this->db->jdate($obj->datec);
1488 $this->date_creation = $this->db->jdate($obj->datec);
1489 $this->datem = $this->db->jdate($obj->datem);
1490 $this->date_modification = $this->db->jdate($obj->datem);
1491 $this->datefin = $this->db->jdate($obj->datefin);
1492 $this->datevalid = $this->db->jdate($obj->datev);
1493 $this->date_validation = $this->db->jdate($obj->datev);
1494 $this->birth = $this->db->jdate($obj->birthday);
1496 $this->default_lang = $obj->default_lang;
1498 $this->note_private = $obj->note_private;
1499 $this->note_public = $obj->note_public;
1500 $this->morphy = $obj->morphy;
1502 $this->
typeid = $obj->fk_adherent_type;
1503 $this->
type = $obj->type;
1504 $this->need_subscription = $obj->subscription;
1506 $this->user_id = $obj->user_id;
1507 $this->user_login = $obj->user_login;
1509 $this->model_pdf = $obj->model_pdf;
1513 if ($fetch_optionals) {
1518 if ($fetch_subscriptions) {
1527 $this->error = $this->db->lasterror();
1547 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
1549 $sql =
"SELECT c.rowid, c.fk_adherent, c.fk_type, c.subscription, c.note as note_public, c.fk_bank,";
1550 $sql .=
" c.tms as datem,";
1551 $sql .=
" c.datec as datec,";
1552 $sql .=
" c.dateadh as dateh,";
1553 $sql .=
" c.datef as datef";
1554 $sql .=
" FROM ".MAIN_DB_PREFIX.
"subscription as c";
1555 $sql .=
" WHERE c.fk_adherent = ".((int) $this->
id);
1556 $sql .=
" ORDER BY c.dateadh";
1557 dol_syslog(get_class($this).
"::fetch_subscriptions", LOG_DEBUG);
1559 $resql = $this->db->query($sql);
1561 $this->subscriptions = array();
1564 while ($obj = $this->db->fetch_object($resql)) {
1566 $this->first_subscription_date = $this->db->jdate($obj->datec);
1567 $this->first_subscription_date_start = $this->db->jdate($obj->dateh);
1568 $this->first_subscription_date_end = $this->db->jdate($obj->datef);
1569 $this->first_subscription_amount = $obj->subscription;
1571 $this->last_subscription_date = $this->db->jdate($obj->datec);
1572 $this->last_subscription_date_start = $this->db->jdate($obj->dateh);
1573 $this->last_subscription_date_end = $this->db->jdate($obj->datef);
1574 $this->last_subscription_amount = $obj->subscription;
1577 $subscription->id = $obj->rowid;
1578 $subscription->fk_adherent = $obj->fk_adherent;
1579 $subscription->fk_type = $obj->fk_type;
1580 $subscription->amount = $obj->subscription;
1581 $subscription->note = $obj->note_public;
1582 $subscription->note_public = $obj->note_public;
1583 $subscription->fk_bank = $obj->fk_bank;
1584 $subscription->datem = $this->db->jdate($obj->datem);
1585 $subscription->datec = $this->db->jdate($obj->datec);
1586 $subscription->dateh = $this->db->jdate($obj->dateh);
1587 $subscription->datef = $this->db->jdate($obj->datef);
1589 $this->subscriptions[] = $subscription;
1595 $this->error = $this->db->error().
' sql='.$sql;
1611 require_once DOL_DOCUMENT_ROOT.
'/partnership/class/partnership.class.php';
1614 $this->partnerships[] = array();
1635 public function subscription($date, $amount, $accountid = 0, $operation =
'', $label =
'', $num_chq =
'', $emetteur_nom =
'', $emetteur_banque =
'', $datesubend = 0, $fk_type =
null)
1637 global $conf, $langs, $user;
1639 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
1651 $datefin = $datesubend;
1660 $subscription->fk_adherent = $this->id;
1661 $subscription->dateh = $date;
1662 $subscription->datef = $datefin;
1663 $subscription->amount = $amount;
1664 $subscription->note = $label;
1665 $subscription->note_public = $label;
1666 $subscription->fk_type = $fk_type;
1668 $rowid = $subscription->create($user);
1675 $this->last_subscription_date =
dol_now();
1676 $this->last_subscription_date_start = $date;
1677 $this->last_subscription_date_end = $datefin;
1678 $this->last_subscription_amount = $amount;
1682 $this->db->commit();
1685 $this->db->rollback();
1690 $this->db->rollback();
1715 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 =
'')
1717 global $conf, $langs, $user, $mysoc;
1721 $this->invoice =
null;
1723 dol_syslog(
"subscriptionComplementaryActions subscriptionid=".$subscriptionid.
" option=".$option.
" accountid=".$accountid.
" datesubscription=".$datesubscription.
" paymentdate=".
1724 $paymentdate.
" label=".$label.
" amount=".$amount.
" num_chq=".$num_chq.
" autocreatethirdparty=".$autocreatethirdparty);
1727 if ($option ==
'bankdirect' && $accountid) {
1728 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
1730 $acct =
new Account($this->db);
1731 $result = $acct->fetch($accountid);
1733 $dateop = $paymentdate;
1735 $insertid = $acct->addline($dateop, $operation, $label, $amount, $num_chq,
'', $user, $emetteur_nom, $emetteur_banque);
1736 if ($insertid > 0) {
1737 $inserturlid = $acct->add_url_line($insertid, $this->
id, DOL_URL_ROOT.
'/adherents/card.php?rowid=', $this->getFullName($langs),
'member');
1738 if ($inserturlid > 0) {
1740 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"subscription SET fk_bank=".((int) $insertid);
1741 $sql .=
" WHERE rowid=".((int) $subscriptionid);
1743 dol_syslog(
"subscription::subscription", LOG_DEBUG);
1744 $resql = $this->db->query($sql);
1747 $this->error = $this->db->lasterror();
1748 $this->errors[] = $this->error;
1761 if (($option ==
'bankviainvoice' && $accountid) || $option ==
'invoiceonly') {
1762 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1763 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/paymentterm.class.php';
1765 $invoice =
new Facture($this->db);
1766 $customer =
new Societe($this->db);
1769 if (!($this->fk_soc > 0)) {
1770 if ($autocreatethirdparty) {
1775 if ($this->morphy ==
'mor') {
1776 $companyname = $this->company;
1777 if (!empty($fullname)) {
1778 $companyalias = $fullname;
1781 $companyname = $fullname;
1782 if (!empty($this->company)) {
1783 $companyalias = $this->company;
1787 $result = $customer->create_from_member($this, $companyname, $companyalias);
1789 $this->error = $customer->error;
1790 $this->errors = $customer->errors;
1793 $this->fk_soc = $result;
1796 $langs->load(
"errors");
1797 $this->error = $langs->trans(
"ErrorMemberNotLinkedToAThirpartyLinkOrCreateFirst");
1798 $this->errors[] = $this->error;
1804 $result = $customer->fetch($this->fk_soc);
1806 $this->error = $customer->error;
1807 $this->errors = $customer->errors;
1815 $invoice->cond_reglement_id = $customer->cond_reglement_id;
1816 if (empty($invoice->cond_reglement_id)) {
1818 $invoice->cond_reglement_id = $paymenttermstatic->getDefaultId();
1819 if (empty($invoice->cond_reglement_id)) {
1821 $this->error =
'ErrorNoPaymentTermRECEPFound';
1822 $this->errors[] = $this->error;
1825 $invoice->socid = $this->fk_soc;
1830 $invoice->linked_objects[
'subscription'] = $subscriptionid;
1832 $invoice->linked_objects = array_merge($invoice->linked_objects,
GETPOST(
'other_linked_objects',
'array:int'));
1835 $result = $invoice->create($user);
1837 $this->error = $invoice->error;
1838 $this->errors = $invoice->errors;
1841 $this->invoice = $invoice;
1847 $idprodsubscription = 0;
1848 if (
getDolGlobalString(
'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS') && (isModEnabled(
"product") || isModEnabled(
"service"))) {
1853 if (
getDolGlobalString(
'ADHERENT_VAT_FOR_SUBSCRIPTIONS') ==
'defaultforfoundationcountry') {
1858 $result = $invoice->addline($label, 0, 1, $vattouse, 0, 0, $idprodsubscription, 0, $datesubscription,
'', 0, 0,
'',
'TTC', $amount, 1);
1860 $this->error = $invoice->error;
1861 $this->errors = $invoice->errors;
1868 $result = $invoice->validate($user);
1870 $this->error = $invoice->error;
1871 $this->errors = $invoice->errors;
1881 if (!$error && $option ==
'bankviainvoice' && $accountid) {
1882 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1883 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
1884 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions.lib.php';
1887 $amounts[$invoice->id] = (float)
price2num($amount);
1889 $paiement =
new Paiement($this->db);
1890 $paiement->datepaye = $paymentdate;
1891 $paiement->amounts = $amounts;
1892 $paiement->paiementcode = $operation;
1893 $paiement->paiementid =
dol_getIdFromCode($this->db, $operation,
'c_paiement',
'code',
'id', 1);
1894 $paiement->num_payment = $num_chq;
1895 $paiement->note_public = $label;
1896 $paiement->ext_payment_id = $ext_payment_id;
1897 $paiement->ext_payment_site = $ext_payment_site;
1901 $paiement_id = $paiement->create($user);
1902 if (!($paiement_id > 0)) {
1903 $this->error = $paiement->error;
1904 $this->errors = $paiement->errors;
1911 $bank_line_id = $paiement->addPaymentToBank($user,
'payment',
'(SubscriptionPayment)', $accountid, $emetteur_nom, $emetteur_banque);
1912 if (!($bank_line_id > 0)) {
1913 $this->error = $paiement->error;
1914 $this->errors = $paiement->errors;
1919 if (!$error && !empty($bank_line_id)) {
1921 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'subscription SET fk_bank='.((int) $bank_line_id);
1922 $sql .=
' WHERE rowid='.((int) $subscriptionid);
1924 $result = $this->db->query($sql);
1932 $invoice->setPaid($user);
1938 $outputlangs = $langs;
1940 $lang_id =
GETPOST(
'lang_id');
1941 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && !empty($lang_id)) {
1942 $newlang = $lang_id;
1945 $newlang = $customer->default_lang;
1947 if (!empty($newlang)) {
1948 $outputlangs =
new Translate(
"", $conf);
1949 $outputlangs->setDefaultLang($newlang);
1954 $invoice->generateDocument($invoice->model_pdf, $outputlangs);
1974 global $langs, $conf;
1980 if ($this->
statut == self::STATUS_VALIDATED) {
1981 dol_syslog(get_class($this).
"::validate statut of member does not allow this", LOG_WARNING);
1987 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
1988 $sql .=
" statut = ".self::STATUS_VALIDATED;
1989 $sql .=
", datevalid = '".$this->db->idate($now).
"'";
1990 $sql .=
", fk_user_valid = ".((int) $user->id);
1991 $sql .=
" WHERE rowid = ".((int) $this->
id);
1993 dol_syslog(get_class($this).
"::validate", LOG_DEBUG);
1994 $result = $this->db->query($sql);
1999 $result = $this->
call_trigger(
'MEMBER_VALIDATE', $user);
2002 $this->db->rollback();
2007 $this->datevalid = $now;
2009 $this->db->commit();
2012 $this->error = $this->db->error();
2013 $this->db->rollback();
2027 global $langs, $conf;
2032 if ($this->
statut == self::STATUS_RESILIATED) {
2033 dol_syslog(get_class($this).
"::resiliate statut of member does not allow this", LOG_WARNING);
2039 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
2040 $sql .=
" statut = ".self::STATUS_RESILIATED;
2041 $sql .=
", fk_user_valid=".$user->id;
2042 $sql .=
" WHERE rowid = ".((int) $this->
id);
2044 $result = $this->db->query($sql);
2049 $result = $this->
call_trigger(
'MEMBER_RESILIATE', $user);
2052 $this->db->rollback();
2057 $this->db->commit();
2060 $this->error = $this->db->error();
2061 $this->db->rollback();
2080 if ($this->
statut == self::STATUS_EXCLUDED) {
2081 dol_syslog(get_class($this).
"::resiliate statut of member does not allow this", LOG_WARNING);
2087 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
2088 $sql .=
" statut = ".self::STATUS_EXCLUDED;
2089 $sql .=
", fk_user_valid=".$user->id;
2090 $sql .=
" WHERE rowid = ".((int) $this->
id);
2092 $result = $this->db->query($sql);
2097 $result = $this->
call_trigger(
'MEMBER_EXCLUDE', $user);
2100 $this->db->rollback();
2105 $this->db->commit();
2108 $this->error = $this->db->error();
2109 $this->db->rollback();
2125 include_once DOL_DOCUMENT_ROOT.
'/mailmanspip/class/mailmanspip.class.php';
2132 $result = $mailmanspip->add_to_mailman($this);
2135 if (!empty($mailmanspip->error)) {
2136 $this->errors[] = $mailmanspip->error;
2140 foreach ($mailmanspip->mladded_ko as $tmplist => $tmpemail) {
2141 $langs->load(
"errors");
2142 $this->errors[] = $langs->trans(
"ErrorFailedToAddToMailmanList", $tmpemail, $tmplist);
2144 foreach ($mailmanspip->mladded_ok as $tmplist => $tmpemail) {
2145 $langs->load(
"mailmanspip");
2146 $this->mesgs[] = $langs->trans(
"SuccessToAddToMailmanList", $tmpemail, $tmplist);
2152 $result = $mailmanspip->add_to_spip($this);
2154 $this->errors[] = $mailmanspip->error;
2175 global $conf, $langs;
2177 include_once DOL_DOCUMENT_ROOT.
'/mailmanspip/class/mailmanspip.class.php';
2184 $result = $mailmanspip->del_to_mailman($this);
2186 if (!empty($mailmanspip->error)) {
2187 $this->errors[] = $mailmanspip->error;
2192 foreach ($mailmanspip->mlremoved_ko as $tmplist => $tmpemail) {
2193 $langs->load(
"errors");
2194 $this->errors[] = $langs->trans(
"ErrorFailedToRemoveToMailmanList", $tmpemail, $tmplist);
2196 foreach ($mailmanspip->mlremoved_ok as $tmplist => $tmpemail) {
2197 $langs->load(
"mailmanspip");
2198 $this->mesgs[] = $langs->trans(
"SuccessToRemoveToMailmanList", $tmpemail, $tmplist);
2203 $result = $mailmanspip->del_to_spip($this);
2205 $this->errors[] = $mailmanspip->error;
2226 $langs->load(
"dict");
2228 $code = (empty($this->civility_id) ?
'' : $this->civility_id);
2232 return $langs->getLabelFromKey($this->db,
"Civility".$code,
"c_civility",
"code",
"label", $code);
2245 $langs->loadLangs([
'members',
'companies']);
2246 $nofetch = !empty($params[
'nofetch']);
2251 $langs->load(
"users");
2252 return [
'optimize' => $langs->trans(
"ShowUser")];
2254 if (!empty($this->photo)) {
2255 $photo =
'<div class="photointooltip floatright">';
2256 $photo .=
Form::showphoto(
'memberphoto', $this, 80, 0, 0,
'photoref photowithmargin photologintooltip',
'small', 0, 1);
2258 $datas[
'photo'] = $photo;
2261 $datas[
'divopen'] =
'<div class="centpercent">';
2262 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <u class="paddingrightonly">'.$langs->trans(
"Member").
'</u> '.$this->
getLibStatut(4);
2263 if (!empty($this->morphy)) {
2264 $datas[
'picto'] .=
' ' . $this->
getmorphylib(
'', 1);
2266 if (!empty($this->
ref)) {
2267 $datas[
'ref'] =
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
2269 if (!empty($this->login)) {
2270 $datas[
'login'] =
'<br><b>'.$langs->trans(
'Login').
':</b> '.$this->login;
2272 if (!empty($this->firstname) || !empty($this->lastname)) {
2273 $datas[
'name'] =
'<br><b>'.$langs->trans(
'Name').
':</b> '.$this->
getFullName($langs);
2275 if (!empty($this->company)) {
2276 $datas[
'company'] =
'<br><b>'.$langs->trans(
'Company').
':</b> '.$this->company;
2278 if (!empty($this->email)) {
2279 $datas[
'email'] =
'<br><b>'.$langs->trans(
"EMail").
':</b> '.$this->email;
2281 $datas[
'address'] =
'<br><b>'.$langs->trans(
"Address").
':</b> '.
dol_format_address($this, 1,
' ', $langs);
2283 if (isModEnabled(
'category') && !$nofetch) {
2284 require_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
2285 $form =
new Form($this->db);
2286 $datas[
'categories'] =
'<br>' . $form->showCategories($this->
id, Categorie::TYPE_MEMBER, 1);
2288 $datas[
'divclose'] =
'</div>';
2306 public function getNomUrl($withpictoimg = 0, $maxlen = 0, $option =
'card', $mode =
'', $morecss =
'', $save_lastsearch_value = -1, $notooltip = 0, $addlinktonotes = 0)
2308 global $conf, $langs, $hookmanager;
2317 $classfortooltip =
'classfortooltip';
2321 'objecttype' => $this->element,
2322 'option' => $option,
2326 $classfortooltip =
'classforajaxtooltip';
2327 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
2333 $url = DOL_URL_ROOT.
'/adherents/card.php?rowid='.((int) $this->
id);
2334 if ($option ==
'subscription') {
2335 $url = DOL_URL_ROOT.
'/adherents/subscription.php?rowid='.((int) $this->
id);
2338 if ($option !=
'nolink') {
2340 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
2341 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
2342 $add_save_lastsearch_values = 1;
2344 if ($add_save_lastsearch_values) {
2345 $url .=
'&save_lastsearch_values=1';
2349 $linkstart .=
'<a href="'.$url.
'"';
2351 if (empty($notooltip)) {
2353 $langs->load(
"users");
2354 $label = $langs->trans(
"ShowUser");
2355 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
2357 $linkclose .= ($label ?
' title="'.dol_escape_htmltag($label, 1).
'"' :
' title="tocomplete"');
2358 $linkclose .= $dataparams.
' class="'.$classfortooltip.($morecss ?
' '.$morecss :
'').
'"';
2361 $linkstart .= $linkclose.
'>';
2364 $result .= $linkstart;
2366 if ($withpictoimg) {
2367 $paddafterimage =
'';
2368 if (abs($withpictoimg) == 1 || abs($withpictoimg) == 4) {
2369 $morecss .=
' paddingrightonly';
2372 if ($withpictoimg > 0) {
2373 $picto =
'<span class="nopadding'.($morecss ?
' userimg'.$morecss :
'').
'">'.
img_object(
'',
'user', $paddafterimage.
' '.($notooltip ?
'' : $dataparams), 0, 0, $notooltip ? 0 : 1).
'</span>';
2376 $picto =
'<span class="nopadding'.($morecss ?
' userimg'.$morecss :
'').
'"'.($paddafterimage ?
' '.$paddafterimage :
'').
'>';
2377 $picto .=
Form::showphoto(
'memberphoto', $this, 0, 0, 0,
'userphoto'.(($withpictoimg == -3 || $withpictoimg == -4) ?
'small' :
''),
'mini', 0, 1);
2378 $picto .=
'</span>';
2382 if (($withpictoimg > -2 && $withpictoimg != 2) || $withpictoimg == -4) {
2384 $result .=
'<span class="nopadding valignmiddle'.((!isset($this->
statut) || $this->statut) ?
'' :
' strikefordisabled').
2385 ($morecss ?
' usertext'.$morecss :
'').
'">';
2387 if ($mode ==
'login') {
2388 $result .=
dol_trunc($this->login, $maxlen);
2389 } elseif ($mode ==
'ref') {
2390 $result .= $this->ref;
2392 $result .= $this->
getFullName($langs,
'', ($mode ==
'firstname' ? 2 : ($mode ==
'lastname' ? 4 : -1)), $maxlen);
2395 $result .=
'</span>';
2399 $result .= $linkend;
2401 if ($addlinktonotes) {
2402 if ($this->note_private) {
2403 $notetoshow = $langs->trans(
"ViewPrivateNote").
':<br>'.
dol_string_nohtmltag($this->note_private, 1);
2404 $result .=
' <span class="note inline-block">';
2405 $result .=
'<a href="'.DOL_URL_ROOT.
'/adherents/note.php?id='.$this->
id.
'" class="classfortooltip" title="'.
dol_escape_htmltag($notetoshow).
'">';
2408 $result .=
'</span>';
2412 $hookmanager->initHooks(array($this->element .
'dao'));
2413 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
2414 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
2416 $result = $hookmanager->resPrint;
2418 $result .= $hookmanager->resPrint;
2431 return $this->
LibStatut($this->
statut, $this->need_subscription, $this->datefin, $mode);
2444 public function LibStatut($status, $need_subscription, $date_end_subscription, $mode = 0)
2448 $langs->load(
"members");
2452 $labelStatusShort =
'';
2454 if ($status == self::STATUS_DRAFT) {
2455 $statusType =
'status0';
2456 $labelStatus = $langs->trans(
"MemberStatusDraft");
2457 $labelStatusShort = $langs->trans(
"MemberStatusDraftShort");
2458 } elseif ($status >= self::STATUS_VALIDATED) {
2459 if ($need_subscription === 0) {
2460 $statusType =
'status4';
2461 $labelStatus = $langs->trans(
"Validated").
' - '.$langs->trans(
"MemberStatusNoSubscription");
2462 $labelStatusShort = $langs->trans(
"MemberStatusNoSubscriptionShort");
2463 } elseif (!$date_end_subscription) {
2464 $statusType =
'status1';
2465 $labelStatus = $langs->trans(
"Validated").
' - '.$langs->trans(
"WaitingSubscription");
2466 $labelStatusShort = $langs->trans(
"WaitingSubscriptionShort");
2467 } elseif ($date_end_subscription <
dol_now()) {
2468 $statusType =
'status8';
2469 $labelStatus = $langs->trans(
"Validated").
' - '.$langs->trans(
"MemberStatusActiveLate");
2470 $labelStatusShort = $langs->trans(
"MemberStatusActiveLateShort");
2472 $statusType =
'status4';
2473 $labelStatus = $langs->trans(
"Validated").
' - '.$langs->trans(
"MemberStatusPaid");
2474 $labelStatusShort = $langs->trans(
"MemberStatusPaidShort");
2476 } elseif ($status == self::STATUS_RESILIATED) {
2477 $statusType =
'status6';
2478 $labelStatus = $langs->transnoentitiesnoconv(
"MemberStatusResiliated");
2479 $labelStatusShort = $langs->transnoentitiesnoconv(
"MemberStatusResiliatedShort");
2480 } elseif ($status == self::STATUS_EXCLUDED) {
2481 $statusType =
'status10';
2482 $labelStatus = $langs->transnoentitiesnoconv(
"MemberStatusExcluded");
2483 $labelStatusShort = $langs->transnoentitiesnoconv(
"MemberStatusExcludedShort");
2486 return dolGetStatus($labelStatus, $labelStatusShort,
'', $statusType, $mode);
2499 $this->nb = array();
2501 $sql =
"SELECT count(a.rowid) as nb";
2502 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as a";
2503 $sql .=
" WHERE a.statut > 0";
2504 $sql .=
" AND a.entity IN (".getEntity(
'adherent').
")";
2506 $resql = $this->db->query($sql);
2508 while ($obj = $this->db->fetch_object($resql)) {
2509 $this->nb[
"members"] = $obj->nb;
2511 $this->db->free($resql);
2515 $this->error = $this->db->error();
2531 global $conf, $langs;
2539 $sql =
"SELECT a.rowid, a.datefin, a.statut";
2540 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as a";
2541 $sql .=
", ".MAIN_DB_PREFIX.
"adherent_type as t";
2542 $sql .=
" WHERE a.fk_adherent_type = t.rowid";
2543 if ($mode ==
'expired') {
2544 $sql .=
" AND a.statut = ".self::STATUS_VALIDATED;
2545 $sql .=
" AND a.entity IN (".getEntity(
'adherent').
")";
2546 $sql .=
" AND ((a.datefin IS NULL or a.datefin < '".$this->db->idate($now).
"') AND t.subscription = '1')";
2547 } elseif ($mode ==
'shift') {
2548 $sql .=
" AND a.statut = ".self::STATUS_DRAFT;
2549 $sql .=
" AND a.entity IN (".getEntity(
'adherent').
")";
2552 $resql = $this->db->query($sql);
2554 $langs->load(
"members");
2561 if ($mode ==
'expired') {
2562 $warning_delay = $conf->adherent->subscription->warning_delay / 60 / 60 / 24;
2563 $label = $langs->trans(
"MembersWithSubscriptionToReceive");
2564 $labelShort = $langs->trans(
"MembersWithSubscriptionToReceiveShort");
2565 $url = DOL_URL_ROOT.
'/adherents/list.php?mainmenu=members&statut='.self::STATUS_VALIDATED.
'&filter=outofdate';
2566 } elseif ($mode ==
'shift') {
2567 $warning_delay = $conf->adherent->subscription->warning_delay / 60 / 60 / 24;
2568 $url = DOL_URL_ROOT.
'/adherents/list.php?mainmenu=members&statut='.
self::STATUS_DRAFT;
2569 $label = $langs->trans(
"MembersListToValid");
2570 $labelShort = $langs->trans(
"ToValidate");
2574 $response->warning_delay = $warning_delay;
2575 $response->label = $label;
2576 $response->labelShort = $labelShort;
2577 $response->url = $url;
2580 $adherentstatic =
new Adherent($this->db);
2582 while ($obj = $this->db->fetch_object($resql)) {
2583 $response->nbtodo++;
2585 $adherentstatic->datefin = $this->db->jdate($obj->datefin);
2586 $adherentstatic->statut = $obj->statut;
2588 if ($adherentstatic->hasDelay()) {
2589 $response->nbtodolate++;
2596 $this->error = $this->db->error();
2613 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams =
null)
2615 global $conf, $langs;
2617 $langs->load(
"orders");
2620 $modele =
'standard';
2622 if ($this->model_pdf) {
2623 $modele = $this->model_pdf;
2629 $modelpath =
"core/modules/member/doc/";
2631 return $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
2644 global $user, $langs;
2649 $this->
ref =
'ABC001';
2651 $this->specimen = 1;
2652 $this->civility_id =
'MR';
2653 $this->lastname =
'DOLIBARR';
2654 $this->firstname =
'SPECIMEN';
2655 $this->gender =
'man';
2656 $this->login =
'dolibspec';
2657 $this->pass =
'dolibspec';
2658 $this->company =
'Societe ABC';
2659 $this->address =
'61 jump street';
2660 $this->zip =
'75000';
2661 $this->town =
'Paris';
2662 $this->country_id = 1;
2663 $this->country_code =
'FR';
2664 $this->country =
'France';
2665 $this->morphy =
'mor';
2666 $this->email =
'specimen@specimen.com';
2667 $this->socialnetworks = array(
2668 'skype' =>
'skypepseudo',
2669 'twitter' =>
'twitterpseudo',
2670 'facebook' =>
'facebookpseudo',
2671 'linkedin' =>
'linkedinpseudo',
2673 $this->phone =
'0999999999';
2674 $this->phone_perso =
'0999999998';
2675 $this->phone_mobile =
'0999999997';
2676 $this->note_public =
'This is a public note';
2677 $this->note_private =
'This is a private note';
2678 $this->birth = $now;
2683 $this->datefin = $now;
2684 $this->datevalid = $now;
2685 $this->default_lang =
'';
2688 $this->
type =
'Type adherent';
2689 $this->need_subscription = 0;
2691 $this->first_subscription_date = $now;
2692 $this->first_subscription_date_start = $this->first_subscription_date;
2693 $this->first_subscription_date_end =
dol_time_plus_duree($this->first_subscription_date_start, 1,
'y');
2694 $this->first_subscription_amount = 10;
2696 $this->last_subscription_date = $this->first_subscription_date;
2697 $this->last_subscription_date_start = $this->first_subscription_date;
2698 $this->last_subscription_date_end =
dol_time_plus_duree($this->last_subscription_date_start, 1,
'y');
2699 $this->last_subscription_amount = 10;
2743 global $conf, $langs;
2747 $keymodified =
false;
2755 if ($this->morphy ==
'mor' && (empty($this->fullname) || $this->fullname == $this->company)) {
2756 $this->fullname = $this->company;
2757 $this->lastname = $this->company;
2762 'LDAP_MEMBER_FIELD_FULLNAME' =>
'fullname',
2763 'LDAP_MEMBER_FIELD_NAME' =>
'lastname',
2764 'LDAP_MEMBER_FIELD_LOGIN' =>
'login',
2765 'LDAP_MEMBER_FIELD_LOGIN_SAMBA' =>
'login',
2766 'LDAP_MEMBER_FIELD_MAIL' =>
'email'
2770 foreach ($ldapkey as $constname => $varname) {
2776 if (!empty($this->oldcopy) && $this->$varname != $this->oldcopy->$varname) {
2777 $keymodified =
true;
2803 foreach ($socialnetworks as $key => $value) {
2804 if ($this->socialnetworks[$value[
'label']] &&
getDolGlobalString(
'LDAP_MEMBER_FIELD_'.strtoupper($value[
'label']))) {
2805 $info[
getDolGlobalString(
'LDAP_MEMBER_FIELD_'.strtoupper($value[
'label']))] = $this->socialnetworks[$value[
'label']];
2832 if ($this->datefin &&
getDolGlobalString(
'LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION')) {
2837 if (!empty($this->pass)) {
2850 if ($this->pass_indatabase_crypted &&
getDolGlobalString(
'LDAP_MEMBER_FIELD_PASSWORD_CRYPTED')) {
2856 } elseif (!empty($this->pass_indatabase)) {
2868 if ($this->first_subscription_date &&
getDolGlobalString(
'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE')) {
2871 if (isset($this->first_subscription_amount) &&
getDolGlobalString(
'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT')) {
2872 $info[
getDolGlobalString(
'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT')] = $this->first_subscription_amount;
2874 if ($this->last_subscription_date &&
getDolGlobalString(
'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE')) {
2877 if (isset($this->last_subscription_amount) &&
getDolGlobalString(
'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT')) {
2878 $info[
getDolGlobalString(
'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT')] = $this->last_subscription_amount;
2893 $sql =
'SELECT a.rowid, a.datec as datec,';
2894 $sql .=
' a.datevalid as datev,';
2895 $sql .=
' a.tms as datem,';
2896 $sql .=
' a.fk_user_author, a.fk_user_valid, a.fk_user_mod';
2897 $sql .=
' FROM '.MAIN_DB_PREFIX.
'adherent as a';
2898 $sql .=
' WHERE a.rowid = '.((int) $id);
2900 dol_syslog(get_class($this).
"::info", LOG_DEBUG);
2901 $result = $this->db->query($sql);
2903 if ($this->db->num_rows($result)) {
2904 $obj = $this->db->fetch_object($result);
2906 $this->
id = $obj->rowid;
2908 $this->user_creation_id = $obj->fk_user_author;
2909 $this->user_validation_id = $obj->fk_user_valid;
2910 $this->user_modification_id = $obj->fk_user_mod;
2911 $this->date_creation = $this->db->jdate($obj->datec);
2912 $this->date_validation = $this->db->jdate($obj->datev);
2913 $this->date_modification = $this->db->jdate($obj->datem);
2916 $this->db->free($result);
2929 $sql =
"SELECT count(mc.email) as nb";
2930 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mailing_cibles as mc";
2931 $sql .=
" WHERE mc.email = '".$this->db->escape($this->email).
"'";
2932 $sql .=
" AND mc.statut NOT IN (-1,0)";
2934 $resql = $this->db->query($sql);
2936 $obj = $this->db->fetch_object($resql);
2939 $this->db->free($resql);
2942 $this->error = $this->db->error();
2959 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
2960 return parent::setCategoriesCommon($categories, Categorie::TYPE_MEMBER);
2973 $tables = array(
'adherent');
2988 if ($this->
statut != self::STATUS_VALIDATED) {
2991 if (!$this->datefin) {
2997 return $this->datefin < ($now - $conf->adherent->subscription->warning_delay);
3010 global $conf, $langs, $mysoc, $user;
3016 $blockingerrormsg =
'';
3018 if (!isModEnabled(
'member')) {
3019 $langs->load(
"agenda");
3020 $this->output = $langs->trans(
'ModuleNotEnabled', $langs->transnoentitiesnoconv(
"Adherent"));
3024 $langs->load(
"agenda");
3025 $this->output = $langs->trans(
'EventRemindersByEmailNotEnabled', $langs->transnoentitiesnoconv(
"Adherent"));
3033 $listofmembersok = array();
3034 $listofmembersko = array();
3036 $arraydaysbeforeend = explode(
';', $daysbeforeendlist);
3037 foreach ($arraydaysbeforeend as $daysbeforeend) {
3038 dol_syslog(__METHOD__.
' - Process delta = '.$daysbeforeend, LOG_DEBUG);
3040 if (!is_numeric($daysbeforeend)) {
3041 $blockingerrormsg =
"Value for delta is not a numeric value";
3048 $datetosearchforend =
dol_time_plus_duree(
dol_mktime(23, 59, 59, $tmp[
'mon'], $tmp[
'mday'], $tmp[
'year'],
'tzserver'), $daysbeforeend,
'd');
3050 $sql =
'SELECT rowid FROM '.MAIN_DB_PREFIX.
'adherent';
3051 $sql .=
" WHERE entity = ".((int) $conf->entity);
3052 $sql .=
" AND statut = 1";
3053 $sql .=
" AND datefin >= '".$this->db->idate($datetosearchfor).
"'";
3054 $sql .=
" AND datefin <= '".$this->db->idate($datetosearchforend).
"'";
3057 $resql = $this->db->query($sql);
3059 $num_rows = $this->db->num_rows($resql);
3061 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
3062 $adherent =
new Adherent($this->db);
3063 $formmail =
new FormMail($this->db);
3066 while ($i < $num_rows) {
3067 $obj = $this->db->fetch_object($resql);
3069 $adherent->fetch($obj->rowid,
'',
'',
'',
true,
true);
3071 if (empty($adherent->email)) {
3073 $listofmembersko[$adherent->id] = $adherent->id;
3075 $adherent->fetch_thirdparty();
3078 $languagefromcountrycode =
getLanguageCodeFromCountryCode($adherent->country_code ? $adherent->country_code : $adherent->thirdparty->country_code);
3079 $languagecodeformember = (empty($adherent->thirdparty->default_lang) ? ($languagefromcountrycode ? $languagefromcountrycode : $mysoc->default_lang) : $adherent->thirdparty->default_lang);
3082 $outputlangs =
new Translate(
'', $conf);
3083 $outputlangs->setDefaultLang($languagecodeformember);
3084 $outputlangs->loadLangs(array(
"main",
"members"));
3085 dol_syslog(
"sendReminderForExpiredSubscription Language for member id ".$adherent->id.
" set to ".$outputlangs->defaultlang.
" mysoc->default_lang=".$mysoc->default_lang);
3087 $arraydefaultmessage =
null;
3090 if (!empty($labeltouse)) {
3091 $arraydefaultmessage = $formmail->getEMailTemplate($this->db,
'member', $user, $outputlangs, 0, 1, $labeltouse);
3094 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
3099 $subject =
make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs);
3100 $msg =
make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs);
3102 $to = $adherent->email;
3105 $trackid =
'mem'.$adherent->id;
3106 $moreinheader =
'X-Dolibarr-Info: sendReminderForExpiredSubscription'.
"\r\n";
3108 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
3109 $cmail =
new CMailFile($subject, $to, $from, $msg, array(), array(), array(), $cc,
'', 0, 1,
'',
'', $trackid, $moreinheader);
3110 $result = $cmail->sendfile();
3113 $this->error .= $cmail->error.
' ';
3114 if (!is_null($cmail->errors)) {
3115 $this->errors += $cmail->errors;
3118 $listofmembersko[$adherent->id] = $adherent->id;
3121 $listofmembersok[$adherent->id] = $adherent->id;
3127 $actioncode =
'EMAIL';
3138 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic').
": ".$subject);
3139 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody').
":");
3143 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
3148 $actioncomm->type_code =
'AC_OTH_AUTO';
3149 $actioncomm->code =
'AC_'.$actioncode;
3150 $actioncomm->label = $actionmsg2;
3151 $actioncomm->note_private = $actionmsg;
3152 $actioncomm->fk_project = 0;
3153 $actioncomm->datep = $now;
3154 $actioncomm->datef = $now;
3155 $actioncomm->percentage = -1;
3156 $actioncomm->socid = $adherent->thirdparty->id;
3157 $actioncomm->contact_id = 0;
3158 $actioncomm->authorid = $user->id;
3159 $actioncomm->userownerid = $user->id;
3161 $actioncomm->email_msgid = $cmail->msgid;
3162 $actioncomm->email_from = $from;
3163 $actioncomm->email_sender =
'';
3164 $actioncomm->email_to = $to;
3165 $actioncomm->email_tocc = $sendtocc;
3166 $actioncomm->email_tobcc = $sendtobcc;
3167 $actioncomm->email_subject = $subject;
3168 $actioncomm->errors_to =
'';
3170 $actioncomm->fk_element = $adherent->id;
3171 $actioncomm->elementtype = $adherent->element;
3173 $actioncomm->extraparams = $extraparams;
3175 $actioncomm->create($user);
3181 $this->error .=
"Can't find email template with label=".$labeltouse.
", to use for the reminding email ";
3184 $listofmembersko[$adherent->id] = $adherent->id;
3193 $this->error = $this->db->lasterror();
3198 if ($blockingerrormsg) {
3199 $this->error = $blockingerrormsg;
3202 $this->output =
'Found '.($nbok + $nbko).
' members to send reminder to.';
3203 $this->output .=
' Send email successfully to '.$nbok.
' members';
3204 if (is_array($listofmembersok)) {
3207 foreach ($listofmembersok as $idmember) {
3209 $listofids .=
', ...';
3212 if (empty($listofids)) {
3217 $listofids .= $idmember;
3224 $this->output .= ($listofids ?
' ids='.$listofids :
'');
3227 $this->output .=
' - Canceled for '.$nbko.
' member (no email or email sending error)';
3228 if (is_array($listofmembersko)) {
3231 foreach ($listofmembersko as $idmember) {
3233 $listofids .=
', ...';
3236 if (empty($listofids)) {
3241 $listofids .= $idmember;
3247 $this->output .= ($listofids ?
' ids='.$listofids :
'');
3264 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
3266 $return =
'<div class="box-flex-item box-flex-grow-zero">';
3267 $return .=
'<div class="info-box info-box-sm">';
3268 $return .=
'<span class="info-box-icon bg-infobox-action">';
3269 if (property_exists($this,
'photo') || !empty($this->photo)) {
3270 $return .=
Form::showphoto(
'memberphoto', $this, 0, 60, 0,
'photokanban photoref photowithmargin photologintooltip',
'small', 0, 1);
3274 $return .=
'</span>';
3275 $return .=
'<div class="info-box-content">';
3276 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this,
'getNomUrl') ? $this->
getNomUrl() : $this->ref).
'</span>';
3277 if ($selected >= 0) {
3278 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
3280 if (property_exists($this,
'type')) {
3281 $return .=
'<br><span class="info-box-label opacitymedium">'.$this->type.
'</span>';
3283 if (method_exists($this,
'getmorphylib')) {
3284 $return .=
'<br><span class="info-box-label">'.$this->getmorphylib(
'', 2).
'</span>';
3286 if (method_exists($this,
'getLibStatut')) {
3287 $return .=
'<br><div class="info-box-status paddingtop">';
3288 $return .= $this->
LibStatut($this->
status, $this->need_subscription, $this->datefin, 5);
3289 $return .=
'</div>';
3291 $return .=
'</div>';
3292 $return .=
'</div>';
3293 $return .=
'</div>';
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
Or an array listing all the potential status of the object: array: int of the status => translated la...
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 exclude (set adherent.status to -2) a member TODO A private note should be added to know ...
add_to_abo()
Function to add member into external tools mailing-list, spip, etc.
loadStateBoard()
Load indicators this->nb in state board.
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 attributes 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.
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
Support class for thirdparties, contacts, members, users or resources.
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 information (by default a local PHP server timestamp) Rep...
getLanguageCodeFromCountryCode($countrycode)
Return default language from country code.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_format_address($object, $withcountry=0, $sep="\n", $outputlangs=null, $mode=0, $extralangcode='')
Return a formatted address (part address/zip/town/state) according to country rules.
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_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
GETPOSTISARRAY($paramname, $method=0)
Return true if the parameter $paramname is submit from a POST OR GET as an array.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
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...
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.
publicphonebutton2 phonegreen basiclayout basiclayout TotalHT VATCode TotalVAT TotalLT1 TotalLT2 TotalTTC TotalHT clearboth nowraponall TAKEPOS_SHOW_SUBPRICE right right right takeposterminal SELECT e e e e e statut