dolibarr  13.0.2
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 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 require '../main.inc.php';
32 require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
34 require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
35 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
36 require_once DOL_DOCUMENT_ROOT.'/core/lib/holiday.lib.php';
37 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
38 
39 // Load translation files required by the page
40 $langs->loadLangs(array('other', 'holiday', 'companies'));
41 
42 $id = GETPOST('id', 'int');
43 $ref = GETPOST('ref', 'alpha');
44 $action = GETPOST('action', 'aZ09');
45 $confirm = GETPOST('confirm', 'alpha');
46 
47 // Security check
48 if ($user->socid) $socid = $user->socid;
49 $result = restrictedArea($user, 'holiday', $id, 'holiday');
50 
51 // Get parameters
52 $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
53 $sortfield = GETPOST('sortfield', 'aZ09comma');
54 $sortorder = GETPOST('sortorder', 'aZ09comma');
55 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
56 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
57 $offset = $limit * $page;
58 $pageprev = $page - 1;
59 $pagenext = $page + 1;
60 if (!$sortorder) $sortorder = "ASC";
61 if (!$sortfield) $sortfield = "position_name";
62 
63 
64 $object = new Holiday($db);
65 $object->fetch($id, $ref);
66 
67 $upload_dir = $conf->holiday->dir_output.'/'.get_exdir(0, 0, 0, 1, $object, '');
68 $modulepart = 'holiday';
69 
70 
71 /*
72  * Actions
73  */
74 
75 include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
76 
77 
78 /*
79  * View
80  */
81 
82 $form = new Form($db);
83 
84 $listhalfday = array('morning'=>$langs->trans("Morning"), "afternoon"=>$langs->trans("Afternoon"));
85 
86 llxHeader("", "", $langs->trans("InterventionCard"));
87 
88 
89 if ($object->id)
90 {
91  $valideur = new User($db);
92  $valideur->fetch($object->fk_validator);
93 
94  $userRequest = new User($db);
95  $userRequest->fetch($object->fk_user);
96 
97  $head = holiday_prepare_head($object);
98 
99  print dol_get_fiche_head($head, 'documents', $langs->trans("CPTitreMenu"), -1, 'holiday');
100 
101 
102  // Build file list
103  $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
104  $totalsize = 0;
105  foreach ($filearray as $key => $file)
106  {
107  $totalsize += $file['size'];
108  }
109 
110 
111  $linkback = '<a href="'.DOL_URL_ROOT.'/holiday/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
112 
113  dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref');
114 
115 
116  print '<div class="fichecenter">';
117  //print '<div class="fichehalfleft">';
118  print '<div class="underbanner clearboth"></div>';
119 
120  print '<table class="border tableforfield centpercent">';
121 
122  print '<tr>';
123  print '<td class="titlefield">'.$langs->trans("User").'</td>';
124  print '<td>';
125  print $userRequest->getNomUrl(-1, 'leave');
126  print '</td></tr>';
127 
128  // Type
129  print '<tr>';
130  print '<td>'.$langs->trans("Type").'</td>';
131  print '<td>';
132  $typeleaves = $object->getTypes(1, -1);
133  $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']);
134  print empty($labeltoshow) ? $langs->trans("TypeWasDisabledOrRemoved", $object->fk_type) : $labeltoshow;
135  print '</td>';
136  print '</tr>';
137 
138  $starthalfday = ($object->halfday == -1 || $object->halfday == 2) ? 'afternoon' : 'morning';
139  $endhalfday = ($object->halfday == 1 || $object->halfday == 2) ? 'morning' : 'afternoon';
140 
141  if (!$edit)
142  {
143  print '<tr>';
144  print '<td>';
145  print $form->textwithpicto($langs->trans('DateDebCP'), $langs->trans("FirstDayOfHoliday"));
146  print '</td>';
147  print '<td>'.dol_print_date($object->date_debut, 'day');
148  print ' &nbsp; &nbsp; ';
149  print '<span class="opacitymedium">'.$langs->trans($listhalfday[$starthalfday]).'</span>';
150  print '</td>';
151  print '</tr>';
152  } else {
153  print '<tr>';
154  print '<td>';
155  print $form->textwithpicto($langs->trans('DateDebCP'), $langs->trans("FirstDayOfHoliday"));
156  print '</td>';
157  print '<td>';
158  print $form->selectDate($object->date_debut, 'date_debut_');
159  print ' &nbsp; &nbsp; ';
160  print $form->selectarray('starthalfday', $listhalfday, (GETPOST('starthalfday') ?GETPOST('starthalfday') : $starthalfday));
161  print '</td>';
162  print '</tr>';
163  }
164 
165  if (!$edit)
166  {
167  print '<tr>';
168  print '<td>';
169  print $form->textwithpicto($langs->trans('DateFinCP'), $langs->trans("LastDayOfHoliday"));
170  print '</td>';
171  print '<td>'.dol_print_date($object->date_fin, 'day');
172  print ' &nbsp; &nbsp; ';
173  print '<span class="opacitymedium">'.$langs->trans($listhalfday[$endhalfday]).'</span>';
174  print '</td>';
175  print '</tr>';
176  } else {
177  print '<tr>';
178  print '<td>';
179  print $form->textwithpicto($langs->trans('DateFinCP'), $langs->trans("LastDayOfHoliday"));
180  print '</td>';
181  print '<td>';
182  print $form->selectDate($object->date_fin, 'date_fin_');
183  print ' &nbsp; &nbsp; ';
184  print $form->selectarray('endhalfday', $listhalfday, (GETPOST('endhalfday') ?GETPOST('endhalfday') : $endhalfday));
185  print '</td>';
186  print '</tr>';
187  }
188 
189  // Nb days consumed
190  print '<tr>';
191  print '<td>';
192  $htmlhelp = $langs->trans('NbUseDaysCPHelp');
193  $includesaturday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY : 1);
194  $includesunday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY : 1);
195  if ($includesaturday) $htmlhelp .= '<br>'.$langs->trans("DayIsANonWorkingDay", $langs->trans("Saturday"));
196  if ($includesunday) $htmlhelp .= '<br>'.$langs->trans("DayIsANonWorkingDay", $langs->trans("Sunday"));
197  print $form->textwithpicto($langs->trans('NbUseDaysCP'), $htmlhelp);
198  print '</td>';
199  print '<td>'.num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday).'</td>';
200  print '</tr>';
201 
202  if ($object->statut == 5)
203  {
204  print '<tr>';
205  print '<td>'.$langs->trans('DetailRefusCP').'</td>';
206  print '<td>'.$object->detail_refuse.'</td>';
207  print '</tr>';
208  }
209 
210  // Description
211  if (!$edit)
212  {
213  print '<tr>';
214  print '<td>'.$langs->trans('DescCP').'</td>';
215  print '<td>'.nl2br($object->description).'</td>';
216  print '</tr>';
217  } else {
218  print '<tr>';
219  print '<td>'.$langs->trans('DescCP').'</td>';
220  print '<td><textarea name="description" class="flat" rows="'.ROWS_3.'" cols="70">'.$object->description.'</textarea></td>';
221  print '</tr>';
222  }
223 
224  print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
225  print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.dol_print_size($totalsize, 1, 1).'</td></tr>';
226 
227  print '</tbody>';
228  print '</table>'."\n";
229  /*
230  print '</div>';
231  print '<div class="fichehalfright">';
232  print '<div class="ficheaddleft">';
233 
234  print '<div class="underbanner clearboth"></div>';
235 
236  // Info workflow
237  print '<table class="border tableforfield centpercent">'."\n";
238  print '<tbody>';
239 
240  if (! empty($object->fk_user_create))
241  {
242  $userCreate=new User($db);
243  $userCreate->fetch($object->fk_user_create);
244  print '<tr>';
245  print '<td class="titlefield">'.$langs->trans('RequestByCP').'</td>';
246  print '<td>'.$userCreate->getNomUrl(-1).'</td>';
247  print '</tr>';
248  }
249 
250  if (!$edit) {
251  print '<tr>';
252  print '<td class="titlefield">'.$langs->trans('ReviewedByCP').'</td>';
253  print '<td>'.$valideur->getNomUrl(-1).'</td>';
254  print '</tr>';
255  } else {
256  print '<tr>';
257  print '<td class="titlefield">'.$langs->trans('ReviewedByCP').'</td>';
258  print '<td>';
259  print $form->select_dolusers($object->fk_user, "valideur", 1, ($user->admin ? '' : array($user->id))); // By default, hierarchical parent
260  print '</td>';
261  print '</tr>';
262  }
263 
264  print '<tr>';
265  print '<td>'.$langs->trans('DateCreation').'</td>';
266  print '<td>'.dol_print_date($object->date_create,'dayhour').'</td>';
267  print '</tr>';
268  if ($object->statut == 3) {
269  print '<tr>';
270  print '<td>'.$langs->trans('DateValidCP').'</td>';
271  print '<td>'.dol_print_date($object->date_valid,'dayhour').'</td>';
272  print '</tr>';
273  }
274  if ($object->statut == 4) {
275  print '<tr>';
276  print '<td>'.$langs->trans('DateCancelCP').'</td>';
277  print '<td>'.dol_print_date($object->date_cancel,'dayhour').'</td>';
278  print '</tr>';
279  }
280  if ($object->statut == 5) {
281  print '<tr>';
282  print '<td>'.$langs->trans('DateRefusCP').'</td>';
283  print '<td>'.dol_print_date($object->date_refuse,'dayhour').'</td>';
284  print '</tr>';
285  }
286  print '</tbody>';
287  print '</table>';
288 
289  print '</div>';
290  print '</div>'; */
291  print '</div>';
292 
293  print '<div class="clearboth"></div>';
294 
296 
297 
298 
299  $modulepart = 'holiday';
300  $permission = $user->rights->holiday->write;
301  $permtoedit = $user->rights->holiday->write;
302  $param = '&id='.$object->id;
303  include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
304 } else {
305  print $langs->trans("ErrorUnknown");
306 }
307 
308 // End of page
309 llxFooter();
310 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class of the module paid holiday.
holiday_prepare_head($object)
Return array head with list of tabs to view object informations.
Definition: holiday.lib.php:30
Class to manage Dolibarr users.
Definition: user.class.php:44
llxHeader()
Empty header.
Definition: wrapper.php:45
Class to manage generation of HTML components Only common components must be here.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart= '')
Return a path to have a the directory according to object where files are stored. ...
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
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_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
Definition: index.php:89
dol_print_size($size, $shortvalue=0, $shortunit=0)
Return string with formated size.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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.
llxFooter()
Empty footer.
Definition: wrapper.php:59