29 require
'../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/holiday/class/holiday.class.php';
34 $langs->loadlangs(array(
'users',
'other',
'holiday',
'hrm'));
36 $action =
GETPOST(
'action',
'aZ09');
37 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'defineholidaylist';
39 $search_name =
GETPOST(
'search_name',
'alpha');
40 $search_supervisor =
GETPOST(
'search_supervisor',
'int');
43 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
44 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
45 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
47 if (empty($page) || $page == -1) { $page = 0; }
48 $offset = $limit * $page;
49 $pageprev = $page - 1;
50 $pagenext = $page + 1;
51 if (!$sortfield) $sortfield =
"t.rowid";
52 if (!$sortorder) $sortorder =
"ASC";
63 $hookmanager->initHooks(array(
'defineholidaylist'));
68 if (empty($conf->holiday->enabled))
70 llxHeader(
'', $langs->trans(
'CPTitreMenu'));
71 print '<div class="tabBar">';
72 print
'<span style="color: #FF0000;">'.$langs->trans(
'NotActiveModCP').
'</span>';
84 if (
GETPOST(
'cancel',
'alpha')) { $action =
'list'; $massaction =
''; }
85 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') { $massaction =
''; }
87 $parameters = array();
88 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
89 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
94 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
97 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha'))
100 $search_supervisor =
'';
102 $search_array_options = array();
116 if ($action ==
'update' && isset($_POST[
'update_cp']))
120 $typeleaves = $holiday->getTypes(1, 1);
122 $userID = array_keys($_POST[
'update_cp']);
123 $userID = $userID[0];
125 foreach ($typeleaves as $key => $val)
127 $userValue = $_POST[
'nb_holiday_'.$val[
'rowid']];
128 $userValue = $userValue[$userID];
130 if (!empty($userValue) || (
string) $userValue ==
'0')
138 $comment = ((isset($_POST[
'note_holiday'][$userID]) && !empty($_POST[
'note_holiday'][$userID])) ?
' ('.$_POST[
'note_holiday'][$userID].
')' :
'');
141 if ($userValue !=
'')
144 $result = $holiday->addLogCP($user->id, $userID, $langs->transnoentitiesnoconv(
'ManualUpdate').$comment, $userValue, $val[
'rowid']);
152 $result = $holiday->updateSoldeCP($userID, $userValue, $val[
'rowid']);
180 $form =
new Form($db);
181 $userstatic =
new User($db);
183 llxHeader(
'', $langs->trans(
'CPTitreMenu'));
186 $typeleaves = $holiday->getTypes(1, 1);
187 $result = $holiday->updateBalance();
193 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
194 if ($optioncss !=
'') print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
195 print
'<input type="hidden" name="token" value="'.newToken().
'">';
196 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
197 print
'<input type="hidden" name="action" value="update">';
198 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
199 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
200 print
'<input type="hidden" name="page" value="'.$page.
'">';
201 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
205 print
'<div class="info">'.$langs->trans(
'LastUpdateCP').
': '.
"\n";
206 $lastUpdate = $holiday->getConfCP(
'lastUpdate');
208 print
'<strong>'.dol_print_date($db->jdate($lastUpdate),
'dayhour').
'</strong>';
209 print
'<br>'.$langs->trans(
"MonthOfLastMonthlyUpdate").
': <strong>'.$langs->trans(
'Month'.substr($lastUpdate, 4, 2)).
' '.substr($lastUpdate, 0, 4).
'</strong>'.
"\n";
211 print $langs->trans(
'None');
213 print
"</div><br>\n";
219 $userchilds = array();
220 if (empty($user->rights->holiday->readall))
222 $userchilds = $user->getAllChildIds(1);
223 $filters .=
' AND u.rowid IN ('.join(
', ', $userchilds).
')';
225 if (!empty($search_name)) {
226 $filters .=
natural_search(array(
'u.firstname',
'u.lastname'), $search_name);
228 if ($search_supervisor > 0) $filters .=
natural_search(array(
'u.fk_user'), $search_supervisor, 2);
229 $filters .=
' AND employee = 1';
231 $listUsers = $holiday->fetchUsers(
false,
true, $filters);
232 if (is_numeric($listUsers) && $listUsers < 0)
240 if (count($typeleaves) == 0)
243 print $langs->trans(
"NoLeaveWithCounterDefined").
"<br>\n";
244 print $langs->trans(
"GoIntoDictionaryHolidayTypes");
248 if (!empty($user->rights->holiday->define_holiday)) $canedit = 1;
252 print
'<div class="div-table-responsive">';
253 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'" id="tablelines3">'.
"\n";
255 print
'<tr class="liste_titre_filter">';
258 print
'<td class="liste_titre"><input type="text" name="search_name" value="'.dol_escape_htmltag($search_name).
'"></td>';
261 print
'<td class="liste_titre">';
262 print $form->select_dolusers($search_supervisor,
'search_supervisor', 1, null, 0, null, null, 0, 0, 0,
'', 0,
'',
'maxwidth200');
266 if (count($typeleaves))
268 foreach ($typeleaves as $key => $val)
270 print
'<td class="liste_titre" style="text-align:center"></td>';
273 print
'<td class="liste_titre"></td>';
275 print
'<td class="liste_titre"></td>';
278 print
'<td class="liste_titre maxwidthsearch center">';
279 $searchpicto = $form->showFilterButtons();
285 print
'<tr class="liste_titre">';
288 if (count($typeleaves))
290 foreach ($typeleaves as $key => $val)
292 $labeltype = ($langs->trans($val[
'code']) != $val[
'code']) ? $langs->trans($val[
'code']) : $langs->trans($val[
'label']);
302 $usersupervisor =
new User($db);
304 foreach ($listUsers as $users)
307 if (empty($user->rights->holiday->readall))
309 if (($users[
'rowid'] != $user->id) && (!in_array($users[
'rowid'], $userchilds)))
continue;
312 $userstatic->id = $users[
'rowid'];
313 $userstatic->lastname = $users[
'lastname'];
314 $userstatic->firstname = $users[
'firstname'];
315 $userstatic->gender = $users[
'gender'];
316 $userstatic->photo = $users[
'photo'];
317 $userstatic->statut = $users[
'status'];
318 $userstatic->employee = $users[
'employee'];
319 $userstatic->fk_user = $users[
'fk_user'];
321 if ($userstatic->fk_user > 0) $usersupervisor->fetch($userstatic->fk_user);
323 print
'<tr class="oddeven">';
327 print $userstatic->getNomUrl(-1);
332 if ($userstatic->fk_user > 0) print $usersupervisor->getNomUrl(-1);
336 if (count($typeleaves))
338 foreach ($typeleaves as $key => $val)
341 if ($holiday->getCPforUser($users[
'rowid'], $val[
'rowid']) !=
'') $nbtoshow =
price2num($holiday->getCPforUser($users[
'rowid'], $val[
'rowid']), 5);
344 print
'<td style="text-align:center">';
345 if ($canedit) print
'<input type="text"'.($canedit ?
'' :
' disabled="disabled"').
' value="'.$nbtoshow.
'" name="nb_holiday_'.$val[
'rowid'].
'['.$users[
'rowid'].
']" size="5" style="text-align: center;"/>';
346 else print $nbtoshow;
356 if ($canedit) print
'<input type="text"'.($canedit ?
'' :
' disabled="disabled"').
' class="maxwidthonsmartphone" value="" name="note_holiday['.$users[
'rowid'].
']" size="30"/>';
361 if (!empty($user->rights->holiday->define_holiday))
363 print
'<input type="submit" name="update_cp['.$users[
'rowid'].
']" value="'.
dol_escape_htmltag($langs->trans(
"Save")).
'" class="button smallpaddingimp"/>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class of the module paid holiday.
Class to manage Dolibarr users.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
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 $_SERVER["PHP_SELF"]
Edit parameters.
print
Draft customers invoices.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...