30 require
'../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/holiday/class/holiday.class.php';
35 $langs->loadlangs(array(
'users',
'other',
'holiday',
'hrm'));
37 $action =
GETPOST(
'action',
'aZ09');
38 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'defineholidaylist';
39 $massaction =
GETPOST(
'massaction',
'alpha');
40 $optioncss =
GETPOST(
'optioncss',
'alpha');
42 $search_name =
GETPOST(
'search_name',
'alpha');
43 $search_supervisor =
GETPOST(
'search_supervisor',
'int');
46 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
47 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
48 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
49 $toselect =
GETPOST(
'toselect',
'array');
50 $confirm =
GETPOST(
'confirm',
'alpha');
53 if (empty($page) || $page == -1) {
56 $offset = $limit * $page;
57 $pageprev = $page - 1;
58 $pagenext = $page + 1;
60 $sortfield =
"t.rowid";
68 $hookmanager->initHooks(array(
'defineholidaylist'));
74 if (empty($conf->holiday->enabled)) {
79 if ($user->socid > 0) {
84 if (empty($user->rights->holiday->read)) {
93 if (
GETPOST(
'cancel',
'alpha')) {
94 $action =
'list'; $massaction =
'';
96 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
100 $parameters = array();
101 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
106 if (empty($reshook)) {
108 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
111 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
113 $search_supervisor =
'';
115 $search_array_options = array();
119 $objectclass =
'Holiday';
120 $objectlabel =
'Holiday';
121 $permissiontoread = $user->hasRight(
'holiday',
'read');
122 $permissiontodelete = $user->hasRight(
'holiday',
'delete');
123 $permissiontoapprove = $user->hasRight(
'holiday',
'approve');
124 $uploaddir = $conf->holiday->dir_output;
125 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
132 $typeleaves = $holiday->getTypes(1, 1);
134 $userID = array_keys(
GETPOST(
'update_cp'));
135 $userID = $userID[0];
139 foreach ($typeleaves as $key => $val) {
140 $userValue =
GETPOST(
'nb_holiday_'.$val[
'rowid']);
141 $userValue = $userValue[$userID];
143 if (!empty($userValue) || (
string) $userValue ==
'0') {
150 $note_holiday =
GETPOST(
'note_holiday');
151 $comment = ((isset($note_holiday[$userID]) && !empty($note_holiday[$userID])) ?
' ('.$note_holiday[$userID].
')' :
'');
154 if ($userValue !=
'') {
156 $result = $holiday->addLogCP($user->id, $userID, $langs->transnoentitiesnoconv(
'ManualUpdate').$comment, $userValue, $val[
'rowid']);
160 } elseif ($result == 0) {
161 setEventMessages($langs->trans(
"HolidayQtyNotModified", $user->login),
null,
'warnings');
168 $result = $holiday->updateSoldeCP($userID, $userValue, $val[
'rowid']);
205 $userstatic =
new User($db);
208 $title = $langs->trans(
'CPTitreMenu');
212 $typeleaves = $holiday->getTypes(1, 1);
213 $result = $holiday->updateBalance();
219 $arrayofmassactions = array(
224 if ($user->hasRight(
"holiday",
"approve")) {
225 $arrayofmassactions[
'preincreaseholiday'] =
img_picto(
'',
'add',
'class="pictofixedwidth"').$langs->trans(
"IncreaseHolidays");
227 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
230 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
231 if ($optioncss !=
'') {
232 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
234 print
'<input type="hidden" name="token" value="'.newToken().
'">';
235 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
236 print
'<input type="hidden" name="action" value="update">';
237 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
238 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
239 print
'<input type="hidden" name="page" value="'.$page.
'">';
240 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
242 $title = $langs->trans(
"MenuConfCP");
243 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"],
'', $sortfield, $sortorder, $massactionbutton,
'',
'',
'title_hrm', 0,
'',
'', $limit, 0, 0, 1);
245 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
247 if ($massaction ==
'preincreaseholiday') {
248 $langs->load(
"holiday",
"hrm");
249 require_once DOL_DOCUMENT_ROOT.
'/holiday/class/holiday.class.php';
250 $staticholiday =
new Holiday($db);
251 $arraytypeholidays = $staticholiday->getTypes(1, 1);
252 $formquestion[] = array();
253 $labeltypes = array();
254 foreach ($typeleaves as $key => $val) {
255 $labeltypes[$val[
'id']] = ($langs->trans($val[
'code']) != $val[
'code']) ? $langs->trans($val[
'code']) : $langs->trans($val[
'label']);
257 $formquestion [] = array(
'type' =>
'other',
258 'name' =>
'typeofholiday',
259 'label' => $langs->trans(
"Type"),
260 'value' =>
$form->selectarray(
'typeholiday', $labeltypes,
GETPOST(
'typeholiday',
'alpha'), 1)
262 $formquestion [] = array(
'type' =>
'other',
263 'name' =>
'nbdaysholydays',
264 'label' => $langs->trans(
"NumberDayAddMass"),
265 'value' =>
'<input name="nbdaysholidays" class="maxwidth75" id="nbdaysholidays" value="'.GETPOST(
'nbdaysholidays',
'int').
'">'
267 print
$form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"ConfirmMassIncreaseHoliday"), $langs->trans(
"ConfirmMassIncreaseHolidayQuestion", count($toselect)),
"increaseholiday", $formquestion, 1, 0, 200, 500, 1);
270 print
'<div class="info">'.$langs->trans(
'LastUpdateCP').
': '.
"\n";
271 $lastUpdate = $holiday->getConfCP(
'lastUpdate');
273 print
'<strong>'.dol_print_date($db->jdate($lastUpdate),
'dayhour').
'</strong>';
274 print
'<br>'.$langs->trans(
"MonthOfLastMonthlyUpdate").
': <strong>'.$langs->trans(
'Month'.substr($lastUpdate, 4, 2)).
' '.substr($lastUpdate, 0, 4).
'</strong>'.
"\n";
276 print $langs->trans(
'None');
278 print
"</div><br>\n";
284 $userchilds = array();
285 if (empty($user->rights->holiday->readall)) {
286 $userchilds = $user->getAllChildIds(1);
287 $filters .=
' AND u.rowid IN ('.$db->sanitize(join(
', ', $userchilds)).
')';
289 if (!empty($search_name)) {
290 $filters .=
natural_search(array(
'u.firstname',
'u.lastname'), $search_name);
292 if ($search_supervisor > 0) {
293 $filters .=
natural_search(array(
'u.fk_user'), $search_supervisor, 2);
295 $filters .=
' AND employee = 1';
297 $listUsers = $holiday->fetchUsers(
false,
true, $filters);
298 if (is_numeric($listUsers) && $listUsers < 0) {
305 if (count($typeleaves) == 0) {
307 print $langs->trans(
"NoLeaveWithCounterDefined").
"<br>\n";
308 print $langs->trans(
"GoIntoDictionaryHolidayTypes");
312 if (!empty($user->rights->holiday->define_holiday)) {
318 print
'<div class="div-table-responsive">';
319 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'" id="tablelines3">'.
"\n";
321 print
'<tr class="liste_titre_filter">';
324 print
'<td class="liste_titre">';
325 print
'<input type="text" name="search_name" value="'.dol_escape_htmltag($search_name).
'" class="maxwidth100">';
329 print
'<td class="liste_titre">';
330 print
$form->select_dolusers($search_supervisor,
'search_supervisor', 1,
null, 0,
null,
null, 0, 0, 0,
'', 0,
'',
'maxwidth150');
334 if (count($typeleaves)) {
335 foreach ($typeleaves as $key => $val) {
336 print
'<td class="liste_titre" style="text-align:center"></td>';
339 print
'<td class="liste_titre"></td>';
341 print
'<td class="liste_titre"></td>';
342 print
'<td class="liste_titre"></td>';
345 print
'<td class="liste_titre maxwidthsearch center">';
346 $searchpicto =
$form->showFilterButtons();
352 print
'<tr class="liste_titre">';
355 if (count($typeleaves)) {
356 foreach ($typeleaves as $key => $val) {
357 $labeltype = ($langs->trans($val[
'code']) != $val[
'code']) ? $langs->trans($val[
'code']) : $langs->trans($val[
'label']);
366 if ($massactionbutton) {
367 $selectedfields =
$form->showCheckAddButtons(
'checkforselect', 1);
370 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
373 $usersupervisor =
new User($db);
375 foreach ($listUsers as $users) {
376 $arrayofselected = is_array($toselect) ? $toselect : array();
379 if (empty($user->rights->holiday->readall)) {
380 if (($users[
'rowid'] != $user->id) && (!in_array($users[
'rowid'], $userchilds))) {
385 $userstatic->id = $users[
'rowid'];
386 $userstatic->lastname = $users[
'lastname'];
387 $userstatic->firstname = $users[
'firstname'];
388 $userstatic->gender = $users[
'gender'];
389 $userstatic->photo = $users[
'photo'];
390 $userstatic->statut = $users[
'status'];
391 $userstatic->employee = $users[
'employee'];
392 $userstatic->fk_user = $users[
'fk_user'];
394 if ($userstatic->fk_user > 0) {
395 $usersupervisor->fetch($userstatic->fk_user);
398 print
'<tr class="oddeven">';
402 print $userstatic->getNomUrl(-1);
407 if ($userstatic->fk_user > 0) {
408 print $usersupervisor->getNomUrl(-1);
413 if (count($typeleaves)) {
414 foreach ($typeleaves as $key => $val) {
416 if ($holiday->getCPforUser($users[
'rowid'], $val[
'rowid']) !=
'') {
417 $nbtoshow =
price2num($holiday->getCPforUser($users[
'rowid'], $val[
'rowid']), 5);
421 print
'<td style="text-align:center">';
423 print
'<input type="text"'.($canedit ?
'' :
' disabled="disabled"').
' value="'.$nbtoshow.
'" name="nb_holiday_'.$val[
'rowid'].
'['.$users[
'rowid'].
']" class="width75 center" />';
437 print
'<input type="text"'.($canedit ?
'' :
' disabled="disabled"').
' class="maxwidthonsmartphone" value="" name="note_holiday['.$users[
'rowid'].
']" size="30"/>';
442 print
'<td class="center">';
443 if (!empty($user->rights->holiday->define_holiday)) {
444 print
'<input type="submit" name="update_cp['.$users[
'rowid'].
']" value="'.
dol_escape_htmltag($langs->trans(
"Save")).
'" class="button smallpaddingimp"/>';
447 print
'<td class="nowrap center">';
449 if ($massactionbutton || $massaction) {
451 if (in_array($userstatic->id, $arrayofselected)) {
454 print
'<input id="cb'.$userstatic->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$userstatic->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class of the module paid holiday.
Class to manage Dolibarr users.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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 from a POST of a form.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.