28 require
'../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.
'/holiday/class/holiday.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
36 $langs->loadLangs(array(
'holiday',
'hrm'));
42 if ($user->socid > 0) {
48 $action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
49 $massaction =
GETPOST(
'massaction',
'alpha');
50 $contextpage =
GETPOST(
'contextpage',
'aZ');
51 $optioncss =
GETPOST(
'optioncss',
'aZ');
53 $search_ref =
GETPOST(
'search_ref',
'alphanohtml');
54 $search_employee =
GETPOST(
'search_employee',
'int');
55 $search_type =
GETPOST(
'search_type',
'int');
56 $search_description =
GETPOST(
'search_description',
'alphanohtml');
58 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
59 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
60 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
63 $sortfield =
"cp.rowid";
70 if (empty($page) || $page == -1) {
74 $hookmanager->initHooks(array(
'leavemovementlist'));
76 $arrayfields = array();
77 $arrayofmassactions = array();
83 if (
GETPOST(
'cancel',
'alpha')) {
84 $action =
'list'; $massaction =
'';
86 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
90 $parameters = array();
91 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
96 if (empty($reshook)) {
98 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
101 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
103 $search_employee =
'';
105 $search_description =
'';
107 $search_array_options = array();
110 if (
GETPOST(
'button_removefilter_x',
'alpha')
111 ||
GETPOST(
'button_removefilter.x',
'alpha')
112 ||
GETPOST(
'button_removefilter',
'alpha')
113 ||
GETPOST(
'button_search_x',
'alpha')
114 ||
GETPOST(
'button_search.x',
'alpha')
115 ||
GETPOST(
'button_search',
'alpha')) {
120 $arrayfields = array(
121 'cp.ref'=>array(
'label' =>
'Ref',
'checked'=>1),
122 'cp.fk_user'=>array(
'label' =>
'Employee',
'checked'=>1),
123 'cp.fk_type'=>array(
'label' =>
'Type',
'checked'=>1),
124 'cp.date_debut'=>array(
'label' =>
'DateDebCP',
'checked'=>1),
125 'cp.date_fin'=>array(
'label' =>
'DateFinCP',
'checked'=>1),
126 'used_days'=>array(
'label' =>
'NbUseDaysCPShort',
'checked'=>1),
127 'date_start_month'=>array(
'label' =>
'DateStartInMonth',
'checked'=>1),
128 'date_end_month'=>array(
'label' =>
'DateEndInMonth',
'checked'=>1),
129 'used_days_month'=>array(
'label' =>
'NbUseDaysCPShortInMonth',
'checked'=>1),
130 'cp.description'=>array(
'label' =>
'DescCP',
'checked'=>1),
140 $holidaystatic =
new Holiday($db);
142 $listhalfday = array(
'morning'=>$langs->trans(
"Morning"),
"afternoon"=>$langs->trans(
"Afternoon"));
144 $title = $langs->trans(
'CPTitreMenu');
148 $search_month =
GETPOST(
"remonth",
'int') ?
GETPOST(
"remonth",
'int') : date(
"m", time());
149 $search_year =
GETPOST(
"reyear",
'int') ?
GETPOST(
"reyear",
'int') : date(
"Y", time());
150 $year_month = sprintf(
"%04d", $search_year).
'-'.sprintf(
"%02d", $search_month);
152 $sql =
"SELECT cp.rowid, cp.ref, cp.fk_user, cp.date_debut, cp.date_fin, cp.fk_type, cp.description, cp.halfday";
153 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday cp";
154 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user u ON cp.fk_user = u.rowid";
155 $sql .=
" WHERE cp.rowid > 0";
156 $sql .=
" AND cp.statut = ".Holiday::STATUS_APPROVED;
158 $sql .=
" (date_format(cp.date_debut, '%Y-%m') = '".$db->escape($year_month).
"' OR date_format(cp.date_fin, '%Y-%m') = '".$db->escape($year_month).
"')";
160 $sql .=
" (date_format(cp.date_debut, '%Y-%m') < '".$db->escape($year_month).
"' AND date_format(cp.date_fin, '%Y-%m') > '".$db->escape($year_month).
"') ";
162 if (!empty($search_ref)) {
165 if (!empty($search_employee) && $search_employee > 0) {
166 $sql .=
" AND cp.fk_user = ".((int) $search_employee);
168 if (!empty($search_type) && $search_type !=
'-1') {
169 $sql .=
' AND cp.fk_type IN ('.$db->sanitize($search_type).
')';
171 if (!empty($search_description)) {
175 $sql .= $db->order($sortfield, $sortorder);
177 $resql = $db->query($sql);
183 $num = $db->num_rows(
$resql);
186 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
187 $param .=
'&contextpage='.urlencode($contextpage);
189 if ($limit > 0 && $limit != $conf->liste_limit) {
190 $param .=
'&limit='.urlencode($limit);
192 if (!empty($search_ref)) {
193 $param .=
'&search_ref='.urlencode($search_ref);
195 if (!empty($search_employee)) {
196 $param .=
'&search_employee='.urlencode($search_employee);
198 if (!empty($search_type)) {
199 $param .=
'&search_type='.urlencode($search_type);
201 if (!empty($search_description)) {
202 $param .=
'&search_description='.urlencode($search_description);
205 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
206 if ($optioncss !=
'') {
207 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
209 print
'<input type="hidden" name="token" value="'.newToken().
'">';
210 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
211 print
'<input type="hidden" name="action" value="list">';
212 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
213 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
214 print
'<input type="hidden" name="page" value="'.$page.
'">';
215 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
220 print
'<div class="tabBar">';
221 print $formother->select_month($search_month,
'remonth', 0, 0,
'minwidth50 maxwidth75imp valignmiddle',
true);
222 print $formother->selectyear($search_year,
'reyear', 0, 10, 5, 0, 0,
'',
'valignmiddle width75',
true);
223 print
'<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans(
"Search")).
'" />';
229 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
230 $selectedfields =
'';
231 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
232 $selectedfields .= (count($arrayofmassactions) ?
$form->showCheckAddButtons(
'checkforselect', 1) :
'');
234 print
'<div class="div-table-responsive">';
235 print
'<table class="noborder centpercent">';
237 print
'<tr class="liste_titre">';
240 if (!empty($arrayfields[
'cp.ref'][
'checked'])) {
241 print
'<td class="liste_titre">';
242 print
'<input class="flat maxwidth100" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
247 if (!empty($arrayfields[
'cp.fk_user'][
'checked'])) {
248 print
'<td class="liste_titre">';
249 print
$form->select_dolusers($search_employee,
"search_employee", 1,
null, 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth100');
254 if (!empty($arrayfields[
'cp.fk_type'][
'checked'])) {
255 $typeleaves = $holidaystatic->getTypes(1, -1);
256 $arraytypeleaves = array();
257 foreach ($typeleaves as $key => $val) {
258 $labeltoshow = ($langs->trans($val[
'code']) != $val[
'code'] ? $langs->trans($val[
'code']) : $val[
'label']);
259 $arraytypeleaves[$val[
'rowid']] = $labeltoshow;
262 print
'<td class="liste_titre">';
263 print
$form->selectarray(
'search_type', $arraytypeleaves, $search_type, 1, 0, 0,
'', 0, 0, 0,
'',
'', 1);
267 if (!empty($arrayfields[
'cp.date_debut'][
'checked'])) {
268 print
'<td class="liste_titre"></td>';
270 if (!empty($arrayfields[
'cp.date_fin'][
'checked'])) {
271 print
'<td class="liste_titre"></td>';
273 if (!empty($arrayfields[
'used_days'][
'checked'])) {
274 print
'<td class="liste_titre"></td>';
276 if (!empty($arrayfields[
'date_start_month'][
'checked'])) {
277 print
'<td class="liste_titre"></td>';
279 if (!empty($arrayfields[
'date_end_month'][
'checked'])) {
280 print
'<td class="liste_titre"></td>';
282 if (!empty($arrayfields[
'used_days_month'][
'checked'])) {
283 print
'<td class="liste_titre"></td>';
287 if (!empty($arrayfields[
'cp.description'][
'checked'])) {
288 print
'<td class="liste_titre">';
289 print
'<input type="text" class="maxwidth100" name="search_description" value="'.$search_description.
'">';
294 print
'<td class="liste_titre maxwidthsearch">';
295 $searchpicto =
$form->showFilterButtons();
300 print
'<tr class="liste_titre">';
301 if (!empty($arrayfields[
'cp.ref'][
'checked'])) {
302 print_liste_field_titre($arrayfields[
'cp.ref'][
'label'], $_SERVER[
"PHP_SELF"],
'cp.ref',
'',
'',
'', $sortfield, $sortorder);
304 if (!empty($arrayfields[
'cp.fk_user'][
'checked'])) {
305 print_liste_field_titre($arrayfields[
'cp.fk_user'][
'label'], $_SERVER[
"PHP_SELF"],
'cp.fk_user',
'',
'',
'', $sortfield, $sortorder);
307 if (!empty($arrayfields[
'cp.fk_type'][
'checked'])) {
308 print_liste_field_titre($arrayfields[
'cp.fk_type'][
'label'], $_SERVER[
"PHP_SELF"],
'cp.fk_type',
'',
'',
'', $sortfield, $sortorder);
310 if (!empty($arrayfields[
'ct.label'][
'checked'])) {
311 print_liste_field_titre($arrayfields[
'ct.label'][
'label'], $_SERVER[
"PHP_SELF"],
'ct.label',
'',
'',
'', $sortfield, $sortorder);
313 if (!empty($arrayfields[
'cp.date_debut'][
'checked'])) {
314 print_liste_field_titre($arrayfields[
'cp.date_debut'][
'label'], $_SERVER[
"PHP_SELF"],
'cp.date_debut',
'',
'',
'', $sortfield, $sortorder,
'center ');
316 if (!empty($arrayfields[
'cp.date_fin'][
'checked'])) {
317 print_liste_field_titre($arrayfields[
'cp.date_fin'][
'label'], $_SERVER[
"PHP_SELF"],
'cp.date_fin',
'',
'',
'', $sortfield, $sortorder,
'center ');
319 if (!empty($arrayfields[
'used_days'][
'checked'])) {
320 print_liste_field_titre($arrayfields[
'used_days'][
'label'], $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'maxwidth125 right ');
322 if (!empty($arrayfields[
'date_start_month'][
'checked'])) {
323 print_liste_field_titre($arrayfields[
'date_start_month'][
'label'], $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center ');
325 if (!empty($arrayfields[
'date_end_month'][
'checked'])) {
326 print_liste_field_titre($arrayfields[
'date_end_month'][
'label'], $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center ');
328 if (!empty($arrayfields[
'used_days_month'][
'checked'])) {
329 print_liste_field_titre($arrayfields[
'used_days_month'][
'label'], $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'maxwidth125 right ');
331 if (!empty($arrayfields[
'cp.description'][
'checked'])) {
332 print_liste_field_titre($arrayfields[
'cp.description'][
'label'], $_SERVER[
"PHP_SELF"],
'cp.description',
'',
'',
'', $sortfield, $sortorder);
334 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
338 print
'<tr><td colspan="11" class="opacitymedium">'.$langs->trans(
'None').
'</td></tr>';
340 while ($obj = $db->fetch_object(
$resql)) {
341 $user =
new User($db);
342 $user->fetch($obj->fk_user);
344 $date_start = $db->jdate($obj->date_debut,
true);
345 $date_end = $db->jdate($obj->date_fin,
true);
350 $starthalfday = ($obj->halfday == -1 || $obj->halfday == 2) ?
'afternoon' :
'morning';
351 $endhalfday = ($obj->halfday == 1 || $obj->halfday == 2) ?
'morning' :
'afternoon';
353 $halfdayinmonth = $obj->halfday;
354 $starthalfdayinmonth = $starthalfday;
355 $endhalfdayinmonth = $endhalfday;
360 $date_start_inmonth = $db->jdate($obj->date_debut,
true);
361 $date_end_inmonth = $db->jdate($obj->date_fin,
true);
362 if ($tmpstart[
'year'] < $search_year || $tmpstart[
'mon'] < $search_month) {
364 $starthalfdayinmonth =
'morning';
365 if ($halfdayinmonth == 2) {
368 if ($halfdayinmonth == -1) {
372 if ($tmpend[
'year'] > $search_year || $tmpend[
'mon'] > $search_month) {
373 $date_end_inmonth =
dol_get_last_day($search_year, $search_month,
true) - ((24 * 3600) - 1);
374 $endhalfdayinmonth =
'afternoon';
375 if ($halfdayinmonth == 2) {
376 $halfdayinmonth = -1;
378 if ($halfdayinmonth == 1) {
384 $holidaystatic->id = $obj->rowid;
385 $holidaystatic->ref = $obj->ref;
387 print
'<tr class="oddeven">';
389 if (!empty($arrayfields[
'cp.ref'][
'checked'])) {
390 print
'<td class="nowraponall">'.$holidaystatic->getNomUrl(1, 1).
'</td>';
392 if (!empty($arrayfields[
'cp.fk_user'][
'checked'])) {
393 print
'<td>'.$user->getFullName($langs).
'</td>';
395 if (!empty($arrayfields[
'cp.fk_type'][
'checked'])) {
396 print
'<td>'.$arraytypeleaves[$obj->fk_type].
'</td>';
399 if (!empty($arrayfields[
'cp.date_debut'][
'checked'])) {
400 print
'<td class="center">'.dol_print_date($db->jdate($obj->date_debut),
'day');
401 print
' <span class="opacitymedium">('.$langs->trans($listhalfday[$starthalfday]).
')</span>';
405 if (!empty($arrayfields[
'cp.date_fin'][
'checked'])) {
406 print
'<td class="center">'.dol_print_date($db->jdate($obj->date_fin),
'day');
407 print
' <span class="opacitymedium">('.$langs->trans($listhalfday[$endhalfday]).
')</span>';
411 if (!empty($arrayfields[
'used_days'][
'checked'])) {
412 print
'<td class="right">'.num_open_day($date_start, $date_end, 0, 1, $obj->halfday).
'</td>';
415 if (!empty($arrayfields[
'date_start_month'][
'checked'])) {
416 print
'<td class="center">'.dol_print_date($date_start_inmonth,
'day');
417 print
' <span class="opacitymedium">('.$langs->trans($listhalfday[$starthalfdayinmonth]).
')</span>';
421 if (!empty($arrayfields[
'date_end_month'][
'checked'])) {
422 print
'<td class="center">'.dol_print_date($date_end_inmonth,
'day');
423 print
' <span class="opacitymedium">('.$langs->trans($listhalfday[$endhalfdayinmonth]).
')</span>';
427 if (!empty($arrayfields[
'used_days_month'][
'checked'])) {
428 print
'<td class="right">'.num_open_day($date_start_inmonth, $date_end_inmonth, 0, 1, $halfdayinmonth).
'</td>';
430 if (!empty($arrayfields[
'cp.description'][
'checked'])) {
431 print
'<td class="maxwidth300 small">'.dolGetFirstLineOfText(
dol_string_nohtmltag($obj->description, 1)).
'</td>';
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(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.