2012-09-05 03:26:57 +02:00
< ? php
2015-06-27 11:45:23 +02:00
/* Copyright ( C ) 2011 Dimitri Mouillard < dmouillard @ teclib . com >
2018-05-23 18:19:59 +02:00
* Copyright ( C ) 2013 - 2018 Laurent Destailleur < eldy @ users . sourceforge . net >
2018-12-02 10:01:38 +01:00
* Copyright ( C ) 2012 - 2016 Regis Houssin < regis . houssin @ inodbox . com >
* Copyright ( C ) 2018 Charlene Benke < charlie @ patas - monkey . com >
2012-09-05 03:26:57 +02: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
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2012-09-05 03:26:57 +02: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
2012-09-05 03:57:26 +02:00
* along with this program . If not , see < http :// www . gnu . org / licenses />.
2012-09-05 03:26:57 +02:00
*/
/**
2015-09-11 07:52:06 +02:00
* \file htdocs / holiday / list . php
2012-09-05 03:26:57 +02:00
* \ingroup holiday
2017-07-07 06:42:29 +02:00
* \brief List of holiday
2012-09-05 03:26:57 +02:00
*/
2018-07-26 11:57:25 +02:00
require '../main.inc.php' ;
2012-09-06 10:39:25 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php' ;
2012-11-20 12:40:57 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php' ;
2012-09-06 10:39:25 +02:00
require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php' ;
2012-09-07 17:23:16 +02:00
require_once DOL_DOCUMENT_ROOT . '/user/class/usergroup.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/holiday/common.inc.php' ;
2013-03-30 14:27:13 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/usergroups.lib.php' ;
2013-02-17 19:25:55 +01:00
2018-05-26 21:11:25 +02:00
// Load translation files required by the page
2017-10-02 20:32:31 +02:00
$langs -> loadLangs ( array ( 'users' , 'holidays' , 'hrm' ));
2012-09-05 03:26:57 +02:00
// Protection if external user
if ( $user -> societe_id > 0 ) accessforbidden ();
2017-10-02 20:32:31 +02:00
$action = GETPOST ( 'action' , 'alpha' ); // The action 'add', 'create', 'edit', 'update', 'view', ...
$massaction = GETPOST ( 'massaction' , 'alpha' ); // The bulk action (combo box choice into lists)
$show_files = GETPOST ( 'show_files' , 'int' ); // Show files area generated by bulk actions ?
$confirm = GETPOST ( 'confirm' , 'alpha' ); // Result of a confirmation
$cancel = GETPOST ( 'cancel' , 'alpha' ); // We click on a Cancel button
$toselect = GETPOST ( 'toselect' , 'array' ); // Array of ids of elements selected into a list
$contextpage = GETPOST ( 'contextpage' , 'aZ' ) ? GETPOST ( 'contextpage' , 'aZ' ) : 'myobjectlist' ; // To manage different context of search
$backtopage = GETPOST ( 'backtopage' , 'alpha' ); // Go back to a dedicated page
$optioncss = GETPOST ( 'optioncss' , 'aZ' ); // Option for the css output (always '' except when 'print')
2018-03-21 19:17:42 +01:00
$childids = $user -> getAllChildIds ( 1 );
2018-03-20 14:31:33 +01:00
2018-03-20 11:45:57 +01:00
// Security check
$socid = 0 ;
if ( $user -> societe_id > 0 ) // Protection if external user
{
//$socid = $user->societe_id;
accessforbidden ();
}
$result = restrictedArea ( $user , 'holiday' , $id , '' );
2018-03-20 14:31:33 +01:00
$id = GETPOST ( 'id' , 'int' );
2018-03-20 11:45:57 +01:00
2017-10-02 20:32:31 +02:00
// Load variable for pagination
$limit = GETPOST ( 'limit' , 'int' ) ? GETPOST ( 'limit' , 'int' ) : $conf -> liste_limit ;
$sortfield = GETPOST ( 'sortfield' , 'alpha' );
$sortorder = GETPOST ( 'sortorder' , 'alpha' );
$page = GETPOST ( 'page' , 'int' );
if ( empty ( $page ) || $page == - 1 ) { $page = 0 ; } // If $page is not defined, or '' or -1
2015-12-24 12:52:11 +01:00
$offset = $limit * $page ;
2012-09-07 17:23:16 +02:00
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
2017-10-02 20:32:31 +02:00
// Initialize technical objects
$object = new Holiday ( $db );
$extrafields = new ExtraFields ( $db );
$diroutputmassaction = $conf -> holiday -> dir_output . '/temp/massgeneration/' . $user -> id ;
$hookmanager -> initHooks ( array ( 'holidaylist' )); // Note that conf->hooks_modules contains array
// Fetch optionals attributes and labels
$extralabels = $extrafields -> fetch_name_optionals_label ( 'holiday' );
2018-11-07 12:49:17 +01:00
$search_array_options = $extrafields -> getOptionalsFromPost ( $object -> table_element , '' , 'search_' );
2017-10-02 20:32:31 +02:00
// Default sort order (if not yet defined by previous GETPOST)
if ( ! $sortfield ) $sortfield = " cp.rowid " ;
if ( ! $sortorder ) $sortorder = " DESC " ;
2013-02-17 19:25:55 +01:00
2018-03-19 16:11:42 +01:00
$sall = trim (( GETPOST ( 'search_all' , 'alphanohtml' ) != '' ) ? GETPOST ( 'search_all' , 'alphanohtml' ) : GETPOST ( 'sall' , 'alphanohtml' ));
2018-04-06 17:22:14 +02:00
$search_ref = GETPOST ( 'search_ref' , 'alphanohtml' );
2018-03-19 16:11:42 +01:00
$search_day_create = GETPOST ( 'search_day_create' , 'int' );
$search_month_create = GETPOST ( 'search_month_create' , 'int' );
$search_year_create = GETPOST ( 'search_year_create' , 'int' );
$search_day_start = GETPOST ( 'search_day_start' , 'int' );
$search_month_start = GETPOST ( 'search_month_start' , 'int' );
$search_year_start = GETPOST ( 'search_year_start' , 'int' );
$search_day_end = GETPOST ( 'search_day_end' , 'int' );
$search_month_end = GETPOST ( 'search_month_end' , 'int' );
$search_year_end = GETPOST ( 'search_year_end' , 'int' );
$search_employee = GETPOST ( 'search_employee' , 'int' );
$search_valideur = GETPOST ( 'search_valideur' , 'int' );
$search_statut = GETPOST ( 'search_statut' , 'int' );
$search_type = GETPOST ( 'search_type' , 'int' );
2012-09-05 03:26:57 +02:00
2015-10-17 01:40:46 +02:00
// List of fields to search into when doing a "search in all"
$fieldstosearchall = array (
'cp.description' => 'Description' ,
2016-06-20 10:54:02 +02:00
'uu.lastname' => 'EmployeeLastname' ,
'uu.firstname' => 'EmployeeFirstname'
2015-10-17 01:40:46 +02:00
);
2015-05-31 01:06:51 +02:00
2016-07-23 11:18:22 +02:00
2012-09-05 03:26:57 +02:00
/*
* Actions
*/
2017-10-02 20:32:31 +02:00
if ( GETPOST ( 'cancel' , 'alpha' )) { $action = 'list' ; $massaction = '' ; }
if ( ! GETPOST ( 'confirmmassaction' , 'alpha' ) && $massaction != 'presend' && $massaction != 'confirm_presend' ) { $massaction = '' ; }
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
if ( $reshook < 0 ) setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
if ( empty ( $reshook ))
2016-07-23 11:18:22 +02:00
{
2017-10-02 20:32:31 +02:00
// Selection of new fields
include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php' ;
// Purge search criteria
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
{
$search_ref = " " ;
2018-03-19 16:11:42 +01:00
$search_month_create = " " ;
$search_year_create = " " ;
$search_month_start = " " ;
$search_year_start = " " ;
$search_month_end = " " ;
$search_year_end = " " ;
2017-10-02 20:32:31 +02:00
$search_employee = " " ;
$search_valideur = " " ;
$search_statut = " " ;
$search_type = '' ;
$toselect = '' ;
$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' ) || GETPOST ( 'button_search' , 'alpha' ))
{
$massaction = '' ; // Protection to avoid mass action if we force a new search during a mass action confirmation
}
// Mass actions
$objectclass = 'Holiday' ;
$objectlabel = 'Holiday' ;
$permtoread = $user -> rights -> holiday -> read ;
$permtodelete = $user -> rights -> holiday -> delete ;
$uploaddir = $conf -> holiday -> dir_output ;
include DOL_DOCUMENT_ROOT . '/core/actions_massactions.inc.php' ;
2016-07-23 11:18:22 +02:00
}
2012-09-05 03:26:57 +02:00
2015-05-31 01:06:51 +02:00
2017-10-02 20:32:31 +02:00
2012-09-05 03:26:57 +02:00
/*
* View
*/
2017-10-02 20:32:31 +02:00
$form = new Form ( $db );
$formother = new FormOther ( $db );
2012-12-18 13:12:11 +01:00
$holiday = new Holiday ( $db );
$holidaystatic = new Holiday ( $db );
2013-03-30 14:27:13 +01:00
$fuser = new User ( $db );
2012-12-18 13:12:11 +01:00
2013-02-01 10:13:42 +01:00
// Update sold
2015-06-27 11:45:23 +02:00
$result = $holiday -> updateBalance ();
2013-02-01 10:13:42 +01:00
2012-09-05 03:26:57 +02:00
$max_year = 5 ;
2012-09-05 03:57:26 +02:00
$min_year = 10 ;
2012-11-14 11:29:22 +01:00
$filter = '' ;
2012-09-05 03:26:57 +02:00
2016-04-09 16:04:07 +02:00
llxHeader ( '' , $langs -> trans ( 'CPTitreMenu' ));
2012-09-05 12:59:33 +02:00
2015-12-24 12:52:11 +01:00
$order = $db -> order ( $sortfield , $sortorder ) . $db -> plimit ( $limit + 1 , $offset );
2012-09-05 03:26:57 +02:00
2017-07-07 06:42:29 +02:00
// Ref
2012-12-02 18:21:26 +01:00
if ( ! empty ( $search_ref ))
{
2018-04-06 17:22:14 +02:00
$filter .= " AND cp.rowid = " . ( int ) $db -> escape ( $search_ref );
2012-09-05 03:26:57 +02:00
}
2017-07-07 06:42:29 +02:00
// Start date
2018-12-15 11:48:21 +01:00
$filter .= dolSqlDateFilter ( " cp.date_debut " , $search_day_start , $search_month_start , $search_year_start );
2017-07-07 06:42:29 +02:00
// End date
2018-12-15 11:48:21 +01:00
$filter .= dolSqlDateFilter ( " cp.date_fin " , $search_day_end , $search_month_end , $search_year_end );
2017-07-07 06:42:29 +02:00
// Create date
2018-12-15 11:48:21 +01:00
$filter .= dolSqlDateFilter ( " cp.date_create " , $search_day_create , $search_month_create , $search_year_create );
2017-07-07 06:42:29 +02:00
// Employee
if ( ! empty ( $search_employee ) && $search_employee != - 1 ) {
$filter .= " AND cp.fk_user = ' " . $db -> escape ( $search_employee ) . " ' \n " ;
2012-09-05 03:26:57 +02:00
}
2017-07-07 06:42:29 +02:00
// Validator
2012-09-05 03:26:57 +02:00
if ( ! empty ( $search_valideur ) && $search_valideur != - 1 ) {
2012-12-02 18:21:26 +01:00
$filter .= " AND cp.fk_validator = ' " . $db -> escape ( $search_valideur ) . " ' \n " ;
2012-09-05 03:26:57 +02:00
}
2017-07-07 06:42:29 +02:00
// Type
if ( ! empty ( $search_type ) && $search_type != - 1 ) {
$filter .= ' AND cp.fk_type IN (' . $db -> escape ( $search_type ) . ')' ;
}
// Status
2012-09-05 03:26:57 +02:00
if ( ! empty ( $search_statut ) && $search_statut != - 1 ) {
2012-12-02 18:21:26 +01:00
$filter .= " AND cp.statut = ' " . $db -> escape ( $search_statut ) . " ' \n " ;
2012-09-05 03:26:57 +02:00
}
2015-10-17 01:40:46 +02:00
// Search all
if ( ! empty ( $sall ))
{
$filter .= natural_search ( array_keys ( $fieldstosearchall ), $sall );
}
2015-12-24 12:37:38 +01:00
if ( empty ( $user -> rights -> holiday -> read_all )) $filter .= ' AND cp.fk_user IN (' . join ( ',' , $childids ) . ')' ;
2012-09-05 03:26:57 +02:00
2016-07-23 11:18:22 +02:00
2012-09-05 03:26:57 +02:00
// Récupération de l'ID de l'utilisateur
$user_id = $user -> id ;
2013-03-30 14:27:13 +01:00
if ( $id > 0 )
{
// Charge utilisateur edite
2017-05-06 12:43:45 +02:00
$fuser -> fetch ( $id , '' , '' , 1 );
2013-02-17 19:25:55 +01:00
$fuser -> getrights ();
2013-03-30 14:27:13 +01:00
$user_id = $fuser -> id ;
2017-10-19 20:56:23 +02:00
$search_employee = $user_id ;
2013-02-17 19:25:55 +01:00
}
2017-06-22 15:22:44 +02:00
2018-03-21 19:17:42 +01:00
// Récupération des congés payés de l'utilisateur ou de tous les users de sa hierarchy
// Load array $holiday->holiday
2015-12-24 12:52:11 +01:00
if ( empty ( $user -> rights -> holiday -> read_all ) || $id > 0 )
2012-09-05 03:26:57 +02:00
{
2018-03-21 19:17:42 +01:00
if ( $id > 0 ) $result = $holiday -> fetchByUser ( $id , $order , $filter );
else $result = $holiday -> fetchByUser ( join ( ',' , $childids ), $order , $filter );
2012-09-05 03:26:57 +02:00
}
else
{
2018-03-21 19:17:42 +01:00
$result = $holiday -> fetchAll ( $order , $filter );
2012-09-05 03:26:57 +02:00
}
// Si erreur SQL
2017-06-22 15:22:44 +02:00
if ( $result == '-1' )
2012-09-05 03:26:57 +02:00
{
2015-09-24 18:33:48 +02:00
print load_fiche_titre ( $langs -> trans ( 'CPTitreMenu' ), '' , 'title_hrm.png' );
2012-09-05 03:26:57 +02:00
2014-05-10 15:50:32 +02:00
dol_print_error ( $db , $langs -> trans ( 'Error' ) . ' ' . $holiday -> error );
2012-09-05 03:26:57 +02:00
exit ();
}
2015-06-21 03:19:15 +02:00
// Show table of vacations
2012-09-05 03:26:57 +02:00
2015-12-24 12:52:11 +01:00
$num = count ( $holiday -> holiday );
2017-10-02 20:32:31 +02:00
$arrayofselected = is_array ( $toselect ) ? $toselect : array ();
2012-09-05 03:26:57 +02:00
2017-06-22 15:31:07 +02:00
$param = '' ;
2018-03-19 16:11:42 +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 ( $optioncss != '' ) $param .= '&optioncss=' . urlencode ( $optioncss );
if ( $search_ref ) $param .= '&search_ref=' . urlencode ( $search_ref );
if ( $search_day_create ) $param .= '&search_day_create=' . urlencode ( $search_day_create );
if ( $search_month_create ) $param .= '&search_month_create=' . urlencode ( $search_month_create );
if ( $search_year_create ) $param .= '&search_year_create=' . urlencode ( $search_year_create );
if ( $search_search_day_start ) $param .= '&search_day_start=' . urlencode ( $search_day_start );
if ( $search_month_start ) $param .= '&search_month_start=' . urlencode ( $search_month_start );
if ( $search_year_start ) $param .= '&search_year_start=' . urlencode ( $search_year_start );
2018-03-19 20:46:43 +01:00
if ( $search_day_end ) $param .= '&search_day_end=' . urlencode ( $search_day_end );
2018-03-19 16:11:42 +01:00
if ( $search_month_end ) $param .= '&search_month_end=' . urlencode ( $search_month_end );
if ( $search_year_end ) $param .= '&search_year_end=' . urlencode ( $search_year_end );
if ( $search_employee > 0 ) $param .= '&search_employee=' . urlencode ( $search_employee );
if ( $search_valideur > 0 ) $param .= '&search_valideur=' . urlencode ( $search_valideur );
if ( $search_type > 0 ) $param .= '&search_type=' . urlencode ( $search_type );
if ( $search_statut > 0 ) $param .= '&search_statut=' . urlencode ( $search_statut );
2017-06-22 15:31:07 +02:00
2017-10-02 20:32:31 +02:00
// List of mass actions available
$arrayofmassactions = array (
//'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"),
);
2017-11-15 11:39:11 +01:00
if ( $user -> rights -> holiday -> delete ) $arrayofmassactions [ 'predelete' ] = $langs -> trans ( " Delete " );
if ( in_array ( $massaction , array ( 'presend' , 'predelete' ))) $arrayofmassactions = array ();
2017-10-02 20:32:31 +02:00
$massactionbutton = $form -> selectMassAction ( '' , $arrayofmassactions );
print '<form method="POST" id="searchFormList" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
2017-06-22 15:31:07 +02:00
if ( $optioncss != '' ) print '<input type="hidden" name="optioncss" value="' . $optioncss . '">' ;
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
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 . '">' ;
2017-10-02 20:32:31 +02:00
print '<input type="hidden" name="contextpage" value="' . $contextpage . '">' ;
2017-06-22 15:31:07 +02:00
if ( $id > 0 ) print '<input type="hidden" name="id" value="' . $id . '">' ;
2017-10-02 18:17:16 +02:00
if ( $id > 0 ) // For user tab
2013-02-17 19:25:55 +01:00
{
2015-11-17 22:14:39 +01:00
$title = $langs -> trans ( " User " );
2018-04-06 00:36:52 +02:00
$linkback = '<a href="' . DOL_URL_ROOT . '/user/list.php?restore_lastsearch_values=1">' . $langs -> trans ( " BackToList " ) . '</a>' ;
2015-11-17 21:22:45 +01:00
$head = user_prepare_head ( $fuser );
2016-03-03 08:41:39 +01:00
2017-10-02 18:17:16 +02:00
dol_fiche_head ( $head , 'paidholidays' , $title , - 1 , 'user' );
2013-02-17 19:25:55 +01:00
2015-11-04 15:45:35 +01:00
dol_banner_tab ( $fuser , 'id' , $linkback , $user -> rights -> user -> user -> lire || $user -> admin );
2016-03-03 08:41:39 +01:00
2017-08-29 17:52:10 +02:00
if ( empty ( $conf -> global -> HOLIDAY_HIDE_BALANCE ))
{
print '<div class="underbanner clearboth"></div>' ;
2016-03-03 08:41:39 +01:00
2017-08-29 17:52:10 +02:00
print '<br>' ;
showMyBalance ( $holiday , $user_id );
}
dol_fiche_end ();
2017-10-06 12:36:11 +02:00
print '<div class="tabsAction">' ;
$canedit = (( $user -> id == $user_id && $user -> rights -> holiday -> write ) || ( $user -> id != $user_id && $user -> rights -> holiday -> write_all ));
// Boutons d'actions
if ( $canedit )
{
print '<a href="' . DOL_URL_ROOT . '/holiday/card.php?action=request&fuserid=' . $user_id . '" class="butAction">' . $langs -> trans ( " AddCP " ) . '</a>' ;
}
print '</div>' ;
2013-02-17 19:25:55 +01:00
}
else
{
2017-10-02 20:32:31 +02:00
$nbtotalofrecords = count ( $holiday -> holiday );
//print $num;
2015-12-24 12:52:11 +01:00
//print count($holiday->holiday);
2018-03-30 16:54:38 +02:00
2018-04-15 17:37:49 +02:00
$newcardbutton = '' ;
if ( $user -> rights -> holiday -> write )
{
2018-06-13 22:57:41 +02:00
$newcardbutton = '<a class="butActionNew" href="' . DOL_URL_ROOT . '/holiday/card.php?action=request"><span class="valignmiddle">' . $langs -> trans ( 'MenuAddCP' ) . '</span>' ;
2018-04-18 03:26:15 +02:00
$newcardbutton .= '<span class="fa fa-plus-circle valignmiddle"></span>' ;
$newcardbutton .= '</a>' ;
2018-04-15 17:37:49 +02:00
}
2018-03-30 16:54:38 +02:00
print_barre_liste ( $langs -> trans ( " ListeCP " ), $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , $massactionbutton , $num , $nbtotalofrecords , 'title_hrm.png' , 0 , $newcardbutton , '' , $limit );
2012-09-05 03:26:57 +02:00
2017-11-15 11:39:11 +01:00
$topicmail = " Information " ;
$modelmail = " leaverequest " ;
$objecttmp = new Holiday ( $db );
$trackid = 'leav' . $object -> id ;
include DOL_DOCUMENT_ROOT . '/core/tpl/massactions_pre.tpl.php' ;
2013-02-17 19:25:55 +01:00
}
2015-10-17 01:40:46 +02:00
if ( $sall )
{
foreach ( $fieldstosearchall as $key => $val ) $fieldstosearchall [ $key ] = $langs -> trans ( $val );
2018-06-22 22:53:53 +02:00
print '<div class="divsearchfieldfilter">' . $langs -> trans ( " FilterOnInto " , $sall ) . join ( ', ' , $fieldstosearchall ) . '</div>' ;
2015-10-17 01:40:46 +02:00
}
2016-03-03 08:41:39 +01:00
2017-10-02 20:32:31 +02:00
$varpage = empty ( $contextpage ) ? $_SERVER [ " PHP_SELF " ] : $contextpage ;
$selectedfields = '' ; // $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
$selectedfields .= $form -> showCheckAddButtons ( 'checkforselect' , 1 );
2016-11-27 13:49:46 +01:00
print '<div class="div-table-responsive">' ;
print '<table class="tagtable liste' . ( $moreforfilter ? " listwithfilterbefore " : " " ) . '">' . " \n " ;
2017-07-07 06:42:29 +02:00
// Filters
2017-04-07 14:18:04 +02:00
print '<tr class="liste_titre_filter">' ;
2018-05-23 18:19:59 +02:00
print '<td class="liste_titre">' ;
2015-09-05 20:03:02 +02:00
print '<input class="flat" size="4" type="text" name="search_ref" value="' . dol_escape_htmltag ( $search_ref ) . '">' ;
2013-09-13 10:40:49 +02:00
print '</td>' ;
2012-09-05 03:26:57 +02:00
2017-07-07 06:42:29 +02:00
// Create date
2016-07-23 11:18:22 +02:00
print '<td class="liste_titre" align="center">' ;
2018-05-23 18:19:59 +02:00
print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_month_create" value="' . dol_escape_htmltag ( $search_month_create ) . '">' ;
$formother -> select_year ( $search_year_create , 'search_year_create' , 1 , $min_year , 0 );
2012-09-05 03:26:57 +02:00
print '</td>' ;
2018-03-19 20:46:43 +01:00
$morefilter = 'AND employee = 1' ;
if ( ! empty ( $conf -> global -> HOLIDAY_FOR_NON_SALARIES_TOO )) $morefilter = '' ;
2017-07-07 06:42:29 +02:00
// User
2018-03-20 14:31:33 +01:00
$disabled = 0 ;
// If into the tab holiday of a user ($id is set in such a case)
if ( $id && ! GETPOSTISSET ( 'search_employee' ))
{
$search_employee = $id ;
$disabled = 1 ;
}
if ( ! empty ( $user -> rights -> holiday -> read_all )) // Can see all
2015-06-21 03:19:15 +02:00
{
2018-03-20 14:31:33 +01:00
if ( GETPOSTISSET ( 'search_employee' )) $search_employee = GETPOST ( 'search_employee' , 'int' );
2018-03-19 20:46:43 +01:00
print '<td class="liste_titre maxwidthonsmartphone" align="left">' ;
2018-03-20 14:31:33 +01:00
print $form -> select_dolusers ( $search_employee , " search_employee " , 1 , " " , $disabled , '' , '' , 0 , 0 , 0 , $morefilter , 0 , '' , 'maxwidth200' );
2012-09-05 03:26:57 +02:00
print '</td>' ;
2015-06-27 11:45:23 +02:00
}
else
{
2018-03-20 14:31:33 +01:00
if ( GETPOSTISSET ( 'search_employee' )) $search_employee = GETPOST ( 'search_employee' , 'int' );
2016-09-09 09:21:27 +02:00
print '<td class="liste_titre maxwidthonsmartphone" align="left">' ;
2018-03-20 14:31:33 +01:00
print $form -> select_dolusers ( $search_employee , " search_employee " , 1 , " " , $disabled , 'hierarchyme' , '' , 0 , 0 , 0 , $morefilter , 0 , '' , 'maxwidth200' );
2015-06-27 11:45:23 +02:00
print '</td>' ;
2012-09-05 03:26:57 +02:00
}
2017-07-07 06:42:29 +02:00
// Approve
2018-03-20 14:31:33 +01:00
if ( $user -> rights -> holiday -> read_all )
2013-04-15 12:39:34 +02:00
{
2016-09-09 09:21:27 +02:00
print '<td class="liste_titre maxwidthonsmartphone" align="left">' ;
2012-09-05 03:26:57 +02:00
2013-04-29 18:01:26 +02:00
$validator = new UserGroup ( $db );
$excludefilter = $user -> admin ? '' : 'u.rowid <> ' . $user -> id ;
$valideurobjects = $validator -> listUsersForGroup ( $excludefilter );
$valideurarray = array ();
foreach ( $valideurobjects as $val ) $valideurarray [ $val -> id ] = $val -> id ;
2018-03-19 20:46:43 +01:00
print $form -> select_dolusers ( $search_valideur , " search_valideur " , 1 , " " , 0 , $valideurarray , '' , 0 , 0 , 0 , $morefilter , 0 , '' , 'maxwidth200' );
2012-09-05 03:26:57 +02:00
print '</td>' ;
2013-04-15 12:39:34 +02:00
}
2014-03-05 20:52:27 +01:00
else
2013-04-15 12:39:34 +02:00
{
2012-09-05 03:26:57 +02:00
print '<td class="liste_titre"> </td>' ;
}
2015-06-21 03:19:15 +02:00
// Type
2016-07-23 11:18:22 +02:00
print '<td class="liste_titre">' ;
2018-04-10 15:28:05 +02:00
if ( empty ( $mysoc -> country_id )) {
setEventMessages ( null , array ( $langs -> trans ( " ErrorSetACountryFirst " ), $langs -> trans ( " CompanyFoundation " )), 'errors' );
} else {
$typeleaves = $holidaystatic -> getTypes ( 1 , - 1 );
$arraytypeleaves = array ();
foreach ( $typeleaves as $key => $val )
{
$labeltoshow = ( $langs -> trans ( $val [ 'code' ]) != $val [ 'code' ] ? $langs -> trans ( $val [ 'code' ]) : $val [ 'label' ]);
//$labeltoshow .= ($val['delay'] > 0 ? ' ('.$langs->trans("NoticePeriod").': '.$val['delay'].' '.$langs->trans("days").')':'');
$arraytypeleaves [ $val [ 'rowid' ]] = $labeltoshow ;
}
print $form -> selectarray ( 'search_type' , $arraytypeleaves , $search_type , 1 );
2016-07-23 11:18:22 +02:00
}
2015-06-21 03:19:15 +02:00
print '</td>' ;
2017-07-07 06:42:29 +02:00
// Duration
2016-12-11 16:11:42 +01:00
print '<td class="liste_titre"> </td>' ;
2015-06-21 03:19:15 +02:00
2017-07-07 06:42:29 +02:00
// Start date
2016-07-23 11:18:22 +02:00
print '<td class="liste_titre" align="center">' ;
2018-05-23 18:19:59 +02:00
print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_month_start" value="' . dol_escape_htmltag ( $search_month_start ) . '">' ;
2018-03-19 16:11:42 +01:00
$formother -> select_year ( $search_year_start , 'search_year_start' , 1 , $min_year , $max_year );
2012-09-05 03:26:57 +02:00
print '</td>' ;
2017-07-07 06:42:29 +02:00
// End date
2016-07-23 11:18:22 +02:00
print '<td class="liste_titre" align="center">' ;
2018-05-23 18:19:59 +02:00
print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_month_end" value="' . dol_escape_htmltag ( $search_month_end ) . '">' ;
2018-03-19 16:11:42 +01:00
$formother -> select_year ( $search_year_end , 'search_year_end' , 1 , $min_year , $max_year );
2012-09-05 03:26:57 +02:00
print '</td>' ;
2017-07-07 06:42:29 +02:00
// Status
2016-09-09 09:21:27 +02:00
print '<td class="liste_titre maxwidthonsmartphone maxwidth200" align="right">' ;
2018-03-19 16:11:42 +01:00
$holiday -> selectStatutCP ( $search_statut , 'search_statut' );
2013-04-29 22:09:47 +02:00
print '</td>' ;
2013-09-13 10:40:49 +02:00
2017-07-07 06:42:29 +02:00
// Actions
2016-02-07 15:50:48 +01:00
print '<td class="liste_titre" align="right">' ;
2017-05-14 21:06:33 +02:00
$searchpicto = $form -> showFilterAndCheckAddButtons ( 0 );
print $searchpicto ;
2013-09-13 10:40:49 +02:00
print '</td>' ;
print " </tr> \n " ;
2012-09-05 03:26:57 +02:00
2017-04-07 14:18:04 +02:00
print '<tr class="liste_titre">' ;
2018-10-25 18:50:53 +02:00
print_liste_field_titre ( " Ref " , $_SERVER [ " PHP_SELF " ], " cp.ref " , " " , $param , '' , $sortfield , $sortorder );
2017-08-02 13:31:53 +02:00
print_liste_field_titre ( " DateCreateCP " , $_SERVER [ " PHP_SELF " ], " cp.date_create " , " " , $param , 'align="center"' , $sortfield , $sortorder );
print_liste_field_titre ( " Employee " , $_SERVER [ " PHP_SELF " ], " cp.fk_user " , " " , $param , '' , $sortfield , $sortorder );
print_liste_field_titre ( " ValidatorCP " , $_SERVER [ " PHP_SELF " ], " cp.fk_validator " , " " , $param , '' , $sortfield , $sortorder );
print_liste_field_titre ( " Type " , $_SERVER [ " PHP_SELF " ], '' , '' , $param , '' , $sortfield , $sortorder );
2018-03-20 13:42:29 +01:00
print_liste_field_titre ( " NbUseDaysCPShort " , $_SERVER [ " PHP_SELF " ], '' , '' , $pram , 'align="right"' , $sortfield , $sortorder );
2017-08-02 13:31:53 +02:00
print_liste_field_titre ( " DateDebCP " , $_SERVER [ " PHP_SELF " ], " cp.date_debut " , " " , $param , 'align="center"' , $sortfield , $sortorder );
print_liste_field_titre ( " DateFinCP " , $_SERVER [ " PHP_SELF " ], " cp.date_fin " , " " , $param , 'align="center"' , $sortfield , $sortorder );
print_liste_field_titre ( " Status " , $_SERVER [ " PHP_SELF " ], " cp.statut " , " " , $param , 'align="right"' , $sortfield , $sortorder );
2018-03-19 16:11:42 +01:00
print getTitleFieldOfList ( $selectedfields , 0 , $_SERVER [ " PHP_SELF " ], " " , '' , $param , 'align="center"' , $sortfield , $sortorder , 'maxwidthsearch ' ) . " \n " ;
2017-04-07 14:18:04 +02:00
print " </tr> \n " ;
2012-12-18 13:12:11 +01:00
2017-12-02 01:13:32 +01:00
$listhalfday = array ( 'morning' => $langs -> trans ( " Morning " ), " afternoon " => $langs -> trans ( " Afternoon " ));
2018-03-20 14:31:33 +01:00
// If we ask a dedicated card and not allow to see it, we forc on user.
2018-03-20 14:31:33 +01:00
if ( $id && empty ( $user -> rights -> holiday -> read_all ) && ! in_array ( $id , $childids ))
2018-03-20 14:31:33 +01:00
{
2018-03-20 14:31:33 +01:00
$langs -> load ( " errors " );
print '<tr class="oddeven opacitymediuem"><td colspan="10">' . $langs -> trans ( " NotEnoughPermissions " ) . '</td></tr>' ;
2018-03-20 14:31:33 +01:00
$result = 0 ;
}
2012-12-18 13:12:11 +01:00
// Lines
2018-04-10 15:28:05 +02:00
elseif ( ! empty ( $holiday -> holiday ) && ! empty ( $mysoc -> country_id ))
2012-09-05 03:26:57 +02:00
{
2012-12-18 13:12:11 +01:00
$userstatic = new User ( $db );
$approbatorstatic = new User ( $db );
2012-12-19 20:59:08 +01:00
2017-10-02 19:36:54 +02:00
$typeleaves = $holiday -> getTypes ( 1 , - 1 );
2012-09-05 03:26:57 +02:00
foreach ( $holiday -> holiday as $infos_CP )
{
2017-12-02 01:13:32 +01:00
// Leave request
$holidaystatic -> id = $infos_CP [ 'rowid' ];
2018-10-25 18:50:53 +02:00
$holidaystatic -> ref = ( $infos_CP [ 'ref' ] ? $infos_CP [ 'ref' ] : $infos_CP [ 'rowid' ]);
2017-12-02 01:13:32 +01:00
2017-07-07 06:42:29 +02:00
// User
2012-12-18 13:12:11 +01:00
$userstatic -> id = $infos_CP [ 'fk_user' ];
$userstatic -> lastname = $infos_CP [ 'user_lastname' ];
$userstatic -> firstname = $infos_CP [ 'user_firstname' ];
2016-09-01 11:29:30 +02:00
$userstatic -> login = $infos_CP [ 'user_login' ];
$userstatic -> statut = $infos_CP [ 'user_statut' ];
$userstatic -> photo = $infos_CP [ 'user_photo' ];
2017-06-14 11:28:42 +02:00
2017-07-07 06:42:29 +02:00
// Validator
2012-12-18 13:12:11 +01:00
$approbatorstatic -> id = $infos_CP [ 'fk_validator' ];
2013-01-10 08:27:12 +01:00
$approbatorstatic -> lastname = $infos_CP [ 'validator_lastname' ];
$approbatorstatic -> firstname = $infos_CP [ 'validator_firstname' ];
2016-09-01 11:29:30 +02:00
$approbatorstatic -> login = $infos_CP [ 'validator_login' ];
$approbatorstatic -> statut = $infos_CP [ 'validator_statut' ];
$approbatorstatic -> photo = $infos_CP [ 'validator_photo' ];
2017-06-14 11:28:42 +02:00
2012-11-20 13:14:16 +01:00
$date = $infos_CP [ 'date_create' ];
2012-09-05 03:26:57 +02:00
2017-12-02 01:13:32 +01:00
$starthalfday = ( $infos_CP [ 'halfday' ] == - 1 || $infos_CP [ 'halfday' ] == 2 ) ? 'afternoon' : 'morning' ;
$endhalfday = ( $infos_CP [ 'halfday' ] == 1 || $infos_CP [ 'halfday' ] == 2 ) ? 'morning' : 'afternoon' ;
2017-04-07 14:18:04 +02:00
print '<tr class="oddeven">' ;
2012-09-24 21:37:19 +02:00
print '<td>' ;
2018-03-20 13:42:29 +01:00
print $holidaystatic -> getNomUrl ( 1 , 1 );
2012-12-18 13:12:11 +01:00
print '</td>' ;
print '<td style="text-align: center;">' . dol_print_date ( $date , 'day' ) . '</td>' ;
2016-09-01 11:29:30 +02:00
print '<td>' . $userstatic -> getNomUrl ( - 1 , 'leave' ) . '</td>' ;
print '<td>' . $approbatorstatic -> getNomUrl ( - 1 ) . '</td>' ;
2016-01-09 01:54:10 +01:00
print '<td>' ;
2018-03-19 13:55:26 +01:00
$labeltypeleavetoshow = ( $langs -> trans ( $typeleaves [ $infos_CP [ 'fk_type' ]][ 'code' ]) != $typeleaves [ $infos_CP [ 'fk_type' ]][ 'code' ] ? $langs -> trans ( $typeleaves [ $infos_CP [ 'fk_type' ]][ 'code' ]) : $typeleaves [ $infos_CP [ 'fk_type' ]][ 'label' ]);
print empty ( $typeleaves [ $infos_CP [ 'fk_type' ]][ 'label' ]) ? $langs -> trans ( " TypeWasDisabledOrRemoved " , $infos_CP [ 'fk_type' ]) : $labeltypeleavetoshow ;
2016-01-09 01:54:10 +01:00
print '</td>' ;
2012-12-18 13:12:11 +01:00
print '<td align="right">' ;
2014-03-05 20:52:27 +01:00
$nbopenedday = num_open_day ( $infos_CP [ 'date_debut_gmt' ], $infos_CP [ 'date_fin_gmt' ], 0 , 1 , $infos_CP [ 'halfday' ]);
2013-04-29 18:01:26 +02:00
print $nbopenedday . ' ' . $langs -> trans ( 'DurationDays' );
2015-06-21 03:19:15 +02:00
print '</td>' ;
2017-12-02 01:13:32 +01:00
print '<td align="center">' ;
print dol_print_date ( $infos_CP [ 'date_debut' ], 'day' );
print ' <span class="opacitymedium">(' . $langs -> trans ( $listhalfday [ $starthalfday ]) . ')</span>' ;
print '</td>' ;
print '<td align="center">' ;
print dol_print_date ( $infos_CP [ 'date_fin' ], 'day' );
print ' <span class="opacitymedium">(' . $langs -> trans ( $listhalfday [ $endhalfday ]) . ')</span>' ;
print '</td>' ;
2015-06-30 13:14:19 +02:00
print '<td align="right">' . $holidaystatic -> LibStatut ( $infos_CP [ 'statut' ], 5 ) . '</td>' ;
2017-10-02 20:32:31 +02:00
// Action column
print '<td class="nowrap" align="center">' ;
if ( $massactionbutton || $massaction ) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
{
$selected = 0 ;
if ( in_array ( $infos_CP [ 'rowid' ], $arrayofselected )) $selected = 1 ;
print '<input id="cb' . $infos_CP [ 'rowid' ] . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $infos_CP [ 'rowid' ] . '"' . ( $selected ? ' checked="checked"' : '' ) . '>' ;
}
print '</td>' ;
2012-09-05 03:26:57 +02:00
print '</tr>' . " \n " ;
}
}
// Si il n'y a pas d'enregistrement suite à une recherche
2017-06-22 15:22:44 +02:00
if ( $result == '2' )
2012-09-05 03:26:57 +02:00
{
2017-06-22 15:22:44 +02:00
print '<tr>' ;
2016-06-20 10:54:02 +02:00
print '<td colspan="10" class="opacitymedium">' . $langs -> trans ( 'NoRecordFound' ) . '</td>' ;
2012-09-05 03:26:57 +02:00
print '</tr>' ;
}
print '</table>' ;
2016-11-27 13:49:46 +01:00
print '</div>' ;
2017-06-22 15:31:07 +02:00
2012-09-05 03:26:57 +02:00
print '</form>' ;
2016-01-23 11:30:06 +01:00
/* if ( $user_id == $user -> id )
2013-02-17 19:25:55 +01:00
{
print '<br>' ;
print '<div style="float: right; margin-top: 8px;">' ;
2014-09-18 21:18:25 +02:00
print '<a href="./card.php?action=request" class="butAction">' . $langs -> trans ( 'AddCP' ) . '</a>' ;
2013-02-17 19:25:55 +01:00
print '</div>' ;
2016-01-23 11:30:06 +01:00
} */
2012-09-05 03:26:57 +02:00
2018-08-13 10:20:21 +02:00
// End of page
2012-09-05 03:26:57 +02:00
llxFooter ();
2012-12-02 18:21:26 +01:00
$db -> close ();
2017-10-02 20:32:31 +02:00
/**
* Show balance of user
*
* @ param Holiday $holiday Object $holiday
* @ param int $user_id User id
* @ return string Html code with balance
*/
function showMyBalance ( $holiday , $user_id )
{
global $conf , $langs ;
$alltypeleaves = $holiday -> getTypes ( 1 , - 1 ); // To have labels
$out = '' ;
$nb_holiday = 0 ;
$typeleaves = $holiday -> getTypes ( 1 , 1 );
foreach ( $typeleaves as $key => $val )
{
$nb_type = $holiday -> getCPforUser ( $user_id , $val [ 'rowid' ]);
$nb_holiday += $nb_type ;
$out .= ' - ' . $val [ 'label' ] . ': <strong>' . ( $nb_type ? price2num ( $nb_type ) : 0 ) . '</strong><br>' ;
}
print $langs -> trans ( 'SoldeCPUser' , round ( $nb_holiday , 5 )) . '<br>' ;
print $out ;
}