dolibarr 21.0.0-beta
document.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2002-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
6 * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
7 * Copyright (C) 2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
8 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 */
23
38// Load Dolibarr environment
39require '../main.inc.php';
40require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
41require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
42require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
43require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
44require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
45require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
46
47// Load translation files required by the page
48$langs->loadLangs(array("companies", "members", "other"));
49
50
51$id = GETPOSTISSET('id') ? GETPOSTINT('id') : GETPOSTINT('rowid');
52$ref = GETPOST('ref', 'alphanohtml');
53$action = GETPOST('action', 'aZ09');
54$confirm = GETPOST('confirm', 'alpha');
55
56// Get parameters
57$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
58$sortfield = GETPOST('sortfield', 'aZ09comma');
59$sortorder = GETPOST('sortorder', 'aZ09comma');
60$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT('page');
61if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
62 // If $page is not defined, or '' or -1 or if we click on clear filters
63 $page = 0;
64}
65$offset = $limit * $page;
66$pageprev = $page - 1;
67$pagenext = $page + 1;
68if (!$sortorder) {
69 $sortorder = "ASC";
70}
71if (!$sortfield) {
72 $sortfield = "name";
73}
74
75$object = new Adherent($db);
76$membert = new AdherentType($db);
77$result = $object->fetch($id, $ref);
78if ($result < 0) {
79 dol_print_error($db);
80 exit;
81}
82$upload_dir = $conf->adherent->dir_output."/".get_exdir(0, 0, 0, 1, $object, 'member');
83
84// Fetch object
85if ($id > 0 || !empty($ref)) {
86 // Load member
87 $result = $object->fetch($id, $ref);
88
89 // Define variables to know what current user can do on users
90 $canadduser = ($user->admin || $user->hasRight('user', 'user', 'creer'));
91 // Define variables to know what current user can do on properties of user linked to edited member
92 if ($object->user_id) {
93 // $User is the user who edits, $object->user_id is the id of the related user in the edited member
94 $caneditfielduser = ((($user->id == $object->user_id) && $user->hasRight('user', 'self', 'creer'))
95 || (($user->id != $object->user_id) && $user->hasRight('user', 'user', 'creer')));
96 $caneditpassworduser = ((($user->id == $object->user_id) && $user->hasRight('user', 'self', 'password'))
97 || (($user->id != $object->user_id) && $user->hasRight('user', 'user', 'password')));
98 }
99}
100
101// Define variables to determine what the current user can do on the members
102$canaddmember = $user->hasRight('adherent', 'creer');
103// Define variables to determine what the current user can do on the properties of a member
104if ($id) {
105 $caneditfieldmember = $user->hasRight('adherent', 'creer');
106}
107
108$permissiontoadd = $canaddmember;
109
110// Security check
111$result = restrictedArea($user, 'adherent', $object->id, '', '', 'socid', 'rowid', 0);
112
113
114/*
115 * Actions
116 */
117
118include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
119
120
121/*
122 * View
123 */
124
125$form = new Form($db);
126
127$title = $langs->trans("Member")." - ".$langs->trans("Documents");
128$help_url = "EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros|DE:Modul_Mitglieder";
129
130llxHeader("", $title, $help_url, '', 0, 0, '', '', '', 'mod-member page-card_documents');
131
132if ($id > 0) {
133 $result = $membert->fetch($object->typeid);
134 if ($result > 0) {
135 // Build file list
136 $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1);
137 $totalsize = 0;
138 foreach ($filearray as $key => $file) {
139 $totalsize += $file['size'];
140 }
141
142 if (isModEnabled('notification')) {
143 $langs->load("mails");
144 }
145
146 $head = member_prepare_head($object);
147
148 print dol_get_fiche_head($head, 'document', $langs->trans("Member"), -1, 'user');
149
150 $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
151
152 $morehtmlref = '<a href="'.DOL_URL_ROOT.'/adherents/vcard.php?id='.$object->id.'" class="refid">';
153 $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"');
154 $morehtmlref .= '</a>';
155
156 dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref);
157
158 print '<div class="fichecenter">';
159
160 print '<div class="underbanner clearboth"></div>';
161 print '<table class="border tableforfield centpercent">';
162
163 $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
164
165 // Login
166 if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) {
167 print '<tr><td class="titlefield">'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.dol_escape_htmltag($object->login).'</td></tr>';
168 }
169
170 // Type
171 print '<tr><td>'.$langs->trans("Type").'</td>';
172 print '<td class="valeur">'.$membert->getNomUrl(1)."</td></tr>\n";
173
174 // Morphy
175 print '<tr><td class="titlefield">'.$langs->trans("MemberNature").'</td>';
176 print '<td class="valeur" >'.$object->getmorphylib('', 1).'</td>';
177 print '</tr>';
178
179 // Company
180 print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.dol_escape_htmltag($object->company).'</td></tr>';
181
182 // Civility
183 print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$object->getCivilityLabel().'&nbsp;</td>';
184 print '</tr>';
185
186 // Number of Attached Files
187 print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
188
189 //Total Size Of Attached Files
190 print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.dol_print_size($totalsize, 1, 1).'</td></tr>';
191
192 print '</table>';
193
194 print '</div>';
195
196 print dol_get_fiche_end();
197
198 $modulepart = 'member';
199 $permissiontoadd = $user->hasRight('adherent', 'creer');
200 $permtoedit = $user->hasRight('adherent', 'creer');
201 $param = '&id='.$object->id;
202 include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
203 print "<br><br>";
204 } else {
205 dol_print_error($db);
206 }
207} else {
208 $langs->load("errors");
209 print $langs->trans("ErrorRecordNotFound");
210}
211
212// End of page
213llxFooter();
214$db->close();
$id
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:71
Class to manage members of a foundation.
Class to manage members type.
Class to manage generation of HTML components Only common components must be here.
llxFooter()
Footer empty.
Definition document.php:107
dol_dir_list($utf8_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:63
dol_print_size($size, $shortvalue=0, $shortunit=0)
Return string with formatted size.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
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...
member_prepare_head(Adherent $object)
Return array head with list of tabs to view object information.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.