dolibarr  16.0.5
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  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
28 require '../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
34 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
35 
36 // Load translation files required by the page
37 $langs->loadLangs(array("companies", "members", "other"));
38 
39 
40 $id = GETPOSTISSET('id') ? GETPOST('id', 'int') : GETPOST('rowid', 'int');
41 $ref = GETPOST('ref', 'alphanohtml');
42 $action = GETPOST('action', 'aZ09');
43 $confirm = GETPOST('confirm', 'alpha');
44 
45 // Get parameters
46 $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
47 $sortfield = GETPOST('sortfield', 'aZ09comma');
48 $sortorder = GETPOST('sortorder', 'aZ09comma');
49 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
50 if (empty($page) || $page == -1) {
51  $page = 0;
52 } // If $page is not defined, or '' or -1
53 $offset = $limit * $page;
54 $pageprev = $page - 1;
55 $pagenext = $page + 1;
56 if (!$sortorder) {
57  $sortorder = "ASC";
58 }
59 if (!$sortfield) {
60  $sortfield = "name";
61 }
62 
63 $object = new Adherent($db);
64 $membert = new AdherentType($db);
65 $result = $object->fetch($id, $ref);
66 if ($result < 0) {
67  dol_print_error($db);
68  exit;
69 }
70 $upload_dir = $conf->adherent->dir_output."/".get_exdir(0, 0, 0, 1, $object, 'member');
71 
72 // Fetch object
73 if ($id > 0 || !empty($ref)) {
74  // Load member
75  $result = $object->fetch($id, $ref);
76 
77  // Define variables to know what current user can do on users
78  $canadduser = ($user->admin || $user->rights->user->user->creer);
79  // Define variables to know what current user can do on properties of user linked to edited member
80  if ($object->user_id) {
81  // $User is the user who edits, $object->user_id is the id of the related user in the edited member
82  $caneditfielduser = ((($user->id == $object->user_id) && $user->rights->user->self->creer)
83  || (($user->id != $object->user_id) && $user->rights->user->user->creer));
84  $caneditpassworduser = ((($user->id == $object->user_id) && $user->rights->user->self->password)
85  || (($user->id != $object->user_id) && $user->rights->user->user->password));
86  }
87 }
88 
89 // Define variables to determine what the current user can do on the members
90 $canaddmember = $user->rights->adherent->creer;
91 // Define variables to determine what the current user can do on the properties of a member
92 if ($id) {
93  $caneditfieldmember = $user->rights->adherent->creer;
94 }
95 
96 $permissiontoadd = $canaddmember;
97 
98 // Security check
99 $result = restrictedArea($user, 'adherent', $object->id, '', '', 'socid', 'rowid', 0);
100 
101 
102 /*
103  * Actions
104  */
105 
106 include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
107 
108 
109 /*
110  * View
111  */
112 
113 $form = new Form($db);
114 
115 $title = $langs->trans("Member")." - ".$langs->trans("Documents");
116 
117 $help_url = "EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros|DE:Modul_Mitglieder";
118 
119 llxHeader("", $title, $help_url);
120 
121 if ($id > 0) {
122  $result = $membert->fetch($object->typeid);
123  if ($result > 0) {
124  // Build file list
125  $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
126  $totalsize = 0;
127  foreach ($filearray as $key => $file) {
128  $totalsize += $file['size'];
129  }
130 
131  if (!empty($conf->notification->enabled)) {
132  $langs->load("mails");
133  }
134 
135  $head = member_prepare_head($object);
136 
137  print dol_get_fiche_head($head, 'document', $langs->trans("Member"), -1, 'user');
138 
139  $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
140 
141  $morehtmlref = '<a href="'.DOL_URL_ROOT.'/adherents/vcard.php?id='.$object->id.'" class="refid">';
142  $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"');
143  $morehtmlref .= '</a>';
144 
145  dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref);
146 
147  print '<div class="fichecenter">';
148 
149  print '<div class="underbanner clearboth"></div>';
150  print '<table class="border tableforfield centpercent">';
151 
152  $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
153 
154  // Login
155  if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
156  print '<tr><td class="titlefield">'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.dol_escape_htmltag($object->login).'</td></tr>';
157  }
158 
159  // Type
160  print '<tr><td>'.$langs->trans("Type").'</td><td class="valeur">'.$membert->getNomUrl(1)."</td></tr>\n";
161 
162  // Morphy
163  print '<tr><td class="titlefield">'.$langs->trans("MemberNature").'</td><td class="valeur" >'.$object->getmorphylib().'</td>';
164  /*print '<td rowspan="'.$rowspan.'" class="center" valign="middle" width="25%">';
165  print $form->showphoto('memberphoto',$object);
166  print '</td>';*/
167  print '</tr>';
168 
169  // Company
170  print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.dol_escape_htmltag($object->company).'</td></tr>';
171 
172  // Civility
173  print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$object->getCivilityLabel().'&nbsp;</td>';
174  print '</tr>';
175 
176  // Number of Attached Files
177  print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
178 
179  //Total Size Of Attached Files
180  print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.dol_print_size($totalsize, 1, 1).'</td></tr>';
181 
182  print '</table>';
183 
184  print '</div>';
185 
186  print dol_get_fiche_end();
187 
188  $modulepart = 'member';
189  $permissiontoadd = $user->rights->adherent->creer;
190  $permtoedit = $user->rights->adherent->creer;
191  $param = '&id='.$object->id;
192  include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
193  print "<br><br>";
194  } else {
195  dol_print_error($db);
196  }
197 } else {
198  $langs->load("errors");
199  print $langs->trans("ErrorRecordNotFound");
200 }
201 
202 // End of page
203 llxFooter();
204 $db->close();
AdherentType
Class to manage members type.
Definition: adherent_type.class.php:35
dol_escape_htmltag
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
Definition: functions.lib.php:1468
restrictedArea
restrictedArea($user, $features, $objectid=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.
Definition: security.lib.php:234
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4844
llxFooter
llxFooter()
Footer empty.
Definition: document.php:89
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
member_prepare_head
member_prepare_head(Adherent $object)
Return array head with list of tabs to view object informations.
Definition: member.lib.php:33
dol_dir_list
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0)
Scan a directory and return a list of files/directories.
Definition: files.lib.php:60
dol_banner_tab
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
Definition: functions.lib.php:2046
$help_url
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:116
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:3880
llxHeader
if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) if(isset($_GET["hashp"]) &&!defined("NOLOGIN")) if((isset($_GET["modulepart"]) && $_GET["modulepart"]=='medias')) llxHeader()
Header empty.
Definition: document.php:80
get_exdir
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
Definition: functions.lib.php:6549
dol_print_size
dol_print_size($size, $shortvalue=0, $shortunit=0)
Return string with formated size.
Definition: functions.lib.php:2884
Adherent
Class to manage members of a foundation.
Definition: adherent.class.php:46
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:386
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52