dolibarr 20.0.0
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 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
27include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php';
28
29
34{
35 public $boxcode = "box_members_last_modified";
36 public $boximg = "object_user";
37 public $boxlabel = "BoxLastModifiedMembers";
38 public $depends = array("adherent");
39
40 public $enabled = 1;
41
48 public function __construct($db, $param = '')
49 {
50 global $conf, $user;
51
52 $this->db = $db;
53
54 // disable module for such cases
55 $listofmodulesforexternal = explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL'));
56 if (!in_array('adherent', $listofmodulesforexternal) && !empty($user->socid)) {
57 $this->enabled = 0; // disabled for external users
58 }
59
60 $this->hidden = !(isModEnabled('member') && $user->hasRight('adherent', 'lire'));
61 }
62
69 public function loadBox($max = 5)
70 {
71 global $user, $langs, $conf;
72 $langs->load("boxes");
73
74 $this->max = $max;
75
76 include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
77 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
78 $memberstatic = new Adherent($this->db);
79 $statictype = new AdherentType($this->db);
80
81 $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedMembers", $max));
82
83 if ($user->hasRight('adherent', 'lire')) {
84 $sql = "SELECT a.rowid, a.ref, a.lastname, a.firstname, a.societe as company, a.fk_soc,";
85 $sql .= " a.datec, a.tms as datem, a.statut as status, a.datefin as date_end_subscription,";
86 $sql .= ' a.photo, a.email, a.gender, a.morphy,';
87 $sql .= " t.rowid as typeid, t.subscription, t.libelle as label";
88 $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as t";
89 $sql .= " WHERE a.entity IN (".getEntity('member').")";
90 $sql .= " AND a.fk_adherent_type = t.rowid";
91 $sql .= " ORDER BY a.tms DESC";
92 $sql .= $this->db->plimit($max, 0);
93
94 $result = $this->db->query($sql);
95 if ($result) {
96 $num = $this->db->num_rows($result);
97
98 $line = 0;
99 while ($line < $num) {
100 $objp = $this->db->fetch_object($result);
101 $datec = $this->db->jdate($objp->datec);
102 $datem = $this->db->jdate($objp->datem);
103
104 $memberstatic->lastname = $objp->lastname;
105 $memberstatic->firstname = $objp->firstname;
106 $memberstatic->id = $objp->rowid;
107 $memberstatic->ref = $objp->ref;
108 $memberstatic->photo = $objp->photo;
109 $memberstatic->gender = $objp->gender;
110 $memberstatic->email = $objp->email;
111 $memberstatic->morphy = $objp->morphy;
112 $memberstatic->company = $objp->company;
113 $memberstatic->status = $objp->status;
114 $memberstatic->date_creation = $datec;
115 $memberstatic->date_modification = $datem;
116 $memberstatic->need_subscription = $objp->subscription;
117 $memberstatic->datefin = $this->db->jdate($objp->date_end_subscription);
118 if (!empty($objp->fk_soc)) {
119 $memberstatic->socid = $objp->fk_soc;
120 $memberstatic->fetch_thirdparty();
121 $memberstatic->name = $memberstatic->thirdparty->name;
122 } else {
123 $memberstatic->name = $objp->company;
124 }
125 $statictype->id = $objp->typeid;
126 $statictype->label = $objp->label;
127 $statictype->subscription = $objp->subscription;
128
129 $this->info_box_contents[$line][] = array(
130 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"',
131 'text' => $memberstatic->getNomUrl(-1),
132 'asis' => 1,
133 );
134
135 $this->info_box_contents[$line][] = array(
136 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"',
137 'text' =>$memberstatic->company,
138 );
139
140 $this->info_box_contents[$line][] = array(
141 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"',
142 'text' => $statictype->getNomUrl(1, 32),
143 'asis' => 1,
144 );
145
146 $this->info_box_contents[$line][] = array(
147 'td' => 'class="center nowraponall" title="'.dol_escape_htmltag($langs->trans("DateModification").': '.dol_print_date($datem, 'dayhour', 'tzuserrel')).'"',
148 'text' => dol_print_date($datem, "day", 'tzuserrel'),
149 );
150
151 $this->info_box_contents[$line][] = array(
152 'td' => 'class="right" width="18"',
153 'text' => $memberstatic->LibStatut($objp->status, $objp->subscription, $this->db->jdate($objp->date_end_subscription), 3),
154 );
155
156 $line++;
157 }
158
159 if ($num == 0) {
160 $this->info_box_contents[$line][0] = array(
161 'td' => 'class="center"',
162 'text'=>$langs->trans("NoRecordedCustomers"),
163 );
164 }
165
166 $this->db->free($result);
167 } else {
168 $this->info_box_contents[0][0] = array(
169 'td' => '',
170 'maxlength'=>500,
171 'text' => ($this->db->error().' sql='.$sql),
172 );
173 }
174 } else {
175 $this->info_box_contents[0][0] = array(
176 'td' => 'class="nohover left"',
177 'text' => '<span class="opacitymedium">'.$langs->trans("ReadPermissionNotAllowed").'</span>'
178 );
179 }
180 }
181
190 public function showBox($head = null, $contents = null, $nooutput = 0)
191 {
192 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
193 }
194}
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 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...