dolibarr  16.0.5
adherent_type.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2009-2017 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2016 Charlie Benke <charlie@patas-monkey.com>
6  * Copyright (C) 2018-2019 Thibault Foucart <support@ptibogxiv.net>
7  * Copyright (C) 2021 Waël Almoman <info@almoman.com>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <https://www.gnu.org/licenses/>.
21  */
22 
29 require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
30 
31 
36 {
40  public $table_element = 'adherent_type';
41 
45  public $element = 'adherent_type';
46 
50  public $picto = 'members';
51 
56  public $ismultientitymanaged = 1;
57 
63  public $libelle;
64 
68  public $label;
69 
73  public $morphy;
74 
75  public $duration;
76 
77  /*
78  * type expiration
79  */
80  public $duration_value;
81 
86 
90  public $subscription;
91 
95  public $amount;
96 
101  public $note;
102 
104  public $note_public;
105 
107  public $vote;
108 
110  public $mail_valid;
111 
113  public $mail_subscription = '';
114 
116  public $mail_resiliate = '';
117 
119  public $mail_exclude = '';
120 
122  public $members = array();
123 
125  public $other = array();
126 
127  public $multilangs = array();
128 
129 
135  public function __construct($db)
136  {
137  $this->db = $db;
138  $this->status = 1;
139  }
140 
146  public function getMultiLangs()
147  {
148  global $langs;
149 
150  $current_lang = $langs->getDefaultLang();
151 
152  $sql = "SELECT lang, label, description, email";
153  $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang";
154  $sql .= " WHERE fk_type = ".((int) $this->id);
155 
156  $result = $this->db->query($sql);
157  if ($result) {
158  while ($obj = $this->db->fetch_object($result)) {
159  //print 'lang='.$obj->lang.' current='.$current_lang.'<br>';
160  if ($obj->lang == $current_lang) { // si on a les traduct. dans la langue courante on les charge en infos principales.
161  $this->label = $obj->label;
162  $this->description = $obj->description;
163  $this->email = $obj->email;
164  }
165  $this->multilangs["$obj->lang"]["label"] = $obj->label;
166  $this->multilangs["$obj->lang"]["description"] = $obj->description;
167  $this->multilangs["$obj->lang"]["email"] = $obj->email;
168  }
169  return 1;
170  } else {
171  $this->error = "Error: ".$this->db->lasterror()." - ".$sql;
172  return -1;
173  }
174  }
175 
182  public function setMultiLangs($user)
183  {
184  global $conf, $langs;
185 
186  $langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 0, 2);
187  $current_lang = $langs->getDefaultLang();
188 
189  foreach ($langs_available as $key => $value) {
190  if ($key == $current_lang) {
191  $sql = "SELECT rowid";
192  $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang";
193  $sql .= " WHERE fk_type = ".((int) $this->id);
194  $sql .= " AND lang = '".$this->db->escape($key)."'";
195 
196  $result = $this->db->query($sql);
197 
198  if ($this->db->num_rows($result)) { // if there is already a description line for this language
199  $sql2 = "UPDATE ".MAIN_DB_PREFIX."adherent_type_lang";
200  $sql2 .= " SET";
201  $sql2 .= " label = '".$this->db->escape($this->label)."',";
202  $sql2 .= " description = '".$this->db->escape($this->description)."'";
203  $sql2 .= " WHERE fk_type = ".((int) $this->id)." AND lang='".$this->db->escape($key)."'";
204  } else {
205  $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type_lang (fk_type, lang, label, description";
206  $sql2 .= ")";
207  $sql2 .= " VALUES(".((int) $this->id).",'".$this->db->escape($key)."','".$this->db->escape($this->label)."',";
208  $sql2 .= " '".$this->db->escape($this->description)."'";
209  $sql2 .= ")";
210  }
211  dol_syslog(get_class($this).'::setMultiLangs key = current_lang = '.$key);
212  if (!$this->db->query($sql2)) {
213  $this->error = $this->db->lasterror();
214  return -1;
215  }
216  } elseif (isset($this->multilangs[$key])) {
217  $sql = "SELECT rowid";
218  $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang";
219  $sql .= " WHERE fk_type = ".((int) $this->id);
220  $sql .= " AND lang = '".$this->db->escape($key)."'";
221 
222  $result = $this->db->query($sql);
223 
224  if ($this->db->num_rows($result)) { // if there is already a description line for this language
225  $sql2 = "UPDATE ".MAIN_DB_PREFIX."adherent_type_lang";
226  $sql2 .= " SET ";
227  $sql2 .= " label = '".$this->db->escape($this->multilangs["$key"]["label"])."',";
228  $sql2 .= " description = '".$this->db->escape($this->multilangs["$key"]["description"])."'";
229  $sql2 .= " WHERE fk_type = ".((int) $this->id)." AND lang='".$this->db->escape($key)."'";
230  } else {
231  $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type_lang (fk_type, lang, label, description";
232  $sql2 .= ")";
233  $sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->multilangs["$key"]["label"])."',";
234  $sql2 .= " '".$this->db->escape($this->multilangs["$key"]["description"])."'";
235  $sql2 .= ")";
236  }
237 
238  // We do not save if main fields are empty
239  if ($this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"]) {
240  if (!$this->db->query($sql2)) {
241  $this->error = $this->db->lasterror();
242  return -1;
243  }
244  }
245  } else {
246  // language is not current language and we didn't provide a multilang description for this language
247  }
248  }
249 
250  // Call trigger
251  $result = $this->call_trigger('MEMBER_TYPE_SET_MULTILANGS', $user);
252  if ($result < 0) {
253  $this->error = $this->db->lasterror();
254  return -1;
255  }
256  // End call triggers
257 
258  return 1;
259  }
260 
268  public function delMultiLangs($langtodelete, $user)
269  {
270  $sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_type_lang";
271  $sql .= " WHERE fk_type = ".((int) $this->id)." AND lang = '".$this->db->escape($langtodelete)."'";
272 
273  dol_syslog(get_class($this).'::delMultiLangs', LOG_DEBUG);
274  $result = $this->db->query($sql);
275  if ($result) {
276  // Call trigger
277  $result = $this->call_trigger('MEMBER_TYPE_DEL_MULTILANGS', $user);
278  if ($result < 0) {
279  $this->error = $this->db->lasterror();
280  dol_syslog(get_class($this).'::delMultiLangs error='.$this->error, LOG_ERR);
281  return -1;
282  }
283  // End call triggers
284  return 1;
285  } else {
286  $this->error = $this->db->lasterror();
287  dol_syslog(get_class($this).'::delMultiLangs error='.$this->error, LOG_ERR);
288  return -1;
289  }
290  }
291 
299  public function create($user, $notrigger = 0)
300  {
301  global $langs, $conf;
302 
303  $error = 0;
304 
305  $this->status = (int) $this->status;
306  $this->label = trim($this->label);
307 
308  $this->db->begin();
309 
310  $sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type (";
311  $sql .= " morphy";
312  $sql .= ", libelle";
313  $sql .= ", entity";
314  $sql .= ") VALUES (";
315  $sql .= "'".$this->db->escape($this->morphy)."'";
316  $sql .= ", '".$this->db->escape($this->label)."'";
317  $sql .= ", ".$conf->entity;
318  $sql .= ")";
319 
320  dol_syslog("Adherent_type::create", LOG_DEBUG);
321  $result = $this->db->query($sql);
322  if ($result) {
323  $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."adherent_type");
324 
325  $result = $this->update($user, 1);
326  if ($result < 0) {
327  $this->db->rollback();
328  return -3;
329  }
330 
331  if (!$notrigger) {
332  // Call trigger
333  $result = $this->call_trigger('MEMBER_TYPE_CREATE', $user);
334  if ($result < 0) {
335  $error++;
336  }
337  // End call triggers
338  }
339 
340  if (!$error) {
341  $this->db->commit();
342  return $this->id;
343  } else {
344  dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
345  $this->db->rollback();
346  return -2;
347  }
348  } else {
349  $this->error = $this->db->lasterror();
350  $this->db->rollback();
351  return -1;
352  }
353  }
354 
362  public function update($user, $notrigger = 0)
363  {
364  global $langs, $conf, $hookmanager;
365 
366  $error = 0;
367 
368  $this->label = trim($this->label);
369 
370  if (empty($this->note_public) && !empty($this->note)) { // For backward compatibility
371  $this->note_public = $this->note;
372  }
373 
374  $this->db->begin();
375 
376  $sql = "UPDATE ".MAIN_DB_PREFIX."adherent_type ";
377  $sql .= "SET ";
378  $sql .= "statut = ".((int) $this->status).",";
379  $sql .= "libelle = '".$this->db->escape($this->label)."',";
380  $sql .= "morphy = '".$this->db->escape($this->morphy)."',";
381  $sql .= "subscription = '".$this->db->escape($this->subscription)."',";
382  $sql .= "amount = ".((empty($this->amount) && $this->amount == '') ? 'null' : ((float) $this->amount)).",";
383  $sql .= "duration = '".$this->db->escape($this->duration_value.$this->duration_unit)."',";
384  $sql .= "note = '".$this->db->escape($this->note_public)."',";
385  $sql .= "vote = ".(integer) $this->db->escape($this->vote).",";
386  $sql .= "mail_valid = '".$this->db->escape($this->mail_valid)."'";
387  $sql .= " WHERE rowid =".((int) $this->id);
388 
389  $result = $this->db->query($sql);
390  if ($result) {
391  $this->description = $this->db->escape($this->note_public);
392 
393  // Multilangs
394  if (!empty($conf->global->MAIN_MULTILANGS)) {
395  if ($this->setMultiLangs($user) < 0) {
396  $this->error = $langs->trans("Error")." : ".$this->db->error()." - ".$sql;
397  return -2;
398  }
399  }
400 
401  $action = 'update';
402 
403  // Actions on extra fields
404  if (!$error) {
405  $result = $this->insertExtraFields();
406  if ($result < 0) {
407  $error++;
408  }
409  }
410 
411  if (!$error && !$notrigger) {
412  // Call trigger
413  $result = $this->call_trigger('MEMBER_TYPE_MODIFY', $user);
414  if ($result < 0) {
415  $error++;
416  }
417  // End call triggers
418  }
419 
420  if (!$error) {
421  $this->db->commit();
422  return 1;
423  } else {
424  $this->db->rollback();
425  dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR);
426  return -$error;
427  }
428  } else {
429  $this->error = $this->db->lasterror();
430  $this->db->rollback();
431  return -1;
432  }
433  }
434 
441  public function delete()
442  {
443  global $user;
444 
445  $error = 0;
446 
447  $sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_type";
448  $sql .= " WHERE rowid = ".((int) $this->id);
449 
450  $resql = $this->db->query($sql);
451  if ($resql) {
452  // Call trigger
453  $result = $this->call_trigger('MEMBER_TYPE_DELETE', $user);
454  if ($result < 0) {
455  $error++; $this->db->rollback(); return -2;
456  }
457  // End call triggers
458 
459  $this->db->commit();
460  return 1;
461  } else {
462  $this->db->rollback();
463  $this->error = $this->db->lasterror();
464  return -1;
465  }
466  }
467 
474  public function fetch($rowid)
475  {
476  global $langs, $conf;
477 
478  $sql = "SELECT d.rowid, d.libelle as label, d.morphy, d.statut as status, d.duration, d.subscription, d.amount, d.mail_valid, d.note as note_public, d.vote";
479  $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d";
480  $sql .= " WHERE d.rowid = ".(int) $rowid;
481 
482  dol_syslog("Adherent_type::fetch", LOG_DEBUG);
483 
484  $resql = $this->db->query($sql);
485  if ($resql) {
486  if ($this->db->num_rows($resql)) {
487  $obj = $this->db->fetch_object($resql);
488 
489  $this->id = $obj->rowid;
490  $this->ref = $obj->rowid;
491  $this->label = $obj->label;
492  $this->morphy = $obj->morphy;
493  $this->status = $obj->status;
494  $this->duration = $obj->duration;
495  $this->duration_value = substr($obj->duration, 0, dol_strlen($obj->duration) - 1);
496  $this->duration_unit = substr($obj->duration, -1);
497  $this->subscription = $obj->subscription;
498  $this->amount = $obj->amount;
499  $this->mail_valid = $obj->mail_valid;
500  $this->note = $obj->note_public; // deprecated
501  $this->note_public = $obj->note_public;
502  $this->vote = $obj->vote;
503 
504  // multilangs
505  if (!empty($conf->global->MAIN_MULTILANGS)) {
506  $this->getMultiLangs();
507  }
508 
509  // fetch optionals attributes and labels
510  $this->fetch_optionals();
511  }
512 
513  return 1;
514  } else {
515  $this->error = $this->db->lasterror();
516  return -1;
517  }
518  }
519 
520  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
527  public function liste_array($status = -1)
528  {
529  // phpcs:enable
530  global $conf, $langs;
531 
532  $adherenttypes = array();
533 
534  $sql = "SELECT rowid, libelle as label";
535  $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type";
536  $sql .= " WHERE entity IN (".getEntity('member_type').")";
537  if ($status >= 0) {
538  $sql .= " AND statut = ".((int) $status);
539  }
540 
541  $resql = $this->db->query($sql);
542  if ($resql) {
543  $nump = $this->db->num_rows($resql);
544 
545  if ($nump) {
546  $i = 0;
547  while ($i < $nump) {
548  $obj = $this->db->fetch_object($resql);
549 
550  $adherenttypes[$obj->rowid] = $langs->trans($obj->label);
551  $i++;
552  }
553  }
554  } else {
555  print $this->db->error();
556  }
557  return $adherenttypes;
558  }
559 
566  public function amountByType($status = null)
567  {
568  global $conf, $langs;
569 
570  $amountbytype = array();
571 
572  $sql = "SELECT rowid, amount";
573  $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type";
574  $sql .= " WHERE entity IN (".getEntity('member_type').")";
575  if ($status !== null) {
576  $sql .= " AND statut = ".((int) $status);
577  }
578 
579  $resql = $this->db->query($sql);
580  if ($resql) {
581  $nump = $this->db->num_rows($resql);
582 
583  if ($nump) {
584  $i = 0;
585  while ($i < $nump) {
586  $obj = $this->db->fetch_object($resql);
587 
588  $amountbytype[$obj->rowid] = $obj->amount;
589  $i++;
590  }
591  }
592  } else {
593  print $this->db->error();
594  }
595 
596  return $amountbytype;
597  }
598 
608  public function listMembersForMemberType($excludefilter = '', $mode = 0)
609  {
610  global $conf, $user;
611 
612  $ret = array();
613 
614  $sql = "SELECT a.rowid";
615  $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a";
616  $sql .= " WHERE a.entity IN (".getEntity('member').")";
617  $sql .= " AND a.fk_adherent_type = ".((int) $this->id);
618  if (!empty($excludefilter)) {
619  $sql .= ' AND ('.$excludefilter.')';
620  }
621 
622  dol_syslog(get_class($this)."::listUsersForGroup", LOG_DEBUG);
623  $resql = $this->db->query($sql);
624  if ($resql) {
625  while ($obj = $this->db->fetch_object($resql)) {
626  if (!array_key_exists($obj->rowid, $ret)) {
627  if ($mode < 2) {
628  $memberstatic = new Adherent($this->db);
629  if ($mode == 1) {
630  $memberstatic->fetch($obj->rowid, '', '', '', false, false);
631  } else {
632  $memberstatic->fetch($obj->rowid);
633  }
634  $ret[$obj->rowid] = $memberstatic;
635  } else {
636  $ret[$obj->rowid] = $obj->rowid;
637  }
638  }
639  }
640 
641  $this->db->free($resql);
642 
643  $this->members = $ret;
644 
645  return $ret;
646  } else {
647  $this->error = $this->db->lasterror();
648  return -1;
649  }
650  }
651 
658  public function getmorphylib($morphy = '')
659  {
660  global $langs;
661  if ($morphy == 'phy') {
662  return $langs->trans("Physical");
663  } elseif ($morphy == 'mor') {
664  return $langs->trans("Moral");
665  } else {
666  return $langs->trans("MorAndPhy");
667  }
668  //return $morphy;
669  }
670 
681  public function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
682  {
683  global $langs;
684 
685  $result = '';
686 
687  $label = img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("MemberType").'</u>';
688  $label .= ' '.$this->getLibStatut(4);
689  $label .= '<br>'.$langs->trans("Label").': '.$this->label;
690  if (isset($this->subscription)) {
691  $label .= '<br>'.$langs->trans("SubscriptionRequired").': '.yn($this->subscription);
692  }
693 
694  $option = '';
695 
696  $url = DOL_URL_ROOT.'/adherents/type.php?rowid='.((int) $this->id);
697 
698  if ($option != 'nolink') {
699  // Add param to save lastsearch_values or not
700  $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
701  if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
702  $add_save_lastsearch_values = 1;
703  }
704  if ($add_save_lastsearch_values) {
705  $url .= '&save_lastsearch_values=1';
706  }
707  }
708 
709  $linkstart = '<a href="'.$url.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
710  $linkend = '</a>';
711 
712  $result .= $linkstart;
713  if ($withpicto) {
714  $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
715  }
716  if ($withpicto != 2) {
717  $result .= ($maxlen ?dol_trunc($this->label, $maxlen) : $this->label);
718  }
719  $result .= $linkend;
720 
721  return $result;
722  }
723 
724  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
731  public function getLibStatut($mode = 0)
732  {
733  return $this->LibStatut($this->status, $mode);
734  }
735 
743  public function LibStatut($status, $mode = 0)
744  {
745  // phpcs:enable
746  global $langs;
747  $langs->load('companies');
748 
749  $statusType = 'status4';
750  if ($status == 0) {
751  $statusType = 'status5';
752  }
753 
754  if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
755  $this->labelStatus[0] = $langs->transnoentitiesnoconv("ActivityCeased");
756  $this->labelStatus[1] = $langs->transnoentitiesnoconv("InActivity");
757  $this->labelStatusShort[0] = $langs->transnoentitiesnoconv("ActivityCeased");
758  $this->labelStatusShort[1] = $langs->transnoentitiesnoconv("InActivity");
759  }
760 
761  return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
762  }
763 
764  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
765  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
775  public function _load_ldap_dn($info, $mode = 0)
776  {
777  // phpcs:enable
778  global $conf;
779  $dn = '';
780  if ($mode == 0) {
781  $dn = $conf->global->LDAP_KEY_MEMBERS_TYPES."=".$info[$conf->global->LDAP_KEY_MEMBERS_TYPES].",".$conf->global->LDAP_MEMBER_TYPE_DN;
782  }
783  if ($mode == 1) {
784  $dn = $conf->global->LDAP_MEMBER_TYPE_DN;
785  }
786  if ($mode == 2) {
787  $dn = $conf->global->LDAP_KEY_MEMBERS_TYPES."=".$info[$conf->global->LDAP_KEY_MEMBERS_TYPES];
788  }
789  return $dn;
790  }
791 
792 
793  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
794  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
800  public function _load_ldap_info()
801  {
802  // phpcs:enable
803  global $conf, $langs;
804 
805  $info = array();
806 
807  // Object classes
808  $info["objectclass"] = explode(',', $conf->global->LDAP_MEMBER_TYPE_OBJECT_CLASS);
809 
810  if (empty($this->note_public) && !empty($this->note)) { // For backward compatibility
811  $this->note_public = $this->note;
812  }
813 
814  // Champs
815  if ($this->label && !empty($conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME)) {
816  $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME] = $this->label;
817  }
818  if ($this->note_public && !empty($conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION)) {
819  $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note_public, 0, 'UTF-8', 1);
820  }
821  if (!empty($conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS)) {
822  $valueofldapfield = array();
823  foreach ($this->members as $key => $val) { // This is array of users for group into dolibarr database.
824  $member = new Adherent($this->db);
825  $member->fetch($val->id, '', '', '', false, false);
826  $info2 = $member->_load_ldap_info();
827  $valueofldapfield[] = $member->_load_ldap_dn($info2);
828  }
829  $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS] = (!empty($valueofldapfield) ? $valueofldapfield : '');
830  }
831  return $info;
832  }
833 
841  public function initAsSpecimen()
842  {
843  global $user;
844 
845  // Initialise parametres
846  $this->id = 0;
847  $this->ref = 'MTSPEC';
848  $this->specimen = 1;
849 
850  $this->label = 'MEMBERS TYPE SPECIMEN';
851  $this->note_public = 'This is a public note';
852  $this->mail_valid = 'This is welcome email';
853  $this->subscription = 1;
854  $this->vote = 0;
855 
856  $this->status = 1;
857 
858  // Members of this member type is just me
859  $this->members = array(
860  $user->id => $user
861  );
862  }
863 
869  public function getMailOnValid()
870  {
871  if (!empty($this->mail_valid) && trim(dol_htmlentitiesbr_decode($this->mail_valid))) {
872  return $this->mail_valid;
873  }
874 
875  return '';
876  }
877 
883  public function getMailOnSubscription()
884  {
885  // mail_subscription not defined so never used
886  if (!empty($this->mail_subscription) && trim(dol_htmlentitiesbr_decode($this->mail_subscription))) { // Property not yet defined
887  return $this->mail_subscription;
888  }
889 
890  return '';
891  }
892 
898  public function getMailOnResiliate()
899  {
900  // NOTE mail_resiliate not defined so never used
901  if (!empty($this->mail_resiliate) && trim(dol_htmlentitiesbr_decode($this->mail_resiliate))) { // Property not yet defined
902  return $this->mail_resiliate;
903  }
904 
905  return '';
906  }
907 
913  public function getMailOnExclude()
914  {
915  // NOTE mail_exclude not defined so never used
916  if (!empty($this->mail_exclude) && trim(dol_htmlentitiesbr_decode($this->mail_exclude))) { // Property not yet defined
917  return $this->mail_exclude;
918  }
919 
920  return '';
921  }
922 }
db
$conf db
API class for accounts.
Definition: inc.php:41
AdherentType
Class to manage members type.
Definition: adherent_type.class.php:35
yn
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
Definition: functions.lib.php:6491
dol_escape_htmltag
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
Definition: functions.lib.php:1468
dol_trunc
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.
Definition: functions.lib.php:3805
description
print *****$script_file(".$version.") pid cd cd cd description as description
Definition: email_expire_services_to_customers.php:83
dol_htmlentitiesbr_decode
dol_htmlentitiesbr_decode($stringtodecode, $pagecodeto='UTF-8')
This function is called to decode a HTML string (it decodes entities and br tags)
Definition: functions.lib.php:7020
AdherentType\getLibStatut
getLibStatut($mode=0)
Return label of status (activity, closed)
Definition: adherent_type.class.php:731
AdherentType\_load_ldap_info
_load_ldap_info()
Initialize the info array (array of LDAP values) that will be used to call LDAP functions.
Definition: adherent_type.class.php:800
ref
$object ref
Definition: info.php:77
AdherentType\getmorphylib
getmorphylib($morphy='')
Return translated label by the nature of a adherent (physical or moral)
Definition: adherent_type.class.php:658
CommonObject
Parent class of all other business classes (invoices, contracts, proposals, orders,...
Definition: commonobject.class.php:44
AdherentType\_load_ldap_dn
_load_ldap_dn($info, $mode=0)
Retourne chaine DN complete dans l'annuaire LDAP pour l'objet.
Definition: adherent_type.class.php:775
AdherentType\create
create($user, $notrigger=0)
Function to create the member type.
Definition: adherent_type.class.php:299
AdherentType\__construct
__construct($db)
Constructor.
Definition: adherent_type.class.php:135
AdherentType\listMembersForMemberType
listMembersForMemberType($excludefilter='', $mode=0)
Return array of Member objects for member type this->id (or all if this->id not defined)
Definition: adherent_type.class.php:608
AdherentType\getMailOnResiliate
getMailOnResiliate()
getMailOnResiliate
Definition: adherent_type.class.php:898
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:3880
AdherentType\getMultiLangs
getMultiLangs()
Load array this->multilangs.
Definition: adherent_type.class.php:146
AdherentType\LibStatut
LibStatut($status, $mode=0)
Return the label of a given status.
Definition: adherent_type.class.php:743
AdherentType\getMailOnSubscription
getMailOnSubscription()
getMailOnSubscription
Definition: adherent_type.class.php:883
CommonObject\insertExtraFields
insertExtraFields($trigger='', $userused=null)
Add/Update all extra fields values for the current object.
Definition: commonobject.class.php:6156
AdherentType\getMailOnExclude
getMailOnExclude()
getMailOnExclude
Definition: adherent_type.class.php:913
dol_string_nohtmltag
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
Definition: functions.lib.php:6694
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1603
AdherentType\fetch
fetch($rowid)
Function that retrieves the status of the member.
Definition: adherent_type.class.php:474
Adherent
Class to manage members of a foundation.
Definition: adherent.class.php:46
CommonObject\fetch_optionals
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...
Definition: commonobject.class.php:6007
AdherentType\getNomUrl
getNomUrl($withpicto=0, $maxlen=0, $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return clicable name (with picto eventually)
Definition: adherent_type.class.php:681
dol_strlen
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
Definition: functions.lib.php:3747
AdherentType\delMultiLangs
delMultiLangs($langtodelete, $user)
Delete a language for this member type.
Definition: adherent_type.class.php:268
AdherentType\initAsSpecimen
initAsSpecimen()
Initialise an instance with random values.
Definition: adherent_type.class.php:841
AdherentType\liste_array
liste_array($status=-1)
Return list of members' type.
Definition: adherent_type.class.php:527
AdherentType\$duration_unit
$duration_unit
Expiration unit.
Definition: adherent_type.class.php:85
dolGetStatus
dolGetStatus($statusLabel='', $statusLabelShort='', $html='', $statusType='status0', $displayMode=0, $url='', $params=array())
Output the badge of a status.
Definition: functions.lib.php:10338
img_object
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
Definition: functions.lib.php:4211
AdherentType\getMailOnValid
getMailOnValid()
getMailOnValid
Definition: adherent_type.class.php:869
$resql
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:742
AdherentType\update
update($user, $notrigger=0)
Updating the type in the database.
Definition: adherent_type.class.php:362
CommonObject\call_trigger
call_trigger($triggerName, $user)
Call trigger based on this instance.
Definition: commonobject.class.php:5791
AdherentType\amountByType
amountByType($status=null)
Return the array of all amounts per membership type id.
Definition: adherent_type.class.php:566
AdherentType\setMultiLangs
setMultiLangs($user)
Update or add a translation for this member type.
Definition: adherent_type.class.php:182