dolibarr  17.0.4
member.lib.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2006-2015 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2015-2016 Alexandre Spangaro <aspangaro@open-dsi.fr>
4  * Copyright (C) 2015 RaphaĆ«l Doursenaud <rdoursenaud@gpcsolutions.fr>
5  * Copyright (C) 2017 Regis Houssin <regis.houssin@inodbox.com>
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  * or see https://www.gnu.org/
20  */
21 
33 function member_prepare_head(Adherent $object)
34 {
35  global $db, $langs, $conf, $user;
36 
37  $h = 0;
38  $head = array();
39 
40  $head[$h][0] = DOL_URL_ROOT.'/adherents/card.php?rowid='.$object->id;
41  $head[$h][1] = $langs->trans("Member");
42  $head[$h][2] = 'general';
43  $h++;
44 
45  if ((!empty($conf->ldap->enabled) && !empty($conf->global->LDAP_MEMBER_ACTIVE))
46  && (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || !empty($user->admin))) {
47  $langs->load("ldap");
48 
49  $head[$h][0] = DOL_URL_ROOT.'/adherents/ldap.php?id='.$object->id;
50  $head[$h][1] = $langs->trans("LDAPCard");
51  $head[$h][2] = 'ldap';
52  $h++;
53  }
54 
55  if (!empty($user->rights->adherent->cotisation->lire)) {
56  $nbSubscription = is_array($object->subscriptions) ?count($object->subscriptions) : 0;
57  $head[$h][0] = DOL_URL_ROOT.'/adherents/subscription.php?rowid='.$object->id;
58  $head[$h][1] = $langs->trans("Subscriptions");
59  $head[$h][2] = 'subscription';
60  if ($nbSubscription > 0) {
61  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbSubscription.'</span>';
62  }
63  $h++;
64  }
65 
66  if (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') {
67  if (!empty($user->rights->partnership->read)) {
68  $nbPartnership = is_array($object->partnerships) ? count($object->partnerships) : 0;
69  $head[$h][0] = DOL_URL_ROOT.'/partnership/partnership_list.php?rowid='.$object->id;
70  $head[$h][1] = $langs->trans("Partnerships");
71  $nbNote = 0;
72  $sql = "SELECT COUNT(n.rowid) as nb";
73  $sql .= " FROM ".MAIN_DB_PREFIX."partnership as n";
74  $sql .= " WHERE fk_member = ".((int) $object->id);
75  $resql = $db->query($sql);
76  if ($resql) {
77  $obj = $db->fetch_object($resql);
78  $nbNote = $obj->nb;
79  } else {
80  dol_print_error($db);
81  }
82  if ($nbNote > 0) {
83  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
84  }
85  $head[$h][2] = 'partnerships';
86  if ($nbPartnership > 0) {
87  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbPartnership.'</span>';
88  }
89  $h++;
90  }
91  }
92 
93  // Show more tabs from modules
94  // Entries must be declared in modules descriptor with line
95  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
96  // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
97  complete_head_from_modules($conf, $langs, $object, $head, $h, 'member', 'add', 'core');
98 
99  $nbNote = 0;
100  if (!empty($object->note_private)) {
101  $nbNote++;
102  }
103  if (!empty($object->note_public)) {
104  $nbNote++;
105  }
106  $head[$h][0] = DOL_URL_ROOT.'/adherents/note.php?id='.$object->id;
107  $head[$h][1] = $langs->trans("Note");
108  $head[$h][2] = 'note';
109  if ($nbNote > 0) {
110  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
111  }
112  $h++;
113 
114  // Attachments
115  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
116  require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
117  $upload_dir = $conf->adherent->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'member');
118  $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
119  $nbLinks = Link::count($db, $object->element, $object->id);
120  $head[$h][0] = DOL_URL_ROOT.'/adherents/document.php?id='.$object->id;
121  $head[$h][1] = $langs->trans('Documents');
122  if (($nbFiles + $nbLinks) > 0) {
123  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
124  }
125  $head[$h][2] = 'document';
126  $h++;
127 
128  // Show agenda tab
129  if (isModEnabled('agenda')) {
130  $head[$h][0] = DOL_URL_ROOT."/adherents/agenda.php?id=".$object->id;
131  $head[$h][1] = $langs->trans("Events");
132  if (isModEnabled('agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
133  $head[$h][1] .= '/';
134  $head[$h][1] .= $langs->trans("Agenda");
135  }
136  $head[$h][2] = 'agenda';
137  $h++;
138  }
139 
140  complete_head_from_modules($conf, $langs, $object, $head, $h, 'member', 'add', 'external');
141 
142  complete_head_from_modules($conf, $langs, $object, $head, $h, 'member', 'remove');
143 
144  return $head;
145 }
146 
154 {
155  global $langs, $conf, $user;
156 
157  $h = 0;
158  $head = array();
159 
160  $head[$h][0] = DOL_URL_ROOT.'/adherents/type.php?rowid='.$object->id;
161  $head[$h][1] = $langs->trans("MemberType");
162  $head[$h][2] = 'card';
163  $h++;
164 
165  // Multilangs
166  if (getDolGlobalInt('MAIN_MULTILANGS')) {
167  $head[$h][0] = DOL_URL_ROOT."/adherents/type_translation.php?rowid=".$object->id;
168  $head[$h][1] = $langs->trans("Translation");
169  $head[$h][2] = 'translation';
170  $h++;
171  }
172 
173  if ((!empty($conf->ldap->enabled) && !empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE))
174  && (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || !empty($user->admin))) {
175  $langs->load("ldap");
176 
177  $head[$h][0] = DOL_URL_ROOT.'/adherents/type_ldap.php?rowid='.$object->id;
178  $head[$h][1] = $langs->trans("LDAPCard");
179  $head[$h][2] = 'ldap';
180  $h++;
181  }
182 
183  // Show more tabs from modules
184  // Entries must be declared in modules descriptor with line
185  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
186  // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
187  complete_head_from_modules($conf, $langs, $object, $head, $h, 'membertype');
188 
189  complete_head_from_modules($conf, $langs, $object, $head, $h, 'membertype', 'remove');
190 
191  return $head;
192 }
193 
200 {
201  global $langs, $conf, $user, $db;
202 
203  $extrafields = new ExtraFields($db);
204  $extrafields->fetch_name_optionals_label('adherent');
205  $extrafields->fetch_name_optionals_label('adherent_type');
206 
207  $h = 0;
208  $head = array();
209 
210  $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/member.php';
211  $head[$h][1] = $langs->trans("Miscellaneous");
212  $head[$h][2] = 'general';
213  $h++;
214 
215  $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/member_emails.php';
216  $head[$h][1] = $langs->trans("EMails");
217  $head[$h][2] = 'emails';
218  $h++;
219 
220  // Show more tabs from modules
221  // Entries must be declared in modules descriptor with line
222  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
223  // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
224  complete_head_from_modules($conf, $langs, null, $head, $h, 'member_admin');
225 
226  $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/member_extrafields.php';
227  $head[$h][1] = $langs->trans("ExtraFieldsMember");
228  $nbExtrafields = $extrafields->attributes['adherent']['count'];
229  if ($nbExtrafields > 0) {
230  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
231  }
232  $head[$h][2] = 'attributes';
233  $h++;
234 
235  $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/member_type_extrafields.php';
236  $head[$h][1] = $langs->trans("ExtraFieldsMemberType");
237  $nbExtrafields = $extrafields->attributes['adherent_type']['count'];
238  if ($nbExtrafields > 0) {
239  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
240  }
241  $head[$h][2] = 'attributes_type';
242  $h++;
243 
244  $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/website.php';
245  $head[$h][1] = $langs->trans("BlankSubscriptionForm");
246  $head[$h][2] = 'website';
247  $h++;
248 
249  complete_head_from_modules($conf, $langs, null, $head, $h, 'member_admin', 'remove');
250 
251  return $head;
252 }
253 
254 
261 function member_stats_prepare_head($object)
262 {
263  global $langs, $conf, $user;
264 
265  $h = 0;
266  $head = array();
267 
268  $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/index.php';
269  $head[$h][1] = $langs->trans("Subscriptions");
270  $head[$h][2] = 'statssubscription';
271  $h++;
272 
273  $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbycountry';
274  $head[$h][1] = $langs->trans("Country");
275  $head[$h][2] = 'statscountry';
276  $h++;
277 
278  $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbyregion';
279  $head[$h][1] = $langs->trans("Region");
280  $head[$h][2] = 'statsregion';
281  $h++;
282 
283  $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbystate';
284  $head[$h][1] = $langs->trans("State");
285  $head[$h][2] = 'statsstate';
286  $h++;
287 
288  $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbytown';
289  $head[$h][1] = $langs->trans('Town');
290  $head[$h][2] = 'statstown';
291  $h++;
292 
293  $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/byproperties.php';
294  $head[$h][1] = $langs->trans('ByProperties');
295  $head[$h][2] = 'statsbyproperties';
296  $h++;
297 
298  // Show more tabs from modules
299  // Entries must be declared in modules descriptor with line
300  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
301  // $this->tabs = array('entity:-tabname); to remove a tab
302  complete_head_from_modules($conf, $langs, $object, $head, $h, 'member_stats');
303 
304  complete_head_from_modules($conf, $langs, $object, $head, $h, 'member_stats', 'remove');
305 
306  return $head;
307 }
308 
316 {
317  global $db, $langs, $conf, $user;
318 
319  $h = 0;
320  $head = array();
321 
322  $head[$h][0] = DOL_URL_ROOT.'/adherents/subscription/card.php?rowid='.$object->id;
323  $head[$h][1] = $langs->trans("Subscription");
324  $head[$h][2] = 'general';
325  $h++;
326 
327  $head[$h][0] = DOL_URL_ROOT.'/adherents/subscription/info.php?rowid='.$object->id;
328  $head[$h][1] = $langs->trans("Info");
329  $head[$h][2] = 'info';
330  $h++;
331 
332  // Show more tabs from modules
333  // Entries must be declared in modules descriptor with line
334  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
335  // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
336  complete_head_from_modules($conf, $langs, $object, $head, $h, 'subscription');
337 
338  complete_head_from_modules($conf, $langs, $object, $head, $h, 'subscription', 'remove');
339 
340  return $head;
341 }
Class to manage members of a foundation.
Class to manage members type.
Class to manage standard extra fields.
Class to manage subscriptions of foundation members.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:745
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
Definition: files.lib.php:61
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add', $filterorigmodule='')
Complete or removed entries into a head array (used to build tabs).
isModEnabled($module)
Is Dolibarr module enabled.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
subscription_prepare_head(Subscription $object)
Return array head with list of tabs to view object informations.
Definition: member.lib.php:315
member_prepare_head(Adherent $object)
Return array head with list of tabs to view object informations.
Definition: member.lib.php:33
member_type_prepare_head(AdherentType $object)
Return array head with list of tabs to view object informations.
Definition: member.lib.php:153
member_admin_prepare_head()
Return array head with list of tabs to view object informations.
Definition: member.lib.php:199
member_stats_prepare_head($object)
Return array head with list of tabs to view object stats informations.
Definition: member.lib.php:261