dolibarr  9.0.0
list.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2011 Dimitri Mouillard <dmouillard@teclib.com>
3  * Copyright (C) 2013-2018 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2012-2016 Regis Houssin <regis.houssin@inodbox.com>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
26 require '../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
28 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
30 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
31 require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
34 require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
35 
36 // Load translation files required by the page
37 $langs->loadLangs(array('users', 'holidays', 'hrm'));
38 
39 // Protection if external user
40 if ($user->societe_id > 0) accessforbidden();
41 
42 $action = GETPOST('action','alpha'); // The action 'add', 'create', 'edit', 'update', 'view', ...
43 $massaction = GETPOST('massaction','alpha'); // The bulk action (combo box choice into lists)
44 $show_files = GETPOST('show_files','int'); // Show files area generated by bulk actions ?
45 $confirm = GETPOST('confirm','alpha'); // Result of a confirmation
46 $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
47 $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
48 $contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'myobjectlist'; // To manage different context of search
49 $backtopage = GETPOST('backtopage','alpha'); // Go back to a dedicated page
50 $optioncss = GETPOST('optioncss','aZ'); // Option for the css output (always '' except when 'print')
51 
52 $childids = $user->getAllChildIds(1);
53 
54 // Security check
55 $socid=0;
56 if ($user->societe_id > 0) // Protection if external user
57 {
58  //$socid = $user->societe_id;
60 }
61 $result = restrictedArea($user, 'holiday', $id, '');
62 $id = GETPOST('id','int');
63 
64 // Load variable for pagination
65 $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
66 $sortfield = GETPOST('sortfield','alpha');
67 $sortorder = GETPOST('sortorder','alpha');
68 $page = GETPOST('page','int');
69 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
70 $offset = $limit * $page;
71 $pageprev = $page - 1;
72 $pagenext = $page + 1;
73 
74 // Initialize technical objects
75 $object=new Holiday($db);
76 $extrafields = new ExtraFields($db);
77 $diroutputmassaction=$conf->holiday->dir_output . '/temp/massgeneration/'.$user->id;
78 $hookmanager->initHooks(array('holidaylist')); // Note that conf->hooks_modules contains array
79 // Fetch optionals attributes and labels
80 $extralabels = $extrafields->fetch_name_optionals_label('holiday');
81 $search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_');
82 
83 // Default sort order (if not yet defined by previous GETPOST)
84 if (! $sortfield) $sortfield="cp.rowid";
85 if (! $sortorder) $sortorder="DESC";
86 
87 
88 $sall = trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml'));
89 $search_ref = GETPOST('search_ref','alphanohtml');
90 $search_day_create = GETPOST('search_day_create','int');
91 $search_month_create = GETPOST('search_month_create','int');
92 $search_year_create = GETPOST('search_year_create','int');
93 $search_day_start = GETPOST('search_day_start','int');
94 $search_month_start = GETPOST('search_month_start','int');
95 $search_year_start = GETPOST('search_year_start','int');
96 $search_day_end = GETPOST('search_day_end','int');
97 $search_month_end = GETPOST('search_month_end','int');
98 $search_year_end = GETPOST('search_year_end','int');
99 $search_employee = GETPOST('search_employee','int');
100 $search_valideur = GETPOST('search_valideur','int');
101 $search_statut = GETPOST('search_statut','int');
102 $search_type = GETPOST('search_type','int');
103 
104 // List of fields to search into when doing a "search in all"
105 $fieldstosearchall = array(
106  'cp.description'=>'Description',
107  'uu.lastname'=>'EmployeeLastname',
108  'uu.firstname'=>'EmployeeFirstname'
109 );
110 
111 
112 
113 /*
114  * Actions
115  */
116 
117 if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; }
118 if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
119 
120 $parameters=array();
121 $reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
122 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
123 
124 if (empty($reshook))
125 {
126  // Selection of new fields
127  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
128 
129  // Purge search criteria
130  if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers
131  {
132  $search_ref="";
133  $search_month_create="";
134  $search_year_create="";
135  $search_month_start="";
136  $search_year_start="";
137  $search_month_end="";
138  $search_year_end="";
139  $search_employee="";
140  $search_valideur="";
141  $search_statut="";
142  $search_type='';
143  $toselect='';
144  $search_array_options=array();
145  }
146  if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')
147  || GETPOST('button_search_x','alpha') || GETPOST('button_search.x','alpha') || GETPOST('button_search','alpha'))
148  {
149  $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation
150  }
151 
152  // Mass actions
153  $objectclass='Holiday';
154  $objectlabel='Holiday';
155  $permtoread = $user->rights->holiday->read;
156  $permtodelete = $user->rights->holiday->delete;
157  $uploaddir = $conf->holiday->dir_output;
158  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
159 }
160 
161 
162 
163 
164 /*
165  * View
166  */
167 
168 $form = new Form($db);
169 $formother = new FormOther($db);
170 
171 $holiday = new Holiday($db);
172 $holidaystatic=new Holiday($db);
173 $fuser = new User($db);
174 
175 // Update sold
176 $result = $holiday->updateBalance();
177 
178 $max_year = 5;
179 $min_year = 10;
180 $filter='';
181 
182 llxHeader('', $langs->trans('CPTitreMenu'));
183 
184 $order = $db->order($sortfield,$sortorder).$db->plimit($limit + 1, $offset);
185 
186 // Ref
187 if(!empty($search_ref))
188 {
189  $filter.= " AND cp.rowid = ".(int) $db->escape($search_ref);
190 }
191 
192 // Start date
193 if($search_year_start > 0) {
194  if($search_month_start > 0) {
195  $filter .= " AND (cp.date_debut BETWEEN '".$db->idate(dol_get_first_day($search_year_start,$search_month_start,1))."' AND '".$db->idate(dol_get_last_day($search_year_start,$search_month_start,1))."')";
196  //$filter.= " AND date_format(cp.date_debut, '%Y-%m') = '$search_year_start-$search_month_start'";
197  } else {
198  $filter .= " AND (cp.date_debut BETWEEN '".$db->idate(dol_get_first_day($search_year_start,1,1))."' AND '".$db->idate(dol_get_last_day($search_year_start,12,1))."')";
199  //$filter.= " AND date_format(cp.date_debut, '%Y') = '$search_year_start'";
200  }
201 } else {
202  if($search_month_start > 0) {
203  $filter.= " AND date_format(cp.date_debut, '%m') = '".$db->escape($search_month_start)."'";
204  }
205 }
206 
207 // End date
208 if($search_year_end > 0) {
209  if($search_month_end > 0) {
210  $filter .= " AND (cp.date_fin BETWEEN '".$db->idate(dol_get_first_day($search_year_end,$search_month_end,1))."' AND '".$db->idate(dol_get_last_day($search_year_end,$search_month_end,1))."')";
211  //$filter.= " AND date_format(cp.date_fin, '%Y-%m') = '$search_year_end-$search_month_end'";
212  } else {
213  $filter .= " AND (cp.date_fin BETWEEN '".$db->idate(dol_get_first_day($search_year_end,1,1))."' AND '".$db->idate(dol_get_last_day($search_year_end,12,1))."')";
214  //$filter.= " AND date_format(cp.date_fin, '%Y') = '$search_year_end'";
215  }
216 } else {
217  if($search_month_end > 0) {
218  $filter.= " AND date_format(cp.date_fin, '%m') = '".$db->escape($search_month_end)."'";
219  }
220 }
221 
222 // Create date
223 if($search_year_create > 0) {
224  if($search_month_create > 0) {
225  $filter .= " AND (cp.date_create BETWEEN '".$db->idate(dol_get_first_day($search_year_create,$search_month_create,1))."' AND '".$db->idate(dol_get_last_day($search_year_create,$search_month_create,1))."')";
226  //$filter.= " AND date_format(cp.date_create, '%Y-%m') = '$search_year_create-$search_month_create'";
227  } else {
228  $filter .= " AND (cp.date_create BETWEEN '".$db->idate(dol_get_first_day($search_year_create,1,1))."' AND '".$db->idate(dol_get_last_day($search_year_create,12,1))."')";
229  //$filter.= " AND date_format(cp.date_create, '%Y') = '$search_year_create'";
230  }
231 } else {
232  if($search_month_create > 0) {
233  $filter.= " AND date_format(cp.date_create, '%m') = '".$db->escape($search_month_create)."'";
234  }
235 }
236 
237 // Employee
238 if(!empty($search_employee) && $search_employee != -1) {
239  $filter.= " AND cp.fk_user = '".$db->escape($search_employee)."'\n";
240 }
241 
242 // Validator
243 if(!empty($search_valideur) && $search_valideur != -1) {
244  $filter.= " AND cp.fk_validator = '".$db->escape($search_valideur)."'\n";
245 }
246 
247 // Type
248 if (!empty($search_type) && $search_type != -1) {
249  $filter.= ' AND cp.fk_type IN ('.$db->escape($search_type).')';
250 }
251 
252 // Status
253 if(!empty($search_statut) && $search_statut != -1) {
254  $filter.= " AND cp.statut = '".$db->escape($search_statut)."'\n";
255 }
256 // Search all
257 if (!empty($sall))
258 {
259  $filter.= natural_search(array_keys($fieldstosearchall), $sall);
260 }
261 
262 if (empty($user->rights->holiday->read_all)) $filter.=' AND cp.fk_user IN ('.join(',',$childids).')';
263 
264 
265 // Récupération de l'ID de l'utilisateur
266 $user_id = $user->id;
267 
268 if ($id > 0)
269 {
270  // Charge utilisateur edite
271  $fuser->fetch($id, '', '', 1);
272  $fuser->getrights();
273  $user_id = $fuser->id;
274 
275  $search_employee = $user_id;
276 }
277 
278 // Récupération des congés payés de l'utilisateur ou de tous les users de sa hierarchy
279 // Load array $holiday->holiday
280 if (empty($user->rights->holiday->read_all) || $id > 0)
281 {
282  if ($id > 0) $result = $holiday->fetchByUser($id, $order, $filter);
283  else $result = $holiday->fetchByUser(join(',',$childids), $order, $filter);
284 }
285 else
286 {
287  $result = $holiday->fetchAll($order, $filter);
288 }
289 // Si erreur SQL
290 if ($result == '-1')
291 {
292  print load_fiche_titre($langs->trans('CPTitreMenu'), '', 'title_hrm.png');
293 
294  dol_print_error($db, $langs->trans('Error').' '.$holiday->error);
295  exit();
296 }
297 
298 
299 // Show table of vacations
300 
301 $num = count($holiday->holiday);
302 
303 $arrayofselected=is_array($toselect)?$toselect:array();
304 
305 $param='';
306 if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
307 if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
308 if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
309 if ($search_ref) $param.='&search_ref='.urlencode($search_ref);
310 if ($search_day_create) $param.='&search_day_create='.urlencode($search_day_create);
311 if ($search_month_create) $param.='&search_month_create='.urlencode($search_month_create);
312 if ($search_year_create) $param.='&search_year_create='.urlencode($search_year_create);
313 if ($search_search_day_start) $param.='&search_day_start='.urlencode($search_day_start);
314 if ($search_month_start) $param.='&search_month_start='.urlencode($search_month_start);
315 if ($search_year_start) $param.='&search_year_start='.urlencode($search_year_start);
316 if ($search_day_end) $param.='&search_day_end='.urlencode($search_day_end);
317 if ($search_month_end) $param.='&search_month_end='.urlencode($search_month_end);
318 if ($search_year_end) $param.='&search_year_end='.urlencode($search_year_end);
319 if ($search_employee > 0) $param.='&search_employee='.urlencode($search_employee);
320 if ($search_valideur > 0) $param.='&search_valideur='.urlencode($search_valideur);
321 if ($search_type > 0) $param.='&search_type='.urlencode($search_type);
322 if ($search_statut > 0) $param.='&search_statut='.urlencode($search_statut);
323 
324 // List of mass actions available
325 $arrayofmassactions = array(
326 //'presend'=>$langs->trans("SendByMail"),
327 //'builddoc'=>$langs->trans("PDFMerge"),
328 );
329 if ($user->rights->holiday->delete) $arrayofmassactions['predelete']=$langs->trans("Delete");
330 if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
331 $massactionbutton=$form->selectMassAction('', $arrayofmassactions);
332 
333 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
334 if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
335 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
336 print '<input type="hidden" name="action" value="list">';
337 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
338 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
339 print '<input type="hidden" name="page" value="'.$page.'">';
340 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
341 if ($id > 0) print '<input type="hidden" name="id" value="'.$id.'">';
342 
343 if ($id > 0) // For user tab
344 {
345  $title = $langs->trans("User");
346  $linkback = '<a href="'.DOL_URL_ROOT.'/user/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
347  $head = user_prepare_head($fuser);
348 
349  dol_fiche_head($head, 'paidholidays', $title, -1, 'user');
350 
351  dol_banner_tab($fuser,'id',$linkback,$user->rights->user->user->lire || $user->admin);
352 
353  if (empty($conf->global->HOLIDAY_HIDE_BALANCE))
354  {
355  print '<div class="underbanner clearboth"></div>';
356 
357  print '<br>';
358 
359  showMyBalance($holiday, $user_id);
360  }
361 
362  dol_fiche_end();
363 
364  print '<div class="tabsAction">';
365 
366  $canedit=(($user->id == $user_id && $user->rights->holiday->write) || ($user->id != $user_id && $user->rights->holiday->write_all));
367 
368  // Boutons d'actions
369  if ($canedit)
370  {
371  print '<a href="'.DOL_URL_ROOT.'/holiday/card.php?action=request&fuserid='.$user_id.'" class="butAction">'.$langs->trans("AddCP").'</a>';
372  }
373 
374  print '</div>';
375 }
376 else
377 {
378  $nbtotalofrecords = count($holiday->holiday);
379  //print $num;
380  //print count($holiday->holiday);
381 
382  $newcardbutton='';
383  if ($user->rights->holiday->write)
384  {
385  $newcardbutton='<a class="butActionNew" href="'.DOL_URL_ROOT.'/holiday/card.php?action=request"><span class="valignmiddle">'.$langs->trans('MenuAddCP').'</span>';
386  $newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
387  $newcardbutton.= '</a>';
388  }
389 
390  print_barre_liste($langs->trans("ListeCP"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_hrm.png', 0, $newcardbutton, '', $limit);
391 
392  $topicmail="Information";
393  $modelmail="leaverequest";
394  $objecttmp=new Holiday($db);
395  $trackid='leav'.$object->id;
396  include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
397 }
398 
399 if ($sall)
400 {
401  foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
402  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall).'</div>';
403 }
404 
405 $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
406 $selectedfields=''; // $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
407 $selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
408 
409 print '<div class="div-table-responsive">';
410 print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
411 
412 // Filters
413 print '<tr class="liste_titre_filter">';
414 print '<td class="liste_titre">';
415 print '<input class="flat" size="4" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
416 print '</td>';
417 
418 // Create date
419 print '<td class="liste_titre" align="center">';
420 print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_month_create" value="'.dol_escape_htmltag($search_month_create).'">';
421 $formother->select_year($search_year_create, 'search_year_create', 1, $min_year, 0);
422 print '</td>';
423 
424 
425 $morefilter = 'AND employee = 1';
426 if (! empty($conf->global->HOLIDAY_FOR_NON_SALARIES_TOO)) $morefilter = '';
427 
428 // User
429 $disabled=0;
430 // If into the tab holiday of a user ($id is set in such a case)
431 if ($id && ! GETPOSTISSET('search_employee'))
432 {
433  $search_employee=$id;
434  $disabled=1;
435 }
436 if (! empty($user->rights->holiday->read_all)) // Can see all
437 {
438  if (GETPOSTISSET('search_employee')) $search_employee=GETPOST('search_employee','int');
439  print '<td class="liste_titre maxwidthonsmartphone" align="left">';
440  print $form->select_dolusers($search_employee, "search_employee", 1, "", $disabled, '', '', 0, 0, 0, $morefilter, 0, '', 'maxwidth200');
441  print '</td>';
442 }
443 else
444 {
445  if (GETPOSTISSET('search_employee')) $search_employee=GETPOST('search_employee','int');
446  print '<td class="liste_titre maxwidthonsmartphone" align="left">';
447  print $form->select_dolusers($search_employee, "search_employee", 1, "", $disabled, 'hierarchyme', '', 0, 0, 0, $morefilter, 0, '', 'maxwidth200');
448  print '</td>';
449 }
450 
451 // Approve
452 if ($user->rights->holiday->read_all)
453 {
454  print '<td class="liste_titre maxwidthonsmartphone" align="left">';
455 
456  $validator = new UserGroup($db);
457  $excludefilter=$user->admin?'':'u.rowid <> '.$user->id;
458  $valideurobjects = $validator->listUsersForGroup($excludefilter);
459  $valideurarray = array();
460  foreach($valideurobjects as $val) $valideurarray[$val->id]=$val->id;
461  print $form->select_dolusers($search_valideur, "search_valideur", 1, "", 0, $valideurarray, '', 0, 0, 0, $morefilter, 0, '', 'maxwidth200');
462  print '</td>';
463 }
464 else
465 {
466  print '<td class="liste_titre">&nbsp;</td>';
467 }
468 
469 // Type
470 print '<td class="liste_titre">';
471 if (empty($mysoc->country_id)) {
472  setEventMessages(null, array($langs->trans("ErrorSetACountryFirst"),$langs->trans("CompanyFoundation")),'errors');
473 } else {
474  $typeleaves=$holidaystatic->getTypes(1,-1);
475  $arraytypeleaves=array();
476  foreach($typeleaves as $key => $val)
477  {
478  $labeltoshow = ($langs->trans($val['code'])!=$val['code'] ? $langs->trans($val['code']) : $val['label']);
479  //$labeltoshow .= ($val['delay'] > 0 ? ' ('.$langs->trans("NoticePeriod").': '.$val['delay'].' '.$langs->trans("days").')':'');
480  $arraytypeleaves[$val['rowid']]=$labeltoshow;
481  }
482  print $form->selectarray('search_type', $arraytypeleaves, $search_type, 1);
483 }
484 print '</td>';
485 
486 // Duration
487 print '<td class="liste_titre">&nbsp;</td>';
488 
489 // Start date
490 print '<td class="liste_titre" align="center">';
491 print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_month_start" value="'.dol_escape_htmltag($search_month_start).'">';
492 $formother->select_year($search_year_start,'search_year_start',1, $min_year, $max_year);
493 print '</td>';
494 
495 // End date
496 print '<td class="liste_titre" align="center">';
497 print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_month_end" value="'.dol_escape_htmltag($search_month_end).'">';
498 $formother->select_year($search_year_end,'search_year_end',1, $min_year, $max_year);
499 print '</td>';
500 
501 // Status
502 print '<td class="liste_titre maxwidthonsmartphone maxwidth200" align="right">';
503 $holiday->selectStatutCP($search_statut, 'search_statut');
504 print '</td>';
505 
506 // Actions
507 print '<td class="liste_titre" align="right">';
508 $searchpicto=$form->showFilterAndCheckAddButtons(0);
509 print $searchpicto;
510 print '</td>';
511 
512 print "</tr>\n";
513 
514 print '<tr class="liste_titre">';
515 print_liste_field_titre("Ref",$_SERVER["PHP_SELF"],"cp.ref","",$param,'',$sortfield,$sortorder);
516 print_liste_field_titre("DateCreateCP",$_SERVER["PHP_SELF"],"cp.date_create","",$param,'align="center"',$sortfield,$sortorder);
517 print_liste_field_titre("Employee",$_SERVER["PHP_SELF"],"cp.fk_user","",$param,'',$sortfield,$sortorder);
518 print_liste_field_titre("ValidatorCP",$_SERVER["PHP_SELF"],"cp.fk_validator","",$param,'',$sortfield,$sortorder);
519 print_liste_field_titre("Type",$_SERVER["PHP_SELF"],'','',$param,'',$sortfield,$sortorder);
520 print_liste_field_titre("NbUseDaysCPShort",$_SERVER["PHP_SELF"],'','',$pram,'align="right"',$sortfield,$sortorder);
521 print_liste_field_titre("DateDebCP",$_SERVER["PHP_SELF"],"cp.date_debut","",$param,'align="center"',$sortfield,$sortorder);
522 print_liste_field_titre("DateFinCP",$_SERVER["PHP_SELF"],"cp.date_fin","",$param,'align="center"',$sortfield,$sortorder);
523 print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"cp.statut","",$param,'align="right"',$sortfield,$sortorder);
524 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],"",'',$param,'align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n";
525 print "</tr>\n";
526 
527 $listhalfday=array('morning'=>$langs->trans("Morning"),"afternoon"=>$langs->trans("Afternoon"));
528 
529 
530 // If we ask a dedicated card and not allow to see it, we forc on user.
531 if ($id && empty($user->rights->holiday->read_all) && ! in_array($id, $childids))
532 {
533  $langs->load("errors");
534  print '<tr class="oddeven opacitymediuem"><td colspan="10">'.$langs->trans("NotEnoughPermissions").'</td></tr>';
535  $result = 0;
536 }
537 // Lines
538 elseif (! empty($holiday->holiday) && !empty($mysoc->country_id))
539 {
540  $userstatic = new User($db);
541  $approbatorstatic = new User($db);
542 
543  $typeleaves=$holiday->getTypes(1,-1);
544 
545  foreach($holiday->holiday as $infos_CP)
546  {
547  // Leave request
548  $holidaystatic->id=$infos_CP['rowid'];
549  $holidaystatic->ref=($infos_CP['ref']?$infos_CP['ref']:$infos_CP['rowid']);
550 
551  // User
552  $userstatic->id=$infos_CP['fk_user'];
553  $userstatic->lastname=$infos_CP['user_lastname'];
554  $userstatic->firstname=$infos_CP['user_firstname'];
555  $userstatic->login=$infos_CP['user_login'];
556  $userstatic->statut=$infos_CP['user_statut'];
557  $userstatic->photo=$infos_CP['user_photo'];
558 
559  // Validator
560  $approbatorstatic->id=$infos_CP['fk_validator'];
561  $approbatorstatic->lastname=$infos_CP['validator_lastname'];
562  $approbatorstatic->firstname=$infos_CP['validator_firstname'];
563  $approbatorstatic->login=$infos_CP['validator_login'];
564  $approbatorstatic->statut=$infos_CP['validator_statut'];
565  $approbatorstatic->photo=$infos_CP['validator_photo'];
566 
567  $date = $infos_CP['date_create'];
568 
569  $starthalfday=($infos_CP['halfday'] == -1 || $infos_CP['halfday'] == 2)?'afternoon':'morning';
570  $endhalfday=($infos_CP['halfday'] == 1 || $infos_CP['halfday'] == 2)?'morning':'afternoon';
571 
572  print '<tr class="oddeven">';
573  print '<td>';
574  print $holidaystatic->getNomUrl(1, 1);
575  print '</td>';
576  print '<td style="text-align: center;">'.dol_print_date($date,'day').'</td>';
577  print '<td>'.$userstatic->getNomUrl(-1, 'leave').'</td>';
578  print '<td>'.$approbatorstatic->getNomUrl(-1).'</td>';
579  print '<td>';
580  $labeltypeleavetoshow = ($langs->trans($typeleaves[$infos_CP['fk_type']]['code'])!=$typeleaves[$infos_CP['fk_type']]['code'] ? $langs->trans($typeleaves[$infos_CP['fk_type']]['code']) : $typeleaves[$infos_CP['fk_type']]['label']);
581  print empty($typeleaves[$infos_CP['fk_type']]['label']) ? $langs->trans("TypeWasDisabledOrRemoved",$infos_CP['fk_type']) : $labeltypeleavetoshow;
582  print '</td>';
583  print '<td align="right">';
584  $nbopenedday=num_open_day($infos_CP['date_debut_gmt'], $infos_CP['date_fin_gmt'], 0, 1, $infos_CP['halfday']);
585  print $nbopenedday.' '.$langs->trans('DurationDays');
586  print '</td>';
587  print '<td align="center">';
588  print dol_print_date($infos_CP['date_debut'],'day');
589  print ' <span class="opacitymedium">('.$langs->trans($listhalfday[$starthalfday]).')</span>';
590  print '</td>';
591  print '<td align="center">';
592  print dol_print_date($infos_CP['date_fin'],'day');
593  print ' <span class="opacitymedium">('.$langs->trans($listhalfday[$endhalfday]).')</span>';
594  print '</td>';
595  print '<td align="right">'.$holidaystatic->LibStatut($infos_CP['statut'],5).'</td>';
596 
597  // Action column
598  print '<td class="nowrap" align="center">';
599  if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
600  {
601  $selected=0;
602  if (in_array($infos_CP['rowid'], $arrayofselected)) $selected=1;
603  print '<input id="cb'.$infos_CP['rowid'].'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$infos_CP['rowid'].'"'.($selected?' checked="checked"':'').'>';
604  }
605  print '</td>';
606 
607  print '</tr>'."\n";
608  }
609 }
610 
611 // Si il n'y a pas d'enregistrement suite à une recherche
612 if ($result == '2')
613 {
614  print '<tr>';
615  print '<td colspan="10" class="opacitymedium">'.$langs->trans('NoRecordFound').'</td>';
616  print '</tr>';
617 }
618 
619 print '</table>';
620 print '</div>';
621 
622 print '</form>';
623 
624 /*if ($user_id == $user->id)
625 {
626  print '<br>';
627  print '<div style="float: right; margin-top: 8px;">';
628  print '<a href="./card.php?action=request" class="butAction">'.$langs->trans('AddCP').'</a>';
629  print '</div>';
630 }*/
631 
632 // End of page
633 llxFooter();
634 $db->close();
635 
636 
637 
638 
639 
647 function showMyBalance($holiday, $user_id)
648 {
649  global $conf, $langs;
650 
651  $alltypeleaves=$holiday->getTypes(1,-1); // To have labels
652 
653  $out='';
654  $nb_holiday=0;
655  $typeleaves=$holiday->getTypes(1,1);
656  foreach($typeleaves as $key => $val)
657  {
658  $nb_type = $holiday->getCPforUser($user_id, $val['rowid']);
659  $nb_holiday += $nb_type;
660  $out .= ' - '.$val['label'].': <strong>'.($nb_type?price2num($nb_type):0).'</strong><br>';
661  }
662  print $langs->trans('SoldeCPUser', round($nb_holiday,5)).'<br>';
663  print $out;
664 }
Class of the module paid holiday.
llxFooter()
Empty footer.
Definition: wrapper.php:56
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print
Draft customers invoices.
Definition: index.php:91
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
user_prepare_head($object)
Prepare array with list of tabs.
num_open_day($timestampStart, $timestampEnd, $inhour=0, $lastday=0, $halfday=0, $country_code='')
Function to return number of working days (and text of units) between two dates (working days) ...
Definition: date.lib.php:895
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:41
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
Definition: date.lib.php:453
Class to manage user groups.
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Class to manage standard extra fields.
Class to manage generation of HTML components Only common components must be here.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='title_generic.png', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0)
Print a title with navigation controls for pagination.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting a parameter.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='')
Get title line of an array.
dol_fiche_end($notab=0)
Show tab footer of a card.
Classe permettant la generation de composants html autre Only common components are here...
llxHeader()
Empty header.
Definition: wrapper.php:44
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
dol_print_date($time, $format='', $tzoutput='tzserver', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
Definition: date.lib.php:467
showMyBalance($holiday, $user_id)
Show balance of user.
Definition: list.php:647
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.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="")
Show title line of an array.
price2num($amount, $rounding='', $alreadysqlnb=0)
Function that return a number with universal decimal format (decimal separator is &#39;...
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='')
Show tab header of a card.