2018-03-20 13:42:59 +01:00
< ? php
2019-03-10 09:32:19 +01:00
/* Copyright ( C ) 2007 - 2010 Laurent Destailleur < eldy @ users . sourceforge . net >
* Copyright ( C ) 2011 François Legastelois < flegastelois @ teclib . com >
* Copyright ( C ) 2018 - 2019 Frédéric France < frederic . france @ netlogic . fr >
2020-06-26 10:54:27 +02:00
* Copyright ( C ) 2020 Tobias Sekan < tobias . sekan @ startmail . com >
2018-03-20 13:42:59 +01:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
2021-11-09 03:01:48 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2018-03-20 13:42:59 +01:00
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2018-03-20 13:42:59 +01:00
*/
/**
* \file month_report . php
* \ingroup holiday
* \brief Monthly report of leave requests .
*/
2018-07-26 11:57:25 +02:00
require '../main.inc.php' ;
2018-05-26 21:11:25 +02:00
require_once DOL_DOCUMENT_ROOT . '/holiday/class/holiday.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php' ;
2018-03-20 13:42:59 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php' ;
2019-09-28 13:22:05 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php' ;
2018-03-20 13:42:59 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php' ;
2018-05-26 21:11:25 +02:00
// Load translation files required by the page
2022-03-16 09:40:31 +01:00
$langs -> loadLangs ( array ( 'holiday' , 'hrm' ));
2018-03-20 13:42:59 +01:00
// Security check
2019-11-13 19:35:02 +01:00
$socid = 0 ;
2022-06-02 11:14:35 +02:00
$id = GETPOST ( 'id' , 'int' );
2021-02-26 17:59:31 +01:00
if ( $user -> socid > 0 ) { // Protection if external user
2021-02-26 18:14:26 +01:00
//$socid = $user->socid;
2018-03-20 13:42:59 +01:00
accessforbidden ();
}
$result = restrictedArea ( $user , 'holiday' , $id , '' );
2020-06-26 10:54:27 +02:00
$action = GETPOST ( 'action' , 'aZ09' ) ? GETPOST ( 'action' , 'aZ09' ) : 'view' ;
2020-06-26 10:59:50 +02:00
$massaction = GETPOST ( 'massaction' , 'alpha' );
2020-06-26 10:54:27 +02:00
$contextpage = GETPOST ( 'contextpage' , 'aZ' );
2020-06-26 10:59:50 +02:00
$optioncss = GETPOST ( 'optioncss' , 'aZ' );
2020-06-26 10:54:27 +02:00
2020-10-07 14:00:32 +02:00
$search_ref = GETPOST ( 'search_ref' , 'alphanohtml' );
$search_employee = GETPOST ( 'search_employee' , 'int' );
$search_type = GETPOST ( 'search_type' , 'int' );
$search_description = GETPOST ( 'search_description' , 'alphanohtml' );
2020-06-26 10:54:27 +02:00
$limit = GETPOST ( 'limit' , 'int' ) ? GETPOST ( 'limit' , 'int' ) : $conf -> liste_limit ;
2020-09-18 17:13:01 +02:00
$sortfield = GETPOST ( 'sortfield' , 'aZ09comma' );
2022-01-13 11:09:37 +01:00
$sortorder = GETPOST ( 'sortorder' , 'aZ09comma' );
2020-06-26 10:54:27 +02:00
2021-02-26 17:59:31 +01:00
if ( ! $sortfield ) {
$sortfield = " cp.rowid " ;
}
if ( ! $sortorder ) {
$sortorder = " ASC " ;
}
2020-06-26 10:54:27 +02:00
2022-06-02 11:14:35 +02:00
$page = GETPOSTISSET ( 'pageplusone' ) ? ( GETPOST ( 'pageplusone' ) - 1 ) : GETPOST ( " page " , 'int' );
if ( empty ( $page ) || $page == - 1 ) {
$page = 0 ;
}
2020-06-26 10:54:27 +02:00
$hookmanager -> initHooks ( array ( 'leavemovementlist' ));
$arrayfields = array ();
$arrayofmassactions = array ();
/*
* Actions
*/
2021-02-26 17:59:31 +01:00
if ( GETPOST ( 'cancel' , 'alpha' )) {
$action = 'list' ; $massaction = '' ;
}
if ( ! GETPOST ( 'confirmmassaction' , 'alpha' ) && $massaction != 'presend' && $massaction != 'confirm_presend' ) {
$massaction = '' ;
}
2020-06-26 10:54:27 +02:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
2021-02-26 17:59:31 +01:00
if ( $reshook < 0 ) {
setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
}
2020-06-26 10:54:27 +02:00
2021-02-26 17:59:31 +01:00
if ( empty ( $reshook )) {
2020-10-31 14:32:18 +01:00
// Selection of new fields
include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php' ;
// Purge search criteria
2021-02-26 17:59:31 +01:00
if ( GETPOST ( 'button_removefilter_x' , 'alpha' ) || GETPOST ( 'button_removefilter.x' , 'alpha' ) || GETPOST ( 'button_removefilter' , 'alpha' )) { // All tests are required to be compatible with all browsers
2020-10-31 14:32:18 +01:00
$search_ref = '' ;
$search_employee = '' ;
$search_type = '' ;
$search_description = '' ;
2022-05-08 18:25:22 +02:00
$toselect = array ();
2020-10-31 14:32:18 +01:00
$search_array_options = array ();
}
if ( GETPOST ( 'button_removefilter_x' , 'alpha' )
|| GETPOST ( 'button_removefilter.x' , 'alpha' )
|| GETPOST ( 'button_removefilter' , 'alpha' )
|| GETPOST ( 'button_search_x' , 'alpha' )
|| GETPOST ( 'button_search.x' , 'alpha' )
2021-02-26 17:59:31 +01:00
|| GETPOST ( 'button_search' , 'alpha' )) {
2020-10-31 14:32:18 +01:00
$massaction = '' ;
}
2020-06-26 10:54:27 +02:00
}
$arrayfields = array (
2020-10-31 14:32:18 +01:00
'cp.ref' => array ( 'label' => $langs -> trans ( 'Ref' ), 'checked' => 1 ),
'cp.fk_user' => array ( 'label' => $langs -> trans ( 'Employee' ), 'checked' => 1 ),
2022-03-16 09:40:31 +01:00
'cp.fk_type' => array ( 'label' => $langs -> trans ( 'Type' ), 'checked' => 1 ),
2020-10-31 14:32:18 +01:00
'cp.date_debut' => array ( 'label' => $langs -> trans ( 'DateDebCP' ), 'checked' => 1 ),
'cp.date_fin' => array ( 'label' => $langs -> trans ( 'DateFinCP' ), 'checked' => 1 ),
'used_days' => array ( 'label' => $langs -> trans ( 'NbUseDaysCPShort' ), 'checked' => 1 ),
'date_start_month' => array ( 'label' => $langs -> trans ( 'DateStartInMonth' ), 'checked' => 1 ),
'date_end_month' => array ( 'label' => $langs -> trans ( 'DateEndInMonth' ), 'checked' => 1 ),
'used_days_month' => array ( 'label' => $langs -> trans ( 'NbUseDaysCPShortInMonth' ), 'checked' => 1 ),
'cp.description' => array ( 'label' => $langs -> trans ( 'DescCP' ), 'checked' => 1 ),
2020-06-26 10:54:27 +02:00
);
2018-03-20 13:42:59 +01:00
/*
* View
*/
2020-06-26 10:54:27 +02:00
$form = new Form ( $db );
2019-10-02 18:36:36 +02:00
$formother = new FormOther ( $db );
2018-03-20 13:42:59 +01:00
$holidaystatic = new Holiday ( $db );
2019-11-13 19:35:02 +01:00
$listhalfday = array ( 'morning' => $langs -> trans ( " Morning " ), " afternoon " => $langs -> trans ( " Afternoon " ));
2018-03-20 13:42:59 +01:00
2021-06-17 09:13:54 +02:00
$title = $langs -> trans ( 'CPTitreMenu' );
llxHeader ( '' , $title );
2018-03-20 13:42:59 +01:00
2019-11-13 19:35:02 +01:00
$search_month = GETPOST ( " remonth " , 'int' ) ? GETPOST ( " remonth " , 'int' ) : date ( " m " , time ());
$search_year = GETPOST ( " reyear " , 'int' ) ? GETPOST ( " reyear " , 'int' ) : date ( " Y " , time ());
2019-01-27 11:55:16 +01:00
$year_month = sprintf ( " %04d " , $search_year ) . '-' . sprintf ( " %02d " , $search_month );
2018-03-20 13:42:59 +01:00
2022-03-16 09:40:31 +01:00
$sql = " SELECT cp.rowid, cp.ref, cp.fk_user, cp.date_debut, cp.date_fin, cp.fk_type, cp.description, cp.halfday " ;
2020-10-31 14:32:18 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " holiday cp " ;
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " user u ON cp.fk_user = u.rowid " ;
$sql .= " WHERE cp.rowid > 0 " ;
2021-06-02 16:29:38 +02:00
$sql .= " AND cp.statut = " . Holiday :: STATUS_APPROVED ;
2021-12-16 15:41:13 +01:00
$sql .= " AND ( " ;
$sql .= " (date_format(cp.date_debut, '%Y-%m') = ' " . $db -> escape ( $year_month ) . " ' OR date_format(cp.date_fin, '%Y-%m') = ' " . $db -> escape ( $year_month ) . " ') " ;
2021-12-19 00:01:11 +01:00
$sql .= " OR " ; // For leave over several months
2021-12-16 15:41:13 +01:00
$sql .= " (date_format(cp.date_debut, '%Y-%m') < ' " . $db -> escape ( $year_month ) . " ' AND date_format(cp.date_fin, '%Y-%m') > ' " . $db -> escape ( $year_month ) . " ') " ;
$sql .= " ) " ;
2021-02-26 17:59:31 +01:00
if ( ! empty ( $search_ref )) {
$sql .= natural_search ( 'cp.ref' , $search_ref );
}
2021-06-02 16:29:38 +02:00
if ( ! empty ( $search_employee ) && $search_employee > 0 ) {
$sql .= " AND cp.fk_user = " . (( int ) $search_employee );
2021-02-26 17:59:31 +01:00
}
2021-06-02 16:29:38 +02:00
if ( ! empty ( $search_type ) && $search_type != '-1' ) {
2021-06-04 12:30:46 +02:00
$sql .= ' AND cp.fk_type IN (' . $db -> sanitize ( $search_type ) . ')' ;
2021-02-26 17:59:31 +01:00
}
if ( ! empty ( $search_description )) {
$sql .= natural_search ( 'cp.description' , $search_description );
}
2018-03-20 13:42:59 +01:00
2020-10-31 14:32:18 +01:00
$sql .= $db -> order ( $sortfield , $sortorder );
2018-03-20 13:42:59 +01:00
$resql = $db -> query ( $sql );
2021-02-26 17:59:31 +01:00
if ( empty ( $resql )) {
2018-03-20 13:42:59 +01:00
dol_print_error ( $db );
exit ;
}
$num = $db -> num_rows ( $resql );
2020-06-26 10:54:27 +02:00
$param = '' ;
2021-02-26 17:59:31 +01:00
if ( ! empty ( $contextpage ) && $contextpage != $_SERVER [ " PHP_SELF " ]) {
$param .= '&contextpage=' . urlencode ( $contextpage );
}
if ( $limit > 0 && $limit != $conf -> liste_limit ) {
$param .= '&limit=' . urlencode ( $limit );
}
if ( ! empty ( $search_ref )) {
$param .= '&search_ref=' . urlencode ( $search_ref );
}
if ( ! empty ( $search_employee )) {
$param .= '&search_employee=' . urlencode ( $search_employee );
}
if ( ! empty ( $search_type )) {
$param .= '&search_type=' . urlencode ( $search_type );
}
if ( ! empty ( $search_description )) {
$param .= '&search_description=' . urlencode ( $search_description );
}
2020-06-26 10:54:27 +02:00
print '<form method="POST" id="searchFormList" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
2021-02-26 17:59:31 +01:00
if ( $optioncss != '' ) {
print '<input type="hidden" name="optioncss" value="' . $optioncss . '">' ;
}
2020-06-26 10:54:27 +02:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">' ;
print '<input type="hidden" name="action" value="list">' ;
print '<input type="hidden" name="sortfield" value="' . $sortfield . '">' ;
print '<input type="hidden" name="sortorder" value="' . $sortorder . '">' ;
print '<input type="hidden" name="page" value="' . $page . '">' ;
print '<input type="hidden" name="contextpage" value="' . $contextpage . '">' ;
2018-03-20 14:30:02 +01:00
2020-06-26 10:54:27 +02:00
print load_fiche_titre ( $langs -> trans ( 'MenuReportMonth' ), '' , 'title_hrm' );
2018-03-20 13:42:59 +01:00
2020-06-26 10:54:27 +02:00
// Selection filter
print '<div class="tabBar">' ;
2020-12-04 14:53:52 +01:00
print $formother -> select_month ( $search_month , 'remonth' , 0 , 0 , 'minwidth50 maxwidth75imp valignmiddle' , true );
print $formother -> selectyear ( $search_year , 'reyear' , 0 , 10 , 5 , 0 , 0 , '' , 'valignmiddle width75' , true );
2020-06-26 10:54:27 +02:00
print '<input type="submit" class="button" value="' . dol_escape_htmltag ( $langs -> trans ( " Search " )) . '" />' ;
print '</div>' ;
2018-03-20 14:30:02 +01:00
print '<br>' ;
2018-03-20 13:42:59 +01:00
2020-06-26 10:54:27 +02:00
$moreforfilter = '' ;
$varpage = empty ( $contextpage ) ? $_SERVER [ " PHP_SELF " ] : $contextpage ;
$selectedfields = '' ;
$selectedfields = $form -> multiSelectArrayWithCheckbox ( 'selectedfields' , $arrayfields , $varpage ); // This also change content of $arrayfields
2020-10-31 14:32:18 +01:00
$selectedfields .= ( count ( $arrayofmassactions ) ? $form -> showCheckAddButtons ( 'checkforselect' , 1 ) : '' );
2020-06-26 10:54:27 +02:00
2018-03-20 14:30:02 +01:00
print '<div class="div-table-responsive">' ;
2019-11-05 21:24:41 +01:00
print '<table class="noborder centpercent">' ;
2018-03-20 13:42:59 +01:00
print '<tr class="liste_titre">' ;
2020-10-07 14:00:32 +02:00
// Filter: Ref
if ( ! empty ( $arrayfields [ 'cp.ref' ][ 'checked' ])) {
2020-10-31 14:32:18 +01:00
print '<td class="liste_titre">' ;
print '<input class="flat maxwidth100" type="text" name="search_ref" value="' . dol_escape_htmltag ( $search_ref ) . '">' ;
print '</td>' ;
2020-10-07 14:00:32 +02:00
}
// Filter: Employee
if ( ! empty ( $arrayfields [ 'cp.fk_user' ][ 'checked' ])) {
2020-10-31 14:32:18 +01:00
print '<td class="liste_titre">' ;
print $form -> select_dolusers ( $search_employee , " search_employee " , 1 , null , 0 , '' , '' , 0 , 0 , 0 , '' , 0 , '' , 'maxwidth200' );
print '</td>' ;
2020-10-07 14:00:32 +02:00
}
// Filter: Type
2022-03-16 09:40:31 +01:00
if ( ! empty ( $arrayfields [ 'cp.fk_type' ][ 'checked' ])) {
2020-10-31 14:32:18 +01:00
$typeleaves = $holidaystatic -> getTypes ( 1 , - 1 );
$arraytypeleaves = array ();
2021-02-26 17:59:31 +01:00
foreach ( $typeleaves as $key => $val ) {
2020-10-31 14:32:18 +01:00
$labeltoshow = ( $langs -> trans ( $val [ 'code' ]) != $val [ 'code' ] ? $langs -> trans ( $val [ 'code' ]) : $val [ 'label' ]);
$arraytypeleaves [ $val [ 'rowid' ]] = $labeltoshow ;
}
print '<td class="liste_titre">' ;
print $form -> selectarray ( 'search_type' , $arraytypeleaves , $search_type , 1 , 0 , 0 , '' , 0 , 0 , 0 , '' , '' , 1 );
print '</td>' ;
2020-10-07 14:00:32 +02:00
}
2021-02-26 17:59:31 +01:00
if ( ! empty ( $arrayfields [ 'cp.date_debut' ][ 'checked' ])) {
print '<td class="liste_titre"></td>' ;
}
if ( ! empty ( $arrayfields [ 'cp.date_fin' ][ 'checked' ])) {
print '<td class="liste_titre"></td>' ;
}
if ( ! empty ( $arrayfields [ 'used_days' ][ 'checked' ])) {
print '<td class="liste_titre"></td>' ;
}
if ( ! empty ( $arrayfields [ 'date_start_month' ][ 'checked' ])) {
print '<td class="liste_titre"></td>' ;
}
if ( ! empty ( $arrayfields [ 'date_end_month' ][ 'checked' ])) {
print '<td class="liste_titre"></td>' ;
}
if ( ! empty ( $arrayfields [ 'used_days_month' ][ 'checked' ])) {
print '<td class="liste_titre"></td>' ;
}
2020-10-07 14:00:32 +02:00
// Filter: Description
if ( ! empty ( $arrayfields [ 'cp.description' ][ 'checked' ])) {
2020-10-31 14:32:18 +01:00
print '<td class="liste_titre">' ;
print '<input type="text" class="maxwidth100" name="search_description" value="' . $search_description . '">' ;
print '</td>' ;
2020-10-07 14:00:32 +02:00
}
2020-06-26 10:54:27 +02:00
// Action column
print '<td class="liste_titre maxwidthsearch">' ;
$searchpicto = $form -> showFilterButtons ();
print $searchpicto ;
print '</td>' ;
print '</tr>' ;
print '<tr class="liste_titre">' ;
2021-02-26 17:59:31 +01:00
if ( ! empty ( $arrayfields [ 'cp.ref' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'cp.ref' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'cp.ref' , '' , '' , '' , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'cp.fk_user' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'cp.fk_user' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'cp.fk_user' , '' , '' , '' , $sortfield , $sortorder );
}
2022-03-16 21:27:34 +01:00
if ( ! empty ( $arrayfields [ 'cp.fk_type' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'cp.fk_type' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'cp.fk_type' , '' , '' , '' , $sortfield , $sortorder );
}
2021-02-26 17:59:31 +01:00
if ( ! empty ( $arrayfields [ 'ct.label' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'ct.label' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'ct.label' , '' , '' , '' , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'cp.date_debut' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'cp.date_debut' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'cp.date_debut' , '' , '' , '' , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'cp.date_fin' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'cp.date_fin' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'cp.date_fin' , '' , '' , '' , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'used_days' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'used_days' ][ 'label' ], $_SERVER [ " PHP_SELF " ], '' , '' , '' , '' , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'date_start_month' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'date_start_month' ][ 'label' ], $_SERVER [ " PHP_SELF " ], '' , '' , '' , '' , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'date_end_month' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'date_end_month' ][ 'label' ], $_SERVER [ " PHP_SELF " ], '' , '' , '' , '' , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'used_days_month' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'used_days_month' ][ 'label' ], $_SERVER [ " PHP_SELF " ], '' , '' , '' , '' , $sortfield , $sortorder );
}
if ( ! empty ( $arrayfields [ 'cp.description' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'cp.description' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'cp.description' , '' , '' , '' , $sortfield , $sortorder );
}
2020-06-26 10:54:27 +02:00
print getTitleFieldOfList ( $selectedfields , 0 , $_SERVER [ " PHP_SELF " ], '' , '' , '' , '' , $sortfield , $sortorder , 'center maxwidthsearch ' ) . " \n " ;
2018-03-20 13:42:59 +01:00
print '</tr>' ;
2021-02-26 17:59:31 +01:00
if ( $num == 0 ) {
2020-10-31 14:32:18 +01:00
print '<tr><td colspan="10" class="opacitymedium">' . $langs -> trans ( 'None' ) . '</td></tr>' ;
2021-02-26 17:59:31 +01:00
} else {
while ( $obj = $db -> fetch_object ( $resql )) {
2020-10-31 14:32:18 +01:00
$user = new User ( $db );
$user -> fetch ( $obj -> fk_user );
$date_start = $db -> jdate ( $obj -> date_debut , true );
$date_end = $db -> jdate ( $obj -> date_fin , true );
$tmpstart = dol_getdate ( $date_start );
$tmpend = dol_getdate ( $date_end );
$starthalfday = ( $obj -> halfday == - 1 || $obj -> halfday == 2 ) ? 'afternoon' : 'morning' ;
$endhalfday = ( $obj -> halfday == 1 || $obj -> halfday == 2 ) ? 'morning' : 'afternoon' ;
$halfdayinmonth = $obj -> halfday ;
$starthalfdayinmonth = $starthalfday ;
$endhalfdayinmonth = $endhalfday ;
//0:Full days, 2:Start afternoon end morning, -1:Start afternoon end afternoon, 1:Start morning end morning
// Set date_start_gmt and date_end_gmt that are date to show for the selected month
$date_start_inmonth = $db -> jdate ( $obj -> date_debut , true );
$date_end_inmonth = $db -> jdate ( $obj -> date_fin , true );
2021-02-26 17:59:31 +01:00
if ( $tmpstart [ 'year' ] < $search_year || $tmpstart [ 'mon' ] < $search_month ) {
2020-10-31 14:32:18 +01:00
$date_start_inmonth = dol_get_first_day ( $search_year , $search_month , true );
$starthalfdayinmonth = 'morning' ;
2021-02-26 17:59:31 +01:00
if ( $halfdayinmonth == 2 ) {
$halfdayinmonth = 1 ;
}
if ( $halfdayinmonth == - 1 ) {
$halfdayinmonth = 0 ;
}
2020-10-31 14:32:18 +01:00
}
2021-02-26 17:59:31 +01:00
if ( $tmpend [ 'year' ] > $search_year || $tmpend [ 'mon' ] > $search_month ) {
2020-10-31 14:32:18 +01:00
$date_end_inmonth = dol_get_last_day ( $search_year , $search_month , true ) - (( 24 * 3600 ) - 1 );
$endhalfdayinmonth = 'afternoon' ;
2021-02-26 17:59:31 +01:00
if ( $halfdayinmonth == 2 ) {
$halfdayinmonth = - 1 ;
}
if ( $halfdayinmonth == 1 ) {
$halfdayinmonth = 0 ;
}
2020-10-31 14:32:18 +01:00
}
// Leave request
$holidaystatic -> id = $obj -> rowid ;
$holidaystatic -> ref = $obj -> ref ;
print '<tr class="oddeven">' ;
2021-02-26 17:59:31 +01:00
if ( ! empty ( $arrayfields [ 'cp.ref' ][ 'checked' ])) {
print '<td>' . $holidaystatic -> getNomUrl ( 1 , 1 ) . '</td>' ;
}
if ( ! empty ( $arrayfields [ 'cp.fk_user' ][ 'checked' ])) {
print '<td>' . $user -> getFullName ( $langs ) . '</td>' ;
}
2022-03-16 09:40:31 +01:00
if ( ! empty ( $arrayfields [ 'cp.fk_type' ][ 'checked' ])) {
print '<td>' . $arraytypeleaves [ $obj -> fk_type ] . '</td>' ;
2021-02-26 17:59:31 +01:00
}
2020-10-31 14:32:18 +01:00
2021-02-26 17:59:31 +01:00
if ( ! empty ( $arrayfields [ 'cp.date_debut' ][ 'checked' ])) {
2020-10-31 14:32:18 +01:00
print '<td class="center">' . dol_print_date ( $db -> jdate ( $obj -> date_debut ), 'day' );
print ' <span class="opacitymedium">(' . $langs -> trans ( $listhalfday [ $starthalfday ]) . ')</span>' ;
print '</td>' ;
}
2021-02-26 17:59:31 +01:00
if ( ! empty ( $arrayfields [ 'cp.date_fin' ][ 'checked' ])) {
2020-10-31 14:32:18 +01:00
print '<td class="center">' . dol_print_date ( $db -> jdate ( $obj -> date_fin ), 'day' );
print ' <span class="opacitymedium">(' . $langs -> trans ( $listhalfday [ $endhalfday ]) . ')</span>' ;
print '</td>' ;
}
2021-02-26 17:59:31 +01:00
if ( ! empty ( $arrayfields [ 'used_days' ][ 'checked' ])) {
print '<td class="right">' . num_open_day ( $date_start , $date_end , 0 , 1 , $obj -> halfday ) . '</td>' ;
}
2020-10-31 14:32:18 +01:00
2021-02-26 17:59:31 +01:00
if ( ! empty ( $arrayfields [ 'date_start_month' ][ 'checked' ])) {
2020-10-31 14:32:18 +01:00
print '<td class="center">' . dol_print_date ( $date_start_inmonth , 'day' );
print ' <span class="opacitymedium">(' . $langs -> trans ( $listhalfday [ $starthalfdayinmonth ]) . ')</span>' ;
print '</td>' ;
}
2021-02-26 17:59:31 +01:00
if ( ! empty ( $arrayfields [ 'date_end_month' ][ 'checked' ])) {
2020-10-31 14:32:18 +01:00
print '<td class="center">' . dol_print_date ( $date_end_inmonth , 'day' );
print ' <span class="opacitymedium">(' . $langs -> trans ( $listhalfday [ $endhalfdayinmonth ]) . ')</span>' ;
print '</td>' ;
}
2021-02-26 17:59:31 +01:00
if ( ! empty ( $arrayfields [ 'used_days_month' ][ 'checked' ])) {
print '<td class="right">' . num_open_day ( $date_start_inmonth , $date_end_inmonth , 0 , 1 , $halfdayinmonth ) . '</td>' ;
}
if ( ! empty ( $arrayfields [ 'cp.description' ][ 'checked' ])) {
2022-03-16 21:27:34 +01:00
print '<td class="maxwidth300 small">' . dolGetFirstLineOfText ( dol_string_nohtmltag ( $obj -> description , 1 )) . '</td>' ;
2021-02-26 17:59:31 +01:00
}
2020-10-31 14:32:18 +01:00
print '<td></td>' ;
print '</tr>' ;
}
2018-03-20 13:42:59 +01:00
}
print '</table>' ;
print '</div>' ;
2020-06-26 10:54:27 +02:00
print '</form>' ;
2018-03-20 13:42:59 +01:00
2018-08-13 10:20:21 +02:00
// End of page
2018-03-20 13:42:59 +01:00
llxFooter ();
2018-08-13 10:20:21 +02:00
$db -> close ();