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