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;
141 public $socialnetworks;
161 public $phone_mobile;
187 public $default_lang;
236 public $need_subscription;
259 public $first_subscription_date;
264 public $first_subscription_date_start;
269 public $first_subscription_date_end;
274 public $first_subscription_amount;
279 public $last_subscription_date;
284 public $last_subscription_date_start;
289 public $last_subscription_date_end;
294 public $last_subscription_amount;
299 public $subscriptions = array();
311 public $partnerships = array();
322 public $fields = array(
323 'rowid' => array(
'type' =>
'integer',
'label' =>
'TechnicalID',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 10),
324 'ref' => array(
'type' =>
'varchar(30)',
'label' =>
'Ref',
'default' =>
'1',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'position' => 12,
'index' => 1),
325 'entity' => array(
'type' =>
'integer',
'label' =>
'Entity',
'default' =>
'1',
'enabled' => 1,
'visible' => -2,
'notnull' => 1,
'position' => 15,
'index' => 1),
326 'ref_ext' => array(
'type' =>
'varchar(128)',
'label' =>
'Ref ext',
'enabled' => 1,
'visible' => 0,
'position' => 20),
327 'civility' => array(
'type' =>
'varchar(6)',
'label' =>
'Civility',
'enabled' => 1,
'visible' => -1,
'position' => 25),
328 'lastname' => array(
'type' =>
'varchar(50)',
'label' =>
'Lastname',
'enabled' => 1,
'visible' => 1,
'position' => 30,
'showoncombobox' => 1),
329 'firstname' => array(
'type' =>
'varchar(50)',
'label' =>
'Firstname',
'enabled' => 1,
'visible' => 1,
'position' => 35,
'showoncombobox' => 1),
330 'login' => array(
'type' =>
'varchar(50)',
'label' =>
'Login',
'enabled' => 1,
'visible' => 1,
'position' => 40),
331 'pass' => array(
'type' =>
'varchar(50)',
'label' =>
'Pass',
'enabled' => 1,
'visible' => -1,
'position' => 45),
332 'pass_crypted' => array(
'type' =>
'varchar(128)',
'label' =>
'Pass crypted',
'enabled' => 1,
'visible' => -1,
'position' => 50),
333 'morphy' => array(
'type' =>
'varchar(3)',
'label' =>
'MemberNature',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'position' => 55),
334 'fk_adherent_type' => array(
'type' =>
'integer',
'label' =>
'Fk adherent type',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'position' => 60),
335 'societe' => array(
'type' =>
'varchar(128)',
'label' =>
'Societe',
'enabled' => 1,
'visible' => 1,
'position' => 65,
'showoncombobox' => 2),
336 'fk_soc' => array(
'type' =>
'integer:Societe:societe/class/societe.class.php',
'label' =>
'ThirdParty',
'enabled' => 1,
'visible' => 1,
'position' => 70),
337 'address' => array(
'type' =>
'text',
'label' =>
'Address',
'enabled' => 1,
'visible' => -1,
'position' => 75),
338 'zip' => array(
'type' =>
'varchar(10)',
'label' =>
'Zip',
'enabled' => 1,
'visible' => -1,
'position' => 80),
339 'town' => array(
'type' =>
'varchar(50)',
'label' =>
'Town',
'enabled' => 1,
'visible' => -1,
'position' => 85),
340 'state_id' => array(
'type' =>
'integer',
'label' =>
'State id',
'enabled' => 1,
'visible' => -1,
'position' => 90),
341 'country' => array(
'type' =>
'integer:Ccountry:core/class/ccountry.class.php',
'label' =>
'Country',
'enabled' => 1,
'visible' => 1,
'position' => 95),
342 'phone' => array(
'type' =>
'varchar(30)',
'label' =>
'Phone',
'enabled' => 1,
'visible' => -1,
'position' => 115),
343 'phone_perso' => array(
'type' =>
'varchar(30)',
'label' =>
'Phone perso',
'enabled' => 1,
'visible' => -1,
'position' => 120),
344 'phone_mobile' => array(
'type' =>
'varchar(30)',
'label' =>
'Phone mobile',
'enabled' => 1,
'visible' => -1,
'position' => 125),
345 'email' => array(
'type' =>
'varchar(255)',
'label' =>
'Email',
'enabled' => 1,
'visible' => 1,
'position' => 126),
346 'url' => array(
'type' =>
'varchar(255)',
'label' =>
'Url',
'enabled' => 1,
'visible' => -1,
'position' => 127),
347 'socialnetworks' => array(
'type' =>
'text',
'label' =>
'Socialnetworks',
'enabled' => 1,
'visible' => -1,
'position' => 128),
348 'birth' => array(
'type' =>
'date',
'label' =>
'DateOfBirth',
'enabled' => 1,
'visible' => -1,
'position' => 130),
349 'gender' => array(
'type' =>
'varchar(10)',
'label' =>
'Gender',
'enabled' => 1,
'visible' => -1,
'position' => 132),
350 'photo' => array(
'type' =>
'varchar(255)',
'label' =>
'Photo',
'enabled' => 1,
'visible' => -1,
'position' => 135),
351 'public' => array(
'type' =>
'smallint(6)',
'label' =>
'Public',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 145),
352 'datefin' => array(
'type' =>
'datetime',
'label' =>
'DateEnd',
'enabled' => 1,
'visible' => 1,
'position' => 150),
353 'default_lang' => array(
'type' =>
'varchar(6)',
'label' =>
'Default lang',
'enabled' => 1,
'visible' => -1,
'position' => 153),
354 'note_public' => array(
'type' =>
'text',
'label' =>
'NotePublic',
'enabled' => 1,
'visible' => 0,
'position' => 155),
355 'note_private' => array(
'type' =>
'text',
'label' =>
'NotePrivate',
'enabled' => 1,
'visible' => 0,
'position' => 160),
356 'datevalid' => array(
'type' =>
'datetime',
'label' =>
'DateValidation',
'enabled' => 1,
'visible' => -1,
'position' => 165),
357 'datec' => array(
'type' =>
'datetime',
'label' =>
'DateCreation',
'enabled' => 1,
'visible' => -1,
'position' => 170),
358 'tms' => array(
'type' =>
'timestamp',
'label' =>
'DateModification',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 175),
359 'fk_user_author' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'Fk user author',
'enabled' => 1,
'visible' => -1,
'position' => 180),
360 'fk_user_mod' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'Fk user mod',
'enabled' => 1,
'visible' => -1,
'position' => 185),
361 'fk_user_valid' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'UserValidation',
'enabled' => 1,
'visible' => -1,
'position' => 190),
362 'canvas' => array(
'type' =>
'varchar(32)',
'label' =>
'Canvas',
'enabled' => 1,
'visible' => -1,
'position' => 195),
363 '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')),
364 'model_pdf' => array(
'type' =>
'varchar(255)',
'label' =>
'Model pdf',
'enabled' => 1,
'visible' => 0,
'position' => 800),
365 'import_key' => array(
'type' =>
'varchar(14)',
'label' =>
'ImportId',
'enabled' => 1,
'visible' => -2,
'position' => 805)
398 $this->ismultientitymanaged = 1;
399 $this->isextrafieldmanaged = 1;
401 $this->array_options = array();
424 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 =
'')
427 dol_syslog(
'Warning using deprecated Adherent::send_an_email', LOG_WARNING);
429 return $this->
sendEmail($text, $subject, $filename_list, $mimetype_list, $mimefilename_list, $addr_cc, $addr_bcc, $deliveryreceipt, $msgishtml, $errors_to, $moreinheader);
449 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 =
'')
451 global
$conf, $langs;
454 if ($msgishtml == -1) {
461 dol_syslog(
'sendEmail msgishtml='.$msgishtml);
470 $from =
$conf->email_from;
475 $trackid =
'mem'.$this->id;
478 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
479 $mailfile =
new CMailFile($subjecttosend, $this->
email, $from, $texttosend, $filename_list, $mimetype_list, $mimefilename_list, $addr_cc, $addr_bcc, $deliveryreceipt, $msgishtml,
'',
'', $trackid, $moreinheader);
480 if ($mailfile->sendfile()) {
483 $this->error = $langs->trans(
"ErrorFailedToSendMail", $from, $this->
email).
'. '.$mailfile->error;
507 if ($this->civility_id) {
508 $infos .= $langs->transnoentities(
"UserTitle").
": ".$this->
getCivilityLabel().
"\n";
510 $infos .= $langs->transnoentities(
"id").
": ".$this->
id.
"\n";
511 $infos .= $langs->transnoentities(
"ref").
": ".$this->
ref.
"\n";
512 $infos .= $langs->transnoentities(
"Lastname").
": ".$this->lastname.
"\n";
513 $infos .= $langs->transnoentities(
"Firstname").
": ".$this->firstname.
"\n";
514 $infos .= $langs->transnoentities(
"Company").
": ".$this->company.
"\n";
515 $infos .= $langs->transnoentities(
"Address").
": ".$this->
address.
"\n";
516 $infos .= $langs->transnoentities(
"Zip").
": ".$this->zip.
"\n";
517 $infos .= $langs->transnoentities(
"Town").
": ".$this->town.
"\n";
518 $infos .= $langs->transnoentities(
"Country").
": ".$this->country.
"\n";
519 $infos .= $langs->transnoentities(
"EMail").
": ".$this->
email.
"\n";
520 $infos .= $langs->transnoentities(
"PhonePro").
": ".$this->phone.
"\n";
521 $infos .= $langs->transnoentities(
"PhonePerso").
": ".$this->phone_perso.
"\n";
522 $infos .= $langs->transnoentities(
"PhoneMobile").
": ".$this->phone_mobile.
"\n";
524 $infos .= $langs->transnoentities(
"Login").
": ".$this->login.
"\n";
525 $infos .= $langs->transnoentities(
"Password").
": ".$this->pass.
"\n";
527 $infos .= $langs->transnoentities(
"Birthday").
": ".$birthday.
"\n";
528 $infos .= $langs->transnoentities(
"Photo").
": ".$this->photo.
"\n";
529 $infos .= $langs->transnoentities(
"Public").
": ".
yn($this->
public);
532 $substitutionarray = array(
533 '__ID__' => $this->
id,
534 '__REF__' => $this->
ref,
535 '__MEMBER_ID__' => $this->
id,
537 '__FIRSTNAME__' => $msgishtml ?
dol_htmlentitiesbr($this->firstname) : ($this->firstname ? $this->firstname :
''),
538 '__LASTNAME__' => $msgishtml ?
dol_htmlentitiesbr($this->lastname) : ($this->lastname ? $this->lastname :
''),
540 '__COMPANY__' => $msgishtml ?
dol_htmlentitiesbr($this->company) : ($this->company ? $this->company :
''),
542 '__ZIP__' => $msgishtml ?
dol_htmlentitiesbr($this->zip) : ($this->zip ? $this->zip :
''),
543 '__TOWN__' => $msgishtml ?
dol_htmlentitiesbr($this->town) : ($this->town ? $this->town :
''),
544 '__COUNTRY__' => $msgishtml ?
dol_htmlentitiesbr($this->country) : ($this->country ? $this->country :
''),
546 '__BIRTH__' => $msgishtml ?
dol_htmlentitiesbr($birthday) : ($birthday ? $birthday :
''),
547 '__PHOTO__' => $msgishtml ?
dol_htmlentitiesbr($this->photo) : ($this->photo ? $this->photo :
''),
548 '__LOGIN__' => $msgishtml ?
dol_htmlentitiesbr($this->login) : ($this->login ? $this->login :
''),
549 '__PASSWORD__' => $msgishtml ?
dol_htmlentitiesbr($this->pass) : ($this->pass ? $this->pass :
''),
550 '__PHONE__' => $msgishtml ?
dol_htmlentitiesbr($this->phone) : ($this->phone ? $this->phone :
''),
551 '__PHONEPRO__' => $msgishtml ?
dol_htmlentitiesbr($this->phone_perso) : ($this->phone_perso ? $this->phone_perso :
''),
552 '__PHONEMOBILE__' => $msgishtml ?
dol_htmlentitiesbr($this->phone_mobile) : ($this->phone_mobile ? $this->phone_mobile :
''),
576 $morphy = $this->morphy;
580 $labeltoshowm = $langs->trans(
"Moral");
581 $labeltoshowp = $langs->trans(
"Physical");
582 if ($morphy ==
'phy') {
583 $labeltoshow = $labeltoshowp;
584 if ($addbadge == 2) {
590 $s .=
'<span class="member-individual-back paddingleftimp paddingrightimp" title="'.$langs->trans(
"Physical").
'">'.$labeltoshow.
'</span>';
592 if ($morphy ==
'mor') {
593 $labeltoshow = $labeltoshowm;
594 if ($addbadge == 2) {
600 $s .=
'<span class="member-company-back paddingleftimp paddingrightimp" title="'.$langs->trans(
"Moral").
'">'.$labeltoshow.
'</span>';
603 if ($morphy ==
'phy') {
604 $s = $langs->trans(
"Physical");
605 } elseif ($morphy ==
'mor') {
606 $s = $langs->trans(
"Moral");
620 public function create($user, $notrigger = 0)
622 global
$conf, $langs, $mysoc;
629 if (isset($this->import_key)) {
630 $this->import_key = trim($this->import_key);
635 $langs->load(
"errors");
636 $this->error = $langs->trans(
"ErrorBadEMail", $this->
email);
643 if (empty($this->login)) {
644 $this->error = $langs->trans(
"ErrorWrongValueForParameterX",
"Login");
655 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"adherent";
656 $sql .=
" (ref, datec,login,fk_user_author,fk_user_mod,fk_user_valid,morphy,fk_adherent_type,entity,import_key, ip)";
659 $sql .=
", '".$this->db->idate($this->datec).
"'";
660 $sql .=
", ".($this->login ?
"'".$this->db->escape($this->login).
"'" :
"null");
661 $sql .=
", ".($user->id > 0 ? $user->id :
"null");
662 $sql .=
", null, null, '".$this->db->escape($this->morphy).
"'";
663 $sql .=
", ".((int) $this->
typeid);
664 $sql .=
", ".((int) $this->entity);
665 $sql .=
", ".(!empty($this->import_key) ?
"'".$this->db->escape($this->import_key).
"'" :
"null");
666 $sql .=
", ".(!empty($this->ip) ?
"'".$this->db->escape($this->ip).
"'" :
"null");
669 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
670 $result = $this->db->query($sql);
672 $id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"adherent");
677 $this->
ref = (string) $id;
682 require_once $modfile;
684 $modCodeMember =
new $modname();
685 '@phan-var-force ModeleNumRefMembers $modCodeMember';
687 $this->
ref = $modCodeMember->getNextValue($mysoc, $this);
695 $result = $this->
update($user, 1, 1, 0, 0,
'add');
697 $this->db->rollback();
702 if ($this->user_id) {
704 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET";
705 $sql .=
" fk_member = ".((int) $this->
id);
706 $sql .=
" WHERE rowid = ".((int) $this->user_id);
707 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
708 $resql = $this->db->query($sql);
710 $this->error =
'Failed to update user to make link with member';
711 $this->db->rollback();
725 if (count($this->errors)) {
726 dol_syslog(get_class($this).
"::create ".implode(
',', $this->errors), LOG_ERR);
727 $this->db->rollback();
734 $this->error =
'Failed to get last insert id';
735 dol_syslog(get_class($this).
"::create ".$this->error, LOG_ERR);
736 $this->db->rollback();
740 $this->error = $this->db->error();
741 $this->db->rollback();
758 public function update($user, $notrigger = 0, $nosyncuser = 0, $nosyncuserpass = 0, $nosyncthirdparty = 0, $action =
'update')
760 global $langs, $hookmanager;
762 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
767 dol_syslog(get_class($this).
"::update notrigger=".$notrigger.
", nosyncuser=".$nosyncuser.
", nosyncuserpass=".$nosyncuserpass.
" nosyncthirdparty=".$nosyncthirdparty.
", email=".$this->email);
770 $this->lastname = trim($this->lastname) ? trim($this->lastname) : trim($this->lastname);
771 $this->firstname = trim($this->firstname) ? trim($this->firstname) : trim($this->firstname);
772 $this->gender = trim($this->gender);
780 $this->url = $this->url ?
clean_url($this->url, 0) :
'';
784 $langs->load(
"errors");
785 $this->error = $langs->trans(
"ErrorBadEMail", $this->
email);
791 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
792 $sql .=
" ref = '".$this->db->escape($this->
ref).
"'";
793 $sql .=
", civility = ".($this->civility_id ?
"'".$this->db->escape($this->civility_id).
"'" :
"null");
794 $sql .=
", firstname = ".($this->firstname ?
"'".$this->db->escape($this->firstname).
"'" :
"null");
795 $sql .=
", lastname = ".($this->lastname ?
"'".$this->db->escape($this->lastname).
"'" :
"null");
796 $sql .=
", gender = ".($this->gender != -1 ?
"'".$this->db->escape($this->gender).
"'" :
"null");
797 $sql .=
", login = ".($this->login ?
"'".$this->db->escape($this->login).
"'" :
"null");
798 $sql .=
", societe = ".($this->company ?
"'".$this->db->escape($this->company).
"'" : ($this->societe ?
"'".$this->db->escape($this->societe).
"'" :
"null"));
800 $sql .=
", fk_soc = ".($this->socid > 0 ? (int) $this->socid :
"null");
802 $sql .=
", address = ".($this->address ?
"'".$this->db->escape($this->
address).
"'" :
"null");
803 $sql .=
", zip = ".($this->zip ?
"'".$this->db->escape($this->zip).
"'" :
"null");
804 $sql .=
", town = ".($this->town ?
"'".$this->db->escape($this->town).
"'" :
"null");
805 $sql .=
", country = ".($this->country_id > 0 ? (int) $this->country_id :
"null");
806 $sql .=
", state_id = ".($this->state_id > 0 ? (int) $this->state_id :
"null");
807 $sql .=
", email = '".$this->db->escape($this->
email).
"'";
808 $sql .=
", url = ".(!empty($this->url) ?
"'".$this->db->escape($this->url).
"'" :
"null");
809 $sql .=
", socialnetworks = ".($this->socialnetworks ?
"'".$this->db->escape(json_encode($this->socialnetworks)).
"'" :
"null");
810 $sql .=
", phone = ".($this->phone ?
"'".$this->db->escape($this->phone).
"'" :
"null");
811 $sql .=
", phone_perso = ".($this->phone_perso ?
"'".$this->db->escape($this->phone_perso).
"'" :
"null");
812 $sql .=
", phone_mobile = ".($this->phone_mobile ?
"'".$this->db->escape($this->phone_mobile).
"'" :
"null");
813 $sql .=
", note_private = ".($this->note_private ?
"'".$this->db->escape($this->note_private).
"'" :
"null");
814 $sql .=
", note_public = ".($this->note_public ?
"'".$this->db->escape($this->note_public).
"'" :
"null");
815 $sql .=
", photo = ".($this->photo ?
"'".$this->db->escape($this->photo).
"'" :
"null");
816 $sql .=
", public = ".(int) $this->
public;
817 $sql .=
", statut = ".(int) $this->statut;
818 $sql .=
", default_lang = ".(!empty($this->default_lang) ?
"'".$this->db->escape($this->default_lang).
"'" :
"null");
819 $sql .=
", fk_adherent_type = ".(int) $this->
typeid;
820 $sql .=
", morphy = '".$this->db->escape($this->morphy).
"'";
821 $sql .=
", birth = ".($this->birth ?
"'".$this->db->idate($this->birth).
"'" :
"null");
823 if ($this->datefin) {
824 $sql .=
", datefin = '".$this->db->idate($this->datefin).
"'";
826 if ($this->datevalid) {
827 $sql .=
", datevalid = '".$this->db->idate($this->datevalid).
"'";
829 $sql .=
", fk_user_mod = ".($user->id > 0 ? $user->id :
'null');
830 $sql .=
" WHERE rowid = ".((int) $this->
id);
833 '@phan-var-force Adherent $oldcopy';
834 if (!empty($this->oldcopy) && $this->
typeid != $this->oldcopy->typeid) {
835 $sql2 =
"SELECT libelle as label";
836 $sql2 .=
" FROM ".MAIN_DB_PREFIX.
"adherent_type";
837 $sql2 .=
" WHERE rowid = ".((int) $this->
typeid);
838 $resql2 = $this->db->query($sql2);
840 while ($obj = $this->db->fetch_object($resql2)) {
841 $this->
type = $obj->label;
846 dol_syslog(get_class($this).
"::update update member", LOG_DEBUG);
847 $resql = $this->db->query($sql);
849 unset($this->country_code);
850 unset($this->country);
851 unset($this->state_code);
854 $nbrowsaffected += $this->db->affected_rows($resql);
867 if (!$error && $this->pass) {
868 dol_syslog(get_class($this).
"::update update password");
869 if ($this->pass != $this->pass_indatabase && $this->pass != $this->pass_indatabase_crypted) {
873 $result = $this->
setPassword($user, $this->pass, $isencrypted, $notrigger, $nosyncuserpass);
874 if (!$nbrowsaffected) {
882 dol_syslog(get_class($this).
"::update update link to user");
883 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = NULL WHERE fk_member = ".((int) $this->
id);
884 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
885 $resql = $this->db->query($sql);
887 $this->error = $this->db->error();
888 $this->db->rollback();
892 if ($this->user_id > 0) {
893 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = ".((int) $this->
id).
" WHERE rowid = ".((int) $this->user_id);
894 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
895 $resql = $this->db->query($sql);
897 $this->error = $this->db->error();
898 $this->db->rollback();
904 if (!$error && $nbrowsaffected) {
906 if (!$error && $this->user_id > 0 && !$nosyncuser) {
907 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
909 dol_syslog(get_class($this).
"::update update linked user");
911 $luser =
new User($this->db);
912 $result = $luser->fetch($this->user_id);
920 $luser->login = $this->login;
923 $luser->ref = $this->ref;
924 $luser->civility_id = $this->civility_id;
925 $luser->firstname = $this->firstname;
926 $luser->lastname = $this->lastname;
927 $luser->gender = $this->gender;
928 $luser->pass = $this->pass;
931 $luser->birth = $this->birth;
933 $luser->address = $this->address;
934 $luser->zip = $this->zip;
935 $luser->town = $this->town;
936 $luser->country_id = $this->country_id;
937 $luser->state_id = $this->state_id;
939 $luser->email = $this->email;
940 $luser->socialnetworks = $this->socialnetworks;
941 $luser->office_phone = $this->phone;
942 $luser->user_mobile = $this->phone_mobile;
944 $luser->lang = $this->default_lang;
946 $luser->fk_member = $this->id;
948 $result = $luser->update($user, 0, 1, 1);
950 $this->error = $luser->error;
951 dol_syslog(get_class($this).
"::update ".$this->error, LOG_ERR);
955 $this->error = $luser->error;
961 if (!$error && $this->fk_soc > 0 && !$nosyncthirdparty) {
962 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
964 dol_syslog(get_class($this).
"::update update linked thirdparty");
968 $lthirdparty =
new Societe($this->db);
969 $result = $lthirdparty->fetch($this->fk_soc);
972 $lthirdparty->address = $this->address;
973 $lthirdparty->zip = $this->zip;
974 $lthirdparty->town = $this->town;
975 $lthirdparty->email = $this->email;
976 $lthirdparty->socialnetworks = $this->socialnetworks;
977 $lthirdparty->phone = $this->phone;
978 $lthirdparty->state_id = $this->state_id;
979 $lthirdparty->country_id = $this->country_id;
981 $lthirdparty->default_lang = $this->default_lang;
983 $result = $lthirdparty->update($this->fk_soc, $user, 0, 1, 1,
'update');
986 $this->error = $lthirdparty->error;
987 $this->errors = $lthirdparty->errors;
988 dol_syslog(get_class($this).
"::update ".$this->error, LOG_ERR);
991 } elseif ($result < 0) {
992 $this->error = $lthirdparty->error;
998 if (!$error && !$notrigger) {
1008 $this->db->commit();
1009 return $nbrowsaffected;
1011 $this->db->rollback();
1015 $this->db->rollback();
1016 $this->error = $this->db->lasterror();
1036 $sql =
"SELECT rowid, datec as dateop, dateadh as datedeb, datef as datefin";
1037 $sql .=
" FROM ".MAIN_DB_PREFIX.
"subscription";
1038 $sql .=
" WHERE fk_adherent = ".((int) $this->
id);
1039 $sql .=
" ORDER by dateadh DESC";
1041 dol_syslog(get_class($this).
"::update_end_date", LOG_DEBUG);
1042 $resql = $this->db->query($sql);
1044 $obj = $this->db->fetch_object($resql);
1045 $dateop = $this->db->jdate($obj->dateop);
1046 $datedeb = $this->db->jdate($obj->datedeb);
1047 $datefin = $this->db->jdate($obj->datefin);
1049 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
1050 $sql .=
" datefin=".($datefin !=
'' ?
"'".$this->db->idate($datefin).
"'" :
"null");
1051 $sql .=
" WHERE rowid = ".((int) $this->
id);
1053 dol_syslog(get_class($this).
"::update_end_date", LOG_DEBUG);
1054 $resql = $this->db->query($sql);
1056 $this->last_subscription_date = $dateop;
1057 $this->last_subscription_date_start = $datedeb;
1058 $this->last_subscription_date_end = $datefin;
1059 $this->datefin = $datefin;
1060 $this->db->commit();
1063 $this->db->rollback();
1067 $this->error = $this->db->lasterror();
1068 $this->db->rollback();
1080 public function delete($user, $notrigger = 0)
1091 if (!$error && !$notrigger) {
1101 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"categorie_member WHERE fk_member = ".((int) $rowid);
1102 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1103 $resql = $this->db->query($sql);
1106 $this->error .= $this->db->lasterror();
1112 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"subscription WHERE fk_adherent = ".((int) $rowid);
1113 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1114 $resql = $this->db->query($sql);
1117 $this->error .= $this->db->lasterror();
1127 $this->error .= $this->db->lasterror();
1138 dol_syslog(get_class($this).
"::delete erreur ".$errorflag.
" ".$this->error, LOG_ERR);
1144 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"adherent WHERE rowid = ".((int) $rowid);
1145 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1146 $resql = $this->db->query($sql);
1149 $this->error .= $this->db->lasterror();
1155 $this->db->commit();
1158 $this->db->rollback();
1174 public function setPassword($user, $password =
'', $isencrypted = 0, $notrigger = 0, $nosyncuser = 0)
1176 global
$conf, $langs;
1180 dol_syslog(get_class($this).
"::setPassword user=".$user->id.
" password=".preg_replace(
'/./i',
'*', $password).
" isencrypted=".$isencrypted);
1184 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
1189 $password_crypted =
dol_hash($password);
1191 $password_indatabase =
'';
1192 if (!$isencrypted) {
1193 $password_indatabase = $password;
1199 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent";
1200 $sql .=
" SET pass_crypted = '".$this->db->escape($password_crypted).
"'";
1202 $sql .=
", pass = null";
1204 $sql .=
", pass = '".$this->db->escape($password_indatabase).
"'";
1206 $sql .=
" WHERE rowid = ".((int) $this->
id);
1209 dol_syslog(get_class($this).
"::setPassword", LOG_DEBUG);
1210 $result = $this->db->query($sql);
1212 $nbaffectedrows = $this->db->affected_rows($result);
1214 if ($nbaffectedrows) {
1215 $this->pass = $password;
1216 $this->pass_indatabase = $password_indatabase;
1217 $this->pass_indatabase_crypted = $password_crypted;
1219 if ($this->user_id && !$nosyncuser) {
1220 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
1224 $luser =
new User($this->db);
1225 $result = $luser->fetch($this->user_id);
1228 $result = $luser->setPassword($user, $this->pass, 0, 0, 1);
1229 if (is_int($result) && $result < 0) {
1230 $this->error = $luser->error;
1231 dol_syslog(get_class($this).
"::setPassword ".$this->error, LOG_ERR);
1235 $this->error = $luser->error;
1240 if (!$error && !$notrigger) {
1242 $result = $this->
call_trigger(
'MEMBER_NEW_PASSWORD', $user);
1245 $this->db->rollback();
1251 $this->db->commit();
1254 $this->db->rollback();
1258 $this->db->rollback();
1273 global
$conf, $langs;
1278 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = NULL WHERE fk_member = ".((int) $this->
id);
1279 dol_syslog(get_class($this).
"::setUserId", LOG_DEBUG);
1280 $resql = $this->db->query($sql);
1282 $this->error = $this->db->error();
1283 $this->db->rollback();
1289 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = ".((int) $this->
id);
1290 $sql .=
" WHERE rowid = ".((int) $userid);
1291 dol_syslog(get_class($this).
"::setUserId", LOG_DEBUG);
1292 $resql = $this->db->query($sql);
1294 $this->error = $this->db->error();
1295 $this->db->rollback();
1300 $this->db->commit();
1314 global
$conf, $langs;
1319 if ($thirdpartyid > 0) {
1320 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET fk_soc = null";
1321 $sql .=
" WHERE fk_soc = ".((int) $thirdpartyid);
1322 $sql .=
" AND entity = ".$conf->entity;
1323 dol_syslog(get_class($this).
"::setThirdPartyId", LOG_DEBUG);
1324 $resql = $this->db->query($sql);
1328 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET fk_soc = ".($thirdpartyid > 0 ? (int) $thirdpartyid :
'null');
1329 $sql .=
" WHERE rowid = ".((int) $this->
id);
1331 dol_syslog(get_class($this).
"::setThirdPartyId", LOG_DEBUG);
1332 $resql = $this->db->query($sql);
1334 $this->db->commit();
1337 $this->error = $this->db->error();
1338 $this->db->rollback();
1356 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"adherent";
1357 $sql .=
" WHERE login='".$this->db->escape($login).
"'";
1358 $sql .=
" AND entity = ".$conf->entity;
1360 $resql = $this->db->query($sql);
1362 if ($this->db->num_rows($resql)) {
1363 $obj = $this->db->fetch_object($resql);
1364 $this->
fetch($obj->rowid);
1384 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"adherent";
1385 $sql .=
" WHERE firstname='".$this->db->escape($firstname).
"'";
1386 $sql .=
" AND lastname='".$this->db->escape($lastname).
"'";
1387 $sql .=
" AND entity = ".$conf->entity;
1389 $resql = $this->db->query($sql);
1391 if ($this->db->num_rows($resql)) {
1392 $obj = $this->db->fetch_object($resql);
1393 $this->
fetch($obj->rowid);
1411 public function fetch($rowid, $ref =
'', $fk_soc = 0, $ref_ext =
'', $fetch_optionals =
true, $fetch_subscriptions =
true)
1415 $sql =
"SELECT d.rowid, d.ref, d.ref_ext, d.civility as civility_code, d.gender, d.firstname, d.lastname,";
1416 $sql .=
" d.societe as company, d.fk_soc, d.statut, d.public, d.address, d.zip, d.town, d.note_private,";
1417 $sql .=
" d.note_public,";
1418 $sql .=
" d.email, d.url, d.socialnetworks, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass, d.pass_crypted,";
1419 $sql .=
" d.photo, d.fk_adherent_type, d.morphy, d.entity,";
1420 $sql .=
" d.datec as datec,";
1421 $sql .=
" d.tms as datem,";
1422 $sql .=
" d.datefin as datefin, d.default_lang,";
1423 $sql .=
" d.birth as birthday,";
1424 $sql .=
" d.datevalid as datev,";
1425 $sql .=
" d.country,";
1426 $sql .=
" d.state_id,";
1427 $sql .=
" d.model_pdf,";
1428 $sql .=
" c.rowid as country_id, c.code as country_code, c.label as country,";
1429 $sql .=
" dep.nom as state, dep.code_departement as state_code,";
1430 $sql .=
" t.libelle as type, t.subscription as subscription,";
1431 $sql .=
" u.rowid as user_id, u.login as user_login";
1432 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent_type as t, ".MAIN_DB_PREFIX.
"adherent as d";
1433 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as c ON d.country = c.rowid";
1434 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as dep ON d.state_id = dep.rowid";
1435 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON d.rowid = u.fk_member";
1436 $sql .=
" WHERE d.fk_adherent_type = t.rowid";
1438 $sql .=
" AND d.rowid=".((int) $rowid);
1439 } elseif ($ref || $fk_soc) {
1440 $sql .=
" AND d.entity IN (".getEntity(
'adherent').
")";
1442 $sql .=
" AND d.ref='".$this->db->escape($ref).
"'";
1443 } elseif ($fk_soc > 0) {
1444 $sql .=
" AND d.fk_soc=".((int) $fk_soc);
1446 } elseif ($ref_ext) {
1447 $sql .=
" AND d.ref_ext='".$this->db->escape($ref_ext).
"'";
1450 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
1451 $resql = $this->db->query($sql);
1453 if ($this->db->num_rows($resql)) {
1454 $obj = $this->db->fetch_object($resql);
1456 $this->entity = $obj->entity;
1457 $this->
id = $obj->rowid;
1458 $this->
ref = $obj->ref;
1459 $this->ref_ext = $obj->ref_ext;
1461 $this->civility_id = $obj->civility_code;
1462 $this->civility_code = $obj->civility_code;
1463 $this->civility = $obj->civility_code ? ($langs->trans(
"Civility".$obj->civility_code) !=
"Civility".$obj->civility_code ? $langs->trans(
"Civility".$obj->civility_code) : $obj->civility_code) :
'';
1465 $this->firstname = $obj->firstname;
1466 $this->lastname = $obj->lastname;
1467 $this->gender = $obj->gender;
1468 $this->login = $obj->login;
1469 $this->societe = $obj->company;
1470 $this->company = $obj->company;
1471 $this->socid = $obj->fk_soc;
1472 $this->fk_soc = $obj->fk_soc;
1473 $this->
address = $obj->address;
1474 $this->zip = $obj->zip;
1475 $this->town = $obj->town;
1477 $this->pass = $obj->pass;
1478 $this->pass_indatabase = $obj->pass;
1479 $this->pass_indatabase_crypted = $obj->pass_crypted;
1481 $this->state_id = $obj->state_id;
1482 $this->state_code = $obj->state_id ? $obj->state_code :
'';
1483 $this->state = $obj->state_id ? $obj->state :
'';
1485 $this->country_id = $obj->country_id;
1486 $this->country_code = $obj->country_code;
1487 if ($langs->trans(
"Country".$obj->country_code) !=
"Country".$obj->country_code) {
1488 $this->country = $langs->transnoentitiesnoconv(
"Country".$obj->country_code);
1490 $this->country = $obj->country;
1493 $this->phone = $obj->phone;
1494 $this->phone_perso = $obj->phone_perso;
1495 $this->phone_mobile = $obj->phone_mobile;
1496 $this->
email = $obj->email;
1497 $this->url = $obj->url;
1499 $this->socialnetworks = ($obj->socialnetworks ? (array) json_decode($obj->socialnetworks,
true) : array());
1501 $this->photo = $obj->photo;
1502 $this->statut = $obj->statut;
1503 $this->
status = $obj->statut;
1504 $this->
public = $obj->public;
1506 $this->datec = $this->db->jdate($obj->datec);
1507 $this->date_creation = $this->db->jdate($obj->datec);
1508 $this->datem = $this->db->jdate($obj->datem);
1509 $this->date_modification = $this->db->jdate($obj->datem);
1510 $this->datefin = $this->db->jdate($obj->datefin);
1511 $this->datevalid = $this->db->jdate($obj->datev);
1512 $this->date_validation = $this->db->jdate($obj->datev);
1513 $this->birth = $this->db->jdate($obj->birthday);
1515 $this->default_lang = $obj->default_lang;
1517 $this->note_private = $obj->note_private;
1518 $this->note_public = $obj->note_public;
1519 $this->morphy = $obj->morphy;
1521 $this->
typeid = $obj->fk_adherent_type;
1522 $this->
type = $obj->type;
1523 $this->need_subscription = $obj->subscription;
1525 $this->user_id = $obj->user_id;
1526 $this->user_login = $obj->user_login;
1528 $this->model_pdf = $obj->model_pdf;
1532 if ($fetch_optionals) {
1537 if ($fetch_subscriptions) {
1546 $this->error = $this->db->lasterror();
1566 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
1568 $sql =
"SELECT c.rowid, c.fk_adherent, c.fk_type, c.subscription, c.note as note_public, c.fk_bank,";
1569 $sql .=
" c.tms as datem,";
1570 $sql .=
" c.datec as datec,";
1571 $sql .=
" c.dateadh as dateh,";
1572 $sql .=
" c.datef as datef";
1573 $sql .=
" FROM ".MAIN_DB_PREFIX.
"subscription as c";
1574 $sql .=
" WHERE c.fk_adherent = ".((int) $this->
id);
1575 $sql .=
" ORDER BY c.dateadh";
1576 dol_syslog(get_class($this).
"::fetch_subscriptions", LOG_DEBUG);
1578 $resql = $this->db->query($sql);
1580 $this->subscriptions = array();
1583 while ($obj = $this->db->fetch_object($resql)) {
1585 $this->first_subscription_date = $this->db->jdate($obj->datec);
1586 $this->first_subscription_date_start = $this->db->jdate($obj->dateh);
1587 $this->first_subscription_date_end = $this->db->jdate($obj->datef);
1588 $this->first_subscription_amount = $obj->subscription;
1590 $this->last_subscription_date = $this->db->jdate($obj->datec);
1591 $this->last_subscription_date_start = $this->db->jdate($obj->dateh);
1592 $this->last_subscription_date_end = $this->db->jdate($obj->datef);
1593 $this->last_subscription_amount = $obj->subscription;
1596 $subscription->id = $obj->rowid;
1597 $subscription->fk_adherent = $obj->fk_adherent;
1598 $subscription->fk_type = $obj->fk_type;
1599 $subscription->amount = $obj->subscription;
1600 $subscription->note = $obj->note_public;
1601 $subscription->note_public = $obj->note_public;
1602 $subscription->fk_bank = $obj->fk_bank;
1603 $subscription->datem = $this->db->jdate($obj->datem);
1604 $subscription->datec = $this->db->jdate($obj->datec);
1605 $subscription->dateh = $this->db->jdate($obj->dateh);
1606 $subscription->datef = $this->db->jdate($obj->datef);
1608 $this->subscriptions[] = $subscription;
1614 $this->error = $this->db->error().
' sql='.$sql;
1630 require_once DOL_DOCUMENT_ROOT.
'/partnership/class/partnership.class.php';
1633 $this->partnerships[] = array();
1654 public function subscription($date, $amount, $accountid = 0, $operation =
'', $label =
'', $num_chq =
'', $emetteur_nom =
'', $emetteur_banque =
'', $datesubend = 0, $fk_type =
null)
1656 global
$conf, $langs, $user;
1658 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
1670 $datefin = $datesubend;
1679 $subscription->fk_adherent = $this->id;
1680 $subscription->dateh = $date;
1681 $subscription->datef = $datefin;
1682 $subscription->amount = $amount;
1683 $subscription->note = $label;
1684 $subscription->note_public = $label;
1685 $subscription->fk_type = $fk_type;
1687 $rowid = $subscription->create($user);
1694 $this->last_subscription_date =
dol_now();
1695 $this->last_subscription_date_start = $date;
1696 $this->last_subscription_date_end = $datefin;
1697 $this->last_subscription_amount = $amount;
1701 $this->db->commit();
1704 $this->db->rollback();
1709 $this->db->rollback();
1734 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 =
'')
1736 global
$conf, $langs, $user, $mysoc;
1740 $this->invoice =
null;
1742 dol_syslog(
"subscriptionComplementaryActions subscriptionid=".$subscriptionid.
" option=".$option.
" accountid=".$accountid.
" datesubscription=".$datesubscription.
" paymentdate=".
1743 $paymentdate.
" label=".$label.
" amount=".$amount.
" num_chq=".$num_chq.
" autocreatethirdparty=".$autocreatethirdparty);
1746 if ($option ==
'bankdirect' && $accountid) {
1747 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
1749 $acct =
new Account($this->db);
1750 $result = $acct->fetch($accountid);
1752 $dateop = $paymentdate;
1754 $insertid = $acct->addline($dateop, $operation, $label, $amount, $num_chq, 0, $user, $emetteur_nom, $emetteur_banque);
1755 if ($insertid > 0) {
1756 $inserturlid = $acct->add_url_line($insertid, $this->
id, DOL_URL_ROOT.
'/adherents/card.php?rowid=', $this->getFullName($langs),
'member');
1757 if ($inserturlid > 0) {
1759 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"subscription SET fk_bank=".((int) $insertid);
1760 $sql .=
" WHERE rowid=".((int) $subscriptionid);
1762 dol_syslog(
"subscription::subscription", LOG_DEBUG);
1763 $resql = $this->db->query($sql);
1766 $this->error = $this->db->lasterror();
1767 $this->errors[] = $this->error;
1780 if (($option ==
'bankviainvoice' && $accountid) || $option ==
'invoiceonly') {
1781 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1782 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/paymentterm.class.php';
1784 $invoice =
new Facture($this->db);
1785 $customer =
new Societe($this->db);
1788 if (!($this->fk_soc > 0)) {
1789 if ($autocreatethirdparty) {
1794 if ($this->morphy ==
'mor') {
1795 $companyname = $this->company;
1796 if (!empty($fullname)) {
1797 $companyalias = $fullname;
1800 $companyname = $fullname;
1801 if (!empty($this->company)) {
1802 $companyalias = $this->company;
1806 $result = $customer->create_from_member($this, $companyname, $companyalias);
1808 $this->error = $customer->error;
1809 $this->errors = $customer->errors;
1812 $this->fk_soc = $result;
1815 $langs->load(
"errors");
1816 $this->error = $langs->trans(
"ErrorMemberNotLinkedToAThirpartyLinkOrCreateFirst");
1817 $this->errors[] = $this->error;
1823 $result = $customer->fetch($this->fk_soc);
1825 $this->error = $customer->error;
1826 $this->errors = $customer->errors;
1834 $invoice->cond_reglement_id = $customer->cond_reglement_id;
1835 if (empty($invoice->cond_reglement_id)) {
1837 $invoice->cond_reglement_id = $paymenttermstatic->getDefaultId();
1838 if (empty($invoice->cond_reglement_id)) {
1840 $this->error =
'ErrorNoPaymentTermRECEPFound';
1841 $this->errors[] = $this->error;
1844 $invoice->socid = $this->fk_soc;
1846 if (!empty($customer->fk_account)) {
1847 $invoice->fk_account = $customer->fk_account;
1853 if (!empty($customer->mode_reglement_id)) {
1854 $invoice->mode_reglement_id = $customer->mode_reglement_id;
1860 $invoice->linked_objects[
'subscription'] = $subscriptionid;
1862 $invoice->linked_objects = array_merge($invoice->linked_objects,
GETPOST(
'other_linked_objects',
'array:int'));
1865 $result = $invoice->create($user);
1867 $this->error = $invoice->error;
1868 $this->errors = $invoice->errors;
1871 $this->invoice = $invoice;
1877 $idprodsubscription = 0;
1878 if (
getDolGlobalString(
'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS') && (isModEnabled(
"product") || isModEnabled(
"service"))) {
1883 if (
getDolGlobalString(
'ADHERENT_VAT_FOR_SUBSCRIPTIONS') ==
'defaultforfoundationcountry') {
1888 $result = $invoice->addline($label, 0, 1, $vattouse, 0, 0, $idprodsubscription, 0, $datesubscription,
'', 0, 0, 0,
'TTC', $amount, 1);
1890 $this->error = $invoice->error;
1891 $this->errors = $invoice->errors;
1898 $result = $invoice->validate($user);
1900 $this->error = $invoice->error;
1901 $this->errors = $invoice->errors;
1911 if (!$error && $option ==
'bankviainvoice' && $accountid) {
1912 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1913 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
1914 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions.lib.php';
1917 $amounts[$invoice->id] = (float)
price2num($amount);
1919 $paiement =
new Paiement($this->db);
1920 $paiement->datepaye = $paymentdate;
1921 $paiement->amounts = $amounts;
1922 $paiement->paiementcode = $operation;
1923 $paiement->paiementid =
dol_getIdFromCode($this->db, $operation,
'c_paiement',
'code',
'id', 1);
1924 $paiement->num_payment = $num_chq;
1925 $paiement->note_public = $label;
1926 $paiement->ext_payment_id = $ext_payment_id;
1927 $paiement->ext_payment_site = $ext_payment_site;
1931 $paiement_id = $paiement->create($user);
1932 if (!($paiement_id > 0)) {
1933 $this->error = $paiement->error;
1934 $this->errors = $paiement->errors;
1941 $bank_line_id = $paiement->addPaymentToBank($user,
'payment',
'(SubscriptionPayment)', $accountid, $emetteur_nom, $emetteur_banque);
1942 if (!($bank_line_id > 0)) {
1943 $this->error = $paiement->error;
1944 $this->errors = $paiement->errors;
1949 if (!$error && !empty($bank_line_id)) {
1951 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'subscription SET fk_bank='.((int) $bank_line_id);
1952 $sql .=
' WHERE rowid='.((int) $subscriptionid);
1954 $result = $this->db->query($sql);
1962 $invoice->setPaid($user);
1968 $outputlangs = $langs;
1970 $lang_id =
GETPOST(
'lang_id');
1971 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && !empty($lang_id)) {
1972 $newlang = $lang_id;
1975 $newlang = $customer->default_lang;
1977 if (!empty($newlang)) {
1979 $outputlangs->setDefaultLang($newlang);
1984 $invoice->generateDocument($invoice->model_pdf, $outputlangs);
2004 global $langs,
$conf;
2010 if ($this->statut == self::STATUS_VALIDATED) {
2011 dol_syslog(get_class($this).
"::validate statut of member does not allow this", LOG_WARNING);
2017 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
2018 $sql .=
" statut = ".self::STATUS_VALIDATED;
2019 $sql .=
", datevalid = '".$this->db->idate($now).
"'";
2020 $sql .=
", fk_user_valid = ".((int) $user->id);
2021 $sql .=
" WHERE rowid = ".((int) $this->
id);
2023 dol_syslog(get_class($this).
"::validate", LOG_DEBUG);
2024 $result = $this->db->query($sql);
2029 $result = $this->
call_trigger(
'MEMBER_VALIDATE', $user);
2032 $this->db->rollback();
2037 $this->datevalid = $now;
2039 $this->db->commit();
2042 $this->error = $this->db->error();
2043 $this->db->rollback();
2057 global $langs,
$conf;
2062 if ($this->statut == self::STATUS_RESILIATED) {
2063 dol_syslog(get_class($this).
"::resiliate statut of member does not allow this", LOG_WARNING);
2069 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
2070 $sql .=
" statut = ".self::STATUS_RESILIATED;
2071 $sql .=
", fk_user_valid=".$user->id;
2072 $sql .=
" WHERE rowid = ".((int) $this->
id);
2074 $result = $this->db->query($sql);
2079 $result = $this->
call_trigger(
'MEMBER_RESILIATE', $user);
2082 $this->db->rollback();
2087 $this->db->commit();
2090 $this->error = $this->db->error();
2091 $this->db->rollback();
2110 if ($this->statut == self::STATUS_EXCLUDED) {
2111 dol_syslog(get_class($this).
"::resiliate statut of member does not allow this", LOG_WARNING);
2117 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
2118 $sql .=
" statut = ".self::STATUS_EXCLUDED;
2119 $sql .=
", fk_user_valid=".$user->id;
2120 $sql .=
" WHERE rowid = ".((int) $this->
id);
2122 $result = $this->db->query($sql);
2127 $result = $this->
call_trigger(
'MEMBER_EXCLUDE', $user);
2130 $this->db->rollback();
2135 $this->db->commit();
2138 $this->error = $this->db->error();
2139 $this->db->rollback();
2155 include_once DOL_DOCUMENT_ROOT.
'/mailmanspip/class/mailmanspip.class.php';
2162 $result = $mailmanspip->add_to_mailman($this);
2165 if (!empty($mailmanspip->error)) {
2166 $this->errors[] = $mailmanspip->error;
2170 foreach ($mailmanspip->mladded_ko as $tmplist => $tmpemail) {
2171 $langs->load(
"errors");
2172 $this->errors[] = $langs->trans(
"ErrorFailedToAddToMailmanList", $tmpemail, $tmplist);
2174 foreach ($mailmanspip->mladded_ok as $tmplist => $tmpemail) {
2175 $langs->load(
"mailmanspip");
2176 $this->mesgs[] = $langs->trans(
"SuccessToAddToMailmanList", $tmpemail, $tmplist);
2182 $result = $mailmanspip->add_to_spip($this);
2184 $this->errors[] = $mailmanspip->error;
2205 global
$conf, $langs;
2207 include_once DOL_DOCUMENT_ROOT.
'/mailmanspip/class/mailmanspip.class.php';
2214 $result = $mailmanspip->del_to_mailman($this);
2216 if (!empty($mailmanspip->error)) {
2217 $this->errors[] = $mailmanspip->error;
2222 foreach ($mailmanspip->mlremoved_ko as $tmplist => $tmpemail) {
2223 $langs->load(
"errors");
2224 $this->errors[] = $langs->trans(
"ErrorFailedToRemoveToMailmanList", $tmpemail, $tmplist);
2226 foreach ($mailmanspip->mlremoved_ok as $tmplist => $tmpemail) {
2227 $langs->load(
"mailmanspip");
2228 $this->mesgs[] = $langs->trans(
"SuccessToRemoveToMailmanList", $tmpemail, $tmplist);
2233 $result = $mailmanspip->del_to_spip($this);
2235 $this->errors[] = $mailmanspip->error;
2256 $langs->load(
"dict");
2258 $code = (empty($this->civility_id) ?
'' : $this->civility_id);
2262 return $langs->getLabelFromKey($this->db,
"Civility".$code,
"c_civility",
"code",
"label", $code);
2275 $langs->loadLangs([
'members',
'companies']);
2276 $nofetch = !empty($params[
'nofetch']);
2281 $langs->load(
"users");
2282 return [
'optimize' => $langs->trans(
"ShowUser")];
2284 if (!empty($this->photo)) {
2285 $photo =
'<div class="photointooltip floatright">';
2286 $photo .=
Form::showphoto(
'memberphoto', $this, 80, 0, 0,
'photoref photowithmargin photologintooltip',
'small', 0, 1);
2288 $datas[
'photo'] = $photo;
2291 $datas[
'divopen'] =
'<div class="centpercent">';
2292 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <u class="paddingrightonly">'.$langs->trans(
"Member").
'</u> '.$this->
getLibStatut(4);
2293 if (!empty($this->morphy)) {
2294 $datas[
'picto'] .=
' ' . $this->
getmorphylib(
'', 1);
2296 if (!empty($this->
ref)) {
2297 $datas[
'ref'] =
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
2299 if (!empty($this->login)) {
2300 $datas[
'login'] =
'<br><b>'.$langs->trans(
'Login').
':</b> '.$this->login;
2302 if (!empty($this->firstname) || !empty($this->lastname)) {
2303 $datas[
'name'] =
'<br><b>'.$langs->trans(
'Name').
':</b> '.$this->
getFullName($langs);
2305 if (!empty($this->company)) {
2306 $datas[
'company'] =
'<br><b>'.$langs->trans(
'Company').
':</b> '.$this->company;
2308 if (!empty($this->
email)) {
2309 $datas[
'email'] =
'<br><b>'.$langs->trans(
"EMail").
':</b> '.$this->email;
2311 $datas[
'address'] =
'<br><b>'.$langs->trans(
"Address").
':</b> '.
dol_format_address($this, 1,
' ', $langs);
2313 if (isModEnabled(
'category') && !$nofetch) {
2314 require_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
2315 $form =
new Form($this->db);
2316 $datas[
'categories'] =
'<br>' . $form->showCategories($this->
id, Categorie::TYPE_MEMBER, 1);
2318 $datas[
'divclose'] =
'</div>';
2336 public function getNomUrl($withpictoimg = 0, $maxlen = 0, $option =
'card', $mode =
'', $morecss =
'', $save_lastsearch_value = -1, $notooltip = 0, $addlinktonotes = 0)
2338 global
$conf, $langs, $hookmanager;
2347 $classfortooltip =
'classfortooltip';
2351 'objecttype' => $this->element,
2352 'option' => $option,
2356 $classfortooltip =
'classforajaxtooltip';
2357 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
2363 $url = DOL_URL_ROOT.
'/adherents/card.php?rowid='.((int) $this->
id);
2364 if ($option ==
'subscription') {
2365 $url = DOL_URL_ROOT.
'/adherents/subscription.php?rowid='.((int) $this->
id);
2368 if ($option !=
'nolink') {
2370 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
2371 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
2372 $add_save_lastsearch_values = 1;
2374 if ($add_save_lastsearch_values) {
2375 $url .=
'&save_lastsearch_values=1';
2379 $linkstart .=
'<a href="'.$url.
'"';
2381 if (empty($notooltip)) {
2383 $langs->load(
"users");
2384 $label = $langs->trans(
"ShowUser");
2385 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
2387 $linkclose .= ($label ?
' title="'.dol_escape_htmltag($label, 1).
'"' :
' title="tocomplete"');
2388 $linkclose .= $dataparams.
' class="'.$classfortooltip.($morecss ?
' '.$morecss :
'').
'"';
2391 $linkstart .= $linkclose.
'>';
2394 $result .= $linkstart;
2396 if ($withpictoimg) {
2397 $paddafterimage =
'';
2398 if (abs($withpictoimg) == 1 || abs($withpictoimg) == 4) {
2399 $morecss .=
' paddingrightonly';
2402 if ($withpictoimg > 0) {
2403 $picto =
'<span class="nopadding'.($morecss ?
' userimg'.$morecss :
'').
'">'.
img_object(
'',
'user', $paddafterimage.
' '.($notooltip ?
'' : $dataparams), 0, 0, $notooltip ? 0 : 1).
'</span>';
2406 $picto =
'<span class="nopadding'.($morecss ?
' userimg'.$morecss :
'').
'"'.($paddafterimage ?
' '.$paddafterimage :
'').
'>';
2407 $picto .=
Form::showphoto(
'memberphoto', $this, 0, 0, 0,
'userphoto'.(($withpictoimg == -3 || $withpictoimg == -4) ?
'small' :
''),
'mini', 0, 1);
2408 $picto .=
'</span>';
2412 if (($withpictoimg > -2 && $withpictoimg != 2) || $withpictoimg == -4) {
2414 $result .=
'<span class="nopadding valignmiddle'.((!isset($this->statut) || $this->statut) ?
'' :
' strikefordisabled').
2415 ($morecss ?
' usertext'.$morecss :
'').
'">';
2417 if ($mode ==
'login') {
2418 $result .=
dol_trunc($this->login, $maxlen);
2419 } elseif ($mode ==
'ref') {
2420 $result .= $this->ref;
2422 $result .= $this->
getFullName($langs, 0, ($mode ==
'firstname' ? 2 : ($mode ==
'lastname' ? 4 : -1)), $maxlen);
2425 $result .=
'</span>';
2429 $result .= $linkend;
2431 if ($addlinktonotes) {
2432 if ($this->note_private) {
2433 $notetoshow = $langs->trans(
"ViewPrivateNote").
':<br>'.
dol_string_nohtmltag($this->note_private, 1);
2434 $result .=
' <span class="note inline-block">';
2435 $result .=
'<a href="'.DOL_URL_ROOT.
'/adherents/note.php?id='.$this->
id.
'" class="classfortooltip" title="'.
dol_escape_htmltag($notetoshow).
'">';
2438 $result .=
'</span>';
2442 $hookmanager->initHooks(array($this->element .
'dao'));
2443 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
2444 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
2446 $result = $hookmanager->resPrint;
2448 $result .= $hookmanager->resPrint;
2461 return $this->
LibStatut($this->statut, $this->need_subscription, $this->datefin, $mode);
2474 public function LibStatut($status, $need_subscription, $date_end_subscription, $mode = 0)
2478 $langs->load(
"members");
2482 $labelStatusShort =
'';
2484 if ($status == self::STATUS_DRAFT) {
2485 $statusType =
'status0';
2486 $labelStatus = $langs->trans(
"MemberStatusDraft");
2487 $labelStatusShort = $langs->trans(
"MemberStatusDraftShort");
2488 } elseif ($status >= self::STATUS_VALIDATED) {
2489 if ($need_subscription === 0) {
2490 $statusType =
'status4';
2491 $labelStatus = $langs->trans(
"Validated").
' - '.$langs->trans(
"MemberStatusNoSubscription");
2492 $labelStatusShort = $langs->trans(
"MemberStatusNoSubscriptionShort");
2493 } elseif (!$date_end_subscription) {
2494 $statusType =
'status1';
2495 $labelStatus = $langs->trans(
"Validated").
' - '.$langs->trans(
"WaitingSubscription");
2496 $labelStatusShort = $langs->trans(
"WaitingSubscriptionShort");
2497 } elseif ($date_end_subscription <
dol_now()) {
2498 $statusType =
'status8';
2499 $labelStatus = $langs->trans(
"Validated").
' - '.$langs->trans(
"MemberStatusActiveLate");
2500 $labelStatusShort = $langs->trans(
"MemberStatusActiveLateShort");
2502 $statusType =
'status4';
2503 $labelStatus = $langs->trans(
"Validated").
' - '.$langs->trans(
"MemberStatusPaid");
2504 $labelStatusShort = $langs->trans(
"MemberStatusPaidShort");
2506 } elseif ($status == self::STATUS_RESILIATED) {
2507 $statusType =
'status6';
2508 $labelStatus = $langs->transnoentitiesnoconv(
"MemberStatusResiliated");
2509 $labelStatusShort = $langs->transnoentitiesnoconv(
"MemberStatusResiliatedShort");
2510 } elseif ($status == self::STATUS_EXCLUDED) {
2511 $statusType =
'status10';
2512 $labelStatus = $langs->transnoentitiesnoconv(
"MemberStatusExcluded");
2513 $labelStatusShort = $langs->transnoentitiesnoconv(
"MemberStatusExcludedShort");
2516 return dolGetStatus($labelStatus, $labelStatusShort,
'', $statusType, $mode);
2529 $this->nb = array();
2531 $sql =
"SELECT count(a.rowid) as nb";
2532 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as a";
2533 $sql .=
" WHERE a.statut > 0";
2534 $sql .=
" AND a.entity IN (".getEntity(
'adherent').
")";
2536 $resql = $this->db->query($sql);
2538 while ($obj = $this->db->fetch_object($resql)) {
2539 $this->nb[
"members"] = $obj->nb;
2541 $this->db->free($resql);
2545 $this->error = $this->db->error();
2561 global
$conf, $langs;
2569 $sql =
"SELECT a.rowid, a.datefin, a.statut";
2570 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as a";
2571 $sql .=
", ".MAIN_DB_PREFIX.
"adherent_type as t";
2572 $sql .=
" WHERE a.fk_adherent_type = t.rowid";
2573 if ($mode ==
'expired') {
2574 $sql .=
" AND a.statut = ".self::STATUS_VALIDATED;
2575 $sql .=
" AND a.entity IN (".getEntity(
'adherent').
")";
2576 $sql .=
" AND ((a.datefin IS NULL or a.datefin < '".$this->db->idate($now).
"') AND t.subscription = '1')";
2577 } elseif ($mode ==
'shift') {
2578 $sql .=
" AND a.statut = ".self::STATUS_DRAFT;
2579 $sql .=
" AND a.entity IN (".getEntity(
'adherent').
")";
2582 $resql = $this->db->query($sql);
2584 $langs->load(
"members");
2591 if ($mode ==
'expired') {
2592 $warning_delay =
$conf->adherent->subscription->warning_delay / 60 / 60 / 24;
2593 $label = $langs->trans(
"MembersWithSubscriptionToReceive");
2594 $labelShort = $langs->trans(
"MembersWithSubscriptionToReceiveShort");
2595 $url = DOL_URL_ROOT.
'/adherents/list.php?mainmenu=members&statut='.self::STATUS_VALIDATED.
'&filter=outofdate';
2596 } elseif ($mode ==
'shift') {
2597 $warning_delay =
$conf->adherent->subscription->warning_delay / 60 / 60 / 24;
2598 $url = DOL_URL_ROOT.
'/adherents/list.php?mainmenu=members&statut='.
self::STATUS_DRAFT;
2599 $label = $langs->trans(
"MembersListToValid");
2600 $labelShort = $langs->trans(
"ToValidate");
2604 $response->warning_delay = $warning_delay;
2605 $response->label = $label;
2606 $response->labelShort = $labelShort;
2607 $response->url = $url;
2610 $adherentstatic =
new Adherent($this->db);
2612 while ($obj = $this->db->fetch_object($resql)) {
2613 $response->nbtodo++;
2615 $adherentstatic->datefin = $this->db->jdate($obj->datefin);
2616 $adherentstatic->statut = $obj->statut;
2618 if ($adherentstatic->hasDelay()) {
2619 $response->nbtodolate++;
2626 $this->error = $this->db->error();
2643 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams =
null)
2645 global
$conf, $langs;
2647 $langs->load(
"orders");
2650 $modele =
'standard';
2652 if ($this->model_pdf) {
2653 $modele = $this->model_pdf;
2659 $modelpath =
"core/modules/member/doc/";
2661 return $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
2674 global $user, $langs;
2679 $this->
ref =
'ABC001';
2681 $this->specimen = 1;
2682 $this->civility_id =
'MR';
2683 $this->lastname =
'DOLIBARR';
2684 $this->firstname =
'SPECIMEN';
2685 $this->gender =
'man';
2686 $this->login =
'dolibspec';
2687 $this->pass =
'dolibspec';
2688 $this->company =
'Societe ABC';
2689 $this->
address =
'61 jump street';
2690 $this->zip =
'75000';
2691 $this->town =
'Paris';
2692 $this->country_id = 1;
2693 $this->country_code =
'FR';
2694 $this->country =
'France';
2695 $this->morphy =
'mor';
2696 $this->
email =
'specimen@specimen.com';
2697 $this->socialnetworks = array(
2698 'skype' =>
'skypepseudo',
2699 'twitter' =>
'twitterpseudo',
2700 'facebook' =>
'facebookpseudo',
2701 'linkedin' =>
'linkedinpseudo',
2703 $this->phone =
'0999999999';
2704 $this->phone_perso =
'0999999998';
2705 $this->phone_mobile =
'0999999997';
2706 $this->note_public =
'This is a public note';
2707 $this->note_private =
'This is a private note';
2708 $this->birth = $now;
2714 $this->datefin = $now;
2715 $this->datevalid = $now;
2716 $this->default_lang =
'';
2719 $this->
type =
'Type adherent';
2720 $this->need_subscription = 0;
2722 $this->first_subscription_date = $now;
2723 $this->first_subscription_date_start = $this->first_subscription_date;
2724 $this->first_subscription_date_end =
dol_time_plus_duree($this->first_subscription_date_start, 1,
'y');
2725 $this->first_subscription_amount = 10;
2727 $this->last_subscription_date = $this->first_subscription_date;
2728 $this->last_subscription_date_start = $this->first_subscription_date;
2729 $this->last_subscription_date_end =
dol_time_plus_duree($this->last_subscription_date_start, 1,
'y');
2730 $this->last_subscription_amount = 10;
2774 global
$conf, $langs;
2778 $keymodified =
false;
2786 if ($this->morphy ==
'mor' && (empty($this->fullname) || $this->fullname == $this->company)) {
2787 $this->fullname = $this->company;
2788 $this->lastname = $this->company;
2793 'LDAP_MEMBER_FIELD_FULLNAME' =>
'fullname',
2794 'LDAP_MEMBER_FIELD_NAME' =>
'lastname',
2795 'LDAP_MEMBER_FIELD_LOGIN' =>
'login',
2796 'LDAP_MEMBER_FIELD_LOGIN_SAMBA' =>
'login',
2797 'LDAP_MEMBER_FIELD_MAIL' =>
'email'
2801 foreach ($ldapkey as $constname => $varname) {
2807 if (!empty($this->oldcopy) && $this->$varname != $this->oldcopy->$varname) {
2808 $keymodified =
true;
2834 foreach ($socialnetworks as $key => $value) {
2835 if ($this->socialnetworks[$value[
'label']] &&
getDolGlobalString(
'LDAP_MEMBER_FIELD_'.strtoupper($value[
'label']))) {
2836 $info[
getDolGlobalString(
'LDAP_MEMBER_FIELD_'.strtoupper($value[
'label']))] = $this->socialnetworks[$value[
'label']];
2863 if ($this->datefin &&
getDolGlobalString(
'LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION')) {
2868 if (!empty($this->pass)) {
2881 if ($this->pass_indatabase_crypted &&
getDolGlobalString(
'LDAP_MEMBER_FIELD_PASSWORD_CRYPTED')) {
2887 } elseif (!empty($this->pass_indatabase)) {
2899 if ($this->first_subscription_date &&
getDolGlobalString(
'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE')) {
2902 if (isset($this->first_subscription_amount) &&
getDolGlobalString(
'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT')) {
2903 $info[
getDolGlobalString(
'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT')] = $this->first_subscription_amount;
2905 if ($this->last_subscription_date &&
getDolGlobalString(
'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE')) {
2908 if (isset($this->last_subscription_amount) &&
getDolGlobalString(
'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT')) {
2909 $info[
getDolGlobalString(
'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT')] = $this->last_subscription_amount;
2924 $sql =
'SELECT a.rowid, a.datec as datec,';
2925 $sql .=
' a.datevalid as datev,';
2926 $sql .=
' a.tms as datem,';
2927 $sql .=
' a.fk_user_author, a.fk_user_valid, a.fk_user_mod';
2928 $sql .=
' FROM '.MAIN_DB_PREFIX.
'adherent as a';
2929 $sql .=
' WHERE a.rowid = '.((int) $id);
2931 dol_syslog(get_class($this).
"::info", LOG_DEBUG);
2932 $result = $this->db->query($sql);
2934 if ($this->db->num_rows($result)) {
2935 $obj = $this->db->fetch_object($result);
2937 $this->
id = $obj->rowid;
2939 $this->user_creation_id = $obj->fk_user_author;
2940 $this->user_validation_id = $obj->fk_user_valid;
2941 $this->user_modification_id = $obj->fk_user_mod;
2942 $this->date_creation = $this->db->jdate($obj->datec);
2943 $this->date_validation = $this->db->jdate($obj->datev);
2944 $this->date_modification = $this->db->jdate($obj->datem);
2947 $this->db->free($result);
2960 $sql =
"SELECT count(mc.email) as nb";
2961 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mailing_cibles as mc";
2962 $sql .=
" WHERE mc.email = '".$this->db->escape($this->
email).
"'";
2963 $sql .=
" AND mc.statut NOT IN (-1,0)";
2965 $resql = $this->db->query($sql);
2967 $obj = $this->db->fetch_object($resql);
2970 $this->db->free($resql);
2973 $this->error = $this->db->error();
2990 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
2991 return parent::setCategoriesCommon($categories, Categorie::TYPE_MEMBER);
3004 $tables = array(
'adherent');
3019 if ($this->statut != self::STATUS_VALIDATED) {
3022 if (!$this->datefin) {
3028 return $this->datefin < ($now -
$conf->adherent->subscription->warning_delay);
3042 global
$conf, $langs, $mysoc, $user;
3048 $blockingerrormsg =
'';
3050 if (!isModEnabled(
'member')) {
3051 $langs->load(
"agenda");
3052 $this->output = $langs->trans(
'ModuleNotEnabled', $langs->transnoentitiesnoconv(
"Adherent"));
3056 $langs->load(
"agenda");
3057 $this->output = $langs->trans(
'EventRemindersByEmailNotEnabled', $langs->transnoentitiesnoconv(
"Adherent"));
3065 $listofmembersok = array();
3066 $listofmembersko = array();
3068 $arraydaysbeforeend = explode(
';', $daysbeforeendlist);
3069 foreach ($arraydaysbeforeend as $daysbeforeend) {
3070 dol_syslog(__METHOD__.
' - Process delta = '.$daysbeforeend, LOG_DEBUG);
3072 if (!is_numeric($daysbeforeend)) {
3073 $blockingerrormsg =
"Value for delta is not a numeric value";
3079 $datetosearchfor =
dol_time_plus_duree(
dol_mktime(0, 0, 0, $tmp[
'mon'], $tmp[
'mday'], $tmp[
'year'],
'tzserver'), (
int) $daysbeforeend,
'd');
3081 $sql =
'SELECT rowid FROM '.MAIN_DB_PREFIX.
'adherent';
3082 $sql .=
" WHERE entity = ".((int)
$conf->entity);
3083 $sql .=
" AND statut = 1";
3084 $sql .=
" AND datefin = '".$this->db->idate($datetosearchfor).
"'";
3085 if ((
int) $fk_adherent_type > 0) {
3086 $sql .=
" AND fk_adherent_type = ".((int) $fk_adherent_type);
3090 $resql = $this->db->query($sql);
3092 $num_rows = $this->db->num_rows($resql);
3094 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
3095 $adherent =
new Adherent($this->db);
3096 $formmail =
new FormMail($this->db);
3099 while ($i < $num_rows) {
3100 $obj = $this->db->fetch_object($resql);
3102 $adherent->fetch($obj->rowid,
'', 0,
'',
true,
true);
3104 if (empty($adherent->email)) {
3106 $listofmembersko[$adherent->id] = $adherent->id;
3108 $thirdpartyres = $adherent->fetch_thirdparty();
3109 if ($thirdpartyres === -1 ) {
3110 $languagecodeformember = $mysoc->default_lang;
3113 $languagefromcountrycode =
getLanguageCodeFromCountryCode($adherent->country_code ? $adherent->country_code : $adherent->thirdparty->country_code);
3114 $languagecodeformember = (empty($adherent->thirdparty->default_lang) ? ($languagefromcountrycode ? $languagefromcountrycode : $mysoc->default_lang) : $adherent->thirdparty->default_lang);
3119 $outputlangs->setDefaultLang($languagecodeformember);
3120 $outputlangs->loadLangs(array(
"main",
"members"));
3121 dol_syslog(
"sendReminderForExpiredSubscription Language for member id ".$adherent->id.
" set to ".$outputlangs->defaultlang.
" mysoc->default_lang=".$mysoc->default_lang);
3123 $arraydefaultmessage =
null;
3126 if (!empty($labeltouse)) {
3127 $arraydefaultmessage = $formmail->getEMailTemplate($this->db,
'member', $user, $outputlangs, 0, 1, $labeltouse);
3130 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
3135 $subject =
make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs);
3136 $msg =
make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs);
3138 $to = $adherent->email;
3141 $trackid =
'mem'.$adherent->id;
3142 $moreinheader =
'X-Dolibarr-Info: sendReminderForExpiredSubscription'.
"\r\n";
3144 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
3145 $cmail =
new CMailFile($subject, $to, $from, $msg, array(), array(), array(), $cc,
'', 0, 1,
'',
'', $trackid, $moreinheader);
3146 $result = $cmail->sendfile();
3149 $this->error .= $cmail->error.
' ';
3150 if (!is_null($cmail->errors)) {
3151 $this->errors += $cmail->errors;
3154 $listofmembersko[$adherent->id] = $adherent->id;
3157 $listofmembersok[$adherent->id] = $adherent->id;
3163 $actioncode =
'EMAIL';
3174 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic').
": ".$subject);
3175 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody').
":");
3179 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
3184 $actioncomm->type_code =
'AC_OTH_AUTO';
3185 $actioncomm->code =
'AC_'.$actioncode;
3186 $actioncomm->label = $actionmsg2;
3187 $actioncomm->note_private = $actionmsg;
3188 $actioncomm->fk_project = 0;
3189 $actioncomm->datep = $now;
3190 $actioncomm->datef = $now;
3191 $actioncomm->percentage = -1;
3192 $actioncomm->socid = $adherent->thirdparty->id;
3193 $actioncomm->contact_id = 0;
3194 $actioncomm->authorid = $user->id;
3195 $actioncomm->userownerid = $user->id;
3197 $actioncomm->email_msgid = $cmail->msgid;
3198 $actioncomm->email_from = $from;
3199 $actioncomm->email_sender =
'';
3200 $actioncomm->email_to = $to;
3201 $actioncomm->email_tocc = $sendtocc;
3202 $actioncomm->email_tobcc = $sendtobcc;
3203 $actioncomm->email_subject = $subject;
3204 $actioncomm->errors_to =
'';
3206 $actioncomm->fk_element = $adherent->id;
3207 $actioncomm->elementid = $adherent->id;
3208 $actioncomm->elementtype = $adherent->element;
3210 $actioncomm->extraparams = $extraparams;
3212 $actioncomm->create($user);
3218 $this->error .=
"Can't find email template with label=".$labeltouse.
", to use for the reminding email ";
3221 $listofmembersko[$adherent->id] = $adherent->id;
3230 $this->error = $this->db->lasterror();
3235 if ($blockingerrormsg) {
3236 $this->error = $blockingerrormsg;
3239 $this->output =
'Found '.($nbok + $nbko).
' members to send reminder to.';
3240 $this->output .=
' Send email successfully to '.$nbok.
' members';
3241 if (is_array($listofmembersok)) {
3244 foreach ($listofmembersok as $idmember) {
3246 $listofids .=
', ...';
3249 if (empty($listofids)) {
3254 $listofids .= $idmember;
3261 $this->output .= ($listofids ?
' ids='.$listofids :
'');
3264 $this->output .=
' - Canceled for '.$nbko.
' member (no email or email sending error)';
3265 if (is_array($listofmembersko)) {
3268 foreach ($listofmembersko as $idmember) {
3270 $listofids .=
', ...';
3273 if (empty($listofids)) {
3278 $listofids .= $idmember;
3284 $this->output .= ($listofids ?
' ids='.$listofids :
'');
3301 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
3303 $return =
'<div class="box-flex-item box-flex-grow-zero">';
3304 $return .=
'<div class="info-box info-box-sm">';
3305 $return .=
'<span class="info-box-icon bg-infobox-action">';
3306 if (property_exists($this,
'photo') || !empty($this->photo)) {
3307 $return .=
Form::showphoto(
'memberphoto', $this, 0, 60, 0,
'photokanban photowithmargin photologintooltip',
'small', 0, 1);
3311 $return .=
'</span>';
3312 $return .=
'<div class="info-box-content">';
3313 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this,
'getNomUrl') ? $this->
getNomUrl() : $this->ref).
'</span>';
3314 if ($selected >= 0) {
3315 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
3317 $return .=
'<br><span class="info-box-label paddingright">'.$this->getmorphylib(
'', 2).
'</span>';
3318 $return .=
'<span class="info-box-label opacitymedium">'.$this->type.
'</span>';
3320 if (method_exists($this,
'getLibStatut')) {
3321 $return .=
'<br><div class="info-box-status paddingtop">';
3322 $return .= $this->
LibStatut($this->
status, $this->need_subscription, $this->datefin, 5);
3323 $return .=
'</div>';
3325 $return .=
'</div>';
3326 $return .=
'</div>';
3327 $return .=
'</div>';
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.
_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 clickable link of object (with eventually picto)
const STATUS_DRAFT
Draft status.
const STATUS_RESILIATED
Resiliated.
sendReminderForExpiredSubscription($daysbeforeendlist='10', $fk_adherent_type=0)
Send reminders by emails before subscription end CAN BE A CRON TASK.
fetch_login($login)
Method to load member from its login.
_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 clickable 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.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
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.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as p label as s rowid as s nom as s email
Sender: Who sends the email ("Sender" has sent emails on behalf of "From").
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)
setEntity($currentobject)
Set entity id to use when to create an object.
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.
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.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
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.
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 a 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...
div refaddress div address
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.