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();
359 'rowid' => array(
'type' =>
'integer',
'label' =>
'TechnicalID',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 10),
360 'ref' => array(
'type' =>
'varchar(30)',
'label' =>
'Ref',
'default' =>
'1',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'position' => 12,
'index' => 1),
361 'entity' => array(
'type' =>
'integer',
'label' =>
'Entity',
'default' =>
'1',
'enabled' => 1,
'visible' => 3,
'notnull' => 1,
'position' => 15,
'index' => 1),
362 'ref_ext' => array(
'type' =>
'varchar(128)',
'label' =>
'RefExt',
'enabled' => 1,
'visible' => 0,
'position' => 20),
363 'civility' => array(
'type' =>
'varchar(6)',
'label' =>
'Civility',
'enabled' => 1,
'visible' => -1,
'position' => 25),
364 'lastname' => array(
'type' =>
'varchar(50)',
'label' =>
'Lastname',
'enabled' => 1,
'visible' => 1,
'position' => 30,
'showoncombobox' => 1),
365 'firstname' => array(
'type' =>
'varchar(50)',
'label' =>
'Firstname',
'enabled' => 1,
'visible' => 1,
'position' => 35,
'showoncombobox' => 1),
366 'login' => array(
'type' =>
'varchar(50)',
'label' =>
'Login',
'enabled' => 1,
'visible' => -1,
'position' => 40),
367 'pass' => array(
'type' =>
'varchar(50)',
'label' =>
'Pass',
'enabled' => 1,
'visible' => 3,
'position' => 45),
368 'pass_crypted' => array(
'type' =>
'varchar(128)',
'label' =>
'Pass crypted',
'enabled' => 1,
'visible' => 3,
'position' => 50),
369 'morphy' => array(
'type' =>
'varchar(3)',
'label' =>
'MemberNature',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'position' => 55),
370 'fk_adherent_type' => array(
'type' =>
'integer',
'label' =>
'MemberType',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'position' => 60),
371 'societe' => array(
'type' =>
'varchar(128)',
'label' =>
'Societe',
'enabled' => 1,
'visible' => 1,
'position' => 65,
'showoncombobox' => 2),
372 'fk_soc' => array(
'type' =>
'integer:Societe:societe/class/societe.class.php',
'label' =>
'LinkedToDolibarrThirdParty',
'enabled' => 1,
'visible' => 1,
'position' => 70),
373 'address' => array(
'type' =>
'text',
'label' =>
'Address',
'enabled' => 1,
'visible' => -1,
'position' => 75),
374 'zip' => array(
'type' =>
'varchar(10)',
'label' =>
'Zip',
'enabled' => 1,
'visible' => -1,
'position' => 80),
375 'town' => array(
'type' =>
'varchar(50)',
'label' =>
'Town',
'enabled' => 1,
'visible' => -1,
'position' => 85),
376 'state_id' => array(
'type' =>
'integer',
'label' =>
'State',
'enabled' => 1,
'visible' => -1,
'position' => 90),
377 'country' => array(
'type' =>
'integer:Ccountry:core/class/ccountry.class.php',
'label' =>
'Country',
'enabled' => 1,
'visible' => 1,
'position' => 95),
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 'email' => array(
'type' =>
'varchar(255)',
'label' =>
'Email',
'enabled' => 1,
'visible' => 1,
'position' => 126),
382 'url' => array(
'type' =>
'varchar(255)',
'label' =>
'Url',
'enabled' => 1,
'visible' => -1,
'position' => 127),
383 'socialnetworks' => array(
'type' =>
'text',
'label' =>
'Socialnetworks',
'enabled' => 1,
'visible' => 3,
'position' => 128),
384 'birth' => array(
'type' =>
'date',
'label' =>
'DateOfBirth',
'enabled' => 1,
'visible' => -1,
'position' => 130),
385 'gender' => array(
'type' =>
'varchar(10)',
'label' =>
'Gender',
'enabled' => 1,
'visible' => -1,
'position' => 132),
386 'photo' => array(
'type' =>
'varchar(255)',
'label' =>
'Photo',
'enabled' => 1,
'visible' => -1,
'position' => 135),
387 'public' => array(
'type' =>
'smallint(6)',
'label' =>
'Public',
'enabled' => 1,
'visible' => 3,
'notnull' => 1,
'position' => 145),
388 'datefin' => array(
'type' =>
'datetime',
'label' =>
'DateEnd',
'enabled' => 1,
'visible' => 1,
'position' => 150),
389 'default_lang' => array(
'type' =>
'varchar(6)',
'label' =>
'Default lang',
'enabled' => 1,
'visible' => -1,
'position' => 153),
390 'note_public' => array(
'type' =>
'text',
'label' =>
'NotePublic',
'enabled' => 1,
'visible' => 0,
'position' => 155),
391 'note_private' => array(
'type' =>
'text',
'label' =>
'NotePrivate',
'enabled' => 1,
'visible' => 0,
'position' => 160),
392 'datevalid' => array(
'type' =>
'datetime',
'label' =>
'DateValidation',
'enabled' => 1,
'visible' => -1,
'position' => 165),
393 'datec' => array(
'type' =>
'datetime',
'label' =>
'DateCreation',
'enabled' => 1,
'visible' => -1,
'position' => 170),
394 'tms' => array(
'type' =>
'timestamp',
'label' =>
'DateModification',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 175),
395 'fk_user_author' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'UserCreation',
'enabled' => 1,
'visible' => 3,
'position' => 180),
396 'fk_user_mod' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'UserModification',
'enabled' => 1,
'visible' => 3,
'position' => 185),
397 'fk_user_valid' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'UserValidation',
'enabled' => 1,
'visible' => 3,
'position' => 190),
398 'canvas' => array(
'type' =>
'varchar(32)',
'label' =>
'Canvas',
'enabled' => 1,
'visible' => 0,
'position' => 195),
399 'model_pdf' => array(
'type' =>
'varchar(255)',
'label' =>
'Model pdf',
'enabled' => 1,
'visible' => 0,
'position' => 800),
400 'import_key' => array(
'type' =>
'varchar(14)',
'label' =>
'ImportId',
'enabled' => 1,
'visible' => -2,
'position' => 805),
401 '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'))
434 $this->ismultientitymanaged = 1;
435 $this->isextrafieldmanaged = 1;
437 $this->array_options = array();
439 $this->fields[
'ref_ext'][
'visible'] =
getDolGlobalInt(
'MAIN_LIST_SHOW_REF_EXT');
462 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 =
'')
465 dol_syslog(
'Warning using deprecated Adherent::send_an_email', LOG_WARNING);
467 return $this->
sendEmail($text, $subject, $filename_list, $mimetype_list, $mimefilename_list, $addr_cc, $addr_bcc, $deliveryreceipt, $msgishtml, $errors_to, $moreinheader);
487 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 =
'')
489 global
$conf, $langs;
492 if ($msgishtml == -1) {
499 dol_syslog(
'sendEmail msgishtml='.$msgishtml);
510 $trackid =
'mem'.$this->id;
513 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
514 $mailfile =
new CMailFile($subjecttosend, (
string) $this->
email, $from, $texttosend, $filename_list, $mimetype_list, $mimefilename_list, $addr_cc, $addr_bcc, $deliveryreceipt, $msgishtml,
'',
'', $trackid, $moreinheader);
515 if ($mailfile->sendfile()) {
518 $this->error = $langs->trans(
"ErrorFailedToSendMail", $from, (
string) $this->email).
'. '.$mailfile->error;
535 $photo = isset($this->photo) ? $this->photo :
'';
536 $login = isset($this->login) ? $this->login :
'';
537 $type = isset($this->
type) ? $this->
type :
'';
538 $pass = isset($this->pass) ? $this->pass :
'';
546 if ($this->civility_id) {
547 $infos .= $langs->transnoentities(
"UserTitle").
": ".$this->
getCivilityLabel().
"\n";
549 $infos .= $langs->transnoentities(
"Id").
": ".$this->
id.
"\n";
550 $infos .= $langs->transnoentities(
"Ref").
": ".$this->
ref.
"\n";
551 $infos .= $langs->transnoentities(
"Lastname").
": ".$this->lastname.
"\n";
552 $infos .= $langs->transnoentities(
"Firstname").
": ".$this->firstname.
"\n";
553 $infos .= $langs->transnoentities(
"Company").
": ".$this->company.
"\n";
554 $infos .= $langs->transnoentities(
"Address").
": ".$this->
address.
"\n";
555 $infos .= $langs->transnoentities(
"Zip").
": ".$this->zip.
"\n";
556 $infos .= $langs->transnoentities(
"Town").
": ".$this->town.
"\n";
557 $infos .= $langs->transnoentities(
"Country").
": ".$this->country.
"\n";
558 $infos .= $langs->transnoentities(
"EMail").
": ".$this->
email.
"\n";
559 $infos .= $langs->transnoentities(
"PhonePro").
": ".$this->phone.
"\n";
560 $infos .= $langs->transnoentities(
"PhonePerso").
": ".$this->phone_perso.
"\n";
561 $infos .= $langs->transnoentities(
"PhoneMobile").
": ".$this->phone_mobile.
"\n";
563 $infos .= $langs->transnoentities(
"Login").
": ".$login.
"\n";
564 $infos .= $langs->transnoentities(
"Password").
": ".$pass.
"\n";
566 $infos .= $langs->transnoentities(
"Birthday").
": ".$birthday.
"\n";
567 $infos .= $langs->transnoentities(
"Photo").
": ".$photo.
"\n";
568 $infos .= $langs->transnoentities(
"Public").
": ".
yn($this->
public);
571 $substitutionarray = array(
572 '__ID__' => $this->
id,
573 '__REF__' => $this->
ref,
574 '__MEMBER_ID__' => $this->
id,
576 '__FIRSTNAME__' => $msgishtml ?
dol_htmlentitiesbr($this->firstname) : ($this->firstname ? $this->firstname :
''),
577 '__LASTNAME__' => $msgishtml ?
dol_htmlentitiesbr($this->lastname) : ($this->lastname ? $this->lastname :
''),
579 '__COMPANY__' => $msgishtml ?
dol_htmlentitiesbr((
string) $this->company) : ($this->company ? $this->company :
''),
581 '__ZIP__' => $msgishtml ?
dol_htmlentitiesbr((
string) $this->zip) : ($this->zip ? $this->zip :
''),
582 '__TOWN__' => $msgishtml ?
dol_htmlentitiesbr((
string) $this->town) : ($this->town ? $this->town :
''),
583 '__COUNTRY__' => $msgishtml ?
dol_htmlentitiesbr($this->country) : ($this->country ? $this->country :
''),
585 '__BIRTH__' => $msgishtml ?
dol_htmlentitiesbr($birthday) : ($birthday ? $birthday :
''),
589 '__PHONE__' => $msgishtml ?
dol_htmlentitiesbr($this->phone) : ($this->phone ? $this->phone :
''),
590 '__PHONEPRO__' => $msgishtml ?
dol_htmlentitiesbr($this->phone_perso) : ($this->phone_perso ? $this->phone_perso :
''),
591 '__PHONEMOBILE__' => $msgishtml ?
dol_htmlentitiesbr($this->phone_mobile) : ($this->phone_mobile ? $this->phone_mobile :
''),
615 $morphy = $this->morphy;
619 $labeltoshowm = $langs->trans(
"Moral");
620 $labeltoshowp = $langs->trans(
"Physical");
621 if ($morphy ==
'phy') {
622 $labeltoshow = $labeltoshowp;
623 if ($addbadge == 2) {
629 $s .=
'<span class="member-individual-back paddingleftimp paddingrightimp" title="'.$langs->trans(
"Physical").
'">'.$labeltoshow.
'</span>';
631 if ($morphy ==
'mor') {
632 $labeltoshow = $labeltoshowm;
633 if ($addbadge == 2) {
639 $s .=
'<span class="member-company-back paddingleftimp paddingrightimp" title="'.$langs->trans(
"Moral").
'">'.$labeltoshow.
'</span>';
642 if ($morphy ==
'phy') {
643 $s = $langs->trans(
"Physical");
644 } elseif ($morphy ==
'mor') {
645 $s = $langs->trans(
"Moral");
659 public function create($user, $notrigger = 0)
668 if (isset($this->import_key)) {
669 $this->import_key = trim($this->import_key);
674 $langs->load(
"errors");
675 $this->error = $langs->trans(
"ErrorBadEMail", (
string) $this->email);
682 if (empty($this->login)) {
683 $this->error = $langs->trans(
"ErrorWrongValueForParameterX",
"Login");
694 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"adherent";
695 $sql .=
" (ref, datec, login, fk_user_author, fk_user_mod, fk_user_valid, morphy, fk_adherent_type, entity, import_key, ip)";
698 $sql .=
", '".$this->db->idate($this->datec).
"'";
699 $sql .=
", ".($this->login ?
"'".$this->db->escape($this->login).
"'" :
"null");
700 $sql .=
", ".($user->id > 0 ? $user->id :
"null");
701 $sql .=
", null, null, '".$this->db->escape($this->morphy).
"'";
702 $sql .=
", ".((int) $this->
typeid);
703 $sql .=
", ".((int) $this->entity);
704 $sql .=
", ".(!empty($this->import_key) ?
"'".$this->db->escape($this->import_key).
"'" :
"null");
705 $sql .=
", ".(!empty($this->ip) ?
"'".$this->db->escape($this->ip).
"'" :
"null");
708 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
709 $result = $this->db->query($sql);
711 $id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"adherent");
717 $modfile =
dol_buildpath(
'core/modules/member/'.$modulenum.
'.php', 0);
719 require_once $modfile;
720 $modname = $modulenum;
721 $modCodeMember =
new $modname();
722 '@phan-var-force ModeleNumRefMembers $modCodeMember';
724 $this->
ref = $modCodeMember->getNextValue(
$mysoc, $this);
731 $result = $this->
update($user, 1, 1, 0, 0,
'add');
733 $this->db->rollback();
738 if ($this->user_id) {
740 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET";
741 $sql .=
" fk_member = ".((int) $this->
id);
742 $sql .=
" WHERE rowid = ".((int) $this->user_id);
743 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
744 $resql = $this->db->query($sql);
746 $this->error =
'Failed to update user to make link with member';
747 $this->db->rollback();
754 $result = $this->call_trigger(
'MEMBER_CREATE', $user);
761 if (count($this->errors)) {
762 dol_syslog(get_class($this).
"::create ".implode(
',', $this->errors), LOG_ERR);
763 $this->db->rollback();
770 $this->error =
'Failed to get last insert id';
771 dol_syslog(get_class($this).
"::create ".$this->error, LOG_ERR);
772 $this->db->rollback();
776 $this->error = $this->db->error();
777 $this->db->rollback();
794 public function update($user, $notrigger = 0, $nosyncuser = 0, $nosyncuserpass = 0, $nosyncthirdparty = 0, $action =
'update')
796 global $langs, $hookmanager;
798 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
800 if (empty($this->country_id) && !empty($this->country_code)) {
801 $country_id =
getCountry($this->country_code,
'3');
802 $this->country_id = is_int($country_id) ? $country_id : 0;
808 dol_syslog(get_class($this).
"::update notrigger=".$notrigger.
", nosyncuser=".$nosyncuser.
", nosyncuserpass=".$nosyncuserpass.
" nosyncthirdparty=".$nosyncthirdparty.
", email=".$this->email);
811 $this->lastname = trim($this->lastname) ? trim($this->lastname) : trim($this->lastname);
812 $this->firstname = trim($this->firstname) ? trim($this->firstname) : trim($this->firstname);
813 if (isset($this->gender)) {
814 $this->gender = trim($this->gender);
823 $this->url = $this->url ?
clean_url($this->url, 0) :
'';
828 $langs->load(
"errors");
829 $this->error = $langs->trans(
"ErrorBadEMail", (
string) $this->email);
835 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
836 $sql .=
" ref = '".$this->db->escape($this->
ref).
"'";
837 $sql .=
", ref_ext = ".(empty($this->ref_ext) ?
"null" :
"'".$this->db->escape($this->ref_ext).
"'");
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);
910 if (!$error && $this->pass) {
911 dol_syslog(get_class($this).
"::update update password");
912 if ($this->pass != $this->pass_indatabase && $this->pass != $this->pass_indatabase_crypted) {
916 $result = $this->
setPassword($user, $this->pass, $isencrypted, $notrigger, $nosyncuserpass);
917 if (!$nbrowsaffected) {
925 dol_syslog(get_class($this).
"::update update link to user");
926 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = NULL WHERE fk_member = ".((int) $this->
id);
927 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
928 $resql = $this->db->query($sql);
930 $this->error = $this->db->error();
931 $this->db->rollback();
935 if ($this->user_id > 0) {
936 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = ".((int) $this->
id).
" WHERE rowid = ".((int) $this->user_id);
937 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
938 $resql = $this->db->query($sql);
940 $this->error = $this->db->error();
941 $this->db->rollback();
947 if (!$error && $nbrowsaffected) {
949 if ($this->user_id > 0 && !$nosyncuser) {
950 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
952 dol_syslog(get_class($this).
"::update update linked user");
954 $luser =
new User($this->db);
955 $result = $luser->fetch($this->user_id);
960 $luser->login = $this->login;
963 $luser->ref = $this->ref;
964 $luser->civility_id = $this->civility_id;
965 $luser->firstname = $this->firstname;
966 $luser->lastname = $this->lastname;
967 $luser->gender = $this->gender;
968 $luser->pass = isset($this->pass) ? $this->pass :
'';
971 $luser->birth = $this->birth;
973 $luser->address = $this->address;
974 $luser->zip = $this->zip;
975 $luser->town = $this->town;
976 $luser->country_id = $this->country_id;
977 $luser->state_id = $this->state_id;
979 $luser->email = $this->email;
980 $luser->socialnetworks = $this->socialnetworks;
981 $luser->office_phone = $this->phone;
982 $luser->user_mobile = $this->phone_mobile;
984 $luser->lang = $this->default_lang;
986 $luser->fk_member = $this->id;
988 $result = $luser->update($user, 0, 1, 1);
990 $this->error = $luser->error;
991 dol_syslog(get_class($this).
"::update ".$this->error, LOG_ERR);
995 $this->error = $luser->error;
1001 if (!$error && $this->socid > 0 && !$nosyncthirdparty) {
1002 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
1004 dol_syslog(get_class($this).
"::update update linked thirdparty");
1008 $lthirdparty =
new Societe($this->db);
1009 $result = $lthirdparty->fetch($this->socid);
1012 $lthirdparty->address = $this->address;
1013 $lthirdparty->zip = $this->zip;
1014 $lthirdparty->town = $this->town;
1015 $lthirdparty->email = $this->email;
1016 $lthirdparty->socialnetworks = $this->socialnetworks;
1017 $lthirdparty->phone = $this->phone;
1018 $lthirdparty->state_id = $this->state_id;
1019 $lthirdparty->country_id = $this->country_id;
1021 $lthirdparty->default_lang = $this->default_lang;
1023 $result = $lthirdparty->update($this->socid, $user, 0, 1, 1,
'update');
1026 $this->error = $lthirdparty->error;
1027 $this->errors = $lthirdparty->errors;
1028 dol_syslog(get_class($this).
"::update ".$this->error, LOG_ERR);
1031 } elseif ($result < 0) {
1032 $this->error = $lthirdparty->error;
1038 if (!$error && !$notrigger) {
1040 $result = $this->call_trigger(
'MEMBER_MODIFY', $user);
1048 $this->db->commit();
1049 return $nbrowsaffected;
1051 $this->db->rollback();
1055 $this->db->rollback();
1056 $this->error = $this->db->lasterror();
1076 $sql =
"SELECT rowid, datec as dateop, dateadh as datedeb, datef as datefin";
1077 $sql .=
" FROM ".MAIN_DB_PREFIX.
"subscription";
1078 $sql .=
" WHERE fk_adherent = ".((int) $this->
id);
1079 $sql .=
" ORDER by dateadh DESC";
1081 dol_syslog(get_class($this).
"::update_end_date", LOG_DEBUG);
1082 $resql = $this->db->query($sql);
1084 $obj = $this->db->fetch_object($resql);
1085 $dateop = $this->db->jdate($obj->dateop);
1086 $datedeb = $this->db->jdate($obj->datedeb);
1087 $datefin = $this->db->jdate($obj->datefin);
1089 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
1090 $sql .=
" datefin=".($datefin !=
'' ?
"'".$this->db->idate($datefin).
"'" :
"null");
1091 $sql .=
" WHERE rowid = ".((int) $this->
id);
1093 dol_syslog(get_class($this).
"::update_end_date", LOG_DEBUG);
1094 $resql = $this->db->query($sql);
1096 $this->last_subscription_date = $dateop;
1097 $this->last_subscription_date_start = $datedeb;
1098 $this->last_subscription_date_end = $datefin;
1099 $this->datefin = $datefin;
1100 $this->db->commit();
1103 $this->db->rollback();
1107 $this->error = $this->db->lasterror();
1108 $this->db->rollback();
1120 public function delete($user, $notrigger = 0)
1133 $result = $this->call_trigger(
'MEMBER_DELETE', $user);
1141 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"categorie_member WHERE fk_member = ".((int) $rowid);
1142 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1143 $resql = $this->db->query($sql);
1146 $this->error .= $this->db->lasterror();
1152 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"subscription WHERE fk_adherent = ".((int) $rowid);
1153 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1154 $resql = $this->db->query($sql);
1157 $this->error .= $this->db->lasterror();
1167 $this->error .= $this->db->lasterror();
1178 dol_syslog(get_class($this).
"::delete erreur ".$errorflag.
" ".$this->error, LOG_ERR);
1184 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"adherent WHERE rowid = ".((int) $rowid);
1185 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1186 $resql = $this->db->query($sql);
1189 $this->error .= $this->db->lasterror();
1195 $this->db->commit();
1198 $this->db->rollback();
1215 global
$conf, $langs, $hookmanager, $user, $action;
1218 $member_origin =
new Adherent($this->db);
1220 dol_syslog(
"mergeMembers merge member id=".$member_origin_id.
" (will be deleted) into the member id=".$this->id);
1221 if ($member_origin->fetch($member_origin_id) < 1) {
1222 $this->error = $langs->trans(
'ErrorRecordNotFound');
1228 $listofproperties = array(
1229 'ref_ext',
'civility',
'lastname',
'firstname',
'morphy',
'societe',
'socid',
'user_id',
'address',
1230 'zip',
'town',
'state_id',
'country',
'phone',
'phone_perso',
'phone_mobile',
'email',
1231 'url',
'socialnetworks',
'birth',
'gender',
'photo',
'public',
'datefin',
'default_lang',
1232 'canvas',
'model_pdf',
'import_key'
1234 foreach ($listofproperties as $property) {
1235 if (empty($this->$property)) {
1236 $this->$property = $member_origin->$property;
1241 $listofproperties = array(
1242 'note_public',
'note_private'
1244 foreach ($listofproperties as $property) {
1245 $this->$property =
dol_concatdesc($this->$property, $member_origin->$property);
1249 if (is_array($member_origin->array_options)) {
1250 foreach ($member_origin->array_options as $key => $val) {
1251 if (empty($this->array_options[$key])) {
1252 $this->array_options[$key] = $val;
1258 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1260 $custcats_ori = $static_cat->containing($member_origin->id,
'member',
'id');
1261 $custcats = $static_cat->containing($this->
id,
'member',
'id');
1262 $custcats = array_merge($custcats, $custcats_ori);
1265 $result = $this->
update($user, 1, 1, 1, 1,
'merge');
1271 if (!$error && $member_origin->fetch_subscriptions() < 1) {
1276 foreach ($member_origin->subscriptions as $key => $subscription) {
1277 $subscription->fk_adherent = $this->id;
1278 $result = $subscription->update($user);
1288 $parameters = array(
'member_origin' => $member_origin->id,
'member_dest' => $this->id);
1289 $reshook = $hookmanager->executeHooks(
'replaceMember', $parameters, $this, $action);
1298 $this->context = array(
'merge' => 1,
'mergefromid' => $member_origin->id);
1301 $result = $this->call_trigger(
'MEMBER_MODIFY', $user);
1310 if ($member_origin->delete($user) < 1) {
1318 if (!empty(
$conf->adherent->multidir_output[$this->entity])) {
1319 $srcdir =
$conf->adherent->multidir_output[$this->entity].
"/".$member_origin->id;
1320 $destdir =
$conf->adherent->multidir_output[$this->entity].
"/".$this->id;
1324 foreach ($dirlist as $filetomove) {
1325 $destfile = $destdir.
'/'.$filetomove[
'relativename'];
1326 $result =
dol_move($filetomove[
'fullname'], $destfile,
'0', 0, 0, 1);
1336 $this->db->commit();
1339 $langs->load(
"errors");
1340 $this->error = $langs->trans(
'ErrorMembersMerge');
1341 $this->db->rollback();
1358 public function setPassword($user, $password =
'', $isencrypted = 0, $notrigger = 0, $nosyncuser = 0)
1360 global
$conf, $langs;
1364 dol_syslog(get_class($this).
"::setPassword user=".$user->id.
" password=".preg_replace(
'/./i',
'*', $password).
" isencrypted=".$isencrypted);
1368 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
1373 $password_crypted =
dol_hash($password);
1375 $password_indatabase =
'';
1376 if (!$isencrypted) {
1377 $password_indatabase = $password;
1383 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent";
1384 $sql .=
" SET pass_crypted = '".$this->db->escape($password_crypted).
"'";
1386 $sql .=
", pass = null";
1388 $sql .=
", pass = '".$this->db->escape($password_indatabase).
"'";
1390 $sql .=
" WHERE rowid = ".((int) $this->
id);
1393 dol_syslog(get_class($this).
"::setPassword", LOG_DEBUG);
1394 $result = $this->db->query($sql);
1396 $nbaffectedrows = $this->db->affected_rows($result);
1398 if ($nbaffectedrows) {
1399 $this->pass = $password;
1400 $this->pass_indatabase = $password_indatabase;
1401 $this->pass_indatabase_crypted = $password_crypted;
1403 if ($this->user_id && !$nosyncuser) {
1404 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
1408 $luser =
new User($this->db);
1409 $result = $luser->fetch($this->user_id);
1412 $result = $luser->setPassword($user, $this->pass, 0, 0, 1);
1413 if (is_int($result) && $result < 0) {
1414 $this->error = $luser->error;
1415 dol_syslog(get_class($this).
"::setPassword ".$this->error, LOG_ERR);
1419 $this->error = $luser->error;
1424 if (!$error && !$notrigger) {
1426 $result = $this->call_trigger(
'MEMBER_NEW_PASSWORD', $user);
1429 $this->db->rollback();
1435 $this->db->commit();
1438 $this->db->rollback();
1442 $this->db->rollback();
1457 global
$conf, $langs;
1462 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = NULL WHERE fk_member = ".((int) $this->
id);
1463 dol_syslog(get_class($this).
"::setUserId", LOG_DEBUG);
1464 $resql = $this->db->query($sql);
1466 $this->error = $this->db->error();
1467 $this->db->rollback();
1473 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = ".((int) $this->
id);
1474 $sql .=
" WHERE rowid = ".((int) $userid);
1475 dol_syslog(get_class($this).
"::setUserId", LOG_DEBUG);
1476 $resql = $this->db->query($sql);
1478 $this->error = $this->db->error();
1479 $this->db->rollback();
1484 $this->db->commit();
1498 global
$conf, $langs;
1503 if ($thirdpartyid > 0) {
1504 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET fk_soc = null";
1505 $sql .=
" WHERE fk_soc = ".((int) $thirdpartyid);
1506 $sql .=
" AND entity = ".$conf->entity;
1507 dol_syslog(get_class($this).
"::setThirdPartyId", LOG_DEBUG);
1508 $resql = $this->db->query($sql);
1512 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET fk_soc = ".($thirdpartyid > 0 ? (int) $thirdpartyid :
'null');
1513 $sql .=
" WHERE rowid = ".((int) $this->
id);
1515 dol_syslog(get_class($this).
"::setThirdPartyId", LOG_DEBUG);
1516 $resql = $this->db->query($sql);
1518 $this->db->commit();
1521 $this->error = $this->db->error();
1522 $this->db->rollback();
1540 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"adherent";
1541 $sql .=
" WHERE login='".$this->db->escape($login).
"'";
1542 $sql .=
" AND entity = ".$conf->entity;
1544 $resql = $this->db->query($sql);
1546 if ($this->db->num_rows($resql)) {
1547 $obj = $this->db->fetch_object($resql);
1548 $this->
fetch($obj->rowid);
1568 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"adherent";
1569 $sql .=
" WHERE firstname='".$this->db->escape($firstname).
"'";
1570 $sql .=
" AND lastname='".$this->db->escape($lastname).
"'";
1571 $sql .=
" AND entity = ".$conf->entity;
1573 $resql = $this->db->query($sql);
1575 if ($this->db->num_rows($resql)) {
1576 $obj = $this->db->fetch_object($resql);
1577 $this->
fetch($obj->rowid);
1595 public function fetch($rowid, $ref =
'', $socid = 0, $ref_ext =
'', $fetch_optionals =
true, $fetch_subscriptions =
true)
1599 $sql =
"SELECT d.rowid, d.ref, d.ref_ext, d.civility as civility_code, d.gender, d.firstname, d.lastname,";
1600 $sql .=
" d.societe as company, d.fk_soc as socid, d.statut, d.public, d.address, d.zip, d.town, d.note_private,";
1601 $sql .=
" d.note_public,";
1602 $sql .=
" d.email, d.url, d.socialnetworks, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass, d.pass_crypted,";
1603 $sql .=
" d.photo, d.fk_adherent_type, d.morphy, d.entity,";
1604 $sql .=
" d.datec as datec,";
1605 $sql .=
" GREATEST(d.tms, aef.tms) as datem,";
1606 $sql .=
" d.datefin as datefin, d.default_lang,";
1607 $sql .=
" d.birth as birthday,";
1608 $sql .=
" d.datevalid as datev,";
1609 $sql .=
" d.country,";
1610 $sql .=
" d.state_id,";
1611 $sql .=
" d.model_pdf,";
1612 $sql .=
" c.rowid as country_id, c.code as country_code, c.label as country,";
1613 $sql .=
" dep.nom as state, dep.code_departement as state_code,";
1614 $sql .=
" t.libelle as type, t.subscription as subscription,";
1615 $sql .=
" u.rowid as user_id, u.login as user_login";
1616 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent_type as t, ".MAIN_DB_PREFIX.
"adherent as d";
1617 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'adherent_extrafields as aef ON aef.fk_object = d.rowid';
1618 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as c ON d.country = c.rowid";
1619 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as dep ON d.state_id = dep.rowid";
1620 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON d.rowid = u.fk_member";
1621 $sql .=
" WHERE d.fk_adherent_type = t.rowid";
1623 $sql .=
" AND d.rowid=".((int) $rowid);
1624 } elseif ($ref || $socid) {
1625 $sql .=
" AND d.entity IN (".getEntity(
'adherent').
")";
1627 $sql .=
" AND d.ref='".$this->db->escape($ref).
"'";
1628 } elseif ($socid > 0) {
1629 $sql .=
" AND d.fk_soc=".((int) $socid);
1631 } elseif ($ref_ext) {
1632 $sql .=
" AND d.ref_ext='".$this->db->escape($ref_ext).
"'";
1635 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
1636 $resql = $this->db->query($sql);
1638 if ($this->db->num_rows($resql)) {
1639 $obj = $this->db->fetch_object($resql);
1641 $this->entity = $obj->entity;
1642 $this->
id = $obj->rowid;
1643 $this->
ref = $obj->ref;
1644 $this->ref_ext = $obj->ref_ext;
1646 $this->civility_id = $obj->civility_code;
1647 $this->civility_code = $obj->civility_code;
1648 $this->civility = $obj->civility_code ? ($langs->trans(
"Civility".$obj->civility_code) !=
"Civility".$obj->civility_code ? $langs->trans(
"Civility".$obj->civility_code) : $obj->civility_code) :
'';
1650 $this->firstname = $obj->firstname;
1651 $this->lastname = $obj->lastname;
1652 $this->gender = $obj->gender;
1653 $this->login = $obj->login;
1654 $this->societe = $obj->company;
1655 $this->company = $obj->company;
1656 $this->socid = $obj->socid;
1657 $this->fk_soc = $obj->socid;
1658 $this->
address = $obj->address;
1659 $this->zip = $obj->zip;
1660 $this->town = $obj->town;
1662 $this->pass = $obj->pass;
1663 $this->pass_indatabase = $obj->pass;
1664 $this->pass_indatabase_crypted = $obj->pass_crypted;
1666 $this->state_id = $obj->state_id;
1667 $this->state_code = $obj->state_id ? $obj->state_code :
'';
1668 $this->state = $obj->state_id ? $obj->state :
'';
1670 $this->country_id = $obj->country_id;
1671 $this->country_code = $obj->country_code;
1672 if ($langs->trans(
"Country".$obj->country_code) !=
"Country".$obj->country_code) {
1673 $this->country = $langs->transnoentitiesnoconv(
"Country".$obj->country_code);
1675 $this->country = $obj->country;
1678 $this->phone = $obj->phone;
1679 $this->phone_perso = $obj->phone_perso;
1680 $this->phone_mobile = $obj->phone_mobile;
1681 $this->email = $obj->email;
1682 $this->url = $obj->url;
1684 $this->socialnetworks = ($obj->socialnetworks ? (array) json_decode($obj->socialnetworks,
true) : array());
1686 $this->photo = $obj->photo;
1687 $this->statut = $obj->statut;
1688 $this->
status = $obj->statut;
1689 $this->
public = $obj->public;
1691 $this->datec = $this->db->jdate($obj->datec);
1692 $this->date_creation = $this->db->jdate($obj->datec);
1693 $this->datem = $this->db->jdate($obj->datem);
1694 $this->date_modification = $this->db->jdate($obj->datem);
1695 $this->datefin = $this->db->jdate($obj->datefin);
1696 $this->datevalid = $this->db->jdate($obj->datev);
1697 $this->date_validation = $this->db->jdate($obj->datev);
1698 $this->birth = $this->db->jdate($obj->birthday);
1700 $this->default_lang = $obj->default_lang;
1702 $this->note_private = $obj->note_private;
1703 $this->note_public = $obj->note_public;
1704 $this->morphy = $obj->morphy;
1706 $this->
typeid = $obj->fk_adherent_type;
1707 $this->
type = $obj->type;
1708 $this->need_subscription = $obj->subscription;
1710 $this->user_id = $obj->user_id;
1711 $this->user_login = $obj->user_login;
1713 $this->model_pdf = $obj->model_pdf;
1717 if ($fetch_optionals) {
1722 if ($fetch_subscriptions) {
1731 $this->error = $this->db->lasterror();
1749 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
1751 $sql =
"SELECT c.rowid, c.fk_adherent, c.fk_type, c.subscription, c.note as note_public, c.fk_bank,";
1752 $sql .=
" c.tms as datem,";
1753 $sql .=
" c.datec as datec,";
1754 $sql .=
" c.dateadh as dateh,";
1755 $sql .=
" c.datef as datef";
1756 $sql .=
" FROM ".MAIN_DB_PREFIX.
"subscription as c";
1757 $sql .=
" WHERE c.fk_adherent = ".((int) $this->
id);
1758 $sql .=
" ORDER BY c.dateadh";
1759 dol_syslog(get_class($this).
"::fetch_subscriptions", LOG_DEBUG);
1761 $resql = $this->db->query($sql);
1763 $this->subscriptions = array();
1766 while ($obj = $this->db->fetch_object($resql)) {
1768 $this->first_subscription_date = $this->db->jdate($obj->datec);
1769 $this->first_subscription_date_start = $this->db->jdate($obj->dateh);
1770 $this->first_subscription_date_end = $this->db->jdate($obj->datef);
1771 $this->first_subscription_amount = $obj->subscription;
1773 $this->last_subscription_date = $this->db->jdate($obj->datec);
1774 $this->last_subscription_date_start = $this->db->jdate($obj->dateh);
1775 $this->last_subscription_date_end = $this->db->jdate($obj->datef);
1776 $this->last_subscription_amount = (float) $obj->subscription;
1779 $subscription->id = $obj->rowid;
1780 $subscription->fk_adherent = $obj->fk_adherent;
1781 $subscription->fk_type = $obj->fk_type;
1782 $subscription->amount = (float) $obj->subscription;
1783 $subscription->note = $obj->note_public;
1784 $subscription->note_public = $obj->note_public;
1785 $subscription->fk_bank = $obj->fk_bank;
1786 $subscription->datem = $this->db->jdate($obj->datem);
1787 $subscription->datec = $this->db->jdate($obj->datec);
1788 $subscription->dateh = $this->db->jdate($obj->dateh);
1789 $subscription->datef = $this->db->jdate($obj->datef);
1791 $this->subscriptions[] = $subscription;
1797 $this->error = $this->db->error().
' sql='.$sql;
1811 require_once DOL_DOCUMENT_ROOT.
'/partnership/class/partnership.class.php';
1814 $this->partnerships[] = array();
1836 public function subscription($date, $amount, $accountid = 0, $operation =
'', $label =
'', $num_chq =
'', $emetteur_nom =
'', $emetteur_banque =
'', $datesubend = 0, $fk_type =
null, $ref_ext =
'')
1840 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
1852 $datefin = $datesubend;
1861 $subscription->fk_adherent = $this->id;
1862 $subscription->dateh = $date;
1863 $subscription->datef = $datefin;
1864 $subscription->amount = $amount;
1865 $subscription->note_public = $label;
1866 $subscription->note_private =
'';
1867 $subscription->fk_type = $fk_type;
1868 $subscription->ref_ext = $ref_ext;
1870 if (empty($subscription->user_creation_id)) {
1871 $subscription->user_creation_id = $user->id;
1874 $rowid = $subscription->create($user);
1881 $this->last_subscription_date =
dol_now();
1882 $this->last_subscription_date_start = $date;
1883 $this->last_subscription_date_end = $datefin;
1884 $this->last_subscription_amount = $amount;
1890 $this->db->commit();
1893 $this->db->rollback();
1898 $this->db->rollback();
1923 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 =
'')
1929 $this->invoice =
null;
1931 dol_syslog(
"subscriptionComplementaryActions subscriptionid=".$subscriptionid.
" option=".$option.
" accountid=".$accountid.
" datesubscription=".$datesubscription.
" paymentdate=".
1932 $paymentdate.
" label=".$label.
" amount=".$amount.
" num_chq=".$num_chq.
" autocreatethirdparty=".$autocreatethirdparty);
1935 if ($option ==
'bankdirect' && $accountid) {
1936 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
1938 $acct =
new Account($this->db);
1939 $result = $acct->fetch($accountid);
1941 $dateop = $paymentdate;
1943 $insertid = $acct->addline($dateop, $operation, $label, $amount, $num_chq, 0, $user, $emetteur_nom, $emetteur_banque);
1944 if ($insertid > 0) {
1945 $inserturlid = $acct->add_url_line($insertid, $this->
id, DOL_URL_ROOT.
'/adherents/card.php?rowid=', $this->getFullName($langs),
'member');
1946 if ($inserturlid > 0) {
1948 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"subscription SET fk_bank=".((int) $insertid);
1949 $sql .=
" WHERE rowid=".((int) $subscriptionid);
1951 dol_syslog(
"subscription::subscription", LOG_DEBUG);
1952 $resql = $this->db->query($sql);
1955 $this->error = $this->db->lasterror();
1956 $this->errors[] = $this->error;
1969 if (($option ==
'bankviainvoice' && $accountid) || $option ==
'invoiceonly') {
1970 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1971 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/paymentterm.class.php';
1973 $invoice =
new Facture($this->db);
1974 $customer =
new Societe($this->db);
1977 if (!($this->socid > 0)) {
1978 if ($autocreatethirdparty) {
1983 if ($this->morphy ==
'mor') {
1984 $companyname = $this->company;
1985 if (!empty($fullname)) {
1986 $companyalias = $fullname;
1989 $companyname = $fullname;
1990 if (!empty($this->company)) {
1991 $companyalias = $this->company;
1995 $result = $customer->create_from_member($this, (
string) $companyname, $companyalias);
1997 $this->error = $customer->error;
1998 $this->errors = $customer->errors;
2001 $this->fk_soc = $result;
2002 $this->socid = $result;
2005 $langs->load(
"errors");
2006 $this->error = $langs->trans(
"ErrorMemberNotLinkedToAThirpartyLinkOrCreateFirst");
2007 $this->errors[] = $this->error;
2013 $result = $customer->fetch($this->socid);
2015 $this->error = $customer->error;
2016 $this->errors = $customer->errors;
2024 $invoice->cond_reglement_id = $customer->cond_reglement_id;
2025 if (empty($invoice->cond_reglement_id)) {
2027 $invoice->cond_reglement_id = $paymenttermstatic->getDefaultId();
2028 if (empty($invoice->cond_reglement_id)) {
2030 $this->error =
'ErrorNoPaymentTermRECEPFound';
2031 $this->errors[] = $this->error;
2034 $invoice->socid = $this->socid;
2036 if (!empty($customer->fk_account)) {
2037 $invoice->fk_account = $customer->fk_account;
2043 if (!empty($customer->mode_reglement_id)) {
2044 $invoice->mode_reglement_id = $customer->mode_reglement_id;
2050 $invoice->linked_objects[
'subscription'] = $subscriptionid;
2052 $invoice->linked_objects = array_merge($invoice->linked_objects,
GETPOST(
'other_linked_objects',
'array:int'));
2055 $result = $invoice->create($user);
2060 $this->invoice = $invoice;
2066 $idprodsubscription = 0;
2072 if (
getDolGlobalString(
'ADHERENT_VAT_FOR_SUBSCRIPTIONS') ==
'defaultforfoundationcountry') {
2077 $result = $invoice->addline($label, 0, 1, $vattouse, 0, 0, $idprodsubscription, 0, $datesubscription,
'', 0, 0, 0,
'TTC', $amount, 1);
2086 $result = $invoice->validate($user);
2098 if (!$error && $option ==
'bankviainvoice' && $accountid) {
2099 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
2100 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
2101 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions.lib.php';
2104 $amounts[$invoice->id] = (float)
price2num($amount);
2106 $paiement =
new Paiement($this->db);
2107 $paiement->datepaye = $paymentdate;
2108 $paiement->amounts = $amounts;
2109 $paiement->paiementcode = $operation;
2110 $paiement->paiementid =
dol_getIdFromCode($this->db, $operation,
'c_paiement',
'code',
'id', 1);
2111 $paiement->num_payment = $num_chq;
2112 $paiement->note_public = $label;
2113 $paiement->ext_payment_id = $ext_payment_id;
2114 $paiement->ext_payment_site = $ext_payment_site;
2117 $paiement_id = $paiement->create($user);
2118 if (!($paiement_id > 0)) {
2125 $bank_line_id = $paiement->addPaymentToBank($user,
'payment',
'(SubscriptionPayment)', $accountid, $emetteur_nom, $emetteur_banque);
2126 if (!($bank_line_id > 0)) {
2132 if (!$error && !empty($bank_line_id)) {
2134 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'subscription SET fk_bank='.((int) $bank_line_id);
2135 $sql .=
' WHERE rowid='.((int) $subscriptionid);
2137 $result = $this->db->query($sql);
2145 $invoice->setPaid($user);
2151 $outputlangs = $langs;
2153 $lang_id =
GETPOST(
'lang_id');
2154 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && !empty($lang_id)) {
2155 $newlang = $lang_id;
2158 $newlang = $customer->default_lang;
2160 if (!empty($newlang)) {
2162 $outputlangs->setDefaultLang($newlang);
2167 $invoice->fetch($invoice->id);
2168 $invoice->generateDocument($invoice->model_pdf, $outputlangs);
2189 global $langs,
$conf;
2195 if ($this->
status == self::STATUS_VALIDATED) {
2196 dol_syslog(get_class($this).
"::validate statut of member does not allow this", LOG_WARNING);
2202 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
2203 $sql .=
" statut = ".self::STATUS_VALIDATED;
2204 $sql .=
", datevalid = '".$this->db->idate($now).
"'";
2205 $sql .=
", fk_user_valid = ".((int) $user->id);
2206 $sql .=
" WHERE rowid = ".((int) $this->
id);
2208 dol_syslog(get_class($this).
"::validate", LOG_DEBUG);
2209 $result = $this->db->query($sql);
2216 $result = $this->call_trigger(
'MEMBER_VALIDATE', $user);
2219 $this->db->rollback();
2225 $this->datevalid = $now;
2227 $this->db->commit();
2230 $this->error = $this->db->error();
2231 $this->db->rollback();
2245 global $langs,
$conf;
2250 if ($this->
status == self::STATUS_RESILIATED) {
2251 dol_syslog(get_class($this).
"::resiliate statut of member does not allow this", LOG_WARNING);
2257 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
2258 $sql .=
" statut = ".((int) self::STATUS_RESILIATED);
2259 $sql .=
", fk_user_valid = ".((int) $user->id);
2260 $sql .=
" WHERE rowid = ".((int) $this->
id);
2262 $result = $this->db->query($sql);
2268 $result = $this->call_trigger(
'MEMBER_RESILIATE', $user);
2271 $this->db->rollback();
2276 $this->db->commit();
2279 $this->error = $this->db->error();
2280 $this->db->rollback();
2299 if ($this->
status == self::STATUS_EXCLUDED) {
2300 dol_syslog(get_class($this).
"::resiliate statut of member does not allow this", LOG_WARNING);
2306 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
2307 $sql .=
" statut = ".((int) self::STATUS_EXCLUDED);
2308 $sql .=
", fk_user_valid = ".((int) $user->id);
2309 $sql .=
" WHERE rowid = ".((int) $this->
id);
2311 $result = $this->db->query($sql);
2317 $result = $this->call_trigger(
'MEMBER_EXCLUDE', $user);
2320 $this->db->rollback();
2325 $this->db->commit();
2328 $this->error = $this->db->error();
2329 $this->db->rollback();
2345 include_once DOL_DOCUMENT_ROOT.
'/mailmanspip/class/mailmanspip.class.php';
2352 $result = $mailmanspip->add_to_mailman($this);
2355 if (!empty($mailmanspip->error)) {
2356 $this->errors[] = $mailmanspip->error;
2360 foreach ($mailmanspip->mladded_ko as $tmplist => $tmpemail) {
2361 $langs->load(
"errors");
2362 $this->errors[] = $langs->trans(
"ErrorFailedToAddToMailmanList", $tmpemail, $tmplist);
2364 foreach ($mailmanspip->mladded_ok as $tmplist => $tmpemail) {
2365 $langs->load(
"mailmanspip");
2366 $this->mesgs[] = $langs->trans(
"SuccessToAddToMailmanList", $tmpemail, $tmplist);
2372 $result = $mailmanspip->add_to_spip($this);
2374 $this->errors[] = $mailmanspip->error;
2395 global
$conf, $langs;
2397 include_once DOL_DOCUMENT_ROOT.
'/mailmanspip/class/mailmanspip.class.php';
2404 $result = $mailmanspip->del_to_mailman($this);
2406 if (!empty($mailmanspip->error)) {
2407 $this->errors[] = $mailmanspip->error;
2412 foreach ($mailmanspip->mlremoved_ko as $tmplist => $tmpemail) {
2413 $langs->load(
"errors");
2414 $this->errors[] = $langs->trans(
"ErrorFailedToRemoveToMailmanList", $tmpemail, $tmplist);
2416 foreach ($mailmanspip->mlremoved_ok as $tmplist => $tmpemail) {
2417 $langs->load(
"mailmanspip");
2418 $this->mesgs[] = $langs->trans(
"SuccessToRemoveToMailmanList", $tmpemail, $tmplist);
2423 $result = $mailmanspip->del_to_spip($this);
2425 $this->errors[] = $mailmanspip->error;
2446 $langs->load(
"dict");
2448 $code = (empty($this->civility_id) ?
'' : $this->civility_id);
2452 return $langs->getLabelFromKey($this->db,
"Civility".$code,
"c_civility",
"code",
"label", $code);
2465 $langs->loadLangs([
'members',
'companies']);
2466 $nofetch = !empty($params[
'nofetch']);
2471 $langs->load(
"users");
2472 return [
'optimize' => $langs->trans(
"ShowUser")];
2474 if (!empty($this->photo)) {
2475 $photo =
'<div class="photointooltip floatright">';
2476 $photo .=
Form::showphoto(
'memberphoto', $this, 80, 0, 0,
'photoref photowithmargin photologintooltip',
'small', 0, 1);
2478 $datas[
'photo'] = $photo;
2481 $datas[
'divopen'] =
'<div class="centpercent">';
2482 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <u class="paddingrightonly">'.$langs->trans(
"Member").
'</u> '.$this->
getLibStatut(4);
2483 if (!empty($this->morphy)) {
2484 $datas[
'picto'] .=
' ' . $this->
getmorphylib(
'', 1);
2486 if (!empty($this->
ref)) {
2487 $datas[
'ref'] =
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
2489 if (!empty($this->login)) {
2490 $datas[
'login'] =
'<br><b>'.$langs->trans(
'Login').
':</b> '.$this->login;
2492 if (!empty($this->firstname) || !empty($this->lastname)) {
2493 $datas[
'name'] =
'<br><b>'.$langs->trans(
'Name').
':</b> '.$this->
getFullName($langs);
2495 if (!empty($this->company)) {
2496 $datas[
'company'] =
'<br><b>'.$langs->trans(
'Company').
':</b> '.$this->company;
2498 if (!empty($this->email)) {
2499 $datas[
'email'] =
'<br><b>'.$langs->trans(
"EMail").
':</b> '.$this->email;
2501 $datas[
'address'] =
'<br><b>'.$langs->trans(
"Address").
':</b> '.
dol_format_address($this, 1,
' ', $langs);
2504 require_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
2505 $form =
new Form($this->db);
2506 $datas[
'categories'] =
'<br>' . $form->showCategories($this->
id, Categorie::TYPE_MEMBER, 1);
2508 $datas[
'divclose'] =
'</div>';
2526 public function getNomUrl($withpictoimg = 0, $maxlen = 0, $option =
'card', $mode =
'', $morecss =
'', $save_lastsearch_value = -1, $notooltip = 0, $addlinktonotes = 0)
2528 global $langs, $hookmanager;
2537 $classfortooltip =
'classfortooltip';
2541 'objecttype' => $this->element,
2542 'option' => $option,
2546 $classfortooltip =
'classforajaxtooltip';
2547 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
2553 $baseurl = DOL_URL_ROOT .
'/adherents/card.php';
2554 if ($option ==
'subscription') {
2555 $baseurl = DOL_URL_ROOT .
'/adherents/subscription.php';
2557 $query = [
'rowid' => $this->id];
2559 if ($option !=
'nolink') {
2561 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
2562 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
2563 $add_save_lastsearch_values = 1;
2565 if ($add_save_lastsearch_values) {
2566 $query = array_merge($query, [
'save_lastsearch_values' => 1]);
2571 $linkstart .=
'<a href="'.$url.
'"';
2573 if (empty($notooltip)) {
2575 $langs->load(
"users");
2576 $label = $langs->trans(
"ShowUser");
2577 $linkclose .=
' alt="'.dolPrintHTMLForAttribute($label).
'"';
2579 $linkclose .= ($label ?
' title="'.dolPrintHTMLForAttribute($label).
'"' :
' title="tocomplete"');
2580 $linkclose .= $dataparams.
' class="'.$classfortooltip.($morecss ?
' '.$morecss :
'').
'"';
2583 $linkstart .= $linkclose.
'>';
2586 $result .= $linkstart;
2588 if ($withpictoimg) {
2589 if (abs($withpictoimg) == 1 || abs($withpictoimg) == 4) {
2590 $morecss .=
' paddingrightonly';
2593 if ($withpictoimg > 0) {
2594 $picto =
'<span class="nopadding'.($morecss ?
' userimg'.$morecss :
'').
'">'.
img_object(
'',
'user',
' '.($notooltip ?
'' : $dataparams), 0, 0, $notooltip ? 0 : 1).
'</span>';
2597 $picto =
'<span class="nopadding'.($morecss ?
' userimg'.$morecss :
'').
'">';
2598 $picto .=
Form::showphoto(
'memberphoto', $this, 0, 0, 0,
'userphoto'.(($withpictoimg == -3 || $withpictoimg == -4) ?
'small' :
''),
'mini', 0, 1);
2599 $picto .=
'</span>';
2603 if (($withpictoimg > -2 && $withpictoimg != 2) || $withpictoimg == -4) {
2605 $result .=
'<span class="nopadding valignmiddle'.((!isset($this->
status) || $this->status) ?
'' :
' strikefordisabled').
2606 ($morecss ?
' usertext'.$morecss :
'').
'">';
2608 if ($mode ==
'login') {
2609 $result .=
dol_trunc(isset($this->login) ? $this->login :
'', $maxlen);
2610 } elseif ($mode ==
'ref') {
2611 $result .= $this->ref;
2613 if (empty($this->lastname) && empty($this->firstname) && !empty($this->company)) {
2614 $result .= $this->company;
2616 $result .= $this->
getFullName($langs, 0, ($mode ==
'firstname' ? 2 : ($mode ==
'lastname' ? 4 : -1)), $maxlen);
2620 $result .=
'</span>';
2624 $result .= $linkend;
2626 if ($addlinktonotes) {
2627 if ($this->note_private) {
2628 $notetoshow = $langs->trans(
"ViewPrivateNote").
':<br>'.
dol_string_nohtmltag($this->note_private, 1);
2629 $result .=
' <span class="note inline-block">';
2630 $result .=
'<a href="'.DOL_URL_ROOT.
'/adherents/note.php?id='.$this->
id.
'" class="classfortooltip" title="'.
dol_escape_htmltag($notetoshow).
'">';
2633 $result .=
'</span>';
2637 $hookmanager->initHooks(array($this->element .
'dao'));
2638 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
2639 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
2641 $result = $hookmanager->resPrint;
2643 $result .= $hookmanager->resPrint;
2656 return $this->
LibStatut($this->
status, $this->need_subscription, $this->datefin, $mode);
2669 public function LibStatut($status, $need_subscription, $date_end_subscription, $mode = 0)
2673 $langs->load(
"members");
2677 $labelStatusShort =
'';
2679 if ($status == self::STATUS_DRAFT) {
2680 $statusType =
'status0';
2681 $labelStatus = $langs->trans(
"MemberStatusDraft");
2682 $labelStatusShort = $langs->trans(
"MemberStatusDraftShort");
2683 } elseif ($status >= self::STATUS_VALIDATED) {
2684 if ($need_subscription === 0) {
2685 $statusType =
'status4';
2686 $labelStatus = $langs->trans(
"Validated").
' - '.$langs->trans(
"MemberStatusNoSubscription");
2687 $labelStatusShort = $langs->trans(
"MemberStatusNoSubscriptionShort");
2688 } elseif (!$date_end_subscription) {
2689 $statusType =
'status1';
2690 $labelStatus = $langs->trans(
"Validated").
' - '.$langs->trans(
"WaitingSubscription");
2691 $labelStatusShort = $langs->trans(
"WaitingSubscriptionShort");
2692 } elseif ($date_end_subscription <
dol_now()) {
2693 $statusType =
'status2';
2694 $labelStatus = $langs->trans(
"Validated").
' - '.$langs->trans(
"MemberStatusActiveLate");
2695 $labelStatusShort = $langs->trans(
"MemberStatusActiveLateShort");
2697 $statusType =
'status4';
2698 $labelStatus = $langs->trans(
"Validated").
' - '.$langs->trans(
"MemberStatusPaid");
2699 $labelStatusShort = $langs->trans(
"MemberStatusPaidShort");
2701 } elseif ($status == self::STATUS_RESILIATED) {
2702 $statusType =
'status6';
2703 $labelStatus = $langs->transnoentitiesnoconv(
"MemberStatusResiliated");
2704 $labelStatusShort = $langs->transnoentitiesnoconv(
"MemberStatusResiliatedShort");
2705 } elseif ($status == self::STATUS_EXCLUDED) {
2706 $statusType =
'status10';
2707 $labelStatus = $langs->transnoentitiesnoconv(
"MemberStatusExcluded");
2708 $labelStatusShort = $langs->transnoentitiesnoconv(
"MemberStatusExcludedShort");
2711 return dolGetStatus($labelStatus, $labelStatusShort,
'', $statusType, $mode);
2724 $this->nb = array();
2726 $sql =
"SELECT count(a.rowid) as nb";
2727 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as a";
2728 $sql .=
" WHERE a.statut > 0";
2729 $sql .=
" AND a.entity IN (".getEntity(
'adherent').
")";
2731 $resql = $this->db->query($sql);
2733 while ($obj = $this->db->fetch_object($resql)) {
2734 $this->nb[
"members"] = $obj->nb;
2736 $this->db->free($resql);
2740 $this->error = $this->db->error();
2756 global
$conf, $langs;
2764 $sql =
"SELECT a.rowid, a.datefin, a.statut as status";
2765 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as a";
2766 $sql .=
", ".MAIN_DB_PREFIX.
"adherent_type as t";
2767 $sql .=
" WHERE a.fk_adherent_type = t.rowid";
2768 if ($mode ==
'expired') {
2769 $sql .=
" AND a.statut = ".self::STATUS_VALIDATED;
2770 $sql .=
" AND a.entity IN (".getEntity(
'adherent').
")";
2771 $sql .=
" AND ((a.datefin IS NULL or a.datefin < '".$this->db->idate($now).
"') AND t.subscription = '1')";
2772 } elseif ($mode ==
'shift') {
2773 $sql .=
" AND a.statut = ".self::STATUS_DRAFT;
2774 $sql .=
" AND a.entity IN (".getEntity(
'adherent').
")";
2777 $resql = $this->db->query($sql);
2779 $langs->load(
"members");
2786 if ($mode ==
'expired') {
2787 $warning_delay =
getWarningDelay(
'member',
'subscription') / 60 / 60 / 24;
2788 $label = $langs->trans(
"MembersWithSubscriptionToReceive");
2789 $labelShort = $langs->trans(
"MembersWithSubscriptionToReceiveShort");
2790 $url =
dolBuildUrl(DOL_URL_ROOT.
'/adherents/list.php', [
'mainmenu' =>
'members',
'statut' => self::STATUS_VALIDATED,
'filter' =>
'outofdate']);
2791 } elseif ($mode ==
'shift') {
2792 $warning_delay =
getWarningDelay(
'member',
'subscription') / 60 / 60 / 24;
2793 $url =
dolBuildUrl(DOL_URL_ROOT.
'/adherents/list.php', [
'mainmenu' =>
'members',
'statut' => self::STATUS_DRAFT]);
2794 $label = $langs->trans(
"MembersListToValid");
2795 $labelShort = $langs->trans(
"ToValidate");
2799 $response->warning_delay = $warning_delay;
2800 $response->label = $label;
2801 $response->labelShort = $labelShort;
2802 $response->url = $url;
2805 $adherentstatic =
new Adherent($this->db);
2807 while ($obj = $this->db->fetch_object($resql)) {
2808 $response->nbtodo++;
2810 $adherentstatic->datefin = $this->db->jdate($obj->datefin);
2811 $adherentstatic->statut = $obj->status;
2812 $adherentstatic->status = $obj->status;
2814 if ($adherentstatic->hasDelay()) {
2815 $response->nbtodolate++;
2822 $this->error = $this->db->error();
2839 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams =
null)
2841 global
$conf, $langs;
2843 $langs->load(
"orders");
2846 $modele =
'standard';
2848 if ($this->model_pdf) {
2849 $modele = $this->model_pdf;
2855 $modelpath =
"core/modules/member/doc/";
2857 return $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
2870 global $user, $langs;
2875 $this->
ref =
'ABC001';
2877 $this->specimen = 1;
2878 $this->civility_id =
'MR';
2879 $this->lastname =
'DOLIBARR';
2880 $this->firstname =
'SPECIMEN';
2881 $this->gender =
'man';
2882 $this->login =
'dolibspec';
2883 $this->pass =
'dolibspec';
2884 $this->company =
'Societe ABC';
2885 $this->
address =
'61 jump street';
2886 $this->zip =
'75000';
2887 $this->town =
'Paris';
2888 $this->country_id = 1;
2889 $this->country_code =
'FR';
2890 $this->country =
'France';
2891 $this->morphy =
'mor';
2892 $this->email =
'specimen@specimen.com';
2893 $this->socialnetworks = array(
2894 'skype' =>
'skypepseudo',
2895 'twitter' =>
'twitterpseudo',
2896 'facebook' =>
'facebookpseudo',
2897 'linkedin' =>
'linkedinpseudo',
2899 $this->phone =
'0999999999';
2900 $this->phone_perso =
'0999999998';
2901 $this->phone_mobile =
'0999999997';
2902 $this->note_public =
'This is a public note';
2903 $this->note_private =
'This is a private note';
2904 $this->birth = $now;
2910 $this->datefin = $now;
2911 $this->datevalid = $now;
2912 $this->default_lang =
'';
2915 $this->
type =
'Type adherent';
2916 $this->need_subscription = 0;
2918 $this->first_subscription_date = $now;
2919 $this->first_subscription_date_start = $this->first_subscription_date;
2920 $this->first_subscription_date_end =
dol_time_plus_duree($this->first_subscription_date_start, 1,
'y');
2921 $this->first_subscription_amount = 10;
2923 $this->last_subscription_date = $this->first_subscription_date;
2924 $this->last_subscription_date_start = $this->first_subscription_date;
2925 $this->last_subscription_date_end =
dol_time_plus_duree($this->last_subscription_date_start, 1,
'y');
2926 $this->last_subscription_amount = 10;
2970 global
$conf, $langs;
2974 $keymodified =
false;
2982 if ($this->morphy ==
'mor' && (empty($this->fullname) || $this->fullname == $this->company)) {
2983 $this->fullname = $this->company;
2984 $this->lastname = $this->company;
2989 'LDAP_MEMBER_FIELD_FULLNAME' =>
'fullname',
2990 'LDAP_MEMBER_FIELD_NAME' =>
'lastname',
2991 'LDAP_MEMBER_FIELD_LOGIN' =>
'login',
2992 'LDAP_MEMBER_FIELD_LOGIN_SAMBA' =>
'login',
2993 'LDAP_MEMBER_FIELD_MAIL' =>
'email'
2997 foreach ($ldapkey as $constname => $varname) {
3003 if (!empty($this->oldcopy) && $this->$varname != $this->oldcopy->$varname) {
3004 $keymodified =
true;
3030 foreach ($socialnetworks as $key => $value) {
3031 if ($this->socialnetworks[$value[
'label']] &&
getDolGlobalString(
'LDAP_MEMBER_FIELD_'.strtoupper($value[
'label']))) {
3032 $info[
getDolGlobalString(
'LDAP_MEMBER_FIELD_'.strtoupper($value[
'label']))] = $this->socialnetworks[$value[
'label']];
3059 if ($this->datefin &&
getDolGlobalString(
'LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION')) {
3064 if (!empty($this->pass)) {
3077 if ($this->pass_indatabase_crypted &&
getDolGlobalString(
'LDAP_MEMBER_FIELD_PASSWORD_CRYPTED')) {
3083 } elseif (!empty($this->pass_indatabase)) {
3095 if ($this->first_subscription_date &&
getDolGlobalString(
'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE')) {
3098 if (isset($this->first_subscription_amount) &&
getDolGlobalString(
'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT')) {
3099 $info[
getDolGlobalString(
'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT')] = $this->first_subscription_amount;
3101 if ($this->last_subscription_date &&
getDolGlobalString(
'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE')) {
3104 if (isset($this->last_subscription_amount) &&
getDolGlobalString(
'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT')) {
3105 $info[
getDolGlobalString(
'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT')] = $this->last_subscription_amount;
3120 $sql =
'SELECT a.rowid, a.datec as datec,';
3121 $sql .=
' a.datevalid as datev,';
3122 $sql .=
' GREATEST(a.tms, aef.tms) as datem,';
3123 $sql .=
' a.fk_user_author, a.fk_user_valid, a.fk_user_mod';
3124 $sql .=
' FROM '.MAIN_DB_PREFIX.
'adherent as a';
3125 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'adherent_extrafields as aef ON aef.fk_object = a.rowid';
3126 $sql .=
' WHERE a.rowid = '.((int) $id);
3128 dol_syslog(get_class($this).
"::info", LOG_DEBUG);
3129 $result = $this->db->query($sql);
3131 if ($this->db->num_rows($result)) {
3132 $obj = $this->db->fetch_object($result);
3134 $this->
id = $obj->rowid;
3136 $this->user_creation_id = $obj->fk_user_author;
3137 $this->user_validation_id = $obj->fk_user_valid;
3138 $this->user_modification_id = $obj->fk_user_mod;
3139 $this->date_creation = $this->db->jdate($obj->datec);
3140 $this->date_validation = $this->db->jdate($obj->datev);
3141 $this->date_modification = $this->db->jdate($obj->datem);
3144 $this->db->free($result);
3157 $sql =
"SELECT count(mc.email) as nb";
3158 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mailing_cibles as mc";
3159 $sql .=
" WHERE mc.email = '".$this->db->escape($this->email).
"'";
3160 $sql .=
" AND mc.statut NOT IN (-1,0)";
3162 $resql = $this->db->query($sql);
3164 $obj = $this->db->fetch_object($resql);
3165 $nb = (int) $obj->nb;
3167 $this->db->free($resql);
3170 $this->error = $this->db->error();
3187 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
3188 return parent::setCategoriesCommon($categories, Categorie::TYPE_MEMBER);
3201 $tables = array(
'adherent');
3216 if ($this->
status != self::STATUS_VALIDATED) {
3219 if (!$this->datefin) {
3225 return $this->datefin < ($now -
getWarningDelay(
'member',
'subscription'));
3245 $blockingerrormsg =
'';
3248 $langs->load(
"agenda");
3249 $this->output = $langs->trans(
'ModuleNotEnabled', $langs->transnoentitiesnoconv(
"Adherent"));
3253 $langs->load(
"agenda");
3254 $this->output = $langs->trans(
'EventRemindersByEmailNotEnabled', $langs->transnoentitiesnoconv(
"Adherent"));
3262 $listofmembersok = array();
3263 $listofmembersko = array();
3265 $arraydaysbeforeend = explode(
';', $daysbeforeendlist);
3266 foreach ($arraydaysbeforeend as $daysbeforeend) {
3267 dol_syslog(__METHOD__.
' - Process delta = '.$daysbeforeend, LOG_DEBUG);
3269 if (!is_numeric($daysbeforeend)) {
3270 $blockingerrormsg =
"Value for delta is not a numeric value";
3276 $datetosearchfor =
dol_time_plus_duree(
dol_mktime(0, 0, 0, $tmp[
'mon'], $tmp[
'mday'], $tmp[
'year'],
'tzserver'), (
int) $daysbeforeend,
'd');
3277 $datetosearchforend =
dol_time_plus_duree(
dol_mktime(23, 59, 59, $tmp[
'mon'], $tmp[
'mday'], $tmp[
'year'],
'tzserver'), (
int) $daysbeforeend,
'd');
3279 $sql =
'SELECT rowid FROM '.MAIN_DB_PREFIX.
'adherent';
3280 $sql .=
" WHERE entity = ".((int)
$conf->entity);
3281 $sql .=
" AND statut = 1";
3282 $sql .=
" AND datefin >= '".$this->db->idate($datetosearchfor).
"'";
3283 $sql .=
" AND datefin <= '".$this->db->idate($datetosearchforend).
"'";
3284 if ((
int) $fk_adherent_type > 0) {
3285 $sql .=
" AND fk_adherent_type = ".((int) $fk_adherent_type);
3289 $resql = $this->db->query($sql);
3291 $num_rows = $this->db->num_rows($resql);
3293 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
3294 $adherent =
new Adherent($this->db);
3295 $formmail =
new FormMail($this->db);
3298 while ($i < $num_rows) {
3299 $obj = $this->db->fetch_object($resql);
3301 $adherent->fetch($obj->rowid,
'', 0,
'',
true,
true);
3303 if (empty($adherent->email)) {
3305 $listofmembersko[$adherent->id] = $adherent->id;
3307 $thirdpartyres = $adherent->fetch_thirdparty();
3308 if ($thirdpartyres === -1) {
3309 $languagecodeformember =
$mysoc->default_lang;
3312 $languagefromcountrycode =
getLanguageCodeFromCountryCode($adherent->country_code ? $adherent->country_code : $adherent->thirdparty->country_code);
3313 $languagecodeformember = (empty($adherent->thirdparty->default_lang) ? ($languagefromcountrycode ? $languagefromcountrycode :
$mysoc->default_lang) : $adherent->thirdparty->default_lang);
3318 $outputlangs->setDefaultLang($languagecodeformember);
3319 $outputlangs->loadLangs(array(
"main",
"members"));
3320 dol_syslog(
"sendReminderForExpiredSubscription Language for member id ".$adherent->id.
" set to ".$outputlangs->defaultlang.
" mysoc->default_lang=".
$mysoc->default_lang);
3322 $arraydefaultmessage =
null;
3325 if (!empty($labeltouse)) {
3326 $arraydefaultmessage = $formmail->getEMailTemplate($this->db,
'member', $user, $outputlangs, 0, 1, $labeltouse);
3329 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
3330 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0,
null, $adherent);
3334 $subject =
make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs);
3335 $msg =
make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs);
3337 $to = $adherent->email;
3340 $trackid =
'mem'.$adherent->id;
3341 $moreinheader =
'X-Dolibarr-Info: sendReminderForExpiredSubscription'.
"\r\n";
3343 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
3344 $cmail =
new CMailFile($subject, $to, $from, $msg, array(), array(), array(), $cc,
'', 0, 1,
'',
'', $trackid, $moreinheader);
3345 $result = $cmail->sendfile();
3348 $this->error .= $cmail->error.
' ';
3349 if (!is_null($cmail->errors)) {
3350 $this->errors += $cmail->errors;
3353 $listofmembersko[$adherent->id] = $adherent->id;
3356 $listofmembersok[$adherent->id] = $adherent->id;
3362 $actioncode =
'EMAIL';
3363 $extraparams = array();
3373 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic').
": ".$subject);
3374 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody').
":");
3378 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
3383 $actioncomm->type_code =
'AC_OTH_AUTO';
3384 $actioncomm->code =
'AC_'.$actioncode;
3385 $actioncomm->label = $actionmsg2;
3386 $actioncomm->note_private = $actionmsg;
3387 $actioncomm->fk_project = 0;
3388 $actioncomm->datep = $now;
3389 $actioncomm->datef = $now;
3390 $actioncomm->percentage = -1;
3391 $actioncomm->socid = $adherent->thirdparty->id;
3392 $actioncomm->contact_id = 0;
3393 $actioncomm->authorid = $user->id;
3394 $actioncomm->userownerid = $user->id;
3396 $actioncomm->email_msgid = $cmail->msgid;
3397 $actioncomm->email_from = $from;
3398 $actioncomm->email_sender =
'';
3399 $actioncomm->email_to = $to;
3400 $actioncomm->email_tocc = $sendtocc;
3401 $actioncomm->email_tobcc = $sendtobcc;
3402 $actioncomm->email_subject = $subject;
3403 $actioncomm->errors_to =
'';
3405 $actioncomm->fk_element = $adherent->id;
3406 $actioncomm->elementid = $adherent->id;
3407 $actioncomm->elementtype = $adherent->element;
3409 $actioncomm->extraparams = $extraparams;
3411 $actioncomm->create($user);
3417 $this->error .=
"Can't find email template with label=".$labeltouse.
", to use for the reminding email ";
3420 $listofmembersko[$adherent->id] = $adherent->id;
3429 $this->error = $this->db->lasterror();
3434 if ($blockingerrormsg) {
3435 $this->error = $blockingerrormsg;
3438 $this->output =
'Found '.($nbok + $nbko).
' members to send reminder to.';
3439 $this->output .=
' Send email successfully to '.$nbok.
' members';
3442 foreach ($listofmembersok as $idmember) {
3444 $listofids .=
', ...';
3447 if (empty($listofids)) {
3452 $listofids .= $idmember;
3458 $this->output .= ($listofids ?
' ids='.$listofids :
'');
3461 $this->output .=
' - Canceled for '.$nbko.
' member (no email or email sending error)';
3464 foreach ($listofmembersko as $idmember) {
3466 $listofids .=
', ...';
3469 if (empty($listofids)) {
3474 $listofids .= $idmember;
3480 $this->output .= ($listofids ?
' ids='.$listofids :
'');
3496 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
3498 $return =
'<div class="box-flex-item box-flex-grow-zero">';
3499 $return .=
'<div class="info-box info-box-sm">';
3500 $return .=
'<span class="info-box-icon bg-infobox-action">';
3501 if (!empty($this->photo)) {
3502 $return .=
Form::showphoto(
'memberphoto', $this, 0, 60, 0,
'photokanban photowithmargin photologintooltip',
'small', 0, 1);
3506 $return .=
'</span>';
3507 $return .=
'<div class="info-box-content">';
3508 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">' . $this->
getNomUrl() .
'</span>';
3509 if ($selected >= 0) {
3510 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
3512 $return .=
'<br><span class="info-box-label paddingright">'.$this->getmorphylib(
'', 2).
'</span>';
3513 $return .=
'<span class="info-box-label opacitymedium">'.$this->type.
'</span>';
3515 $return .=
'<br><div class="info-box-status paddingtop">';
3516 $return .= $this->
LibStatut($this->
status, $this->need_subscription, $this->datefin, 5);
3517 $return .=
'</div>';
3518 $return .=
'</div>';
3519 $return .=
'</div>';
3520 $return .=
'</div>';
Class to manage bank accounts.
Class to manage agenda events (actions)
Class to manage members of a foundation.
mergeMembers($member_origin_id)
Merge a member with current one, deleting the given company $member_origin_id.
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)
Returns the complete DN (Distinguished Name) string in the LDAP directory for the object.
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)
Function that terminates a member.
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.
subscription($date, $amount, $accountid=0, $operation='', $label='', $num_chq='', $emetteur_nom='', $emetteur_banque='', $datesubend=0, $fk_type=null, $ref_ext='')
Insert subscription into database and eventually add links to banks, mailman, etc....
__construct($db)
Constructor.
validate($user, $notrigger=0)
Function that validate a member.
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,...
fetch($rowid, $ref='', $socid=0, $ref_ext='', $fetch_optionals=true, $fetch_subscriptions=true)
Load member from database.
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.
Class to manage categories.
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.
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").
dol_move($srcfile, $destfile, $newmask='0', $overwriteifexists=1, $testvirus=0, $indexdatabase=1, $moreinfo=array(), $entity=null)
Move a file into another name.
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
dol_is_dir($folder)
Test if filename is a directory.
clean_url($url, $http=1)
Clean an url string.
dol_now($mode='gmt')
Return date for now.
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 '.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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...
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_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
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.
isModEnabled($module)
Is Dolibarr module enabled.
getWarningDelay($module, $parmlevel1, $parmlevel2='')
Return a warning delay You can use it like this: if (getWarningDelay('module', 'paramlevel1')) It rep...
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
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
getRandomPassword($generic=false, $replaceambiguouschars=null, $length=32)
Return a generated password using default module.
dolGetLdapPasswordHash($password, $type='md5')
Returns a specific ldap hash of a password.
dol_hash($chain, $type='0', $nosalt=0, $mode=0)
Returns a hash (non reversible encryption) of a string.