dolibarr 23.0.3
box_members_last_modified.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2015-2025 Frédéric France <frederic.france@free.fr>
6 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
28include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php';
29
30
35{
36 public $boxcode = "box_members_last_modified";
37 public $boximg = "object_user";
38 public $boxlabel = "BoxLastModifiedMembers";
39 public $depends = array("adherent");
40
41 public $enabled = 1;
42
49 public function __construct($db, $param = '')
50 {
51 global $conf, $user;
52
53 $this->db = $db;
54
55 // disable module for such cases
56 $listofmodulesforexternal = explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL'));
57 if (!in_array('adherent', $listofmodulesforexternal) && !empty($user->socid)) {
58 $this->enabled = 0; // disabled for external users
59 }
60
61 $this->hidden = !(isModEnabled('member') && $user->hasRight('adherent', 'lire'));
62 }
63
70 public function loadBox($max = 5)
71 {
72 global $user, $langs, $conf;
73 $langs->load("boxes");
74
75 $this->max = $max;
76
77 include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
78 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
79 $memberstatic = new Adherent($this->db);
80 $statictype = new AdherentType($this->db);
81
82 $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedMembers", $max));
83
84 if ($user->hasRight('adherent', 'lire')) {
85 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherentstats.class.php';
86 $stats = new AdherentStats($this->db, $user->socid, $user->id);
87 // Show array
88 $listOfMembers = $stats->getLastModifiedMembers($max);
89 $line = 0;
90 $num = count($listOfMembers);
91 foreach ($listOfMembers as $data) {
92 $memberstatic->lastname = $data['lastname'];
93 $memberstatic->firstname = $data['firstname'];
94 $memberstatic->id = $data['id'];
95 $memberstatic->ref = $data['ref'];
96 $memberstatic->photo = $data['photo'];
97 $memberstatic->gender = $data['gender'];
98 $memberstatic->email = $data['email'];
99 $memberstatic->morphy = $data['morphy'];
100 $memberstatic->company = $data['company'];
101 $memberstatic->status = $data['status'];
102 $memberstatic->date_creation = $data['datec'];
103 $memberstatic->date_modification = $data['datem'];
104 $memberstatic->need_subscription = (int) $data['need_subscription'];
105 $memberstatic->datefin = $data['date_end_subscription'];
106 if (!empty($data['fk_soc'])) {
107 $memberstatic->socid = $data['fk_soc'];
108 $memberstatic->fetch_thirdparty();
109 $memberstatic->name = $memberstatic->thirdparty->name;
110 } else {
111 $memberstatic->name = $data['company'];
112 }
113 $statictype->id = $data['typeid'];
114 $statictype->label = $data['label'];
115 $statictype->subscription = $data['subscription'];
116
117 $this->info_box_contents[$line][] = array(
118 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"',
119 'text' => $memberstatic->getNomUrl(-1),
120 'asis' => 1,
121 );
122
123 $this->info_box_contents[$line][] = array(
124 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"',
125 'text' => $memberstatic->company,
126 );
127
128 $this->info_box_contents[$line][] = array(
129 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"',
130 'text' => $statictype->getNomUrl(1, 32),
131 'asis' => 1,
132 );
133
134 $this->info_box_contents[$line][] = array(
135 'td' => 'class="center nowraponall" title="'.dol_escape_htmltag($langs->trans("DateModification").': '.dol_print_date($data['datem'], 'dayhour', 'tzuserrel')).'"',
136 'text' => dol_print_date($data['datem'], "day", 'tzuserrel'),
137 );
138
139 $this->info_box_contents[$line][] = array(
140 'td' => 'class="right" width="18"',
141 'text' => $memberstatic->LibStatut($data['status'], $data['need_subscription'], $data['date_end_subscription'], 3),
142 );
143 $line ++;
144 }
145
146 if ($num == 0) {
147 $this->info_box_contents[$line][0] = array(
148 'td' => 'class="center"',
149 'text' => $langs->trans("NoRecordedCustomers"),
150 );
151 }
152 } else {
153 $this->info_box_contents[0][0] = array(
154 'td' => 'class="nohover left"',
155 'text' => '<span class="opacitymedium">'.$langs->trans("ReadPermissionNotAllowed").'</span>'
156 );
157 }
158 }
159
160
161
170 public function showBox($head = null, $contents = null, $nooutput = 0)
171 {
172 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
173 }
174}
Class to manage members of a foundation.
Class to manage statistics of members.
Class to manage members type.
Class ModeleBoxes.
Class to manage the box to show last modified members.
loadBox($max=5)
Load data into info_box_contents array to show array later.
__construct($db, $param='')
Constructor.
showBox($head=null, $contents=null, $nooutput=0)
Method to show box.
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).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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...