31require
'../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/holiday/class/holiday.class.php';
36$langs->loadlangs(array(
'users',
'other',
'holiday',
'hrm'));
38$action =
GETPOST(
'action',
'aZ09');
39$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'defineholidaylist';
40$massaction =
GETPOST(
'massaction',
'alpha');
41$optioncss =
GETPOST(
'optioncss',
'alpha');
42$mode =
GETPOST(
'optioncss',
'aZ');
44$search_name =
GETPOST(
'search_name',
'alpha');
45$search_supervisor =
GETPOST(
'search_supervisor',
"intcomma");
49$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
50$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
51$toselect =
GETPOST(
'toselect',
'array');
52$confirm =
GETPOST(
'confirm',
'alpha');
55if (empty($page) || $page == -1) {
58$offset = $limit * $page;
62 $sortfield =
"t.rowid";
70$hookmanager->initHooks(array(
'defineholidaylist'));
76 'cp.rowid' => array(
'label' => $langs->trans(
"Employee"),
'checked' => 1,
'position' => 20),
77 'cp.fk_user' => array(
'label' => $langs->trans(
"Supervisor"),
'checked' => 1,
'position' => 30),
78 'cp.nbHoliday' => array(
'label' => $langs->trans(
"MenuConfCP"),
'checked' => 1,
'position' => 40),
79 'cp.note_public' => array(
'label' => $langs->trans(
"Note"),
'checked' => 1,
'position' => 50),
82$permissiontoread = $user->hasRight(
'holiday',
'read');
83$permissiontoreadall = $user->hasRight(
'holiday',
'readall');
84$permissiontowrite = $user->hasRight(
'holiday',
'write');
85$permissiontowriteall = $user->hasRight(
'holiday',
'writeall');
86$permissiontodelete = $user->hasRight(
'holiday',
'delete');
88$permissiontoapprove = $user->hasRight(
'holiday',
'approve');
89$permissiontosetup = $user->hasRight(
'holiday',
'define_holiday');
91if (!isModEnabled(
'holiday')) {
96if ($user->socid > 0) {
101if (!$user->hasRight(
'holiday',
'read')) {
110if (
GETPOST(
'cancel',
'alpha')) {
114if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
118$parameters = array();
119$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
124if (empty($reshook)) {
126 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
129 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
131 $search_supervisor =
'';
133 $search_array_options = array();
137 $objectclass =
'Holiday';
138 $objectlabel =
'Holiday';
139 $uploaddir = $conf->holiday->dir_output;
140 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
143 if ($action ==
'update' && GETPOSTISSET(
'update_cp') && $permissiontosetup) {
147 $typeleaves = $holiday->getTypes(1, 1);
149 $userID = array_keys(
GETPOST(
'update_cp'));
150 $userID = $userID[0];
154 foreach ($typeleaves as $key => $val) {
155 $userValue =
GETPOST(
'nb_holiday_'.$val[
'rowid']);
156 $userValue = $userValue[$userID];
158 if (!empty($userValue) || (
string) $userValue ==
'0') {
165 $note_holiday =
GETPOST(
'note_holiday');
166 $comment = ((isset($note_holiday[$userID]) && !empty($note_holiday[$userID])) ?
' ('.$note_holiday[$userID].
')' :
'');
169 if ($userValue !=
'') {
171 $result = $holiday->addLogCP($user->id, $userID, $langs->transnoentitiesnoconv(
'ManualUpdate').$comment, $userValue, $val[
'rowid']);
181 $result = $holiday->updateSoldeCP($userID, $userValue, $val[
'rowid']);
200 if (!$error && !$nbok) {
201 setEventMessages($langs->trans(
"HolidayQtyNotModified", $user->login),
null,
'warnings');
221$form =
new Form($db);
222$userstatic =
new User($db);
225$title = $langs->trans(
'CPTitreMenu');
229$typeleaves = $holiday->getTypes(1, 1);
230$result = $holiday->updateBalance();
236$arrayofmassactions = array(
241if ($permissiontosetup) {
242 $arrayofmassactions[
'preincreaseholiday'] =
img_picto(
'',
'add',
'class="pictofixedwidth"').$langs->trans(
"IncreaseHolidays");
244$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
247print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
248if ($optioncss !=
'') {
249 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
251print
'<input type="hidden" name="token" value="'.newToken().
'">';
252print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
253print
'<input type="hidden" name="action" value="update">';
254print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
255print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
256print
'<input type="hidden" name="page" value="'.$page.
'">';
257print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
259$title = $langs->trans(
"MenuConfCP");
260print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"],
'', $sortfield, $sortorder, $massactionbutton,
'',
'',
'title_hrm', 0,
'',
'', $limit, 0, 0, 1);
262include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
264if ($massaction ==
'preincreaseholiday') {
265 $langs->load(
"holiday",
"hrm");
266 require_once DOL_DOCUMENT_ROOT.
'/holiday/class/holiday.class.php';
267 $staticholiday =
new Holiday($db);
268 $arraytypeholidays = $staticholiday->getTypes(1, 1);
269 $formquestion = array();
270 $labeltypes = array();
271 foreach ($typeleaves as $key => $val) {
272 $labeltypes[$val[
'id']] = ($langs->trans($val[
'code']) != $val[
'code']) ? $langs->trans($val[
'code']) : $langs->trans($val[
'label']);
274 $formquestion [] = array(
'type' =>
'other',
275 'name' =>
'typeofholiday',
276 'label' => $langs->trans(
"Type"),
277 'value' => $form->selectarray(
'typeholiday', $labeltypes,
GETPOST(
'typeholiday',
'alpha'), 1)
279 $formquestion [] = array(
'type' =>
'other',
280 'name' =>
'nbdaysholydays',
281 'label' => $langs->trans(
"NumberDayAddMass"),
282 'value' =>
'<input name="nbdaysholidays" class="maxwidth75" id="nbdaysholidays" value="'.GETPOSTINT(
'nbdaysholidays').
'">'
284 print $form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"ConfirmMassIncreaseHoliday"), $langs->trans(
"ConfirmMassIncreaseHolidayQuestion", count($toselect)),
"increaseholiday", $formquestion, 1, 0, 200, 500, 1);
287print
'<div class="info">'.$langs->trans(
'LastUpdateCP').
': '.
"\n";
288$lastUpdate = $holiday->getConfCP(
'lastUpdate');
290 print
'<strong>'.dol_print_date($db->jdate($lastUpdate),
'dayhour').
'</strong>';
291 print
'<br>'.$langs->trans(
"MonthOfLastMonthlyUpdate").
': <strong>'.$langs->trans(
'Month'.substr($lastUpdate, 4, 2)).
' '.substr($lastUpdate, 0, 4).
'</strong>'.
"\n";
293 print $langs->trans(
'None');
301$userchilds = array();
302if (!$permissiontoreadall) {
303 $userchilds = $user->getAllChildIds(1);
304 $filters .=
' AND u.rowid IN ('.$db->sanitize(implode(
', ', $userchilds)).
')';
306if (!empty($search_name)) {
307 $filters .=
natural_search(array(
'u.firstname',
'u.lastname'), $search_name);
309if ($search_supervisor > 0) {
310 $filters .=
natural_search(array(
'u.fk_user'), $search_supervisor, 2);
312$filters .=
' AND employee = 1';
314$listUsers = $holiday->fetchUsers(
false,
true, $filters);
315if (is_numeric($listUsers) && $listUsers < 0) {
323if (count($typeleaves) == 0) {
325 print $langs->trans(
"NoLeaveWithCounterDefined").
"<br>\n";
326 print $langs->trans(
"GoIntoDictionaryHolidayTypes");
330 if ($permissiontosetup) {
336 $selectedfields =
'';
337 if ($massactionbutton) {
338 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
339 $selectedfields .= ($mode !=
'kanban' ? $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN')) :
'');
340 $selectedfields .= $form->showCheckAddButtons(
'checkforselect', 1);
343 print
'<div class="div-table-responsive">';
344 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'" id="tablelines3">'.
"\n";
346 print
'<tr class="liste_titre_filter">';
350 print
'<td class="liste_titre maxwidthsearch center">';
351 $searchpicto = $form->showFilterButtons();
357 if (!empty($arrayfields[
'cp.rowid'][
'checked'])) {
358 print
'<td class="liste_titre">';
359 print
'<input type="text" name="search_name" value="'.dol_escape_htmltag($search_name).
'" class="maxwidth100">';
363 if (!empty($arrayfields[
'cp.fk_user'][
'checked'])) {
364 print
'<td class="liste_titre">';
365 print $form->select_dolusers($search_supervisor,
'search_supervisor', 1,
null, 0,
null,
null, 0, 0, 0,
'', 0,
'',
'maxwidth150');
369 if (!empty($arrayfields[
'cp.nbHoliday'][
'checked'])) {
370 if (count($typeleaves)) {
371 foreach ($typeleaves as $key => $val) {
372 print
'<td class="liste_titre" style="text-align:center"></td>';
375 print
'<td class="liste_titre"></td>';
378 if (!empty($arrayfields[
'cp.note_public'][
'checked'])) {
379 print
'<td class="liste_titre"></td>';
381 print
'<td class="liste_titre"></td>';
385 print
'<td class="liste_titre maxwidthsearch center">';
386 $searchpicto = $form->showFilterButtons();
393 print
'<tr class="liste_titre">';
396 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
398 if (!empty($arrayfields[
'cp.rowid'][
'checked'])) {
401 if (!empty($arrayfields[
'cp.fk_user'][
'checked'])) {
404 if (!empty($arrayfields[
'cp.nbHoliday'][
'checked'])) {
405 if (count($typeleaves)) {
406 foreach ($typeleaves as $key => $val) {
407 $labeltype = ($langs->trans($val[
'code']) != $val[
'code']) ? $langs->trans($val[
'code']) : $langs->trans($val[
'label']);
414 if (!empty($arrayfields[
'cp.note_public'][
'checked'])) {
420 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
423 $usersupervisor =
new User($db);
425 foreach ($listUsers as $users) {
426 $arrayofselected = is_array($toselect) ? $toselect : array();
429 if (!$permissiontoreadall) {
430 if (($users[
'rowid'] != $user->id) && (!in_array($users[
'rowid'], $userchilds))) {
435 $userstatic->id = $users[
'rowid'];
436 $userstatic->lastname = $users[
'lastname'];
437 $userstatic->firstname = $users[
'firstname'];
438 $userstatic->gender = $users[
'gender'];
439 $userstatic->photo = $users[
'photo'];
440 $userstatic->status = $users[
'status'];
441 $userstatic->employee = $users[
'employee'];
442 $userstatic->fk_user = $users[
'fk_user'];
444 if ($userstatic->fk_user > 0) {
445 $usersupervisor->fetch($userstatic->fk_user);
448 print
'<tr class="oddeven">';
452 print
'<td class="nowrap center">';
454 if ($massactionbutton || $massaction) {
456 if (in_array($userstatic->id, $arrayofselected)) {
459 print
'<input id="cb'.$userstatic->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$userstatic->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
465 if (!empty($arrayfields[
'cp.rowid'][
'checked'])) {
467 print $userstatic->getNomUrl(-1);
471 if (!empty($arrayfields[
'cp.fk_user'][
'checked'])) {
473 if ($userstatic->fk_user > 0) {
474 print $usersupervisor->getNomUrl(-1);
480 if (!empty($arrayfields[
'cp.nbHoliday'][
'checked'])) {
481 if (count($typeleaves)) {
482 foreach ($typeleaves as $key => $val) {
484 if ($holiday->getCPforUser($users[
'rowid'], $val[
'rowid']) !=
'') {
485 $nbtoshow =
price2num($holiday->getCPforUser($users[
'rowid'], $val[
'rowid']), 5);
489 print
'<td style="text-align:center">';
491 print
'<input type="text"'.($canedit ?
'' :
' disabled="disabled"').
' value="'.$nbtoshow.
'" name="nb_holiday_'.$val[
'rowid'].
'['.$users[
'rowid'].
']" class="width75 center" />';
504 if (!empty($arrayfields[
'cp.note_public'][
'checked'])) {
507 print
'<input type="text"'.($canedit ?
'' :
' disabled="disabled"').
' class="maxwidthonsmartphone" value="" name="note_holiday['.$users[
'rowid'].
']" size="30"/>';
513 print
'<td class="center">';
514 if ($permissiontosetup) {
515 print
'<input type="submit" name="update_cp['.$users[
'rowid'].
']" value="'.
dol_escape_htmltag($langs->trans(
"Save")).
'" class="button smallpaddingimp"/>';
521 print
'<td class="nowrap center">';
523 if ($massactionbutton || $massaction) {
525 if (in_array($userstatic->id, $arrayofselected)) {
528 print
'<input id="cb'.$userstatic->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$userstatic->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
538 if (count($listUsers) <= 0) {
540 foreach ($arrayfields as $key => $val) {
541 if (!empty($val[
'checked'])) {
542 if ($key ==
'cp.nbHoliday') {
543 foreach ($typeleaves as $leave_key => $leave_val) {
551 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
print_barre_liste($title, $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.
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.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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.