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');
41 $mode =
GETPOST(
'optioncss',
'aZ');
43 $search_name =
GETPOST(
'search_name',
'alpha');
44 $search_supervisor =
GETPOST(
'search_supervisor',
'int');
47 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
48 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
49 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
50 $toselect =
GETPOST(
'toselect',
'array');
51 $confirm =
GETPOST(
'confirm',
'alpha');
54 if (empty($page) || $page == -1) {
57 $offset = $limit * $page;
58 $pageprev = $page - 1;
59 $pagenext = $page + 1;
61 $sortfield =
"t.rowid";
69 $hookmanager->initHooks(array(
'defineholidaylist'));
75 if (empty($conf->holiday->enabled)) {
80 if ($user->socid > 0) {
85 if (empty($user->rights->holiday->read)) {
90 'cp.rowid'=>array(
'label'=>$langs->trans(
"Employee"),
'checked'=>1,
'position'=>20),
91 'cp.fk_user'=>array(
'label'=>$langs->trans(
"Supervisor"),
'checked'=>1,
'position'=>30),
92 'cp.nbHoliday'=>array(
'label'=>$langs->trans(
"MenuConfCP"),
'checked'=>1,
'position'=>40),
93 'cp.note_public'=>array(
'label'=>$langs->trans(
"Note"),
'checked'=>1,
'position'=>50),
101 if (
GETPOST(
'cancel',
'alpha')) {
102 $action =
'list'; $massaction =
'';
104 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
108 $parameters = array();
109 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
114 if (empty($reshook)) {
116 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
119 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
121 $search_supervisor =
'';
123 $search_array_options = array();
127 $objectclass =
'Holiday';
128 $objectlabel =
'Holiday';
129 $permissiontoread = $user->hasRight(
'holiday',
'read');
130 $permissiontodelete = $user->hasRight(
'holiday',
'delete');
131 $permissiontoapprove = $user->hasRight(
'holiday',
'approve');
132 $uploaddir = $conf->holiday->dir_output;
133 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
140 $typeleaves = $holiday->getTypes(1, 1);
142 $userID = array_keys(
GETPOST(
'update_cp'));
143 $userID = $userID[0];
147 foreach ($typeleaves as $key => $val) {
148 $userValue =
GETPOST(
'nb_holiday_'.$val[
'rowid']);
149 $userValue = $userValue[$userID];
151 if (!empty($userValue) || (
string) $userValue ==
'0') {
158 $note_holiday =
GETPOST(
'note_holiday');
159 $comment = ((isset($note_holiday[$userID]) && !empty($note_holiday[$userID])) ?
' ('.$note_holiday[$userID].
')' :
'');
162 if ($userValue !=
'') {
164 $result = $holiday->addLogCP($user->id, $userID, $langs->transnoentitiesnoconv(
'ManualUpdate').$comment, $userValue, $val[
'rowid']);
174 $result = $holiday->updateSoldeCP($userID, $userValue, $val[
'rowid']);
193 if (!$error && !$nbok) {
194 setEventMessages($langs->trans(
"HolidayQtyNotModified", $user->login),
null,
'warnings');
215 $userstatic =
new User($db);
218 $title = $langs->trans(
'CPTitreMenu');
222 $typeleaves = $holiday->getTypes(1, 1);
223 $result = $holiday->updateBalance();
229 $arrayofmassactions = array(
234 if ($user->hasRight(
"holiday",
"approve")) {
235 $arrayofmassactions[
'preincreaseholiday'] =
img_picto(
'',
'add',
'class="pictofixedwidth"').$langs->trans(
"IncreaseHolidays");
237 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
240 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
241 if ($optioncss !=
'') {
242 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
244 print
'<input type="hidden" name="token" value="'.newToken().
'">';
245 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
246 print
'<input type="hidden" name="action" value="update">';
247 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
248 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
249 print
'<input type="hidden" name="page" value="'.$page.
'">';
250 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
252 $title = $langs->trans(
"MenuConfCP");
253 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"],
'', $sortfield, $sortorder, $massactionbutton,
'',
'',
'title_hrm', 0,
'',
'', $limit, 0, 0, 1);
255 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
257 if ($massaction ==
'preincreaseholiday') {
258 $langs->load(
"holiday",
"hrm");
259 require_once DOL_DOCUMENT_ROOT.
'/holiday/class/holiday.class.php';
260 $staticholiday =
new Holiday($db);
261 $arraytypeholidays = $staticholiday->getTypes(1, 1);
262 $formquestion[] = array();
263 $labeltypes = array();
264 foreach ($typeleaves as $key => $val) {
265 $labeltypes[$val[
'id']] = ($langs->trans($val[
'code']) != $val[
'code']) ? $langs->trans($val[
'code']) : $langs->trans($val[
'label']);
267 $formquestion [] = array(
'type' =>
'other',
268 'name' =>
'typeofholiday',
269 'label' => $langs->trans(
"Type"),
270 'value' =>
$form->selectarray(
'typeholiday', $labeltypes,
GETPOST(
'typeholiday',
'alpha'), 1)
272 $formquestion [] = array(
'type' =>
'other',
273 'name' =>
'nbdaysholydays',
274 'label' => $langs->trans(
"NumberDayAddMass"),
275 'value' =>
'<input name="nbdaysholidays" class="maxwidth75" id="nbdaysholidays" value="'.GETPOST(
'nbdaysholidays',
'int').
'">'
277 print
$form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"ConfirmMassIncreaseHoliday"), $langs->trans(
"ConfirmMassIncreaseHolidayQuestion", count($toselect)),
"increaseholiday", $formquestion, 1, 0, 200, 500, 1);
280 print
'<div class="info">'.$langs->trans(
'LastUpdateCP').
': '.
"\n";
281 $lastUpdate = $holiday->getConfCP(
'lastUpdate');
283 print
'<strong>'.dol_print_date($db->jdate($lastUpdate),
'dayhour').
'</strong>';
284 print
'<br>'.$langs->trans(
"MonthOfLastMonthlyUpdate").
': <strong>'.$langs->trans(
'Month'.substr($lastUpdate, 4, 2)).
' '.substr($lastUpdate, 0, 4).
'</strong>'.
"\n";
286 print $langs->trans(
'None');
288 print
"</div><br>\n";
294 $userchilds = array();
295 if (empty($user->rights->holiday->readall)) {
296 $userchilds = $user->getAllChildIds(1);
297 $filters .=
' AND u.rowid IN ('.$db->sanitize(join(
', ', $userchilds)).
')';
299 if (!empty($search_name)) {
300 $filters .=
natural_search(array(
'u.firstname',
'u.lastname'), $search_name);
302 if ($search_supervisor > 0) {
303 $filters .=
natural_search(array(
'u.fk_user'), $search_supervisor, 2);
305 $filters .=
' AND employee = 1';
307 $listUsers = $holiday->fetchUsers(
false,
true, $filters);
308 if (is_numeric($listUsers) && $listUsers < 0) {
316 if (count($typeleaves) == 0) {
318 print $langs->trans(
"NoLeaveWithCounterDefined").
"<br>\n";
319 print $langs->trans(
"GoIntoDictionaryHolidayTypes");
323 if (!empty($user->rights->holiday->define_holiday)) {
329 $selectedfields =
'';
330 if ($massactionbutton) {
331 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
332 $selectedfields .= ($mode !=
'kanban' ?
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN',
'')) :
'');
333 $selectedfields .=
$form->showCheckAddButtons(
'checkforselect', 1);
336 print
'<div class="div-table-responsive">';
337 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'" id="tablelines3">'.
"\n";
339 print
'<tr class="liste_titre_filter">';
343 print
'<td class="liste_titre maxwidthsearch center">';
344 $searchpicto =
$form->showFilterButtons();
350 if (!empty($arrayfields[
'cp.rowid'][
'checked'])) {
351 print
'<td class="liste_titre">';
352 print
'<input type="text" name="search_name" value="'.dol_escape_htmltag($search_name).
'" class="maxwidth100">';
356 if (!empty($arrayfields[
'cp.fk_user'][
'checked'])) {
357 print
'<td class="liste_titre">';
358 print
$form->select_dolusers($search_supervisor,
'search_supervisor', 1,
null, 0,
null,
null, 0, 0, 0,
'', 0,
'',
'maxwidth150');
362 if (!empty($arrayfields[
'cp.nbHoliday'][
'checked'])) {
363 if (count($typeleaves)) {
364 foreach ($typeleaves as $key => $val) {
365 print
'<td class="liste_titre" style="text-align:center"></td>';
368 print
'<td class="liste_titre"></td>';
371 if (!empty($arrayfields[
'cp.note_public'][
'checked'])) {
372 print
'<td class="liste_titre"></td>';
374 print
'<td class="liste_titre"></td>';
378 print
'<td class="liste_titre maxwidthsearch center">';
379 $searchpicto =
$form->showFilterButtons();
386 print
'<tr class="liste_titre">';
389 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
391 if (!empty($arrayfields[
'cp.rowid'][
'checked'])) {
394 if (!empty($arrayfields[
'cp.fk_user'][
'checked'])) {
397 if (!empty($arrayfields[
'cp.nbHoliday'][
'checked'])) {
398 if (count($typeleaves)) {
399 foreach ($typeleaves as $key => $val) {
400 $labeltype = ($langs->trans($val[
'code']) != $val[
'code']) ? $langs->trans($val[
'code']) : $langs->trans($val[
'label']);
407 if (!empty($arrayfields[
'cp.note_public'][
'checked'])) {
413 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
416 $usersupervisor =
new User($db);
418 foreach ($listUsers as $users) {
419 $arrayofselected = is_array($toselect) ? $toselect : array();
422 if (empty($user->rights->holiday->readall)) {
423 if (($users[
'rowid'] != $user->id) && (!in_array($users[
'rowid'], $userchilds))) {
428 $userstatic->id = $users[
'rowid'];
429 $userstatic->lastname = $users[
'lastname'];
430 $userstatic->firstname = $users[
'firstname'];
431 $userstatic->gender = $users[
'gender'];
432 $userstatic->photo = $users[
'photo'];
433 $userstatic->statut = $users[
'status'];
434 $userstatic->employee = $users[
'employee'];
435 $userstatic->fk_user = $users[
'fk_user'];
437 if ($userstatic->fk_user > 0) {
438 $usersupervisor->fetch($userstatic->fk_user);
441 print
'<tr class="oddeven">';
445 print
'<td class="nowrap center">';
447 if ($massactionbutton || $massaction) {
449 if (in_array($userstatic->id, $arrayofselected)) {
452 print
'<input id="cb'.$userstatic->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$userstatic->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
458 if (!empty($arrayfields[
'cp.rowid'][
'checked'])) {
460 print $userstatic->getNomUrl(-1);
464 if (!empty($arrayfields[
'cp.fk_user'][
'checked'])) {
466 if ($userstatic->fk_user > 0) {
467 print $usersupervisor->getNomUrl(-1);
473 if (!empty($arrayfields[
'cp.nbHoliday'][
'checked'])) {
474 if (count($typeleaves)) {
475 foreach ($typeleaves as $key => $val) {
477 if ($holiday->getCPforUser($users[
'rowid'], $val[
'rowid']) !=
'') {
478 $nbtoshow =
price2num($holiday->getCPforUser($users[
'rowid'], $val[
'rowid']), 5);
482 print
'<td style="text-align:center">';
484 print
'<input type="text"'.($canedit ?
'' :
' disabled="disabled"').
' value="'.$nbtoshow.
'" name="nb_holiday_'.$val[
'rowid'].
'['.$users[
'rowid'].
']" class="width75 center" />';
497 if (!empty($arrayfields[
'cp.note_public'][
'checked'])) {
500 print
'<input type="text"'.($canedit ?
'' :
' disabled="disabled"').
' class="maxwidthonsmartphone" value="" name="note_holiday['.$users[
'rowid'].
']" size="30"/>';
506 print
'<td class="center">';
507 if (!empty($user->rights->holiday->define_holiday)) {
508 print
'<input type="submit" name="update_cp['.$users[
'rowid'].
']" value="'.
dol_escape_htmltag($langs->trans(
"Save")).
'" class="button smallpaddingimp"/>';
514 print
'<td class="nowrap center">';
516 if ($massactionbutton || $massaction) {
518 if (in_array($userstatic->id, $arrayofselected)) {
521 print
'<input id="cb'.$userstatic->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$userstatic->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
531 if (count($listUsers) <= 0) {
533 foreach ($arrayfields as $key => $val) {
534 if (!empty($val[
'checked'])) {
535 if ($key ==
'cp.nbHoliday') {
536 foreach ($typeleaves as $key => $val) {
544 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
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.
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.
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.
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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.