27 require
'../main.inc.php';
30 if (empty($user->rights->holiday->define_holiday) || $user->socid > 0) {
34 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/holiday/class/holiday.class.php';
39 $action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
40 $massaction =
GETPOST(
'massaction',
'alpha');
41 $show_files =
GETPOST(
'show_files',
'int');
42 $confirm =
GETPOST(
'confirm',
'alpha');
43 $cancel =
GETPOST(
'cancel',
'alpha');
44 $toselect =
GETPOST(
'toselect',
'array');
45 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'myobjectlist';
46 $backtopage =
GETPOST(
'backtopage',
'alpha');
47 $optioncss =
GETPOST(
'optioncss',
'aZ');
49 $search_id =
GETPOST(
'search_id',
'alphanohtml');
50 $search_month =
GETPOST(
'search_month',
'int');
51 $search_year =
GETPOST(
'search_year',
'int');
52 $search_employee =
GETPOST(
'search_employee',
'int');
53 $search_validator =
GETPOST(
'search_validator',
'int');
54 $search_description =
GETPOST(
'search_description',
'alphanohtml');
55 $search_type =
GETPOST(
'search_type',
'int');
56 $search_prev_solde =
GETPOST(
'search_prev_solde',
'alphanohtml');
57 $search_new_solde =
GETPOST(
'search_new_solde',
'alphanohtml');
60 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
61 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
62 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
64 if (empty($page) || $page == -1 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha') || (empty($toselect) && $massaction ===
'0')) {
67 $offset = $limit * $page;
68 $pageprev = $page - 1;
69 $pagenext = $page + 1;
71 $sortfield =
"cpl.rowid";
78 if (!$user->rights->holiday->readall) {
83 $langs->loadLangs(array(
'users',
'other',
'holiday'));
89 $hookmanager->initHooks(array(
'leavemovementlist'));
91 $arrayfields = array();
92 $arrayofmassactions = array();
94 if (empty($conf->holiday->enabled)) {
95 llxHeader(
'', $langs->trans(
'CPTitreMenu'));
96 print
'<div class="tabBar">';
97 print
'<span style="color: #FF0000;">'.$langs->trans(
'NotActiveModCP').
'</span>';
108 if (
GETPOST(
'cancel',
'alpha')) {
109 $action =
'list'; $massaction =
'';
111 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
115 $parameters = array();
116 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
121 if (empty($reshook)) {
123 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
126 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
130 $search_employee =
'';
131 $search_validator =
'';
132 $search_description =
'';
134 $search_prev_solde =
'';
135 $search_new_solde =
'';
137 $search_array_options = array();
140 if (
GETPOST(
'button_removefilter_x',
'alpha')
141 ||
GETPOST(
'button_removefilter.x',
'alpha')
142 ||
GETPOST(
'button_removefilter',
'alpha')
143 ||
GETPOST(
'button_search_x',
'alpha')
144 ||
GETPOST(
'button_search.x',
'alpha')
145 ||
GETPOST(
'button_search',
'alpha')) {
161 $arrayfields = array(
162 'cpl.rowid'=>array(
'label'=>
"ID",
'checked'=>1),
163 'cpl.date_action'=>array(
'label'=>
"Date",
'checked'=>1),
164 'cpl.fk_user_action'=>array(
'label'=>
"ActionByCP",
'checked'=>1),
165 'cpl.fk_user_update'=>array(
'label'=>
"UserUpdateCP",
'checked'=>1),
166 'cpl.type_action'=>array(
'label'=>
"Description",
'checked'=>1),
167 'cpl.fk_type'=>array(
'label'=>
"Type",
'checked'=>1),
168 'cpl.prev_solde'=>array(
'label'=>
"PrevSoldeCP",
'checked'=>1),
169 'variation'=>array(
'label'=>
"Variation",
'checked'=>1),
170 'cpl.new_solde'=>array(
'label'=>
"NewSoldeCP",
'checked'=>1),
180 $holidaylogstatic =
new stdClass();
181 $alltypeleaves = $object->getTypes(1, -1);
183 $title = $langs->trans(
'CPTitreMenu');
188 if (!empty($search_year) && $search_year > 0) {
189 if (!empty($search_month) && $search_month > 0) {
197 $sqlwhere .=
"AND date_action BETWEEN '".$db->idate($from_date).
"' AND '".$db->idate($to_date).
"'";
200 if (!empty($search_id) && $search_id > 0) {
203 if (!empty($search_validator) && $search_validator > 0) {
204 $sqlwhere .=
natural_search(
'fk_user_action', $search_validator, 1);
206 if (!empty($search_employee) && $search_employee > 0) {
207 $sqlwhere .=
natural_search(
'fk_user_update', $search_employee, 1);
209 if (!empty($search_description)) {
212 if (!empty($search_type) && $search_type > 0) {
215 if (!empty($search_prev_solde)) {
218 if (!empty($search_new_solde)) {
222 $sqlorder = $db->order($sortfield, $sortorder);
225 $log_holiday = $object->fetchLog($sqlorder, $sqlwhere);
228 $nbtotalofrecords =
'';
229 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
232 $nbtotalofrecords = is_array($object->logs) ? count($object->logs) : 0;
234 if (($page * $limit) > $nbtotalofrecords) {
241 $num = is_array($object->logs) ? count($object->logs) : 0;
244 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
245 $param .=
'&contextpage='.urlencode($contextpage);
247 if ($limit > 0 && $limit != $conf->liste_limit) {
248 $param .=
'&limit='.urlencode($limit);
250 if (!empty($search_id)) {
251 $param .=
'&search_statut='.urlencode($search_statut);
253 if (!empty($search_month) && $search_month > 0) {
254 $param .=
'&search_month='.urlencode($search_month);
256 if (!empty($search_year) && $search_year > 0) {
257 $param .=
'&search_year='.urlencode($search_year);
259 if (!empty($search_validator) && $search_validator > 0) {
260 $param .=
'&search_validator='.urlencode($search_validator);
262 if (!empty($search_employee) && $search_employee > 0) {
263 $param .=
'&search_employee='.urlencode($search_employee);
265 if (!empty($search_description)) {
266 $param .=
'&search_description='.urlencode($search_description);
268 if (!empty($search_type) && $search_type > 0) {
269 $param .=
'&search_type='.urlencode($search_type);
271 if (!empty($search_prev_solde)) {
272 $param .=
'&search_prev_solde='.urlencode($search_prev_solde);
274 if (!empty($search_new_solde)) {
275 $param .=
'&search_new_solde='.urlencode($search_new_solde);
278 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
279 if ($optioncss !=
'') {
280 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
282 print
'<input type="hidden" name="token" value="'.newToken().
'">';
283 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
284 print
'<input type="hidden" name="action" value="list">';
285 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
286 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
287 print
'<input type="hidden" name="page" value="'.$page.
'">';
288 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
290 $newcardbutton =
dolGetButtonTitle($langs->trans(
'MenuAddCP'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/holiday/card.php?action=request',
'', $user->rights->holiday->write);
291 print_barre_liste($langs->trans(
'LogCP'), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $nbtotalofrecords,
'title_hrm', 0, $newcardbutton,
'', $limit, 0, 0, 1);
293 print
'<div class="info">'.$langs->trans(
'LastUpdateCP').
': ';
295 $lastUpdate = $object->getConfCP(
'lastUpdate');
297 $monthLastUpdate = $lastUpdate[4].$lastUpdate[5];
298 $yearLastUpdate = $lastUpdate[0].$lastUpdate[1].$lastUpdate[2].$lastUpdate[3];
299 print
'<strong>'.dol_print_date($db->jdate($object->getConfCP(
'lastUpdate')),
'dayhour',
'tzuser').
'</strong>';
301 print $langs->trans(
"MonthOfLastMonthlyUpdate").
': <strong>'.$yearLastUpdate.
'-'.$monthLastUpdate.
'</strong>';
303 print $langs->trans(
'None');
313 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
314 $selectedfields =
'';
315 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
316 $selectedfields .= (count($arrayofmassactions) ?
$form->showCheckAddButtons(
'checkforselect', 1) :
'');
318 print
'<div class="div-table-responsive">';
319 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'" id="tablelines3">';
321 print
'<tr class="liste_titre_filter">';
324 if (!empty($arrayfields[
'cpl.rowid'][
'checked'])) {
325 print
'<td class="liste_titre"><input type="text" class="maxwidth50" name="search_id" value="'.$search_id.
'"></td>';
329 if (!empty($arrayfields[
'cpl.date_action'][
'checked'])) {
330 print
'<td class="liste_titre center">';
331 print
'<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month" value="'.dol_escape_htmltag($search_month).
'">';
332 print $formother->selectyear($search_year,
'search_year', 1, 10, 5, 0, 0,
'',
'valignmiddle width75',
true);
337 if (!empty($arrayfields[
'cpl.fk_user_action'][
'checked'])) {
339 $excludefilter = $user->admin ?
'' :
'u.rowid <> '.$user->id;
340 $valideurobjects = $validator->listUsersForGroup($excludefilter);
341 $valideurarray = array();
343 foreach ($valideurobjects as $val) {
344 $valideurarray[$val->id] = $val->id;
347 print
'<td class="liste_titre">';
348 print
$form->select_dolusers($search_validator,
"search_validator", 1,
"", 0, $valideurarray,
'', 0, 0, 0, $morefilter, 0,
'',
'maxwidth200');
353 if (!empty($arrayfields[
'cpl.fk_user_update'][
'checked'])) {
354 print
'<td class="liste_titre">';
355 print
$form->select_dolusers($search_employee,
"search_employee", 1,
"", $disabled, $include,
'', 0, 0, 0, $morefilter, 0,
'',
'maxwidth200');
360 if (!empty($arrayfields[
'cpl.type_action'][
'checked'])) {
361 print
'<td class="liste_titre">';
362 print
'<input type="text" class="maxwidth50" name="search_description" value="'.$search_description.
'">';
367 if (!empty($arrayfields[
'cpl.fk_type'][
'checked'])) {
368 foreach ($alltypeleaves as $key => $val) {
369 $labeltoshow = ($langs->trans($val[
'code']) != $val[
'code'] ? $langs->trans($val[
'code']) : $val[
'label']);
370 $arraytypeleaves[$val[
'rowid']] = $labeltoshow;
373 print
'<td class="liste_titre">';
374 print
$form->selectarray(
'search_type', $arraytypeleaves, $search_type, 1, 0, 0,
'', 0, 0, 0,
'',
'', 1);
379 if (!empty($arrayfields[
'cpl.prev_solde'][
'checked'])) {
380 print
'<td class="liste_titre right">';
381 print
'<input type="text" class="maxwidth50" name="search_prev_solde" value="'.$search_prev_solde.
'">';
386 if (!empty($arrayfields[
'variation'][
'checked'])) {
387 print
'<td class="liste_titre"></td>';
391 if (!empty($arrayfields[
'cpl.new_solde'][
'checked'])) {
392 print
'<td class="liste_titre right">';
393 print
'<input type="text" class="maxwidth50" name="search_new_solde" value="'.$search_new_solde.
'">';
398 print
'<td class="liste_titre maxwidthsearch">';
399 $searchpicto =
$form->showFilterButtons();
404 print
'<tr class="liste_titre">';
405 if (!empty($arrayfields[
'cpl.rowid'][
'checked'])) {
406 print_liste_field_titre($arrayfields[
'cpl.rowid'][
'label'], $_SERVER[
"PHP_SELF"],
'cpl.rowid',
'',
'',
'', $sortfield, $sortorder);
408 if (!empty($arrayfields[
'cpl.date_action'][
'checked'])) {
409 print_liste_field_titre($arrayfields[
'cpl.date_action'][
'label'], $_SERVER[
"PHP_SELF"],
'date_action',
'',
'',
'', $sortfield, $sortorder,
'center ');
411 if (!empty($arrayfields[
'cpl.fk_user_action'][
'checked'])) {
412 print_liste_field_titre($arrayfields[
'cpl.fk_user_action'][
'label'], $_SERVER[
"PHP_SELF"],
'fk_user_action',
'',
'',
'', $sortfield, $sortorder);
414 if (!empty($arrayfields[
'cpl.fk_user_update'][
'checked'])) {
415 print_liste_field_titre($arrayfields[
'cpl.fk_user_update'][
'label'], $_SERVER[
"PHP_SELF"],
'fk_user_update',
'',
'',
'', $sortfield, $sortorder);
417 if (!empty($arrayfields[
'cpl.type_action'][
'checked'])) {
418 print_liste_field_titre($arrayfields[
'cpl.type_action'][
'label'], $_SERVER[
"PHP_SELF"],
'type_action',
'',
'',
'', $sortfield, $sortorder);
420 if (!empty($arrayfields[
'cpl.fk_type'][
'checked'])) {
421 print_liste_field_titre($arrayfields[
'cpl.fk_type'][
'label'], $_SERVER[
"PHP_SELF"],
'fk_type',
'',
'',
'', $sortfield, $sortorder);
423 if (!empty($arrayfields[
'cpl.prev_solde'][
'checked'])) {
424 print_liste_field_titre($arrayfields[
'cpl.prev_solde'][
'label'], $_SERVER[
"PHP_SELF"],
'prev_solde',
'',
'',
'', $sortfield, $sortorder,
'right ');
426 if (!empty($arrayfields[
'variation'][
'checked'])) {
427 print_liste_field_titre($arrayfields[
'variation'][
'label'], $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'right ');
429 if (!empty($arrayfields[
'cpl.new_solde'][
'checked'])) {
430 print_liste_field_titre($arrayfields[
'cpl.new_solde'][
'label'], $_SERVER[
"PHP_SELF"],
'new_solde',
'',
'',
'', $sortfield, $sortorder,
'right ');
432 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
437 while ($j < ($page * $limit)) {
438 $obj = next($object->logs);
443 while ($i < min($num, $limit)) {
445 $obj = current($object->logs);
450 $holidaylogstatic->id = $obj[
'rowid'];
451 $holidaylogstatic->date = $obj[
'date_action'];
452 $holidaylogstatic->validator = $obj[
'fk_user_action'];
453 $holidaylogstatic->employee = $obj[
'fk_user_update'];
454 $holidaylogstatic->description = $obj[
'type_action'];
455 $holidaylogstatic->type = $obj[
'fk_type'];
456 $holidaylogstatic->balance_previous = $obj[
'prev_solde'];
457 $holidaylogstatic->balance_new = $obj[
'new_solde'];
459 print
'<tr class="oddeven">';
462 if (!empty($arrayfields[
'cpl.rowid'][
'checked'])) {
463 print
'<td>'.$holidaylogstatic->id.
'</td>';
467 if (!empty($arrayfields[
'cpl.date_action'][
'checked'])) {
468 print
'<td style="text-align: center">'.$holidaylogstatic->date.
'</td>';
472 if (!empty($arrayfields[
'cpl.fk_user_action'][
'checked'])) {
473 $user_action =
new User($db);
474 $user_action->fetch($holidaylogstatic->validator);
475 print
'<td>'.$user_action->getNomUrl(-1).
'</td>';
479 if (!empty($arrayfields[
'cpl.fk_user_update'][
'checked'])) {
480 $user_update =
new User($db);
481 $user_update->fetch($holidaylogstatic->employee);
482 print
'<td>'.$user_update->getNomUrl(-1).
'</td>';
486 if (!empty($arrayfields[
'cpl.type_action'][
'checked'])) {
487 print
'<td class="tdoverflowmax400" title="'.dol_escape_htmltag($holidaylogstatic->description).
'">'.
dol_escape_htmltag($holidaylogstatic->description).
'</td>';
491 if (!empty($arrayfields[
'cpl.fk_type'][
'checked'])) {
493 if (!empty($alltypeleaves[$holidaylogstatic->type])) {
494 if ($alltypeleaves[$holidaylogstatic->type][
'code'] && $langs->trans($alltypeleaves[$holidaylogstatic->type][
'code']) != $alltypeleaves[$holidaylogstatic->type][
'code']) {
495 $label = $langs->trans($alltypeleaves[$holidaylogstatic->type][
'code']);
497 $label = $alltypeleaves[$holidaylogstatic->type][
'label'];
502 print $label ? $label : $holidaylogstatic->type;
507 if (!empty($arrayfields[
'cpl.prev_solde'][
'checked'])) {
508 print
'<td style="text-align: right;">'.price2num($holidaylogstatic->balance_previous, 5).
' '.$langs->trans(
'days').
'</td>';
512 if (!empty($arrayfields[
'variation'][
'checked'])) {
513 $delta =
price2num($holidaylogstatic->balance_new - $holidaylogstatic->balance_previous, 5);
514 print
'<td style="text-align: right;">';
516 print
'<span class="stockmovemententry fontsizeunset">+'.$delta.
'</span>';
518 print
'<span class="stockmovementexit fontsizeunset">'.$delta.
'</span>';
524 if (!empty($arrayfields[
'cpl.new_solde'][
'checked'])) {
525 print
'<td style="text-align: right;">'.price2num($holidaylogstatic->balance_new, 5).
' '.$langs->trans(
'days').
'</td>';
537 if ($log_holiday ==
'2') {
538 print
'<tr class="opacitymedium">';
539 print
'<td colspan="10" class="opacitymedium">'.$langs->trans(
'NoRecordFound').
'</td>';