dolibarr 20.0.0
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 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 */
23
30require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
31
32
37{
41 public $table_element = 'adherent_type';
42
46 public $element = 'adherent_type';
47
51 public $picto = 'members';
52
58 public $libelle;
59
63 public $label;
64
68 public $morphy;
69
70 public $duration;
71
76
81
85 public $subscription;
86
90 public $amount;
91
95 public $caneditamount;
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
127 public $description;
128
132 public $email;
133
137 public $multilangs = array();
138
139
145 public function __construct($db)
146 {
147 $this->db = $db;
148
149 $this->ismultientitymanaged = 1;
150 $this->status = 1;
151 }
152
158 public function getMultiLangs()
159 {
160 global $langs;
161
162 $current_lang = $langs->getDefaultLang();
163
164 $sql = "SELECT lang, label, description, email";
165 $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang";
166 $sql .= " WHERE fk_type = ".((int) $this->id);
167
168 $result = $this->db->query($sql);
169 if ($result) {
170 while ($obj = $this->db->fetch_object($result)) {
171 //print 'lang='.$obj->lang.' current='.$current_lang.'<br>';
172 if ($obj->lang == $current_lang) { // si on a les traduct. dans la langue courante on les charge en infos principales.
173 $this->label = $obj->label;
174 $this->description = $obj->description;
175 $this->email = $obj->email;
176 }
177 $this->multilangs["$obj->lang"]["label"] = $obj->label;
178 $this->multilangs["$obj->lang"]["description"] = $obj->description;
179 $this->multilangs["$obj->lang"]["email"] = $obj->email;
180 }
181 return 1;
182 } else {
183 $this->error = "Error: ".$this->db->lasterror()." - ".$sql;
184 return -1;
185 }
186 }
187
194 public function setMultiLangs($user)
195 {
196 global $langs;
197
198 $langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 0, 2);
199 $current_lang = $langs->getDefaultLang();
200
201 foreach ($langs_available as $key => $value) {
202 if ($key == $current_lang) {
203 $sql = "SELECT rowid";
204 $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang";
205 $sql .= " WHERE fk_type = ".((int) $this->id);
206 $sql .= " AND lang = '".$this->db->escape($key)."'";
207
208 $result = $this->db->query($sql);
209
210 if ($this->db->num_rows($result)) { // if there is already a description line for this language
211 $sql2 = "UPDATE ".MAIN_DB_PREFIX."adherent_type_lang";
212 $sql2 .= " SET";
213 $sql2 .= " label = '".$this->db->escape($this->label)."',";
214 $sql2 .= " description = '".$this->db->escape($this->description)."'";
215 $sql2 .= " WHERE fk_type = ".((int) $this->id)." AND lang='".$this->db->escape($key)."'";
216 } else {
217 $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type_lang (fk_type, lang, label, description";
218 $sql2 .= ")";
219 $sql2 .= " VALUES(".((int) $this->id).",'".$this->db->escape($key)."','".$this->db->escape($this->label)."',";
220 $sql2 .= " '".$this->db->escape($this->description)."'";
221 $sql2 .= ")";
222 }
223 dol_syslog(get_class($this).'::setMultiLangs key = current_lang = '.$key);
224 if (!$this->db->query($sql2)) {
225 $this->error = $this->db->lasterror();
226 return -1;
227 }
228 } elseif (isset($this->multilangs[$key])) {
229 $sql = "SELECT rowid";
230 $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang";
231 $sql .= " WHERE fk_type = ".((int) $this->id);
232 $sql .= " AND lang = '".$this->db->escape($key)."'";
233
234 $result = $this->db->query($sql);
235
236 if ($this->db->num_rows($result)) { // if there is already a description line for this language
237 $sql2 = "UPDATE ".MAIN_DB_PREFIX."adherent_type_lang";
238 $sql2 .= " SET ";
239 $sql2 .= " label = '".$this->db->escape($this->multilangs["$key"]["label"])."',";
240 $sql2 .= " description = '".$this->db->escape($this->multilangs["$key"]["description"])."'";
241 $sql2 .= " WHERE fk_type = ".((int) $this->id)." AND lang='".$this->db->escape($key)."'";
242 } else {
243 $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type_lang (fk_type, lang, label, description";
244 $sql2 .= ")";
245 $sql2 .= " VALUES(".((int) $this->id).",'".$this->db->escape($key)."','".$this->db->escape($this->multilangs["$key"]["label"])."',";
246 $sql2 .= " '".$this->db->escape($this->multilangs["$key"]["description"])."'";
247 $sql2 .= ")";
248 }
249
250 // We do not save if main fields are empty
251 if ($this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"]) {
252 if (!$this->db->query($sql2)) {
253 $this->error = $this->db->lasterror();
254 return -1;
255 }
256 }
257 } else {
258 // language is not current language and we didn't provide a multilang description for this language
259 }
260 }
261
262 // Call trigger
263 $result = $this->call_trigger('MEMBER_TYPE_SET_MULTILANGS', $user);
264 if ($result < 0) {
265 $this->error = $this->db->lasterror();
266 return -1;
267 }
268 // End call triggers
269
270 return 1;
271 }
272
280 public function delMultiLangs($langtodelete, $user)
281 {
282 $sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_type_lang";
283 $sql .= " WHERE fk_type = ".((int) $this->id)." AND lang = '".$this->db->escape($langtodelete)."'";
284
285 dol_syslog(get_class($this).'::delMultiLangs', LOG_DEBUG);
286 $result = $this->db->query($sql);
287 if ($result) {
288 // Call trigger
289 $result = $this->call_trigger('MEMBER_TYPE_DEL_MULTILANGS', $user);
290 if ($result < 0) {
291 $this->error = $this->db->lasterror();
292 dol_syslog(get_class($this).'::delMultiLangs error='.$this->error, LOG_ERR);
293 return -1;
294 }
295 // End call triggers
296 return 1;
297 } else {
298 $this->error = $this->db->lasterror();
299 dol_syslog(get_class($this).'::delMultiLangs error='.$this->error, LOG_ERR);
300 return -1;
301 }
302 }
303
311 public function create($user, $notrigger = 0)
312 {
313 global $conf;
314
315 $error = 0;
316
317 $this->status = (int) $this->status;
318 $this->label = trim($this->label);
319
320 $this->db->begin();
321
322 $sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type (";
323 $sql .= " morphy";
324 $sql .= ", libelle";
325 $sql .= ", entity";
326 $sql .= ") VALUES (";
327 $sql .= "'".$this->db->escape($this->morphy)."'";
328 $sql .= ", '".$this->db->escape($this->label)."'";
329 $sql .= ", ".((int) $conf->entity);
330 $sql .= ")";
331
332 dol_syslog("Adherent_type::create", LOG_DEBUG);
333 $result = $this->db->query($sql);
334 if ($result) {
335 $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."adherent_type");
336
337 $result = $this->update($user, 1);
338 if ($result < 0) {
339 $this->db->rollback();
340 return -3;
341 }
342
343 if (!$notrigger) {
344 // Call trigger
345 $result = $this->call_trigger('MEMBER_TYPE_CREATE', $user);
346 if ($result < 0) {
347 $error++;
348 }
349 // End call triggers
350 }
351
352 if (!$error) {
353 $this->db->commit();
354 return $this->id;
355 } else {
356 dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
357 $this->db->rollback();
358 return -2;
359 }
360 } else {
361 $this->error = $this->db->lasterror();
362 $this->db->rollback();
363 return -1;
364 }
365 }
366
374 public function update($user, $notrigger = 0)
375 {
376 global $langs;
377
378 $error = 0;
379
380 $this->label = trim($this->label);
381
382 if (empty($this->note_public) && !empty($this->note)) { // For backward compatibility
383 $this->note_public = $this->note;
384 }
385
386 $this->db->begin();
387
388 $sql = "UPDATE ".MAIN_DB_PREFIX."adherent_type ";
389 $sql .= "SET ";
390 $sql .= "statut = ".((int) $this->status).",";
391 $sql .= "libelle = '".$this->db->escape($this->label)."',";
392 $sql .= "morphy = '".$this->db->escape($this->morphy)."',";
393 $sql .= "subscription = '".$this->db->escape($this->subscription)."',";
394 $sql .= "amount = ".((empty($this->amount) && $this->amount == '') ? "null" : ((float) $this->amount)).",";
395 $sql .= "caneditamount = ".((int) $this->caneditamount).",";
396 $sql .= "duration = '".$this->db->escape($this->duration_value.$this->duration_unit)."',";
397 $sql .= "note = '".$this->db->escape($this->note_public)."',";
398 $sql .= "vote = ".(int) $this->db->escape($this->vote).",";
399 $sql .= "mail_valid = '".$this->db->escape($this->mail_valid)."'";
400 $sql .= " WHERE rowid =".((int) $this->id);
401
402 $result = $this->db->query($sql);
403 if ($result) {
404 $this->description = $this->db->escape($this->note_public);
405
406 // Multilangs
407 if (getDolGlobalInt('MAIN_MULTILANGS')) {
408 if ($this->setMultiLangs($user) < 0) {
409 $this->error = $langs->trans("Error")." : ".$this->db->error()." - ".$sql;
410 return -2;
411 }
412 }
413
414 // Actions on extra fields
415 if (!$error) {
416 $result = $this->insertExtraFields();
417 if ($result < 0) {
418 $error++;
419 }
420 }
421
422 if (!$error && !$notrigger) {
423 // Call trigger
424 $result = $this->call_trigger('MEMBER_TYPE_MODIFY', $user);
425 if ($result < 0) {
426 $error++;
427 }
428 // End call triggers
429 }
430
431 if (!$error) {
432 $this->db->commit();
433 return 1;
434 } else {
435 $this->db->rollback();
436 dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR);
437 return -$error;
438 }
439 } else {
440 $this->error = $this->db->lasterror();
441 $this->db->rollback();
442 return -1;
443 }
444 }
445
452 public function delete($user)
453 {
454 $error = 0;
455
456 $sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_type";
457 $sql .= " WHERE rowid = ".((int) $this->id);
458
459 $resql = $this->db->query($sql);
460 if ($resql) {
461 // Call trigger
462 $result = $this->call_trigger('MEMBER_TYPE_DELETE', $user);
463 if ($result < 0) {
464 $error++;
465 $this->db->rollback();
466 return -2;
467 }
468 // End call triggers
469
470 $this->db->commit();
471 return 1;
472 } else {
473 $this->db->rollback();
474 $this->error = $this->db->lasterror();
475 return -1;
476 }
477 }
478
485 public function fetch($rowid)
486 {
487 $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";
488 $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d";
489 $sql .= " WHERE d.rowid = ".(int) $rowid;
490
491 dol_syslog("Adherent_type::fetch", LOG_DEBUG);
492
493 $resql = $this->db->query($sql);
494 if ($resql) {
495 if ($this->db->num_rows($resql)) {
496 $obj = $this->db->fetch_object($resql);
497
498 $this->id = $obj->rowid;
499 $this->ref = $obj->rowid;
500 $this->label = $obj->label;
501 $this->morphy = $obj->morphy;
502 $this->status = $obj->status;
503 $this->duration = $obj->duration;
504 $this->duration_value = substr($obj->duration, 0, dol_strlen($obj->duration) - 1);
505 $this->duration_unit = substr($obj->duration, -1);
506 $this->subscription = $obj->subscription;
507 $this->amount = $obj->amount;
508 $this->caneditamount = $obj->caneditamount;
509 $this->mail_valid = $obj->mail_valid;
510 $this->note = $obj->note_public; // deprecated
511 $this->note_public = $obj->note_public;
512 $this->vote = $obj->vote;
513
514 // multilangs
515 if (getDolGlobalInt('MAIN_MULTILANGS')) {
516 $this->getMultiLangs();
517 }
518
519 // fetch optionals attributes and labels
520 $this->fetch_optionals();
521 return $this->id;
522 } else {
523 return 0;
524 }
525 } else {
526 $this->error = $this->db->lasterror();
527 return -1;
528 }
529 }
530
531 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
538 public function liste_array($status = -1)
539 {
540 // phpcs:enable
541 global $langs;
542
543 $adherenttypes = array();
544
545 $sql = "SELECT rowid, libelle as label";
546 $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type";
547 $sql .= " WHERE entity IN (".getEntity('member_type').")";
548 if ($status >= 0) {
549 $sql .= " AND statut = ".((int) $status);
550 }
551
552 $resql = $this->db->query($sql);
553 if ($resql) {
554 $nump = $this->db->num_rows($resql);
555
556 if ($nump) {
557 $i = 0;
558 while ($i < $nump) {
559 $obj = $this->db->fetch_object($resql);
560
561 $adherenttypes[$obj->rowid] = $langs->trans($obj->label);
562 $i++;
563 }
564 }
565 } else {
566 print $this->db->error();
567 }
568 return $adherenttypes;
569 }
570
577 public function amountByType($status = null)
578 {
579 $amountbytype = array();
580
581 $sql = "SELECT rowid, amount";
582 $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type";
583 $sql .= " WHERE entity IN (".getEntity('member_type').")";
584 if ($status !== null) {
585 $sql .= " AND statut = ".((int) $status);
586 }
587
588 $resql = $this->db->query($sql);
589 if ($resql) {
590 $nump = $this->db->num_rows($resql);
591
592 if ($nump) {
593 $i = 0;
594 while ($i < $nump) {
595 $obj = $this->db->fetch_object($resql);
596
597 $amountbytype[$obj->rowid] = $obj->amount;
598 $i++;
599 }
600 }
601 } else {
602 print $this->db->error();
603 }
604
605 return $amountbytype;
606 }
607
617 public function listMembersForMemberType($excludefilter = '', $mode = 0)
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
684 public function getTooltipContentArray($params)
685 {
686 global $langs;
687
688 $langs->load('members');
689
690 $datas = [];
691 $datas['picto'] = img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("MemberType").'</u> '.$this->getLibStatut(4);
692 $datas['label'] = '<br>'.$langs->trans("Label").': '.$this->label;
693 if (isset($this->subscription)) {
694 $datas['subscription'] = '<br>'.$langs->trans("SubscriptionRequired").': '.yn($this->subscription);
695 }
696 if (isset($this->vote)) {
697 $datas['vote'] = '<br>'.$langs->trans("VoteAllowed").': '.yn($this->vote);
698 }
699 if (isset($this->duration)) {
700 $datas['duration'] = '<br>'.$langs->trans("Duration").': '.$this->duration_value;
701 if ($this->duration_value > 1) {
702 $dur = array("i"=>$langs->trans("Minutes"), "h"=>$langs->trans("Hours"), "d"=>$langs->trans("Days"), "w"=>$langs->trans("Weeks"), "m"=>$langs->trans("Months"), "y"=>$langs->trans("Years"));
703 } elseif ($this->duration_value > 0) {
704 $dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hour"), "d"=>$langs->trans("Day"), "w"=>$langs->trans("Week"), "m"=>$langs->trans("Month"), "y"=>$langs->trans("Year"));
705 }
706 $datas['duration'] .= "&nbsp;" . (!empty($this->duration_unit) && isset($dur[$this->duration_unit]) ? $langs->trans($dur[$this->duration_unit]) : '');
707 }
708
709 return $datas;
710 }
711
722 public function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
723 {
724 $result = '';
725 $option = '';
726
727 $classfortooltip = 'classfortooltip';
728 $dataparams = '';
729 $params = [
730 'id' => $this->id,
731 'objecttype' => $this->element,
732 'option' => $option,
733 'nofetch' => 1,
734 ];
735 if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
736 $classfortooltip = 'classforajaxtooltip';
737 $dataparams = ' data-params="'.dol_escape_htmltag(json_encode($params)).'"';
738 $label = '';
739 } else {
740 $label = implode($this->getTooltipContentArray($params));
741 }
742
743 $url = DOL_URL_ROOT.'/adherents/type.php?rowid='.((int) $this->id);
744 if ($option != 'nolink') {
745 // Add param to save lastsearch_values or not
746 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
747 if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
748 $add_save_lastsearch_values = 1;
749 }
750 if ($add_save_lastsearch_values) {
751 $url .= '&save_lastsearch_values=1';
752 }
753 }
754 $linkstart = '<a href="'.$url.'"';
755 $linkstart .= ($label ? ' title="'.dol_escape_htmltag($label, 1).'"' : ' title="tocomplete"');
756 $linkstart .= $dataparams.' class="'.$classfortooltip.'">';
757
758 $linkend = '</a>';
759
760 $result .= $linkstart;
761 if ($withpicto) {
762 $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (' class="'.(($withpicto != 2) ? 'paddingright' : '').'"'), 0, 0, $notooltip ? 0 : 1);
763 }
764 if ($withpicto != 2) {
765 $result .= ($maxlen ? dol_trunc($this->label, $maxlen) : $this->label);
766 }
767 $result .= $linkend;
768
769 return $result;
770 }
771
778 public function getLibStatut($mode = 0)
779 {
780 return $this->LibStatut($this->status, $mode);
781 }
782
783 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
791 public function LibStatut($status, $mode = 0)
792 {
793 // phpcs:enable
794 global $langs;
795 $langs->load('companies');
796
797 $statusType = 'status4';
798 if ($status == 0) {
799 $statusType = 'status5';
800 }
801
802 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
803 $this->labelStatus[0] = $langs->transnoentitiesnoconv("ActivityCeased");
804 $this->labelStatus[1] = $langs->transnoentitiesnoconv("InActivity");
805 $this->labelStatusShort[0] = $langs->transnoentitiesnoconv("ActivityCeased");
806 $this->labelStatusShort[1] = $langs->transnoentitiesnoconv("InActivity");
807 }
808
809 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
810 }
811
812 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
813 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
823 public function _load_ldap_dn($info, $mode = 0)
824 {
825 // phpcs:enable
826 $dn = '';
827 if ($mode == 0) {
828 $dn = getDolGlobalString('LDAP_KEY_MEMBERS_TYPES') . "=".$info[getDolGlobalString('LDAP_KEY_MEMBERS_TYPES')]."," . getDolGlobalString('LDAP_MEMBER_TYPE_DN');
829 }
830 if ($mode == 1) {
831 $dn = getDolGlobalString('LDAP_MEMBER_TYPE_DN');
832 }
833 if ($mode == 2) {
834 $dn = getDolGlobalString('LDAP_KEY_MEMBERS_TYPES') . "=".$info[getDolGlobalString('LDAP_KEY_MEMBERS_TYPES')];
835 }
836 return $dn;
837 }
838
839
840 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
841 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
847 public function _load_ldap_info()
848 {
849 // phpcs:enable
850 $info = array();
851
852 // Object classes
853 $info["objectclass"] = explode(',', getDolGlobalString('LDAP_MEMBER_TYPE_OBJECT_CLASS'));
854
855 if (empty($this->note_public) && !empty($this->note)) { // For backward compatibility
856 $this->note_public = $this->note;
857 }
858
859 // Champs
860 if ($this->label && getDolGlobalString('LDAP_MEMBER_TYPE_FIELD_FULLNAME')) {
861 $info[getDolGlobalString('LDAP_MEMBER_TYPE_FIELD_FULLNAME')] = $this->label;
862 }
863 if ($this->note_public && getDolGlobalString('LDAP_MEMBER_TYPE_FIELD_DESCRIPTION')) {
864 $info[getDolGlobalString('LDAP_MEMBER_TYPE_FIELD_DESCRIPTION')] = dol_string_nohtmltag($this->note_public, 0, 'UTF-8', 1);
865 }
866 if (getDolGlobalString('LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS')) {
867 $valueofldapfield = array();
868 foreach ($this->members as $key => $val) { // This is array of users for group into dolibarr database.
869 $member = new Adherent($this->db);
870 $member->fetch($val->id, '', '', '', false, false);
871 $info2 = $member->_load_ldap_info();
872 $valueofldapfield[] = $member->_load_ldap_dn($info2);
873 }
874 $info[getDolGlobalString('LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS')] = (!empty($valueofldapfield) ? $valueofldapfield : '');
875 }
876 return $info;
877 }
878
886 public function initAsSpecimen()
887 {
888 global $user;
889
890 // Initialise parameters
891 $this->id = 0;
892 $this->ref = 'MTSPEC';
893 $this->specimen = 1;
894
895 $this->label = 'MEMBERS TYPE SPECIMEN';
896 $this->note_public = 'This is a public note';
897 $this->mail_valid = 'This is welcome email';
898 $this->subscription = 1;
899 $this->caneditamount = 0;
900 $this->vote = 0;
901
902 $this->status = 1;
903
904 // Members of this member type is just me
905 $this->members = array(
906 $user->id => $user
907 );
908
909 return 1;
910 }
911
917 public function getMailOnValid()
918 {
919 if (!empty($this->mail_valid) && trim(dol_htmlentitiesbr_decode($this->mail_valid))) {
920 return $this->mail_valid;
921 }
922
923 return '';
924 }
925
931 public function getMailOnSubscription()
932 {
933 // mail_subscription not defined so never used
934 if (!empty($this->mail_subscription) && trim(dol_htmlentitiesbr_decode($this->mail_subscription))) { // Property not yet defined
935 return $this->mail_subscription;
936 }
937
938 return '';
939 }
940
946 public function getMailOnResiliate()
947 {
948 // NOTE mail_resiliate not defined so never used
949 if (!empty($this->mail_resiliate) && trim(dol_htmlentitiesbr_decode($this->mail_resiliate))) { // Property not yet defined
950 return $this->mail_resiliate;
951 }
952
953 return '';
954 }
955
961 public function getMailOnExclude()
962 {
963 // NOTE mail_exclude not defined so never used
964 if (!empty($this->mail_exclude) && trim(dol_htmlentitiesbr_decode($this->mail_exclude))) { // Property not yet defined
965 return $this->mail_exclude;
966 }
967
968 return '';
969 }
970
971
979 public function getKanbanView($option = '', $arraydata = null)
980 {
981 global $langs, $user;
982
983 //$selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']);
984
985 $return = '<div class="box-flex-item box-flex-grow-zero">';
986 $return .= '<div class="info-box info-box-sm">';
987 $return .= '<span class="info-box-icon bg-infobox-action">';
988 $return .= img_picto('', $this->picto);
989 $return .= '</span>';
990 $return .= '<div class="info-box-content">';
991 $return .= '<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).'</span>';
992
993 //$return .= '<input id="cb'.$this->id.'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->id.'"'.($selected ? ' checked="checked"' : '').'>';
994
995 if ($user->hasRight('adherent', 'configurer')) {
996 $return .= '<span class="right paddingleft"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=edit&rowid='.urlencode($this->ref).'">'.img_edit().'</a></span>';
997 } else {
998 $return .= '<span class="right">&nbsp;</span>';
999 }
1000 if (property_exists($this, 'vote')) {
1001 $return .= '<br><span class="info-box-label opacitymedium">'.$langs->trans("VoteAllowed").' : '.yn($this->vote).'</span>';
1002 }
1003 if (property_exists($this, 'amount')) {
1004 if (is_null($this->amount) || $this->amount === '') {
1005 $return .= '<br>';
1006 } else {
1007 $return .= '<br><span class="info-box-label opacitymedium">'.$langs->trans("Amount").'</span>';
1008 $return .= '<span class="amount"> : '.price($this->amount).'</span>';
1009 }
1010 }
1011 if (method_exists($this, 'getLibStatut')) {
1012 $return .= '<br><div class="info-box-status">'.$this->getLibStatut(3).'</div>';
1013 }
1014 $return .= '</div>';
1015 $return .= '</div>';
1016 $return .= '</div>';
1017 return $return;
1018 }
1019}
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
Or an array listing all the potential status of the object: array: int of the status => translated la...
Definition security.php:637
$object ref
Definition info.php:79
Class to manage members of a foundation.
Class to manage members type.
amountByType($status=null)
Return the array of all amounts per membership type id.
__construct($db)
Constructor.
getKanbanView($option='', $arraydata=null)
Return clicable link of object (with eventually picto)
update($user, $notrigger=0)
Updating the type in the database.
$duration_unit
Expiration unit.
getMailOnExclude()
getMailOnExclude
fetch($rowid)
Function that retrieves the properties of a membership type.
getNomUrl($withpicto=0, $maxlen=0, $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return clicable name (with picto eventually)
create($user, $notrigger=0)
Function to create the member type.
getTooltipContentArray($params)
getTooltipContentArray
setMultiLangs($user)
Update or add a translation for this member type.
getMailOnValid()
getMailOnValid
getMailOnSubscription()
getMailOnSubscription
initAsSpecimen()
Initialise an instance with random values.
liste_array($status=-1)
Return list of members' type.
getLibStatut($mode=0)
Return label of status (activity, closed)
delMultiLangs($langtodelete, $user)
Delete a language for this member type.
_load_ldap_info()
Initialize the info array (array of LDAP values) that will be used to call LDAP functions.
getmorphylib($morphy='')
Return translated label by the nature of a adherent (physical or moral)
$duration_value
type expiration
getMultiLangs()
Load array this->multilangs.
getMailOnResiliate()
getMailOnResiliate
LibStatut($status, $mode=0)
Return the label of a given status.
_load_ldap_dn($info, $mode=0)
Retourne chaine DN complete dans l'annuaire LDAP pour l'objet.
listMembersForMemberType($excludefilter='', $mode=0)
Return array of Member objects for member type this->id (or all if this->id not defined)
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...
insertExtraFields($trigger='', $userused=null)
Add/Update all extra fields values for the current object.
call_trigger($triggerName, $user)
Call trigger based on this instance.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_htmlentitiesbr_decode($stringtodecode, $pagecodeto='UTF-8')
This function is called to decode a HTML string (it decodes entities and br tags)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.