dolibarr 21.0.0-beta
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-2024 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 $sql = "SELECT a.rowid, a.ref, a.lastname, a.firstname, a.societe as company, a.fk_soc,";
86 $sql .= " a.datec, a.tms as datem, a.statut as status, a.datefin as date_end_subscription,";
87 $sql .= ' a.photo, a.email, a.gender, a.morphy,';
88 $sql .= " t.rowid as typeid, t.subscription, t.libelle as label";
89 $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as t";
90 $sql .= " WHERE a.entity IN (".getEntity('member').")";
91 $sql .= " AND a.fk_adherent_type = t.rowid";
92 $sql .= " ORDER BY a.tms DESC";
93 $sql .= $this->db->plimit($max, 0);
94
95 $result = $this->db->query($sql);
96 if ($result) {
97 $num = $this->db->num_rows($result);
98
99 $line = 0;
100 while ($line < $num) {
101 $objp = $this->db->fetch_object($result);
102 $datec = $this->db->jdate($objp->datec);
103 $datem = $this->db->jdate($objp->datem);
104
105 $memberstatic->lastname = $objp->lastname;
106 $memberstatic->firstname = $objp->firstname;
107 $memberstatic->id = $objp->rowid;
108 $memberstatic->ref = $objp->ref;
109 $memberstatic->photo = $objp->photo;
110 $memberstatic->gender = $objp->gender;
111 $memberstatic->email = $objp->email;
112 $memberstatic->morphy = $objp->morphy;
113 $memberstatic->company = $objp->company;
114 $memberstatic->status = $objp->status;
115 $memberstatic->date_creation = $datec;
116 $memberstatic->date_modification = $datem;
117 $memberstatic->need_subscription = $objp->subscription;
118 $memberstatic->datefin = $this->db->jdate($objp->date_end_subscription);
119 if (!empty($objp->fk_soc)) {
120 $memberstatic->socid = $objp->fk_soc;
121 $memberstatic->fetch_thirdparty();
122 $memberstatic->name = $memberstatic->thirdparty->name;
123 } else {
124 $memberstatic->name = $objp->company;
125 }
126 $statictype->id = $objp->typeid;
127 $statictype->label = $objp->label;
128 $statictype->subscription = $objp->subscription;
129
130 $this->info_box_contents[$line][] = array(
131 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"',
132 'text' => $memberstatic->getNomUrl(-1),
133 'asis' => 1,
134 );
135
136 $this->info_box_contents[$line][] = array(
137 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"',
138 'text' => $memberstatic->company,
139 );
140
141 $this->info_box_contents[$line][] = array(
142 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"',
143 'text' => $statictype->getNomUrl(1, 32),
144 'asis' => 1,
145 );
146
147 $this->info_box_contents[$line][] = array(
148 'td' => 'class="center nowraponall" title="'.dol_escape_htmltag($langs->trans("DateModification").': '.dol_print_date($datem, 'dayhour', 'tzuserrel')).'"',
149 'text' => dol_print_date($datem, "day", 'tzuserrel'),
150 );
151
152 $this->info_box_contents[$line][] = array(
153 'td' => 'class="right" width="18"',
154 'text' => $memberstatic->LibStatut($objp->status, $objp->subscription, $this->db->jdate($objp->date_end_subscription), 3),
155 );
156
157 $line++;
158 }
159
160 if ($num == 0) {
161 $this->info_box_contents[$line][0] = array(
162 'td' => 'class="center"',
163 'text' => $langs->trans("NoRecordedCustomers"),
164 );
165 }
166
167 $this->db->free($result);
168 } else {
169 $this->info_box_contents[0][0] = array(
170 'td' => '',
171 'maxlength' => 500,
172 'text' => ($this->db->error().' sql='.$sql),
173 );
174 }
175 } else {
176 $this->info_box_contents[0][0] = array(
177 'td' => 'class="nohover left"',
178 'text' => '<span class="opacitymedium">'.$langs->trans("ReadPermissionNotAllowed").'</span>'
179 );
180 }
181 }
182
183
184
193 public function showBox($head = null, $contents = null, $nooutput = 0)
194 {
195 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
196 }
197}
Class to manage members of a foundation.
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)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79