29require
'../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/holiday/class/holiday.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
45$langs->loadLangs(array(
'holiday',
'hrm'));
47$action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
48$massaction =
GETPOST(
'massaction',
'alpha');
49$contextpage =
GETPOST(
'contextpage',
'aZ');
50$optioncss =
GETPOST(
'optioncss',
'aZ');
54$search_ref =
GETPOST(
'search_ref',
'alphanohtml');
55$search_employee =
GETPOST(
'search_employee',
"intcomma");
56$search_type =
GETPOST(
'search_type',
"intcomma");
57$search_description =
GETPOST(
'search_description',
'alphanohtml');
60$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
61$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
64 $sortfield =
"cp.rowid";
71if (empty($page) || $page == -1) {
75$hookmanager->initHooks(array(
'leavemovementlist'));
77$arrayfields = array();
78$arrayofmassactions = array();
81if ($user->socid > 0) {
87if (!$user->hasRight(
'holiday',
'readall')) {
96if (
GETPOST(
'cancel',
'alpha')) {
100if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
104$parameters = array();
105$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
110if (empty($reshook)) {
112 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
115 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
117 $search_employee =
'';
119 $search_description =
'';
121 $search_array_options = array();
124 if (
GETPOST(
'button_removefilter_x',
'alpha')
125 ||
GETPOST(
'button_removefilter.x',
'alpha')
126 ||
GETPOST(
'button_removefilter',
'alpha')
127 ||
GETPOST(
'button_search_x',
'alpha')
128 ||
GETPOST(
'button_search.x',
'alpha')
129 ||
GETPOST(
'button_search',
'alpha')) {
135 'cp.ref' => array(
'label' =>
'Ref',
'checked' => 1,
'position' => 5),
136 'cp.fk_type' => array(
'label' =>
'Type',
'checked' => 1,
'position' => 10),
137 'cp.fk_user' => array(
'label' =>
'Employee',
'checked' => 1,
'position' => 20),
138 'cp.date_debut' => array(
'label' =>
'DateDebCP',
'checked' => -1,
'position' => 30),
139 'cp.date_fin' => array(
'label' =>
'DateFinCP',
'checked' => -1,
'position' => 32),
140 'used_days' => array(
'label' =>
'NbUseDaysCPShort',
'checked' => -1,
'position' => 34),
141 'date_start_month' => array(
'label' =>
'DateStartInMonth',
'checked' => 1,
'position' => 50),
142 'date_end_month' => array(
'label' =>
'DateEndInMonth',
'checked' => 1,
'position' => 52),
143 'used_days_month' => array(
'label' =>
'NbUseDaysCPShortInMonth',
'checked' => 1,
'position' => 54),
144 'cp.description' => array(
'label' =>
'DescCP',
'checked' => -1,
'position' => 800),
152$form =
new Form($db);
154$holidaystatic =
new Holiday($db);
156$listhalfday = array(
'morning' => $langs->trans(
"Morning"),
"afternoon" => $langs->trans(
"Afternoon"));
158$title = $langs->trans(
'CPTitreMenu');
159$help_url =
'EN:Module_Holiday';
161llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-holiday page-month_report');
165$year_month = sprintf(
"%04d", $search_year).
'-'.sprintf(
"%02d", $search_month);
167$sql =
"SELECT cp.rowid, cp.ref, cp.fk_user, cp.date_debut, cp.date_fin, cp.fk_type, cp.description, cp.halfday, cp.statut as status";
168$sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday cp";
169$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user u ON cp.fk_user = u.rowid";
170$sql .=
" WHERE cp.rowid > 0";
171$sql .=
" AND cp.statut = ".Holiday::STATUS_APPROVED;
173$sql .=
" (date_format(cp.date_debut, '%Y-%m') = '".$db->escape($year_month).
"' OR date_format(cp.date_fin, '%Y-%m') = '".$db->escape($year_month).
"')";
175$sql .=
" (date_format(cp.date_debut, '%Y-%m') < '".$db->escape($year_month).
"' AND date_format(cp.date_fin, '%Y-%m') > '".$db->escape($year_month).
"') ";
177if (!empty($search_ref)) {
180if (!empty($search_employee) && $search_employee > 0) {
181 $sql .=
" AND cp.fk_user = ".((int) $search_employee);
183if (!empty($search_type) && $search_type !=
'-1') {
184 $sql .=
' AND cp.fk_type IN ('.$db->sanitize($search_type).
')';
186if (!empty($search_description)) {
190$sql .= $db->order($sortfield, $sortorder);
192$resql = $db->query($sql);
198$num = $db->num_rows($resql);
201if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
202 $param .=
'&contextpage='.urlencode($contextpage);
204if ($limit > 0 && $limit !=
$conf->liste_limit) {
205 $param .=
'&limit='.((int) $limit);
207if (!empty($search_ref)) {
208 $param .=
'&search_ref='.urlencode($search_ref);
210if (!empty($search_employee)) {
211 $param .=
'&search_employee='.urlencode($search_employee);
213if (!empty($search_type)) {
214 $param .=
'&search_type='.urlencode($search_type);
216if (!empty($search_description)) {
217 $param .=
'&search_description='.urlencode($search_description);
220print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
221if ($optioncss !=
'') {
222 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
224print
'<input type="hidden" name="token" value="'.newToken().
'">';
225print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
226print
'<input type="hidden" name="action" value="list">';
227print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
228print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
229print
'<input type="hidden" name="page" value="'.$page.
'">';
230print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
235print
'<div class="tabBar">';
236print $formother->select_month($search_month,
'remonth', 0, 0,
'minwidth50 maxwidth75imp valignmiddle',
true);
237print $formother->selectyear($search_year,
'reyear', 0, 10, 5, 0, 0,
'',
'valignmiddle width75',
true);
238print
'<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans(
"Search")).
'" />';
244$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
245$selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
246$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
248print
'<div class="div-table-responsive">';
249print
'<table class="tagtable nobottomiftotal liste">';
251print
'<tr class="liste_titre_filter">';
255 print
'<th class="wrapcolumntitle center maxwidthsearch liste_titre">';
256 $searchpicto = $form->showFilterButtons(
'left');
262if (!empty($arrayfields[
'cp.ref'][
'checked'])) {
263 print
'<th class="liste_titre">';
264 print
'<input class="flat maxwidth100" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
269if (!empty($arrayfields[
'cp.fk_type'][
'checked'])) {
270 $typeleaves = $holidaystatic->getTypes(1, -1);
271 $arraytypeleaves = array();
272 foreach ($typeleaves as $key => $val) {
273 $labeltoshow = ($langs->trans($val[
'code']) != $val[
'code'] ? $langs->trans($val[
'code']) : $val[
'label']);
274 $arraytypeleaves[$val[
'rowid']] = $labeltoshow;
277 print
'<th class="liste_titre">';
278 print $form->selectarray(
'search_type', $arraytypeleaves, $search_type, 1, 0, 0,
'', 0, 0, 0,
'',
'maxwidth100', 1);
283if (!empty($arrayfields[
'cp.fk_user'][
'checked'])) {
284 print
'<th class="liste_titre">';
285 print $form->select_dolusers($search_employee,
"search_employee", 1,
null, 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth100');
289if (!empty($arrayfields[
'cp.date_debut'][
'checked'])) {
290 print
'<th class="liste_titre"></th>';
292if (!empty($arrayfields[
'cp.date_fin'][
'checked'])) {
293 print
'<th class="liste_titre"></th>';
295if (!empty($arrayfields[
'used_days'][
'checked'])) {
296 print
'<th class="liste_titre"></th>';
298if (!empty($arrayfields[
'date_start_month'][
'checked'])) {
299 print
'<th class="liste_titre"></th>';
301if (!empty($arrayfields[
'date_end_month'][
'checked'])) {
302 print
'<th class="liste_titre"></th>';
304if (!empty($arrayfields[
'used_days_month'][
'checked'])) {
305 print
'<th class="liste_titre"></th>';
309if (!empty($arrayfields[
'cp.description'][
'checked'])) {
310 print
'<th class="liste_titre">';
311 print
'<input type="text" class="maxwidth100" name="search_description" value="'.$search_description.
'">';
316 print
'<th class="liste_titre maxwidthsearch">';
317 $searchpicto = $form->showFilterButtons();
323print
'<tr class="liste_titre">';
326 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
328if (!empty($arrayfields[
'cp.ref'][
'checked'])) {
329 print_liste_field_titre($arrayfields[
'cp.ref'][
'label'], $_SERVER[
"PHP_SELF"],
'cp.ref',
'',
'',
'', $sortfield, $sortorder);
331if (!empty($arrayfields[
'cp.fk_type'][
'checked'])) {
332 print_liste_field_titre($arrayfields[
'cp.fk_type'][
'label'], $_SERVER[
"PHP_SELF"],
'cp.fk_type',
'',
'',
'', $sortfield, $sortorder);
334if (!empty($arrayfields[
'cp.fk_user'][
'checked'])) {
335 print_liste_field_titre($arrayfields[
'cp.fk_user'][
'label'], $_SERVER[
"PHP_SELF"],
'u.lastname',
'',
'',
'', $sortfield, $sortorder);
337if (!empty($arrayfields[
'ct.label'][
'checked'])) {
338 print_liste_field_titre($arrayfields[
'ct.label'][
'label'], $_SERVER[
"PHP_SELF"],
'ct.label',
'',
'',
'', $sortfield, $sortorder);
340if (!empty($arrayfields[
'cp.date_debut'][
'checked'])) {
341 print_liste_field_titre($arrayfields[
'cp.date_debut'][
'label'], $_SERVER[
"PHP_SELF"],
'cp.date_debut',
'',
'',
'', $sortfield, $sortorder,
'center ');
343if (!empty($arrayfields[
'cp.date_fin'][
'checked'])) {
344 print_liste_field_titre($arrayfields[
'cp.date_fin'][
'label'], $_SERVER[
"PHP_SELF"],
'cp.date_fin',
'',
'',
'', $sortfield, $sortorder,
'center ');
346if (!empty($arrayfields[
'used_days'][
'checked'])) {
347 print_liste_field_titre($arrayfields[
'used_days'][
'label'], $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'maxwidth125 right ');
349if (!empty($arrayfields[
'date_start_month'][
'checked'])) {
350 print_liste_field_titre($arrayfields[
'date_start_month'][
'label'], $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center ');
352if (!empty($arrayfields[
'date_end_month'][
'checked'])) {
353 print_liste_field_titre($arrayfields[
'date_end_month'][
'label'], $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center ');
355if (!empty($arrayfields[
'used_days_month'][
'checked'])) {
356 print_liste_field_titre($arrayfields[
'used_days_month'][
'label'], $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'maxwidth125 right ');
358if (!empty($arrayfields[
'cp.description'][
'checked'])) {
359 print_liste_field_titre($arrayfields[
'cp.description'][
'label'], $_SERVER[
"PHP_SELF"],
'cp.description',
'',
'',
'', $sortfield, $sortorder);
363 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
368 print
'<tr><td colspan="11"><span class="opacitymedium">'.$langs->trans(
'None').
'</span></td></tr>';
370 $tmpuser =
new User($db);
371 while ($obj = $db->fetch_object($resql)) {
372 $tmpuser->fetch($obj->fk_user);
374 $date_start = $db->jdate($obj->date_debut,
true);
375 $date_end = $db->jdate($obj->date_fin,
true);
380 $starthalfday = ($obj->halfday == -1 || $obj->halfday == 2) ?
'afternoon' :
'morning';
381 $endhalfday = ($obj->halfday == 1 || $obj->halfday == 2) ?
'morning' :
'afternoon';
383 $halfdayinmonth = $obj->halfday;
384 $starthalfdayinmonth = $starthalfday;
385 $endhalfdayinmonth = $endhalfday;
390 $date_start_inmonth = $db->jdate($obj->date_debut,
true);
391 $date_end_inmonth = $db->jdate($obj->date_fin,
true);
392 if ($tmpstart[
'year'] < $search_year || $tmpstart[
'mon'] < $search_month) {
394 $starthalfdayinmonth =
'morning';
395 if ($halfdayinmonth == 2) {
398 if ($halfdayinmonth == -1) {
402 if ($tmpend[
'year'] > $search_year || $tmpend[
'mon'] > $search_month) {
403 $date_end_inmonth =
dol_get_last_day($search_year, $search_month,
true) - ((24 * 3600) - 1);
404 $endhalfdayinmonth =
'afternoon';
405 if ($halfdayinmonth == 2) {
406 $halfdayinmonth = -1;
408 if ($halfdayinmonth == 1) {
414 $holidaystatic->id = $obj->rowid;
415 $holidaystatic->ref = $obj->ref;
416 $holidaystatic->status = $obj->status;
417 $holidaystatic->status = $obj->status;
418 $holidaystatic->fk_user = $obj->fk_user;
419 $holidaystatic->fk_type = $obj->fk_type;
420 $holidaystatic->description = $obj->description;
421 $holidaystatic->halfday = $obj->halfday;
422 $holidaystatic->date_debut = $db->jdate($obj->date_debut);
423 $holidaystatic->date_fin = $db->jdate($obj->date_fin);
426 print
'<tr class="oddeven">';
432 if (!empty($arrayfields[
'cp.ref'][
'checked'])) {
433 print
'<td class="nowraponall">'.$holidaystatic->getNomUrl(1, 1).
'</td>';
435 if (!empty($arrayfields[
'cp.fk_type'][
'checked'])) {
436 print
'<td>'.$arraytypeleaves[$obj->fk_type].
'</td>';
438 if (!empty($arrayfields[
'cp.fk_user'][
'checked'])) {
439 print
'<td class="tdoverflowmax150">'.$tmpuser->getNomUrl(-1).
'</td>';
442 if (!empty($arrayfields[
'cp.date_debut'][
'checked'])) {
443 print
'<td class="center">'.dol_print_date($db->jdate($obj->date_debut),
'day');
444 print
' <span class="opacitymedium">('.$langs->trans($listhalfday[$starthalfday]).
')</span>';
448 if (!empty($arrayfields[
'cp.date_fin'][
'checked'])) {
449 print
'<td class="center">'.dol_print_date($db->jdate($obj->date_fin),
'day');
450 print
' <span class="opacitymedium">('.$langs->trans($listhalfday[$endhalfday]).
')</span>';
454 if (!empty($arrayfields[
'used_days'][
'checked'])) {
455 print
'<td class="right">'.num_open_day($date_start, $date_end, 0, 1, $obj->halfday).
'</td>';
458 if (!empty($arrayfields[
'date_start_month'][
'checked'])) {
459 print
'<td class="center">'.dol_print_date($date_start_inmonth,
'day');
460 print
' <span class="opacitymedium">('.$langs->trans($listhalfday[$starthalfdayinmonth]).
')</span>';
464 if (!empty($arrayfields[
'date_end_month'][
'checked'])) {
465 print
'<td class="center">'.dol_print_date($date_end_inmonth,
'day');
466 print
' <span class="opacitymedium">('.$langs->trans($listhalfday[$endhalfdayinmonth]).
')</span>';
470 if (!empty($arrayfields[
'used_days_month'][
'checked'])) {
471 print
'<td class="right">'.num_open_day($date_start_inmonth, $date_end_inmonth, 0, 1, $halfdayinmonth).
'</td>';
473 if (!empty($arrayfields[
'cp.description'][
'checked'])) {
474 print
'<td class="maxwidth300 small">';
475 print
'<div class="twolinesmax">';
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.
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($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.