33require
'../main.inc.php';
42require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/holiday/class/holiday.class.php';
46$langs->loadlangs(array(
'users',
'other',
'holiday',
'hrm'));
48$action =
GETPOST(
'action',
'aZ09');
49$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'defineholidaylist';
50$massaction =
GETPOST(
'massaction',
'alpha');
51$optioncss =
GETPOST(
'optioncss',
'alpha');
52$mode =
GETPOST(
'optioncss',
'aZ');
54$search_name =
GETPOST(
'search_name',
'alpha');
55$search_supervisor =
GETPOST(
'search_supervisor',
"intcomma");
59$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
60$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
61$toselect =
GETPOST(
'toselect',
'array:int');
62$confirm =
GETPOST(
'confirm',
'alpha');
65if (empty($page) || $page == -1) {
68$offset = $limit * $page;
72 $sortfield =
"t.rowid";
80$hookmanager->initHooks(array(
'defineholidaylist'));
85 'cp.rowid' => array(
'label' => $langs->trans(
"Employee"),
'checked' =>
'1',
'position' => 20),
86 'cp.fk_user' => array(
'label' => $langs->trans(
"Supervisor"),
'checked' =>
'1',
'position' => 30),
87 'cp.nbHoliday' => array(
'label' => $langs->trans(
"MenuConfCP"),
'checked' =>
'1',
'position' => 40),
88 'cp.note_public' => array(
'label' => $langs->trans(
"Note"),
'checked' =>
'1',
'position' => 50),
91$permissiontoread = $user->hasRight(
'holiday',
'read');
92$permissiontoreadall = $user->hasRight(
'holiday',
'readall');
93$permissiontowrite = $user->hasRight(
'holiday',
'write');
94$permissiontowriteall = $user->hasRight(
'holiday',
'writeall');
95$permissiontodelete = $user->hasRight(
'holiday',
'delete');
97$permissiontoapprove = $user->hasRight(
'holiday',
'approve');
98$permissiontosetup = $user->hasRight(
'holiday',
'define_holiday');
105if ($user->socid > 0) {
110if (!$user->hasRight(
'holiday',
'read')) {
119if (
GETPOST(
'cancel',
'alpha')) {
123if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
127$parameters = array();
128$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
133if (empty($reshook)) {
135 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
138 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
140 $search_supervisor =
'';
142 $search_array_options = array();
146 $objectclass =
'Holiday';
147 $objectlabel =
'Holiday';
148 $uploaddir =
$conf->holiday->dir_output;
149 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
152 if ($action ==
'update' && GETPOSTISSET(
'update_cp') && $permissiontosetup) {
156 $typeleaves = $holiday->getTypes(1, 1);
158 $userID = array_keys(
GETPOST(
'update_cp',
'array:int'));
159 $userID = (int) $userID[0];
163 foreach ($typeleaves as $key => $val) {
164 $userValue =
GETPOST(
'nb_holiday_'.$val[
'rowid'],
'array');
165 $userValue = $userValue[$userID];
167 if (!empty($userValue) || (
string) $userValue ==
'0') {
174 $note_holiday =
GETPOST(
'note_holiday');
175 $comment = ((isset($note_holiday[$userID]) && !empty($note_holiday[$userID])) ?
' ('.$note_holiday[$userID].
')' :
'');
178 if ($userValue !=
'') {
180 $result = $holiday->addLogCP($user->id, $userID, $langs->transnoentitiesnoconv(
'ManualUpdate').$comment, (
float) $userValue, $val[
'rowid']);
190 $result = $holiday->updateSoldeCP($userID, (
float) $userValue, $val[
'rowid']);
209 if (!$error && !$nbok) {
210 setEventMessages($langs->trans(
"HolidayQtyNotModified", $user->login),
null,
'warnings');
234$title = $langs->trans(
'CPTitreMenu');
235$help_url =
'EN:Module_Holiday';
237llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-holiday page-define_holiday');
239$typeleaves = $holiday->getTypes(1, 1);
240$result = $holiday->updateBalance();
246$arrayofmassactions = array(
251if ($permissiontosetup) {
252 $arrayofmassactions[
'preincreaseholiday'] =
img_picto(
'',
'add',
'class="pictofixedwidth"').$langs->trans(
"IncreaseHolidays");
254$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
257print
'<form method="POST" id="searchFormList" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
258if ($optioncss !=
'') {
259 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
261print
'<input type="hidden" name="token" value="'.newToken().
'">';
262print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
263print
'<input type="hidden" name="action" value="update">';
264print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
265print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
266print
'<input type="hidden" name="page" value="'.$page.
'">';
267print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
269$title = $langs->trans(
"MenuConfCP");
270print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"],
'', $sortfield, $sortorder, $massactionbutton, 0,
'',
'title_hrm', 0,
'',
'', $limit, 0, 0, 1);
272include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
274if ($massaction ==
'preincreaseholiday') {
275 $langs->loadLangs(array(
"holiday",
"hrm"));
276 require_once DOL_DOCUMENT_ROOT.
'/holiday/class/holiday.class.php';
278 $arraytypeholidays = $staticholiday->getTypes(1, 1);
279 $formquestion = array();
280 $labeltypes = array();
281 foreach ($typeleaves as $key => $val) {
282 $labeltypes[$val[
'id']] = ($langs->trans($val[
'code']) != $val[
'code']) ? $langs->trans($val[
'code']) : $langs->trans($val[
'label']);
284 $formquestion [] = array(
'type' =>
'other',
285 'name' =>
'typeofholiday',
286 'label' => $langs->trans(
"Type"),
287 'value' => $form->selectarray(
'typeholiday', $labeltypes,
GETPOST(
'typeholiday',
'alpha'), 1)
289 $formquestion [] = array(
'type' =>
'other',
290 'name' =>
'nbdaysholydays',
291 'label' => $langs->trans(
"NumberDayAddMass"),
292 'value' =>
'<input name="nbdaysholidays" class="maxwidth75" id="nbdaysholidays" value="'.GETPOSTINT(
'nbdaysholidays').
'">'
294 print $form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"ConfirmMassIncreaseHoliday"), $langs->trans(
"ConfirmMassIncreaseHolidayQuestion", count($toselect)),
"increaseholiday", $formquestion, 1, 0, 200, 500, 1);
297print
'<div class="info">'.$langs->trans(
'LastUpdateCP').
': '.
"\n";
298$lastUpdate = $holiday->getConfCP(
'lastUpdate');
300 print
'<strong>'.dol_print_date(
$db->jdate($lastUpdate),
'dayhour').
'</strong>';
301 print
'<br>'.$langs->trans(
"MonthOfLastMonthlyUpdate").
': <strong>'.$langs->trans(
'Month'.substr($lastUpdate, 4, 2)).
' '.substr($lastUpdate, 0, 4).
'</strong>'.
"\n";
303 print $langs->trans(
'None');
311$userchilds = array();
312if (!$permissiontoreadall) {
313 $userchilds = $user->getAllChildIds(1);
314 $filters .=
' AND u.rowid IN ('.$db->sanitize(implode(
', ', $userchilds)).
')';
316if (!empty($search_name)) {
317 $filters .=
natural_search(array(
'u.firstname',
'u.lastname'), $search_name);
319if ($search_supervisor > 0) {
320 $filters .=
natural_search(array(
'u.fk_user'), $search_supervisor, 2);
322$filters .=
' AND employee = 1';
324$listUsers = $holiday->fetchUsers(
false,
true, $filters);
325if (is_numeric($listUsers) && $listUsers < 0) {
331if (count($typeleaves) == 0) {
333 print $langs->trans(
"NoLeaveWithCounterDefined").
"<br>\n";
334 print $langs->trans(
"GoIntoDictionaryHolidayTypes");
340 if ($permissiontosetup) {
346 $selectedfields =
'';
347 if ($massactionbutton) {
348 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
349 $selectedfields .= ($mode !=
'kanban' ? $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
$conf->main_checkbox_left_column) :
'');
350 $selectedfields .= $form->showCheckAddButtons(
'checkforselect', 1);
353 print
'<div class="div-table-responsive">';
354 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'" id="tablelines3">'.
"\n";
356 print
'<tr class="liste_titre_filter">';
359 if (
$conf->main_checkbox_left_column) {
360 print
'<td class="liste_titre maxwidthsearch center">';
361 $searchpicto = $form->showFilterButtons();
367 if (!empty($arrayfields[
'cp.rowid'][
'checked'])) {
368 print
'<td class="liste_titre">';
369 print
'<input type="text" name="search_name" value="'.dol_escape_htmltag($search_name).
'" class="maxwidth100">';
373 if (!empty($arrayfields[
'cp.fk_user'][
'checked'])) {
374 print
'<td class="liste_titre">';
375 print $form->select_dolusers($search_supervisor,
'search_supervisor', 1,
null, 0, array(),
'',
'', 0, 0,
'', 0,
'',
'maxwidth150');
379 if (!empty($arrayfields[
'cp.nbHoliday'][
'checked'])) {
380 if (count($typeleaves)) {
381 foreach ($typeleaves as $key => $val) {
382 print
'<td class="liste_titre" style="text-align:center"></td>';
385 print
'<td class="liste_titre"></td>';
388 if (!empty($arrayfields[
'cp.note_public'][
'checked'])) {
389 print
'<td class="liste_titre"></td>';
391 print
'<td class="liste_titre"></td>';
392 print
'<td class="liste_titre"></td>';
395 if (!
$conf->main_checkbox_left_column) {
396 print
'<td class="liste_titre maxwidthsearch center">';
397 $searchpicto = $form->showFilterButtons();
404 print
'<tr class="liste_titre">';
406 if (
$conf->main_checkbox_left_column) {
407 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
409 if (!empty($arrayfields[
'cp.rowid'][
'checked'])) {
412 if (!empty($arrayfields[
'cp.fk_user'][
'checked'])) {
415 if (!empty($arrayfields[
'cp.nbHoliday'][
'checked'])) {
416 if (count($typeleaves)) {
417 foreach ($typeleaves as $key => $val) {
418 $labeltype = ($langs->trans($val[
'code']) != $val[
'code']) ? $langs->trans($val[
'code']) : $langs->trans($val[
'label']);
422 print_liste_field_titre(
'NoLeaveWithCounterDefined', $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder);
425 if (!empty($arrayfields[
'cp.note_public'][
'checked'])) {
426 print_liste_field_titre($permissiontosetup ? $langs->trans(
"ReasonForModification") :
'', $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder);
431 if (!
$conf->main_checkbox_left_column) {
432 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
435 $usersupervisor =
new User(
$db);
437 foreach ($listUsers as $users) {
438 $arrayofselected = is_array($toselect) ? $toselect : array();
441 if (!$permissiontoreadall) {
442 if (($users[
'rowid'] != $user->id) && (!in_array($users[
'rowid'], $userchilds))) {
447 $userstatic->id = $users[
'rowid'];
448 $userstatic->lastname = $users[
'lastname'];
449 $userstatic->firstname = $users[
'firstname'];
450 $userstatic->gender = $users[
'gender'];
451 $userstatic->photo = $users[
'photo'];
452 $userstatic->status = $users[
'status'];
453 $userstatic->employee = $users[
'employee'];
454 $userstatic->fk_user = $users[
'fk_user'];
456 if ($userstatic->fk_user > 0) {
457 $usersupervisor->fetch($userstatic->fk_user);
460 print
'<tr class="oddeven">';
463 if (
$conf->main_checkbox_left_column) {
464 print
'<td class="nowrap center">';
466 if ($massactionbutton || $massaction) {
468 if (in_array($userstatic->id, $arrayofselected)) {
471 print
'<input id="cb'.$userstatic->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$userstatic->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
477 if (!empty($arrayfields[
'cp.rowid'][
'checked'])) {
479 print $userstatic->getNomUrl(-1);
483 if (!empty($arrayfields[
'cp.fk_user'][
'checked'])) {
485 if ($userstatic->fk_user > 0) {
486 print $usersupervisor->getNomUrl(-1);
492 if (!empty($arrayfields[
'cp.nbHoliday'][
'checked'])) {
493 if (count($typeleaves)) {
494 foreach ($typeleaves as $key => $val) {
496 if ($holiday->getCPforUser($users[
'rowid'], $val[
'rowid']) !=
'') {
497 $nbtoshow =
price2num((
float) $holiday->getCPforUser($users[
'rowid'], $val[
'rowid']), 5);
501 print
'<td class="center">';
503 print
'<input type="text"'.($canedit ?
'' :
' disabled="disabled"').
' value="'.$nbtoshow.
'" name="nb_holiday_'.$val[
'rowid'].
'['.$users[
'rowid'].
']" class="width75 center" />';
516 if (!empty($arrayfields[
'cp.note_public'][
'checked'])) {
519 print
'<input type="text"'.($canedit ?
'' :
' disabled="disabled"').
' class="maxwidthonsmartphone" value="" name="note_holiday['.$users[
'rowid'].
']" size="30"/>';
525 print
'<td class="center">';
526 if ($permissiontosetup) {
527 print
'<input type="submit" name="update_cp['.$users[
'rowid'].
']" value="'.
dol_escape_htmltag($langs->trans(
"Modify")).
'" class="button smallpaddingimp"/>';
531 print
'<td class="center">';
532 print
'<a href="'.DOL_URL_ROOT.
'/holiday/view_log.php?search_employee='.((int) $users[
'rowid']).
'">'.
img_picto($langs->trans(
'MenuLogCP'),
'list-alt').
'</a>';
536 if (!
$conf->main_checkbox_left_column) {
537 print
'<td class="nowrap center">';
539 if ($massactionbutton || $massaction) {
541 if (in_array($userstatic->id, $arrayofselected)) {
544 print
'<input id="cb'.$userstatic->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$userstatic->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
554 if (count($listUsers) <= 0) {
556 foreach ($arrayfields as $key => $val) {
557 if (!empty($val[
'checked'])) {
558 if ($key ==
'cp.nbHoliday') {
559 foreach ($typeleaves as $leave_key => $leave_val) {
567 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class of the module paid holiday.
Class to manage Dolibarr users.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show 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, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
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, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get 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.
isModEnabled($module)
Is Dolibarr module enabled.
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.