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;
106 public $civility_code;
140 public $socialnetworks;
160 public $phone_mobile;
186 public $default_lang;
235 public $need_subscription;
258 public $first_subscription_date;
263 public $first_subscription_date_start;
268 public $first_subscription_date_end;
273 public $first_subscription_amount;
278 public $last_subscription_date;
283 public $last_subscription_date_start;
288 public $last_subscription_date_end;
293 public $last_subscription_amount;
298 public $subscriptions = array();
310 public $partnerships = array();
360 'rowid' => array(
'type' =>
'integer',
'label' =>
'TechnicalID',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 10),
361 'ref' => array(
'type' =>
'varchar(30)',
'label' =>
'Ref',
'default' =>
'1',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'position' => 12,
'index' => 1),
362 'entity' => array(
'type' =>
'integer',
'label' =>
'Entity',
'default' =>
'1',
'enabled' => 1,
'visible' => 3,
'notnull' => 1,
'position' => 15,
'index' => 1),
363 'ref_ext' => array(
'type' =>
'varchar(128)',
'label' =>
'RefExt',
'enabled' => 1,
'visible' => 0,
'position' => 20),
364 'civility' => array(
'type' =>
'varchar(6)',
'label' =>
'Civility',
'enabled' => 1,
'visible' => -1,
'position' => 25),
365 'lastname' => array(
'type' =>
'varchar(50)',
'label' =>
'Lastname',
'enabled' => 1,
'visible' => 1,
'position' => 30,
'showoncombobox' => 1),
366 'firstname' => array(
'type' =>
'varchar(50)',
'label' =>
'Firstname',
'enabled' => 1,
'visible' => 1,
'position' => 35,
'showoncombobox' => 1),
367 'login' => array(
'type' =>
'varchar(50)',
'label' =>
'Login',
'enabled' => 1,
'visible' => 1,
'position' => 40),
368 'pass' => array(
'type' =>
'varchar(50)',
'label' =>
'Pass',
'enabled' => 1,
'visible' => 3,
'position' => 45),
369 'pass_crypted' => array(
'type' =>
'varchar(128)',
'label' =>
'Pass crypted',
'enabled' => 1,
'visible' => 3,
'position' => 50),
370 'morphy' => array(
'type' =>
'varchar(3)',
'label' =>
'MemberNature',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'position' => 55),
371 'fk_adherent_type' => array(
'type' =>
'integer',
'label' =>
'MemberType',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'position' => 60),
372 'societe' => array(
'type' =>
'varchar(128)',
'label' =>
'Societe',
'enabled' => 1,
'visible' => 1,
'position' => 65,
'showoncombobox' => 2),
373 'fk_soc' => array(
'type' =>
'integer:Societe:societe/class/societe.class.php',
'label' =>
'ThirdParty',
'enabled' => 1,
'visible' => 1,
'position' => 70),
374 'address' => array(
'type' =>
'text',
'label' =>
'Address',
'enabled' => 1,
'visible' => -1,
'position' => 75),
375 'zip' => array(
'type' =>
'varchar(10)',
'label' =>
'Zip',
'enabled' => 1,
'visible' => -1,
'position' => 80),
376 'town' => array(
'type' =>
'varchar(50)',
'label' =>
'Town',
'enabled' => 1,
'visible' => -1,
'position' => 85),
377 'state_id' => array(
'type' =>
'integer',
'label' =>
'State',
'enabled' => 1,
'visible' => -1,
'position' => 90),
378 'country' => array(
'type' =>
'integer:Ccountry:core/class/ccountry.class.php',
'label' =>
'Country',
'enabled' => 1,
'visible' => 1,
'position' => 95),
379 'phone' => array(
'type' =>
'varchar(30)',
'label' =>
'Phone',
'enabled' => 1,
'visible' => -1,
'position' => 115),
380 'phone_perso' => array(
'type' =>
'varchar(30)',
'label' =>
'Phone perso',
'enabled' => 1,
'visible' => -1,
'position' => 120),
381 'phone_mobile' => array(
'type' =>
'varchar(30)',
'label' =>
'Phone mobile',
'enabled' => 1,
'visible' => -1,
'position' => 125),
382 'email' => array(
'type' =>
'varchar(255)',
'label' =>
'Email',
'enabled' => 1,
'visible' => 1,
'position' => 126),
383 'url' => array(
'type' =>
'varchar(255)',
'label' =>
'Url',
'enabled' => 1,
'visible' => -1,
'position' => 127),
384 'socialnetworks' => array(
'type' =>
'text',
'label' =>
'Socialnetworks',
'enabled' => 1,
'visible' => 3,
'position' => 128),
385 'birth' => array(
'type' =>
'date',
'label' =>
'DateOfBirth',
'enabled' => 1,
'visible' => -1,
'position' => 130),
386 'gender' => array(
'type' =>
'varchar(10)',
'label' =>
'Gender',
'enabled' => 1,
'visible' => -1,
'position' => 132),
387 'photo' => array(
'type' =>
'varchar(255)',
'label' =>
'Photo',
'enabled' => 1,
'visible' => -1,
'position' => 135),
388 'public' => array(
'type' =>
'smallint(6)',
'label' =>
'Public',
'enabled' => 1,
'visible' => 3,
'notnull' => 1,
'position' => 145),
389 'datefin' => array(
'type' =>
'datetime',
'label' =>
'DateEnd',
'enabled' => 1,
'visible' => 1,
'position' => 150),
390 'default_lang' => array(
'type' =>
'varchar(6)',
'label' =>
'Default lang',
'enabled' => 1,
'visible' => -1,
'position' => 153),
391 'note_public' => array(
'type' =>
'text',
'label' =>
'NotePublic',
'enabled' => 1,
'visible' => 0,
'position' => 155),
392 'note_private' => array(
'type' =>
'text',
'label' =>
'NotePrivate',
'enabled' => 1,
'visible' => 0,
'position' => 160),
393 'datevalid' => array(
'type' =>
'datetime',
'label' =>
'DateValidation',
'enabled' => 1,
'visible' => -1,
'position' => 165),
394 'datec' => array(
'type' =>
'datetime',
'label' =>
'DateCreation',
'enabled' => 1,
'visible' => -1,
'position' => 170),
395 'tms' => array(
'type' =>
'timestamp',
'label' =>
'DateModification',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 175),
396 'fk_user_author' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'UserCreation',
'enabled' => 1,
'visible' => 3,
'position' => 180),
397 'fk_user_mod' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'UserModification',
'enabled' => 1,
'visible' => 3,
'position' => 185),
398 'fk_user_valid' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'UserValidation',
'enabled' => 1,
'visible' => 3,
'position' => 190),
399 'canvas' => array(
'type' =>
'varchar(32)',
'label' =>
'Canvas',
'enabled' => 1,
'visible' => 0,
'position' => 195),
400 'model_pdf' => array(
'type' =>
'varchar(255)',
'label' =>
'Model pdf',
'enabled' => 1,
'visible' => 0,
'position' => 800),
401 'import_key' => array(
'type' =>
'varchar(14)',
'label' =>
'ImportId',
'enabled' => 1,
'visible' => -2,
'position' => 805),
402 'statut' => array(
'type' =>
'smallint(6)',
'label' =>
'Statut',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'position' => 1000,
'arrayofkeyval' => array(-1 =>
'Draft', 1 =>
'Validated', 0 =>
'MemberStatusResiliatedShort', -2 =>
'MemberStatusExcludedShort'))
435 $this->ismultientitymanaged = 1;
436 $this->isextrafieldmanaged = 1;
438 $this->array_options = array();
440 $this->fields[
'ref_ext'][
'visible'] =
getDolGlobalInt(
'MAIN_LIST_SHOW_REF_EXT');
463 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 =
'')
466 dol_syslog(
'Warning using deprecated Adherent::send_an_email', LOG_WARNING);
468 return $this->
sendEmail($text, $subject, $filename_list, $mimetype_list, $mimefilename_list, $addr_cc, $addr_bcc, $deliveryreceipt, $msgishtml, $errors_to, $moreinheader);
488 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 =
'')
490 global
$conf, $langs;
493 if ($msgishtml == -1) {
500 dol_syslog(
'sendEmail msgishtml='.$msgishtml);
511 $trackid =
'mem'.$this->id;
514 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
515 $mailfile =
new CMailFile($subjecttosend, (
string) $this->
email, $from, $texttosend, $filename_list, $mimetype_list, $mimefilename_list, $addr_cc, $addr_bcc, $deliveryreceipt, $msgishtml,
'',
'', $trackid, $moreinheader);
516 if ($mailfile->sendfile()) {
519 $this->error = $langs->trans(
"ErrorFailedToSendMail", $from, (
string) $this->email).
'. '.$mailfile->error;
536 $photo = isset($this->photo) ? $this->photo :
'';
537 $login = isset($this->login) ? $this->login :
'';
538 $type = isset($this->
type) ? $this->
type :
'';
539 $pass = isset($this->pass) ? $this->pass :
'';
547 if ($this->civility_id) {
548 $infos .= $langs->transnoentities(
"UserTitle").
": ".$this->
getCivilityLabel().
"\n";
550 $infos .= $langs->transnoentities(
"Id").
": ".$this->
id.
"\n";
551 $infos .= $langs->transnoentities(
"Ref").
": ".$this->
ref.
"\n";
552 $infos .= $langs->transnoentities(
"Lastname").
": ".$this->lastname.
"\n";
553 $infos .= $langs->transnoentities(
"Firstname").
": ".$this->firstname.
"\n";
554 $infos .= $langs->transnoentities(
"Company").
": ".$this->company.
"\n";
555 $infos .= $langs->transnoentities(
"Address").
": ".$this->
address.
"\n";
556 $infos .= $langs->transnoentities(
"Zip").
": ".$this->zip.
"\n";
557 $infos .= $langs->transnoentities(
"Town").
": ".$this->town.
"\n";
558 $infos .= $langs->transnoentities(
"Country").
": ".$this->country.
"\n";
559 $infos .= $langs->transnoentities(
"EMail").
": ".$this->
email.
"\n";
560 $infos .= $langs->transnoentities(
"PhonePro").
": ".$this->phone.
"\n";
561 $infos .= $langs->transnoentities(
"PhonePerso").
": ".$this->phone_perso.
"\n";
562 $infos .= $langs->transnoentities(
"PhoneMobile").
": ".$this->phone_mobile.
"\n";
564 $infos .= $langs->transnoentities(
"Login").
": ".$login.
"\n";
565 $infos .= $langs->transnoentities(
"Password").
": ".$pass.
"\n";
567 $infos .= $langs->transnoentities(
"Birthday").
": ".$birthday.
"\n";
568 $infos .= $langs->transnoentities(
"Photo").
": ".$photo.
"\n";
569 $infos .= $langs->transnoentities(
"Public").
": ".
yn($this->
public);
572 $substitutionarray = array(
573 '__ID__' => $this->
id,
574 '__REF__' => $this->
ref,
575 '__MEMBER_ID__' => $this->
id,
577 '__FIRSTNAME__' => $msgishtml ?
dol_htmlentitiesbr($this->firstname) : ($this->firstname ? $this->firstname :
''),
578 '__LASTNAME__' => $msgishtml ?
dol_htmlentitiesbr($this->lastname) : ($this->lastname ? $this->lastname :
''),
580 '__COMPANY__' => $msgishtml ?
dol_htmlentitiesbr((
string) $this->company) : ($this->company ? $this->company :
''),
582 '__ZIP__' => $msgishtml ?
dol_htmlentitiesbr((
string) $this->zip) : ($this->zip ? $this->zip :
''),
583 '__TOWN__' => $msgishtml ?
dol_htmlentitiesbr((
string) $this->town) : ($this->town ? $this->town :
''),
584 '__COUNTRY__' => $msgishtml ?
dol_htmlentitiesbr($this->country) : ($this->country ? $this->country :
''),
586 '__BIRTH__' => $msgishtml ?
dol_htmlentitiesbr($birthday) : ($birthday ? $birthday :
''),
590 '__PHONE__' => $msgishtml ?
dol_htmlentitiesbr($this->phone) : ($this->phone ? $this->phone :
''),
591 '__PHONEPRO__' => $msgishtml ?
dol_htmlentitiesbr($this->phone_perso) : ($this->phone_perso ? $this->phone_perso :
''),
592 '__PHONEMOBILE__' => $msgishtml ?
dol_htmlentitiesbr($this->phone_mobile) : ($this->phone_mobile ? $this->phone_mobile :
''),
616 $morphy = $this->morphy;
620 $labeltoshowm = $langs->trans(
"Moral");
621 $labeltoshowp = $langs->trans(
"Physical");
622 if ($morphy ==
'phy') {
623 $labeltoshow = $labeltoshowp;
624 if ($addbadge == 2) {
630 $s .=
'<span class="member-individual-back paddingleftimp paddingrightimp" title="'.$langs->trans(
"Physical").
'">'.$labeltoshow.
'</span>';
632 if ($morphy ==
'mor') {
633 $labeltoshow = $labeltoshowm;
634 if ($addbadge == 2) {
640 $s .=
'<span class="member-company-back paddingleftimp paddingrightimp" title="'.$langs->trans(
"Moral").
'">'.$labeltoshow.
'</span>';
643 if ($morphy ==
'phy') {
644 $s = $langs->trans(
"Physical");
645 } elseif ($morphy ==
'mor') {
646 $s = $langs->trans(
"Moral");
660 public function create($user, $notrigger = 0)
662 global
$conf, $langs, $mysoc;
669 if (isset($this->import_key)) {
670 $this->import_key = trim($this->import_key);
675 $langs->load(
"errors");
676 $this->error = $langs->trans(
"ErrorBadEMail", (
string) $this->email);
683 if (empty($this->login)) {
684 $this->error = $langs->trans(
"ErrorWrongValueForParameterX",
"Login");
695 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"adherent";
696 $sql .=
" (ref, datec, login, fk_user_author, fk_user_mod, fk_user_valid, morphy, fk_adherent_type, entity, import_key, ip)";
699 $sql .=
", '".$this->db->idate($this->datec).
"'";
700 $sql .=
", ".($this->login ?
"'".$this->db->escape($this->login).
"'" :
"null");
701 $sql .=
", ".($user->id > 0 ? $user->id :
"null");
702 $sql .=
", null, null, '".$this->db->escape($this->morphy).
"'";
703 $sql .=
", ".((int) $this->
typeid);
704 $sql .=
", ".((int) $this->entity);
705 $sql .=
", ".(!empty($this->import_key) ?
"'".$this->db->escape($this->import_key).
"'" :
"null");
706 $sql .=
", ".(!empty($this->ip) ?
"'".$this->db->escape($this->ip).
"'" :
"null");
709 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
710 $result = $this->db->query($sql);
712 $id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"adherent");
717 $this->
ref = (string) $id;
722 require_once $modfile;
724 $modCodeMember =
new $modname();
725 '@phan-var-force ModeleNumRefMembers $modCodeMember';
727 $this->
ref = $modCodeMember->getNextValue($mysoc, $this);
735 $result = $this->
update($user, 1, 1, 0, 0,
'add');
737 $this->db->rollback();
742 if ($this->user_id) {
744 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET";
745 $sql .=
" fk_member = ".((int) $this->
id);
746 $sql .=
" WHERE rowid = ".((int) $this->user_id);
747 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
748 $resql = $this->db->query($sql);
750 $this->error =
'Failed to update user to make link with member';
751 $this->db->rollback();
765 if (count($this->errors)) {
766 dol_syslog(get_class($this).
"::create ".implode(
',', $this->errors), LOG_ERR);
767 $this->db->rollback();
774 $this->error =
'Failed to get last insert id';
775 dol_syslog(get_class($this).
"::create ".$this->error, LOG_ERR);
776 $this->db->rollback();
780 $this->error = $this->db->error();
781 $this->db->rollback();
798 public function update($user, $notrigger = 0, $nosyncuser = 0, $nosyncuserpass = 0, $nosyncthirdparty = 0, $action =
'update')
800 global $langs, $hookmanager;
802 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
804 if (empty($this->country_id) && !empty($this->country_code)) {
805 $country_id =
getCountry($this->country_code,
'3');
806 $this->country_id = is_int($country_id) ? $country_id : 0;
812 dol_syslog(get_class($this).
"::update notrigger=".$notrigger.
", nosyncuser=".$nosyncuser.
", nosyncuserpass=".$nosyncuserpass.
" nosyncthirdparty=".$nosyncthirdparty.
", email=".$this->email);
815 $this->lastname = trim($this->lastname) ? trim($this->lastname) : trim($this->lastname);
816 $this->firstname = trim($this->firstname) ? trim($this->firstname) : trim($this->firstname);
817 $this->gender = trim($this->gender);
825 $this->url = $this->url ?
clean_url($this->url, 0) :
'';
829 $langs->load(
"errors");
830 $this->error = $langs->trans(
"ErrorBadEMail", (
string) $this->email);
836 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
837 $sql .=
" ref = '".$this->db->escape($this->
ref).
"'";
838 $sql .=
", civility = ".($this->civility_id ?
"'".$this->db->escape($this->civility_id).
"'" :
"null");
839 $sql .=
", firstname = ".($this->firstname ?
"'".$this->db->escape($this->firstname).
"'" :
"null");
840 $sql .=
", lastname = ".($this->lastname ?
"'".$this->db->escape($this->lastname).
"'" :
"null");
841 $sql .=
", gender = ".($this->gender != -1 ?
"'".$this->db->escape($this->gender).
"'" :
"null");
842 $sql .=
", login = ".($this->login ?
"'".$this->db->escape($this->login).
"'" :
"null");
843 $sql .=
", societe = ".($this->company ?
"'".$this->db->escape($this->company).
"'" : ($this->societe ?
"'".$this->db->escape($this->societe).
"'" :
"null"));
845 $sql .=
", fk_soc = ".($this->socid > 0 ? (int) $this->socid :
"null");
847 $sql .=
", address = ".($this->address ?
"'".$this->db->escape($this->
address).
"'" :
"null");
848 $sql .=
", zip = ".($this->zip ?
"'".$this->db->escape($this->zip).
"'" :
"null");
849 $sql .=
", town = ".($this->town ?
"'".$this->db->escape($this->town).
"'" :
"null");
850 $sql .=
", country = ".($this->country_id > 0 ? (int) $this->country_id :
"null");
851 $sql .=
", state_id = ".($this->state_id > 0 ? (int) $this->state_id :
"null");
852 $sql .=
", email = '".$this->db->escape((
string) $this->email).
"'";
853 $sql .=
", url = ".(!empty($this->url) ?
"'".$this->db->escape($this->url).
"'" :
"null");
854 $sql .=
", socialnetworks = ".($this->socialnetworks ?
"'".$this->db->escape(json_encode($this->socialnetworks)).
"'" :
"null");
855 $sql .=
", phone = ".($this->phone ?
"'".$this->db->escape($this->phone).
"'" :
"null");
856 $sql .=
", phone_perso = ".($this->phone_perso ?
"'".$this->db->escape($this->phone_perso).
"'" :
"null");
857 $sql .=
", phone_mobile = ".($this->phone_mobile ?
"'".$this->db->escape($this->phone_mobile).
"'" :
"null");
858 $sql .=
", note_private = ".($this->note_private ?
"'".$this->db->escape($this->note_private).
"'" :
"null");
859 $sql .=
", note_public = ".($this->note_public ?
"'".$this->db->escape($this->note_public).
"'" :
"null");
860 $sql .=
", photo = ".($this->photo ?
"'".$this->db->escape($this->photo).
"'" :
"null");
861 $sql .=
", public = ".(int) $this->
public;
862 $sql .=
", statut = ".(int) $this->statut;
863 $sql .=
", default_lang = ".(!empty($this->default_lang) ?
"'".$this->db->escape($this->default_lang).
"'" :
"null");
864 $sql .=
", fk_adherent_type = ".(int) $this->
typeid;
865 $sql .=
", morphy = '".$this->db->escape($this->morphy).
"'";
866 $sql .=
", birth = ".($this->birth ?
"'".$this->db->idate($this->birth).
"'" :
"null");
868 if ($this->datefin) {
869 $sql .=
", datefin = '".$this->db->idate($this->datefin).
"'";
871 if ($this->datevalid) {
872 $sql .=
", datevalid = '".$this->db->idate($this->datevalid).
"'";
874 $sql .=
", fk_user_mod = ".($user->id > 0 ? $user->id :
'null');
875 $sql .=
" WHERE rowid = ".((int) $this->
id);
878 '@phan-var-force Adherent $oldcopy';
879 if (!empty($this->oldcopy) && $this->
typeid != $this->oldcopy->typeid) {
880 $sql2 =
"SELECT libelle as label";
881 $sql2 .=
" FROM ".MAIN_DB_PREFIX.
"adherent_type";
882 $sql2 .=
" WHERE rowid = ".((int) $this->
typeid);
883 $resql2 = $this->db->query($sql2);
885 while ($obj = $this->db->fetch_object($resql2)) {
886 $this->
type = $obj->label;
891 dol_syslog(get_class($this).
"::update update member", LOG_DEBUG);
892 $resql = $this->db->query($sql);
894 unset($this->country_code);
895 unset($this->country);
896 unset($this->state_code);
899 $nbrowsaffected += $this->db->affected_rows($resql);
912 if (!$error && $this->pass) {
913 dol_syslog(get_class($this).
"::update update password");
914 if ($this->pass != $this->pass_indatabase && $this->pass != $this->pass_indatabase_crypted) {
918 $result = $this->
setPassword($user, $this->pass, $isencrypted, $notrigger, $nosyncuserpass);
919 if (!$nbrowsaffected) {
927 dol_syslog(get_class($this).
"::update update link to user");
928 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = NULL WHERE fk_member = ".((int) $this->
id);
929 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
930 $resql = $this->db->query($sql);
932 $this->error = $this->db->error();
933 $this->db->rollback();
937 if ($this->user_id > 0) {
938 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = ".((int) $this->
id).
" WHERE rowid = ".((int) $this->user_id);
939 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
940 $resql = $this->db->query($sql);
942 $this->error = $this->db->error();
943 $this->db->rollback();
949 if (!$error && $nbrowsaffected) {
951 if (!$error && $this->user_id > 0 && !$nosyncuser) {
952 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
954 dol_syslog(get_class($this).
"::update update linked user");
956 $luser =
new User($this->db);
957 $result = $luser->fetch($this->user_id);
962 $luser->login = $this->login;
965 $luser->ref = $this->ref;
966 $luser->civility_id = $this->civility_id;
967 $luser->firstname = $this->firstname;
968 $luser->lastname = $this->lastname;
969 $luser->gender = $this->gender;
970 $luser->pass = isset($this->pass) ? $this->pass :
'';
973 $luser->birth = $this->birth;
975 $luser->address = $this->address;
976 $luser->zip = $this->zip;
977 $luser->town = $this->town;
978 $luser->country_id = $this->country_id;
979 $luser->state_id = $this->state_id;
981 $luser->email = $this->email;
982 $luser->socialnetworks = $this->socialnetworks;
983 $luser->office_phone = $this->phone;
984 $luser->user_mobile = $this->phone_mobile;
986 $luser->lang = $this->default_lang;
988 $luser->fk_member = $this->id;
990 $result = $luser->update($user, 0, 1, 1);
992 $this->error = $luser->error;
993 dol_syslog(get_class($this).
"::update ".$this->error, LOG_ERR);
997 $this->error = $luser->error;
1003 if (!$error && $this->fk_soc > 0 && !$nosyncthirdparty) {
1004 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
1006 dol_syslog(get_class($this).
"::update update linked thirdparty");
1010 $lthirdparty =
new Societe($this->db);
1011 $result = $lthirdparty->fetch($this->fk_soc);
1014 $lthirdparty->address = $this->address;
1015 $lthirdparty->zip = $this->zip;
1016 $lthirdparty->town = $this->town;
1017 $lthirdparty->email = $this->email;
1018 $lthirdparty->socialnetworks = $this->socialnetworks;
1019 $lthirdparty->phone = $this->phone;
1020 $lthirdparty->state_id = $this->state_id;
1021 $lthirdparty->country_id = $this->country_id;
1023 $lthirdparty->default_lang = $this->default_lang;
1025 $result = $lthirdparty->update($this->fk_soc, $user, 0, 1, 1,
'update');
1028 $this->error = $lthirdparty->error;
1029 $this->errors = $lthirdparty->errors;
1030 dol_syslog(get_class($this).
"::update ".$this->error, LOG_ERR);
1033 } elseif ($result < 0) {
1034 $this->error = $lthirdparty->error;
1040 if (!$error && !$notrigger) {
1050 $this->db->commit();
1051 return $nbrowsaffected;
1053 $this->db->rollback();
1057 $this->db->rollback();
1058 $this->error = $this->db->lasterror();
1078 $sql =
"SELECT rowid, datec as dateop, dateadh as datedeb, datef as datefin";
1079 $sql .=
" FROM ".MAIN_DB_PREFIX.
"subscription";
1080 $sql .=
" WHERE fk_adherent = ".((int) $this->
id);
1081 $sql .=
" ORDER by dateadh DESC";
1083 dol_syslog(get_class($this).
"::update_end_date", LOG_DEBUG);
1084 $resql = $this->db->query($sql);
1092 $dateendmember =
'';
1094 while ($obj = $this->db->fetch_object($resql)) {
1095 $dateendsubscription = $this->db->jdate($obj->datefin);
1097 $dateop = $this->db->jdate($obj->dateop);
1098 $datedeb = $this->db->jdate($obj->datedeb);
1099 $datefin = $dateendsubscription;
1101 if ($dateendsubscription !=
'' && ($dateendmember ==
'' || $dateendsubscription > $dateendmember)) {
1102 $dateendmember = $dateendsubscription;
1107 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
1108 $sql .=
" datefin=".($dateendmember !=
'' ?
"'".$this->db->idate($dateendmember).
"'" :
"null");
1109 $sql .=
" WHERE rowid = ".((int) $this->
id);
1111 dol_syslog(get_class($this).
"::update_end_date", LOG_DEBUG);
1112 $resql = $this->db->query($sql);
1114 $this->last_subscription_date = $dateop;
1115 $this->last_subscription_date_start = $datedeb;
1116 $this->last_subscription_date_end = $datefin;
1117 $this->datefin = $dateendmember;
1118 $this->db->commit();
1121 $this->db->rollback();
1125 $this->error = $this->db->lasterror();
1126 $this->db->rollback();
1138 public function delete($user, $notrigger = 0)
1149 if (!$error && !$notrigger) {
1159 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"categorie_member WHERE fk_member = ".((int) $rowid);
1160 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1161 $resql = $this->db->query($sql);
1164 $this->error .= $this->db->lasterror();
1170 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"subscription WHERE fk_adherent = ".((int) $rowid);
1171 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1172 $resql = $this->db->query($sql);
1175 $this->error .= $this->db->lasterror();
1185 $this->error .= $this->db->lasterror();
1196 dol_syslog(get_class($this).
"::delete erreur ".$errorflag.
" ".$this->error, LOG_ERR);
1202 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"adherent WHERE rowid = ".((int) $rowid);
1203 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1204 $resql = $this->db->query($sql);
1207 $this->error .= $this->db->lasterror();
1213 $this->db->commit();
1216 $this->db->rollback();
1232 public function setPassword($user, $password =
'', $isencrypted = 0, $notrigger = 0, $nosyncuser = 0)
1234 global
$conf, $langs;
1238 dol_syslog(get_class($this).
"::setPassword user=".$user->id.
" password=".preg_replace(
'/./i',
'*', $password).
" isencrypted=".$isencrypted);
1242 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
1247 $password_crypted =
dol_hash($password);
1249 $password_indatabase =
'';
1250 if (!$isencrypted) {
1251 $password_indatabase = $password;
1257 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent";
1258 $sql .=
" SET pass_crypted = '".$this->db->escape($password_crypted).
"'";
1260 $sql .=
", pass = null";
1262 $sql .=
", pass = '".$this->db->escape($password_indatabase).
"'";
1264 $sql .=
" WHERE rowid = ".((int) $this->
id);
1267 dol_syslog(get_class($this).
"::setPassword", LOG_DEBUG);
1268 $result = $this->db->query($sql);
1270 $nbaffectedrows = $this->db->affected_rows($result);
1272 if ($nbaffectedrows) {
1273 $this->pass = $password;
1274 $this->pass_indatabase = $password_indatabase;
1275 $this->pass_indatabase_crypted = $password_crypted;
1277 if ($this->user_id && !$nosyncuser) {
1278 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
1282 $luser =
new User($this->db);
1283 $result = $luser->fetch($this->user_id);
1286 $result = $luser->setPassword($user, $this->pass, 0, 0, 1);
1287 if (is_int($result) && $result < 0) {
1288 $this->error = $luser->error;
1289 dol_syslog(get_class($this).
"::setPassword ".$this->error, LOG_ERR);
1293 $this->error = $luser->error;
1298 if (!$error && !$notrigger) {
1300 $result = $this->
call_trigger(
'MEMBER_NEW_PASSWORD', $user);
1303 $this->db->rollback();
1309 $this->db->commit();
1312 $this->db->rollback();
1316 $this->db->rollback();
1331 global
$conf, $langs;
1336 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = NULL WHERE fk_member = ".((int) $this->
id);
1337 dol_syslog(get_class($this).
"::setUserId", LOG_DEBUG);
1338 $resql = $this->db->query($sql);
1340 $this->error = $this->db->error();
1341 $this->db->rollback();
1347 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = ".((int) $this->
id);
1348 $sql .=
" WHERE rowid = ".((int) $userid);
1349 dol_syslog(get_class($this).
"::setUserId", LOG_DEBUG);
1350 $resql = $this->db->query($sql);
1352 $this->error = $this->db->error();
1353 $this->db->rollback();
1358 $this->db->commit();
1372 global
$conf, $langs;
1377 if ($thirdpartyid > 0) {
1378 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET fk_soc = null";
1379 $sql .=
" WHERE fk_soc = ".((int) $thirdpartyid);
1380 $sql .=
" AND entity = ".$conf->entity;
1381 dol_syslog(get_class($this).
"::setThirdPartyId", LOG_DEBUG);
1382 $resql = $this->db->query($sql);
1386 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET fk_soc = ".($thirdpartyid > 0 ? (int) $thirdpartyid :
'null');
1387 $sql .=
" WHERE rowid = ".((int) $this->
id);
1389 dol_syslog(get_class($this).
"::setThirdPartyId", LOG_DEBUG);
1390 $resql = $this->db->query($sql);
1392 $this->db->commit();
1395 $this->error = $this->db->error();
1396 $this->db->rollback();
1414 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"adherent";
1415 $sql .=
" WHERE login='".$this->db->escape($login).
"'";
1416 $sql .=
" AND entity = ".$conf->entity;
1418 $resql = $this->db->query($sql);
1420 if ($this->db->num_rows($resql)) {
1421 $obj = $this->db->fetch_object($resql);
1422 $this->
fetch($obj->rowid);
1442 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"adherent";
1443 $sql .=
" WHERE firstname='".$this->db->escape($firstname).
"'";
1444 $sql .=
" AND lastname='".$this->db->escape($lastname).
"'";
1445 $sql .=
" AND entity = ".$conf->entity;
1447 $resql = $this->db->query($sql);
1449 if ($this->db->num_rows($resql)) {
1450 $obj = $this->db->fetch_object($resql);
1451 $this->
fetch($obj->rowid);
1469 public function fetch($rowid, $ref =
'', $fk_soc = 0, $ref_ext =
'', $fetch_optionals =
true, $fetch_subscriptions =
true)
1473 $sql =
"SELECT d.rowid, d.ref, d.ref_ext, d.civility as civility_code, d.gender, d.firstname, d.lastname,";
1474 $sql .=
" d.societe as company, d.fk_soc, d.statut, d.public, d.address, d.zip, d.town, d.note_private,";
1475 $sql .=
" d.note_public,";
1476 $sql .=
" d.email, d.url, d.socialnetworks, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass, d.pass_crypted,";
1477 $sql .=
" d.photo, d.fk_adherent_type, d.morphy, d.entity,";
1478 $sql .=
" d.datec as datec,";
1479 $sql .=
" d.tms as datem,";
1480 $sql .=
" d.datefin as datefin, d.default_lang,";
1481 $sql .=
" d.birth as birthday,";
1482 $sql .=
" d.datevalid as datev,";
1483 $sql .=
" d.country,";
1484 $sql .=
" d.state_id,";
1485 $sql .=
" d.model_pdf,";
1486 $sql .=
" c.rowid as country_id, c.code as country_code, c.label as country,";
1487 $sql .=
" dep.nom as state, dep.code_departement as state_code,";
1488 $sql .=
" t.libelle as type, t.subscription as subscription,";
1489 $sql .=
" u.rowid as user_id, u.login as user_login";
1490 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent_type as t, ".MAIN_DB_PREFIX.
"adherent as d";
1491 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as c ON d.country = c.rowid";
1492 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as dep ON d.state_id = dep.rowid";
1493 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON d.rowid = u.fk_member";
1494 $sql .=
" WHERE d.fk_adherent_type = t.rowid";
1496 $sql .=
" AND d.rowid=".((int) $rowid);
1497 } elseif ($ref || $fk_soc) {
1498 $sql .=
" AND d.entity IN (".getEntity(
'adherent').
")";
1500 $sql .=
" AND d.ref='".$this->db->escape($ref).
"'";
1501 } elseif ($fk_soc > 0) {
1502 $sql .=
" AND d.fk_soc=".((int) $fk_soc);
1504 } elseif ($ref_ext) {
1505 $sql .=
" AND d.ref_ext='".$this->db->escape($ref_ext).
"'";
1508 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
1509 $resql = $this->db->query($sql);
1511 if ($this->db->num_rows($resql)) {
1512 $obj = $this->db->fetch_object($resql);
1514 $this->entity = $obj->entity;
1515 $this->
id = $obj->rowid;
1516 $this->
ref = $obj->ref;
1517 $this->ref_ext = $obj->ref_ext;
1519 $this->civility_id = $obj->civility_code;
1520 $this->civility_code = $obj->civility_code;
1521 $this->civility = $obj->civility_code ? ($langs->trans(
"Civility".$obj->civility_code) !=
"Civility".$obj->civility_code ? $langs->trans(
"Civility".$obj->civility_code) : $obj->civility_code) :
'';
1523 $this->firstname = $obj->firstname;
1524 $this->lastname = $obj->lastname;
1525 $this->gender = $obj->gender;
1526 $this->login = $obj->login;
1527 $this->societe = $obj->company;
1528 $this->company = $obj->company;
1529 $this->socid = $obj->fk_soc;
1530 $this->fk_soc = $obj->fk_soc;
1531 $this->
address = $obj->address;
1532 $this->zip = $obj->zip;
1533 $this->town = $obj->town;
1535 $this->pass = $obj->pass;
1536 $this->pass_indatabase = $obj->pass;
1537 $this->pass_indatabase_crypted = $obj->pass_crypted;
1539 $this->state_id = $obj->state_id;
1540 $this->state_code = $obj->state_id ? $obj->state_code :
'';
1541 $this->state = $obj->state_id ? $obj->state :
'';
1543 $this->country_id = $obj->country_id;
1544 $this->country_code = $obj->country_code;
1545 if ($langs->trans(
"Country".$obj->country_code) !=
"Country".$obj->country_code) {
1546 $this->country = $langs->transnoentitiesnoconv(
"Country".$obj->country_code);
1548 $this->country = $obj->country;
1551 $this->phone = $obj->phone;
1552 $this->phone_perso = $obj->phone_perso;
1553 $this->phone_mobile = $obj->phone_mobile;
1554 $this->email = $obj->email;
1555 $this->url = $obj->url;
1557 $this->socialnetworks = ($obj->socialnetworks ? (array) json_decode($obj->socialnetworks,
true) : array());
1559 $this->photo = $obj->photo;
1560 $this->statut = $obj->statut;
1561 $this->
status = $obj->statut;
1562 $this->
public = $obj->public;
1564 $this->datec = $this->db->jdate($obj->datec);
1565 $this->date_creation = $this->db->jdate($obj->datec);
1566 $this->datem = $this->db->jdate($obj->datem);
1567 $this->date_modification = $this->db->jdate($obj->datem);
1568 $this->datefin = $this->db->jdate($obj->datefin);
1569 $this->datevalid = $this->db->jdate($obj->datev);
1570 $this->date_validation = $this->db->jdate($obj->datev);
1571 $this->birth = $this->db->jdate($obj->birthday);
1573 $this->default_lang = $obj->default_lang;
1575 $this->note_private = $obj->note_private;
1576 $this->note_public = $obj->note_public;
1577 $this->morphy = $obj->morphy;
1579 $this->
typeid = $obj->fk_adherent_type;
1580 $this->
type = $obj->type;
1581 $this->need_subscription = $obj->subscription;
1583 $this->user_id = $obj->user_id;
1584 $this->user_login = $obj->user_login;
1586 $this->model_pdf = $obj->model_pdf;
1590 if ($fetch_optionals) {
1595 if ($fetch_subscriptions) {
1604 $this->error = $this->db->lasterror();
1624 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
1626 $sql =
"SELECT c.rowid, c.fk_adherent, c.fk_type, c.subscription, c.note as note_public, c.fk_bank,";
1627 $sql .=
" c.tms as datem,";
1628 $sql .=
" c.datec as datec,";
1629 $sql .=
" c.dateadh as dateh,";
1630 $sql .=
" c.datef as datef";
1631 $sql .=
" FROM ".MAIN_DB_PREFIX.
"subscription as c";
1632 $sql .=
" WHERE c.fk_adherent = ".((int) $this->
id);
1633 $sql .=
" ORDER BY c.dateadh";
1634 dol_syslog(get_class($this).
"::fetch_subscriptions", LOG_DEBUG);
1636 $resql = $this->db->query($sql);
1638 $this->subscriptions = array();
1641 while ($obj = $this->db->fetch_object($resql)) {
1643 $this->first_subscription_date = $this->db->jdate($obj->datec);
1644 $this->first_subscription_date_start = $this->db->jdate($obj->dateh);
1645 $this->first_subscription_date_end = $this->db->jdate($obj->datef);
1646 $this->first_subscription_amount = $obj->subscription;
1648 $this->last_subscription_date = $this->db->jdate($obj->datec);
1649 $this->last_subscription_date_start = $this->db->jdate($obj->dateh);
1650 $this->last_subscription_date_end = $this->db->jdate($obj->datef);
1651 $this->last_subscription_amount = $obj->subscription;
1654 $subscription->id = $obj->rowid;
1655 $subscription->fk_adherent = $obj->fk_adherent;
1656 $subscription->fk_type = $obj->fk_type;
1657 $subscription->amount = $obj->subscription;
1658 $subscription->note = $obj->note_public;
1659 $subscription->note_public = $obj->note_public;
1660 $subscription->fk_bank = $obj->fk_bank;
1661 $subscription->datem = $this->db->jdate($obj->datem);
1662 $subscription->datec = $this->db->jdate($obj->datec);
1663 $subscription->dateh = $this->db->jdate($obj->dateh);
1664 $subscription->datef = $this->db->jdate($obj->datef);
1666 $this->subscriptions[] = $subscription;
1672 $this->error = $this->db->error().
' sql='.$sql;
1688 require_once DOL_DOCUMENT_ROOT.
'/partnership/class/partnership.class.php';
1691 $this->partnerships[] = array();
1712 public function subscription($date, $amount, $accountid = 0, $operation =
'', $label =
'', $num_chq =
'', $emetteur_nom =
'', $emetteur_banque =
'', $datesubend = 0, $fk_type =
null)
1716 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
1728 $datefin = $datesubend;
1737 $subscription->fk_adherent = $this->id;
1738 $subscription->dateh = $date;
1739 $subscription->datef = $datefin;
1740 $subscription->amount = $amount;
1741 $subscription->note = $label;
1742 $subscription->note_public = $label;
1743 $subscription->fk_type = $fk_type;
1745 if (empty($subscription->user_creation_id)) {
1746 $subscription->user_creation_id = $user->id;
1749 $rowid = $subscription->create($user);
1756 $this->last_subscription_date =
dol_now();
1757 $this->last_subscription_date_start = $date;
1758 $this->last_subscription_date_end = $datefin;
1759 $this->last_subscription_amount = $amount;
1763 $this->db->commit();
1766 $this->db->rollback();
1771 $this->db->rollback();
1796 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 =
'')
1798 global
$conf, $langs, $user, $mysoc;
1802 $this->invoice =
null;
1804 dol_syslog(
"subscriptionComplementaryActions subscriptionid=".$subscriptionid.
" option=".$option.
" accountid=".$accountid.
" datesubscription=".$datesubscription.
" paymentdate=".
1805 $paymentdate.
" label=".$label.
" amount=".$amount.
" num_chq=".$num_chq.
" autocreatethirdparty=".$autocreatethirdparty);
1808 if ($option ==
'bankdirect' && $accountid) {
1809 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
1811 $acct =
new Account($this->db);
1812 $result = $acct->fetch($accountid);
1814 $dateop = $paymentdate;
1816 $insertid = $acct->addline($dateop, $operation, $label, $amount, $num_chq, 0, $user, $emetteur_nom, $emetteur_banque);
1817 if ($insertid > 0) {
1818 $inserturlid = $acct->add_url_line($insertid, $this->
id, DOL_URL_ROOT.
'/adherents/card.php?rowid=', $this->getFullName($langs),
'member');
1819 if ($inserturlid > 0) {
1821 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"subscription SET fk_bank=".((int) $insertid);
1822 $sql .=
" WHERE rowid=".((int) $subscriptionid);
1824 dol_syslog(
"subscription::subscription", LOG_DEBUG);
1825 $resql = $this->db->query($sql);
1828 $this->error = $this->db->lasterror();
1829 $this->errors[] = $this->error;
1842 if (($option ==
'bankviainvoice' && $accountid) || $option ==
'invoiceonly') {
1843 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1844 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/paymentterm.class.php';
1846 $invoice =
new Facture($this->db);
1847 $customer =
new Societe($this->db);
1850 if (!($this->fk_soc > 0)) {
1851 if ($autocreatethirdparty) {
1856 if ($this->morphy ==
'mor') {
1857 $companyname = $this->company;
1858 if (!empty($fullname)) {
1859 $companyalias = $fullname;
1862 $companyname = $fullname;
1863 if (!empty($this->company)) {
1864 $companyalias = $this->company;
1868 $result = $customer->create_from_member($this, (
string) $companyname, $companyalias);
1870 $this->error = $customer->error;
1871 $this->errors = $customer->errors;
1874 $this->fk_soc = $result;
1877 $langs->load(
"errors");
1878 $this->error = $langs->trans(
"ErrorMemberNotLinkedToAThirpartyLinkOrCreateFirst");
1879 $this->errors[] = $this->error;
1885 $result = $customer->fetch($this->fk_soc);
1887 $this->error = $customer->error;
1888 $this->errors = $customer->errors;
1896 $invoice->cond_reglement_id = $customer->cond_reglement_id;
1897 if (empty($invoice->cond_reglement_id)) {
1899 $invoice->cond_reglement_id = $paymenttermstatic->getDefaultId();
1900 if (empty($invoice->cond_reglement_id)) {
1902 $this->error =
'ErrorNoPaymentTermRECEPFound';
1903 $this->errors[] = $this->error;
1906 $invoice->socid = $this->fk_soc;
1908 if (!empty($customer->fk_account)) {
1909 $invoice->fk_account = $customer->fk_account;
1915 if (!empty($customer->mode_reglement_id)) {
1916 $invoice->mode_reglement_id = $customer->mode_reglement_id;
1922 $invoice->linked_objects[
'subscription'] = $subscriptionid;
1924 $invoice->linked_objects = array_merge($invoice->linked_objects,
GETPOST(
'other_linked_objects',
'array:int'));
1927 $result = $invoice->create($user);
1929 $this->error = $invoice->error;
1930 $this->errors = $invoice->errors;
1933 $this->invoice = $invoice;
1939 $idprodsubscription = 0;
1940 if (
getDolGlobalString(
'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS') && (isModEnabled(
"product") || isModEnabled(
"service"))) {
1945 if (
getDolGlobalString(
'ADHERENT_VAT_FOR_SUBSCRIPTIONS') ==
'defaultforfoundationcountry') {
1950 $result = $invoice->addline($label, 0, 1, $vattouse, 0, 0, $idprodsubscription, 0, $datesubscription,
'', 0, 0, 0,
'TTC', $amount, 1);
1952 $this->error = $invoice->error;
1953 $this->errors = $invoice->errors;
1960 $result = $invoice->validate($user);
1962 $this->error = $invoice->error;
1963 $this->errors = $invoice->errors;
1973 if (!$error && $option ==
'bankviainvoice' && $accountid) {
1974 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1975 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
1976 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions.lib.php';
1979 $amounts[$invoice->id] = (float)
price2num($amount);
1981 $paiement =
new Paiement($this->db);
1982 $paiement->datepaye = $paymentdate;
1983 $paiement->amounts = $amounts;
1984 $paiement->paiementcode = $operation;
1985 $paiement->paiementid =
dol_getIdFromCode($this->db, $operation,
'c_paiement',
'code',
'id', 1);
1986 $paiement->num_payment = $num_chq;
1987 $paiement->note_public = $label;
1988 $paiement->ext_payment_id = $ext_payment_id;
1989 $paiement->ext_payment_site = $ext_payment_site;
1993 $paiement_id = $paiement->create($user);
1994 if (!($paiement_id > 0)) {
1995 $this->error = $paiement->error;
1996 $this->errors = $paiement->errors;
2003 $bank_line_id = $paiement->addPaymentToBank($user,
'payment',
'(SubscriptionPayment)', $accountid, $emetteur_nom, $emetteur_banque);
2004 if (!($bank_line_id > 0)) {
2005 $this->error = $paiement->error;
2006 $this->errors = $paiement->errors;
2011 if (!$error && !empty($bank_line_id)) {
2013 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'subscription SET fk_bank='.((int) $bank_line_id);
2014 $sql .=
' WHERE rowid='.((int) $subscriptionid);
2016 $result = $this->db->query($sql);
2024 $invoice->setPaid($user);
2030 $outputlangs = $langs;
2032 $lang_id =
GETPOST(
'lang_id');
2033 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && !empty($lang_id)) {
2034 $newlang = $lang_id;
2037 $newlang = $customer->default_lang;
2039 if (!empty($newlang)) {
2041 $outputlangs->setDefaultLang($newlang);
2046 $invoice->fetch($invoice->id);
2047 $invoice->generateDocument($invoice->model_pdf, $outputlangs);
2067 global $langs,
$conf;
2073 if ($this->statut == self::STATUS_VALIDATED) {
2074 dol_syslog(get_class($this).
"::validate statut of member does not allow this", LOG_WARNING);
2080 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
2081 $sql .=
" statut = ".self::STATUS_VALIDATED;
2082 $sql .=
", datevalid = '".$this->db->idate($now).
"'";
2083 $sql .=
", fk_user_valid = ".((int) $user->id);
2084 $sql .=
" WHERE rowid = ".((int) $this->
id);
2086 dol_syslog(get_class($this).
"::validate", LOG_DEBUG);
2087 $result = $this->db->query($sql);
2092 $result = $this->
call_trigger(
'MEMBER_VALIDATE', $user);
2095 $this->db->rollback();
2100 $this->datevalid = $now;
2102 $this->db->commit();
2105 $this->error = $this->db->error();
2106 $this->db->rollback();
2120 global $langs,
$conf;
2125 if ($this->statut == self::STATUS_RESILIATED) {
2126 dol_syslog(get_class($this).
"::resiliate statut of member does not allow this", LOG_WARNING);
2132 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
2133 $sql .=
" statut = ".((int) self::STATUS_RESILIATED);
2134 $sql .=
", fk_user_valid = ".((int) $user->id);
2135 $sql .=
" WHERE rowid = ".((int) $this->
id);
2137 $result = $this->db->query($sql);
2142 $result = $this->
call_trigger(
'MEMBER_RESILIATE', $user);
2145 $this->db->rollback();
2150 $this->db->commit();
2153 $this->error = $this->db->error();
2154 $this->db->rollback();
2173 if ($this->statut == self::STATUS_EXCLUDED) {
2174 dol_syslog(get_class($this).
"::resiliate statut of member does not allow this", LOG_WARNING);
2180 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
2181 $sql .=
" statut = ".((int) self::STATUS_EXCLUDED);
2182 $sql .=
", fk_user_valid = ".((int) $user->id);
2183 $sql .=
" WHERE rowid = ".((int) $this->
id);
2185 $result = $this->db->query($sql);
2190 $result = $this->
call_trigger(
'MEMBER_EXCLUDE', $user);
2193 $this->db->rollback();
2198 $this->db->commit();
2201 $this->error = $this->db->error();
2202 $this->db->rollback();
2218 include_once DOL_DOCUMENT_ROOT.
'/mailmanspip/class/mailmanspip.class.php';
2225 $result = $mailmanspip->add_to_mailman($this);
2228 if (!empty($mailmanspip->error)) {
2229 $this->errors[] = $mailmanspip->error;
2233 foreach ($mailmanspip->mladded_ko as $tmplist => $tmpemail) {
2234 $langs->load(
"errors");
2235 $this->errors[] = $langs->trans(
"ErrorFailedToAddToMailmanList", $tmpemail, $tmplist);
2237 foreach ($mailmanspip->mladded_ok as $tmplist => $tmpemail) {
2238 $langs->load(
"mailmanspip");
2239 $this->mesgs[] = $langs->trans(
"SuccessToAddToMailmanList", $tmpemail, $tmplist);
2245 $result = $mailmanspip->add_to_spip($this);
2247 $this->errors[] = $mailmanspip->error;
2268 global
$conf, $langs;
2270 include_once DOL_DOCUMENT_ROOT.
'/mailmanspip/class/mailmanspip.class.php';
2277 $result = $mailmanspip->del_to_mailman($this);
2279 if (!empty($mailmanspip->error)) {
2280 $this->errors[] = $mailmanspip->error;
2285 foreach ($mailmanspip->mlremoved_ko as $tmplist => $tmpemail) {
2286 $langs->load(
"errors");
2287 $this->errors[] = $langs->trans(
"ErrorFailedToRemoveToMailmanList", $tmpemail, $tmplist);
2289 foreach ($mailmanspip->mlremoved_ok as $tmplist => $tmpemail) {
2290 $langs->load(
"mailmanspip");
2291 $this->mesgs[] = $langs->trans(
"SuccessToRemoveToMailmanList", $tmpemail, $tmplist);
2296 $result = $mailmanspip->del_to_spip($this);
2298 $this->errors[] = $mailmanspip->error;
2319 $langs->load(
"dict");
2321 $code = (empty($this->civility_id) ?
'' : $this->civility_id);
2325 return $langs->getLabelFromKey($this->db,
"Civility".$code,
"c_civility",
"code",
"label", $code);
2338 $langs->loadLangs([
'members',
'companies']);
2339 $nofetch = !empty($params[
'nofetch']);
2344 $langs->load(
"users");
2345 return [
'optimize' => $langs->trans(
"ShowUser")];
2347 if (!empty($this->photo)) {
2348 $photo =
'<div class="photointooltip floatright">';
2349 $photo .=
Form::showphoto(
'memberphoto', $this, 80, 0, 0,
'photoref photowithmargin photologintooltip',
'small', 0, 1);
2351 $datas[
'photo'] = $photo;
2354 $datas[
'divopen'] =
'<div class="centpercent">';
2355 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <u class="paddingrightonly">'.$langs->trans(
"Member").
'</u> '.$this->
getLibStatut(4);
2356 if (!empty($this->morphy)) {
2357 $datas[
'picto'] .=
' ' . $this->
getmorphylib(
'', 1);
2359 if (!empty($this->
ref)) {
2360 $datas[
'ref'] =
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
2362 if (!empty($this->login)) {
2363 $datas[
'login'] =
'<br><b>'.$langs->trans(
'Login').
':</b> '.$this->login;
2365 if (!empty($this->firstname) || !empty($this->lastname)) {
2366 $datas[
'name'] =
'<br><b>'.$langs->trans(
'Name').
':</b> '.$this->
getFullName($langs);
2368 if (!empty($this->company)) {
2369 $datas[
'company'] =
'<br><b>'.$langs->trans(
'Company').
':</b> '.$this->company;
2371 if (!empty($this->email)) {
2372 $datas[
'email'] =
'<br><b>'.$langs->trans(
"EMail").
':</b> '.$this->email;
2374 $datas[
'address'] =
'<br><b>'.$langs->trans(
"Address").
':</b> '.
dol_format_address($this, 1,
' ', $langs);
2376 if (isModEnabled(
'category') && !$nofetch) {
2377 require_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
2378 $form =
new Form($this->db);
2379 $datas[
'categories'] =
'<br>' . $form->showCategories($this->
id, Categorie::TYPE_MEMBER, 1);
2381 $datas[
'divclose'] =
'</div>';
2399 public function getNomUrl($withpictoimg = 0, $maxlen = 0, $option =
'card', $mode =
'', $morecss =
'', $save_lastsearch_value = -1, $notooltip = 0, $addlinktonotes = 0)
2401 global
$conf, $langs, $hookmanager;
2410 $classfortooltip =
'classfortooltip';
2414 'objecttype' => $this->element,
2415 'option' => $option,
2419 $classfortooltip =
'classforajaxtooltip';
2420 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
2426 $url = DOL_URL_ROOT.
'/adherents/card.php?rowid='.((int) $this->
id);
2427 if ($option ==
'subscription') {
2428 $url = DOL_URL_ROOT.
'/adherents/subscription.php?rowid='.((int) $this->
id);
2431 if ($option !=
'nolink') {
2433 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
2434 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
2435 $add_save_lastsearch_values = 1;
2437 if ($add_save_lastsearch_values) {
2438 $url .=
'&save_lastsearch_values=1';
2442 $linkstart .=
'<a href="'.$url.
'"';
2444 if (empty($notooltip)) {
2446 $langs->load(
"users");
2447 $label = $langs->trans(
"ShowUser");
2448 $linkclose .=
' alt="'.dolPrintHTMLForAttribute($label).
'"';
2450 $linkclose .= ($label ?
' title="'.dolPrintHTMLForAttribute($label).
'"' :
' title="tocomplete"');
2451 $linkclose .= $dataparams.
' class="'.$classfortooltip.($morecss ?
' '.$morecss :
'').
'"';
2454 $linkstart .= $linkclose.
'>';
2457 $result .= $linkstart;
2459 if ($withpictoimg) {
2460 $paddafterimage =
'';
2461 if (abs($withpictoimg) == 1 || abs($withpictoimg) == 4) {
2462 $morecss .=
' paddingrightonly';
2465 if ($withpictoimg > 0) {
2466 $picto =
'<span class="nopadding'.($morecss ?
' userimg'.$morecss :
'').
'">'.
img_object(
'',
'user', $paddafterimage.
' '.($notooltip ?
'' : $dataparams), 0, 0, $notooltip ? 0 : 1).
'</span>';
2469 $picto =
'<span class="nopadding'.($morecss ?
' userimg'.$morecss :
'').
'"'.($paddafterimage ?
' '.$paddafterimage :
'').
'>';
2470 $picto .=
Form::showphoto(
'memberphoto', $this, 0, 0, 0,
'userphoto'.(($withpictoimg == -3 || $withpictoimg == -4) ?
'small' :
''),
'mini', 0, 1);
2471 $picto .=
'</span>';
2475 if (($withpictoimg > -2 && $withpictoimg != 2) || $withpictoimg == -4) {
2477 $result .=
'<span class="nopadding valignmiddle'.((!isset($this->statut) || $this->statut) ?
'' :
' strikefordisabled').
2478 ($morecss ?
' usertext'.$morecss :
'').
'">';
2480 if ($mode ==
'login') {
2481 $result .=
dol_trunc(isset($this->login) ? $this->login :
'', $maxlen);
2482 } elseif ($mode ==
'ref') {
2483 $result .= $this->ref;
2485 $result .= $this->
getFullName($langs, 0, ($mode ==
'firstname' ? 2 : ($mode ==
'lastname' ? 4 : -1)), $maxlen);
2488 $result .=
'</span>';
2492 $result .= $linkend;
2494 if ($addlinktonotes) {
2495 if ($this->note_private) {
2496 $notetoshow = $langs->trans(
"ViewPrivateNote").
':<br>'.
dol_string_nohtmltag($this->note_private, 1);
2497 $result .=
' <span class="note inline-block">';
2498 $result .=
'<a href="'.DOL_URL_ROOT.
'/adherents/note.php?id='.$this->
id.
'" class="classfortooltip" title="'.
dol_escape_htmltag($notetoshow).
'">';
2501 $result .=
'</span>';
2505 $hookmanager->initHooks(array($this->element .
'dao'));
2506 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
2507 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
2509 $result = $hookmanager->resPrint;
2511 $result .= $hookmanager->resPrint;
2524 return $this->
LibStatut($this->
status, $this->need_subscription, $this->datefin, $mode);
2537 public function LibStatut($status, $need_subscription, $date_end_subscription, $mode = 0)
2541 $langs->load(
"members");
2545 $labelStatusShort =
'';
2547 if ($status == self::STATUS_DRAFT) {
2548 $statusType =
'status0';
2549 $labelStatus = $langs->trans(
"MemberStatusDraft");
2550 $labelStatusShort = $langs->trans(
"MemberStatusDraftShort");
2551 } elseif ($status >= self::STATUS_VALIDATED) {
2552 if ($need_subscription === 0) {
2553 $statusType =
'status4';
2554 $labelStatus = $langs->trans(
"Validated").
' - '.$langs->trans(
"MemberStatusNoSubscription");
2555 $labelStatusShort = $langs->trans(
"MemberStatusNoSubscriptionShort");
2556 } elseif (!$date_end_subscription) {
2557 $statusType =
'status1';
2558 $labelStatus = $langs->trans(
"Validated").
' - '.$langs->trans(
"WaitingSubscription");
2559 $labelStatusShort = $langs->trans(
"WaitingSubscriptionShort");
2560 } elseif ($date_end_subscription <
dol_now()) {
2561 $statusType =
'status2';
2562 $labelStatus = $langs->trans(
"Validated").
' - '.$langs->trans(
"MemberStatusActiveLate");
2563 $labelStatusShort = $langs->trans(
"MemberStatusActiveLateShort");
2565 $statusType =
'status4';
2566 $labelStatus = $langs->trans(
"Validated").
' - '.$langs->trans(
"MemberStatusPaid");
2567 $labelStatusShort = $langs->trans(
"MemberStatusPaidShort");
2569 } elseif ($status == self::STATUS_RESILIATED) {
2570 $statusType =
'status6';
2571 $labelStatus = $langs->transnoentitiesnoconv(
"MemberStatusResiliated");
2572 $labelStatusShort = $langs->transnoentitiesnoconv(
"MemberStatusResiliatedShort");
2573 } elseif ($status == self::STATUS_EXCLUDED) {
2574 $statusType =
'status10';
2575 $labelStatus = $langs->transnoentitiesnoconv(
"MemberStatusExcluded");
2576 $labelStatusShort = $langs->transnoentitiesnoconv(
"MemberStatusExcludedShort");
2579 return dolGetStatus($labelStatus, $labelStatusShort,
'', $statusType, $mode);
2592 $this->nb = array();
2594 $sql =
"SELECT count(a.rowid) as nb";
2595 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as a";
2596 $sql .=
" WHERE a.statut > 0";
2597 $sql .=
" AND a.entity IN (".getEntity(
'adherent').
")";
2599 $resql = $this->db->query($sql);
2601 while ($obj = $this->db->fetch_object($resql)) {
2602 $this->nb[
"members"] = $obj->nb;
2604 $this->db->free($resql);
2608 $this->error = $this->db->error();
2624 global
$conf, $langs;
2632 $sql =
"SELECT a.rowid, a.datefin, a.statut";
2633 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as a";
2634 $sql .=
", ".MAIN_DB_PREFIX.
"adherent_type as t";
2635 $sql .=
" WHERE a.fk_adherent_type = t.rowid";
2636 if ($mode ==
'expired') {
2637 $sql .=
" AND a.statut = ".self::STATUS_VALIDATED;
2638 $sql .=
" AND a.entity IN (".getEntity(
'adherent').
")";
2639 $sql .=
" AND ((a.datefin IS NULL or a.datefin < '".$this->db->idate($now).
"') AND t.subscription = '1')";
2640 } elseif ($mode ==
'shift') {
2641 $sql .=
" AND a.statut = ".self::STATUS_DRAFT;
2642 $sql .=
" AND a.entity IN (".getEntity(
'adherent').
")";
2645 $resql = $this->db->query($sql);
2647 $langs->load(
"members");
2654 if ($mode ==
'expired') {
2655 $warning_delay =
$conf->adherent->subscription->warning_delay / 60 / 60 / 24;
2656 $label = $langs->trans(
"MembersWithSubscriptionToReceive");
2657 $labelShort = $langs->trans(
"MembersWithSubscriptionToReceiveShort");
2658 $url = DOL_URL_ROOT.
'/adherents/list.php?mainmenu=members&statut='.self::STATUS_VALIDATED.
'&filter=outofdate';
2659 } elseif ($mode ==
'shift') {
2660 $warning_delay =
$conf->adherent->subscription->warning_delay / 60 / 60 / 24;
2661 $url = DOL_URL_ROOT.
'/adherents/list.php?mainmenu=members&statut='.
self::STATUS_DRAFT;
2662 $label = $langs->trans(
"MembersListToValid");
2663 $labelShort = $langs->trans(
"ToValidate");
2667 $response->warning_delay = $warning_delay;
2668 $response->label = $label;
2669 $response->labelShort = $labelShort;
2670 $response->url = $url;
2673 $adherentstatic =
new Adherent($this->db);
2675 while ($obj = $this->db->fetch_object($resql)) {
2676 $response->nbtodo++;
2678 $adherentstatic->datefin = $this->db->jdate($obj->datefin);
2679 $adherentstatic->statut = $obj->statut;
2680 $adherentstatic->status = $obj->statut;
2682 if ($adherentstatic->hasDelay()) {
2683 $response->nbtodolate++;
2690 $this->error = $this->db->error();
2707 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams =
null)
2709 global
$conf, $langs;
2711 $langs->load(
"orders");
2714 $modele =
'standard';
2716 if ($this->model_pdf) {
2717 $modele = $this->model_pdf;
2723 $modelpath =
"core/modules/member/doc/";
2725 return $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
2738 global $user, $langs;
2743 $this->
ref =
'ABC001';
2745 $this->specimen = 1;
2746 $this->civility_id =
'MR';
2747 $this->lastname =
'DOLIBARR';
2748 $this->firstname =
'SPECIMEN';
2749 $this->gender =
'man';
2750 $this->login =
'dolibspec';
2751 $this->pass =
'dolibspec';
2752 $this->company =
'Societe ABC';
2753 $this->
address =
'61 jump street';
2754 $this->zip =
'75000';
2755 $this->town =
'Paris';
2756 $this->country_id = 1;
2757 $this->country_code =
'FR';
2758 $this->country =
'France';
2759 $this->morphy =
'mor';
2760 $this->email =
'specimen@specimen.com';
2761 $this->socialnetworks = array(
2762 'skype' =>
'skypepseudo',
2763 'twitter' =>
'twitterpseudo',
2764 'facebook' =>
'facebookpseudo',
2765 'linkedin' =>
'linkedinpseudo',
2767 $this->phone =
'0999999999';
2768 $this->phone_perso =
'0999999998';
2769 $this->phone_mobile =
'0999999997';
2770 $this->note_public =
'This is a public note';
2771 $this->note_private =
'This is a private note';
2772 $this->birth = $now;
2778 $this->datefin = $now;
2779 $this->datevalid = $now;
2780 $this->default_lang =
'';
2783 $this->
type =
'Type adherent';
2784 $this->need_subscription = 0;
2786 $this->first_subscription_date = $now;
2787 $this->first_subscription_date_start = $this->first_subscription_date;
2788 $this->first_subscription_date_end =
dol_time_plus_duree($this->first_subscription_date_start, 1,
'y');
2789 $this->first_subscription_amount = 10;
2791 $this->last_subscription_date = $this->first_subscription_date;
2792 $this->last_subscription_date_start = $this->first_subscription_date;
2793 $this->last_subscription_date_end =
dol_time_plus_duree($this->last_subscription_date_start, 1,
'y');
2794 $this->last_subscription_amount = 10;
2838 global
$conf, $langs;
2842 $keymodified =
false;
2850 if ($this->morphy ==
'mor' && (empty($this->fullname) || $this->fullname == $this->company)) {
2851 $this->fullname = $this->company;
2852 $this->lastname = $this->company;
2857 'LDAP_MEMBER_FIELD_FULLNAME' =>
'fullname',
2858 'LDAP_MEMBER_FIELD_NAME' =>
'lastname',
2859 'LDAP_MEMBER_FIELD_LOGIN' =>
'login',
2860 'LDAP_MEMBER_FIELD_LOGIN_SAMBA' =>
'login',
2861 'LDAP_MEMBER_FIELD_MAIL' =>
'email'
2865 foreach ($ldapkey as $constname => $varname) {
2871 if (!empty($this->oldcopy) && $this->$varname != $this->oldcopy->$varname) {
2872 $keymodified =
true;
2898 foreach ($socialnetworks as $key => $value) {
2899 if ($this->socialnetworks[$value[
'label']] &&
getDolGlobalString(
'LDAP_MEMBER_FIELD_'.strtoupper($value[
'label']))) {
2900 $info[
getDolGlobalString(
'LDAP_MEMBER_FIELD_'.strtoupper($value[
'label']))] = $this->socialnetworks[$value[
'label']];
2927 if ($this->datefin &&
getDolGlobalString(
'LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION')) {
2932 if (!empty($this->pass)) {
2945 if ($this->pass_indatabase_crypted &&
getDolGlobalString(
'LDAP_MEMBER_FIELD_PASSWORD_CRYPTED')) {
2951 } elseif (!empty($this->pass_indatabase)) {
2963 if ($this->first_subscription_date &&
getDolGlobalString(
'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE')) {
2966 if (isset($this->first_subscription_amount) &&
getDolGlobalString(
'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT')) {
2967 $info[
getDolGlobalString(
'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT')] = $this->first_subscription_amount;
2969 if ($this->last_subscription_date &&
getDolGlobalString(
'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE')) {
2972 if (isset($this->last_subscription_amount) &&
getDolGlobalString(
'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT')) {
2973 $info[
getDolGlobalString(
'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT')] = $this->last_subscription_amount;
2988 $sql =
'SELECT a.rowid, a.datec as datec,';
2989 $sql .=
' a.datevalid as datev,';
2990 $sql .=
' a.tms as datem,';
2991 $sql .=
' a.fk_user_author, a.fk_user_valid, a.fk_user_mod';
2992 $sql .=
' FROM '.MAIN_DB_PREFIX.
'adherent as a';
2993 $sql .=
' WHERE a.rowid = '.((int) $id);
2995 dol_syslog(get_class($this).
"::info", LOG_DEBUG);
2996 $result = $this->db->query($sql);
2998 if ($this->db->num_rows($result)) {
2999 $obj = $this->db->fetch_object($result);
3001 $this->
id = $obj->rowid;
3003 $this->user_creation_id = $obj->fk_user_author;
3004 $this->user_validation_id = $obj->fk_user_valid;
3005 $this->user_modification_id = $obj->fk_user_mod;
3006 $this->date_creation = $this->db->jdate($obj->datec);
3007 $this->date_validation = $this->db->jdate($obj->datev);
3008 $this->date_modification = $this->db->jdate($obj->datem);
3011 $this->db->free($result);
3024 $sql =
"SELECT count(mc.email) as nb";
3025 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mailing_cibles as mc";
3026 $sql .=
" WHERE mc.email = '".$this->db->escape($this->email).
"'";
3027 $sql .=
" AND mc.statut NOT IN (-1,0)";
3029 $resql = $this->db->query($sql);
3031 $obj = $this->db->fetch_object($resql);
3034 $this->db->free($resql);
3037 $this->error = $this->db->error();
3054 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
3055 return parent::setCategoriesCommon($categories, Categorie::TYPE_MEMBER);
3068 $tables = array(
'adherent');
3083 if ($this->statut != self::STATUS_VALIDATED) {
3086 if (!$this->datefin) {
3092 return $this->datefin < ($now -
$conf->adherent->subscription->warning_delay);
3106 global
$conf, $langs, $mysoc, $user;
3112 $blockingerrormsg =
'';
3114 if (!isModEnabled(
'member')) {
3115 $langs->load(
"agenda");
3116 $this->output = $langs->trans(
'ModuleNotEnabled', $langs->transnoentitiesnoconv(
"Adherent"));
3120 $langs->load(
"agenda");
3121 $this->output = $langs->trans(
'EventRemindersByEmailNotEnabled', $langs->transnoentitiesnoconv(
"Adherent"));
3129 $listofmembersok = array();
3130 $listofmembersko = array();
3132 $arraydaysbeforeend = explode(
';', $daysbeforeendlist);
3133 foreach ($arraydaysbeforeend as $daysbeforeend) {
3134 dol_syslog(__METHOD__.
' - Process delta = '.$daysbeforeend, LOG_DEBUG);
3136 if (!is_numeric($daysbeforeend)) {
3137 $blockingerrormsg =
"Value for delta is not a numeric value";
3143 $datetosearchfor =
dol_time_plus_duree(
dol_mktime(0, 0, 0, $tmp[
'mon'], $tmp[
'mday'], $tmp[
'year'],
'tzserver'), (
int) $daysbeforeend,
'd');
3144 $datetosearchforend =
dol_time_plus_duree(
dol_mktime(23, 59, 59, $tmp[
'mon'], $tmp[
'mday'], $tmp[
'year'],
'tzserver'), (
int) $daysbeforeend,
'd');
3146 $sql =
'SELECT rowid FROM '.MAIN_DB_PREFIX.
'adherent';
3147 $sql .=
" WHERE entity = ".((int)
$conf->entity);
3148 $sql .=
" AND statut = 1";
3149 $sql .=
" AND datefin >= '".$this->db->idate($datetosearchfor).
"'";
3150 $sql .=
" AND datefin <= '".$this->db->idate($datetosearchforend).
"'";
3151 if ((
int) $fk_adherent_type > 0) {
3152 $sql .=
" AND fk_adherent_type = ".((int) $fk_adherent_type);
3156 $resql = $this->db->query($sql);
3158 $num_rows = $this->db->num_rows($resql);
3160 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
3161 $formmail =
new FormMail($this->db);
3164 while ($i < $num_rows) {
3165 $obj = $this->db->fetch_object($resql);
3169 $adherent =
new Adherent($this->db);
3170 $adherent->fetch($obj->rowid,
'', 0,
'',
true,
true);
3172 if (empty($adherent->email)) {
3174 $listofmembersko[$adherent->id] = $adherent->id;
3176 $thirdpartyres = $adherent->fetch_thirdparty();
3177 if ($thirdpartyres === -1) {
3178 $languagecodeformember = $mysoc->default_lang;
3181 $languagefromcountrycode =
getLanguageCodeFromCountryCode($adherent->country_code ? $adherent->country_code : (is_object($adherent->thirdparty) ? $adherent->thirdparty->country_code :
''));
3182 $languagecodeformember = (empty($adherent->thirdparty->default_lang) ? ($languagefromcountrycode ? $languagefromcountrycode : $mysoc->default_lang) : $adherent->thirdparty->default_lang);
3184 if (!empty($adherent->default_lang)) {
3186 $languagecodeformember = $adherent->default_lang;
3191 $outputlangs->setDefaultLang($languagecodeformember);
3192 $outputlangs->loadLangs(array(
"main",
"members"));
3193 dol_syslog(
"sendReminderForExpiredSubscription Language for member id ".$adherent->id.
" set to ".$outputlangs->defaultlang.
" mysoc->default_lang=".$mysoc->default_lang);
3195 $arraydefaultmessage =
null;
3198 if (!empty($labeltouse)) {
3199 $arraydefaultmessage = $formmail->getEMailTemplate($this->db,
'member', $user, $outputlangs, 0, 1, $labeltouse);
3202 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
3203 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0,
null, $adherent);
3207 $subject =
make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs);
3208 $msg =
make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs);
3210 $to = $adherent->email;
3213 $trackid =
'mem'.$adherent->id;
3214 $moreinheader =
'X-Dolibarr-Info: sendReminderForExpiredSubscription'.
"\r\n";
3216 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
3217 $cmail =
new CMailFile($subject, $to, $from, $msg, array(), array(), array(), $cc,
'', 0, 1,
'',
'', $trackid, $moreinheader);
3218 $result = $cmail->sendfile();
3221 $this->error .= $cmail->error.
' ';
3222 if (!is_null($cmail->errors)) {
3223 $this->errors += $cmail->errors;
3226 $listofmembersko[$adherent->id] = $adherent->id;
3229 $listofmembersok[$adherent->id] = $adherent->id;
3235 $actioncode =
'EMAIL';
3236 $extraparams = array();
3246 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic').
": ".$subject);
3247 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody').
":");
3251 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
3256 $actioncomm->type_code =
'AC_OTH_AUTO';
3257 $actioncomm->code =
'AC_'.$actioncode;
3258 $actioncomm->label = $actionmsg2;
3259 $actioncomm->note_private = $actionmsg;
3260 $actioncomm->fk_project = 0;
3261 $actioncomm->datep = $now;
3262 $actioncomm->datef = $now;
3263 $actioncomm->percentage = -1;
3264 $actioncomm->socid = (is_object($adherent->thirdparty) ? $adherent->thirdparty->id : 0);
3265 $actioncomm->contact_id = 0;
3266 $actioncomm->authorid = $user->id;
3267 $actioncomm->userownerid = $user->id;
3269 $actioncomm->email_msgid = $cmail->msgid;
3270 $actioncomm->email_from = $from;
3271 $actioncomm->email_sender =
'';
3272 $actioncomm->email_to = $to;
3273 $actioncomm->email_tocc = $sendtocc;
3274 $actioncomm->email_tobcc = $sendtobcc;
3275 $actioncomm->email_subject = $subject;
3276 $actioncomm->errors_to =
'';
3278 $actioncomm->fk_element = $adherent->id;
3279 $actioncomm->elementid = $adherent->id;
3280 $actioncomm->elementtype = $adherent->element;
3282 $actioncomm->extraparams = $extraparams;
3284 $actioncomm->create($user);
3290 $this->error .=
"Can't find email template with label=".$labeltouse.
", to use for the reminding email ";
3293 $listofmembersko[$adherent->id] = $adherent->id;
3302 $this->error = $this->db->lasterror();
3307 if ($blockingerrormsg) {
3308 $this->error = $blockingerrormsg;
3311 $this->output =
'Found '.($nbok + $nbko).
' members to send reminder to.';
3312 $this->output .=
' Send email successfully to '.$nbok.
' members';
3313 if (is_array($listofmembersok)) {
3316 foreach ($listofmembersok as $idmember) {
3318 $listofids .=
', ...';
3321 if (empty($listofids)) {
3326 $listofids .= $idmember;
3333 $this->output .= ($listofids ?
' ids='.$listofids :
'');
3336 $this->output .=
' - Canceled for '.$nbko.
' member (no email or email sending error)';
3337 if (is_array($listofmembersko)) {
3340 foreach ($listofmembersko as $idmember) {
3342 $listofids .=
', ...';
3345 if (empty($listofids)) {
3350 $listofids .= $idmember;
3356 $this->output .= ($listofids ?
' ids='.$listofids :
'');
3373 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
3375 $return =
'<div class="box-flex-item box-flex-grow-zero">';
3376 $return .=
'<div class="info-box info-box-sm">';
3377 $return .=
'<span class="info-box-icon bg-infobox-action">';
3378 if (property_exists($this,
'photo') || !empty($this->photo)) {
3379 $return .=
Form::showphoto(
'memberphoto', $this, 0, 60, 0,
'photokanban photowithmargin photologintooltip',
'small', 0, 1);
3383 $return .=
'</span>';
3384 $return .=
'<div class="info-box-content">';
3385 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this,
'getNomUrl') ? $this->
getNomUrl() : $this->ref).
'</span>';
3386 if ($selected >= 0) {
3387 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
3389 $return .=
'<br><span class="info-box-label paddingright">'.$this->getmorphylib(
'', 2).
'</span>';
3390 $return .=
'<span class="info-box-label opacitymedium">'.$this->type.
'</span>';
3392 if (method_exists($this,
'getLibStatut')) {
3393 $return .=
'<br><div class="info-box-status paddingtop">';
3394 $return .= $this->
LibStatut($this->
status, $this->need_subscription, $this->datefin, 5);
3395 $return .=
'</div>';
3397 $return .=
'</div>';
3398 $return .=
'</div>';
3399 $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.
$fields
'type' field format: 'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortf...
getKanbanView($option='', $arraydata=null)
Return clickable link of object (with eventually picto)
const STATUS_DRAFT
Draft status.
const STATUS_RESILIATED
Resiliated (membership end and was not renew)
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.
getCountry($searchkey, $withcode='', $dbtouse=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
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...
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='', $useCache=true)
Return an id or code from a code or id.
getLanguageCodeFromCountryCode($countrycode)
Return default language from country code.
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, $allowothertags=array())
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 '.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
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_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...
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|dolcrypt):/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.
dol_hash($chain, $type='0', $nosalt=0, $mode=0)
Returns a hash (non reversible encryption) of a string.
dolGetLdapPasswordHash($password, $type='md5')
Returns a specific ldap hash of a password.