33require
'../main.inc.php';
34require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/holiday/class/holiday.class.php';
38$langs->loadlangs(array(
'users',
'other',
'holiday',
'hrm'));
40$action =
GETPOST(
'action',
'aZ09');
41$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'defineholidaylist';
42$massaction =
GETPOST(
'massaction',
'alpha');
43$optioncss =
GETPOST(
'optioncss',
'alpha');
44$mode =
GETPOST(
'optioncss',
'aZ');
46$search_name =
GETPOST(
'search_name',
'alpha');
47$search_supervisor =
GETPOST(
'search_supervisor',
"intcomma");
51$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
52$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
53$toselect =
GETPOST(
'toselect',
'array');
54$confirm =
GETPOST(
'confirm',
'alpha');
57if (empty($page) || $page == -1) {
60$offset = $limit * $page;
64 $sortfield =
"t.rowid";
72$hookmanager->initHooks(array(
'defineholidaylist'));
78 'cp.rowid' => array(
'label' => $langs->trans(
"Employee"),
'checked' => 1,
'position' => 20),
79 'cp.fk_user' => array(
'label' => $langs->trans(
"Supervisor"),
'checked' => 1,
'position' => 30),
80 'cp.nbHoliday' => array(
'label' => $langs->trans(
"MenuConfCP"),
'checked' => 1,
'position' => 40),
81 'cp.note_public' => array(
'label' => $langs->trans(
"Note"),
'checked' => 1,
'position' => 50),
84$permissiontoread = $user->hasRight(
'holiday',
'read');
85$permissiontoreadall = $user->hasRight(
'holiday',
'readall');
86$permissiontowrite = $user->hasRight(
'holiday',
'write');
87$permissiontowriteall = $user->hasRight(
'holiday',
'writeall');
88$permissiontodelete = $user->hasRight(
'holiday',
'delete');
90$permissiontoapprove = $user->hasRight(
'holiday',
'approve');
91$permissiontosetup = $user->hasRight(
'holiday',
'define_holiday');
93if (!isModEnabled(
'holiday')) {
98if ($user->socid > 0) {
103if (!$user->hasRight(
'holiday',
'read')) {
112if (
GETPOST(
'cancel',
'alpha')) {
116if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
120$parameters = array();
121$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
126if (empty($reshook)) {
128 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
131 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
133 $search_supervisor =
'';
135 $search_array_options = array();
139 $objectclass =
'Holiday';
140 $objectlabel =
'Holiday';
141 $uploaddir = $conf->holiday->dir_output;
142 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
145 if ($action ==
'update' && GETPOSTISSET(
'update_cp') && $permissiontosetup) {
149 $typeleaves = $holiday->getTypes(1, 1);
151 $userID = array_keys(
GETPOST(
'update_cp'));
152 $userID = $userID[0];
156 foreach ($typeleaves as $key => $val) {
157 $userValue =
GETPOST(
'nb_holiday_'.$val[
'rowid']);
158 $userValue = $userValue[$userID];
160 if (!empty($userValue) || (
string) $userValue ==
'0') {
167 $note_holiday =
GETPOST(
'note_holiday');
168 $comment = ((isset($note_holiday[$userID]) && !empty($note_holiday[$userID])) ?
' ('.$note_holiday[$userID].
')' :
'');
171 if ($userValue !=
'') {
173 $result = $holiday->addLogCP($user->id, $userID, $langs->transnoentitiesnoconv(
'ManualUpdate').$comment, $userValue, $val[
'rowid']);
183 $result = $holiday->updateSoldeCP($userID, $userValue, $val[
'rowid']);
202 if (!$error && !$nbok) {
203 setEventMessages($langs->trans(
"HolidayQtyNotModified", $user->login),
null,
'warnings');
223$form =
new Form($db);
224$userstatic =
new User($db);
227$title = $langs->trans(
'CPTitreMenu');
228$help_url =
'EN:Module_Holiday';
230llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-holiday page-define_holiday');
232$typeleaves = $holiday->getTypes(1, 1);
233$result = $holiday->updateBalance();
239$arrayofmassactions = array(
244if ($permissiontosetup) {
245 $arrayofmassactions[
'preincreaseholiday'] =
img_picto(
'',
'add',
'class="pictofixedwidth"').$langs->trans(
"IncreaseHolidays");
247$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
250print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
251if ($optioncss !=
'') {
252 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
254print
'<input type="hidden" name="token" value="'.newToken().
'">';
255print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
256print
'<input type="hidden" name="action" value="update">';
257print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
258print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
259print
'<input type="hidden" name="page" value="'.$page.
'">';
260print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
262$title = $langs->trans(
"MenuConfCP");
263print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"],
'', $sortfield, $sortorder, $massactionbutton, 0,
'',
'title_hrm', 0,
'',
'', $limit, 0, 0, 1);
265include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
267if ($massaction ==
'preincreaseholiday') {
268 $langs->loadLangs(array(
"holiday",
"hrm"));
269 require_once DOL_DOCUMENT_ROOT.
'/holiday/class/holiday.class.php';
270 $staticholiday =
new Holiday($db);
271 $arraytypeholidays = $staticholiday->getTypes(1, 1);
272 $formquestion = array();
273 $labeltypes = array();
274 foreach ($typeleaves as $key => $val) {
275 $labeltypes[$val[
'id']] = ($langs->trans($val[
'code']) != $val[
'code']) ? $langs->trans($val[
'code']) : $langs->trans($val[
'label']);
277 $formquestion [] = array(
'type' =>
'other',
278 'name' =>
'typeofholiday',
279 'label' => $langs->trans(
"Type"),
280 'value' => $form->selectarray(
'typeholiday', $labeltypes,
GETPOST(
'typeholiday',
'alpha'), 1)
282 $formquestion [] = array(
'type' =>
'other',
283 'name' =>
'nbdaysholydays',
284 'label' => $langs->trans(
"NumberDayAddMass"),
285 'value' =>
'<input name="nbdaysholidays" class="maxwidth75" id="nbdaysholidays" value="'.GETPOSTINT(
'nbdaysholidays').
'">'
287 print $form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"ConfirmMassIncreaseHoliday"), $langs->trans(
"ConfirmMassIncreaseHolidayQuestion", count($toselect)),
"increaseholiday", $formquestion, 1, 0, 200, 500, 1);
290print
'<div class="info">'.$langs->trans(
'LastUpdateCP').
': '.
"\n";
291$lastUpdate = $holiday->getConfCP(
'lastUpdate');
293 print
'<strong>'.dol_print_date($db->jdate($lastUpdate),
'dayhour').
'</strong>';
294 print
'<br>'.$langs->trans(
"MonthOfLastMonthlyUpdate").
': <strong>'.$langs->trans(
'Month'.substr($lastUpdate, 4, 2)).
' '.substr($lastUpdate, 0, 4).
'</strong>'.
"\n";
296 print $langs->trans(
'None');
304$userchilds = array();
305if (!$permissiontoreadall) {
306 $userchilds = $user->getAllChildIds(1);
307 $filters .=
' AND u.rowid IN ('.$db->sanitize(implode(
', ', $userchilds)).
')';
309if (!empty($search_name)) {
310 $filters .=
natural_search(array(
'u.firstname',
'u.lastname'), $search_name);
312if ($search_supervisor > 0) {
313 $filters .=
natural_search(array(
'u.fk_user'), $search_supervisor, 2);
315$filters .=
' AND employee = 1';
317$listUsers = $holiday->fetchUsers(
false,
true, $filters);
318if (is_numeric($listUsers) && $listUsers < 0) {
326if (count($typeleaves) == 0) {
328 print $langs->trans(
"NoLeaveWithCounterDefined").
"<br>\n";
329 print $langs->trans(
"GoIntoDictionaryHolidayTypes");
333 if ($permissiontosetup) {
339 $selectedfields =
'';
340 if ($massactionbutton) {
341 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
342 $selectedfields .= ($mode !=
'kanban' ? $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN')) :
'');
343 $selectedfields .= $form->showCheckAddButtons(
'checkforselect', 1);
346 print
'<div class="div-table-responsive">';
347 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'" id="tablelines3">'.
"\n";
349 print
'<tr class="liste_titre_filter">';
353 print
'<td class="liste_titre maxwidthsearch center">';
354 $searchpicto = $form->showFilterButtons();
360 if (!empty($arrayfields[
'cp.rowid'][
'checked'])) {
361 print
'<td class="liste_titre">';
362 print
'<input type="text" name="search_name" value="'.dol_escape_htmltag($search_name).
'" class="maxwidth100">';
366 if (!empty($arrayfields[
'cp.fk_user'][
'checked'])) {
367 print
'<td class="liste_titre">';
368 print $form->select_dolusers($search_supervisor,
'search_supervisor', 1,
null, 0, array(),
'', 0, 0, 0,
'', 0,
'',
'maxwidth150');
372 if (!empty($arrayfields[
'cp.nbHoliday'][
'checked'])) {
373 if (count($typeleaves)) {
374 foreach ($typeleaves as $key => $val) {
375 print
'<td class="liste_titre" style="text-align:center"></td>';
378 print
'<td class="liste_titre"></td>';
381 if (!empty($arrayfields[
'cp.note_public'][
'checked'])) {
382 print
'<td class="liste_titre"></td>';
384 print
'<td class="liste_titre"></td>';
388 print
'<td class="liste_titre maxwidthsearch center">';
389 $searchpicto = $form->showFilterButtons();
396 print
'<tr class="liste_titre">';
399 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
401 if (!empty($arrayfields[
'cp.rowid'][
'checked'])) {
404 if (!empty($arrayfields[
'cp.fk_user'][
'checked'])) {
407 if (!empty($arrayfields[
'cp.nbHoliday'][
'checked'])) {
408 if (count($typeleaves)) {
409 foreach ($typeleaves as $key => $val) {
410 $labeltype = ($langs->trans($val[
'code']) != $val[
'code']) ? $langs->trans($val[
'code']) : $langs->trans($val[
'label']);
417 if (!empty($arrayfields[
'cp.note_public'][
'checked'])) {
423 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
426 $usersupervisor =
new User($db);
428 foreach ($listUsers as $users) {
429 $arrayofselected = is_array($toselect) ? $toselect : array();
432 if (!$permissiontoreadall) {
433 if (($users[
'rowid'] != $user->id) && (!in_array($users[
'rowid'], $userchilds))) {
438 $userstatic->id = $users[
'rowid'];
439 $userstatic->lastname = $users[
'lastname'];
440 $userstatic->firstname = $users[
'firstname'];
441 $userstatic->gender = $users[
'gender'];
442 $userstatic->photo = $users[
'photo'];
443 $userstatic->status = $users[
'status'];
444 $userstatic->employee = $users[
'employee'];
445 $userstatic->fk_user = $users[
'fk_user'];
447 if ($userstatic->fk_user > 0) {
448 $usersupervisor->fetch($userstatic->fk_user);
451 print
'<tr class="oddeven">';
455 print
'<td class="nowrap center">';
457 if ($massactionbutton || $massaction) {
459 if (in_array($userstatic->id, $arrayofselected)) {
462 print
'<input id="cb'.$userstatic->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$userstatic->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
468 if (!empty($arrayfields[
'cp.rowid'][
'checked'])) {
470 print $userstatic->getNomUrl(-1);
474 if (!empty($arrayfields[
'cp.fk_user'][
'checked'])) {
476 if ($userstatic->fk_user > 0) {
477 print $usersupervisor->getNomUrl(-1);
483 if (!empty($arrayfields[
'cp.nbHoliday'][
'checked'])) {
484 if (count($typeleaves)) {
485 foreach ($typeleaves as $key => $val) {
487 if ($holiday->getCPforUser($users[
'rowid'], $val[
'rowid']) !=
'') {
488 $nbtoshow =
price2num($holiday->getCPforUser($users[
'rowid'], $val[
'rowid']), 5);
492 print
'<td style="text-align:center">';
494 print
'<input type="text"'.($canedit ?
'' :
' disabled="disabled"').
' value="'.$nbtoshow.
'" name="nb_holiday_'.$val[
'rowid'].
'['.$users[
'rowid'].
']" class="width75 center" />';
507 if (!empty($arrayfields[
'cp.note_public'][
'checked'])) {
510 print
'<input type="text"'.($canedit ?
'' :
' disabled="disabled"').
' class="maxwidthonsmartphone" value="" name="note_holiday['.$users[
'rowid'].
']" size="30"/>';
516 print
'<td class="center">';
517 if ($permissiontosetup) {
518 print
'<input type="submit" name="update_cp['.$users[
'rowid'].
']" value="'.
dol_escape_htmltag($langs->trans(
"Save")).
'" class="button smallpaddingimp"/>';
524 print
'<td class="nowrap center">';
526 if ($massactionbutton || $massaction) {
528 if (in_array($userstatic->id, $arrayofselected)) {
531 print
'<input id="cb'.$userstatic->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$userstatic->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
541 if (count($listUsers) <= 0) {
543 foreach ($arrayfields as $key => $val) {
544 if (!empty($val[
'checked'])) {
545 if ($key ==
'cp.nbHoliday') {
546 foreach ($typeleaves as $leave_key => $leave_val) {
554 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($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.
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.
getDolGlobalString($key, $default='')
Return a 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.