dolibarr 21.0.0-alpha
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 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
29// Load Dolibarr environment
30require '../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
33require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
34require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
35require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
36require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
37
38// Load translation files required by the page
39$langs->loadLangs(array("companies", "members", "other"));
40
41
42$id = GETPOSTISSET('id') ? GETPOSTINT('id') : GETPOSTINT('rowid');
43$ref = GETPOST('ref', 'alphanohtml');
44$action = GETPOST('action', 'aZ09');
45$confirm = GETPOST('confirm', 'alpha');
46
47// Get parameters
48$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
49$sortfield = GETPOST('sortfield', 'aZ09comma');
50$sortorder = GETPOST('sortorder', 'aZ09comma');
51$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT('page');
52if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
53 // If $page is not defined, or '' or -1 or if we click on clear filters
54 $page = 0;
55}
56$offset = $limit * $page;
57$pageprev = $page - 1;
58$pagenext = $page + 1;
59if (!$sortorder) {
60 $sortorder = "ASC";
61}
62if (!$sortfield) {
63 $sortfield = "name";
64}
65
66$object = new Adherent($db);
67$membert = new AdherentType($db);
68$result = $object->fetch($id, $ref);
69if ($result < 0) {
70 dol_print_error($db);
71 exit;
72}
73$upload_dir = $conf->adherent->dir_output."/".get_exdir(0, 0, 0, 1, $object, 'member');
74
75// Fetch object
76if ($id > 0 || !empty($ref)) {
77 // Load member
78 $result = $object->fetch($id, $ref);
79
80 // Define variables to know what current user can do on users
81 $canadduser = ($user->admin || $user->hasRight('user', 'user', 'creer'));
82 // Define variables to know what current user can do on properties of user linked to edited member
83 if ($object->user_id) {
84 // $User is the user who edits, $object->user_id is the id of the related user in the edited member
85 $caneditfielduser = ((($user->id == $object->user_id) && $user->hasRight('user', 'self', 'creer'))
86 || (($user->id != $object->user_id) && $user->hasRight('user', 'user', 'creer')));
87 $caneditpassworduser = ((($user->id == $object->user_id) && $user->hasRight('user', 'self', 'password'))
88 || (($user->id != $object->user_id) && $user->hasRight('user', 'user', 'password')));
89 }
90}
91
92// Define variables to determine what the current user can do on the members
93$canaddmember = $user->hasRight('adherent', 'creer');
94// Define variables to determine what the current user can do on the properties of a member
95if ($id) {
96 $caneditfieldmember = $user->hasRight('adherent', 'creer');
97}
98
99$permissiontoadd = $canaddmember;
100
101// Security check
102$result = restrictedArea($user, 'adherent', $object->id, '', '', 'socid', 'rowid', 0);
103
104
105/*
106 * Actions
107 */
108
109include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
110
111
112/*
113 * View
114 */
115
116$form = new Form($db);
117
118$title = $langs->trans("Member")." - ".$langs->trans("Documents");
119$help_url = "EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros|DE:Modul_Mitglieder";
120
121llxHeader("", $title, $help_url, '', 0, 0, '', '', '', 'mod-member page-card_documents');
122
123if ($id > 0) {
124 $result = $membert->fetch($object->typeid);
125 if ($result > 0) {
126 // Build file list
127 $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1);
128 $totalsize = 0;
129 foreach ($filearray as $key => $file) {
130 $totalsize += $file['size'];
131 }
132
133 if (isModEnabled('notification')) {
134 $langs->load("mails");
135 }
136
137 $head = member_prepare_head($object);
138
139 print dol_get_fiche_head($head, 'document', $langs->trans("Member"), -1, 'user');
140
141 $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
142
143 $morehtmlref = '<a href="'.DOL_URL_ROOT.'/adherents/vcard.php?id='.$object->id.'" class="refid">';
144 $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"');
145 $morehtmlref .= '</a>';
146
147 dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref);
148
149 print '<div class="fichecenter">';
150
151 print '<div class="underbanner clearboth"></div>';
152 print '<table class="border tableforfield centpercent">';
153
154 $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
155
156 // Login
157 if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) {
158 print '<tr><td class="titlefield">'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.dol_escape_htmltag($object->login).'</td></tr>';
159 }
160
161 // Type
162 print '<tr><td>'.$langs->trans("Type").'</td>';
163 print '<td class="valeur">'.$membert->getNomUrl(1)."</td></tr>\n";
164
165 // Morphy
166 print '<tr><td class="titlefield">'.$langs->trans("MemberNature").'</td>';
167 print '<td class="valeur" >'.$object->getmorphylib('', 1).'</td>';
168 print '</tr>';
169
170 // Company
171 print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.dol_escape_htmltag($object->company).'</td></tr>';
172
173 // Civility
174 print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$object->getCivilityLabel().'&nbsp;</td>';
175 print '</tr>';
176
177 // Number of Attached Files
178 print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
179
180 //Total Size Of Attached Files
181 print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.dol_print_size($totalsize, 1, 1).'</td></tr>';
182
183 print '</table>';
184
185 print '</div>';
186
187 print dol_get_fiche_end();
188
189 $modulepart = 'member';
190 $permissiontoadd = $user->hasRight('adherent', 'creer');
191 $permtoedit = $user->hasRight('adherent', 'creer');
192 $param = '&id='.$object->id;
193 include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
194 print "<br><br>";
195 } else {
196 dol_print_error($db);
197 }
198} else {
199 $langs->load("errors");
200 print $langs->trans("ErrorRecordNotFound");
201}
202
203// End of page
204llxFooter();
205$db->close();
$id
Definition account.php:39
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
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:70
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.
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.