dolibarr  7.0.0-beta
list.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2011 Dimitri Mouillard <dmouillard@teclib.com>
3  * Copyright (C) 2013-2017 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2012-2016 Regis Houssin <regis.houssin@capnetworks.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 $langs->loadLangs(array('users', 'holidays', 'hrm'));
37 
38 // Protection if external user
39 if ($user->societe_id > 0) accessforbidden();
40 
41 $action = GETPOST('action','alpha'); // The action 'add', 'create', 'edit', 'update', 'view', ...
42 $massaction = GETPOST('massaction','alpha'); // The bulk action (combo box choice into lists)
43 $show_files = GETPOST('show_files','int'); // Show files area generated by bulk actions ?
44 $confirm = GETPOST('confirm','alpha'); // Result of a confirmation
45 $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
46 $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
47 $contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'myobjectlist'; // To manage different context of search
48 $backtopage = GETPOST('backtopage','alpha'); // Go back to a dedicated page
49 $optioncss = GETPOST('optioncss','aZ'); // Option for the css output (always '' except when 'print')
50 
51 // Load variable for pagination
52 $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
53 $sortfield = GETPOST('sortfield','alpha');
54 $sortorder = GETPOST('sortorder','alpha');
55 $page = 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 
61 // Initialize technical objects
62 $object=new Holiday($db);
63 $extrafields = new ExtraFields($db);
64 $diroutputmassaction=$conf->holiday->dir_output . '/temp/massgeneration/'.$user->id;
65 $hookmanager->initHooks(array('holidaylist')); // Note that conf->hooks_modules contains array
66 // Fetch optionals attributes and labels
67 $extralabels = $extrafields->fetch_name_optionals_label('holiday');
68 $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_');
69 
70 // Default sort order (if not yet defined by previous GETPOST)
71 if (! $sortfield) $sortfield="cp.rowid";
72 if (! $sortorder) $sortorder="DESC";
73 
74 $id = GETPOST('id','int');
75 
76 $sall = trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml'));
77 $search_ref = GETPOST('search_ref');
78 $month_create = GETPOST('month_create');
79 $year_create = GETPOST('year_create');
80 $month_start = GETPOST('month_start');
81 $year_start = GETPOST('year_start');
82 $month_end = GETPOST('month_end');
83 $year_end = GETPOST('year_end');
84 $search_employee = GETPOST('search_employee');
85 $search_valideur = GETPOST('search_valideur');
86 $search_statut = GETPOST('select_statut');
87 $search_type = GETPOST('search_type','int');
88 
89 // List of fields to search into when doing a "search in all"
90 $fieldstosearchall = array(
91  'cp.description'=>'Description',
92  'uu.lastname'=>'EmployeeLastname',
93  'uu.firstname'=>'EmployeeFirstname'
94 );
95 
96 
97 
98 /*
99  * Actions
100  */
101 
102 if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; }
103 if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
104 
105 $parameters=array();
106 $reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
107 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
108 
109 if (empty($reshook))
110 {
111  // Selection of new fields
112  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
113 
114  // Purge search criteria
115  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
116  {
117  $search_ref="";
118  $month_create="";
119  $year_create="";
120  $month_start="";
121  $year_start="";
122  $month_end="";
123  $year_end="";
124  $search_employee="";
125  $search_valideur="";
126  $search_statut="";
127  $search_type='';
128  $toselect='';
129  $search_array_options=array();
130  }
131  if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')
132  || GETPOST('button_search_x','alpha') || GETPOST('button_search.x','alpha') || GETPOST('button_search','alpha'))
133  {
134  $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation
135  }
136 
137  // Mass actions
138  $objectclass='Holiday';
139  $objectlabel='Holiday';
140  $permtoread = $user->rights->holiday->read;
141  $permtodelete = $user->rights->holiday->delete;
142  $uploaddir = $conf->holiday->dir_output;
143  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
144 }
145 
146 
147 
148 
149 /*
150  * View
151  */
152 
153 $form = new Form($db);
154 $formother = new FormOther($db);
155 
156 $holiday = new Holiday($db);
157 $holidaystatic=new Holiday($db);
158 $fuser = new User($db);
159 
160 $childids = $user->getAllChildIds();
161 $childids[]=$user->id;
162 
163 // Update sold
164 $result = $holiday->updateBalance();
165 
166 $max_year = 5;
167 $min_year = 10;
168 $filter='';
169 
170 llxHeader('', $langs->trans('CPTitreMenu'));
171 
172 $order = $db->order($sortfield,$sortorder).$db->plimit($limit + 1, $offset);
173 
174 // Ref
175 if(!empty($search_ref))
176 {
177  $filter.= " AND cp.rowid = ".$db->escape($search_ref);
178 }
179 
180 // Start date
181 if($year_start > 0) {
182  if($month_start > 0) {
183  $filter .= " AND (cp.date_debut BETWEEN '".$db->idate(dol_get_first_day($year_start,$month_start,1))."' AND '".$db->idate(dol_get_last_day($year_start,$month_start,1))."')";
184  //$filter.= " AND date_format(cp.date_debut, '%Y-%m') = '$year_start-$month_start'";
185  } else {
186  $filter .= " AND (cp.date_debut BETWEEN '".$db->idate(dol_get_first_day($year_start,1,1))."' AND '".$db->idate(dol_get_last_day($year_start,12,1))."')";
187  //$filter.= " AND date_format(cp.date_debut, '%Y') = '$year_start'";
188  }
189 } else {
190  if($month_start > 0) {
191  $filter.= " AND date_format(cp.date_debut, '%m') = '".$db->escape($month_start)."'";
192  }
193 }
194 
195 // End date
196 if($year_end > 0) {
197  if($month_end > 0) {
198  $filter .= " AND (cp.date_fin BETWEEN '".$db->idate(dol_get_first_day($year_end,$month_end,1))."' AND '".$db->idate(dol_get_last_day($year_end,$month_end,1))."')";
199  //$filter.= " AND date_format(cp.date_fin, '%Y-%m') = '$year_end-$month_end'";
200  } else {
201  $filter .= " AND (cp.date_fin BETWEEN '".$db->idate(dol_get_first_day($year_end,1,1))."' AND '".$db->idate(dol_get_last_day($year_end,12,1))."')";
202  //$filter.= " AND date_format(cp.date_fin, '%Y') = '$year_end'";
203  }
204 } else {
205  if($month_end > 0) {
206  $filter.= " AND date_format(cp.date_fin, '%m') = '".$db->escape($month_end)."'";
207  }
208 }
209 
210 // Create date
211 if($year_create > 0) {
212  if($month_create > 0) {
213  $filter .= " AND (cp.date_create BETWEEN '".$db->idate(dol_get_first_day($year_create,$month_create,1))."' AND '".$db->idate(dol_get_last_day($year_create,$month_create,1))."')";
214  //$filter.= " AND date_format(cp.date_create, '%Y-%m') = '$year_create-$month_create'";
215  } else {
216  $filter .= " AND (cp.date_create BETWEEN '".$db->idate(dol_get_first_day($year_create,1,1))."' AND '".$db->idate(dol_get_last_day($year_create,12,1))."')";
217  //$filter.= " AND date_format(cp.date_create, '%Y') = '$year_create'";
218  }
219 } else {
220  if($month_create > 0) {
221  $filter.= " AND date_format(cp.date_create, '%m') = '".$db->escape($month_create)."'";
222  }
223 }
224 
225 // Employee
226 if(!empty($search_employee) && $search_employee != -1) {
227  $filter.= " AND cp.fk_user = '".$db->escape($search_employee)."'\n";
228 }
229 
230 // Validator
231 if(!empty($search_valideur) && $search_valideur != -1) {
232  $filter.= " AND cp.fk_validator = '".$db->escape($search_valideur)."'\n";
233 }
234 
235 // Type
236 if (!empty($search_type) && $search_type != -1) {
237  $filter.= ' AND cp.fk_type IN ('.$db->escape($search_type).')';
238 }
239 
240 // Status
241 if(!empty($search_statut) && $search_statut != -1) {
242  $filter.= " AND cp.statut = '".$db->escape($search_statut)."'\n";
243 }
244 // Search all
245 if (!empty($sall))
246 {
247  $filter.= natural_search(array_keys($fieldstosearchall), $sall);
248 }
249 
250 if (empty($user->rights->holiday->read_all)) $filter.=' AND cp.fk_user IN ('.join(',',$childids).')';
251 
252 
253 // Récupération de l'ID de l'utilisateur
254 $user_id = $user->id;
255 
256 if ($id > 0)
257 {
258  // Charge utilisateur edite
259  $fuser->fetch($id, '', '', 1);
260  $fuser->getrights();
261  $user_id = $fuser->id;
262 
263  $search_employee = $user_id;
264 }
265 
266 // Récupération des congés payés de l'utilisateur ou de tous les users
267 if (empty($user->rights->holiday->read_all) || $id > 0)
268 {
269  $result = $holiday->fetchByUser($user_id,$order,$filter); // Load array $holiday->holiday
270 }
271 else
272 {
273  $result = $holiday->fetchAll($order,$filter); // Load array $holiday->holiday
274 }
275 // Si erreur SQL
276 if ($result == '-1')
277 {
278  print load_fiche_titre($langs->trans('CPTitreMenu'), '', 'title_hrm.png');
279 
280  dol_print_error($db, $langs->trans('Error').' '.$holiday->error);
281  exit();
282 }
283 
284 
285 // Show table of vacations
286 
287 $num = count($holiday->holiday);
288 
289 $arrayofselected=is_array($toselect)?$toselect:array();
290 
291 $param='';
292 if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
293 if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
294 if ($optioncss != '') $param.='&optioncss='.$optioncss;
295 
296 // List of mass actions available
297 $arrayofmassactions = array(
298 //'presend'=>$langs->trans("SendByMail"),
299 //'builddoc'=>$langs->trans("PDFMerge"),
300 );
301 if ($user->rights->holiday->delete) $arrayofmassactions['predelete']=$langs->trans("Delete");
302 if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
303 $massactionbutton=$form->selectMassAction('', $arrayofmassactions);
304 
305 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
306 if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
307 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
308 print '<input type="hidden" name="action" value="list">';
309 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
310 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
311 print '<input type="hidden" name="page" value="'.$page.'">';
312 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
313 if ($id > 0) print '<input type="hidden" name="id" value="'.$id.'">';
314 
315 if ($id > 0) // For user tab
316 {
317  $title = $langs->trans("User");
318  $linkback = '<a href="'.DOL_URL_ROOT.'/user/index.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
319  $head = user_prepare_head($fuser);
320 
321  dol_fiche_head($head, 'paidholidays', $title, -1, 'user');
322 
323  dol_banner_tab($fuser,'id',$linkback,$user->rights->user->user->lire || $user->admin);
324 
325  if (empty($conf->global->HOLIDAY_HIDE_BALANCE))
326  {
327  print '<div class="underbanner clearboth"></div>';
328 
329  print '<br>';
330 
331  showMyBalance($holiday, $user_id);
332  }
333 
334  dol_fiche_end();
335 
336  print '<div class="tabsAction">';
337 
338  $canedit=(($user->id == $user_id && $user->rights->holiday->write) || ($user->id != $user_id && $user->rights->holiday->write_all));
339 
340  // Boutons d'actions
341  if ($canedit)
342  {
343  print '<a href="'.DOL_URL_ROOT.'/holiday/card.php?action=request&fuserid='.$user_id.'" class="butAction">'.$langs->trans("AddCP").'</a>';
344  }
345 
346  print '</div>';
347 }
348 else
349 {
350  $nbtotalofrecords = count($holiday->holiday);
351  //print $num;
352  //print count($holiday->holiday);
353  print_barre_liste($langs->trans("ListeCP"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_hrm.png', 0, '', '', $limit);
354 
355  $topicmail="Information";
356  $modelmail="leaverequest";
357  $objecttmp=new Holiday($db);
358  $trackid='leav'.$object->id;
359  include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
360 }
361 
362 if ($sall)
363 {
364  foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
365  print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall);
366 }
367 
368 $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
369 $selectedfields=''; // $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
370 $selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
371 
372 print '<div class="div-table-responsive">';
373 print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
374 
375 // Filters
376 print '<tr class="liste_titre_filter">';
377 print '<td class="liste_titre" align="left">';
378 print '<input class="flat" size="4" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
379 print '</td>';
380 
381 // Create date
382 print '<td class="liste_titre" align="center">';
383 print '<input class="flat" type="text" size="1" maxlength="2" name="month_create" value="'.dol_escape_htmltag($month_create).'">';
384 $formother->select_year($year_create,'year_create',1, $min_year, 0);
385 print '</td>';
386 
387 // User
388 if ($user->rights->holiday->write_all)
389 {
390  print '<td class="liste_titre maxwidthonsmartphone" align="left">';
391  print $form->select_dolusers($search_employee,"search_employee",1,"",0,'','',0,0,0,'',0,'','maxwidth200');
392  print '</td>';
393 }
394 else
395 {
396  //print '<td class="liste_titre">&nbsp;</td>';
397  print '<td class="liste_titre maxwidthonsmartphone" align="left">';
398  print $form->select_dolusers($user->id,"search_employee",1,"",1,'','',0,0,0,'',0,'','maxwidth200');
399  print '</td>';
400 }
401 
402 // Approve
403 if($user->rights->holiday->write_all)
404 {
405  print '<td class="liste_titre maxwidthonsmartphone" align="left">';
406 
407  $validator = new UserGroup($db);
408  $excludefilter=$user->admin?'':'u.rowid <> '.$user->id;
409  $valideurobjects = $validator->listUsersForGroup($excludefilter);
410  $valideurarray = array();
411  foreach($valideurobjects as $val) $valideurarray[$val->id]=$val->id;
412  print $form->select_dolusers($search_valideur,"search_valideur",1,"",0,$valideurarray,'', 0, 0, 0, '', 0, '', 'maxwidth200');
413  print '</td>';
414 }
415 else
416 {
417  print '<td class="liste_titre">&nbsp;</td>';
418 }
419 
420 // Type
421 print '<td class="liste_titre">';
422 $typeleaves=$holidaystatic->getTypes(1,-1);
423 $arraytypeleaves=array();
424 foreach($typeleaves as $key => $val)
425 {
426  $labeltoshow = $val['label'];
427  //$labeltoshow .= ($val['delay'] > 0 ? ' ('.$langs->trans("NoticePeriod").': '.$val['delay'].' '.$langs->trans("days").')':'');
428  $arraytypeleaves[$val['rowid']]=$labeltoshow;
429 }
430 print $form->selectarray('search_type', $arraytypeleaves, $search_type, 1);
431 print '</td>';
432 
433 // Duration
434 print '<td class="liste_titre">&nbsp;</td>';
435 
436 // Start date
437 print '<td class="liste_titre" align="center">';
438 print '<input class="flat" type="text" size="1" maxlength="2" name="month_start" value="'.dol_escape_htmltag($month_start).'">';
439 $formother->select_year($year_start,'year_start',1, $min_year, $max_year);
440 print '</td>';
441 
442 // End date
443 print '<td class="liste_titre" align="center">';
444 print '<input class="flat" type="text" size="1" maxlength="2" name="month_end" value="'.dol_escape_htmltag($month_end).'">';
445 $formother->select_year($year_end,'year_end',1, $min_year, $max_year);
446 print '</td>';
447 
448 // Status
449 print '<td class="liste_titre maxwidthonsmartphone maxwidth200" align="right">';
450 $holiday->selectStatutCP($search_statut);
451 print '</td>';
452 
453 // Actions
454 print '<td class="liste_titre" align="right">';
455 $searchpicto=$form->showFilterAndCheckAddButtons(0);
456 print $searchpicto;
457 print '</td>';
458 
459 print "</tr>\n";
460 
461 print '<tr class="liste_titre">';
462 print_liste_field_titre("Ref",$_SERVER["PHP_SELF"],"cp.rowid","",$param,'',$sortfield,$sortorder);
463 print_liste_field_titre("DateCreateCP",$_SERVER["PHP_SELF"],"cp.date_create","",$param,'align="center"',$sortfield,$sortorder);
464 print_liste_field_titre("Employee",$_SERVER["PHP_SELF"],"cp.fk_user","",$param,'',$sortfield,$sortorder);
465 print_liste_field_titre("ValidatorCP",$_SERVER["PHP_SELF"],"cp.fk_validator","",$param,'',$sortfield,$sortorder);
466 print_liste_field_titre("Type",$_SERVER["PHP_SELF"],'','',$param,'',$sortfield,$sortorder);
467 print_liste_field_titre("Duration",$_SERVER["PHP_SELF"],'','',$pram,'align="right"',$sortfield,$sortorder);
468 print_liste_field_titre("DateDebCP",$_SERVER["PHP_SELF"],"cp.date_debut","",$param,'align="center"',$sortfield,$sortorder);
469 print_liste_field_titre("DateFinCP",$_SERVER["PHP_SELF"],"cp.date_fin","",$param,'align="center"',$sortfield,$sortorder);
470 print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"cp.statut","",$param,'align="right"',$sortfield,$sortorder);
471 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n";
472 print "</tr>\n";
473 
474 $listhalfday=array('morning'=>$langs->trans("Morning"),"afternoon"=>$langs->trans("Afternoon"));
475 
476 // Lines
477 if (! empty($holiday->holiday))
478 {
479  $userstatic = new User($db);
480  $approbatorstatic = new User($db);
481 
482  $typeleaves=$holiday->getTypes(1,-1);
483 
484  foreach($holiday->holiday as $infos_CP)
485  {
486  // Leave request
487  $holidaystatic->id=$infos_CP['rowid'];
488  $holidaystatic->ref=$infos_CP['rowid'];
489 
490  // User
491  $userstatic->id=$infos_CP['fk_user'];
492  $userstatic->lastname=$infos_CP['user_lastname'];
493  $userstatic->firstname=$infos_CP['user_firstname'];
494  $userstatic->login=$infos_CP['user_login'];
495  $userstatic->statut=$infos_CP['user_statut'];
496  $userstatic->photo=$infos_CP['user_photo'];
497 
498  // Validator
499  $approbatorstatic->id=$infos_CP['fk_validator'];
500  $approbatorstatic->lastname=$infos_CP['validator_lastname'];
501  $approbatorstatic->firstname=$infos_CP['validator_firstname'];
502  $approbatorstatic->login=$infos_CP['validator_login'];
503  $approbatorstatic->statut=$infos_CP['validator_statut'];
504  $approbatorstatic->photo=$infos_CP['validator_photo'];
505 
506  $date = $infos_CP['date_create'];
507 
508  $starthalfday=($infos_CP['halfday'] == -1 || $infos_CP['halfday'] == 2)?'afternoon':'morning';
509  $endhalfday=($infos_CP['halfday'] == 1 || $infos_CP['halfday'] == 2)?'morning':'afternoon';
510 
511  print '<tr class="oddeven">';
512  print '<td>';
513  print $holidaystatic->getNomUrl(1);
514  print '</td>';
515  print '<td style="text-align: center;">'.dol_print_date($date,'day').'</td>';
516  print '<td>'.$userstatic->getNomUrl(-1, 'leave').'</td>';
517  print '<td>'.$approbatorstatic->getNomUrl(-1).'</td>';
518  print '<td>';
519  print empty($typeleaves[$infos_CP['fk_type']]['label']) ? $langs->trans("TypeWasDisabledOrRemoved",$infos_CP['fk_type']) : $typeleaves[$infos_CP['fk_type']]['label'];
520  print '</td>';
521  print '<td align="right">';
522  $nbopenedday=num_open_day($infos_CP['date_debut_gmt'], $infos_CP['date_fin_gmt'], 0, 1, $infos_CP['halfday']);
523  print $nbopenedday.' '.$langs->trans('DurationDays');
524  print '</td>';
525  print '<td align="center">';
526  print dol_print_date($infos_CP['date_debut'],'day');
527  print ' <span class="opacitymedium">('.$langs->trans($listhalfday[$starthalfday]).')</span>';
528  print '</td>';
529  print '<td align="center">';
530  print dol_print_date($infos_CP['date_fin'],'day');
531  print ' <span class="opacitymedium">('.$langs->trans($listhalfday[$endhalfday]).')</span>';
532  print '</td>';
533  print '<td align="right">'.$holidaystatic->LibStatut($infos_CP['statut'],5).'</td>';
534 
535  // Action column
536  print '<td class="nowrap" align="center">';
537  if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
538  {
539  $selected=0;
540  if (in_array($infos_CP['rowid'], $arrayofselected)) $selected=1;
541  print '<input id="cb'.$infos_CP['rowid'].'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$infos_CP['rowid'].'"'.($selected?' checked="checked"':'').'>';
542  }
543  print '</td>';
544 
545  print '</tr>'."\n";
546 
547  }
548 }
549 
550 // Si il n'y a pas d'enregistrement suite à une recherche
551 if ($result == '2')
552 {
553  print '<tr>';
554  print '<td colspan="10" class="opacitymedium">'.$langs->trans('NoRecordFound').'</td>';
555  print '</tr>';
556 }
557 
558 print '</table>';
559 print '</div>';
560 
561 print '</form>';
562 
563 /*if ($user_id == $user->id)
564 {
565  print '<br>';
566  print '<div style="float: right; margin-top: 8px;">';
567  print '<a href="./card.php?action=request" class="butAction">'.$langs->trans('AddCP').'</a>';
568  print '</div>';
569 }*/
570 
571 llxFooter();
572 
573 $db->close();
574 
575 
576 
577 
578 
586 function showMyBalance($holiday, $user_id)
587 {
588  global $conf, $langs;
589 
590  $alltypeleaves=$holiday->getTypes(1,-1); // To have labels
591 
592  $out='';
593  $nb_holiday=0;
594  $typeleaves=$holiday->getTypes(1,1);
595  foreach($typeleaves as $key => $val)
596  {
597  $nb_type = $holiday->getCPforUser($user_id, $val['rowid']);
598  $nb_holiday += $nb_type;
599  $out .= ' - '.$val['label'].': <strong>'.($nb_type?price2num($nb_type):0).'</strong><br>';
600  }
601  print $langs->trans('SoldeCPUser', round($nb_holiday,5)).'<br>';
602  print $out;
603 }
Class of the module paid holiday.
llxFooter()
Empty footer.
Definition: wrapper.php:58
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
user_prepare_head($object)
Prepare array with list of tabs.
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='')
Show tab header of a card.
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:863
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
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
Definition: date.lib.php:445
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...
if(empty($reshook)) $form
View.
Definition: perms.php:103
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='')
Get title line of an array.
if($_POST["cancel"]==$langs->trans("Cancel")&&!$id) if($action== 'setdatev'&&$user->rights->tax->charges->creer) if($action== 'add'&&$_POST["cancel"]<> $langs->trans("Cancel")) if($action== 'delete') $title
Actions.
Definition: card.php:183
dol_fiche_end($notab=0)
Show tab footer of a card.
Classe permettant la generation de composants html autre Only common components are here...
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id=0, $morecssontable='', $morehtmlcenter='')
Load a title with picto.
llxHeader()
Empty header.
Definition: wrapper.php:46
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:459
print
Draft customers invoices.
Definition: index.php:91
showMyBalance($holiday, $user_id)
Show balance of user.
Definition: list.php:586
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 '...