30require
'../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
32require_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');
52$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
53if (empty($page) || $page == -1) {
56$offset = $limit * $page;
60 $sortfield =
"t.rowid";
68$hookmanager->initHooks(array(
'defineholidaylist'));
74if (empty($conf->holiday->enabled)) {
79if ($user->socid > 0) {
84if (empty($user->rights->holiday->read)) {
93if (
GETPOST(
'cancel',
'alpha')) {
94 $action =
'list'; $massaction =
'';
96if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
100$parameters = array();
101$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
106if (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';
128 if ($action ==
'update' && GETPOSTISSET(
'update_cp')) {
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']);
204$form =
new Form($db);
205$userstatic =
new User($db);
208$title = $langs->trans(
'CPTitreMenu');
212$typeleaves = $holiday->getTypes(1, 1);
213$result = $holiday->updateBalance();
219$arrayofmassactions = array(
224if ($user->hasRight(
"holiday",
"approve")) {
225 $arrayofmassactions[
'preincreaseholiday'] =
img_picto(
'',
'add',
'class="pictofixedwidth"').$langs->trans(
"IncreaseHolidays");
227$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
230print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
231if ($optioncss !=
'') {
232 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
234print
'<input type="hidden" name="token" value="'.newToken().
'">';
235print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
236print
'<input type="hidden" name="action" value="update">';
237print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
238print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
239print
'<input type="hidden" name="page" value="'.$page.
'">';
240print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
242$title = $langs->trans(
"MenuConfCP");
243print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"],
'', $sortfield, $sortorder, $massactionbutton,
'',
'',
'title_hrm', 0,
'',
'', $limit, 0, 0, 1);
245include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
247if ($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);
270print
'<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');
284$userchilds = array();
285if (empty($user->rights->holiday->readall)) {
286 $userchilds = $user->getAllChildIds(1);
287 $filters .=
' AND u.rowid IN ('.$db->sanitize(join(
', ', $userchilds)).
')';
289if (!empty($search_name)) {
290 $filters .=
natural_search(array(
'u.firstname',
'u.lastname'), $search_name);
292if ($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);
298if (is_numeric($listUsers) && $listUsers < 0) {
305if (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 $selectedfields =
'';
367 if ($massactionbutton) {
368 $selectedfields = $form->showCheckAddButtons(
'checkforselect', 1);
371 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
374 $usersupervisor =
new User($db);
376 foreach ($listUsers as $users) {
377 $arrayofselected = is_array($toselect) ? $toselect : array();
380 if (empty($user->rights->holiday->readall)) {
381 if (($users[
'rowid'] != $user->id) && (!in_array($users[
'rowid'], $userchilds))) {
386 $userstatic->id = $users[
'rowid'];
387 $userstatic->lastname = $users[
'lastname'];
388 $userstatic->firstname = $users[
'firstname'];
389 $userstatic->gender = $users[
'gender'];
390 $userstatic->photo = $users[
'photo'];
391 $userstatic->statut = $users[
'status'];
392 $userstatic->employee = $users[
'employee'];
393 $userstatic->fk_user = $users[
'fk_user'];
395 if ($userstatic->fk_user > 0) {
396 $usersupervisor->fetch($userstatic->fk_user);
399 print
'<tr class="oddeven">';
403 print $userstatic->getNomUrl(-1);
408 if ($userstatic->fk_user > 0) {
409 print $usersupervisor->getNomUrl(-1);
414 if (count($typeleaves)) {
415 foreach ($typeleaves as $key => $val) {
417 if ($holiday->getCPforUser($users[
'rowid'], $val[
'rowid']) !=
'') {
418 $nbtoshow =
price2num($holiday->getCPforUser($users[
'rowid'], $val[
'rowid']), 5);
422 print
'<td style="text-align:center">';
424 print
'<input type="text"'.($canedit ?
'' :
' disabled="disabled"').
' value="'.$nbtoshow.
'" name="nb_holiday_'.$val[
'rowid'].
'['.$users[
'rowid'].
']" class="width75 center" />';
438 print
'<input type="text"'.($canedit ?
'' :
' disabled="disabled"').
' class="maxwidthonsmartphone" value="" name="note_holiday['.$users[
'rowid'].
']" size="30"/>';
443 print
'<td class="center">';
444 if (!empty($user->rights->holiday->define_holiday)) {
445 print
'<input type="submit" name="update_cp['.$users[
'rowid'].
']" value="'.
dol_escape_htmltag($langs->trans(
"Save")).
'" class="button smallpaddingimp"/>';
448 print
'<td class="nowrap center">';
450 if ($massactionbutton || $massaction) {
452 if (in_array($userstatic->id, $arrayofselected)) {
455 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.
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...
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
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.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.