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);
814 if (empty($this->civility_code) && !empty($this->civility_id)) {
815 $this->civility_code = $this->civility_id;
817 if (isset($this->gender)) {
818 $this->gender = trim($this->gender);
827 $this->url = $this->url ?
clean_url($this->url, 0) :
'';
832 $langs->load(
"errors");
833 $this->error = $langs->trans(
"ErrorBadEMail", (
string) $this->email);
839 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
840 $sql .=
" ref = '".$this->db->escape($this->
ref).
"'";
841 $sql .=
", ref_ext = ".(empty($this->ref_ext) ?
"null" :
"'".$this->db->escape($this->ref_ext).
"'");
842 $sql .=
", civility = ".($this->civility_code ?
"'".$this->db->escape($this->civility_code).
"'" :
"null");
843 $sql .=
", firstname = ".($this->firstname ?
"'".$this->db->escape($this->firstname).
"'" :
"null");
844 $sql .=
", lastname = ".($this->lastname ?
"'".$this->db->escape($this->lastname).
"'" :
"null");
845 $sql .=
", gender = ".($this->gender != -1 ?
"'".$this->db->escape($this->gender).
"'" :
"null");
846 $sql .=
", login = ".($this->login ?
"'".$this->db->escape($this->login).
"'" :
"null");
847 $sql .=
", societe = ".($this->company ?
"'".$this->db->escape($this->company).
"'" : ($this->societe ?
"'".$this->db->escape($this->societe).
"'" :
"null"));
849 $sql .=
", fk_soc = ".($this->socid > 0 ? (int) $this->socid :
"null");
851 $sql .=
", address = ".($this->address ?
"'".$this->db->escape($this->
address).
"'" :
"null");
852 $sql .=
", zip = ".($this->zip ?
"'".$this->db->escape($this->zip).
"'" :
"null");
853 $sql .=
", town = ".($this->town ?
"'".$this->db->escape($this->town).
"'" :
"null");
854 $sql .=
", country = ".($this->country_id > 0 ? (int) $this->country_id :
"null");
855 $sql .=
", state_id = ".($this->state_id > 0 ? (int) $this->state_id :
"null");
856 $sql .=
", email = '".$this->db->escape((
string) $this->email).
"'";
857 $sql .=
", url = ".(!empty($this->url) ?
"'".$this->db->escape($this->url).
"'" :
"null");
858 $sql .=
", socialnetworks = ".($this->socialnetworks ?
"'".$this->db->escape(json_encode($this->socialnetworks)).
"'" :
"null");
859 $sql .=
", phone = ".($this->phone ?
"'".$this->db->escape($this->phone).
"'" :
"null");
860 $sql .=
", phone_perso = ".($this->phone_perso ?
"'".$this->db->escape($this->phone_perso).
"'" :
"null");
861 $sql .=
", phone_mobile = ".($this->phone_mobile ?
"'".$this->db->escape($this->phone_mobile).
"'" :
"null");
862 $sql .=
", note_private = ".($this->note_private ?
"'".$this->db->escape($this->note_private).
"'" :
"null");
863 $sql .=
", note_public = ".($this->note_public ?
"'".$this->db->escape($this->note_public).
"'" :
"null");
864 $sql .=
", photo = ".($this->photo ?
"'".$this->db->escape($this->photo).
"'" :
"null");
865 $sql .=
", public = ".(int) $this->
public;
866 $sql .=
", statut = ".(int) $this->statut;
867 $sql .=
", default_lang = ".(!empty($this->default_lang) ?
"'".$this->db->escape($this->default_lang).
"'" :
"null");
868 $sql .=
", fk_adherent_type = ".(int) $this->
typeid;
869 $sql .=
", morphy = '".$this->db->escape($this->morphy).
"'";
870 $sql .=
", birth = ".($this->birth ?
"'".$this->db->idate($this->birth).
"'" :
"null");
872 if ($this->datefin) {
873 $sql .=
", datefin = '".$this->db->idate($this->datefin).
"'";
875 if ($this->datevalid) {
876 $sql .=
", datevalid = '".$this->db->idate($this->datevalid).
"'";
878 $sql .=
", fk_user_mod = ".($user->id > 0 ? $user->id :
'null');
879 $sql .=
" WHERE rowid = ".((int) $this->
id);
882 '@phan-var-force Adherent $oldcopy';
883 if (!empty($this->oldcopy) && $this->
typeid != $this->oldcopy->typeid) {
884 $sql2 =
"SELECT libelle as label";
885 $sql2 .=
" FROM ".MAIN_DB_PREFIX.
"adherent_type";
886 $sql2 .=
" WHERE rowid = ".((int) $this->
typeid);
887 $resql2 = $this->db->query($sql2);
889 while ($obj = $this->db->fetch_object($resql2)) {
890 $this->
type = $obj->label;
895 dol_syslog(get_class($this).
"::update update member", LOG_DEBUG);
896 $resql = $this->db->query($sql);
898 unset($this->country_code);
899 unset($this->country);
900 unset($this->state_code);
903 $nbrowsaffected += $this->db->affected_rows($resql);
914 if (!$error && $this->pass) {
915 dol_syslog(get_class($this).
"::update update password");
916 if ($this->pass != $this->pass_indatabase && $this->pass != $this->pass_indatabase_crypted) {
920 $result = $this->
setPassword($user, $this->pass, $isencrypted, $notrigger, $nosyncuserpass);
921 if (!$nbrowsaffected) {
929 dol_syslog(get_class($this).
"::update update link to user");
930 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = NULL WHERE fk_member = ".((int) $this->
id);
931 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
932 $resql = $this->db->query($sql);
934 $this->error = $this->db->error();
935 $this->db->rollback();
939 if ($this->user_id > 0) {
940 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = ".((int) $this->
id).
" WHERE rowid = ".((int) $this->user_id);
941 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
942 $resql = $this->db->query($sql);
944 $this->error = $this->db->error();
945 $this->db->rollback();
951 if (!$error && $nbrowsaffected) {
953 if ($this->user_id > 0 && !$nosyncuser) {
954 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
956 dol_syslog(get_class($this).
"::update update linked user");
958 $luser =
new User($this->db);
959 $result = $luser->fetch($this->user_id);
964 $luser->login = $this->login;
967 $luser->ref = $this->ref;
968 $luser->civility_code = $this->civility_code;
969 $luser->firstname = $this->firstname;
970 $luser->lastname = $this->lastname;
971 $luser->gender = $this->gender;
972 $luser->pass = isset($this->pass) ? $this->pass :
'';
975 $luser->birth = $this->birth;
977 $luser->address = $this->address;
978 $luser->zip = $this->zip;
979 $luser->town = $this->town;
980 $luser->country_id = $this->country_id;
981 $luser->state_id = $this->state_id;
983 $luser->email = $this->email;
984 $luser->socialnetworks = $this->socialnetworks;
985 $luser->office_phone = $this->phone;
986 $luser->user_mobile = $this->phone_mobile;
988 $luser->lang = $this->default_lang;
990 $luser->fk_member = $this->id;
992 $result = $luser->update($user, 0, 1, 1);
994 $this->error = $luser->error;
995 dol_syslog(get_class($this).
"::update ".$this->error, LOG_ERR);
999 $this->error = $luser->error;
1005 if (!$error && $this->socid > 0 && !$nosyncthirdparty) {
1006 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
1008 dol_syslog(get_class($this).
"::update update linked thirdparty");
1012 $lthirdparty =
new Societe($this->db);
1013 $result = $lthirdparty->fetch($this->socid);
1016 $lthirdparty->address = $this->address;
1017 $lthirdparty->zip = $this->zip;
1018 $lthirdparty->town = $this->town;
1019 $lthirdparty->email = $this->email;
1020 $lthirdparty->socialnetworks = $this->socialnetworks;
1021 $lthirdparty->phone = $this->phone;
1022 $lthirdparty->state_id = $this->state_id;
1023 $lthirdparty->country_id = $this->country_id;
1025 $lthirdparty->default_lang = $this->default_lang;
1027 $result = $lthirdparty->update($this->socid, $user, 0, 1, 1,
'update');
1030 $this->error = $lthirdparty->error;
1031 $this->errors = $lthirdparty->errors;
1032 dol_syslog(get_class($this).
"::update ".$this->error, LOG_ERR);
1035 } elseif ($result < 0) {
1036 $this->error = $lthirdparty->error;
1042 if (!$error && !$notrigger) {
1044 $result = $this->call_trigger(
'MEMBER_MODIFY', $user);
1052 $this->db->commit();
1053 return $nbrowsaffected;
1055 $this->db->rollback();
1059 $this->db->rollback();
1060 $this->error = $this->db->lasterror();
1080 $sql =
"SELECT rowid, datec as dateop, dateadh as datedeb, datef as datefin";
1081 $sql .=
" FROM ".MAIN_DB_PREFIX.
"subscription";
1082 $sql .=
" WHERE fk_adherent = ".((int) $this->
id);
1083 $sql .=
" ORDER by dateadh DESC";
1085 dol_syslog(get_class($this).
"::update_end_date", LOG_DEBUG);
1086 $resql = $this->db->query($sql);
1094 $dateendmember =
'';
1096 while ($obj = $this->db->fetch_object($resql)) {
1097 $dateendsubscription = $this->db->jdate($obj->datefin);
1099 $dateop = $this->db->jdate($obj->dateop);
1100 $datedeb = $this->db->jdate($obj->datedeb);
1101 $datefin = $dateendsubscription;
1103 if ($dateendsubscription !=
'' && ($dateendmember ==
'' || $dateendsubscription > $dateendmember)) {
1104 $dateendmember = $dateendsubscription;
1109 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
1110 $sql .=
" datefin=".($dateendmember !=
'' ?
"'".$this->db->idate($dateendmember).
"'" :
"null");
1111 $sql .=
" WHERE rowid = ".((int) $this->
id);
1113 dol_syslog(get_class($this).
"::update_end_date", LOG_DEBUG);
1114 $resql = $this->db->query($sql);
1116 $this->last_subscription_date = $dateop;
1117 $this->last_subscription_date_start = $datedeb;
1118 $this->last_subscription_date_end = $datefin;
1119 $this->datefin = $dateendmember;
1120 $this->db->commit();
1123 $this->db->rollback();
1127 $this->error = $this->db->lasterror();
1128 $this->db->rollback();
1140 public function delete($user, $notrigger = 0)
1153 $result = $this->call_trigger(
'MEMBER_DELETE', $user);
1161 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"categorie_member WHERE fk_member = ".((int) $rowid);
1162 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1163 $resql = $this->db->query($sql);
1166 $this->error .= $this->db->lasterror();
1172 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"subscription WHERE fk_adherent = ".((int) $rowid);
1173 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1174 $resql = $this->db->query($sql);
1177 $this->error .= $this->db->lasterror();
1187 $this->error .= $this->db->lasterror();
1198 dol_syslog(get_class($this).
"::delete erreur ".$errorflag.
" ".$this->error, LOG_ERR);
1204 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"adherent WHERE rowid = ".((int) $rowid);
1205 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
1206 $resql = $this->db->query($sql);
1209 $this->error .= $this->db->lasterror();
1215 $this->db->commit();
1218 $this->db->rollback();
1235 global $conf, $langs, $hookmanager, $user, $action;
1238 $member_origin =
new Adherent($this->db);
1240 dol_syslog(
"mergeMembers merge member id=".$member_origin_id.
" (will be deleted) into the member id=".$this->id);
1241 if ($member_origin->fetch($member_origin_id) < 1) {
1242 $this->error = $langs->trans(
'ErrorRecordNotFound');
1248 $listofproperties = array(
1249 'ref_ext',
'civility',
'lastname',
'firstname',
'morphy',
'societe',
'socid',
'user_id',
'address',
1250 'zip',
'town',
'state_id',
'country',
'phone',
'phone_perso',
'phone_mobile',
'email',
1251 'url',
'socialnetworks',
'birth',
'gender',
'photo',
'public',
'datefin',
'default_lang',
1252 'canvas',
'model_pdf',
'import_key'
1254 foreach ($listofproperties as $property) {
1255 if (empty($this->$property)) {
1256 $this->$property = $member_origin->$property;
1261 $listofproperties = array(
1262 'note_public',
'note_private'
1264 foreach ($listofproperties as $property) {
1265 $this->$property =
dol_concatdesc($this->$property, $member_origin->$property);
1269 if (is_array($member_origin->array_options)) {
1270 foreach ($member_origin->array_options as $key => $val) {
1271 if (empty($this->array_options[$key])) {
1272 $this->array_options[$key] = $val;
1278 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1280 $custcats_ori = $static_cat->containing($member_origin->id,
'member',
'id');
1281 $custcats = $static_cat->containing($this->
id,
'member',
'id');
1282 $custcats = array_merge($custcats, $custcats_ori);
1285 $result = $this->
update($user, 1, 1, 1, 1,
'merge');
1291 if (!$error && $member_origin->fetch_subscriptions() < 1) {
1296 foreach ($member_origin->subscriptions as $key => $subscription) {
1297 $subscription->fk_adherent = $this->id;
1298 $result = $subscription->update($user);
1308 $parameters = array(
'member_origin' => $member_origin->id,
'member_dest' => $this->id);
1309 $reshook = $hookmanager->executeHooks(
'replaceMember', $parameters, $this, $action);
1318 $this->context = array(
'merge' => 1,
'mergefromid' => $member_origin->id);
1321 $result = $this->call_trigger(
'MEMBER_MODIFY', $user);
1330 if ($member_origin->delete($user) < 1) {
1338 if (!empty($conf->adherent->multidir_output[$this->entity])) {
1339 $srcdir = $conf->adherent->multidir_output[$this->entity].
"/".$member_origin->id;
1340 $destdir = $conf->adherent->multidir_output[$this->entity].
"/".$this->id;
1344 foreach ($dirlist as $filetomove) {
1345 $destfile = $destdir.
'/'.$filetomove[
'relativename'];
1346 $result =
dol_move($filetomove[
'fullname'], $destfile,
'0', 0, 0, 1);
1356 $this->db->commit();
1359 $langs->load(
"errors");
1360 $this->error = $langs->trans(
'ErrorMembersMerge');
1361 $this->db->rollback();
1378 public function setPassword($user, $password =
'', $isencrypted = 0, $notrigger = 0, $nosyncuser = 0)
1380 global $conf, $langs;
1384 dol_syslog(get_class($this).
"::setPassword user=".$user->id.
" password=".preg_replace(
'/./i',
'*', $password).
" isencrypted=".$isencrypted);
1388 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
1393 $password_crypted =
dol_hash($password);
1395 $password_indatabase =
'';
1396 if (!$isencrypted) {
1397 $password_indatabase = $password;
1403 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent";
1404 $sql .=
" SET pass_crypted = '".$this->db->escape($password_crypted).
"'";
1406 $sql .=
", pass = null";
1408 $sql .=
", pass = '".$this->db->escape($password_indatabase).
"'";
1410 $sql .=
" WHERE rowid = ".((int) $this->
id);
1413 dol_syslog(get_class($this).
"::setPassword", LOG_DEBUG);
1414 $result = $this->db->query($sql);
1416 $nbaffectedrows = $this->db->affected_rows($result);
1418 if ($nbaffectedrows) {
1419 $this->pass = $password;
1420 $this->pass_indatabase = $password_indatabase;
1421 $this->pass_indatabase_crypted = $password_crypted;
1423 if ($this->user_id && !$nosyncuser) {
1424 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
1428 $luser =
new User($this->db);
1429 $result = $luser->fetch($this->user_id);
1432 $result = $luser->setPassword($user, $this->pass, 0, 0, 1);
1433 if (is_int($result) && $result < 0) {
1434 $this->error = $luser->error;
1435 dol_syslog(get_class($this).
"::setPassword ".$this->error, LOG_ERR);
1439 $this->error = $luser->error;
1444 if (!$error && !$notrigger) {
1446 $result = $this->call_trigger(
'MEMBER_NEW_PASSWORD', $user);
1449 $this->db->rollback();
1455 $this->db->commit();
1458 $this->db->rollback();
1462 $this->db->rollback();
1477 global $conf, $langs;
1482 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = NULL WHERE fk_member = ".((int) $this->
id);
1483 dol_syslog(get_class($this).
"::setUserId", LOG_DEBUG);
1484 $resql = $this->db->query($sql);
1486 $this->error = $this->db->error();
1487 $this->db->rollback();
1493 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"user SET fk_member = ".((int) $this->
id);
1494 $sql .=
" WHERE rowid = ".((int) $userid);
1495 dol_syslog(get_class($this).
"::setUserId", LOG_DEBUG);
1496 $resql = $this->db->query($sql);
1498 $this->error = $this->db->error();
1499 $this->db->rollback();
1504 $this->db->commit();
1518 global $conf, $langs;
1523 if ($thirdpartyid > 0) {
1524 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET fk_soc = null";
1525 $sql .=
" WHERE fk_soc = ".((int) $thirdpartyid);
1526 $sql .=
" AND entity = ".$conf->entity;
1527 dol_syslog(get_class($this).
"::setThirdPartyId", LOG_DEBUG);
1528 $resql = $this->db->query($sql);
1532 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET fk_soc = ".($thirdpartyid > 0 ? (int) $thirdpartyid :
'null');
1533 $sql .=
" WHERE rowid = ".((int) $this->
id);
1535 dol_syslog(get_class($this).
"::setThirdPartyId", LOG_DEBUG);
1536 $resql = $this->db->query($sql);
1538 $this->db->commit();
1541 $this->error = $this->db->error();
1542 $this->db->rollback();
1560 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"adherent";
1561 $sql .=
" WHERE login='".$this->db->escape($login).
"'";
1562 $sql .=
" AND entity = ".$conf->entity;
1564 $resql = $this->db->query($sql);
1566 if ($this->db->num_rows($resql)) {
1567 $obj = $this->db->fetch_object($resql);
1568 $this->
fetch($obj->rowid);
1588 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"adherent";
1589 $sql .=
" WHERE firstname='".$this->db->escape($firstname).
"'";
1590 $sql .=
" AND lastname='".$this->db->escape($lastname).
"'";
1591 $sql .=
" AND entity = ".$conf->entity;
1593 $resql = $this->db->query($sql);
1595 if ($this->db->num_rows($resql)) {
1596 $obj = $this->db->fetch_object($resql);
1597 $this->
fetch($obj->rowid);
1615 public function fetch($rowid, $ref =
'', $socid = 0, $ref_ext =
'', $fetch_optionals =
true, $fetch_subscriptions =
true)
1619 $sql =
"SELECT d.rowid, d.ref, d.ref_ext, d.civility as civility_code, d.gender, d.firstname, d.lastname,";
1620 $sql .=
" d.societe as company, d.fk_soc as socid, d.statut, d.public, d.address, d.zip, d.town, d.note_private,";
1621 $sql .=
" d.note_public,";
1622 $sql .=
" d.email, d.url, d.socialnetworks, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass, d.pass_crypted,";
1623 $sql .=
" d.photo, d.fk_adherent_type, d.morphy, d.entity,";
1624 $sql .=
" d.datec as datec,";
1625 $sql .=
" GREATEST(d.tms, COALESCE(aef.tms, d.tms)) as datem,";
1626 $sql .=
" d.datefin as datefin, d.default_lang,";
1627 $sql .=
" d.birth as birthday,";
1628 $sql .=
" d.datevalid as datev,";
1629 $sql .=
" d.country,";
1630 $sql .=
" d.state_id,";
1631 $sql .=
" d.model_pdf,";
1632 $sql .=
" c.rowid as country_id, c.code as country_code, c.label as country,";
1633 $sql .=
" dep.nom as state, dep.code_departement as state_code,";
1634 $sql .=
" t.libelle as type, t.subscription as subscription,";
1635 $sql .=
" u.rowid as user_id, u.login as user_login";
1636 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent_type as t, ".MAIN_DB_PREFIX.
"adherent as d";
1637 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'adherent_extrafields as aef ON aef.fk_object = d.rowid';
1638 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as c ON d.country = c.rowid";
1639 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as dep ON d.state_id = dep.rowid";
1640 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON d.rowid = u.fk_member";
1641 $sql .=
" WHERE d.fk_adherent_type = t.rowid";
1643 $sql .=
" AND d.rowid=".((int) $rowid);
1644 } elseif ($ref || $socid) {
1645 $sql .=
" AND d.entity IN (".getEntity(
'adherent').
")";
1647 $sql .=
" AND d.ref='".$this->db->escape($ref).
"'";
1648 } elseif ($socid > 0) {
1649 $sql .=
" AND d.fk_soc=".((int) $socid);
1651 } elseif ($ref_ext) {
1652 $sql .=
" AND d.ref_ext='".$this->db->escape($ref_ext).
"'";
1655 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
1656 $resql = $this->db->query($sql);
1658 if ($this->db->num_rows($resql)) {
1659 $obj = $this->db->fetch_object($resql);
1661 $this->entity = $obj->entity;
1662 $this->
id = $obj->rowid;
1663 $this->
ref = $obj->ref;
1664 $this->ref_ext = $obj->ref_ext;
1666 $this->civility_id = $obj->civility_code;
1667 $this->civility_code = $obj->civility_code;
1668 $this->civility = $obj->civility_code ? ($langs->trans(
"Civility".$obj->civility_code) !=
"Civility".$obj->civility_code ? $langs->trans(
"Civility".$obj->civility_code) : $obj->civility_code) :
'';
1670 $this->firstname = $obj->firstname;
1671 $this->lastname = $obj->lastname;
1672 $this->gender = $obj->gender;
1673 $this->login = $obj->login;
1674 $this->societe = $obj->company;
1675 $this->company = $obj->company;
1676 $this->socid = $obj->socid;
1677 $this->fk_soc = $obj->socid;
1678 $this->
address = $obj->address;
1679 $this->zip = $obj->zip;
1680 $this->town = $obj->town;
1682 $this->pass = $obj->pass;
1683 $this->pass_indatabase = $obj->pass;
1684 $this->pass_indatabase_crypted = $obj->pass_crypted;
1686 $this->state_id = $obj->state_id;
1687 $this->state_code = $obj->state_id ? $obj->state_code :
'';
1688 $this->state = $obj->state_id ? $obj->state :
'';
1690 $this->country_id = $obj->country_id;
1691 $this->country_code = $obj->country_code;
1692 if ($langs->trans(
"Country".$obj->country_code) !=
"Country".$obj->country_code) {
1693 $this->country = $langs->transnoentitiesnoconv(
"Country".$obj->country_code);
1695 $this->country = $obj->country;
1698 $this->phone = $obj->phone;
1699 $this->phone_perso = $obj->phone_perso;
1700 $this->phone_mobile = $obj->phone_mobile;
1701 $this->email = $obj->email;
1702 $this->url = $obj->url;
1704 $this->socialnetworks = ($obj->socialnetworks ? (array) json_decode($obj->socialnetworks,
true) : array());
1706 $this->photo = $obj->photo;
1707 $this->statut = $obj->statut;
1708 $this->
status = $obj->statut;
1709 $this->
public = $obj->public;
1711 $this->datec = $this->db->jdate($obj->datec);
1712 $this->date_creation = $this->db->jdate($obj->datec);
1713 $this->datem = $this->db->jdate($obj->datem);
1714 $this->date_modification = $this->db->jdate($obj->datem);
1715 $this->datefin = $this->db->jdate($obj->datefin);
1716 $this->datevalid = $this->db->jdate($obj->datev);
1717 $this->date_validation = $this->db->jdate($obj->datev);
1718 $this->birth = $this->db->jdate($obj->birthday);
1720 $this->default_lang = $obj->default_lang;
1722 $this->note_private = $obj->note_private;
1723 $this->note_public = $obj->note_public;
1724 $this->morphy = $obj->morphy;
1726 $this->
typeid = $obj->fk_adherent_type;
1727 $this->
type = $obj->type;
1728 $this->need_subscription = $obj->subscription;
1730 $this->user_id = $obj->user_id;
1731 $this->user_login = $obj->user_login;
1733 $this->model_pdf = $obj->model_pdf;
1737 if ($fetch_optionals) {
1742 if ($fetch_subscriptions) {
1751 $this->error = $this->db->lasterror();
1769 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
1771 $sql =
"SELECT c.rowid, c.fk_adherent, c.fk_type, c.subscription, c.note as note_public, c.fk_bank,";
1772 $sql .=
" c.tms as datem,";
1773 $sql .=
" c.datec as datec,";
1774 $sql .=
" c.dateadh as dateh,";
1775 $sql .=
" c.datef as datef";
1776 $sql .=
" FROM ".MAIN_DB_PREFIX.
"subscription as c";
1777 $sql .=
" WHERE c.fk_adherent = ".((int) $this->
id);
1778 $sql .=
" ORDER BY c.dateadh";
1779 dol_syslog(get_class($this).
"::fetch_subscriptions", LOG_DEBUG);
1781 $resql = $this->db->query($sql);
1783 $this->subscriptions = array();
1786 while ($obj = $this->db->fetch_object($resql)) {
1788 $this->first_subscription_date = $this->db->jdate($obj->datec);
1789 $this->first_subscription_date_start = $this->db->jdate($obj->dateh);
1790 $this->first_subscription_date_end = $this->db->jdate($obj->datef);
1791 $this->first_subscription_amount = $obj->subscription;
1793 $this->last_subscription_date = $this->db->jdate($obj->datec);
1794 $this->last_subscription_date_start = $this->db->jdate($obj->dateh);
1795 $this->last_subscription_date_end = $this->db->jdate($obj->datef);
1796 $this->last_subscription_amount = (float) $obj->subscription;
1799 $subscription->id = $obj->rowid;
1800 $subscription->fk_adherent = $obj->fk_adherent;
1801 $subscription->fk_type = $obj->fk_type;
1802 $subscription->amount = (float) $obj->subscription;
1803 $subscription->note = $obj->note_public;
1804 $subscription->note_public = $obj->note_public;
1805 $subscription->fk_bank = $obj->fk_bank;
1806 $subscription->datem = $this->db->jdate($obj->datem);
1807 $subscription->datec = $this->db->jdate($obj->datec);
1808 $subscription->dateh = $this->db->jdate($obj->dateh);
1809 $subscription->datef = $this->db->jdate($obj->datef);
1811 $this->subscriptions[] = $subscription;
1817 $this->error = $this->db->error().
' sql='.$sql;
1831 require_once DOL_DOCUMENT_ROOT.
'/partnership/class/partnership.class.php';
1834 $this->partnerships[] = array();
1856 public function subscription($date, $amount, $accountid = 0, $operation =
'', $label =
'', $num_chq =
'', $emetteur_nom =
'', $emetteur_banque =
'', $datesubend = 0, $fk_type =
null, $ref_ext =
'')
1860 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
1872 $datefin = $datesubend;
1881 $subscription->fk_adherent = $this->id;
1882 $subscription->dateh = $date;
1883 $subscription->datef = $datefin;
1884 $subscription->amount = $amount;
1885 $subscription->note_public = $label;
1886 $subscription->note_private =
'';
1887 $subscription->fk_type = $fk_type;
1888 $subscription->ref_ext = $ref_ext;
1890 if (empty($subscription->user_creation_id)) {
1891 $subscription->user_creation_id = $user->id;
1894 $rowid = $subscription->create($user);
1901 $this->last_subscription_date =
dol_now();
1902 $this->last_subscription_date_start = $date;
1903 $this->last_subscription_date_end = $datefin;
1904 $this->last_subscription_amount = $amount;
1910 $this->db->commit();
1913 $this->db->rollback();
1918 $this->db->rollback();
1943 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 =
'')
1945 global $conf, $langs, $user,
$mysoc;
1949 $this->invoice =
null;
1951 dol_syslog(
"subscriptionComplementaryActions subscriptionid=".$subscriptionid.
" option=".$option.
" accountid=".$accountid.
" datesubscription=".$datesubscription.
" paymentdate=".
1952 $paymentdate.
" label=".$label.
" amount=".$amount.
" num_chq=".$num_chq.
" autocreatethirdparty=".$autocreatethirdparty);
1955 if ($option ==
'bankdirect' && $accountid) {
1956 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
1958 $acct =
new Account($this->db);
1959 $result = $acct->fetch($accountid);
1961 $dateop = $paymentdate;
1963 $insertid = $acct->addline($dateop, $operation, $label, $amount, $num_chq, 0, $user, $emetteur_nom, $emetteur_banque);
1964 if ($insertid > 0) {
1965 $inserturlid = $acct->add_url_line($insertid, $this->
id, DOL_URL_ROOT.
'/adherents/card.php?rowid=', $this->getFullName($langs),
'member');
1966 if ($inserturlid > 0) {
1968 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"subscription SET fk_bank=".((int) $insertid);
1969 $sql .=
" WHERE rowid=".((int) $subscriptionid);
1971 dol_syslog(
"subscription::subscription", LOG_DEBUG);
1972 $resql = $this->db->query($sql);
1975 $this->error = $this->db->lasterror();
1976 $this->errors[] = $this->error;
1989 if (($option ==
'bankviainvoice' && $accountid) || $option ==
'invoiceonly') {
1990 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1991 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/paymentterm.class.php';
1993 $invoice =
new Facture($this->db);
1994 $customer =
new Societe($this->db);
1997 if (!($this->socid > 0)) {
1998 if ($autocreatethirdparty) {
2003 if ($this->morphy ==
'mor') {
2004 $companyname = $this->company;
2005 if (!empty($fullname)) {
2006 $companyalias = $fullname;
2009 $companyname = $fullname;
2010 if (!empty($this->company)) {
2011 $companyalias = $this->company;
2015 $result = $customer->create_from_member($this, (
string) $companyname, $companyalias);
2017 $this->error = $customer->error;
2018 $this->errors = $customer->errors;
2021 $this->fk_soc = $result;
2022 $this->socid = $result;
2025 $langs->load(
"errors");
2026 $this->error = $langs->trans(
"ErrorMemberNotLinkedToAThirpartyLinkOrCreateFirst");
2027 $this->errors[] = $this->error;
2033 $result = $customer->fetch($this->socid);
2035 $this->error = $customer->error;
2036 $this->errors = $customer->errors;
2044 $invoice->cond_reglement_id = $customer->cond_reglement_id;
2045 if (empty($invoice->cond_reglement_id)) {
2047 $invoice->cond_reglement_id = $paymenttermstatic->getDefaultId();
2048 if (empty($invoice->cond_reglement_id)) {
2050 $this->error =
'ErrorNoPaymentTermRECEPFound';
2051 $this->errors[] = $this->error;
2054 $invoice->socid = $this->socid;
2056 if (!empty($customer->fk_account)) {
2057 $invoice->fk_account = $customer->fk_account;
2063 if (!empty($customer->mode_reglement_id)) {
2064 $invoice->mode_reglement_id = $customer->mode_reglement_id;
2070 $invoice->linked_objects[
'subscription'] = $subscriptionid;
2072 $invoice->linked_objects = array_merge($invoice->linked_objects,
GETPOST(
'other_linked_objects',
'array:int'));
2075 $result = $invoice->create($user);
2080 $this->invoice = $invoice;
2086 $idprodsubscription = 0;
2092 if (
getDolGlobalString(
'ADHERENT_VAT_FOR_SUBSCRIPTIONS') ==
'defaultforfoundationcountry') {
2097 $result = $invoice->addline($label, 0, 1, $vattouse, 0, 0, $idprodsubscription, 0, $datesubscription,
'', 0, 0, 0,
'TTC', $amount, 1);
2106 $result = $invoice->validate($user);
2118 if (!$error && $option ==
'bankviainvoice' && $accountid) {
2119 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
2120 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
2121 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions.lib.php';
2124 $amounts[$invoice->id] = (float)
price2num($amount);
2126 $paiement =
new Paiement($this->db);
2127 $paiement->datepaye = $paymentdate;
2128 $paiement->amounts = $amounts;
2129 $paiement->paiementcode = $operation;
2130 $paiement->paiementid =
dol_getIdFromCode($this->db, $operation,
'c_paiement',
'code',
'id', 1);
2131 $paiement->num_payment = $num_chq;
2132 $paiement->note_public = $label;
2133 $paiement->ext_payment_id = $ext_payment_id;
2134 $paiement->ext_payment_site = $ext_payment_site;
2137 $paiement_id = $paiement->create($user);
2138 if (!($paiement_id > 0)) {
2145 $bank_line_id = $paiement->addPaymentToBank($user,
'payment',
'(SubscriptionPayment)', $accountid, $emetteur_nom, $emetteur_banque);
2146 if (!($bank_line_id > 0)) {
2152 if (!$error && !empty($bank_line_id)) {
2154 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'subscription SET fk_bank='.((int) $bank_line_id);
2155 $sql .=
' WHERE rowid='.((int) $subscriptionid);
2157 $result = $this->db->query($sql);
2165 $invoice->setPaid($user);
2171 $outputlangs = $langs;
2173 $lang_id =
GETPOST(
'lang_id');
2174 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && !empty($lang_id)) {
2175 $newlang = $lang_id;
2178 $newlang = $customer->default_lang;
2180 if (!empty($newlang)) {
2181 $outputlangs =
new Translate(
"", $conf);
2182 $outputlangs->setDefaultLang($newlang);
2187 $invoice->fetch($invoice->id);
2188 $invoice->generateDocument($invoice->model_pdf, $outputlangs);
2208 global $langs, $conf;
2214 if ($this->statut == self::STATUS_VALIDATED) {
2215 dol_syslog(get_class($this).
"::validate statut of member does not allow this", LOG_WARNING);
2221 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
2222 $sql .=
" statut = ".self::STATUS_VALIDATED;
2223 $sql .=
", datevalid = '".$this->db->idate($now).
"'";
2224 $sql .=
", fk_user_valid = ".((int) $user->id);
2225 $sql .=
" WHERE rowid = ".((int) $this->
id);
2227 dol_syslog(get_class($this).
"::validate", LOG_DEBUG);
2228 $result = $this->db->query($sql);
2233 $result = $this->call_trigger(
'MEMBER_VALIDATE', $user);
2236 $this->db->rollback();
2241 $this->datevalid = $now;
2243 $this->db->commit();
2246 $this->error = $this->db->error();
2247 $this->db->rollback();
2261 global $langs, $conf;
2266 if ($this->statut == self::STATUS_RESILIATED) {
2267 dol_syslog(get_class($this).
"::resiliate statut of member does not allow this", LOG_WARNING);
2273 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
2274 $sql .=
" statut = ".((int) self::STATUS_RESILIATED);
2275 $sql .=
", fk_user_valid = ".((int) $user->id);
2276 $sql .=
" WHERE rowid = ".((int) $this->
id);
2278 $result = $this->db->query($sql);
2283 $result = $this->call_trigger(
'MEMBER_RESILIATE', $user);
2286 $this->db->rollback();
2291 $this->db->commit();
2294 $this->error = $this->db->error();
2295 $this->db->rollback();
2314 if ($this->statut == self::STATUS_EXCLUDED) {
2315 dol_syslog(get_class($this).
"::resiliate statut of member does not allow this", LOG_WARNING);
2321 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
2322 $sql .=
" statut = ".((int) self::STATUS_EXCLUDED);
2323 $sql .=
", fk_user_valid = ".((int) $user->id);
2324 $sql .=
" WHERE rowid = ".((int) $this->
id);
2326 $result = $this->db->query($sql);
2331 $result = $this->call_trigger(
'MEMBER_EXCLUDE', $user);
2334 $this->db->rollback();
2339 $this->db->commit();
2342 $this->error = $this->db->error();
2343 $this->db->rollback();
2359 include_once DOL_DOCUMENT_ROOT.
'/mailmanspip/class/mailmanspip.class.php';
2366 $result = $mailmanspip->add_to_mailman($this);
2369 if (!empty($mailmanspip->error)) {
2370 $this->errors[] = $mailmanspip->error;
2374 foreach ($mailmanspip->mladded_ko as $tmplist => $tmpemail) {
2375 $langs->load(
"errors");
2376 $this->errors[] = $langs->trans(
"ErrorFailedToAddToMailmanList", $tmpemail, $tmplist);
2378 foreach ($mailmanspip->mladded_ok as $tmplist => $tmpemail) {
2379 $langs->load(
"mailmanspip");
2380 $this->mesgs[] = $langs->trans(
"SuccessToAddToMailmanList", $tmpemail, $tmplist);
2386 $result = $mailmanspip->add_to_spip($this);
2388 $this->errors[] = $mailmanspip->error;
2409 global $conf, $langs;
2411 include_once DOL_DOCUMENT_ROOT.
'/mailmanspip/class/mailmanspip.class.php';
2418 $result = $mailmanspip->del_to_mailman($this);
2420 if (!empty($mailmanspip->error)) {
2421 $this->errors[] = $mailmanspip->error;
2426 foreach ($mailmanspip->mlremoved_ko as $tmplist => $tmpemail) {
2427 $langs->load(
"errors");
2428 $this->errors[] = $langs->trans(
"ErrorFailedToRemoveToMailmanList", $tmpemail, $tmplist);
2430 foreach ($mailmanspip->mlremoved_ok as $tmplist => $tmpemail) {
2431 $langs->load(
"mailmanspip");
2432 $this->mesgs[] = $langs->trans(
"SuccessToRemoveToMailmanList", $tmpemail, $tmplist);
2437 $result = $mailmanspip->del_to_spip($this);
2439 $this->errors[] = $mailmanspip->error;
2460 $langs->load(
"dict");
2462 $code = (empty($this->civility_id) ?
'' : $this->civility_id);
2466 return $langs->getLabelFromKey($this->db,
"Civility".$code,
"c_civility",
"code",
"label", $code);
2479 $langs->loadLangs([
'members',
'companies']);
2480 $nofetch = !empty($params[
'nofetch']);
2485 $langs->load(
"users");
2486 return [
'optimize' => $langs->trans(
"ShowUser")];
2488 if (!empty($this->photo)) {
2489 $photo =
'<div class="photointooltip floatright">';
2490 $photo .=
Form::showphoto(
'memberphoto', $this, 80, 0, 0,
'photoref photowithmargin photologintooltip',
'small', 0, 1);
2492 $datas[
'photo'] = $photo;
2495 $datas[
'divopen'] =
'<div class="centpercent">';
2496 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <u class="paddingrightonly">'.$langs->trans(
"Member").
'</u> '.$this->
getLibStatut(4);
2497 if (!empty($this->morphy)) {
2498 $datas[
'picto'] .=
' ' . $this->
getmorphylib(
'', 1);
2500 if (!empty($this->
ref)) {
2501 $datas[
'ref'] =
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
2503 if (!empty($this->login)) {
2504 $datas[
'login'] =
'<br><b>'.$langs->trans(
'Login').
':</b> '.$this->login;
2506 if (!empty($this->firstname) || !empty($this->lastname)) {
2507 $datas[
'name'] =
'<br><b>'.$langs->trans(
'Name').
':</b> '.$this->
getFullName($langs);
2509 if (!empty($this->company)) {
2510 $datas[
'company'] =
'<br><b>'.$langs->trans(
'Company').
':</b> '.$this->company;
2512 if (!empty($this->email)) {
2513 $datas[
'email'] =
'<br><b>'.$langs->trans(
"EMail").
':</b> '.$this->email;
2515 $datas[
'address'] =
'<br><b>'.$langs->trans(
"Address").
':</b> '.
dol_format_address($this, 1,
' ', $langs);
2518 require_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
2519 $form =
new Form($this->db);
2520 $datas[
'categories'] =
'<br>' . $form->showCategories($this->
id, Categorie::TYPE_MEMBER, 1);
2522 $datas[
'divclose'] =
'</div>';
2540 public function getNomUrl($withpictoimg = 0, $maxlen = 0, $option =
'card', $mode =
'', $morecss =
'', $save_lastsearch_value = -1, $notooltip = 0, $addlinktonotes = 0)
2542 global $conf, $langs, $hookmanager;
2551 $classfortooltip =
'classfortooltip';
2555 'objecttype' => $this->element,
2556 'option' => $option,
2560 $classfortooltip =
'classforajaxtooltip';
2561 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
2567 $baseurl = DOL_URL_ROOT .
'/adherents/card.php';
2568 if ($option ==
'subscription') {
2569 $baseurl = DOL_URL_ROOT .
'/adherents/subscription.php';
2571 $query = [
'rowid' => $this->id];
2573 if ($option !=
'nolink') {
2575 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
2576 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
2577 $add_save_lastsearch_values = 1;
2579 if ($add_save_lastsearch_values) {
2580 $query = array_merge($query, [
'save_lastsearch_values' => 1]);
2585 $linkstart .=
'<a href="'.$url.
'"';
2587 if (empty($notooltip)) {
2589 $langs->load(
"users");
2590 $label = $langs->trans(
"ShowUser");
2591 $linkclose .=
' alt="'.dolPrintHTMLForAttribute($label).
'"';
2593 $linkclose .= ($label ?
' title="'.dolPrintHTMLForAttribute($label).
'"' :
' title="tocomplete"');
2594 $linkclose .= $dataparams.
' class="'.$classfortooltip.($morecss ?
' '.$morecss :
'').
'"';
2597 $linkstart .= $linkclose.
'>';
2600 $result .= $linkstart;
2602 if ($withpictoimg) {
2603 if (abs($withpictoimg) == 1 || abs($withpictoimg) == 4) {
2604 $morecss .=
' paddingrightonly';
2607 if ($withpictoimg > 0) {
2608 $picto =
'<span class="nopadding'.($morecss ?
' userimg'.$morecss :
'').
'">'.
img_object(
'',
'user',
' '.($notooltip ?
'' : $dataparams), 0, 0, $notooltip ? 0 : 1).
'</span>';
2611 $picto =
'<span class="nopadding'.($morecss ?
' userimg'.$morecss :
'').
'">';
2612 $picto .=
Form::showphoto(
'memberphoto', $this, 0, 0, 0,
'userphoto'.(($withpictoimg == -3 || $withpictoimg == -4) ?
'small' :
''),
'mini', 0, 1);
2613 $picto .=
'</span>';
2617 if (($withpictoimg > -2 && $withpictoimg != 2) || $withpictoimg == -4) {
2619 $result .=
'<span class="nopadding valignmiddle'.((!isset($this->
status) || $this->status) ?
'' :
' strikefordisabled').
2620 ($morecss ?
' usertext'.$morecss :
'').
'">';
2622 if ($mode ==
'login') {
2623 $result .=
dol_trunc(isset($this->login) ? $this->login :
'', $maxlen);
2624 } elseif ($mode ==
'ref') {
2625 $result .= $this->ref;
2627 $result .= $this->
getFullName($langs, 0, ($mode ==
'firstname' ? 2 : ($mode ==
'lastname' ? 4 : -1)), $maxlen);
2630 $result .=
'</span>';
2634 $result .= $linkend;
2636 if ($addlinktonotes) {
2637 if ($this->note_private) {
2638 $notetoshow = $langs->trans(
"ViewPrivateNote").
':<br>'.
dol_string_nohtmltag($this->note_private, 1);
2639 $result .=
' <span class="note inline-block">';
2640 $result .=
'<a href="'.DOL_URL_ROOT.
'/adherents/note.php?id='.$this->
id.
'" class="classfortooltip" title="'.
dol_escape_htmltag($notetoshow).
'">';
2643 $result .=
'</span>';
2647 $hookmanager->initHooks(array($this->element .
'dao'));
2648 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
2649 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
2651 $result = $hookmanager->resPrint;
2653 $result .= $hookmanager->resPrint;
2666 return $this->
LibStatut($this->
status, $this->need_subscription, $this->datefin, $mode);
2679 public function LibStatut($status, $need_subscription, $date_end_subscription, $mode = 0)
2683 $langs->load(
"members");
2687 $labelStatusShort =
'';
2689 if ($status == self::STATUS_DRAFT) {
2690 $statusType =
'status0';
2691 $labelStatus = $langs->trans(
"MemberStatusDraft");
2692 $labelStatusShort = $langs->trans(
"MemberStatusDraftShort");
2693 } elseif ($status >= self::STATUS_VALIDATED) {
2694 if (empty($need_subscription)) {
2695 $statusType =
'status4';
2696 $labelStatus = $langs->trans(
"Validated").
' - '.$langs->trans(
"SubscriptionNotNeeded");
2697 $labelStatusShort = $langs->trans(
"MemberStatusNoSubscriptionShort");
2698 } elseif (!$date_end_subscription) {
2699 $statusType =
'status1';
2700 $labelStatus = $langs->trans(
"Validated").
' - '.$langs->trans(
"WaitingSubscription");
2701 $labelStatusShort = $langs->trans(
"WaitingSubscriptionShort");
2702 } elseif ($date_end_subscription <
dol_now()) {
2703 $statusType =
'status2';
2704 $labelStatus = $langs->trans(
"Validated").
' - '.$langs->trans(
"MemberStatusActiveLate");
2705 $labelStatusShort = $langs->trans(
"MemberStatusActiveLateShort");
2707 $statusType =
'status4';
2708 $labelStatus = $langs->trans(
"Validated").
' - '.$langs->trans(
"MemberStatusPaid");
2709 $labelStatusShort = $langs->trans(
"MemberStatusPaidShort");
2711 } elseif ($status == self::STATUS_RESILIATED) {
2712 $statusType =
'status6';
2713 $labelStatus = $langs->transnoentitiesnoconv(
"MemberStatusResiliated");
2714 $labelStatusShort = $langs->transnoentitiesnoconv(
"MemberStatusResiliatedShort");
2715 } elseif ($status == self::STATUS_EXCLUDED) {
2716 $statusType =
'status10';
2717 $labelStatus = $langs->transnoentitiesnoconv(
"MemberStatusExcluded");
2718 $labelStatusShort = $langs->transnoentitiesnoconv(
"MemberStatusExcludedShort");
2721 return dolGetStatus($labelStatus, $labelStatusShort,
'', $statusType, $mode);
2734 $this->nb = array();
2736 $sql =
"SELECT count(a.rowid) as nb";
2737 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as a";
2738 $sql .=
" WHERE a.statut > 0";
2739 $sql .=
" AND a.entity IN (".getEntity(
'adherent').
")";
2741 $resql = $this->db->query($sql);
2743 while ($obj = $this->db->fetch_object($resql)) {
2744 $this->nb[
"members"] = $obj->nb;
2746 $this->db->free($resql);
2750 $this->error = $this->db->error();
2766 global $conf, $langs;
2774 $sql =
"SELECT a.rowid, a.datefin, a.statut as status";
2775 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as a";
2776 $sql .=
", ".MAIN_DB_PREFIX.
"adherent_type as t";
2777 $sql .=
" WHERE a.fk_adherent_type = t.rowid";
2778 if ($mode ==
'expired') {
2779 $sql .=
" AND a.statut = ".self::STATUS_VALIDATED;
2780 $sql .=
" AND a.entity IN (".getEntity(
'adherent').
")";
2781 $sql .=
" AND ((a.datefin IS NULL or a.datefin < '".$this->db->idate($now).
"') AND t.subscription = '1')";
2782 } elseif ($mode ==
'shift') {
2783 $sql .=
" AND a.statut = ".self::STATUS_DRAFT;
2784 $sql .=
" AND a.entity IN (".getEntity(
'adherent').
")";
2787 $resql = $this->db->query($sql);
2789 $langs->load(
"members");
2796 if ($mode ==
'expired') {
2797 $warning_delay =
getWarningDelay(
'member',
'subscription') / 60 / 60 / 24;
2798 $label = $langs->trans(
"MembersWithSubscriptionToReceive");
2799 $labelShort = $langs->trans(
"MembersWithSubscriptionToReceiveShort");
2800 $url =
dolBuildUrl(DOL_URL_ROOT.
'/adherents/list.php', [
'mainmenu' =>
'members',
'statut' => self::STATUS_VALIDATED,
'filter' =>
'outofdate']);
2801 } elseif ($mode ==
'shift') {
2802 $warning_delay =
getWarningDelay(
'member',
'subscription') / 60 / 60 / 24;
2803 $url =
dolBuildUrl(DOL_URL_ROOT.
'/adherents/list.php', [
'mainmenu' =>
'members',
'statut' => self::STATUS_DRAFT]);
2804 $label = $langs->trans(
"MembersListToValid");
2805 $labelShort = $langs->trans(
"ToValidate");
2809 $response->warning_delay = $warning_delay;
2810 $response->label = $label;
2811 $response->labelShort = $labelShort;
2812 $response->url = $url;
2815 $adherentstatic =
new Adherent($this->db);
2817 while ($obj = $this->db->fetch_object($resql)) {
2818 $response->nbtodo++;
2820 $adherentstatic->datefin = $this->db->jdate($obj->datefin);
2821 $adherentstatic->statut = $obj->status;
2822 $adherentstatic->status = $obj->status;
2824 if ($adherentstatic->hasDelay()) {
2825 $response->nbtodolate++;
2832 $this->error = $this->db->error();
2849 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams =
null)
2851 global $conf, $langs;
2853 $langs->load(
"orders");
2856 $modele =
'standard';
2858 if ($this->model_pdf) {
2859 $modele = $this->model_pdf;
2865 $modelpath =
"core/modules/member/doc/";
2867 return $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
2880 global $user, $langs;
2885 $this->
ref =
'ABC001';
2887 $this->specimen = 1;
2888 $this->civility_id =
'MR';
2889 $this->lastname =
'DOLIBARR';
2890 $this->firstname =
'SPECIMEN';
2891 $this->gender =
'man';
2892 $this->login =
'dolibspec';
2893 $this->pass =
'dolibspec';
2894 $this->company =
'Societe ABC';
2895 $this->
address =
'61 jump street';
2896 $this->zip =
'75000';
2897 $this->town =
'Paris';
2898 $this->country_id = 1;
2899 $this->country_code =
'FR';
2900 $this->country =
'France';
2901 $this->morphy =
'mor';
2902 $this->email =
'specimen@specimen.com';
2903 $this->socialnetworks = array(
2904 'skype' =>
'skypepseudo',
2905 'twitter' =>
'twitterpseudo',
2906 'facebook' =>
'facebookpseudo',
2907 'linkedin' =>
'linkedinpseudo',
2909 $this->phone =
'0999999999';
2910 $this->phone_perso =
'0999999998';
2911 $this->phone_mobile =
'0999999997';
2912 $this->note_public =
'This is a public note';
2913 $this->note_private =
'This is a private note';
2914 $this->birth = $now;
2920 $this->datefin = $now;
2921 $this->datevalid = $now;
2922 $this->default_lang =
'';
2925 $this->
type =
'Type adherent';
2926 $this->need_subscription = 0;
2928 $this->first_subscription_date = $now;
2929 $this->first_subscription_date_start = $this->first_subscription_date;
2930 $this->first_subscription_date_end =
dol_time_plus_duree($this->first_subscription_date_start, 1,
'y');
2931 $this->first_subscription_amount = 10;
2933 $this->last_subscription_date = $this->first_subscription_date;
2934 $this->last_subscription_date_start = $this->first_subscription_date;
2935 $this->last_subscription_date_end =
dol_time_plus_duree($this->last_subscription_date_start, 1,
'y');
2936 $this->last_subscription_amount = 10;
2980 global $conf, $langs;
2984 $keymodified =
false;
2992 if ($this->morphy ==
'mor' && (empty($this->fullname) || $this->fullname == $this->company)) {
2993 $this->fullname = $this->company;
2994 $this->lastname = $this->company;
2999 'LDAP_MEMBER_FIELD_FULLNAME' =>
'fullname',
3000 'LDAP_MEMBER_FIELD_NAME' =>
'lastname',
3001 'LDAP_MEMBER_FIELD_LOGIN' =>
'login',
3002 'LDAP_MEMBER_FIELD_LOGIN_SAMBA' =>
'login',
3003 'LDAP_MEMBER_FIELD_MAIL' =>
'email'
3007 foreach ($ldapkey as $constname => $varname) {
3013 if (!empty($this->oldcopy) && $this->$varname != $this->oldcopy->$varname) {
3014 $keymodified =
true;
3040 foreach ($socialnetworks as $key => $value) {
3041 if ($this->socialnetworks[$value[
'label']] &&
getDolGlobalString(
'LDAP_MEMBER_FIELD_'.strtoupper($value[
'label']))) {
3042 $info[
getDolGlobalString(
'LDAP_MEMBER_FIELD_'.strtoupper($value[
'label']))] = $this->socialnetworks[$value[
'label']];
3069 if ($this->datefin &&
getDolGlobalString(
'LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION')) {
3074 if (!empty($this->pass)) {
3087 if ($this->pass_indatabase_crypted &&
getDolGlobalString(
'LDAP_MEMBER_FIELD_PASSWORD_CRYPTED')) {
3093 } elseif (!empty($this->pass_indatabase)) {
3105 if ($this->first_subscription_date &&
getDolGlobalString(
'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE')) {
3108 if (isset($this->first_subscription_amount) &&
getDolGlobalString(
'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT')) {
3109 $info[
getDolGlobalString(
'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT')] = $this->first_subscription_amount;
3111 if ($this->last_subscription_date &&
getDolGlobalString(
'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE')) {
3114 if (isset($this->last_subscription_amount) &&
getDolGlobalString(
'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT')) {
3115 $info[
getDolGlobalString(
'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT')] = $this->last_subscription_amount;
3130 $sql =
'SELECT a.rowid, a.datec as datec,';
3131 $sql .=
' a.datevalid as datev,';
3132 $sql .=
' GREATEST(a.tms, COALESCE(aef.tms, a.tms)) as datem,';
3133 $sql .=
' a.fk_user_author, a.fk_user_valid, a.fk_user_mod';
3134 $sql .=
' FROM '.MAIN_DB_PREFIX.
'adherent as a';
3135 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'adherent_extrafields as aef ON aef.fk_object = a.rowid';
3136 $sql .=
' WHERE a.rowid = '.((int) $id);
3138 dol_syslog(get_class($this).
"::info", LOG_DEBUG);
3139 $result = $this->db->query($sql);
3141 if ($this->db->num_rows($result)) {
3142 $obj = $this->db->fetch_object($result);
3144 $this->
id = $obj->rowid;
3146 $this->user_creation_id = $obj->fk_user_author;
3147 $this->user_validation_id = $obj->fk_user_valid;
3148 $this->user_modification_id = $obj->fk_user_mod;
3149 $this->date_creation = $this->db->jdate($obj->datec);
3150 $this->date_validation = $this->db->jdate($obj->datev);
3151 $this->date_modification = $this->db->jdate($obj->datem);
3154 $this->db->free($result);
3167 $sql =
"SELECT count(mc.email) as nb";
3168 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mailing_cibles as mc";
3169 $sql .=
" WHERE mc.email = '".$this->db->escape($this->email).
"'";
3170 $sql .=
" AND mc.statut NOT IN (-1,0)";
3172 $resql = $this->db->query($sql);
3174 $obj = $this->db->fetch_object($resql);
3175 $nb = (int) $obj->nb;
3177 $this->db->free($resql);
3180 $this->error = $this->db->error();
3197 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
3198 return parent::setCategoriesCommon($categories, Categorie::TYPE_MEMBER);
3211 $tables = array(
'adherent');
3226 if ($this->
status != self::STATUS_VALIDATED) {
3229 if (!$this->datefin) {
3235 return $this->datefin < ($now -
getWarningDelay(
'member',
'subscription'));
3249 global $conf, $langs,
$mysoc, $user;
3255 $blockingerrormsg =
'';
3258 $langs->load(
"agenda");
3259 $this->output = $langs->trans(
'ModuleNotEnabled', $langs->transnoentitiesnoconv(
"Adherent"));
3263 $langs->load(
"agenda");
3264 $this->output = $langs->trans(
'EventRemindersByEmailNotEnabled', $langs->transnoentitiesnoconv(
"Adherent"));
3272 $listofmembersok = array();
3273 $listofmembersko = array();
3275 $arraydaysbeforeend = explode(
';', $daysbeforeendlist);
3276 foreach ($arraydaysbeforeend as $daysbeforeend) {
3277 dol_syslog(__METHOD__.
' - Process delta = '.$daysbeforeend, LOG_DEBUG);
3279 if (!is_numeric($daysbeforeend)) {
3280 $blockingerrormsg =
"Value for delta is not a numeric value";
3286 $datetosearchfor =
dol_time_plus_duree(
dol_mktime(0, 0, 0, $tmp[
'mon'], $tmp[
'mday'], $tmp[
'year'],
'tzserver'), (
int) $daysbeforeend,
'd');
3287 $datetosearchforend =
dol_time_plus_duree(
dol_mktime(23, 59, 59, $tmp[
'mon'], $tmp[
'mday'], $tmp[
'year'],
'tzserver'), (
int) $daysbeforeend,
'd');
3289 $sql =
'SELECT rowid FROM '.MAIN_DB_PREFIX.
'adherent';
3290 $sql .=
" WHERE entity = ".((int) $conf->entity);
3291 $sql .=
" AND statut = 1";
3292 $sql .=
" AND datefin >= '".$this->db->idate($datetosearchfor).
"'";
3293 $sql .=
" AND datefin <= '".$this->db->idate($datetosearchforend).
"'";
3294 if ((
int) $fk_adherent_type > 0) {
3295 $sql .=
" AND fk_adherent_type = ".((int) $fk_adherent_type);
3299 $resql = $this->db->query($sql);
3301 $num_rows = $this->db->num_rows($resql);
3303 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
3304 $formmail =
new FormMail($this->db);
3307 while ($i < $num_rows) {
3308 $obj = $this->db->fetch_object($resql);
3312 $adherent =
new Adherent($this->db);
3313 $adherent->fetch($obj->rowid,
'', 0,
'',
true,
true);
3315 if (empty($adherent->email)) {
3317 $listofmembersko[$adherent->id] = $adherent->id;
3319 $thirdpartyres = $adherent->fetch_thirdparty();
3320 if ($thirdpartyres === -1) {
3321 $languagecodeformember =
$mysoc->default_lang;
3324 $languagefromcountrycode =
getLanguageCodeFromCountryCode($adherent->country_code ? $adherent->country_code : (is_object($adherent->thirdparty) ? $adherent->thirdparty->country_code :
''));
3325 $languagecodeformember = (empty($adherent->thirdparty->default_lang) ? ($languagefromcountrycode ? $languagefromcountrycode :
$mysoc->default_lang) : $adherent->thirdparty->default_lang);
3327 if (!empty($adherent->default_lang)) {
3329 $languagecodeformember = $adherent->default_lang;
3333 $outputlangs =
new Translate(
'', $conf);
3334 $outputlangs->setDefaultLang($languagecodeformember);
3335 $outputlangs->loadLangs(array(
"main",
"members"));
3336 dol_syslog(
"sendReminderForExpiredSubscription Language for member id ".$adherent->id.
" set to ".$outputlangs->defaultlang.
" mysoc->default_lang=".
$mysoc->default_lang);
3338 $arraydefaultmessage =
null;
3341 if (!empty($labeltouse)) {
3342 $arraydefaultmessage = $formmail->getEMailTemplate($this->db,
'member', $user, $outputlangs, 0, 1, $labeltouse);
3345 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
3346 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0,
null, $adherent);
3350 $subject =
make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs);
3351 $msg =
make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs);
3353 $to = $adherent->email;
3356 $trackid =
'mem'.$adherent->id;
3357 $moreinheader =
'X-Dolibarr-Info: sendReminderForExpiredSubscription'.
"\r\n";
3359 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
3360 $cmail =
new CMailFile($subject, $to, $from, $msg, array(), array(), array(), $cc,
'', 0, 1,
'',
'', $trackid, $moreinheader);
3361 $result = $cmail->sendfile();
3364 $this->error .= $cmail->error.
' ';
3365 if (!is_null($cmail->errors)) {
3366 $this->errors += $cmail->errors;
3369 $listofmembersko[$adherent->id] = $adherent->id;
3372 $listofmembersok[$adherent->id] = $adherent->id;
3378 $actioncode =
'EMAIL';
3379 $extraparams = array();
3389 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'MailTopic').
": ".$subject);
3390 $actionmsg =
dol_concatdesc($actionmsg, $langs->transnoentities(
'TextUsedInTheMessageBody').
":");
3394 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
3399 $actioncomm->type_code =
'AC_OTH_AUTO';
3400 $actioncomm->code =
'AC_'.$actioncode;
3401 $actioncomm->label = $actionmsg2;
3402 $actioncomm->note_private = $actionmsg;
3403 $actioncomm->fk_project = 0;
3404 $actioncomm->datep = $now;
3405 $actioncomm->datef = $now;
3406 $actioncomm->percentage = -1;
3407 $actioncomm->socid = (is_object($adherent->thirdparty) ? $adherent->thirdparty->id : 0);
3408 $actioncomm->contact_id = 0;
3409 $actioncomm->authorid = $user->id;
3410 $actioncomm->userownerid = $user->id;
3412 $actioncomm->email_msgid = $cmail->msgid;
3413 $actioncomm->email_from = $from;
3414 $actioncomm->email_sender =
'';
3415 $actioncomm->email_to = $to;
3416 $actioncomm->email_tocc = $sendtocc;
3417 $actioncomm->email_tobcc = $sendtobcc;
3418 $actioncomm->email_subject = $subject;
3419 $actioncomm->errors_to =
'';
3421 $actioncomm->fk_element = $adherent->id;
3422 $actioncomm->elementid = $adherent->id;
3423 $actioncomm->elementtype = $adherent->element;
3425 $actioncomm->extraparams = $extraparams;
3427 $actioncomm->create($user);
3433 $this->error .=
"Can't find email template with label=".$labeltouse.
", to use for the reminding email ";
3436 $listofmembersko[$adherent->id] = $adherent->id;
3445 $this->error = $this->db->lasterror();
3450 if ($blockingerrormsg) {
3451 $this->error = $blockingerrormsg;
3454 $this->output =
'Found '.($nbok + $nbko).
' members to send reminder to.';
3455 $this->output .=
' Send email successfully to '.$nbok.
' members';
3458 foreach ($listofmembersok as $idmember) {
3460 $listofids .=
', ...';
3463 if (empty($listofids)) {
3468 $listofids .= $idmember;
3474 $this->output .= ($listofids ?
' ids='.$listofids :
'');
3477 $this->output .=
' - Canceled for '.$nbko.
' member (no email or email sending error)';
3480 foreach ($listofmembersko as $idmember) {
3482 $listofids .=
', ...';
3485 if (empty($listofids)) {
3490 $listofids .= $idmember;
3496 $this->output .= ($listofids ?
' ids='.$listofids :
'');
3512 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
3514 $return =
'<div class="box-flex-item box-flex-grow-zero">';
3515 $return .=
'<div class="info-box info-box-sm">';
3516 $return .=
'<span class="info-box-icon bg-infobox-action">';
3517 if (!empty($this->photo)) {
3518 $return .=
Form::showphoto(
'memberphoto', $this, 0, 60, 0,
'photokanban photowithmargin photologintooltip',
'small', 0, 1);
3522 $return .=
'</span>';
3523 $return .=
'<div class="info-box-content">';
3524 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">' . $this->
getNomUrl() .
'</span>';
3525 if ($selected >= 0) {
3526 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
3528 $return .=
'<br><span class="info-box-label paddingright">'.$this->getmorphylib(
'', 2).
'</span>';
3529 $return .=
'<span class="info-box-label opacitymedium">'.$this->type.
'</span>';
3531 $return .=
'<br><div class="info-box-status paddingtop">';
3532 $return .= $this->
LibStatut($this->
status, $this->need_subscription, $this->datefin, 5);
3533 $return .=
'</div>';
3534 $return .=
'</div>';
3535 $return .=
'</div>';
3536 $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)
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.
$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.
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.
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.
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, $tz='')
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.
dolBuildUrl($url, $params=[], $addtoken=false)
Return path of url.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
GETPOSTISARRAY($paramname, $method=0)
Return true if the parameter $paramname is submit from a POST OR GET as an array.
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...
dolGetStatus($statusLabel='', $statusLabelShort='', $html='', $statusType='status0', $displayMode=0, $url='', $params=array())
Output the badge of a status.
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
getArrayOfSocialNetworks()
Get array of social network dictionary.
dol_textishtml($msg, $option=0)
Return if a text is a html content.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_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.
dol_hash($chain, $type='0', $nosalt=0, $mode=0)
Returns a hash (non reversible encryption) of a string.
dolGetLdapPasswordHash($password, $type='md5')
Returns a specific ldap hash of a password.