dolibarr 19.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-2020 Frederic France <frederic.france@netlogic.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
43 public $db;
44
45 public $param;
46 public $enabled = 1;
47
48 public $info_box_head = array();
49 public $info_box_contents = array();
50
51
58 public function __construct($db, $param = '')
59 {
60 global $conf, $user;
61
62 $this->db = $db;
63
64 // disable module for such cases
65 $listofmodulesforexternal = explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL'));
66 if (!in_array('adherent', $listofmodulesforexternal) && !empty($user->socid)) {
67 $this->enabled = 0; // disabled for external users
68 }
69
70 $this->hidden = !(isModEnabled('adherent') && $user->hasRight('adherent', 'lire'));
71 }
72
79 public function loadBox($max = 5)
80 {
81 global $user, $langs, $conf;
82 $langs->load("boxes");
83
84 $this->max = $max;
85
86 include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
87 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
88 $memberstatic = new Adherent($this->db);
89 $statictype = new AdherentType($this->db);
90
91 $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedMembers", $max));
92
93 if ($user->hasRight('adherent', 'lire')) {
94 $sql = "SELECT a.rowid, a.ref, a.lastname, a.firstname, a.societe as company, a.fk_soc,";
95 $sql .= " a.datec, a.tms as datem, a.statut as status, a.datefin as date_end_subscription,";
96 $sql .= ' a.photo, a.email, a.gender, a.morphy,';
97 $sql .= " t.rowid as typeid, t.subscription, t.libelle as label";
98 $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as t";
99 $sql .= " WHERE a.entity IN (".getEntity('member').")";
100 $sql .= " AND a.fk_adherent_type = t.rowid";
101 $sql .= " ORDER BY a.tms DESC";
102 $sql .= $this->db->plimit($max, 0);
103
104 $result = $this->db->query($sql);
105 if ($result) {
106 $num = $this->db->num_rows($result);
107
108 $line = 0;
109 while ($line < $num) {
110 $objp = $this->db->fetch_object($result);
111 $datec = $this->db->jdate($objp->datec);
112 $datem = $this->db->jdate($objp->datem);
113
114 $memberstatic->lastname = $objp->lastname;
115 $memberstatic->firstname = $objp->firstname;
116 $memberstatic->id = $objp->rowid;
117 $memberstatic->ref = $objp->ref;
118 $memberstatic->photo = $objp->photo;
119 $memberstatic->gender = $objp->gender;
120 $memberstatic->email = $objp->email;
121 $memberstatic->morphy = $objp->morphy;
122 $memberstatic->company = $objp->company;
123 $memberstatic->statut = $objp->status;
124 $memberstatic->date_creation = $datec;
125 $memberstatic->date_modification = $datem;
126 $memberstatic->need_subscription = $objp->subscription;
127 $memberstatic->datefin = $this->db->jdate($objp->date_end_subscription);
128 if (!empty($objp->fk_soc)) {
129 $memberstatic->socid = $objp->fk_soc;
130 $memberstatic->fetch_thirdparty();
131 $memberstatic->name = $memberstatic->thirdparty->name;
132 } else {
133 $memberstatic->name = $objp->company;
134 }
135 $statictype->id = $objp->typeid;
136 $statictype->label = $objp->label;
137 $statictype->subscription = $objp->subscription;
138
139 $this->info_box_contents[$line][] = array(
140 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"',
141 'text' => $memberstatic->getNomUrl(-1),
142 'asis' => 1,
143 );
144
145 $this->info_box_contents[$line][] = array(
146 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"',
147 'text' =>$memberstatic->company,
148 );
149
150 $this->info_box_contents[$line][] = array(
151 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"',
152 'text' => $statictype->getNomUrl(1, 32),
153 'asis' => 1,
154 );
155
156 $this->info_box_contents[$line][] = array(
157 'td' => 'class="center nowraponall" title="'.dol_escape_htmltag($langs->trans("DateModification").': '.dol_print_date($datem, 'dayhour', 'tzuserrel')).'"',
158 'text' => dol_print_date($datem, "day", 'tzuserrel'),
159 );
160
161 $this->info_box_contents[$line][] = array(
162 'td' => 'class="right" width="18"',
163 'text' => $memberstatic->LibStatut($objp->status, $objp->subscription, $this->db->jdate($objp->date_end_subscription), 3),
164 );
165
166 $line++;
167 }
168
169 if ($num == 0) {
170 $this->info_box_contents[$line][0] = array(
171 'td' => 'class="center"',
172 'text'=>$langs->trans("NoRecordedCustomers"),
173 );
174 }
175
176 $this->db->free($result);
177 } else {
178 $this->info_box_contents[0][0] = array(
179 'td' => '',
180 'maxlength'=>500,
181 'text' => ($this->db->error().' sql='.$sql),
182 );
183 }
184 } else {
185 $this->info_box_contents[0][0] = array(
186 'td' => 'class="nohover left"',
187 'text' => '<span class="opacitymedium">'.$langs->trans("ReadPermissionNotAllowed").'</span>'
188 );
189 }
190 }
191
200 public function showBox($head = null, $contents = null, $nooutput = 0)
201 {
202 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
203 }
204}
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='', $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...