dolibarr  17.0.3
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 
100  public $caneditamount;
101 
106  public $note;
107 
109  public $note_public;
110 
112  public $vote;
113 
115  public $mail_valid;
116 
118  public $mail_subscription = '';
119 
121  public $mail_resiliate = '';
122 
124  public $mail_exclude = '';
125 
127  public $members = array();
128 
130  public $other = array();
131 
132  public $multilangs = array();
133 
134 
140  public function __construct($db)
141  {
142  $this->db = $db;
143  $this->status = 1;
144  }
145 
151  public function getMultiLangs()
152  {
153  global $langs;
154 
155  $current_lang = $langs->getDefaultLang();
156 
157  $sql = "SELECT lang, label, description, email";
158  $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang";
159  $sql .= " WHERE fk_type = ".((int) $this->id);
160 
161  $result = $this->db->query($sql);
162  if ($result) {
163  while ($obj = $this->db->fetch_object($result)) {
164  //print 'lang='.$obj->lang.' current='.$current_lang.'<br>';
165  if ($obj->lang == $current_lang) { // si on a les traduct. dans la langue courante on les charge en infos principales.
166  $this->label = $obj->label;
167  $this->description = $obj->description;
168  $this->email = $obj->email;
169  }
170  $this->multilangs["$obj->lang"]["label"] = $obj->label;
171  $this->multilangs["$obj->lang"]["description"] = $obj->description;
172  $this->multilangs["$obj->lang"]["email"] = $obj->email;
173  }
174  return 1;
175  } else {
176  $this->error = "Error: ".$this->db->lasterror()." - ".$sql;
177  return -1;
178  }
179  }
180 
187  public function setMultiLangs($user)
188  {
189  global $conf, $langs;
190 
191  $langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 0, 2);
192  $current_lang = $langs->getDefaultLang();
193 
194  foreach ($langs_available as $key => $value) {
195  if ($key == $current_lang) {
196  $sql = "SELECT rowid";
197  $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang";
198  $sql .= " WHERE fk_type = ".((int) $this->id);
199  $sql .= " AND lang = '".$this->db->escape($key)."'";
200 
201  $result = $this->db->query($sql);
202 
203  if ($this->db->num_rows($result)) { // if there is already a description line for this language
204  $sql2 = "UPDATE ".MAIN_DB_PREFIX."adherent_type_lang";
205  $sql2 .= " SET";
206  $sql2 .= " label = '".$this->db->escape($this->label)."',";
207  $sql2 .= " description = '".$this->db->escape($this->description)."'";
208  $sql2 .= " WHERE fk_type = ".((int) $this->id)." AND lang='".$this->db->escape($key)."'";
209  } else {
210  $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type_lang (fk_type, lang, label, description";
211  $sql2 .= ")";
212  $sql2 .= " VALUES(".((int) $this->id).",'".$this->db->escape($key)."','".$this->db->escape($this->label)."',";
213  $sql2 .= " '".$this->db->escape($this->description)."'";
214  $sql2 .= ")";
215  }
216  dol_syslog(get_class($this).'::setMultiLangs key = current_lang = '.$key);
217  if (!$this->db->query($sql2)) {
218  $this->error = $this->db->lasterror();
219  return -1;
220  }
221  } elseif (isset($this->multilangs[$key])) {
222  $sql = "SELECT rowid";
223  $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang";
224  $sql .= " WHERE fk_type = ".((int) $this->id);
225  $sql .= " AND lang = '".$this->db->escape($key)."'";
226 
227  $result = $this->db->query($sql);
228 
229  if ($this->db->num_rows($result)) { // if there is already a description line for this language
230  $sql2 = "UPDATE ".MAIN_DB_PREFIX."adherent_type_lang";
231  $sql2 .= " SET ";
232  $sql2 .= " label = '".$this->db->escape($this->multilangs["$key"]["label"])."',";
233  $sql2 .= " description = '".$this->db->escape($this->multilangs["$key"]["description"])."'";
234  $sql2 .= " WHERE fk_type = ".((int) $this->id)." AND lang='".$this->db->escape($key)."'";
235  } else {
236  $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type_lang (fk_type, lang, label, description";
237  $sql2 .= ")";
238  $sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->multilangs["$key"]["label"])."',";
239  $sql2 .= " '".$this->db->escape($this->multilangs["$key"]["description"])."'";
240  $sql2 .= ")";
241  }
242 
243  // We do not save if main fields are empty
244  if ($this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"]) {
245  if (!$this->db->query($sql2)) {
246  $this->error = $this->db->lasterror();
247  return -1;
248  }
249  }
250  } else {
251  // language is not current language and we didn't provide a multilang description for this language
252  }
253  }
254 
255  // Call trigger
256  $result = $this->call_trigger('MEMBER_TYPE_SET_MULTILANGS', $user);
257  if ($result < 0) {
258  $this->error = $this->db->lasterror();
259  return -1;
260  }
261  // End call triggers
262 
263  return 1;
264  }
265 
273  public function delMultiLangs($langtodelete, $user)
274  {
275  $sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_type_lang";
276  $sql .= " WHERE fk_type = ".((int) $this->id)." AND lang = '".$this->db->escape($langtodelete)."'";
277 
278  dol_syslog(get_class($this).'::delMultiLangs', LOG_DEBUG);
279  $result = $this->db->query($sql);
280  if ($result) {
281  // Call trigger
282  $result = $this->call_trigger('MEMBER_TYPE_DEL_MULTILANGS', $user);
283  if ($result < 0) {
284  $this->error = $this->db->lasterror();
285  dol_syslog(get_class($this).'::delMultiLangs error='.$this->error, LOG_ERR);
286  return -1;
287  }
288  // End call triggers
289  return 1;
290  } else {
291  $this->error = $this->db->lasterror();
292  dol_syslog(get_class($this).'::delMultiLangs error='.$this->error, LOG_ERR);
293  return -1;
294  }
295  }
296 
304  public function create($user, $notrigger = 0)
305  {
306  global $langs, $conf;
307 
308  $error = 0;
309 
310  $this->status = (int) $this->status;
311  $this->label = trim($this->label);
312 
313  $this->db->begin();
314 
315  $sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type (";
316  $sql .= " morphy";
317  $sql .= ", libelle";
318  $sql .= ", entity";
319  $sql .= ") VALUES (";
320  $sql .= "'".$this->db->escape($this->morphy)."'";
321  $sql .= ", '".$this->db->escape($this->label)."'";
322  $sql .= ", ".((int) $conf->entity);
323  $sql .= ")";
324 
325  dol_syslog("Adherent_type::create", LOG_DEBUG);
326  $result = $this->db->query($sql);
327  if ($result) {
328  $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."adherent_type");
329 
330  $result = $this->update($user, 1);
331  if ($result < 0) {
332  $this->db->rollback();
333  return -3;
334  }
335 
336  if (!$notrigger) {
337  // Call trigger
338  $result = $this->call_trigger('MEMBER_TYPE_CREATE', $user);
339  if ($result < 0) {
340  $error++;
341  }
342  // End call triggers
343  }
344 
345  if (!$error) {
346  $this->db->commit();
347  return $this->id;
348  } else {
349  dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
350  $this->db->rollback();
351  return -2;
352  }
353  } else {
354  $this->error = $this->db->lasterror();
355  $this->db->rollback();
356  return -1;
357  }
358  }
359 
367  public function update($user, $notrigger = 0)
368  {
369  global $langs, $conf, $hookmanager;
370 
371  $error = 0;
372 
373  $this->label = trim($this->label);
374 
375  if (empty($this->note_public) && !empty($this->note)) { // For backward compatibility
376  $this->note_public = $this->note;
377  }
378 
379  $this->db->begin();
380 
381  $sql = "UPDATE ".MAIN_DB_PREFIX."adherent_type ";
382  $sql .= "SET ";
383  $sql .= "statut = ".((int) $this->status).",";
384  $sql .= "libelle = '".$this->db->escape($this->label)."',";
385  $sql .= "morphy = '".$this->db->escape($this->morphy)."',";
386  $sql .= "subscription = '".$this->db->escape($this->subscription)."',";
387  $sql .= "amount = ".((empty($this->amount) && $this->amount == '') ? 'null' : ((float) $this->amount)).",";
388  $sql .= "caneditamount = ".((int) $this->caneditamount).",";
389  $sql .= "duration = '".$this->db->escape($this->duration_value.$this->duration_unit)."',";
390  $sql .= "note = '".$this->db->escape($this->note_public)."',";
391  $sql .= "vote = ".(integer) $this->db->escape($this->vote).",";
392  $sql .= "mail_valid = '".$this->db->escape($this->mail_valid)."'";
393  $sql .= " WHERE rowid =".((int) $this->id);
394 
395  $result = $this->db->query($sql);
396  if ($result) {
397  $this->description = $this->db->escape($this->note_public);
398 
399  // Multilangs
400  if (getDolGlobalInt('MAIN_MULTILANGS')) {
401  if ($this->setMultiLangs($user) < 0) {
402  $this->error = $langs->trans("Error")." : ".$this->db->error()." - ".$sql;
403  return -2;
404  }
405  }
406 
407  $action = 'update';
408 
409  // Actions on extra fields
410  if (!$error) {
411  $result = $this->insertExtraFields();
412  if ($result < 0) {
413  $error++;
414  }
415  }
416 
417  if (!$error && !$notrigger) {
418  // Call trigger
419  $result = $this->call_trigger('MEMBER_TYPE_MODIFY', $user);
420  if ($result < 0) {
421  $error++;
422  }
423  // End call triggers
424  }
425 
426  if (!$error) {
427  $this->db->commit();
428  return 1;
429  } else {
430  $this->db->rollback();
431  dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR);
432  return -$error;
433  }
434  } else {
435  $this->error = $this->db->lasterror();
436  $this->db->rollback();
437  return -1;
438  }
439  }
440 
447  public function delete()
448  {
449  global $user;
450 
451  $error = 0;
452 
453  $sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_type";
454  $sql .= " WHERE rowid = ".((int) $this->id);
455 
456  $resql = $this->db->query($sql);
457  if ($resql) {
458  // Call trigger
459  $result = $this->call_trigger('MEMBER_TYPE_DELETE', $user);
460  if ($result < 0) {
461  $error++; $this->db->rollback(); return -2;
462  }
463  // End call triggers
464 
465  $this->db->commit();
466  return 1;
467  } else {
468  $this->db->rollback();
469  $this->error = $this->db->lasterror();
470  return -1;
471  }
472  }
473 
480  public function fetch($rowid)
481  {
482  global $langs, $conf;
483 
484  $sql = "SELECT d.rowid, d.libelle as label, d.morphy, d.statut as status, d.duration, d.subscription, d.amount, d.caneditamount, d.mail_valid, d.note as note_public, d.vote";
485  $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d";
486  $sql .= " WHERE d.rowid = ".(int) $rowid;
487 
488  dol_syslog("Adherent_type::fetch", LOG_DEBUG);
489 
490  $resql = $this->db->query($sql);
491  if ($resql) {
492  if ($this->db->num_rows($resql)) {
493  $obj = $this->db->fetch_object($resql);
494 
495  $this->id = $obj->rowid;
496  $this->ref = $obj->rowid;
497  $this->label = $obj->label;
498  $this->morphy = $obj->morphy;
499  $this->status = $obj->status;
500  $this->duration = $obj->duration;
501  $this->duration_value = substr($obj->duration, 0, dol_strlen($obj->duration) - 1);
502  $this->duration_unit = substr($obj->duration, -1);
503  $this->subscription = $obj->subscription;
504  $this->amount = $obj->amount;
505  $this->caneditamount = $obj->caneditamount;
506  $this->mail_valid = $obj->mail_valid;
507  $this->note = $obj->note_public; // deprecated
508  $this->note_public = $obj->note_public;
509  $this->vote = $obj->vote;
510 
511  // multilangs
512  if (getDolGlobalInt('MAIN_MULTILANGS')) {
513  $this->getMultiLangs();
514  }
515 
516  // fetch optionals attributes and labels
517  $this->fetch_optionals();
518  }
519 
520  return 1;
521  } else {
522  $this->error = $this->db->lasterror();
523  return -1;
524  }
525  }
526 
527  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
534  public function liste_array($status = -1)
535  {
536  // phpcs:enable
537  global $conf, $langs;
538 
539  $adherenttypes = array();
540 
541  $sql = "SELECT rowid, libelle as label";
542  $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type";
543  $sql .= " WHERE entity IN (".getEntity('member_type').")";
544  if ($status >= 0) {
545  $sql .= " AND statut = ".((int) $status);
546  }
547 
548  $resql = $this->db->query($sql);
549  if ($resql) {
550  $nump = $this->db->num_rows($resql);
551 
552  if ($nump) {
553  $i = 0;
554  while ($i < $nump) {
555  $obj = $this->db->fetch_object($resql);
556 
557  $adherenttypes[$obj->rowid] = $langs->trans($obj->label);
558  $i++;
559  }
560  }
561  } else {
562  print $this->db->error();
563  }
564  return $adherenttypes;
565  }
566 
573  public function amountByType($status = null)
574  {
575  global $conf, $langs;
576 
577  $amountbytype = array();
578 
579  $sql = "SELECT rowid, amount";
580  $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type";
581  $sql .= " WHERE entity IN (".getEntity('member_type').")";
582  if ($status !== null) {
583  $sql .= " AND statut = ".((int) $status);
584  }
585 
586  $resql = $this->db->query($sql);
587  if ($resql) {
588  $nump = $this->db->num_rows($resql);
589 
590  if ($nump) {
591  $i = 0;
592  while ($i < $nump) {
593  $obj = $this->db->fetch_object($resql);
594 
595  $amountbytype[$obj->rowid] = $obj->amount;
596  $i++;
597  }
598  }
599  } else {
600  print $this->db->error();
601  }
602 
603  return $amountbytype;
604  }
605 
615  public function listMembersForMemberType($excludefilter = '', $mode = 0)
616  {
617  global $conf, $user;
618 
619  $ret = array();
620 
621  $sql = "SELECT a.rowid";
622  $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a";
623  $sql .= " WHERE a.entity IN (".getEntity('member').")";
624  $sql .= " AND a.fk_adherent_type = ".((int) $this->id);
625  if (!empty($excludefilter)) {
626  $sql .= ' AND ('.$excludefilter.')';
627  }
628 
629  dol_syslog(get_class($this)."::listMembersForMemberType", LOG_DEBUG);
630  $resql = $this->db->query($sql);
631  if ($resql) {
632  while ($obj = $this->db->fetch_object($resql)) {
633  if (!array_key_exists($obj->rowid, $ret)) {
634  if ($mode < 2) {
635  $memberstatic = new Adherent($this->db);
636  if ($mode == 1) {
637  $memberstatic->fetch($obj->rowid, '', '', '', false, false);
638  } else {
639  $memberstatic->fetch($obj->rowid);
640  }
641  $ret[$obj->rowid] = $memberstatic;
642  } else {
643  $ret[$obj->rowid] = $obj->rowid;
644  }
645  }
646  }
647 
648  $this->db->free($resql);
649 
650  $this->members = $ret;
651 
652  return $ret;
653  } else {
654  $this->error = $this->db->lasterror();
655  return -1;
656  }
657  }
658 
665  public function getmorphylib($morphy = '')
666  {
667  global $langs;
668  if ($morphy == 'phy') {
669  return $langs->trans("Physical");
670  } elseif ($morphy == 'mor') {
671  return $langs->trans("Moral");
672  } else {
673  return $langs->trans("MorAndPhy");
674  }
675  //return $morphy;
676  }
677 
688  public function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
689  {
690  global $langs;
691 
692  $result = '';
693 
694  $label = img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("MemberType").'</u>';
695  $label .= ' '.$this->getLibStatut(4);
696  $label .= '<br>'.$langs->trans("Label").': '.$this->label;
697  if (isset($this->subscription)) {
698  $label .= '<br>'.$langs->trans("SubscriptionRequired").': '.yn($this->subscription);
699  }
700 
701  $option = '';
702 
703  $url = DOL_URL_ROOT.'/adherents/type.php?rowid='.((int) $this->id);
704 
705  if ($option != 'nolink') {
706  // Add param to save lastsearch_values or not
707  $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
708  if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
709  $add_save_lastsearch_values = 1;
710  }
711  if ($add_save_lastsearch_values) {
712  $url .= '&save_lastsearch_values=1';
713  }
714  }
715 
716  $linkstart = '<a href="'.$url.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
717  $linkend = '</a>';
718 
719  $result .= $linkstart;
720  if ($withpicto) {
721  $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);
722  }
723  if ($withpicto != 2) {
724  $result .= ($maxlen ?dol_trunc($this->label, $maxlen) : $this->label);
725  }
726  $result .= $linkend;
727 
728  return $result;
729  }
730 
731  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
738  public function getLibStatut($mode = 0)
739  {
740  return $this->LibStatut($this->status, $mode);
741  }
742 
750  public function LibStatut($status, $mode = 0)
751  {
752  // phpcs:enable
753  global $langs;
754  $langs->load('companies');
755 
756  $statusType = 'status4';
757  if ($status == 0) {
758  $statusType = 'status5';
759  }
760 
761  if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
762  $this->labelStatus[0] = $langs->transnoentitiesnoconv("ActivityCeased");
763  $this->labelStatus[1] = $langs->transnoentitiesnoconv("InActivity");
764  $this->labelStatusShort[0] = $langs->transnoentitiesnoconv("ActivityCeased");
765  $this->labelStatusShort[1] = $langs->transnoentitiesnoconv("InActivity");
766  }
767 
768  return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
769  }
770 
771  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
772  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
782  public function _load_ldap_dn($info, $mode = 0)
783  {
784  // phpcs:enable
785  global $conf;
786  $dn = '';
787  if ($mode == 0) {
788  $dn = $conf->global->LDAP_KEY_MEMBERS_TYPES."=".$info[$conf->global->LDAP_KEY_MEMBERS_TYPES].",".$conf->global->LDAP_MEMBER_TYPE_DN;
789  }
790  if ($mode == 1) {
791  $dn = $conf->global->LDAP_MEMBER_TYPE_DN;
792  }
793  if ($mode == 2) {
794  $dn = $conf->global->LDAP_KEY_MEMBERS_TYPES."=".$info[$conf->global->LDAP_KEY_MEMBERS_TYPES];
795  }
796  return $dn;
797  }
798 
799 
800  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
801  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
807  public function _load_ldap_info()
808  {
809  // phpcs:enable
810  global $conf, $langs;
811 
812  $info = array();
813 
814  // Object classes
815  $info["objectclass"] = explode(',', $conf->global->LDAP_MEMBER_TYPE_OBJECT_CLASS);
816 
817  if (empty($this->note_public) && !empty($this->note)) { // For backward compatibility
818  $this->note_public = $this->note;
819  }
820 
821  // Champs
822  if ($this->label && !empty($conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME)) {
823  $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME] = $this->label;
824  }
825  if ($this->note_public && !empty($conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION)) {
826  $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note_public, 0, 'UTF-8', 1);
827  }
828  if (!empty($conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS)) {
829  $valueofldapfield = array();
830  foreach ($this->members as $key => $val) { // This is array of users for group into dolibarr database.
831  $member = new Adherent($this->db);
832  $member->fetch($val->id, '', '', '', false, false);
833  $info2 = $member->_load_ldap_info();
834  $valueofldapfield[] = $member->_load_ldap_dn($info2);
835  }
836  $info[$conf->global->LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS] = (!empty($valueofldapfield) ? $valueofldapfield : '');
837  }
838  return $info;
839  }
840 
848  public function initAsSpecimen()
849  {
850  global $user;
851 
852  // Initialise parametres
853  $this->id = 0;
854  $this->ref = 'MTSPEC';
855  $this->specimen = 1;
856 
857  $this->label = 'MEMBERS TYPE SPECIMEN';
858  $this->note_public = 'This is a public note';
859  $this->mail_valid = 'This is welcome email';
860  $this->subscription = 1;
861  $this->caneditamount = 0;
862  $this->vote = 0;
863 
864  $this->status = 1;
865 
866  // Members of this member type is just me
867  $this->members = array(
868  $user->id => $user
869  );
870  }
871 
877  public function getMailOnValid()
878  {
879  if (!empty($this->mail_valid) && trim(dol_htmlentitiesbr_decode($this->mail_valid))) {
880  return $this->mail_valid;
881  }
882 
883  return '';
884  }
885 
891  public function getMailOnSubscription()
892  {
893  // mail_subscription not defined so never used
894  if (!empty($this->mail_subscription) && trim(dol_htmlentitiesbr_decode($this->mail_subscription))) { // Property not yet defined
895  return $this->mail_subscription;
896  }
897 
898  return '';
899  }
900 
906  public function getMailOnResiliate()
907  {
908  // NOTE mail_resiliate not defined so never used
909  if (!empty($this->mail_resiliate) && trim(dol_htmlentitiesbr_decode($this->mail_resiliate))) { // Property not yet defined
910  return $this->mail_resiliate;
911  }
912 
913  return '';
914  }
915 
921  public function getMailOnExclude()
922  {
923  // NOTE mail_exclude not defined so never used
924  if (!empty($this->mail_exclude) && trim(dol_htmlentitiesbr_decode($this->mail_exclude))) { // Property not yet defined
925  return $this->mail_exclude;
926  }
927 
928  return '';
929  }
930 }
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:6677
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:1493
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:3949
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:7310
AdherentType\getLibStatut
getLibStatut($mode=0)
Return label of status (activity, closed)
Definition: adherent_type.class.php:738
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:807
ref
$object ref
Definition: info.php:78
AdherentType\getmorphylib
getmorphylib($morphy='')
Return translated label by the nature of a adherent (physical or moral)
Definition: adherent_type.class.php:665
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:782
AdherentType\create
create($user, $notrigger=0)
Function to create the member type.
Definition: adherent_type.class.php:304
AdherentType\__construct
__construct($db)
Constructor.
Definition: adherent_type.class.php:140
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:615
AdherentType\getMailOnResiliate
getMailOnResiliate()
getMailOnResiliate
Definition: adherent_type.class.php:906
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:4024
AdherentType\getMultiLangs
getMultiLangs()
Load array this->multilangs.
Definition: adherent_type.class.php:151
AdherentType\LibStatut
LibStatut($status, $mode=0)
Return the label of a given status.
Definition: adherent_type.class.php:750
AdherentType\getMailOnSubscription
getMailOnSubscription()
getMailOnSubscription
Definition: adherent_type.class.php:891
CommonObject\insertExtraFields
insertExtraFields($trigger='', $userused=null)
Add/Update all extra fields values for the current object.
Definition: commonobject.class.php:6185
$resql
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("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->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:745
AdherentType\getMailOnExclude
getMailOnExclude()
getMailOnExclude
Definition: adherent_type.class.php:921
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:6880
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1628
AdherentType\fetch
fetch($rowid)
Function that retrieves the properties of a membership type.
Definition: adherent_type.class.php:480
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:6034
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:688
dol_strlen
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
Definition: functions.lib.php:3887
AdherentType\delMultiLangs
delMultiLangs($langtodelete, $user)
Delete a language for this member type.
Definition: adherent_type.class.php:273
AdherentType\initAsSpecimen
initAsSpecimen()
Initialise an instance with random values.
Definition: adherent_type.class.php:848
AdherentType\liste_array
liste_array($status=-1)
Return list of members' type.
Definition: adherent_type.class.php:534
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:10745
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:4360
AdherentType\getMailOnValid
getMailOnValid()
getMailOnValid
Definition: adherent_type.class.php:877
AdherentType\update
update($user, $notrigger=0)
Updating the type in the database.
Definition: adherent_type.class.php:367
CommonObject\call_trigger
call_trigger($triggerName, $user)
Call trigger based on this instance.
Definition: commonobject.class.php:5818
getDolGlobalInt
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
Definition: functions.lib.php:96
AdherentType\amountByType
amountByType($status=null)
Return the array of all amounts per membership type id.
Definition: adherent_type.class.php:573
AdherentType\setMultiLangs
setMultiLangs($user)
Update or add a translation for this member type.
Definition: adherent_type.class.php:187