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')) { $page = 0; }
65 $offset = $limit * $page;
66 $pageprev = $page - 1;
67 $pagenext = $page + 1;
68 if (!$sortfield) $sortfield =
"cpl.rowid";
69 if (!$sortorder) $sortorder =
"DESC";
75 $langs->loadLangs(array(
'users',
'other',
'holiday'));
81 $hookmanager->initHooks(array(
'leavemovementlist'));
83 $arrayfields = array();
84 $arrayofmassactions = array();
86 if (empty($conf->holiday->enabled))
88 llxHeader(
'', $langs->trans(
'CPTitreMenu'));
89 print '<div class="tabBar">';
90 print
'<span style="color: #FF0000;">'.$langs->trans(
'NotActiveModCP').
'</span>';
101 if (
GETPOST(
'cancel',
'alpha')) { $action =
'list'; $massaction =
''; }
102 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') { $massaction =
''; }
104 $parameters = array();
105 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
106 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
108 if (empty($reshook)) {
110 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
113 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
117 $search_employee =
'';
118 $search_validator =
'';
119 $search_description =
'';
121 $search_prev_solde =
'';
122 $search_new_solde =
'';
124 $search_array_options = array();
127 if (
GETPOST(
'button_removefilter_x',
'alpha')
128 ||
GETPOST(
'button_removefilter.x',
'alpha')
129 ||
GETPOST(
'button_removefilter',
'alpha')
130 ||
GETPOST(
'button_search_x',
'alpha')
131 ||
GETPOST(
'button_search.x',
'alpha')
132 ||
GETPOST(
'button_search',
'alpha'))
149 $arrayfields = array(
150 'cpl.rowid'=>array(
'label'=>$langs->trans(
"ID"),
'checked'=>1),
151 'cpl.date_action'=>array(
'label'=>$langs->trans(
"Date"),
'checked'=>1),
152 'cpl.fk_user_action'=>array(
'label'=>$langs->trans(
"ActionByCP"),
'checked'=>1),
153 'cpl.fk_user_update'=>array(
'label'=>$langs->trans(
"UserUpdateCP"),
'checked'=>1),
154 'cpl.type_action'=>array(
'label'=>$langs->trans(
"Description"),
'checked'=>1),
155 'cpl.fk_type'=>array(
'label'=>$langs->trans(
"Type"),
'checked'=>1),
156 'cpl.prev_solde'=>array(
'label'=>$langs->trans(
"PrevSoldeCP"),
'checked'=>1),
157 'variation'=>array(
'label'=>$langs->trans(
"Variation"),
'checked'=>1),
158 'cpl.new_solde'=>array(
'label'=>$langs->trans(
"NewSoldeCP"),
'checked'=>1),
166 $form =
new Form($db);
168 $holidaylogstatic =
new stdClass();
169 $alltypeleaves = $object->getTypes(1, -1);
171 llxHeader(
'', $langs->trans(
'CPTitreMenu'));
175 if (!empty($search_year) && $search_year > 0) {
176 if (!empty($search_month) && $search_month > 0) {
184 $sqlwhere .=
"AND date_action BETWEEN '".$db->idate($from_date).
"' AND '".$db->idate($to_date).
"'";
187 if (!empty($search_id) && $search_id > 0) $sqlwhere .=
natural_search(
'rowid', $search_id, 1);
188 if (!empty($search_validator) && $search_validator > 0) $sqlwhere .=
natural_search(
'fk_user_action', $search_validator, 1);
189 if (!empty($search_employee) && $search_employee > 0) $sqlwhere .=
natural_search(
'fk_user_update', $search_employee, 1);
190 if (!empty($search_description)) $sqlwhere .=
natural_search(
'type_action', $search_description);
191 if (!empty($search_type) && $search_type > 0) $sqlwhere .=
natural_search(
'fk_type', $search_type, 1);
192 if (!empty($search_prev_solde)) $sqlwhere .=
natural_search(
'prev_solde', $search_prev_solde, 1);
193 if (!empty($search_new_solde)) $sqlwhere .=
natural_search(
'new_solde', $search_new_solde, 1);
195 $sqlorder = $db->order($sortfield, $sortorder);
198 $log_holiday = $object->fetchLog($sqlorder, $sqlwhere);
201 $nbtotalofrecords =
'';
202 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
205 $nbtotalofrecords = is_array($object->logs) ? count($object->logs) : 0;
207 if (($page * $limit) > $nbtotalofrecords) {
214 $num = is_array($object->logs) ? count($object->logs) : 0;
217 if (!empty($contextpage) && $contextpage !=
$_SERVER[
"PHP_SELF"]) $param .=
'&contextpage='.urlencode($contextpage);
218 if ($limit > 0 && $limit != $conf->liste_limit) $param .=
'&limit='.urlencode($limit);
219 if (!empty($search_id)) $param .=
'&search_statut='.urlencode($search_statut);
220 if (!empty($search_month) && $search_month > 0) $param .=
'&search_month='.urlencode($search_month);
221 if (!empty($search_year) && $search_year > 0) $param .=
'&search_year='.urlencode($search_year);
222 if (!empty($search_validator) && $search_validator > 0) $param .=
'&search_validator='.urlencode($search_validator);
223 if (!empty($search_employee) && $search_employee > 0) $param .=
'&search_employee='.urlencode($search_employee);
224 if (!empty($search_description)) $param .=
'&search_description='.urlencode($search_description);
225 if (!empty($search_type) && $search_type > 0) $param .=
'&search_type='.urlencode($search_type);
226 if (!empty($search_prev_solde)) $param .=
'&search_prev_solde='.urlencode($search_prev_solde);
227 if (!empty($search_new_solde)) $param .=
'&search_new_solde='.urlencode($search_new_solde);
229 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
230 if ($optioncss !=
'') print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
231 print
'<input type="hidden" name="token" value="'.newToken().
'">';
232 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
233 print
'<input type="hidden" name="action" value="list">';
234 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
235 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
236 print
'<input type="hidden" name="page" value="'.$page.
'">';
237 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
239 $newcardbutton =
dolGetButtonTitle($langs->trans(
'MenuAddCP'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/holiday/card.php?action=request',
'', $user->rights->holiday->write);
240 print_barre_liste($langs->trans(
'LogCP'), $page,
$_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $nbtotalofrecords,
'title_hrm', 0, $newcardbutton,
'', $limit, 0, 0, 1);
242 print
'<div class="info">'.$langs->trans(
'LastUpdateCP').
': ';
244 $lastUpdate = $object->getConfCP(
'lastUpdate');
246 $monthLastUpdate = $lastUpdate[4].$lastUpdate[5];
247 $yearLastUpdate = $lastUpdate[0].$lastUpdate[1].$lastUpdate[2].$lastUpdate[3];
248 print
'<strong>'.dol_print_date($db->jdate($object->getConfCP(
'lastUpdate')),
'dayhour',
'tzuser').
'</strong>';
250 print $langs->trans(
"MonthOfLastMonthlyUpdate").
': <strong>'.$yearLastUpdate.
'-'.$monthLastUpdate.
'</strong>';
252 print $langs->trans(
'None');
259 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
260 $selectedfields =
'';
261 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
262 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
264 print
'<div class="div-table-responsive">';
265 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'" id="tablelines3">';
267 print
'<tr class="liste_titre_filter">';
270 if (!empty($arrayfields[
'cpl.rowid'][
'checked'])) {
271 print
'<td class="liste_titre"><input type="text" class="maxwidth50" name="search_id" value="'.$search_id.
'"></td>';
275 if (!empty($arrayfields[
'cpl.date_action'][
'checked'])) {
276 print
'<td class="liste_titre center">';
277 print
'<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month" value="'.dol_escape_htmltag($search_month).
'">';
278 print $formother->selectyear($search_year,
'search_year', 1, 10, 5, 0, 0,
'',
'valignmiddle width75',
true);
283 if (!empty($arrayfields[
'cpl.fk_user_action'][
'checked'])) {
285 $excludefilter = $user->admin ?
'' :
'u.rowid <> '.$user->id;
286 $valideurobjects = $validator->listUsersForGroup($excludefilter);
287 $valideurarray = array();
289 foreach ($valideurobjects as $val) {
290 $valideurarray[$val->id] = $val->id;
293 print
'<td class="liste_titre">';
294 print $form->select_dolusers($search_validator,
"search_validator", 1,
"", 0, $valideurarray,
'', 0, 0, 0, $morefilter, 0,
'',
'maxwidth200');
299 if (!empty($arrayfields[
'cpl.fk_user_update'][
'checked'])) {
300 print
'<td class="liste_titre">';
301 print $form->select_dolusers($search_employee,
"search_employee", 1,
"", $disabled, $include,
'', 0, 0, 0, $morefilter, 0,
'',
'maxwidth200');
306 if (!empty($arrayfields[
'cpl.type_action'][
'checked'])) {
307 print
'<td class="liste_titre">';
308 print
'<input type="text" class="maxwidth50" name="search_description" value="'.$search_description.
'">';
313 if (!empty($arrayfields[
'cpl.fk_type'][
'checked'])) {
314 foreach ($alltypeleaves as $key => $val) {
315 $labeltoshow = ($langs->trans($val[
'code']) != $val[
'code'] ? $langs->trans($val[
'code']) : $val[
'label']);
316 $arraytypeleaves[$val[
'rowid']] = $labeltoshow;
319 print
'<td class="liste_titre">';
320 print $form->selectarray(
'search_type', $arraytypeleaves, $search_type, 1, 0, 0,
'', 0, 0, 0,
'',
'', 1);
325 if (!empty($arrayfields[
'cpl.prev_solde'][
'checked'])) {
326 print
'<td class="liste_titre">';
327 print
'<input type="text" class="maxwidth50" name="search_prev_solde" value="'.$search_prev_solde.
'">';
332 if (!empty($arrayfields[
'variation'][
'checked'])) {
333 print
'<td class="liste_titre"></td>';
337 if (!empty($arrayfields[
'cpl.new_solde'][
'checked'])) {
338 print
'<td class="liste_titre">';
339 print
'<input type="text" class="maxwidth50" name="search_new_solde" value="'.$search_new_solde.
'">';
344 print
'<td class="liste_titre maxwidthsearch">';
345 $searchpicto = $form->showFilterButtons();
350 print
'<tr class="liste_titre">';
351 if (!empty($arrayfields[
'cpl.rowid'][
'checked']))
print_liste_field_titre($arrayfields[
'cpl.rowid'][
'label'], $_SERVER[
"PHP_SELF"],
'rowid',
'',
'',
'', $sortfield, $sortorder);
352 if (!empty($arrayfields[
'cpl.date_action'][
'checked']))
print_liste_field_titre($arrayfields[
'cpl.date_action'][
'label'], $_SERVER[
"PHP_SELF"],
'date_action',
'',
'',
'', $sortfield, $sortorder,
'center ');
353 if (!empty($arrayfields[
'cpl.fk_user_action'][
'checked']))
print_liste_field_titre($arrayfields[
'cpl.fk_user_action'][
'label'], $_SERVER[
"PHP_SELF"],
'fk_user_action',
'',
'',
'', $sortfield, $sortorder);
354 if (!empty($arrayfields[
'cpl.fk_user_update'][
'checked']))
print_liste_field_titre($arrayfields[
'cpl.fk_user_update'][
'label'], $_SERVER[
"PHP_SELF"],
'fk_user_update',
'',
'',
'', $sortfield, $sortorder);
355 if (!empty($arrayfields[
'cpl.type_action'][
'checked']))
print_liste_field_titre($arrayfields[
'cpl.type_action'][
'label'], $_SERVER[
"PHP_SELF"],
'type_action',
'',
'',
'', $sortfield, $sortorder);
356 if (!empty($arrayfields[
'cpl.fk_type'][
'checked']))
print_liste_field_titre($arrayfields[
'cpl.fk_type'][
'label'], $_SERVER[
"PHP_SELF"],
'fk_type',
'',
'',
'', $sortfield, $sortorder);
357 if (!empty($arrayfields[
'cpl.prev_solde'][
'checked']))
print_liste_field_titre($arrayfields[
'cpl.prev_solde'][
'label'], $_SERVER[
"PHP_SELF"],
'prev_solde',
'',
'',
'', $sortfield, $sortorder,
'right ');
358 if (!empty($arrayfields[
'variation'][
'checked']))
print_liste_field_titre($arrayfields[
'variation'][
'label'], $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'right ');
359 if (!empty($arrayfields[
'cpl.new_solde'][
'checked']))
print_liste_field_titre($arrayfields[
'cpl.new_solde'][
'label'], $_SERVER[
"PHP_SELF"],
'new_solde',
'',
'',
'', $sortfield, $sortorder,
'right ');
360 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
366 while ($i < min($num, $limit))
369 $obj = next($object->logs);
371 $holidaylogstatic->id = $obj[
'rowid'];
372 $holidaylogstatic->date = $obj[
'date_action'];
373 $holidaylogstatic->validator = $obj[
'fk_user_action'];
374 $holidaylogstatic->employee = $obj[
'fk_user_update'];
375 $holidaylogstatic->description = $obj[
'type_action'];
376 $holidaylogstatic->type = $obj[
'fk_type'];
377 $holidaylogstatic->balance_previous = $obj[
'prev_solde'];
378 $holidaylogstatic->balance_new = $obj[
'new_solde'];
380 print
'<tr class="oddeven">';
383 if (!empty($arrayfields[
'cpl.rowid'][
'checked'])) {
384 print
'<td>'.$holidaylogstatic->id.
'</td>';
388 if (!empty($arrayfields[
'cpl.date_action'][
'checked'])) {
389 print
'<td style="text-align: center">'.$holidaylogstatic->date.
'</td>';
393 if (!empty($arrayfields[
'cpl.fk_user_action'][
'checked'])) {
394 $user_action =
new User($db);
395 $user_action->fetch($holidaylogstatic->validator);
396 print
'<td>'.$user_action->getNomUrl(-1).
'</td>';
400 if (!empty($arrayfields[
'cpl.fk_user_update'][
'checked'])) {
401 $user_update =
new User($db);
402 $user_update->fetch($holidaylogstatic->employee);
403 print
'<td>'.$user_update->getNomUrl(-1).
'</td>';
407 if (!empty($arrayfields[
'cpl.type_action'][
'checked'])) {
408 print
'<td>'.$holidaylogstatic->description.
'</td>';
412 if (!empty($arrayfields[
'cpl.fk_type'][
'checked'])) {
413 if ($alltypeleaves[$holidaylogstatic->type][
'code'] && $langs->trans($alltypeleaves[$holidaylogstatic->type][
'code']) != $alltypeleaves[$holidaylogstatic->type][
'code']) {
414 $label = $langs->trans($alltypeleaves[$holidaylogstatic->type][
'code']);
416 $label = $alltypeleaves[$holidaylogstatic->type][
'label'];
420 print $label ? $label : $holidaylogstatic->type;
425 if (!empty($arrayfields[
'cpl.prev_solde'][
'checked'])) {
426 print
'<td style="text-align: right;">'.price2num($holidaylogstatic->balance_previous, 5).
' '.$langs->trans(
'days').
'</td>';
430 if (!empty($arrayfields[
'variation'][
'checked'])) {
431 $delta =
price2num($holidaylogstatic->balance_new - $holidaylogstatic->balance_previous, 5);
432 $detasign = ($delta > 0 ?
'+' :
'');
433 print
'<td style="text-align: right;">'.$detasign.$delta.
'</td>';
437 if (!empty($arrayfields[
'cpl.new_solde'][
'checked'])) {
438 print
'<td style="text-align: right;">'.price2num($holidaylogstatic->balance_new, 5).
' '.$langs->trans(
'days').
'</td>';
449 if ($log_holiday ==
'2') {
450 print
'<tr class="opacitymedium">';
451 print
'<td colspan="10" class="opacitymedium">'.$langs->trans(
'NoRecordFound').
'</td>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class of the module paid holiday.
dolGetButtonTitle($label, $helpText= '', $iconClass= 'fa fa-file', $url= '', $id= '', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
Class to manage Dolibarr users.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
Class to manage user groups.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options= '', $sortfield= '', $sortorder= '', $morehtmlcenter= '', $num=-1, $totalnboflines= '', $picto= 'generic', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow= '')
Print a title with navigation controls for pagination.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
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...
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
print
Draft customers invoices.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip= '', $forcenowrapcolumntitle=0)
Get title line of an array.