30require
'../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/holiday/class/holiday.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
46$langs->loadLangs(array(
'holiday',
'hrm'));
48$action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
49$massaction =
GETPOST(
'massaction',
'alpha');
50$contextpage =
GETPOST(
'contextpage',
'aZ');
51$optioncss =
GETPOST(
'optioncss',
'aZ');
55$search_ref =
GETPOST(
'search_ref',
'alphanohtml');
56$search_employee =
GETPOST(
'search_employee',
"intcomma");
57$search_type =
GETPOST(
'search_type',
"intcomma");
58$search_description =
GETPOST(
'search_description',
'alphanohtml');
61$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
62$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
65 $sortfield =
"cp.rowid";
72if (empty($page) || $page == -1) {
76$hookmanager->initHooks(array(
'leavemovementlist'));
78$arrayfields = array();
79$arrayofmassactions = array();
82if ($user->socid > 0) {
88if (!$user->hasRight(
'holiday',
'readall')) {
97if (
GETPOST(
'cancel',
'alpha')) {
101if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
105$parameters = array();
106$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
111if (empty($reshook)) {
113 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
116 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
118 $search_employee =
'';
120 $search_description =
'';
122 $search_array_options = array();
125 if (
GETPOST(
'button_removefilter_x',
'alpha')
126 ||
GETPOST(
'button_removefilter.x',
'alpha')
127 ||
GETPOST(
'button_removefilter',
'alpha')
128 ||
GETPOST(
'button_search_x',
'alpha')
129 ||
GETPOST(
'button_search.x',
'alpha')
130 ||
GETPOST(
'button_search',
'alpha')) {
136 'cp.ref' => array(
'label' =>
'Ref',
'checked' =>
'1',
'position' => 5),
137 'cp.fk_type' => array(
'label' =>
'Type',
'checked' =>
'1',
'position' => 10),
138 'cp.fk_user' => array(
'label' =>
'Employee',
'checked' =>
'1',
'position' => 20),
139 'cp.date_debut' => array(
'label' =>
'DateDebCP',
'checked' =>
'-1',
'position' => 30),
140 'cp.date_fin' => array(
'label' =>
'DateFinCP',
'checked' =>
'-1',
'position' => 32),
141 'used_days' => array(
'label' =>
'NbUseDaysCPShort',
'checked' =>
'-1',
'position' => 34),
142 'date_start_month' => array(
'label' =>
'DateStartInMonth',
'checked' =>
'1',
'position' => 50),
143 'date_end_month' => array(
'label' =>
'DateEndInMonth',
'checked' =>
'1',
'position' => 52),
144 'used_days_month' => array(
'label' =>
'NbUseDaysCPShortInMonth',
'checked' =>
'1',
'position' => 54),
145 'cp.description' => array(
'label' =>
'DescCP',
'checked' =>
'-1',
'position' => 800),
153$form =
new Form($db);
155$holidaystatic =
new Holiday($db);
157$listhalfday = array(
'morning' => $langs->trans(
"Morning"),
"afternoon" => $langs->trans(
"Afternoon"));
159$title = $langs->trans(
'CPTitreMenu');
160$help_url =
'EN:Module_Holiday';
162llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-holiday page-month_report');
166$year_month = sprintf(
"%04d", $search_year).
'-'.sprintf(
"%02d", $search_month);
168$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";
169$sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday cp";
170$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user u ON cp.fk_user = u.rowid";
171$sql .=
" WHERE cp.entity IN (".getEntity(
'holiday').
") AND cp.rowid > 0";
172$sql .=
" AND cp.statut = ".Holiday::STATUS_APPROVED;
174$sql .=
" (date_format(cp.date_debut, '%Y-%m') = '".$db->escape($year_month).
"' OR date_format(cp.date_fin, '%Y-%m') = '".$db->escape($year_month).
"')";
176$sql .=
" (date_format(cp.date_debut, '%Y-%m') < '".$db->escape($year_month).
"' AND date_format(cp.date_fin, '%Y-%m') > '".$db->escape($year_month).
"') ";
178if (!empty($search_ref)) {
181if (!empty($search_employee) && $search_employee !=
'-1') {
182 $sql .=
" AND cp.fk_user IN (".$db->sanitize($search_employee).
")";
184if (!empty($search_type) && $search_type !=
'-1') {
185 $sql .=
" AND cp.fk_type IN (".$db->sanitize($search_type).
")";
187if (!empty($search_description)) {
191$sql .= $db->order($sortfield, $sortorder);
193$resql = $db->query($sql);
199$num = $db->num_rows($resql);
202if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
203 $param .=
'&contextpage='.urlencode($contextpage);
205if ($limit > 0 && $limit !=
$conf->liste_limit) {
206 $param .=
'&limit='.((int) $limit);
208if (!empty($search_ref)) {
209 $param .=
'&search_ref='.urlencode($search_ref);
211if (!empty($search_employee) && $search_employee !=
'-1') {
212 $param .=
'&search_employee='.urlencode($search_employee);
214if (!empty($search_type) && $search_type !=
'-1') {
215 $param .=
'&search_type='.urlencode($search_type);
217if (!empty($search_description)) {
218 $param .=
'&search_description='.urlencode($search_description);
220if (!empty($search_month)) {
221 $param .=
'&search_month='.((int) $search_month);
223if (!empty($search_year)) {
224 $param .=
'&search_year='.((int) $search_year);
227print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
228if ($optioncss !=
'') {
229 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
231print
'<input type="hidden" name="token" value="'.newToken().
'">';
232print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
233print
'<input type="hidden" name="action" value="list">';
234print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
235print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
236print
'<input type="hidden" name="page" value="'.$page.
'">';
237print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
242print
'<div class="tabBar">';
243print $formother->select_month($search_month,
'search_month', 0, 1,
'minwidth50 maxwidth75imp valignmiddle',
true);
244print $formother->selectyear($search_year,
'search_year', 0, 10, 5, 0, 0,
'',
'valignmiddle width75',
true);
245print
'<input type="submit" class="button small" value="'.dol_escape_htmltag($langs->trans(
"Search")).
'" />';
251$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
252$selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
253$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
255print
'<div class="div-table-responsive">';
256print
'<table class="tagtable nobottomiftotal liste">';
258print
'<tr class="liste_titre_filter">';
262 print
'<th class="wrapcolumntitle center maxwidthsearch liste_titre">';
263 $searchpicto = $form->showFilterButtons(
'left');
269if (!empty($arrayfields[
'cp.ref'][
'checked'])) {
270 print
'<th class="liste_titre">';
271 print
'<input class="flat maxwidth100" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
276if (!empty($arrayfields[
'cp.fk_type'][
'checked'])) {
277 $typeleaves = $holidaystatic->getTypes(1, -1);
278 $arraytypeleaves = array();
279 foreach ($typeleaves as $key => $val) {
280 $labeltoshow = ($langs->trans($val[
'code']) != $val[
'code'] ? $langs->trans($val[
'code']) : $val[
'label']);
281 $arraytypeleaves[$val[
'rowid']] = $labeltoshow;
284 print
'<th class="liste_titre">';
285 print $form->selectarray(
'search_type', $arraytypeleaves, $search_type, 1, 0, 0,
'', 0, 0, 0,
'',
'maxwidth150', 1);
290if (!empty($arrayfields[
'cp.fk_user'][
'checked'])) {
291 print
'<th class="liste_titre">';
292 print $form->select_dolusers($search_employee,
"search_employee", 1,
null, 0,
'',
'',
'0', 0, 0,
'', 0,
'',
'maxwidth150');
296if (!empty($arrayfields[
'cp.date_debut'][
'checked'])) {
297 print
'<th class="liste_titre"></th>';
299if (!empty($arrayfields[
'cp.date_fin'][
'checked'])) {
300 print
'<th class="liste_titre"></th>';
302if (!empty($arrayfields[
'used_days'][
'checked'])) {
303 print
'<th class="liste_titre"></th>';
305if (!empty($arrayfields[
'date_start_month'][
'checked'])) {
306 print
'<th class="liste_titre"></th>';
308if (!empty($arrayfields[
'date_end_month'][
'checked'])) {
309 print
'<th class="liste_titre"></th>';
311if (!empty($arrayfields[
'used_days_month'][
'checked'])) {
312 print
'<th class="liste_titre"></th>';
316if (!empty($arrayfields[
'cp.description'][
'checked'])) {
317 print
'<th class="liste_titre">';
318 print
'<input type="text" class="maxwidth100" name="search_description" value="'.$search_description.
'">';
323 print
'<th class="liste_titre maxwidthsearch">';
324 $searchpicto = $form->showFilterButtons();
330print
'<tr class="liste_titre">';
333 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
335if (!empty($arrayfields[
'cp.ref'][
'checked'])) {
336 print_liste_field_titre($arrayfields[
'cp.ref'][
'label'], $_SERVER[
"PHP_SELF"],
'cp.ref',
'', $param,
'', $sortfield, $sortorder);
338if (!empty($arrayfields[
'cp.fk_type'][
'checked'])) {
339 print_liste_field_titre($arrayfields[
'cp.fk_type'][
'label'], $_SERVER[
"PHP_SELF"],
'cp.fk_type',
'', $param,
'', $sortfield, $sortorder);
341if (!empty($arrayfields[
'cp.fk_user'][
'checked'])) {
342 print_liste_field_titre($arrayfields[
'cp.fk_user'][
'label'], $_SERVER[
"PHP_SELF"],
'u.lastname',
'', $param,
'', $sortfield, $sortorder);
344if (!empty($arrayfields[
'ct.label'][
'checked'])) {
345 print_liste_field_titre($arrayfields[
'ct.label'][
'label'], $_SERVER[
"PHP_SELF"],
'ct.label',
'', $param,
'', $sortfield, $sortorder);
347if (!empty($arrayfields[
'cp.date_debut'][
'checked'])) {
348 print_liste_field_titre($arrayfields[
'cp.date_debut'][
'label'], $_SERVER[
"PHP_SELF"],
'cp.date_debut',
'', $param,
'', $sortfield, $sortorder,
'center ');
350if (!empty($arrayfields[
'cp.date_fin'][
'checked'])) {
351 print_liste_field_titre($arrayfields[
'cp.date_fin'][
'label'], $_SERVER[
"PHP_SELF"],
'cp.date_fin',
'', $param,
'', $sortfield, $sortorder,
'center ');
353if (!empty($arrayfields[
'used_days'][
'checked'])) {
354 print_liste_field_titre($arrayfields[
'used_days'][
'label'], $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'maxwidth125 right ');
356if (!empty($arrayfields[
'date_start_month'][
'checked'])) {
357 print_liste_field_titre($arrayfields[
'date_start_month'][
'label'], $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'center ');
359if (!empty($arrayfields[
'date_end_month'][
'checked'])) {
360 print_liste_field_titre($arrayfields[
'date_end_month'][
'label'], $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'center ');
362if (!empty($arrayfields[
'used_days_month'][
'checked'])) {
363 print_liste_field_titre($arrayfields[
'used_days_month'][
'label'], $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'maxwidth125 right ');
365if (!empty($arrayfields[
'cp.description'][
'checked'])) {
366 print_liste_field_titre($arrayfields[
'cp.description'][
'label'], $_SERVER[
"PHP_SELF"],
'cp.description',
'', $param,
'', $sortfield, $sortorder);
370 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'', $param,
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
375 print
'<tr><td colspan="11"><span class="opacitymedium">'.$langs->trans(
'None').
'</span></td></tr>';
377 $tmpuser =
new User($db);
378 while ($obj = $db->fetch_object($resql)) {
379 $tmpuser->fetch($obj->fk_user);
381 $date_start = $db->jdate($obj->date_debut,
true);
382 $date_end = $db->jdate($obj->date_fin,
true);
387 $starthalfday = ($obj->halfday == -1 || $obj->halfday == 2) ?
'afternoon' :
'morning';
388 $endhalfday = ($obj->halfday == 1 || $obj->halfday == 2) ?
'morning' :
'afternoon';
390 $halfdayinmonth = $obj->halfday;
391 $starthalfdayinmonth = $starthalfday;
392 $endhalfdayinmonth = $endhalfday;
397 $date_start_inmonth = $db->jdate($obj->date_debut,
true);
398 $date_end_inmonth = $db->jdate($obj->date_fin,
true);
399 if ($tmpstart[
'year'] < $search_year || $tmpstart[
'mon'] < $search_month) {
401 $starthalfdayinmonth =
'morning';
402 if ($halfdayinmonth == 2) {
405 if ($halfdayinmonth == -1) {
409 if ($tmpend[
'year'] > $search_year || $tmpend[
'mon'] > $search_month) {
410 $date_end_inmonth =
dol_get_last_day($search_year, $search_month,
true) - ((24 * 3600) - 1);
411 $endhalfdayinmonth =
'afternoon';
412 if ($halfdayinmonth == 2) {
413 $halfdayinmonth = -1;
415 if ($halfdayinmonth == 1) {
421 $holidaystatic->id = $obj->rowid;
422 $holidaystatic->ref = $obj->ref;
423 $holidaystatic->status = $obj->status;
424 $holidaystatic->status = $obj->status;
425 $holidaystatic->fk_user = $obj->fk_user;
426 $holidaystatic->fk_type = $obj->fk_type;
427 $holidaystatic->description = $obj->description;
428 $holidaystatic->halfday = $obj->halfday;
429 $holidaystatic->date_debut = $db->jdate($obj->date_debut);
430 $holidaystatic->date_fin = $db->jdate($obj->date_fin);
433 print
'<tr class="oddeven">';
439 if (!empty($arrayfields[
'cp.ref'][
'checked'])) {
440 print
'<td class="nowraponall">'.$holidaystatic->getNomUrl(1, 1).
'</td>';
442 if (!empty($arrayfields[
'cp.fk_type'][
'checked'])) {
443 print
'<td>'.$arraytypeleaves[$obj->fk_type].
'</td>';
445 if (!empty($arrayfields[
'cp.fk_user'][
'checked'])) {
446 print
'<td class="tdoverflowmax150">'.$tmpuser->getNomUrl(-1).
'</td>';
449 if (!empty($arrayfields[
'cp.date_debut'][
'checked'])) {
450 print
'<td class="center">'.dol_print_date($db->jdate($obj->date_debut),
'day');
451 print
' <span class="opacitymedium">('.$langs->trans($listhalfday[$starthalfday]).
')</span>';
455 if (!empty($arrayfields[
'cp.date_fin'][
'checked'])) {
456 print
'<td class="center">'.dol_print_date($db->jdate($obj->date_fin),
'day');
457 print
' <span class="opacitymedium">('.$langs->trans($listhalfday[$endhalfday]).
')</span>';
461 if (!empty($arrayfields[
'used_days'][
'checked'])) {
462 print
'<td class="right">'.num_open_day($date_start, $date_end, 0, 1, $obj->halfday).
'</td>';
465 if (!empty($arrayfields[
'date_start_month'][
'checked'])) {
466 print
'<td class="center">'.dol_print_date($date_start_inmonth,
'day');
467 print
' <span class="opacitymedium">('.$langs->trans($listhalfday[$starthalfdayinmonth]).
')</span>';
471 if (!empty($arrayfields[
'date_end_month'][
'checked'])) {
472 print
'<td class="center">'.dol_print_date($date_end_inmonth,
'day');
473 print
' <span class="opacitymedium">('.$langs->trans($listhalfday[$endhalfdayinmonth]).
')</span>';
477 if (!empty($arrayfields[
'used_days_month'][
'checked'])) {
478 print
'<td class="right">'.num_open_day($date_start_inmonth, $date_end_inmonth, 0, 1, $halfdayinmonth).
'</td>';
480 if (!empty($arrayfields[
'cp.description'][
'checked'])) {
481 print
'<td class="maxwidth300 small">';
482 print
'<div class="twolinesmax">';
$id
Support class for third parties, contacts, members, users or resources.
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
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...
dol_now($mode='auto')
Return date for now.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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.