dolibarr 19.0.4
document.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
5 * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
6 * Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
7 * Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
8 * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
9 * Copyright (C) 2018-2022 Frédéric France <frederic.france@netlogic.fr>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 */
24
31// Load Dolibarr environment
32require '../main.inc.php';
33require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
34require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
35require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
36require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
37require_once DOL_DOCUMENT_ROOT.'/core/lib/holiday.lib.php';
38require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
39
40// Load translation files required by the page
41$langs->loadLangs(array('other', 'holiday', 'companies'));
42
43$id = GETPOST('id', 'int');
44$ref = GETPOST('ref', 'alpha');
45$action = GETPOST('action', 'aZ09');
46$confirm = GETPOST('confirm', 'alpha');
47
48// Get parameters
49$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
50$sortfield = GETPOST('sortfield', 'aZ09comma');
51$sortorder = GETPOST('sortorder', 'aZ09comma');
52$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
53if (empty($page) || $page == -1) {
54 $page = 0;
55} // If $page is not defined, or '' or -1
56$offset = $limit * $page;
57$pageprev = $page - 1;
58$pagenext = $page + 1;
59if (!$sortorder) {
60 $sortorder = "ASC";
61}
62if (!$sortfield) {
63 $sortfield = "position_name";
64}
65
66
67$childids = $user->getAllChildIds(1);
68
69$morefilter = '';
70if (getDolGlobalString('HOLIDAY_HIDE_FOR_NON_SALARIES')) {
71 $morefilter = 'AND employee = 1';
72}
73
74$object = new Holiday($db);
75
76$extrafields = new ExtraFields($db);
77
78// fetch optionals attributes and labels
79$extrafields->fetch_name_optionals_label($object->table_element);
80
81if (($id > 0) || $ref) {
82 $object->fetch($id, $ref);
83
84 // Check current user can read this leave request
85 $canread = 0;
86 if ($user->hasRight('holiday', 'readall')) {
87 $canread = 1;
88 }
89 if ($user->hasRight('holiday', 'read') && in_array($object->fk_user, $childids)) {
90 $canread = 1;
91 }
92 if (!$canread) {
94 }
95}
96
97
98$upload_dir = $conf->holiday->dir_output.'/'.get_exdir(0, 0, 0, 1, $object, '');
99$modulepart = 'holiday';
100
101// Protection if external user
102if ($user->socid) {
103 $socid = $user->socid;
104}
105$result = restrictedArea($user, 'holiday', $object->id, 'holiday');
106
107$permissiontoadd = $user->rights->holiday->write; // Used by the include of actions_setnotes.inc.php
108
109
110/*
111 * Actions
112 */
113
114include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
115
116
117/*
118 * View
119 */
120
121$form = new Form($db);
122
123$listhalfday = array('morning'=>$langs->trans("Morning"), "afternoon"=>$langs->trans("Afternoon"));
124$title = $langs->trans("Leave").' - '.$langs->trans("Files");
125
126llxHeader('', $title);
127
128if ($object->id) {
129 $valideur = new User($db);
130 $valideur->fetch($object->fk_validator);
131
132 $userRequest = new User($db);
133 $userRequest->fetch($object->fk_user);
134
135 $head = holiday_prepare_head($object);
136
137 print dol_get_fiche_head($head, 'documents', $langs->trans("CPTitreMenu"), -1, 'holiday');
138
139
140 // Build file list
141 $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1);
142 $totalsize = 0;
143 foreach ($filearray as $key => $file) {
144 $totalsize += $file['size'];
145 }
146
147
148 $linkback = '<a href="'.DOL_URL_ROOT.'/holiday/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
149
150 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref');
151
152
153 print '<div class="fichecenter">';
154 //print '<div class="fichehalfleft">';
155 print '<div class="underbanner clearboth"></div>';
156
157 print '<table class="border tableforfield centpercent">';
158
159 print '<tr>';
160 print '<td class="titlefield">'.$langs->trans("User").'</td>';
161 print '<td>';
162 print $userRequest->getNomUrl(-1, 'leave');
163 print '</td></tr>';
164
165 // Type
166 print '<tr>';
167 print '<td>'.$langs->trans("Type").'</td>';
168 print '<td>';
169 $typeleaves = $object->getTypes(1, -1);
170 $labeltoshow = (($typeleaves[$object->fk_type]['code'] && $langs->trans($typeleaves[$object->fk_type]['code']) != $typeleaves[$object->fk_type]['code']) ? $langs->trans($typeleaves[$object->fk_type]['code']) : $typeleaves[$object->fk_type]['label']);
171 print empty($labeltoshow) ? $langs->trans("TypeWasDisabledOrRemoved", $object->fk_type) : $labeltoshow;
172 print '</td>';
173 print '</tr>';
174
175 $starthalfday = ($object->halfday == -1 || $object->halfday == 2) ? 'afternoon' : 'morning';
176 $endhalfday = ($object->halfday == 1 || $object->halfday == 2) ? 'morning' : 'afternoon';
177
178 print '<tr>';
179 print '<td>';
180 print $form->textwithpicto($langs->trans('DateDebCP'), $langs->trans("FirstDayOfHoliday"));
181 print '</td>';
182 print '<td>'.dol_print_date($object->date_debut, 'day');
183 print ' &nbsp; &nbsp; ';
184 print '<span class="opacitymedium">'.$langs->trans($listhalfday[$starthalfday]).'</span>';
185 print '</td>';
186 print '</tr>';
187
188 print '<tr>';
189 print '<td>';
190 print $form->textwithpicto($langs->trans('DateFinCP'), $langs->trans("LastDayOfHoliday"));
191 print '</td>';
192 print '<td>'.dol_print_date($object->date_fin, 'day');
193 print ' &nbsp; &nbsp; ';
194 print '<span class="opacitymedium">'.$langs->trans($listhalfday[$endhalfday]).'</span>';
195 print '</td>';
196 print '</tr>';
197
198 // Nb days consumed
199 print '<tr>';
200 print '<td>';
201 $htmlhelp = $langs->trans('NbUseDaysCPHelp');
202 $includesaturday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY : 1);
203 $includesunday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY : 1);
204 if ($includesaturday) {
205 $htmlhelp .= '<br>'.$langs->trans("DayIsANonWorkingDay", $langs->trans("Saturday"));
206 }
207 if ($includesunday) {
208 $htmlhelp .= '<br>'.$langs->trans("DayIsANonWorkingDay", $langs->trans("Sunday"));
209 }
210 print $form->textwithpicto($langs->trans('NbUseDaysCP'), $htmlhelp);
211 print '</td>';
212 print '<td>'.num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday).'</td>';
213 print '</tr>';
214
215 if ($object->statut == 5) {
216 print '<tr>';
217 print '<td>'.$langs->trans('DetailRefusCP').'</td>';
218 print '<td>'.$object->detail_refuse.'</td>';
219 print '</tr>';
220 }
221
222 // Description
223 print '<tr>';
224 print '<td>'.$langs->trans('DescCP').'</td>';
225 print '<td>'.nl2br($object->description).'</td>';
226 print '</tr>';
227
228 print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
229 print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.dol_print_size($totalsize, 1, 1).'</td></tr>';
230
231 print '</tbody>';
232 print '</table>'."\n";
233 /*
234 print '</div>';
235 print '<div class="fichehalfright">';
236
237 print '<div class="underbanner clearboth"></div>';
238
239 // Info workflow
240 print '<table class="border tableforfield centpercent">'."\n";
241 print '<tbody>';
242
243 if (!empty($object->fk_user_create)) {
244 $userCreate=new User($db);
245 $userCreate->fetch($object->fk_user_create);
246 print '<tr>';
247 print '<td class="titlefield">'.$langs->trans('RequestByCP').'</td>';
248 print '<td>'.$userCreate->getNomUrl(-1).'</td>';
249 print '</tr>';
250 }
251
252 print '<tr>';
253 print '<td class="titlefield">'.$langs->trans('ReviewedByCP').'</td>';
254 print '<td>'.$valideur->getNomUrl(-1).'</td>';
255 print '</tr>';
256
257 print '<tr>';
258 print '<td>'.$langs->trans('DateCreation').'</td>';
259 print '<td>'.dol_print_date($object->date_create,'dayhour').'</td>';
260 print '</tr>';
261 if ($object->statut == 3) {
262 print '<tr>';
263 print '<td>'.$langs->trans('DateValidCP').'</td>';
264 print '<td>'.dol_print_date($object->date_valid,'dayhour').'</td>';
265 print '</tr>';
266 }
267 if ($object->statut == 4) {
268 print '<tr>';
269 print '<td>'.$langs->trans('DateCancelCP').'</td>';
270 print '<td>'.dol_print_date($object->date_cancel,'dayhour').'</td>';
271 print '</tr>';
272 }
273 if ($object->statut == 5) {
274 print '<tr>';
275 print '<td>'.$langs->trans('DateRefusCP').'</td>';
276 print '<td>'.dol_print_date($object->date_refuse,'dayhour').'</td>';
277 print '</tr>';
278 }
279 print '</tbody>';
280 print '</table>';
281
282 print '</div>'; */
283 print '</div>';
284
285 print '<div class="clearboth"></div>';
286
287 print dol_get_fiche_end();
288
289 $permissiontoadd = $user->rights->holiday->write;
290 $permtoedit = $user->rights->holiday->write;
291 $param = '&id='.$object->id;
292 $relativepathwithnofile = dol_sanitizeFileName($object->ref).'/';
293 $savingdocmask = dol_sanitizeFileName($object->ref).'-__file__';
294
295 include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
296} else {
297 print $langs->trans("ErrorUnknown");
298}
299
300// End of page
301llxFooter();
302$db->close();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
Class to manage standard extra fields.
Class to manage generation of HTML components Only common components must be here.
Class of the module paid holiday.
Class to manage Dolibarr users.
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:62
dol_print_size($size, $shortvalue=0, $shortunit=0)
Return string with formated size.
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.
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_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return 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.
holiday_prepare_head($object)
Return array head with list of tabs to view object informations.
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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.