28 require
'../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
33 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/user/class/usergroup.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/holiday/class/holiday.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/lib/usergroups.lib.php';
40 $langs->loadLangs(array(
'users',
'other',
'holiday',
'hrm'));
43 if ($user->socid > 0) {
47 $action =
GETPOST(
'action',
'aZ09');
48 $massaction =
GETPOST(
'massaction',
'alpha');
49 $show_files =
GETPOST(
'show_files',
'int');
50 $confirm =
GETPOST(
'confirm',
'alpha');
51 $cancel =
GETPOST(
'cancel',
'alpha');
52 $toselect =
GETPOST(
'toselect',
'array');
53 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'holidaylist';
55 $backtopage =
GETPOST(
'backtopage',
'alpha');
56 $optioncss =
GETPOST(
'optioncss',
'aZ');
60 $childids = $user->getAllChildIds(1);
64 if ($user->socid > 0) {
72 if ($id == $user->id) {
75 if (!empty($user->rights->holiday->readall)) {
78 if (!empty($user->rights->holiday->read) && in_array($id, $childids)) {
86 $diroutputmassaction = $conf->holiday->dir_output.
'/temp/massgeneration/'.$user->id;
90 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
91 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
92 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
94 if (empty($page) || $page == -1) {
97 $offset = $limit * $page;
98 $pageprev = $page - 1;
99 $pagenext = $page + 1;
104 $sortfield =
"cp.ref";
107 $sall = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
108 $search_ref =
GETPOST(
'search_ref',
'alphanohtml');
109 $search_day_create =
GETPOST(
'search_day_create',
'int');
110 $search_month_create =
GETPOST(
'search_month_create',
'int');
111 $search_year_create =
GETPOST(
'search_year_create',
'int');
112 $search_day_start =
GETPOST(
'search_day_start',
'int');
113 $search_month_start =
GETPOST(
'search_month_start',
'int');
114 $search_year_start =
GETPOST(
'search_year_start',
'int');
115 $search_day_end =
GETPOST(
'search_day_end',
'int');
116 $search_month_end =
GETPOST(
'search_month_end',
'int');
117 $search_year_end =
GETPOST(
'search_year_end',
'int');
118 $search_employee =
GETPOST(
'search_employee',
'int');
119 $search_valideur =
GETPOST(
'search_valideur',
'int');
121 $search_type =
GETPOST(
'search_type',
'int');
126 $hookmanager->initHooks(array(
'holidaylist'));
129 $extrafields->fetch_name_optionals_label($object->table_element);
131 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
134 $fieldstosearchall = array(
136 'cp.description'=>
'Description',
137 'uu.lastname'=>
'EmployeeLastname',
138 'uu.firstname'=>
'EmployeeFirstname',
142 $arrayfields = array(
143 'cp.ref'=>array(
'label'=>$langs->trans(
"Ref"),
'checked'=>1),
144 'cp.fk_user'=>array(
'label'=>$langs->trans(
"Employee"),
'checked'=>1,
'position'=>20),
145 'cp.fk_validator'=>array(
'label'=>$langs->trans(
"ValidatorCP"),
'checked'=>1,
'position'=>30),
146 'cp.fk_type'=>array(
'label'=>$langs->trans(
"Type"),
'checked'=>1,
'position'=>35),
147 'duration'=>array(
'label'=>$langs->trans(
"NbUseDaysCPShort"),
'checked'=>1,
'position'=>38),
148 'cp.date_debut'=>array(
'label'=>$langs->trans(
"DateStart"),
'checked'=>1,
'position'=>40),
149 'cp.date_fin'=>array(
'label'=>$langs->trans(
"DateEnd"),
'checked'=>1,
'position'=>42),
150 'cp.date_valid'=>array(
'label'=>$langs->trans(
"DateValidation"),
'checked'=>1,
'position'=>60),
151 'cp.date_approve'=>array(
'label'=>$langs->trans(
"DateApprove"),
'checked'=>1,
'position'=>70),
152 'cp.date_create'=>array(
'label'=>$langs->trans(
"DateCreation"),
'checked'=>0,
'position'=>500),
153 'cp.tms'=>array(
'label'=>$langs->trans(
"DateModificationShort"),
'checked'=>0,
'position'=>501),
154 'cp.statut'=>array(
'label'=>$langs->trans(
"Status"),
'checked'=>1,
'position'=>1000),
157 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
159 if (empty($conf->holiday->enabled)) {
160 llxHeader(
'', $langs->trans(
'CPTitreMenu'));
161 print
'<div class="tabBar">';
162 print
'<span style="color: #FF0000;">'.$langs->trans(
'NotActiveModCP').
'</span>';
173 if (
GETPOST(
'cancel',
'alpha')) {
174 $action =
'list'; $massaction =
'';
176 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
180 $parameters = array(
'socid'=>$socid);
181 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
186 if (empty($reshook)) {
188 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
191 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
193 $search_month_create =
"";
194 $search_year_create =
"";
195 $search_month_start =
"";
196 $search_year_start =
"";
197 $search_month_end =
"";
198 $search_year_end =
"";
199 $search_employee =
"";
200 $search_valideur =
"";
204 $search_array_options = array();
206 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
207 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
212 $objectclass =
'Holiday';
213 $objectlabel =
'Holiday';
214 $permissiontoread = $user->rights->holiday->read;
215 $permissiontodelete = $user->rights->holiday->delete;
216 $permissiontoapprove = $user->rights->holiday->approve;
217 $uploaddir = $conf->holiday->dir_output;
218 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
232 $fuser =
new User($db);
233 $holidaystatic =
new Holiday($db);
236 $result = $object->updateBalance();
238 $title = $langs->trans(
'CPTitreMenu');
245 $user_id = $user->id;
249 $fuser->fetch($id,
'',
'', 1);
251 $user_id = $fuser->id;
253 $search_employee = $user_id;
260 $sql .=
" cp.rowid,";
263 $sql .=
" cp.fk_user,";
264 $sql .=
" cp.fk_type,";
265 $sql .=
" cp.date_create,";
266 $sql .=
" cp.tms as date_update,";
267 $sql .=
" cp.description,";
268 $sql .=
" cp.date_debut,";
269 $sql .=
" cp.date_fin,";
270 $sql .=
" cp.halfday,";
271 $sql .=
" cp.statut as status,";
272 $sql .=
" cp.fk_validator,";
273 $sql .=
" cp.date_valid,";
274 $sql .=
" cp.fk_user_valid,";
275 $sql .=
" cp.date_refuse,";
276 $sql .=
" cp.fk_user_refuse,";
277 $sql .=
" cp.date_cancel,";
278 $sql .=
" cp.fk_user_cancel,";
279 $sql .=
" cp.detail_refuse,";
281 $sql .=
" uu.lastname as user_lastname,";
282 $sql .=
" uu.firstname as user_firstname,";
283 $sql .=
" uu.admin as user_admin,";
284 $sql .=
" uu.email as user_email,";
285 $sql .=
" uu.login as user_login,";
286 $sql .=
" uu.statut as user_status,";
287 $sql .=
" uu.photo as user_photo,";
289 $sql .=
" ua.lastname as validator_lastname,";
290 $sql .=
" ua.firstname as validator_firstname,";
291 $sql .=
" ua.admin as validator_admin,";
292 $sql .=
" ua.email as validator_email,";
293 $sql .=
" ua.login as validator_login,";
294 $sql .=
" ua.statut as validator_status,";
295 $sql .=
" ua.photo as validator_photo";
297 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
298 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
299 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
303 $parameters = array();
304 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
305 $sql .= $hookmanager->resPrint;
306 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday as cp";
307 if (isset($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
308 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (cp.rowid = ef.fk_object)";
310 $sql .=
", ".MAIN_DB_PREFIX.
"user as uu, ".MAIN_DB_PREFIX.
"user as ua";
311 $sql .=
" WHERE cp.entity IN (".getEntity(
'holiday').
")";
312 $sql .=
" AND cp.fk_user = uu.rowid AND cp.fk_validator = ua.rowid ";
318 if (!empty($search_ref)) {
322 $sql .=
dolSqlDateFilter(
"cp.date_debut", $search_day_start, $search_month_start, $search_year_start);
324 $sql .=
dolSqlDateFilter(
"cp.date_fin", $search_day_end, $search_month_end, $search_year_end);
326 $sql .=
dolSqlDateFilter(
"cp.date_create", $search_day_create, $search_month_create, $search_year_create);
328 if (!empty($search_employee) && $search_employee != -1) {
329 $sql .=
" AND cp.fk_user = '".$db->escape($search_employee).
"'\n";
332 if (!empty($search_valideur) && $search_valideur != -1) {
333 $sql .=
" AND cp.fk_validator = '".$db->escape($search_valideur).
"'\n";
336 if (!empty($search_type) && $search_type != -1) {
337 $sql .=
' AND cp.fk_type IN ('.$db->sanitize($db->escape($search_type)).
')';
340 if (!empty($search_status) && $search_status != -1) {
341 $sql .=
" AND cp.statut = '".$db->escape($search_status).
"'\n";
344 if (empty($user->rights->holiday->readall)) {
345 $sql .=
' AND cp.fk_user IN ('.$db->sanitize(join(
',', $childids)).
')';
348 $sql .=
" AND cp.fk_user IN (".$db->sanitize($id).
")";
352 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
354 $parameters = array();
355 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
356 $sql .= $hookmanager->resPrint;
358 $sql .= $db->order($sortfield, $sortorder);
361 $nbtotalofrecords =
'';
362 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
363 $result = $db->query($sql);
364 $nbtotalofrecords = $db->num_rows($result);
365 if (($page * $limit) > $nbtotalofrecords) {
371 $sql .= $db->plimit($limit + 1, $offset);
375 $resql = $db->query($sql);
377 $num = $db->num_rows(
$resql);
379 $arrayofselected = is_array($toselect) ? $toselect : array();
382 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
383 $param .=
'&contextpage='.urlencode($contextpage);
385 if ($limit > 0 && $limit != $conf->liste_limit) {
386 $param .=
'&limit='.urlencode($limit);
388 if ($optioncss !=
'') {
389 $param .=
'&optioncss='.urlencode($optioncss);
392 $param .=
'&search_ref='.urlencode($search_ref);
394 if ($search_day_create) {
395 $param .=
'&search_day_create='.urlencode($search_day_create);
397 if ($search_month_create) {
398 $param .=
'&search_month_create='.urlencode($search_month_create);
400 if ($search_year_create) {
401 $param .=
'&search_year_create='.urlencode($search_year_create);
403 if ($search_day_start) {
404 $param .=
'&search_day_start='.urlencode($search_day_start);
406 if ($search_month_start) {
407 $param .=
'&search_month_start='.urlencode($search_month_start);
409 if ($search_year_start) {
410 $param .=
'&search_year_start='.urlencode($search_year_start);
412 if ($search_day_end) {
413 $param .=
'&search_day_end='.urlencode($search_day_end);
415 if ($search_month_end) {
416 $param .=
'&search_month_end='.urlencode($search_month_end);
418 if ($search_year_end) {
419 $param .=
'&search_year_end='.urlencode($search_year_end);
421 if ($search_employee > 0) {
422 $param .=
'&search_employee='.urlencode($search_employee);
424 if ($search_valideur > 0) {
425 $param .=
'&search_valideur='.urlencode($search_valideur);
427 if ($search_type > 0) {
428 $param .=
'&search_type='.urlencode($search_type);
430 if ($search_status > 0) {
431 $param .=
'&search_status='.urlencode($search_status);
434 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
437 $arrayofmassactions = array(
442 if (!empty($user->rights->holiday->delete)) {
443 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
445 if (!empty($user->rights->holiday->approve)) {
446 $arrayofmassactions[
'preapproveleave'] =
img_picto(
'',
'check',
'class="pictofixedwidth"').$langs->trans(
"Approve");
448 if (in_array($massaction, array(
'presend',
'predelete'))) {
449 $arrayofmassactions = array();
451 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
454 print
'<form id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">'.
"\n";
455 if ($optioncss !=
'') {
456 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
458 print
'<input type="hidden" name="token" value="'.newToken().
'">';
459 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
460 print
'<input type="hidden" name="action" value="'.($action ==
'edit' ?
'update' :
'list').
'">';
461 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
462 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
463 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
465 print
'<input type="hidden" name="id" value="'.$id.
'">';
469 $title = $langs->trans(
"User");
470 $linkback =
'<a href="'.DOL_URL_ROOT.
'/user/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
475 dol_banner_tab($fuser,
'id', $linkback, $user->rights->user->user->lire || $user->admin);
477 if (empty($conf->global->HOLIDAY_HIDE_BALANCE)) {
478 print
'<div class="underbanner clearboth"></div>';
489 print
'<div class="tabsAction">';
492 if (!empty($user->rights->holiday->writeall)) {
495 if (!empty($user->rights->holiday->write) && in_array($user_id, $childids)) {
500 print
'<a href="'.DOL_URL_ROOT.
'/holiday/card.php?action=create&fuserid='.$user_id.
'" class="butAction">'.$langs->trans(
"AddCP").
'</a>';
505 $title = $langs->trans(
"ListeCP");
507 $newcardbutton =
dolGetButtonTitle($langs->trans(
'MenuAddCP'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/holiday/card.php?action=create',
'', $user->rights->holiday->write);
509 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'title_hrm', 0, $newcardbutton,
'', $limit, 0, 0, 1);
512 $topicmail =
"Information";
513 $modelmail =
"leaverequest";
515 $trackid =
'leav'.$object->id;
516 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
519 foreach ($fieldstosearchall as $key => $val) {
520 $fieldstosearchall[$key] = $langs->trans($val);
522 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).join(
', ', $fieldstosearchall).
'</div>';
527 $parameters = array();
528 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
529 if (empty($reshook)) {
530 $moreforfilter .= $hookmanager->resPrint;
532 $moreforfilter = $hookmanager->resPrint;
535 if (!empty($moreforfilter)) {
536 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
537 print $moreforfilter;
541 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
542 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
543 $selectedfields .= (count($arrayofmassactions) ?
$form->showCheckAddButtons(
'checkforselect', 1) :
'');
547 if (empty($user->rights->holiday->readall)) {
548 $include =
'hierarchyme';
551 print
'<div class="div-table-responsive">';
552 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
556 print
'<tr class="liste_titre_filter">';
558 if (!empty($arrayfields[
'cp.ref'][
'checked'])) {
559 print
'<td class="liste_titre">';
560 print
'<input class="flat maxwidth50" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
564 if (!empty($arrayfields[
'cp.fk_user'][
'checked'])) {
566 if (!empty($conf->global->HOLIDAY_HIDE_FOR_NON_SALARIES)) {
567 $morefilter =
'AND employee = 1';
574 $search_employee = $id;
578 print
'<td class="liste_titre maxwidthonsmartphone left">';
579 print
$form->select_dolusers($search_employee,
"search_employee", 1,
"", $disabled, $include,
'', 0, 0, 0, $morefilter, 0,
'',
'maxwidth150');
584 if (!empty($arrayfields[
'cp.fk_validator'][
'checked'])) {
585 if ($user->rights->holiday->readall) {
586 print
'<td class="liste_titre maxwidthonsmartphone left">';
588 $excludefilter = $user->admin ?
'' :
'u.rowid <> '.$user->id;
589 $valideurobjects = $validator->listUsersForGroup($excludefilter);
590 $valideurarray = array();
591 foreach ($valideurobjects as $val) {
592 $valideurarray[$val->id] = $val->id;
594 print
$form->select_dolusers($search_valideur,
"search_valideur", 1,
"", 0, $valideurarray,
'', 0, 0, 0, $morefilter, 0,
'',
'maxwidth150');
597 print
'<td class="liste_titre"> </td>';
602 if (!empty($arrayfields[
'cp.fk_type'][
'checked'])) {
603 print
'<td class="liste_titre">';
604 if (empty($mysoc->country_id)) {
605 setEventMessages(
null, array($langs->trans(
"ErrorSetACountryFirst"), $langs->trans(
"CompanyFoundation")),
'errors');
607 $typeleaves = $holidaystatic->getTypes(1, -1);
608 $arraytypeleaves = array();
609 foreach ($typeleaves as $key => $val) {
610 $labeltoshow = ($langs->trans($val[
'code']) != $val[
'code'] ? $langs->trans($val[
'code']) : $val[
'label']);
612 $arraytypeleaves[$val[
'rowid']] = $labeltoshow;
614 print
$form->selectarray(
'search_type', $arraytypeleaves, $search_type, 1, 0, 0,
'', 0, 0, 0,
'',
'', 1);
620 if (!empty($arrayfields[
'duration'][
'checked'])) {
621 print
'<td class="liste_titre"> </td>';
625 if (!empty($arrayfields[
'cp.date_debut'][
'checked'])) {
626 print
'<td class="liste_titre center nowraponall">';
627 print
'<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month_start" value="'.dol_escape_htmltag($search_month_start).
'">';
628 print $formother->selectyear($search_year_start,
'search_year_start', 1, $min_year, $max_year);
633 if (!empty($arrayfields[
'cp.date_fin'][
'checked'])) {
634 print
'<td class="liste_titre center nowraponall">';
635 print
'<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month_end" value="'.dol_escape_htmltag($search_month_end).
'">';
636 print $formother->selectyear($search_year_end,
'search_year_end', 1, $min_year, $max_year);
641 if (!empty($arrayfields[
'cp.date_valid'][
'checked'])) {
642 print
'<td class="liste_titre center nowraponall">';
647 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
649 $parameters = array(
'arrayfields'=>$arrayfields);
650 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
651 print $hookmanager->resPrint;
654 if (!empty($arrayfields[
'cp.date_create'][
'checked'])) {
655 print
'<td class="liste_titre center width200">';
656 print
'<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month_create" value="'.dol_escape_htmltag($search_month_create).
'">';
657 print $formother->selectyear($search_year_create,
'search_year_create', 1, $min_year, 0);
662 if (!empty($arrayfields[
'cp.tms'][
'checked'])) {
663 print
'<td class="liste_titre center width200">';
664 print
'<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month_update" value="'.dol_escape_htmltag($search_month_update).
'">';
665 print $formother->selectyear($search_year_update,
'search_year_update', 1, $min_year, 0);
670 if (!empty($arrayfields[
'cp.statut'][
'checked'])) {
671 print
'<td class="liste_titre right">';
672 $object->selectStatutCP($search_status,
'search_status',
'minwidth125');
677 print
'<td class="liste_titre maxwidthsearch">';
678 $searchpicto =
$form->showFilterButtons();
684 print
'<tr class="liste_titre">';
685 if (!empty($arrayfields[
'cp.ref'][
'checked'])) {
686 print_liste_field_titre($arrayfields[
'cp.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"cp.ref",
"", $param,
'', $sortfield, $sortorder);
688 if (!empty($arrayfields[
'cp.fk_user'][
'checked'])) {
689 print_liste_field_titre($arrayfields[
'cp.fk_user'][
'label'], $_SERVER[
"PHP_SELF"],
"cp.fk_user",
"", $param,
'', $sortfield, $sortorder);
691 if (!empty($arrayfields[
'cp.fk_validator'][
'checked'])) {
692 print_liste_field_titre($arrayfields[
'cp.fk_validator'][
'label'], $_SERVER[
"PHP_SELF"],
"cp.fk_validator",
"", $param,
'', $sortfield, $sortorder);
694 if (!empty($arrayfields[
'cp.fk_type'][
'checked'])) {
695 print_liste_field_titre($arrayfields[
'cp.fk_type'][
'label'], $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder);
697 if (!empty($arrayfields[
'duration'][
'checked'])) {
698 print_liste_field_titre($arrayfields[
'duration'][
'label'], $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'right maxwidth100');
700 if (!empty($arrayfields[
'cp.date_debut'][
'checked'])) {
701 print_liste_field_titre($arrayfields[
'cp.date_debut'][
'label'], $_SERVER[
"PHP_SELF"],
"cp.date_debut",
"", $param,
'', $sortfield, $sortorder,
'center ');
703 if (!empty($arrayfields[
'cp.date_fin'][
'checked'])) {
704 print_liste_field_titre($arrayfields[
'cp.date_fin'][
'label'], $_SERVER[
"PHP_SELF"],
"cp.date_fin",
"", $param,
'', $sortfield, $sortorder,
'center ');
706 if (!empty($arrayfields[
'cp.date_valid'][
'checked'])) {
707 print_liste_field_titre($arrayfields[
'cp.date_valid'][
'label'], $_SERVER[
"PHP_SELF"],
"cp.date_valid",
"", $param,
'', $sortfield, $sortorder,
'center ');
710 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
712 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
713 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
714 print $hookmanager->resPrint;
715 if (!empty($arrayfields[
'cp.date_create'][
'checked'])) {
716 print_liste_field_titre($arrayfields[
'cp.date_create'][
'label'], $_SERVER[
"PHP_SELF"],
"cp.date_create",
"", $param,
'', $sortfield, $sortorder,
'center ');
718 if (!empty($arrayfields[
'cp.tms'][
'checked'])) {
719 print_liste_field_titre($arrayfields[
'cp.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"cp.tms",
"", $param,
'', $sortfield, $sortorder,
'center ');
721 if (!empty($arrayfields[
'cp.statut'][
'checked'])) {
722 print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"],
"cp.statut",
"", $param,
'', $sortfield, $sortorder,
'right ');
724 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'maxwidthsearch center ');
727 $listhalfday = array(
'morning'=>$langs->trans(
"Morning"),
"afternoon"=>$langs->trans(
"Afternoon"));
731 if ($id && empty($user->rights->holiday->readall) && !in_array($id, $childids)) {
732 $langs->load(
"errors");
733 print
'<tr class="oddeven opacitymediuem"><td colspan="10">'.$langs->trans(
"NotEnoughPermissions").
'</td></tr>';
735 } elseif ($num > 0 && !empty($mysoc->country_id)) {
737 $userstatic =
new User($db);
738 $approbatorstatic =
new User($db);
740 $typeleaves = $object->getTypes(1, -1);
743 $totalarray = array();
744 $totalarray[
'nbfield'] = 0;
746 while ($i < min($num, $limit)) {
747 $obj = $db->fetch_object(
$resql);
750 $holidaystatic->id = $obj->rowid;
751 $holidaystatic->ref = ($obj->ref ? $obj->ref : $obj->rowid);
752 $holidaystatic->statut = $obj->status;
753 $holidaystatic->date_debut = $db->jdate($obj->date_debut);
756 $userstatic->id = $obj->fk_user;
757 $userstatic->lastname = $obj->user_lastname;
758 $userstatic->firstname = $obj->user_firstname;
759 $userstatic->admin = $obj->user_admin;
760 $userstatic->email = $obj->user_email;
761 $userstatic->login = $obj->user_login;
762 $userstatic->statut = $obj->user_status;
763 $userstatic->photo = $obj->user_photo;
766 $approbatorstatic->id = $obj->fk_validator;
767 $approbatorstatic->lastname = $obj->validator_lastname;
768 $approbatorstatic->firstname = $obj->validator_firstname;
769 $approbatorstatic->admin = $obj->validator_admin;
770 $approbatorstatic->email = $obj->validator_email;
771 $approbatorstatic->login = $obj->validator_login;
772 $approbatorstatic->statut = $obj->validator_status;
773 $approbatorstatic->photo = $obj->validator_photo;
775 $date = $obj->date_create;
776 $date_modif = $obj->date_update;
778 $starthalfday = ($obj->halfday == -1 || $obj->halfday == 2) ?
'afternoon' :
'morning';
779 $endhalfday = ($obj->halfday == 1 || $obj->halfday == 2) ?
'morning' :
'afternoon';
781 print
'<tr class="oddeven">';
783 if (!empty($arrayfields[
'cp.ref'][
'checked'])) {
784 print
'<td class="nowraponall">';
785 print $holidaystatic->getNomUrl(1, 1);
788 $totalarray[
'nbfield']++;
791 if (!empty($arrayfields[
'cp.fk_user'][
'checked'])) {
792 print
'<td class="tdoverflowmax125">'.$userstatic->getNomUrl(-1,
'leave').
'</td>';
794 $totalarray[
'nbfield']++;
797 if (!empty($arrayfields[
'cp.fk_validator'][
'checked'])) {
798 print
'<td class="tdoverflowmax125">'.$approbatorstatic->getNomUrl(-1).
'</td>';
800 $totalarray[
'nbfield']++;
803 if (!empty($arrayfields[
'cp.fk_type'][
'checked'])) {
804 $labeltypeleavetoshow = ($langs->trans($typeleaves[$obj->fk_type][
'code']) != $typeleaves[$obj->fk_type][
'code'] ? $langs->trans($typeleaves[$obj->fk_type][
'code']) : $typeleaves[$obj->fk_type][
'label']);
805 $labeltypeleavetoshow = empty($typeleaves[$obj->fk_type][
'label']) ? $langs->trans(
"TypeWasDisabledOrRemoved", $obj->fk_type) : $labeltypeleavetoshow;
807 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($labeltypeleavetoshow).
'">';
808 print $labeltypeleavetoshow;
811 $totalarray[
'nbfield']++;
814 if (!empty($arrayfields[
'duration'][
'checked'])) {
815 print
'<td class="right">';
816 $nbopenedday =
num_open_day($db->jdate($obj->date_debut, 1), $db->jdate($obj->date_fin, 1), 0, 1, $obj->halfday);
817 $totalduration += $nbopenedday;
822 $totalarray[
'nbfield']++;
825 if (!empty($arrayfields[
'cp.date_debut'][
'checked'])) {
826 print
'<td class="center">';
828 print
' <span class="opacitymedium nowraponall">('.$langs->trans($listhalfday[$starthalfday]).
')</span>';
831 $totalarray[
'nbfield']++;
834 if (!empty($arrayfields[
'cp.date_fin'][
'checked'])) {
835 print
'<td class="center">';
837 print
' <span class="opacitymedium nowraponall">('.$langs->trans($listhalfday[$endhalfday]).
')</span>';
840 $totalarray[
'nbfield']++;
843 if (!empty($arrayfields[
'cp.date_valid'][
'checked'])) {
844 print
'<td class="center">';
847 if (!$i) $totalarray[
'nbfield']++;
857 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
859 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
860 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
861 print $hookmanager->resPrint;
864 if (!empty($arrayfields[
'cp.date_create'][
'checked'])) {
865 print
'<td style="text-align: center;">'.dol_print_date($date,
'dayhour').
'</td>';
867 $totalarray[
'nbfield']++;
870 if (!empty($arrayfields[
'cp.tms'][
'checked'])) {
871 print
'<td style="text-align: center;">'.dol_print_date($date_modif,
'dayhour').
'</td>';
873 $totalarray[
'nbfield']++;
876 if (!empty($arrayfields[
'cp.statut'][
'checked'])) {
877 print
'<td class="right nowrap">'.$holidaystatic->getLibStatut(5).
'</td>';
879 $totalarray[
'nbfield']++;
884 print
'<td class="nowrap center">';
885 if ($massactionbutton || $massaction) {
887 if (in_array($obj->rowid, $arrayofselected)) {
890 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
894 $totalarray[
'nbfield']++;
903 if (!empty($arrayfields[
'duration'][
'checked'])) {
904 print
'<tr class="total">';
905 foreach ($arrayfields as $key => $val) {
906 if (!empty($val[
'checked'])) {
907 if ($key ==
'duration') {
908 print
'<td class="right">'.$totalduration.
' '.$langs->trans(
'DurationDays').
'</td>';
923 foreach ($arrayfields as $key => $val) {
924 if (!empty($val[
'checked'])) {
928 print
'<tr><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</td></tr>';
956 global $conf, $langs;
958 $alltypeleaves = $holiday->getTypes(1, -1);
962 $typeleaves = $holiday->getTypes(1, 1);
963 foreach ($typeleaves as $key => $val) {
964 $nb_type = $holiday->getCPforUser($user_id, $val[
'rowid']);
965 $nb_holiday += $nb_type;
966 $out .=
' - '.$val[
'label'].
': <strong>'.($nb_type ?
price2num($nb_type) : 0).
'</strong><br>';
968 print $langs->trans(
'SoldeCPUser', round($nb_holiday, 5)).
'<br>';