dolibarr  7.0.0-beta
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@capnetworks.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  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  */
23 
30 require '../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
34 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
35 require_once DOL_DOCUMENT_ROOT.'/core/lib/holiday.lib.php';
36 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
37 
38 $langs->load("other");
39 $langs->load("holidays");
40 $langs->load("companies");
41 
42 $id = GETPOST('id','int');
43 $ref = GETPOST('ref', 'alpha');
44 $action = GETPOST('action','alpha');
45 $confirm = GETPOST('confirm','alpha');
46 
47 // Security check
48 if ($user->societe_id) $socid=$user->societe_id;
49 $result = restrictedArea($user, 'holiday', $id, 'holiday');
50 
51 $langs->load("holiday");
52 
53 // Get parameters
54 $sortfield = GETPOST('sortfield','alpha');
55 $sortorder = GETPOST('sortorder','alpha');
56 $page = GETPOST('page','int');
57 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
58 $offset = $conf->liste_limit * $page;
59 $pageprev = $page - 1;
60 $pagenext = $page + 1;
61 if (! $sortorder) $sortorder="ASC";
62 if (! $sortfield) $sortfield="name";
63 
64 
65 $object = new Holiday($db);
66 $object->fetch($id, $ref);
67 
68 $upload_dir = $conf->holiday->dir_output.'/'.get_exdir($object->id, 0, 0, 0, $object, 'holiday').dol_sanitizeFileName($object->ref);
69 $modulepart='holiday';
70 
71 
72 /*
73  * Actions
74  */
75 
76 include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php';
77 
78 
79 /*
80  * View
81  */
82 
83 $form = new Form($db);
84 
85 $listhalfday=array('morning'=>$langs->trans("Morning"),"afternoon"=>$langs->trans("Afternoon"));
86 
87 llxHeader("","",$langs->trans("InterventionCard"));
88 
89 
90 if ($object->id)
91 {
92  $valideur = new User($db);
93  $valideur->fetch($object->fk_validator);
94 
95  $userRequest = new User($db);
96  $userRequest->fetch($object->fk_user);
97 
98  $head=holiday_prepare_head($object);
99 
100  dol_fiche_head($head, 'documents', $langs->trans("CPTitreMenu"), -1,'holiday');
101 
102 
103  // Construit liste des fichiers
104  $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
105  $totalsize=0;
106  foreach($filearray as $key => $file)
107  {
108  $totalsize+=$file['size'];
109  }
110 
111 
112  $linkback='<a href="'.DOL_URL_ROOT.'/holiday/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
113 
114  dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref');
115 
116 
117  print '<div class="fichecenter">';
118  //print '<div class="fichehalfleft">';
119  print '<div class="underbanner clearboth"></div>';
120 
121  print '<table class="border centpercent">';
122 
123  print '<tr>';
124  print '<td class="titlefield">'.$langs->trans("User").'</td>';
125  print '<td>';
126  print $userRequest->getNomUrl(-1, 'leave');
127  print '</td></tr>';
128 
129  // Type
130  print '<tr>';
131  print '<td>'.$langs->trans("Type").'</td>';
132  print '<td>';
133  $typeleaves=$object->getTypes(1,-1);
134  print empty($typeleaves[$object->fk_type]['label']) ? $langs->trans("TypeWasDisabledOrRemoved",$object->fk_type) : $typeleaves[$object->fk_type]['label'];
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>'.$langs->trans('DateDebCP').' ('.$langs->trans("FirstDayOfHoliday").')</td>';
145  print '<td>'.dol_print_date($object->date_debut,'day');
146  print ' &nbsp; &nbsp; ';
147  print $langs->trans($listhalfday[$starthalfday]);
148  print '</td>';
149  print '</tr>';
150  }
151  else
152  {
153  print '<tr>';
154  print '<td>'.$langs->trans('DateDebCP').' ('.$langs->trans("FirstDayOfHoliday").')</td>';
155  print '<td>';
156  $form->select_date($object->date_debut,'date_debut_');
157  print ' &nbsp; &nbsp; ';
158  print $form->selectarray('starthalfday', $listhalfday, (GETPOST('starthalfday')?GETPOST('starthalfday'):$starthalfday));
159  print '</td>';
160  print '</tr>';
161  }
162 
163  if (!$edit)
164  {
165  print '<tr>';
166  print '<td>'.$langs->trans('DateFinCP').' ('.$langs->trans("LastDayOfHoliday").')</td>';
167  print '<td>'.dol_print_date($object->date_fin,'day');
168  print ' &nbsp; &nbsp; ';
169  print $langs->trans($listhalfday[$endhalfday]);
170  print '</td>';
171  print '</tr>';
172  }
173  else
174  {
175  print '<tr>';
176  print '<td>'.$langs->trans('DateFinCP').' ('.$langs->trans("LastDayOfHoliday").')</td>';
177  print '<td>';
178  $form->select_date($object->date_fin,'date_fin_');
179  print ' &nbsp; &nbsp; ';
180  print $form->selectarray('endhalfday', $listhalfday, (GETPOST('endhalfday')?GETPOST('endhalfday'):$endhalfday));
181  print '</td>';
182  print '</tr>';
183  }
184  print '<tr>';
185  print '<td>'.$langs->trans('NbUseDaysCP').'</td>';
186  print '<td>'.num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday).'</td>';
187  print '</tr>';
188 
189  if ($object->statut == 5)
190  {
191  print '<tr>';
192  print '<td>'.$langs->trans('DetailRefusCP').'</td>';
193  print '<td>'.$object->detail_refuse.'</td>';
194  print '</tr>';
195  }
196 
197  // Description
198  if (!$edit)
199  {
200  print '<tr>';
201  print '<td>'.$langs->trans('DescCP').'</td>';
202  print '<td>'.nl2br($object->description).'</td>';
203  print '</tr>';
204  }
205  else
206  {
207  print '<tr>';
208  print '<td>'.$langs->trans('DescCP').'</td>';
209  print '<td><textarea name="description" class="flat" rows="'.ROWS_3.'" cols="70">'.$object->description.'</textarea></td>';
210  print '</tr>';
211  }
212 
213  print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
214  print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
215 
216  print '</tbody>';
217  print '</table>'."\n";
218 /*
219  print '</div>';
220  print '<div class="fichehalfright">';
221  print '<div class="ficheaddleft">';
222 
223  print '<div class="underbanner clearboth"></div>';
224 
225  // Info workflow
226  print '<table class="border centpercent">'."\n";
227  print '<tbody>';
228 
229  if (! empty($object->fk_user_create))
230  {
231  $userCreate=new User($db);
232  $userCreate->fetch($object->fk_user_create);
233  print '<tr>';
234  print '<td class="titlefield">'.$langs->trans('RequestByCP').'</td>';
235  print '<td>'.$userCreate->getNomUrl(-1).'</td>';
236  print '</tr>';
237  }
238 
239  if (!$edit) {
240  print '<tr>';
241  print '<td class="titlefield">'.$langs->trans('ReviewedByCP').'</td>';
242  print '<td>'.$valideur->getNomUrl(-1).'</td>';
243  print '</tr>';
244  } else {
245  print '<tr>';
246  print '<td class="titlefield">'.$langs->trans('ReviewedByCP').'</td>';
247  print '<td>';
248  print $form->select_dolusers($object->fk_user, "valideur", 1, ($user->admin ? '' : array($user->id))); // By default, hierarchical parent
249  print '</td>';
250  print '</tr>';
251  }
252 
253  print '<tr>';
254  print '<td>'.$langs->trans('DateCreateCP').'</td>';
255  print '<td>'.dol_print_date($object->date_create,'dayhour').'</td>';
256  print '</tr>';
257  if ($object->statut == 3) {
258  print '<tr>';
259  print '<td>'.$langs->trans('DateValidCP').'</td>';
260  print '<td>'.dol_print_date($object->date_valid,'dayhour').'</td>';
261  print '</tr>';
262  }
263  if ($object->statut == 4) {
264  print '<tr>';
265  print '<td>'.$langs->trans('DateCancelCP').'</td>';
266  print '<td>'.dol_print_date($object->date_cancel,'dayhour').'</td>';
267  print '</tr>';
268  }
269  if ($object->statut == 5) {
270  print '<tr>';
271  print '<td>'.$langs->trans('DateRefusCP').'</td>';
272  print '<td>'.dol_print_date($object->date_refuse,'dayhour').'</td>';
273  print '</tr>';
274  }
275  print '</tbody>';
276  print '</table>';
277 
278  print '</div>';
279  print '</div>'; */
280  print '</div>';
281 
282  print '<div class="clearboth"></div>';
283 
284  dol_fiche_end();
285 
286 
287 
288  $modulepart = 'holiday';
289  $permission = $user->rights->holiday->write;
290  $permtoedit = $user->rights->holiday->write;
291  $param = '&id=' . $object->id;
292  include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
293 }
294 else
295 {
296  print $langs->trans("ErrorUnknown");
297 }
298 
299 
300 llxFooter();
301 
302 $db->close();
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
llxHeader()
Header empty.
Definition: document.php:70
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='')
Show tab header of a card.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart)
Return a path to have a the directory according to object where files are stored. ...
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.
Class to manage Dolibarr users.
Definition: user.class.php:39
if(empty($reshook)) $form
View.
Definition: perms.php:103
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="")
Scan a directory and return a list of files/directories.
Definition: files.lib.php:58
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage generation of HTML components Only common components must be here.
dol_fiche_end($notab=0)
Show tab footer of a card.
print
Draft customers invoices.
Definition: index.php:91
llxFooter()
Footer empty.
Definition: document.php:76
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $objcanvas=null)
Check permissions of a user to show a page and an object.