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');
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');
53$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
54if (empty($page) || $page == -1) {
57$offset = $limit * $page;
61 $sortfield =
"t.rowid";
69$hookmanager->initHooks(array(
'defineholidaylist'));
75if (empty($conf->holiday->enabled)) {
80if ($user->socid > 0) {
85if (!$user->hasRight(
'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),
101if (
GETPOST(
'cancel',
'alpha')) {
105if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
109$parameters = array();
110$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
115if (empty($reshook)) {
117 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
120 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
122 $search_supervisor =
'';
124 $search_array_options = array();
128 $objectclass =
'Holiday';
129 $objectlabel =
'Holiday';
130 $permissiontoread = $user->hasRight(
'holiday',
'read');
131 $permissiontodelete = $user->hasRight(
'holiday',
'delete');
132 $permissiontoapprove = $user->hasRight(
'holiday',
'approve');
133 $uploaddir = $conf->holiday->dir_output;
134 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
137 if ($action ==
'update' && GETPOSTISSET(
'update_cp')) {
141 $typeleaves = $holiday->getTypes(1, 1);
143 $userID = array_keys(
GETPOST(
'update_cp'));
144 $userID = $userID[0];
148 foreach ($typeleaves as $key => $val) {
149 $userValue =
GETPOST(
'nb_holiday_'.$val[
'rowid']);
150 $userValue = $userValue[$userID];
152 if (!empty($userValue) || (
string) $userValue ==
'0') {
159 $note_holiday =
GETPOST(
'note_holiday');
160 $comment = ((isset($note_holiday[$userID]) && !empty($note_holiday[$userID])) ?
' ('.$note_holiday[$userID].
')' :
'');
163 if ($userValue !=
'') {
165 $result = $holiday->addLogCP($user->id, $userID, $langs->transnoentitiesnoconv(
'ManualUpdate').$comment, $userValue, $val[
'rowid']);
175 $result = $holiday->updateSoldeCP($userID, $userValue, $val[
'rowid']);
194 if (!$error && !$nbok) {
195 setEventMessages($langs->trans(
"HolidayQtyNotModified", $user->login),
null,
'warnings');
215$form =
new Form($db);
216$userstatic =
new User($db);
219$title = $langs->trans(
'CPTitreMenu');
223$typeleaves = $holiday->getTypes(1, 1);
224$result = $holiday->updateBalance();
230$arrayofmassactions = array(
235if ($user->hasRight(
"holiday",
"approve")) {
236 $arrayofmassactions[
'preincreaseholiday'] =
img_picto(
'',
'add',
'class="pictofixedwidth"').$langs->trans(
"IncreaseHolidays");
238$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
241print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
242if ($optioncss !=
'') {
243 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
245print
'<input type="hidden" name="token" value="'.newToken().
'">';
246print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
247print
'<input type="hidden" name="action" value="update">';
248print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
249print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
250print
'<input type="hidden" name="page" value="'.$page.
'">';
251print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
253$title = $langs->trans(
"MenuConfCP");
254print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"],
'', $sortfield, $sortorder, $massactionbutton,
'',
'',
'title_hrm', 0,
'',
'', $limit, 0, 0, 1);
256include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
258if ($massaction ==
'preincreaseholiday') {
259 $langs->load(
"holiday",
"hrm");
260 require_once DOL_DOCUMENT_ROOT.
'/holiday/class/holiday.class.php';
261 $staticholiday =
new Holiday($db);
262 $arraytypeholidays = $staticholiday->getTypes(1, 1);
263 $formquestion[] = array();
264 $labeltypes = array();
265 foreach ($typeleaves as $key => $val) {
266 $labeltypes[$val[
'id']] = ($langs->trans($val[
'code']) != $val[
'code']) ? $langs->trans($val[
'code']) : $langs->trans($val[
'label']);
268 $formquestion [] = array(
'type' =>
'other',
269 'name' =>
'typeofholiday',
270 'label' => $langs->trans(
"Type"),
271 'value' => $form->selectarray(
'typeholiday', $labeltypes,
GETPOST(
'typeholiday',
'alpha'), 1)
273 $formquestion [] = array(
'type' =>
'other',
274 'name' =>
'nbdaysholydays',
275 'label' => $langs->trans(
"NumberDayAddMass"),
276 'value' =>
'<input name="nbdaysholidays" class="maxwidth75" id="nbdaysholidays" value="'.GETPOST(
'nbdaysholidays',
'int').
'">'
278 print $form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"ConfirmMassIncreaseHoliday"), $langs->trans(
"ConfirmMassIncreaseHolidayQuestion", count($toselect)),
"increaseholiday", $formquestion, 1, 0, 200, 500, 1);
281print
'<div class="info">'.$langs->trans(
'LastUpdateCP').
': '.
"\n";
282$lastUpdate = $holiday->getConfCP(
'lastUpdate');
284 print
'<strong>'.dol_print_date($db->jdate($lastUpdate),
'dayhour').
'</strong>';
285 print
'<br>'.$langs->trans(
"MonthOfLastMonthlyUpdate").
': <strong>'.$langs->trans(
'Month'.substr($lastUpdate, 4, 2)).
' '.substr($lastUpdate, 0, 4).
'</strong>'.
"\n";
287 print $langs->trans(
'None');
295$userchilds = array();
296if (!$user->hasRight(
'holiday',
'readall')) {
297 $userchilds = $user->getAllChildIds(1);
298 $filters .=
' AND u.rowid IN ('.$db->sanitize(join(
', ', $userchilds)).
')';
300if (!empty($search_name)) {
301 $filters .=
natural_search(array(
'u.firstname',
'u.lastname'), $search_name);
303if ($search_supervisor > 0) {
304 $filters .=
natural_search(array(
'u.fk_user'), $search_supervisor, 2);
306$filters .=
' AND employee = 1';
308$listUsers = $holiday->fetchUsers(
false,
true, $filters);
309if (is_numeric($listUsers) && $listUsers < 0) {
317if (count($typeleaves) == 0) {
319 print $langs->trans(
"NoLeaveWithCounterDefined").
"<br>\n";
320 print $langs->trans(
"GoIntoDictionaryHolidayTypes");
324 if ($user->hasRight(
'holiday',
'define_holiday')) {
330 $selectedfields =
'';
331 if ($massactionbutton) {
332 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
333 $selectedfields .= ($mode !=
'kanban' ? $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN',
'')) :
'');
334 $selectedfields .= $form->showCheckAddButtons(
'checkforselect', 1);
337 print
'<div class="div-table-responsive">';
338 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'" id="tablelines3">'.
"\n";
340 print
'<tr class="liste_titre_filter">';
344 print
'<td class="liste_titre maxwidthsearch center">';
345 $searchpicto = $form->showFilterButtons();
351 if (!empty($arrayfields[
'cp.rowid'][
'checked'])) {
352 print
'<td class="liste_titre">';
353 print
'<input type="text" name="search_name" value="'.dol_escape_htmltag($search_name).
'" class="maxwidth100">';
357 if (!empty($arrayfields[
'cp.fk_user'][
'checked'])) {
358 print
'<td class="liste_titre">';
359 print $form->select_dolusers($search_supervisor,
'search_supervisor', 1,
null, 0,
null,
null, 0, 0, 0,
'', 0,
'',
'maxwidth150');
363 if (!empty($arrayfields[
'cp.nbHoliday'][
'checked'])) {
364 if (count($typeleaves)) {
365 foreach ($typeleaves as $key => $val) {
366 print
'<td class="liste_titre" style="text-align:center"></td>';
369 print
'<td class="liste_titre"></td>';
372 if (!empty($arrayfields[
'cp.note_public'][
'checked'])) {
373 print
'<td class="liste_titre"></td>';
375 print
'<td class="liste_titre"></td>';
379 print
'<td class="liste_titre maxwidthsearch center">';
380 $searchpicto = $form->showFilterButtons();
387 print
'<tr class="liste_titre">';
390 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
392 if (!empty($arrayfields[
'cp.rowid'][
'checked'])) {
395 if (!empty($arrayfields[
'cp.fk_user'][
'checked'])) {
398 if (!empty($arrayfields[
'cp.nbHoliday'][
'checked'])) {
399 if (count($typeleaves)) {
400 foreach ($typeleaves as $key => $val) {
401 $labeltype = ($langs->trans($val[
'code']) != $val[
'code']) ? $langs->trans($val[
'code']) : $langs->trans($val[
'label']);
408 if (!empty($arrayfields[
'cp.note_public'][
'checked'])) {
414 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
417 $usersupervisor =
new User($db);
419 foreach ($listUsers as $users) {
420 $arrayofselected = is_array($toselect) ? $toselect : array();
423 if (!$user->hasRight(
'holiday',
'readall')) {
424 if (($users[
'rowid'] != $user->id) && (!in_array($users[
'rowid'], $userchilds))) {
429 $userstatic->id = $users[
'rowid'];
430 $userstatic->lastname = $users[
'lastname'];
431 $userstatic->firstname = $users[
'firstname'];
432 $userstatic->gender = $users[
'gender'];
433 $userstatic->photo = $users[
'photo'];
434 $userstatic->statut = $users[
'status'];
435 $userstatic->employee = $users[
'employee'];
436 $userstatic->fk_user = $users[
'fk_user'];
438 if ($userstatic->fk_user > 0) {
439 $usersupervisor->fetch($userstatic->fk_user);
442 print
'<tr class="oddeven">';
446 print
'<td class="nowrap center">';
448 if ($massactionbutton || $massaction) {
450 if (in_array($userstatic->id, $arrayofselected)) {
453 print
'<input id="cb'.$userstatic->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$userstatic->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
459 if (!empty($arrayfields[
'cp.rowid'][
'checked'])) {
461 print $userstatic->getNomUrl(-1);
465 if (!empty($arrayfields[
'cp.fk_user'][
'checked'])) {
467 if ($userstatic->fk_user > 0) {
468 print $usersupervisor->getNomUrl(-1);
474 if (!empty($arrayfields[
'cp.nbHoliday'][
'checked'])) {
475 if (count($typeleaves)) {
476 foreach ($typeleaves as $key => $val) {
478 if ($holiday->getCPforUser($users[
'rowid'], $val[
'rowid']) !=
'') {
479 $nbtoshow =
price2num($holiday->getCPforUser($users[
'rowid'], $val[
'rowid']), 5);
483 print
'<td style="text-align:center">';
485 print
'<input type="text"'.($canedit ?
'' :
' disabled="disabled"').
' value="'.$nbtoshow.
'" name="nb_holiday_'.$val[
'rowid'].
'['.$users[
'rowid'].
']" class="width75 center" />';
498 if (!empty($arrayfields[
'cp.note_public'][
'checked'])) {
501 print
'<input type="text"'.($canedit ?
'' :
' disabled="disabled"').
' class="maxwidthonsmartphone" value="" name="note_holiday['.$users[
'rowid'].
']" size="30"/>';
507 print
'<td class="center">';
508 if ($user->hasRight(
'holiday',
'define_holiday')) {
509 print
'<input type="submit" name="update_cp['.$users[
'rowid'].
']" value="'.
dol_escape_htmltag($langs->trans(
"Save")).
'" class="button smallpaddingimp"/>';
515 print
'<td class="nowrap center">';
517 if ($massactionbutton || $massaction) {
519 if (in_array($userstatic->id, $arrayofselected)) {
522 print
'<input id="cb'.$userstatic->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$userstatic->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
532 if (count($listUsers) <= 0) {
534 foreach ($arrayfields as $key => $val) {
535 if (!empty($val[
'checked'])) {
536 if ($key ==
'cp.nbHoliday') {
537 foreach ($typeleaves as $leave_key => $leave_val) {
545 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.
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.
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.