38require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
40require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/class/commonpeople.class.php';
54 public $element =
'member';
59 public $table_element =
'adherent';
65 public $ismultientitymanaged = 1;
70 public $isextrafieldmanaged = 1;
75 public $picto =
'member';
93 public $pass_indatabase;
98 public $pass_indatabase_crypted;
109 public $civility_code;
179 public $socialnetworks;
227 public $phone_mobile;
253 public $default_lang;
296 public $need_subscription;
313 public $first_subscription_date;
315 public $first_subscription_date_start;
317 public $first_subscription_date_end;
319 public $first_subscription_amount;
321 public $last_subscription_date;
323 public $last_subscription_date_start;
325 public $last_subscription_date_end;
327 public $last_subscription_amount;
329 public $subscriptions = array();
338 public $partnerships = array();
354 public $fields = array(
355 'rowid' => array(
'type' =>
'integer',
'label' =>
'TechnicalID',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 10),
356 'ref' => array(
'type' =>
'varchar(30)',
'label' =>
'Ref',
'default' => 1,
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 12,
'index' => 1),
357 'entity' => array(
'type' =>
'integer',
'label' =>
'Entity',
'default' => 1,
'enabled' => 1,
'visible' => -2,
'notnull' => 1,
'position' => 15,
'index' => 1),
358 'ref_ext' => array(
'type' =>
'varchar(128)',
'label' =>
'Ref ext',
'enabled' => 1,
'visible' => 0,
'position' => 20),
359 'civility' => array(
'type' =>
'varchar(6)',
'label' =>
'Civility',
'enabled' => 1,
'visible' => -1,
'position' => 25),
360 'lastname' => array(
'type' =>
'varchar(50)',
'label' =>
'Lastname',
'enabled' => 1,
'visible' => -1,
'position' => 30,
'showoncombobox'=>1),
361 'firstname' => array(
'type' =>
'varchar(50)',
'label' =>
'Firstname',
'enabled' => 1,
'visible' => -1,
'position' => 35,
'showoncombobox'=>1),
362 'login' => array(
'type' =>
'varchar(50)',
'label' =>
'Login',
'enabled' => 1,
'visible' => -1,
'position' => 40),
363 'gender' => array(
'type' =>
'varchar(10)',
'label' =>
'Gender',
'enabled' => 1,
'visible' => -1,
'position' => 250),
364 'pass' => array(
'type' =>
'varchar(50)',
'label' =>
'Pass',
'enabled' => 1,
'visible' => -1,
'position' => 45),
365 'pass_crypted' => array(
'type' =>
'varchar(128)',
'label' =>
'Pass crypted',
'enabled' => 1,
'visible' => -1,
'position' => 50),
366 'fk_adherent_type' => array(
'type' =>
'integer',
'label' =>
'Fk adherent type',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 55),
367 'morphy' => array(
'type' =>
'varchar(3)',
'label' =>
'MorPhy',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 60),
368 'societe' => array(
'type' =>
'varchar(128)',
'label' =>
'Societe',
'enabled' => 1,
'visible' => -1,
'position' => 65,
'showoncombobox'=>2),
369 'fk_soc' => array(
'type' =>
'integer:Societe:societe/class/societe.class.php',
'label' =>
'ThirdParty',
'enabled' => 1,
'visible' => -1,
'position' => 70),
370 'address' => array(
'type' =>
'text',
'label' =>
'Address',
'enabled' => 1,
'visible' => -1,
'position' => 75),
371 'zip' => array(
'type' =>
'varchar(10)',
'label' =>
'Zip',
'enabled' => 1,
'visible' => -1,
'position' => 80),
372 'town' => array(
'type' =>
'varchar(50)',
'label' =>
'Town',
'enabled' => 1,
'visible' => -1,
'position' => 85),
373 'state_id' => array(
'type' =>
'integer',
'label' =>
'State id',
'enabled' => 1,
'visible' => -1,
'position' => 90),
374 'country' => array(
'type' =>
'integer:Ccountry:core/class/ccountry.class.php',
'label' =>
'Country',
'enabled' => 1,
'visible' => -1,
'position' => 95),
375 'email' => array(
'type' =>
'varchar(255)',
'label' =>
'Email',
'enabled' => 1,
'visible' => -1,
'position' => 100),
376 'url' =>array(
'type'=>
'varchar(255)',
'label'=>
'Url',
'enabled'=>1,
'visible'=>-1,
'position'=>110),
377 'socialnetworks' => array(
'type' =>
'text',
'label' =>
'Socialnetworks',
'enabled' => 1,
'visible' => -1,
'position' => 105),
378 'phone' => array(
'type' =>
'varchar(30)',
'label' =>
'Phone',
'enabled' => 1,
'visible' => -1,
'position' => 115),
379 'phone_perso' => array(
'type' =>
'varchar(30)',
'label' =>
'Phone perso',
'enabled' => 1,
'visible' => -1,
'position' => 120),
380 'phone_mobile' => array(
'type' =>
'varchar(30)',
'label' =>
'Phone mobile',
'enabled' => 1,
'visible' => -1,
'position' => 125),
381 'birth' => array(
'type' =>
'date',
'label' =>
'DateOfBirth',
'enabled' => 1,
'visible' => -1,
'position' => 130),
382 'photo' => array(
'type' =>
'varchar(255)',
'label' =>
'Photo',
'enabled' => 1,
'visible' => -1,
'position' => 135),
383 'public' => array(
'type' =>
'smallint(6)',
'label' =>
'Public',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 145),
384 'datefin' => array(
'type' =>
'datetime',
'label' =>
'DateEnd',
'enabled' => 1,
'visible' => -1,
'position' => 150),
385 'default_lang' =>array(
'type'=>
'varchar(6)',
'label'=>
'Default lang',
'enabled'=>1,
'visible'=>-1,
'position'=> 153),
386 'note_public' => array(
'type' =>
'text',
'label' =>
'NotePublic',
'enabled' => 1,
'visible' => 0,
'position' => 155),
387 'note_private' => array(
'type' =>
'text',
'label' =>
'NotePrivate',
'enabled' => 1,
'visible' => 0,
'position' => 160),
388 'datevalid' => array(
'type' =>
'datetime',
'label' =>
'DateValidation',
'enabled' => 1,
'visible' => -1,
'position' => 165),
389 'datec' => array(
'type' =>
'datetime',
'label' =>
'DateCreation',
'enabled' => 1,
'visible' => -1,
'position' => 170),
390 'tms' => array(
'type' =>
'timestamp',
'label' =>
'DateModification',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 175),
391 'fk_user_author' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'Fk user author',
'enabled' => 1,
'visible' => -1,
'position' => 180),
392 'fk_user_mod' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'Fk user mod',
'enabled' => 1,
'visible' => -1,
'position' => 185),
393 'fk_user_valid' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'UserValidation',
'enabled' => 1,
'visible' => -1,
'position' => 190),
394 'canvas' => array(
'type' =>
'varchar(32)',
'label' =>
'Canvas',
'enabled' => 1,
'visible' => -1,
'position' => 195),
395 'statut' => array(
'type' =>
'smallint(6)',
'label' =>
'Statut',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 500,
396 'arrayofkeyval' => array(-1 =>
'Draft', 1 =>
'Validated', 0 =>
'MemberStatusResiliatedShort', -2 =>
'MemberStatusExcludedShort')),
397 'model_pdf' => array(
'type' =>
'varchar(255)',
'label' =>
'Model pdf',
'enabled' => 1,
'visible' => 0,
'position' => 800),
398 'import_key' => array(
'type' =>
'varchar(14)',
'label' =>
'ImportId',
'enabled' => 1,
'visible' => -2,
'position' => 805)
428 $this->status = $this->statut;
432 $this->array_options = array();
455 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 =
'')
458 dol_syslog(
'Warning using deprecated Adherent::send_an_email', LOG_WARNING);
460 return $this->
sendEmail($text, $subject, $filename_list, $mimetype_list, $mimefilename_list, $addr_cc, $addr_bcc, $deliveryreceipt, $msgishtml, $errors_to, $moreinheader);
480 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 =
'')
482 global $conf, $langs;
485 if ($msgishtml == -1) {
492 dol_syslog(
'send_an_email msgishtml='.$msgishtml);
501 $from = $conf->email_from;
506 $trackid =
'mem'.$this->id;
509 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
510 $mailfile =
new CMailFile($subjecttosend, $this->email, $from, $texttosend, $filename_list, $mimetype_list, $mimefilename_list, $addr_cc, $addr_bcc, $deliveryreceipt, $msgishtml,
'',
'', $trackid, $moreinheader);
511 if ($mailfile->sendfile()) {
514 $this->error = $langs->trans(
"ErrorFailedToSendMail", $from, $this->email).
'. '.$mailfile->error;
528 global $conf, $langs;
538 if ($this->civility_id) {
539 $infos .= $langs->transnoentities(
"UserTitle").
": ".$this->
getCivilityLabel().
"\n";
541 $infos .= $langs->transnoentities(
"id").
": ".$this->
id.
"\n";
542 $infos .= $langs->transnoentities(
"ref").
": ".$this->
ref.
"\n";
543 $infos .= $langs->transnoentities(
"Lastname").
": ".$this->lastname.
"\n";
544 $infos .= $langs->transnoentities(
"Firstname").
": ".$this->firstname.
"\n";
545 $infos .= $langs->transnoentities(
"Company").
": ".$this->company.
"\n";
546 $infos .= $langs->transnoentities(
"Address").
": ".$this->address.
"\n";
547 $infos .= $langs->transnoentities(
"Zip").
": ".$this->zip.
"\n";
548 $infos .= $langs->transnoentities(
"Town").
": ".$this->town.
"\n";
549 $infos .= $langs->transnoentities(
"Country").
": ".$this->country.
"\n";
550 $infos .= $langs->transnoentities(
"EMail").
": ".$this->email.
"\n";
551 $infos .= $langs->transnoentities(
"PhonePro").
": ".$this->phone.
"\n";
552 $infos .= $langs->transnoentities(
"PhonePerso").
": ".$this->phone_perso.
"\n";
553 $infos .= $langs->transnoentities(
"PhoneMobile").
": ".$this->phone_mobile.
"\n";
554 if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
555 $infos .= $langs->transnoentities(
"Login").
": ".$this->login.
"\n";
556 $infos .= $langs->transnoentities(
"Password").
": ".$this->pass.
"\n";
558 $infos .= $langs->transnoentities(
"Birthday").
": ".$birthday.
"\n";
559 $infos .= $langs->transnoentities(
"Photo").
": ".$this->photo.
"\n";
560 $infos .= $langs->transnoentities(
"Public").
": ".
yn($this->
public);
563 $substitutionarray = array(
564 '__ID__' => $this->
id,
565 '__REF__' => $this->
ref,
566 '__MEMBER_ID__' => $this->
id,
568 '__FIRSTNAME__' => $msgishtml ?
dol_htmlentitiesbr($this->firstname) : ($this->firstname ? $this->firstname :
''),
569 '__LASTNAME__' => $msgishtml ?
dol_htmlentitiesbr($this->lastname) : ($this->lastname ? $this->lastname :
''),
571 '__COMPANY__' => $msgishtml ?
dol_htmlentitiesbr($this->company) : ($this->company ? $this->company :
''),
572 '__ADDRESS__' => $msgishtml ?
dol_htmlentitiesbr($this->address) : ($this->address ? $this->address :
''),
573 '__ZIP__' => $msgishtml ?
dol_htmlentitiesbr($this->zip) : ($this->zip ? $this->zip :
''),
574 '__TOWN__' => $msgishtml ?
dol_htmlentitiesbr($this->town) : ($this->town ? $this->town :
''),
575 '__COUNTRY__' => $msgishtml ?
dol_htmlentitiesbr($this->country) : ($this->country ? $this->country :
''),
576 '__EMAIL__' => $msgishtml ?
dol_htmlentitiesbr($this->email) : ($this->email ? $this->email :
''),
577 '__BIRTH__' => $msgishtml ?
dol_htmlentitiesbr($birthday) : ($birthday ? $birthday :
''),
578 '__PHOTO__' => $msgishtml ?
dol_htmlentitiesbr($this->photo) : ($this->photo ? $this->photo :
''),
579 '__LOGIN__' => $msgishtml ?
dol_htmlentitiesbr($this->login) : ($this->login ? $this->login :
''),
580 '__PASSWORD__' => $msgishtml ?
dol_htmlentitiesbr($this->pass) : ($this->pass ? $this->pass :
''),
581 '__PHONE__' => $msgishtml ?
dol_htmlentitiesbr($this->phone) : ($this->phone ? $this->phone :
''),
582 '__PHONEPRO__' => $msgishtml ?
dol_htmlentitiesbr($this->phone_perso) : ($this->phone_perso ? $this->phone_perso :
''),
583 '__PHONEMOBILE__' => $msgishtml ?
dol_htmlentitiesbr($this->phone_mobile) : ($this->phone_mobile ? $this->phone_mobile :
''),
606 $morphy = $this->morphy;
611 $labeltoshowm = $langs->trans(
"Moral");
612 $labeltoshowp = $langs->trans(
"Physical");
613 if ($morphy ==
'phy') {
614 $labeltoshow = $labeltoshowp;
615 if ($addbadge == 2) {
621 $s .=
'<span class="member-individual-back paddingleftimp paddingrightimp" title="'.$langs->trans(
"Physical").
'">'.$labeltoshow.
'</span>';
623 if ($morphy ==
'mor') {
624 $labeltoshow = $labeltoshowm;
625 if ($addbadge == 2) {
631 $s .=
'<span class="member-company-back paddingleftimp paddingrightimp" title="'.$langs->trans(
"Moral").
'">'.$labeltoshow.
'</span>';
634 if ($morphy ==
'phy') {
635 $s = $langs->trans(
"Physical");
636 } elseif ($morphy ==
'mor') {
637 $s = $langs->trans(
"Moral");
651 public function create($user, $notrigger = 0)
653 global $conf, $langs, $mysoc;
660 $this->import_key = trim($this->import_key);
663 if (!empty($conf->global->ADHERENT_MAIL_REQUIRED) && !isValidEMail($this->email)) {
664 $langs->load(
"errors");
665 $this->error = $langs->trans(
"ErrorBadEMail", $this->email);
671 if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
672 if (empty($this->login)) {
673 $this->error = $langs->trans(
"ErrorWrongValueForParameterX",
"Login");
681 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"adherent";
682 $sql .=
" (ref, datec,login,fk_user_author,fk_user_mod,fk_user_valid,morphy,fk_adherent_type,entity,import_key, ip)";
685 $sql .=
", '".$this->db->idate($this->datec).
"'";
686 $sql .=
", ".($this->login ?
"'".$this->db->escape($this->login).
"'" :
"null");
687 $sql .=
", ".($user->id > 0 ? $user->id :
"null");
688 $sql .=
", null, null, '".$this->db->escape($this->morphy).
"'";
689 $sql .=
", ".((int) $this->
typeid);
690 $sql .=
", ".$conf->entity;
691 $sql .=
", ".(!empty($this->import_key) ?
"'".$this->db->escape($this->import_key).
"'" :
"null");
692 $sql .=
", ".(!empty($this->ip) ?
"'".$this->db->escape($this->ip).
"'" :
"null");
695 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
696 $result = $this->db->query($sql);
698 $id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"adherent");
703 $this->
ref = (string) $id;
708 require_once $modfile;
710 $modCodeMember =
new $modname;
711 $this->
ref = $modCodeMember->getNextValue($mysoc, $this);
719 $result = $this->
update($user, 1, 1, 0, 0,
'add');
721 $this->db->rollback();
726 if ($this->user_id) {
728 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET";
729 $sql .=
" fk_member = ".((int) $this->
id);
730 $sql .=
" WHERE rowid = ".((int) $this->user_id);
731 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
732 $resql = $this->db->query($sql);
734 $this->error =
'Failed to update user to make link with member';
735 $this->db->rollback();
749 if (count($this->errors)) {
750 dol_syslog(get_class($this).
"::create ".implode(
',', $this->errors), LOG_ERR);
751 $this->db->rollback();
758 $this->error =
'Failed to get last insert id';
759 dol_syslog(get_class($this).
"::create ".$this->error, LOG_ERR);
760 $this->db->rollback();
764 $this->error = $this->db->error();
765 $this->db->rollback();
782 public function update($user, $notrigger = 0, $nosyncuser = 0, $nosyncuserpass = 0, $nosyncthirdparty = 0, $action =
'update')
784 global $conf, $langs, $hookmanager;
786 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
791 dol_syslog(get_class($this).
"::update notrigger=".$notrigger.
", nosyncuser=".$nosyncuser.
", nosyncuserpass=".$nosyncuserpass.
" nosyncthirdparty=".$nosyncthirdparty.
", email=".$this->email);
794 $this->lastname = trim($this->lastname) ? trim($this->lastname) : trim($this->lastname);
795 $this->firstname = trim($this->firstname) ? trim($this->firstname) : trim($this->firstname);
796 $this->gender = trim($this->gender);
797 $this->address = ($this->address ? $this->address : $this->address);
798 $this->zip = ($this->zip ? $this->zip : $this->zip);
799 $this->town = ($this->town ? $this->town : $this->town);
800 $this->country_id = ($this->country_id > 0 ? $this->country_id : $this->country_id);
801 $this->state_id = ($this->state_id > 0 ? $this->state_id : $this->state_id);
802 $this->note_public = ($this->note_public ? $this->note_public : $this->note_public);
803 $this->note_private = ($this->note_private ? $this->note_private : $this->note_private);
804 $this->url = $this->url ?
clean_url($this->url, 0) :
'';
807 if (!empty($conf->global->ADHERENT_MAIL_REQUIRED) && !isValidEMail($this->email)) {
808 $langs->load(
"errors");
809 $this->error = $langs->trans(
"ErrorBadEMail", $this->email);
815 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
816 $sql .=
" ref = '".$this->db->escape($this->
ref).
"'";
817 $sql .=
", civility = ".($this->civility_id ?
"'".$this->db->escape($this->civility_id).
"'" :
"null");
818 $sql .=
", firstname = ".($this->firstname ?
"'".$this->db->escape($this->firstname).
"'" :
"null");
819 $sql .=
", lastname = ".($this->lastname ?
"'".$this->db->escape($this->lastname).
"'" :
"null");
820 $sql .=
", gender = ".($this->gender != -1 ?
"'".$this->db->escape($this->gender).
"'" :
"null");
821 $sql .=
", login = ".($this->login ?
"'".$this->db->escape($this->login).
"'" :
"null");
822 $sql .=
", societe = ".($this->company ?
"'".$this->db->escape($this->company).
"'" : ($this->societe ?
"'".$this->db->escape($this->societe).
"'" :
"null"));
824 $sql .=
", fk_soc = ".($this->socid > 0 ? $this->db->escape($this->socid) :
"null");
826 $sql .=
", address = ".($this->address ?
"'".$this->db->escape($this->address).
"'" :
"null");
827 $sql .=
", zip = ".($this->zip ?
"'".$this->db->escape($this->zip).
"'" :
"null");
828 $sql .=
", town = ".($this->town ?
"'".$this->db->escape($this->town).
"'" :
"null");
829 $sql .=
", country = ".($this->country_id > 0 ? $this->db->escape($this->country_id) :
"null");
830 $sql .=
", state_id = ".($this->state_id > 0 ? $this->db->escape($this->state_id) :
"null");
831 $sql .=
", email = '".$this->db->escape($this->email).
"'";
832 $sql .=
", url = ".(!empty($this->url) ?
"'".$this->db->escape($this->url).
"'" :
"null");
833 $sql .=
", socialnetworks = ".($this->socialnetworks ?
"'".$this->db->escape(json_encode($this->socialnetworks)).
"'" :
"null");
834 $sql .=
", phone = ".($this->phone ?
"'".$this->db->escape($this->phone).
"'" :
"null");
835 $sql .=
", phone_perso = ".($this->phone_perso ?
"'".$this->db->escape($this->phone_perso).
"'" :
"null");
836 $sql .=
", phone_mobile = ".($this->phone_mobile ?
"'".$this->db->escape($this->phone_mobile).
"'" :
"null");
837 $sql .=
", note_private = ".($this->note_private ?
"'".$this->db->escape($this->note_private).
"'" :
"null");
838 $sql .=
", note_public = ".($this->note_public ?
"'".$this->db->escape($this->note_public).
"'" :
"null");
839 $sql .=
", photo = ".($this->photo ?
"'".$this->db->escape($this->photo).
"'" :
"null");
840 $sql .=
", public = '".$this->db->escape($this->
public).
"'";
841 $sql .=
", statut = ".$this->db->escape($this->
statut);
842 $sql .=
", default_lang = ".(!empty($this->default_lang) ?
"'".$this->db->escape($this->default_lang).
"'" :
"null");
843 $sql .=
", fk_adherent_type = ".$this->db->escape($this->
typeid);
844 $sql .=
", morphy = '".$this->db->escape($this->morphy).
"'";
845 $sql .=
", birth = ".($this->birth ?
"'".$this->db->idate($this->birth).
"'" :
"null");
847 if ($this->datefin) {
848 $sql .=
", datefin = '".$this->db->idate($this->datefin).
"'";
850 if ($this->datevalid) {
851 $sql .=
", datevalid = '".$this->db->idate($this->datevalid).
"'";
853 $sql .=
", fk_user_mod = ".($user->id > 0 ? $user->id :
'null');
854 $sql .=
" WHERE rowid = ".((int) $this->
id);
857 if (!empty($this->oldcopy) && $this->
typeid != $this->oldcopy->typeid) {
858 $sql2 =
"SELECT libelle as label";
859 $sql2 .=
" FROM ".MAIN_DB_PREFIX.
"adherent_type";
860 $sql2 .=
" WHERE rowid = ".((int) $this->
typeid);
861 $resql2 = $this->db->query($sql2);
863 while ($obj = $this->db->fetch_object($resql2)) {
864 $this->
type = $obj->label;
869 dol_syslog(get_class($this).
"::update update member", LOG_DEBUG);
870 $resql = $this->db->query($sql);
872 unset($this->country_code);
873 unset($this->country);
874 unset($this->state_code);
877 $nbrowsaffected += $this->db->affected_rows($resql);
890 if (!$error && $this->pass) {
891 dol_syslog(get_class($this).
"::update update password");
892 if ($this->pass != $this->pass_indatabase && $this->pass != $this->pass_indatabase_crypted) {
893 $isencrypted = empty($conf->global->DATABASE_PWD_ENCRYPTED) ? 0 : 1;
896 $result = $this->
setPassword($user, $this->pass, $isencrypted, $notrigger, $nosyncuserpass);
897 if (!$nbrowsaffected) {
905 dol_syslog(get_class($this).
"::update update link to user");
906 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = NULL WHERE fk_member = ".((int) $this->
id);
907 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
908 $resql = $this->db->query($sql);
910 $this->error = $this->db->error();
911 $this->db->rollback();
915 if ($this->user_id > 0) {
916 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = ".((int) $this->
id).
" WHERE rowid = ".((int) $this->user_id);
917 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
918 $resql = $this->db->query($sql);
920 $this->error = $this->db->error();
921 $this->db->rollback();
927 if (!$error && $nbrowsaffected) {
929 if (!$error && $this->user_id > 0 && !$nosyncuser) {
930 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
932 dol_syslog(get_class($this).
"::update update linked user");
934 $luser =
new User($this->db);
935 $result = $luser->fetch($this->user_id);
942 if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
943 $luser->login = $this->login;
946 $luser->ref = $this->ref;
947 $luser->civility_id = $this->civility_id;
948 $luser->firstname = $this->firstname;
949 $luser->lastname = $this->lastname;
950 $luser->gender = $this->gender;
951 $luser->pass = $this->pass;
954 $luser->birth = $this->birth;
956 $luser->address = $this->address;
957 $luser->zip = $this->zip;
958 $luser->town = $this->town;
959 $luser->country_id = $this->country_id;
960 $luser->state_id = $this->state_id;
962 $luser->email = $this->email;
963 $luser->socialnetworks = $this->socialnetworks;
964 $luser->office_phone = $this->phone;
965 $luser->user_mobile = $this->phone_mobile;
967 $luser->lang = $this->default_lang;
969 $luser->fk_member = $this->id;
971 $result = $luser->update($user, 0, 1, 1);
973 $this->error = $luser->error;
974 dol_syslog(get_class($this).
"::update ".$this->error, LOG_ERR);
978 $this->error = $luser->error;
984 if (!$error && $this->fk_soc > 0 && !$nosyncthirdparty) {
985 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
987 dol_syslog(get_class($this).
"::update update linked thirdparty");
991 $lthirdparty =
new Societe($this->db);
992 $result = $lthirdparty->fetch($this->fk_soc);
995 $lthirdparty->address = $this->address;
996 $lthirdparty->zip = $this->zip;
997 $lthirdparty->town = $this->town;
998 $lthirdparty->email = $this->email;
999 $lthirdparty->socialnetworks = $this->socialnetworks;
1000 $lthirdparty->phone = $this->phone;
1001 $lthirdparty->state_id = $this->state_id;
1002 $lthirdparty->country_id = $this->country_id;
1004 $lthirdparty->default_lang = $this->default_lang;
1006 $result = $lthirdparty->update($this->fk_soc, $user, 0, 1, 1,
'update');
1009 $this->error = $lthirdparty->error;
1010 $this->errors = $lthirdparty->errors;
1011 dol_syslog(get_class($this).
"::update ".$this->error, LOG_ERR);
1014 } elseif ($result < 0) {
1015 $this->error = $lthirdparty->error;
1021 if (!$error && !$notrigger) {
1031 $this->db->commit();
1032 return $nbrowsaffected;
1034 $this->db->rollback();
1038 $this->db->rollback();
1039 $this->error = $this->db->lasterror();
1059 $sql =
"SELECT rowid, datec as dateop, dateadh as datedeb, datef as datefin";
1060 $sql .=
" FROM ".MAIN_DB_PREFIX.
"subscription";
1061 $sql .=
" WHERE fk_adherent = ".((int) $this->
id);
1062 $sql .=
" ORDER by dateadh DESC";
1064 dol_syslog(get_class($this).
"::update_end_date", LOG_DEBUG);
1065 $resql = $this->db->query($sql);
1067 $obj = $this->db->fetch_object($resql);
1068 $dateop = $this->db->jdate($obj->dateop);
1069 $datedeb = $this->db->jdate($obj->datedeb);
1070 $datefin = $this->db->jdate($obj->datefin);
1072 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
1073 $sql .=
" datefin=".($datefin !=
'' ?
"'".$this->db->idate($datefin).
"'" :
"null");
1074 $sql .=
" WHERE rowid = ".((int) $this->
id);
1076 dol_syslog(get_class($this).
"::update_end_date", LOG_DEBUG);
1077 $resql = $this->db->query($sql);
1079 $this->last_subscription_date = $dateop;
1080 $this->last_subscription_date_start = $datedeb;
1081 $this->last_subscription_date_end = $datefin;
1082 $this->datefin = $datefin;
1083 $this->db->commit();
1086 $this->db->rollback();
1090 $this->error = $this->db->lasterror();
1091 $this->db->rollback();
1104 public function delete($rowid, $user, $notrigger = 0)
1106 global $conf, $langs;
1113 if (empty($rowid)) {
1119 if (!$error && !$notrigger) {
1129 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"categorie_member WHERE fk_member = ".((int) $rowid);
1130 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1131 $resql = $this->db->query($sql);
1134 $this->error .= $this->db->lasterror();
1140 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"subscription WHERE fk_adherent = ".((int) $rowid);
1141 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1142 $resql = $this->db->query($sql);
1145 $this->error .= $this->db->lasterror();
1155 $this->error .= $this->db->lasterror();
1166 dol_syslog(get_class($this).
"::delete erreur ".$errorflag.
" ".$this->error, LOG_ERR);
1172 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"adherent WHERE rowid = ".((int) $rowid);
1173 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1174 $resql = $this->db->query($sql);
1177 $this->error .= $this->db->lasterror();
1183 $this->db->commit();
1186 $this->db->rollback();
1202 public function setPassword($user, $password =
'', $isencrypted = 0, $notrigger = 0, $nosyncuser = 0)
1204 global $conf, $langs;
1208 dol_syslog(get_class($this).
"::setPassword user=".$user->id.
" password=".preg_replace(
'/./i',
'*', $password).
" isencrypted=".$isencrypted);
1212 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
1217 $password_crypted =
dol_hash($password);
1219 $password_indatabase =
'';
1220 if (!$isencrypted) {
1221 $password_indatabase = $password;
1227 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent";
1228 $sql .=
" SET pass_crypted = '".$this->db->escape($password_crypted).
"'";
1231 $sql .=
", pass = null";
1233 $sql .=
", pass = '".$this->db->escape($password_indatabase).
"'";
1235 $sql .=
" WHERE rowid = ".((int) $this->
id);
1238 dol_syslog(get_class($this).
"::setPassword", LOG_DEBUG);
1239 $result = $this->db->query($sql);
1241 $nbaffectedrows = $this->db->affected_rows($result);
1243 if ($nbaffectedrows) {
1244 $this->pass = $password;
1245 $this->pass_indatabase = $password_indatabase;
1246 $this->pass_indatabase_crypted = $password_crypted;
1248 if ($this->user_id && !$nosyncuser) {
1249 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
1253 $luser =
new User($this->db);
1254 $result = $luser->fetch($this->user_id);
1257 $result = $luser->setPassword($user, $this->pass, 0, 0, 1);
1258 if (is_int($result) && $result < 0) {
1259 $this->error = $luser->error;
1260 dol_syslog(get_class($this).
"::setPassword ".$this->error, LOG_ERR);
1264 $this->error = $luser->error;
1269 if (!$error && !$notrigger) {
1271 $result = $this->
call_trigger(
'MEMBER_NEW_PASSWORD', $user);
1274 $this->db->rollback();
1280 $this->db->commit();
1283 $this->db->rollback();
1287 $this->db->rollback();
1302 global $conf, $langs;
1307 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = NULL WHERE fk_member = ".((int) $this->
id);
1308 dol_syslog(get_class($this).
"::setUserId", LOG_DEBUG);
1309 $resql = $this->db->query($sql);
1311 $this->error = $this->db->error();
1312 $this->db->rollback();
1318 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = ".((int) $this->
id);
1319 $sql .=
" WHERE rowid = ".((int) $userid);
1320 dol_syslog(get_class($this).
"::setUserId", LOG_DEBUG);
1321 $resql = $this->db->query($sql);
1323 $this->error = $this->db->error();
1324 $this->db->rollback();
1329 $this->db->commit();
1343 global $conf, $langs;
1348 if ($thirdpartyid > 0) {
1349 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET fk_soc = null";
1350 $sql .=
" WHERE fk_soc = ".((int) $thirdpartyid);
1351 $sql .=
" AND entity = ".$conf->entity;
1352 dol_syslog(get_class($this).
"::setThirdPartyId", LOG_DEBUG);
1353 $resql = $this->db->query($sql);
1357 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET fk_soc = ".($thirdpartyid > 0 ? $thirdpartyid :
'null');
1358 $sql .=
" WHERE rowid = ".((int) $this->
id);
1360 dol_syslog(get_class($this).
"::setThirdPartyId", LOG_DEBUG);
1361 $resql = $this->db->query($sql);
1363 $this->db->commit();
1366 $this->error = $this->db->error();
1367 $this->db->rollback();
1385 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"adherent";
1386 $sql .=
" WHERE login='".$this->db->escape($login).
"'";
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);
1413 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"adherent";
1414 $sql .=
" WHERE firstname='".$this->db->escape($firstname).
"'";
1415 $sql .=
" AND lastname='".$this->db->escape($lastname).
"'";
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);
1440 public function fetch($rowid, $ref =
'', $fk_soc =
'', $ref_ext =
'', $fetch_optionals =
true, $fetch_subscriptions =
true)
1444 $sql =
"SELECT d.rowid, d.ref, d.ref_ext, d.civility as civility_code, d.gender, d.firstname, d.lastname,";
1445 $sql .=
" d.societe as company, d.fk_soc, d.statut, d.public, d.address, d.zip, d.town, d.note_private,";
1446 $sql .=
" d.note_public,";
1447 $sql .=
" d.email, d.url, d.socialnetworks, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass, d.pass_crypted,";
1448 $sql .=
" d.photo, d.fk_adherent_type, d.morphy, d.entity,";
1449 $sql .=
" d.datec as datec,";
1450 $sql .=
" d.tms as datem,";
1451 $sql .=
" d.datefin as datefin, d.default_lang,";
1452 $sql .=
" d.birth as birthday,";
1453 $sql .=
" d.datevalid as datev,";
1454 $sql .=
" d.country,";
1455 $sql .=
" d.state_id,";
1456 $sql .=
" d.model_pdf,";
1457 $sql .=
" c.rowid as country_id, c.code as country_code, c.label as country,";
1458 $sql .=
" dep.nom as state, dep.code_departement as state_code,";
1459 $sql .=
" t.libelle as type, t.subscription as subscription,";
1460 $sql .=
" u.rowid as user_id, u.login as user_login";
1461 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent_type as t, ".MAIN_DB_PREFIX.
"adherent as d";
1462 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as c ON d.country = c.rowid";
1463 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as dep ON d.state_id = dep.rowid";
1464 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON d.rowid = u.fk_member";
1465 $sql .=
" WHERE d.fk_adherent_type = t.rowid";
1467 $sql .=
" AND d.rowid=".((int) $rowid);
1468 } elseif ($ref || $fk_soc) {
1469 $sql .=
" AND d.entity IN (".getEntity(
'adherent').
")";
1471 $sql .=
" AND d.ref='".$this->db->escape($ref).
"'";
1472 } elseif ($fk_soc > 0) {
1473 $sql .=
" AND d.fk_soc=".((int) $fk_soc);
1475 } elseif ($ref_ext) {
1476 $sql .=
" AND d.ref_ext='".$this->db->escape($ref_ext).
"'";
1479 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
1480 $resql = $this->db->query($sql);
1482 if ($this->db->num_rows($resql)) {
1483 $obj = $this->db->fetch_object($resql);
1485 $this->entity = $obj->entity;
1486 $this->
id = $obj->rowid;
1487 $this->
ref = $obj->ref;
1488 $this->ref_ext = $obj->ref_ext;
1490 $this->civility_id = $obj->civility_code;
1491 $this->civility_code = $obj->civility_code;
1492 $this->civility = $obj->civility_code ? ($langs->trans(
"Civility".$obj->civility_code) != (
"Civility".$obj->civility_code) ? $langs->trans(
"Civility".$obj->civility_code) : $obj->civility_code) :
'';
1494 $this->firstname = $obj->firstname;
1495 $this->lastname = $obj->lastname;
1496 $this->gender = $obj->gender;
1497 $this->login = $obj->login;
1498 $this->societe = $obj->company;
1499 $this->company = $obj->company;
1500 $this->socid = $obj->fk_soc;
1501 $this->fk_soc = $obj->fk_soc;
1502 $this->address = $obj->address;
1503 $this->zip = $obj->zip;
1504 $this->town = $obj->town;
1506 $this->pass = $obj->pass;
1507 $this->pass_indatabase = $obj->pass;
1508 $this->pass_indatabase_crypted = $obj->pass_crypted;
1510 $this->state_id = $obj->state_id;
1511 $this->state_code = $obj->state_id ? $obj->state_code :
'';
1512 $this->state = $obj->state_id ? $obj->state :
'';
1514 $this->country_id = $obj->country_id;
1515 $this->country_code = $obj->country_code;
1516 if ($langs->trans(
"Country".$obj->country_code) !=
"Country".$obj->country_code) {
1517 $this->country = $langs->transnoentitiesnoconv(
"Country".$obj->country_code);
1519 $this->country = $obj->country;
1522 $this->phone = $obj->phone;
1523 $this->phone_perso = $obj->phone_perso;
1524 $this->phone_mobile = $obj->phone_mobile;
1525 $this->email = $obj->email;
1526 $this->url = $obj->url;
1528 $this->socialnetworks = ($obj->socialnetworks ? (array) json_decode($obj->socialnetworks,
true) : array());
1530 $this->photo = $obj->photo;
1531 $this->
statut = $obj->statut;
1532 $this->status = $obj->statut;
1533 $this->
public = $obj->public;
1535 $this->datec = $this->db->jdate($obj->datec);
1536 $this->date_creation = $this->db->jdate($obj->datec);
1537 $this->datem = $this->db->jdate($obj->datem);
1538 $this->date_modification = $this->db->jdate($obj->datem);
1539 $this->datefin = $this->db->jdate($obj->datefin);
1540 $this->datevalid = $this->db->jdate($obj->datev);
1541 $this->date_validation = $this->db->jdate($obj->datev);
1542 $this->birth = $this->db->jdate($obj->birthday);
1544 $this->default_lang = $obj->default_lang;
1546 $this->note_private = $obj->note_private;
1547 $this->note_public = $obj->note_public;
1548 $this->morphy = $obj->morphy;
1550 $this->
typeid = $obj->fk_adherent_type;
1551 $this->
type = $obj->type;
1552 $this->need_subscription = $obj->subscription;
1554 $this->user_id = $obj->user_id;
1555 $this->user_login = $obj->user_login;
1557 $this->model_pdf = $obj->model_pdf;
1561 if ($fetch_optionals) {
1566 if ($fetch_subscriptions) {
1575 $this->error = $this->db->lasterror();
1595 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
1597 $sql =
"SELECT c.rowid, c.fk_adherent, c.fk_type, c.subscription, c.note as note_public, c.fk_bank,";
1598 $sql .=
" c.tms as datem,";
1599 $sql .=
" c.datec as datec,";
1600 $sql .=
" c.dateadh as dateh,";
1601 $sql .=
" c.datef as datef";
1602 $sql .=
" FROM ".MAIN_DB_PREFIX.
"subscription as c";
1603 $sql .=
" WHERE c.fk_adherent = ".((int) $this->
id);
1604 $sql .=
" ORDER BY c.dateadh";
1605 dol_syslog(get_class($this).
"::fetch_subscriptions", LOG_DEBUG);
1607 $resql = $this->db->query($sql);
1609 $this->subscriptions = array();
1612 while ($obj = $this->db->fetch_object($resql)) {
1614 $this->first_subscription_date = $this->db->jdate($obj->datec);
1615 $this->first_subscription_date_start = $this->db->jdate($obj->dateh);
1616 $this->first_subscription_date_end = $this->db->jdate($obj->datef);
1617 $this->first_subscription_amount = $obj->subscription;
1619 $this->last_subscription_date = $this->db->jdate($obj->datec);
1620 $this->last_subscription_date_start = $this->db->jdate($obj->dateh);
1621 $this->last_subscription_date_end = $this->db->jdate($obj->datef);
1622 $this->last_subscription_amount = $obj->subscription;
1625 $subscription->id = $obj->rowid;
1626 $subscription->fk_adherent = $obj->fk_adherent;
1627 $subscription->fk_type = $obj->fk_type;
1628 $subscription->amount = $obj->subscription;
1629 $subscription->note = $obj->note_public;
1630 $subscription->note_public = $obj->note_public;
1631 $subscription->fk_bank = $obj->fk_bank;
1632 $subscription->datem = $this->db->jdate($obj->datem);
1633 $subscription->datec = $this->db->jdate($obj->datec);
1634 $subscription->dateh = $this->db->jdate($obj->dateh);
1635 $subscription->datef = $this->db->jdate($obj->datef);
1637 $this->subscriptions[] = $subscription;
1643 $this->error = $this->db->error().
' sql='.$sql;
1659 require_once DOL_DOCUMENT_ROOT.
'/partnership/class/partnership.class.php';
1662 $this->partnerships[] = array();
1683 public function subscription($date, $amount, $accountid = 0, $operation =
'', $label =
'', $num_chq =
'', $emetteur_nom =
'', $emetteur_banque =
'', $datesubend = 0, $fk_type =
null)
1685 global $conf, $langs, $user;
1687 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
1699 $datefin = $datesubend;
1708 $subscription->fk_adherent = $this->id;
1709 $subscription->dateh = $date;
1710 $subscription->datef = $datefin;
1711 $subscription->amount = $amount;
1712 $subscription->note = $label;
1713 $subscription->note_public = $label;
1714 $subscription->fk_type = $fk_type;
1716 $rowid = $subscription->create($user);
1723 $this->last_subscription_date =
dol_now();
1724 $this->last_subscription_date_start = $date;
1725 $this->last_subscription_date_end = $datefin;
1726 $this->last_subscription_amount = $amount;
1730 $this->db->commit();
1733 $this->db->rollback();
1738 $this->db->rollback();
1763 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 =
'')
1765 global $conf, $langs, $user, $mysoc;
1769 $this->invoice =
null;
1771 dol_syslog(
"subscriptionComplementaryActions subscriptionid=".$subscriptionid.
" option=".$option.
" accountid=".$accountid.
" datesubscription=".$datesubscription.
" paymentdate=".
1772 $paymentdate.
" label=".$label.
" amount=".$amount.
" num_chq=".$num_chq.
" autocreatethirdparty=".$autocreatethirdparty);
1775 if ($option ==
'bankdirect' && $accountid) {
1776 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
1778 $acct =
new Account($this->db);
1779 $result = $acct->fetch($accountid);
1781 $dateop = $paymentdate;
1783 $insertid = $acct->addline($dateop, $operation, $label, $amount, $num_chq,
'', $user, $emetteur_nom, $emetteur_banque);
1784 if ($insertid > 0) {
1785 $inserturlid = $acct->add_url_line($insertid, $this->
id, DOL_URL_ROOT.
'/adherents/card.php?rowid=', $this->getFullname($langs),
'member');
1786 if ($inserturlid > 0) {
1788 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"subscription SET fk_bank=".((int) $insertid);
1789 $sql .=
" WHERE rowid=".((int) $subscriptionid);
1791 dol_syslog(
"subscription::subscription", LOG_DEBUG);
1792 $resql = $this->db->query($sql);
1795 $this->error = $this->db->lasterror();
1796 $this->errors[] = $this->error;
1809 if (($option ==
'bankviainvoice' && $accountid) || $option ==
'invoiceonly') {
1810 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1811 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/paymentterm.class.php';
1813 $invoice =
new Facture($this->db);
1814 $customer =
new Societe($this->db);
1817 if (!($this->fk_soc > 0)) {
1818 if ($autocreatethirdparty) {
1823 if ($this->morphy ==
'mor') {
1824 $companyname = $this->company;
1825 if (!empty($fullname)) {
1826 $companyalias = $fullname;
1829 $companyname = $fullname;
1830 if (!empty($this->company)) {
1831 $companyalias = $this->company;
1835 $result = $customer->create_from_member($this, $companyname, $companyalias);
1837 $this->error = $customer->error;
1838 $this->errors = $customer->errors;
1841 $this->fk_soc = $result;
1844 $langs->load(
"errors");
1845 $this->error = $langs->trans(
"ErrorMemberNotLinkedToAThirpartyLinkOrCreateFirst");
1846 $this->errors[] = $this->error;
1852 $result = $customer->fetch($this->fk_soc);
1854 $this->error = $customer->error;
1855 $this->errors = $customer->errors;
1863 $invoice->cond_reglement_id = $customer->cond_reglement_id;
1864 if (empty($invoice->cond_reglement_id)) {
1866 $invoice->cond_reglement_id = $paymenttermstatic->getDefaultId();
1867 if (empty($invoice->cond_reglement_id)) {
1869 $this->error =
'ErrorNoPaymentTermRECEPFound';
1870 $this->errors[] = $this->error;
1873 $invoice->socid = $this->fk_soc;
1878 $invoice->linked_objects[
'subscription'] = $subscriptionid;
1879 if (!empty($_POST[
'other_linked_objects']) && is_array($_POST[
'other_linked_objects'])) {
1880 $invoice->linked_objects = array_merge($invoice->linked_objects, $_POST[
'other_linked_objects']);
1883 $result = $invoice->create($user);
1885 $this->error = $invoice->error;
1886 $this->errors = $invoice->errors;
1889 $this->invoice = $invoice;
1895 $idprodsubscription = 0;
1896 if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (isModEnabled(
"product") || isModEnabled(
"service"))) {
1897 $idprodsubscription = $conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS;
1901 if (isset($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) && $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS ==
'defaultforfoundationcountry') {
1905 $result = $invoice->addline($label, 0, 1, $vattouse, 0, 0, $idprodsubscription, 0, $datesubscription,
'', 0, 0,
'',
'TTC', $amount, 1);
1907 $this->error = $invoice->error;
1908 $this->errors = $invoice->errors;
1915 $result = $invoice->validate($user);
1917 $this->error = $invoice->error;
1918 $this->errors = $invoice->errors;
1928 if (!$error && $option ==
'bankviainvoice' && $accountid) {
1929 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1930 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
1931 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions.lib.php';
1934 $amounts[$invoice->id] =
price2num($amount);
1936 $paiement =
new Paiement($this->db);
1937 $paiement->datepaye = $paymentdate;
1938 $paiement->amounts = $amounts;
1939 $paiement->paiementcode = $operation;
1940 $paiement->paiementid =
dol_getIdFromCode($this->db, $operation,
'c_paiement',
'code',
'id', 1);
1941 $paiement->num_payment = $num_chq;
1942 $paiement->note_public = $label;
1943 $paiement->ext_payment_id = $ext_payment_id;
1944 $paiement->ext_payment_site = $ext_payment_site;
1948 $paiement_id = $paiement->create($user);
1949 if (!($paiement_id > 0)) {
1950 $this->error = $paiement->error;
1951 $this->errors = $paiement->errors;
1958 $bank_line_id = $paiement->addPaymentToBank($user,
'payment',
'(SubscriptionPayment)', $accountid, $emetteur_nom, $emetteur_banque);
1959 if (!($bank_line_id > 0)) {
1960 $this->error = $paiement->error;
1961 $this->errors = $paiement->errors;
1966 if (!$error && !empty($bank_line_id)) {
1968 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'subscription SET fk_bank='.((int) $bank_line_id);
1969 $sql .=
' WHERE rowid='.((int) $subscriptionid);
1971 $result = $this->db->query($sql);
1979 $invoice->setPaid($user);
1985 $outputlangs = $langs;
1987 $lang_id =
GETPOST(
'lang_id');
1988 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && !empty($lang_id)) {
1989 $newlang = $lang_id;
1992 $newlang = $customer->default_lang;
1994 if (!empty($newlang)) {
1995 $outputlangs =
new Translate(
"", $conf);
1996 $outputlangs->setDefaultLang($newlang);
2001 $invoice->generateDocument($invoice->model_pdf, $outputlangs);
2021 global $langs, $conf;
2027 if ($this->
statut == self::STATUS_VALIDATED) {
2028 dol_syslog(get_class($this).
"::validate statut of member does not allow this", LOG_WARNING);
2034 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
2035 $sql .=
" statut = ".self::STATUS_VALIDATED;
2036 $sql .=
", datevalid = '".$this->db->idate($now).
"'";
2037 $sql .=
", fk_user_valid = ".((int) $user->id);
2038 $sql .=
" WHERE rowid = ".((int) $this->
id);
2040 dol_syslog(get_class($this).
"::validate", LOG_DEBUG);
2041 $result = $this->db->query($sql);
2046 $result = $this->
call_trigger(
'MEMBER_VALIDATE', $user);
2049 $this->db->rollback();
2054 $this->datevalid = $now;
2056 $this->db->commit();
2059 $this->error = $this->db->error();
2060 $this->db->rollback();
2074 global $langs, $conf;
2079 if ($this->
statut == self::STATUS_RESILIATED) {
2080 dol_syslog(get_class($this).
"::resiliate statut of member does not allow this", LOG_WARNING);
2086 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
2087 $sql .=
" statut = ".self::STATUS_RESILIATED;
2088 $sql .=
", fk_user_valid=".$user->id;
2089 $sql .=
" WHERE rowid = ".((int) $this->
id);
2091 $result = $this->db->query($sql);
2096 $result = $this->
call_trigger(
'MEMBER_RESILIATE', $user);
2099 $this->db->rollback();
2104 $this->db->commit();
2107 $this->error = $this->db->error();
2108 $this->db->rollback();
2124 global $langs, $conf;
2129 if ($this->
statut == self::STATUS_EXCLUDED) {
2130 dol_syslog(get_class($this).
"::resiliate statut of member does not allow this", LOG_WARNING);
2136 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
2137 $sql .=
" statut = ".self::STATUS_EXCLUDED;
2138 $sql .=
", fk_user_valid=".$user->id;
2139 $sql .=
" WHERE rowid = ".((int) $this->
id);
2141 $result = $this->db->query($sql);
2146 $result = $this->
call_trigger(
'MEMBER_EXCLUDE', $user);
2149 $this->db->rollback();
2154 $this->db->commit();
2157 $this->error = $this->db->error();
2158 $this->db->rollback();
2172 global $conf, $langs;
2174 include_once DOL_DOCUMENT_ROOT.
'/mailmanspip/class/mailmanspip.class.php';
2180 if (!empty($conf->global->ADHERENT_USE_MAILMAN) && isModEnabled(
'mailmanspip')) {
2181 $result = $mailmanspip->add_to_mailman($this);
2184 if (!empty($mailmanspip->error)) {
2185 $this->errors[] = $mailmanspip->error;
2189 foreach ($mailmanspip->mladded_ko as $tmplist => $tmpemail) {
2190 $langs->load(
"errors");
2191 $this->errors[] = $langs->trans(
"ErrorFailedToAddToMailmanList", $tmpemail, $tmplist);
2193 foreach ($mailmanspip->mladded_ok as $tmplist => $tmpemail) {
2194 $langs->load(
"mailmanspip");
2195 $this->mesgs[] = $langs->trans(
"SuccessToAddToMailmanList", $tmpemail, $tmplist);
2200 if (!empty($conf->global->ADHERENT_USE_SPIP) && isModEnabled(
'mailmanspip')) {
2201 $result = $mailmanspip->add_to_spip($this);
2203 $this->errors[] = $mailmanspip->error;
2224 global $conf, $langs;
2226 include_once DOL_DOCUMENT_ROOT.
'/mailmanspip/class/mailmanspip.class.php';
2232 if (!empty($conf->global->ADHERENT_USE_MAILMAN)) {
2233 $result = $mailmanspip->del_to_mailman($this);
2235 if (!empty($mailmanspip->error)) {
2236 $this->errors[] = $mailmanspip->error;
2241 foreach ($mailmanspip->mlremoved_ko as $tmplist => $tmpemail) {
2242 $langs->load(
"errors");
2243 $this->errors[] = $langs->trans(
"ErrorFailedToRemoveToMailmanList", $tmpemail, $tmplist);
2245 foreach ($mailmanspip->mlremoved_ok as $tmplist => $tmpemail) {
2246 $langs->load(
"mailmanspip");
2247 $this->mesgs[] = $langs->trans(
"SuccessToRemoveToMailmanList", $tmpemail, $tmplist);
2251 if ($conf->global->ADHERENT_USE_SPIP && isModEnabled(
'mailmanspip')) {
2252 $result = $mailmanspip->del_to_spip($this);
2254 $this->errors[] = $mailmanspip->error;
2275 $langs->load(
"dict");
2277 $code = (empty($this->civility_id) ?
'' : $this->civility_id);
2281 return $langs->getLabelFromKey($this->db,
"Civility".$code,
"c_civility",
"code",
"label", $code);
2292 global $conf, $langs;
2294 $langs->loadLangs([
'members',
'companies']);
2295 $nofetch = !empty($params[
'nofetch']);
2299 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
2300 $langs->load(
"users");
2301 return [
'optimize' => $langs->trans(
"ShowUser")];
2303 if (!empty($this->photo)) {
2304 $photo =
'<div class="photointooltip floatright">';
2305 $photo .=
Form::showphoto(
'memberphoto', $this, 80, 0, 0,
'photoref photowithmargin photologintooltip',
'small', 0, 1);
2307 $datas[
'photo'] = $photo;
2310 $datas[
'divopen'] =
'<div class="centpercent">';
2311 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <u class="paddingrightonly">'.$langs->trans(
"Member").
'</u> '.$this->
getLibStatut(4);
2312 if (!empty($this->morphy)) {
2313 $datas[
'picto'] .=
' ' . $this->
getmorphylib(
'', 1);
2315 if (!empty($this->
ref)) {
2316 $datas[
'ref'] =
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
2318 if (!empty($this->login)) {
2319 $datas[
'login'] =
'<br><b>'.$langs->trans(
'Login').
':</b> '.$this->login;
2321 if (!empty($this->firstname) || !empty($this->lastname)) {
2322 $datas[
'name'] =
'<br><b>'.$langs->trans(
'Name').
':</b> '.$this->
getFullName($langs);
2324 if (!empty($this->company)) {
2325 $datas[
'company'] =
'<br><b>'.$langs->trans(
'Company').
':</b> '.$this->company;
2327 if (!empty($this->email)) {
2328 $datas[
'email'] =
'<br><b>'.$langs->trans(
"EMail").
':</b> '.$this->email;
2330 $datas[
'address'] =
'<br><b>'.$langs->trans(
"Address").
':</b> '.
dol_format_address($this, 1,
' ', $langs);
2332 if (isModEnabled(
'categorie') && !$nofetch) {
2333 require_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
2334 $form =
new Form($this->db);
2335 $datas[
'categories'] =
'<br>' . $form->showCategories($this->
id, Categorie::TYPE_MEMBER, 1);
2337 $datas[
'divclose'] =
'</div>';
2355 public function getNomUrl($withpictoimg = 0, $maxlen = 0, $option =
'card', $mode =
'', $morecss =
'', $save_lastsearch_value = -1, $notooltip = 0, $addlinktonotes = 0)
2357 global $conf, $langs, $hookmanager;
2359 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpictoimg) {
2366 $classfortooltip =
'classfortooltip';
2370 'objecttype' => $this->element,
2371 'option' => $option,
2375 $classfortooltip =
'classforajaxtooltip';
2376 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
2382 $url = DOL_URL_ROOT.
'/adherents/card.php?rowid='.((int) $this->
id);
2383 if ($option ==
'subscription') {
2384 $url = DOL_URL_ROOT.
'/adherents/subscription.php?rowid='.((int) $this->
id);
2387 if ($option !=
'nolink') {
2389 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
2390 if ($save_lastsearch_value == -1 && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
2391 $add_save_lastsearch_values = 1;
2393 if ($add_save_lastsearch_values) {
2394 $url .=
'&save_lastsearch_values=1';
2398 $linkstart .=
'<a href="'.$url.
'"';
2400 if (empty($notooltip)) {
2401 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
2402 $langs->load(
"users");
2403 $label = $langs->trans(
"ShowUser");
2404 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
2406 $linkclose .= ($label ?
' title="'.dol_escape_htmltag($label, 1).
'"' :
' title="tocomplete"');
2407 $linkclose .= $dataparams.
' class="'.$classfortooltip.($morecss ?
' '.$morecss :
'').
'"';
2410 $linkstart .= $linkclose.
'>';
2413 $result .= $linkstart;
2414 if ($withpictoimg) {
2415 $result .=
'<div class="inline-block nopadding valignmiddle">';
2417 if ($withpictoimg) {
2418 $paddafterimage =
'';
2419 if (abs($withpictoimg) == 1 || abs($withpictoimg) == 4) {
2420 $morecss .=
' paddingrightonly';
2423 if ($withpictoimg > 0) {
2424 $picto =
'<span class="nopadding'.($morecss ?
' userimg'.$morecss :
'').
'">'.
img_object(
'',
'user', $paddafterimage.
' '.($notooltip ?
'' : $dataparams), 0, 0, $notooltip ? 0 : 1).
'</span>';
2427 $picto =
'<span class="nopadding'.($morecss ?
' userimg'.$morecss :
'').
'"'.($paddafterimage ?
' '.$paddafterimage :
'').
'>';
2428 $picto .=
Form::showphoto(
'memberphoto', $this, 0, 0, 0,
'userphoto'.(($withpictoimg == -3 || $withpictoimg == -4) ?
'small' :
''),
'mini', 0, 1);
2429 $picto .=
'</span>';
2433 if (($withpictoimg > -2 && $withpictoimg != 2) || $withpictoimg == -4) {
2434 if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
2435 $result .=
'<span class="nopadding valignmiddle'.((!isset($this->
statut) || $this->statut) ?
'' :
' strikefordisabled').
2436 ($morecss ?
' usertext'.$morecss :
'').
'">';
2438 if ($mode ==
'login') {
2439 $result .=
dol_trunc($this->login, $maxlen);
2440 } elseif ($mode ==
'ref') {
2441 $result .= $this->ref;
2443 $result .= $this->
getFullName($langs,
'', ($mode ==
'firstname' ? 2 : ($mode ==
'lastname' ? 4 : -1)), $maxlen);
2445 if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
2446 $result .=
'</span>';
2449 if ($withpictoimg) {
2450 $result .=
'</div>';
2452 $result .= $linkend;
2454 if ($addlinktonotes) {
2455 if ($this->note_private) {
2456 $notetoshow = $langs->trans(
"ViewPrivateNote").
':<br>'.
dol_string_nohtmltag($this->note_private, 1);
2457 $result .=
' <span class="note inline-block">';
2458 $result .=
'<a href="'.DOL_URL_ROOT.
'/adherents/note.php?id='.$this->
id.
'" class="classfortooltip" title="'.
dol_escape_htmltag($notetoshow).
'">';
2461 $result .=
'</span>';
2465 $hookmanager->initHooks(array($this->element .
'dao'));
2466 $parameters = array(
'id'=>$this->
id,
'getnomurl' => &$result);
2467 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
2469 $result = $hookmanager->resPrint;
2471 $result .= $hookmanager->resPrint;
2484 return $this->
LibStatut($this->
statut, $this->need_subscription, $this->datefin, $mode);
2497 public function LibStatut($status, $need_subscription, $date_end_subscription, $mode = 0)
2501 $langs->load(
"members");
2505 $labelStatusShort =
'';
2507 if ($status == self::STATUS_DRAFT) {
2508 $statusType =
'status0';
2509 $labelStatus = $langs->trans(
"MemberStatusDraft");
2510 $labelStatusShort = $langs->trans(
"MemberStatusDraftShort");
2511 } elseif ($status >= self::STATUS_VALIDATED) {
2512 if ($need_subscription === 0) {
2513 $statusType =
'status4';
2514 $labelStatus = $langs->trans(
"MemberStatusNoSubscription");
2515 $labelStatusShort = $langs->trans(
"MemberStatusNoSubscriptionShort");
2516 } elseif (!$date_end_subscription) {
2517 $statusType =
'status1';
2518 $labelStatus = $langs->trans(
"WaitingSubscription");
2519 $labelStatusShort = $langs->trans(
"WaitingSubscriptionShort");
2520 } elseif ($date_end_subscription <
dol_now()) {
2521 $statusType =
'status8';
2522 $labelStatus = $langs->trans(
"MemberStatusActiveLate");
2523 $labelStatusShort = $langs->trans(
"MemberStatusActiveLateShort");
2525 $statusType =
'status4';
2526 $labelStatus = $langs->trans(
"MemberStatusPaid");
2527 $labelStatusShort = $langs->trans(
"MemberStatusPaidShort");
2529 } elseif ($status == self::STATUS_RESILIATED) {
2530 $statusType =
'status6';
2531 $labelStatus = $langs->transnoentitiesnoconv(
"MemberStatusResiliated");
2532 $labelStatusShort = $langs->transnoentitiesnoconv(
"MemberStatusResiliatedShort");
2533 } elseif ($status == self::STATUS_EXCLUDED) {
2534 $statusType =
'status10';
2535 $labelStatus = $langs->transnoentitiesnoconv(
"MemberStatusExcluded");
2536 $labelStatusShort = $langs->transnoentitiesnoconv(
"MemberStatusExcludedShort");
2539 return dolGetStatus($labelStatus, $labelStatusShort,
'', $statusType, $mode);
2554 $this->nb = array();
2556 $sql =
"SELECT count(a.rowid) as nb";
2557 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as a";
2558 $sql .=
" WHERE a.statut > 0";
2559 $sql .=
" AND a.entity IN (".getEntity(
'adherent').
")";
2561 $resql = $this->db->query($sql);
2563 while ($obj = $this->db->fetch_object($resql)) {
2564 $this->nb[
"members"] = $obj->nb;
2566 $this->db->free($resql);
2570 $this->error = $this->db->error();
2586 global $conf, $langs;
2594 $sql =
"SELECT a.rowid, a.datefin, a.statut";
2595 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as a";
2596 $sql .=
", ".MAIN_DB_PREFIX.
"adherent_type as t";
2597 $sql .=
" WHERE a.fk_adherent_type = t.rowid";
2598 if ($mode ==
'expired') {
2599 $sql .=
" AND a.statut = ".self::STATUS_VALIDATED;
2600 $sql .=
" AND a.entity IN (".getEntity(
'adherent').
")";
2601 $sql .=
" AND ((a.datefin IS NULL or a.datefin < '".$this->db->idate($now).
"') AND t.subscription = '1')";
2602 } elseif ($mode ==
'shift') {
2603 $sql .=
" AND a.statut = ".self::STATUS_DRAFT;
2604 $sql .=
" AND a.entity IN (".getEntity(
'adherent').
")";
2607 $resql = $this->db->query($sql);
2609 $langs->load(
"members");
2616 if ($mode ==
'expired') {
2617 $warning_delay = $conf->adherent->subscription->warning_delay / 60 / 60 / 24;
2618 $label = $langs->trans(
"MembersWithSubscriptionToReceive");
2619 $labelShort = $langs->trans(
"MembersWithSubscriptionToReceiveShort");
2620 $url = DOL_URL_ROOT.
'/adherents/list.php?mainmenu=members&statut='.self::STATUS_VALIDATED.
'&filter=outofdate';
2621 } elseif ($mode ==
'shift') {
2622 $warning_delay = $conf->adherent->subscription->warning_delay / 60 / 60 / 24;
2623 $url = DOL_URL_ROOT.
'/adherents/list.php?mainmenu=members&statut='.
self::STATUS_DRAFT;
2624 $label = $langs->trans(
"MembersListToValid");
2625 $labelShort = $langs->trans(
"ToValidate");
2629 $response->warning_delay = $warning_delay;
2630 $response->label = $label;
2631 $response->labelShort = $labelShort;
2632 $response->url = $url;
2635 $adherentstatic =
new Adherent($this->db);
2637 while ($obj = $this->db->fetch_object($resql)) {
2638 $response->nbtodo++;
2640 $adherentstatic->datefin = $this->db->jdate($obj->datefin);
2641 $adherentstatic->statut = $obj->statut;
2643 if ($adherentstatic->hasDelay()) {
2644 $response->nbtodolate++;
2651 $this->error = $this->db->error();
2668 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams =
null)
2670 global $conf, $langs;
2672 $langs->load(
"orders");
2675 $modele =
'standard';
2677 if ($this->model_pdf) {
2678 $modele = $this->model_pdf;
2679 } elseif (!empty($conf->global->ADHERENT_ADDON_PDF)) {
2680 $modele = $conf->global->ADHERENT_ADDON_PDF;
2684 $modelpath =
"core/modules/member/doc/";
2686 return $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
2699 global $user, $langs;
2704 $this->
ref =
'ABC001';
2706 $this->specimen = 1;
2707 $this->civility_id = 0;
2708 $this->lastname =
'DOLIBARR';
2709 $this->firstname =
'SPECIMEN';
2710 $this->gender =
'man';
2711 $this->login =
'dolibspec';
2712 $this->pass =
'dolibspec';
2713 $this->company =
'Societe ABC';
2714 $this->address =
'61 jump street';
2715 $this->zip =
'75000';
2716 $this->town =
'Paris';
2717 $this->country_id = 1;
2718 $this->country_code =
'FR';
2719 $this->country =
'France';
2720 $this->morphy =
'mor';
2721 $this->email =
'specimen@specimen.com';
2722 $this->socialnetworks = array(
2723 'skype' =>
'skypepseudo',
2724 'twitter' =>
'twitterpseudo',
2725 'facebook' =>
'facebookpseudo',
2726 'linkedin' =>
'linkedinpseudo',
2728 $this->phone =
'0999999999';
2729 $this->phone_perso =
'0999999998';
2730 $this->phone_mobile =
'0999999997';
2731 $this->note_public =
'This is a public note';
2732 $this->note_private =
'This is a private note';
2733 $this->birth = $now;
2738 $this->datefin = $now;
2739 $this->datevalid = $now;
2740 $this->default_lang =
'';
2743 $this->
type =
'Type adherent';
2744 $this->need_subscription = 0;
2746 $this->first_subscription_date = $now;
2747 $this->first_subscription_date_start = $this->first_subscription_date;
2748 $this->first_subscription_date_end =
dol_time_plus_duree($this->first_subscription_date_start, 1,
'y');
2749 $this->first_subscription_amount = 10;
2751 $this->last_subscription_date = $this->first_subscription_date;
2752 $this->last_subscription_date_start = $this->first_subscription_date;
2753 $this->last_subscription_date_end =
dol_time_plus_duree($this->last_subscription_date_start, 1,
'y');
2754 $this->last_subscription_amount = 10;
2776 $dn = $conf->global->LDAP_KEY_MEMBERS.
"=".$info[$conf->global->LDAP_KEY_MEMBERS].
",".$conf->global->LDAP_MEMBER_DN;
2779 $dn = $conf->global->LDAP_MEMBER_DN;
2782 $dn = $conf->global->LDAP_KEY_MEMBERS.
"=".$info[$conf->global->LDAP_KEY_MEMBERS];
2798 global $conf, $langs;
2802 $keymodified =
false;
2805 $info[
"objectclass"] = explode(
',', $conf->global->LDAP_MEMBER_OBJECT_CLASS);
2810 if ($this->morphy ==
'mor' && (empty($this->fullname) || $this->fullname == $this->company)) {
2811 $this->fullname = $this->company;
2812 $this->lastname = $this->company;
2817 'LDAP_MEMBER_FIELD_FULLNAME' =>
'fullname',
2818 'LDAP_MEMBER_FIELD_NAME' =>
'lastname',
2819 'LDAP_MEMBER_FIELD_LOGIN' =>
'login',
2820 'LDAP_MEMBER_FIELD_LOGIN_SAMBA' =>
'login',
2821 'LDAP_MEMBER_FIELD_MAIL' =>
'email'
2825 foreach ($ldapkey as $constname => $varname) {
2826 if (!empty($this->$varname) && !empty($conf->global->$constname)) {
2827 $info[$conf->global->$constname] = $this->$varname;
2830 if (!empty($conf->global->LDAP_KEY_MEMBERS) && $conf->global->LDAP_KEY_MEMBERS == $conf->global->$constname) {
2831 if (!empty($this->oldcopy) && $this->$varname != $this->oldcopy->$varname) {
2832 $keymodified =
true;
2837 if ($this->firstname && !empty($conf->global->LDAP_MEMBER_FIELD_FIRSTNAME)) {
2838 $info[$conf->global->LDAP_MEMBER_FIELD_FIRSTNAME] = $this->firstname;
2840 if ($this->poste && !empty($conf->global->LDAP_MEMBER_FIELD_TITLE)) {
2841 $info[$conf->global->LDAP_MEMBER_FIELD_TITLE] = $this->poste;
2843 if ($this->company && !empty($conf->global->LDAP_MEMBER_FIELD_COMPANY)) {
2844 $info[$conf->global->LDAP_MEMBER_FIELD_COMPANY] = $this->company;
2846 if ($this->address && !empty($conf->global->LDAP_MEMBER_FIELD_ADDRESS)) {
2847 $info[$conf->global->LDAP_MEMBER_FIELD_ADDRESS] = $this->address;
2849 if ($this->zip && !empty($conf->global->LDAP_MEMBER_FIELD_ZIP)) {
2850 $info[$conf->global->LDAP_MEMBER_FIELD_ZIP] = $this->zip;
2852 if ($this->town && !empty($conf->global->LDAP_MEMBER_FIELD_TOWN)) {
2853 $info[$conf->global->LDAP_MEMBER_FIELD_TOWN] = $this->town;
2855 if ($this->country_code && !empty($conf->global->LDAP_MEMBER_FIELD_COUNTRY)) {
2856 $info[$conf->global->LDAP_MEMBER_FIELD_COUNTRY] = $this->country_code;
2858 foreach ($socialnetworks as $key => $value) {
2859 if ($this->socialnetworks[$value[
'label']] && !empty($conf->global->{
'LDAP_MEMBER_FIELD_'.strtoupper($value[
'label'])})) {
2860 $info[$conf->global->{
'LDAP_MEMBER_FIELD_'.strtoupper($value[
'label'])}] = $this->socialnetworks[$value[
'label']];
2863 if ($this->phone && !empty($conf->global->LDAP_MEMBER_FIELD_PHONE)) {
2864 $info[$conf->global->LDAP_MEMBER_FIELD_PHONE] = $this->phone;
2866 if ($this->phone_perso && !empty($conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO)) {
2867 $info[$conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO] = $this->phone_perso;
2869 if ($this->phone_mobile && !empty($conf->global->LDAP_MEMBER_FIELD_MOBILE)) {
2870 $info[$conf->global->LDAP_MEMBER_FIELD_MOBILE] = $this->phone_mobile;
2872 if ($this->fax && !empty($conf->global->LDAP_MEMBER_FIELD_FAX)) {
2873 $info[$conf->global->LDAP_MEMBER_FIELD_FAX] = $this->fax;
2875 if ($this->note_private && !empty($conf->global->LDAP_MEMBER_FIELD_DESCRIPTION)) {
2876 $info[$conf->global->LDAP_MEMBER_FIELD_DESCRIPTION] =
dol_string_nohtmltag($this->note_private, 2);
2878 if ($this->note_public && !empty($conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC)) {
2879 $info[$conf->global->LDAP_MEMBER_FIELD_NOTE_PUBLIC] =
dol_string_nohtmltag($this->note_public, 2);
2881 if ($this->birth && !empty($conf->global->LDAP_MEMBER_FIELD_BIRTHDATE)) {
2882 $info[$conf->global->LDAP_MEMBER_FIELD_BIRTHDATE] =
dol_print_date($this->birth,
'dayhourldap');
2884 if (isset($this->
statut) && !empty($conf->global->LDAP_FIELD_MEMBER_STATUS)) {
2885 $info[$conf->global->LDAP_FIELD_MEMBER_STATUS] = $this->statut;
2887 if ($this->datefin && !empty($conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION)) {
2888 $info[$conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION] =
dol_print_date($this->datefin,
'dayhourldap');
2892 if (!empty($this->pass)) {
2893 if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD)) {
2894 $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD] = $this->pass;
2896 if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) {
2897 $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] =
dol_hash($this->pass,
'openldap');
2899 } elseif ($conf->global->LDAP_SERVER_PROTOCOLVERSION !==
'3') {
2902 if (!empty($conf->global->DATABASE_PWD_ENCRYPTED)) {
2904 if (empty($conf->global->MAIN_SECURITY_HASH_ALGO)) {
2905 if ($this->pass_indatabase_crypted && !empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) {
2908 $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] =
dolGetLdapPasswordHash($this->pass_indatabase_crypted,
'md5frommd5');
2911 } elseif (!empty($this->pass_indatabase)) {
2913 if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD)) {
2914 $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD] = $this->pass_indatabase;
2916 if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) {
2917 $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] =
dol_hash($this->pass_indatabase,
'openldap');
2923 if ($this->first_subscription_date && !empty($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE)) {
2924 $info[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE] =
dol_print_date($this->first_subscription_date,
'dayhourldap');
2926 if (isset($this->first_subscription_amount) && !empty($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT)) {
2927 $info[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT] = $this->first_subscription_amount;
2929 if ($this->last_subscription_date && !empty($conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE)) {
2930 $info[$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE] =
dol_print_date($this->last_subscription_date,
'dayhourldap');
2932 if (isset($this->last_subscription_amount) && !empty($conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT)) {
2933 $info[$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT] = $this->last_subscription_amount;
2948 $sql =
'SELECT a.rowid, a.datec as datec,';
2949 $sql .=
' a.datevalid as datev,';
2950 $sql .=
' a.tms as datem,';
2951 $sql .=
' a.fk_user_author, a.fk_user_valid, a.fk_user_mod';
2952 $sql .=
' FROM '.MAIN_DB_PREFIX.
'adherent as a';
2953 $sql .=
' WHERE a.rowid = '.((int) $id);
2955 dol_syslog(get_class($this).
"::info", LOG_DEBUG);
2956 $result = $this->db->query($sql);
2958 if ($this->db->num_rows($result)) {
2959 $obj = $this->db->fetch_object($result);
2960 $this->
id = $obj->rowid;
2962 $this->user_creation_id = $obj->fk_user_author;
2963 $this->user_validation_id = $obj->fk_user_valid;
2964 $this->user_modification_id = $obj->fk_user_mod;
2965 $this->date_creation = $this->db->jdate($obj->datec);
2966 $this->date_validation = $this->db->jdate($obj->datev);
2967 $this->date_modification = $this->db->jdate($obj->datem);
2970 $this->db->free($result);
2983 $sql =
"SELECT count(mc.email) as nb";
2984 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mailing_cibles as mc";
2985 $sql .=
" WHERE mc.email = '".$this->db->escape($this->email).
"'";
2986 $sql .=
" AND mc.statut NOT IN (-1,0)";
2988 $resql = $this->db->query($sql);
2990 $obj = $this->db->fetch_object($resql);
2993 $this->db->free($resql);
2996 $this->error = $this->db->error();
3013 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
3014 return parent::setCategoriesCommon($categories, Categorie::TYPE_MEMBER);
3027 $tables = array(
'adherent');
3042 if ($this->
statut != self::STATUS_VALIDATED) {
3045 if (!$this->datefin) {
3051 return $this->datefin < ($now - $conf->adherent->subscription->warning_delay);
3064 global $conf, $langs, $mysoc, $user;
3070 $blockingerrormsg =
'';
3072 if (!isModEnabled(
'adherent')) {
3073 $langs->load(
"agenda");
3074 $this->output = $langs->trans(
'ModuleNotEnabled', $langs->transnoentitiesnoconv(
"Adherent"));
3077 if (empty($conf->global->MEMBER_REMINDER_EMAIL)) {
3078 $langs->load(
"agenda");
3079 $this->output = $langs->trans(
'EventRemindersByEmailNotEnabled', $langs->transnoentitiesnoconv(
"Adherent"));
3087 $listofmembersok = array();
3088 $listofmembersko = array();
3090 $arraydaysbeforeend = explode(
';', $daysbeforeendlist);
3091 foreach ($arraydaysbeforeend as $daysbeforeend) {
3092 dol_syslog(__METHOD__.
' - Process delta = '.$daysbeforeend, LOG_DEBUG);
3094 if (!is_numeric($daysbeforeend)) {
3095 $blockingerrormsg =
"Value for delta is not a numeric value";
3103 $sql =
'SELECT rowid FROM '.MAIN_DB_PREFIX.
'adherent';
3104 $sql .=
" WHERE entity = ".((int) $conf->entity);
3105 $sql .=
" AND statut = 1";
3106 $sql .=
" AND datefin = '".$this->db->idate($datetosearchfor).
"'";
3109 $resql = $this->db->query($sql);
3111 $num_rows = $this->db->num_rows($resql);
3113 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
3114 $adherent =
new Adherent($this->db);
3115 $formmail =
new FormMail($this->db);
3118 while ($i < $num_rows) {
3119 $obj = $this->db->fetch_object($resql);
3121 $adherent->fetch($obj->rowid,
'',
'',
'',
true,
true);
3123 if (empty($adherent->email)) {
3125 $listofmembersko[$adherent->id] = $adherent->id;
3127 $adherent->fetch_thirdparty();
3130 $languagefromcountrycode =
getLanguageCodeFromCountryCode($adherent->country_code ? $adherent->country_code : $adherent->thirdparty->country_code);
3131 $languagecodeformember = (empty($adherent->thirdparty->default_lang) ? ($languagefromcountrycode ? $languagefromcountrycode : $mysoc->default_lang) : $adherent->thirdparty->default_lang);
3134 $outputlangs =
new Translate(
'', $conf);
3135 $outputlangs->setDefaultLang($languagecodeformember);
3136 $outputlangs->loadLangs(array(
"main",
"members"));
3137 dol_syslog(
"sendReminderForExpiredSubscription Language for member id ".$adherent->id.
" set to ".$outputlangs->defaultlang.
" mysoc->default_lang=".$mysoc->default_lang);
3139 $arraydefaultmessage =
null;
3142 if (!empty($labeltouse)) {
3143 $arraydefaultmessage = $formmail->getEMailTemplate($this->db,
'member', $user, $outputlangs, 0, 1, $labeltouse);
3146 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
3151 $subject =
make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs);
3152 $msg =
make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs);
3154 $to = $adherent->email;
3157 $trackid =
'mem'.$adherent->id;
3158 $moreinheader =
'X-Dolibarr-Info: sendReminderForExpiredSubscription'.
"\r\n";
3160 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
3161 $cmail =
new CMailFile($subject, $to, $from, $msg, array(), array(), array(), $cc,
'', 0, 1,
'',
'', $trackid, $moreinheader);
3162 $result = $cmail->sendfile();
3165 $this->error .= $cmail->error.
' ';
3166 if (!is_null($cmail->errors)) {
3167 $this->errors += $cmail->errors;
3170 $listofmembersko[$adherent->id] = $adherent->id;
3173 $listofmembersok[$adherent->id] = $adherent->id;
3179 $actioncode =
'EMAIL';
3190 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic').
": ".$subject);
3191 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody').
":");
3195 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
3200 $actioncomm->type_code =
'AC_OTH_AUTO';
3201 $actioncomm->code =
'AC_'.$actioncode;
3202 $actioncomm->label = $actionmsg2;
3203 $actioncomm->note_private = $actionmsg;
3204 $actioncomm->fk_project = 0;
3205 $actioncomm->datep = $now;
3206 $actioncomm->datef = $now;
3207 $actioncomm->percentage = -1;
3208 $actioncomm->socid = $adherent->thirdparty->id;
3209 $actioncomm->contact_id = 0;
3210 $actioncomm->authorid = $user->id;
3211 $actioncomm->userownerid = $user->id;
3213 $actioncomm->email_msgid = $cmail->msgid;
3214 $actioncomm->email_from = $from;
3215 $actioncomm->email_sender =
'';
3216 $actioncomm->email_to = $to;
3217 $actioncomm->email_tocc = $sendtocc;
3218 $actioncomm->email_tobcc = $sendtobcc;
3219 $actioncomm->email_subject = $subject;
3220 $actioncomm->errors_to =
'';
3222 $actioncomm->fk_element = $adherent->id;
3223 $actioncomm->elementtype = $adherent->element;
3225 $actioncomm->extraparams = $extraparams;
3227 $actioncomm->create($user);
3233 $this->error .=
"Can't find email template with label=".$labeltouse.
", to use for the reminding email ";
3236 $listofmembersko[$adherent->id] = $adherent->id;
3245 $this->error = $this->db->lasterror();
3250 if ($blockingerrormsg) {
3251 $this->error = $blockingerrormsg;
3254 $this->output =
'Found '.($nbok + $nbko).
' members to send reminder to.';
3255 $this->output .=
' Send email successfuly to '.$nbok.
' members';
3256 if (is_array($listofmembersok)) {
3259 foreach ($listofmembersok as $idmember) {
3261 $listofids .=
', ...';
3264 if (empty($listofids)) {
3269 $listofids .= $idmember;
3276 $this->output .= ($listofids ?
' ids='.$listofids :
'');
3279 $this->output .=
' - Canceled for '.$nbko.
' member (no email or email sending error)';
3280 if (is_array($listofmembersko)) {
3283 foreach ($listofmembersko as $idmember) {
3285 $listofids .=
', ...';
3288 if (empty($listofids)) {
3293 $listofids .= $idmember;
3299 $this->output .= ($listofids ?
' ids='.$listofids :
'');
3316 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
3318 $return =
'<div class="box-flex-item box-flex-grow-zero">';
3319 $return .=
'<div class="info-box info-box-sm">';
3320 $return .=
'<span class="info-box-icon bg-infobox-action">';
3321 if (property_exists($this,
'photo') || !empty($this->photo)) {
3322 $return.=
Form::showphoto(
'memberphoto', $this, 0, 60, 0,
'photokanban photoref photowithmargin photologintooltip',
'small', 0, 1);
3326 $return .=
'</span>';
3327 $return .=
'<div class="info-box-content">';
3328 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this,
'getNomUrl') ? $this->getNomUrl() : $this->ref).
'</span>';
3329 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
3330 if (property_exists($this,
'type')) {
3331 $return .=
'<br><span class="info-box-label opacitymedium">'.$this->type.
'</span>';
3333 if (method_exists($this,
'getmorphylib')) {
3334 $return .=
'<br><span class="info-box-label">'.$this->getmorphylib(
'', 2).
'</span>';
3336 if (method_exists($this,
'getLibStatut')) {
3337 $return .=
'<br><div class="info-box-status margintoponly">'.$this->getLibStatut(3).
'</div>';
3339 $return .=
'</div>';
3340 $return .=
'</div>';
3341 $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 exlude (set adherent.status to -2) a member TODO A private note should be added to know w...
add_to_abo()
Function to add member into external tools mailing-list, spip, etc.
sendReminderForExpiredSubscription($daysbeforeendlist='10')
Send reminders by emails before subscription end CAN BE A CRON TASK.
_load_ldap_dn($info, $mode=0)
Retourne chaine DN complete dans l'annuaire LDAP pour l'objet.
update($user, $notrigger=0, $nosyncuser=0, $nosyncuserpass=0, $nosyncthirdparty=0, $action='update')
Update a member in database (standard information and password)
setCategories($categories)
Sets object to supplied categories.
getTooltipContentArray($params)
getTooltipContentArray
getNbOfEMailings()
Return number of mass Emailing received by this member with its email.
update_end_date($user)
Update denormalized last subscription date.
static replaceThirdparty($db, $origin_id, $dest_id)
Function used to replace a thirdparty id with another one.
makeSubstitution($text)
Make substitution of tags into text with value of current object.
const STATUS_EXCLUDED
Excluded.
LibStatut($status, $need_subscription, $date_end_subscription, $mode=0)
Renvoi le libelle d'un statut donne.
fetch_name($firstname, $lastname)
Method to load member from its name.
initAsSpecimen()
Initialise an instance with random values.
del_to_abo()
Function to delete a member from external tools like mailing-list, spip, etc.
resiliate($user)
Fonction qui resilie un adherent.
getCivilityLabel()
Return civility label of a member.
getmorphylib($morphy='', $addbadge=0)
Return translated label by the nature of a adherent (physical or moral)
sendEmail($text, $subject, $filename_list=array(), $mimetype_list=array(), $mimefilename_list=array(), $addr_cc="", $addr_bcc="", $deliveryreceipt=0, $msgishtml=-1, $errors_to='', $moreinheader='')
Function sending an email to the current member with the text supplied in parameter.
fetchPartnerships($mode)
Function to get partnerships array.
load_board($user, $mode)
Load indicators for dashboard (this->nbtodo and this->nbtodolate)
setPassword($user, $password='', $isencrypted=0, $notrigger=0, $nosyncuser=0)
Change password of a user.
getKanbanView($option='', $arraydata=null)
Return clicable link of object (with eventually picto)
const STATUS_DRAFT
Draft status.
const STATUS_RESILIATED
Resiliated.
fetch_login($login)
Method to load member from its login.
create($user, $notrigger=0)
Create a member into database.
_load_ldap_info()
Initialise tableau info (tableau des attributs LDAP)
getLibStatut($mode=0)
Retourne le libelle du statut d'un adherent (brouillon, valide, resilie, exclu)
info($id)
Load type info information in the member object.
__construct($db)
Constructor.
subscription($date, $amount, $accountid=0, $operation='', $label='', $num_chq='', $emetteur_nom='', $emetteur_banque='', $datesubend=0, $fk_type=null)
Insert subscription into database and eventually add links to banks, mailman, etc....
send_an_email($text, $subject, $filename_list=array(), $mimetype_list=array(), $mimefilename_list=array(), $addr_cc="", $addr_bcc="", $deliveryreceipt=0, $msgishtml=-1, $errors_to='', $moreinheader='')
Function sending an email to the current member with the text supplied in parameter.
getNomUrl($withpictoimg=0, $maxlen=0, $option='card', $mode='', $morecss='', $save_lastsearch_value=-1, $notooltip=0, $addlinktonotes=0)
Return clicable name (with picto eventually)
generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=null)
Create a document onto disk according to template module.
subscriptionComplementaryActions($subscriptionid, $option, $accountid, $datesubscription, $paymentdate, $operation, $label, $amount, $num_chq, $emetteur_nom='', $emetteur_banque='', $autocreatethirdparty=0, $ext_payment_id='', $ext_payment_site='')
Do complementary actions after subscription recording.
setUserId($userid)
Set link to a user.
load_state_board()
Charge indicateurs this->nb de tableau de bord.
fetch($rowid, $ref='', $fk_soc='', $ref_ext='', $fetch_optionals=true, $fetch_subscriptions=true)
Load member from database.
const STATUS_VALIDATED
Validated status.
fetch_subscriptions()
Function to get member subscriptions data: subscriptions, first_subscription_date,...
validate($user)
Function that validate a member.
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
static getValidAddress($address, $format, $encode=0, $maxnumberofemail=0)
Return a formatted address string for SMTP protocol.
Parent class of all other business classes (invoices, contracts, proposals, orders,...
fetch_optionals($rowid=null, $optionsArray=null)
Function to get extra fields of an object into $this->array_options This method is in most cases call...
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 m m statut
trait CommonPeople
Superclass for thirdparties, contacts, members or users.
getFullName($langs, $option=0, $nameorder=-1, $maxlen=0)
Return full name (civility+' '+name+' '+lastname)
setUpperOrLowerCase()
Set to upper or ucwords/lower if needed.
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
clean_url($url, $http=1)
Clean an url string.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
getLanguageCodeFromCountryCode($countrycode)
Return default language from country code.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_format_address($object, $withcountry=0, $sep="\n", $outputlangs='', $mode=0, $extralangcode='')
Return a formated address (part address/zip/town/state) according to country rules.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
dolGetFirstLetters($s, $nbofchar=1)
Return first letters of a strings.
dol_strtoupper($string, $encoding="UTF-8")
Convert a string to upper.
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
getArrayOfSocialNetworks()
Get array of social network dictionary.
dol_textishtml($msg, $option=0)
Return if a text is a html content.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null, $include=null)
Return array of possible common substitutions.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that return vat rate of a product line (according to seller, buyer and product vat rate) VAT...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
getRandomPassword($generic=false, $replaceambiguouschars=null, $length=32)
Return a generated password using default module.
dolGetLdapPasswordHash($password, $type='md5')
Returns a specific ldap hash of a password.
dol_hash($chain, $type='0')
Returns a hash (non reversible encryption) of a string.