';
}
diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php
index 15a565b04f9..9973223ba0f 100644
--- a/htdocs/holiday/class/holiday.class.php
+++ b/htdocs/holiday/class/holiday.class.php
@@ -1195,12 +1195,15 @@ class Holiday extends CommonObject
*
* @param boolean $stringlist If true return a string list of id. If false, return an array
* @param boolean $type If true, read Dolibarr user list, if false, return vacation balance list.
+ * @param string $filters Filters
* @return array|string|int Return an array
*/
- function fetchUsers($stringlist=true,$type=true)
+ function fetchUsers($stringlist=true, $type=true, $filters='')
{
global $conf;
+ dol_syslog(get_class($this)."::fetchUsers", LOG_DEBUG);
+
// Si vrai donc pour user Dolibarr
if ($stringlist)
{
@@ -1219,11 +1222,12 @@ class Holiday extends CommonObject
$sql.= " OR u.admin = 1";
}
else
+ {
$sql.= " WHERE u.entity IN (0,".$conf->entity.")";
-
+ }
$sql.= " AND u.statut > 0";
+ if ($filters) $sql.=$filters;
- dol_syslog(get_class($this)."::fetchUsers", LOG_DEBUG);
$resql=$this->db->query($sql);
// Si pas d'erreur SQL
@@ -1261,9 +1265,10 @@ class Holiday extends CommonObject
{
// We want only list of user id
$sql = "SELECT DISTINCT cpu.fk_user";
- $sql.= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu";
+ $sql.= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu, ".MAIN_DB_PREFIX."user as u";
+ $sql.= " WHERE cpu.fk_user = u.user";
+ if ($filters) $sql.=$filters;
- dol_syslog(get_class($this)."::fetchUsers", LOG_DEBUG);
$resql=$this->db->query($sql);
// Si pas d'erreur SQL
@@ -1318,8 +1323,8 @@ class Holiday extends CommonObject
$sql.= " WHERE u.entity IN (0,".$conf->entity.")";
$sql.= " AND u.statut > 0";
+ if ($filters) $sql.=$filters;
- dol_syslog(get_class($this)."::fetchUsers", LOG_DEBUG);
$resql=$this->db->query($sql);
// Si pas d'erreur SQL
@@ -1358,14 +1363,13 @@ class Holiday extends CommonObject
}
}
else
- {
+ {
// List of vacation balance users
$sql = "SELECT cpu.fk_user, cpu.fk_type, cpu.nb_holiday, u.lastname, u.firstname";
- $sql.= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu,";
- $sql.= " ".MAIN_DB_PREFIX."user as u";
+ $sql.= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu, ".MAIN_DB_PREFIX."user as u";
$sql.= " WHERE cpu.fk_user = u.rowid";
+ if ($filters) $sql.=$filters;
- dol_syslog(get_class($this)."::fetchUsers", LOG_DEBUG);
$resql=$this->db->query($sql);
// Si pas d'erreur SQL
diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php
index e1b8b21a7bd..88f3438dcaf 100644
--- a/htdocs/holiday/define_holiday.php
+++ b/htdocs/holiday/define_holiday.php
@@ -30,81 +30,135 @@ require('../main.inc.php');
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php';
+$langs->load('users');
+$langs->load('hrm');
+
+$action=GETPOST('action','aZ09');
+
+$search_name=GETPOST('search_name', 'alpha');
+
+// 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
+$offset = $limit * $page;
+$pageprev = $page - 1;
+$pagenext = $page + 1;
+if (! $sortfield) $sortfield="t.rowid"; // Set here default search field
+if (! $sortorder) $sortorder="ASC";
+
+
// Protection if external user
if ($user->societe_id > 0) accessforbidden();
// If the user does not have perm to read the page
if(!$user->rights->holiday->read) accessforbidden();
-$action=GETPOST('action','aZ09');
+
+// Initialize technical object to manage context to save list fields
+$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'defineholidaylist';
+
+// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
+$hookmanager->initHooks(array('defineholidaylist'));
+$extrafields = new ExtraFields($db);
$holiday = new Holiday($db);
-$langs->load('users');
-$langs->load('hrm');
-
/*
* Actions
*/
-// Si il y a une action de mise à jour
-if ($action == 'update' && isset($_POST['update_cp']))
+if (GETPOST('cancel')) { $action='list'; $massaction=''; }
+if (! GETPOST('confirmmassaction') && $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))
{
- $error = 0;
+ // Selection of new fields
+ include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
- $typeleaves=$holiday->getTypes(1,1);
-
- $userID = array_keys($_POST['update_cp']);
- $userID = $userID[0];
-
- foreach($typeleaves as $key => $val)
+ // Purge search criteria
+ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") ||GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers
{
- $userValue = $_POST['nb_holiday_'.$val['rowid']];
- $userValue = $userValue[$userID];
-
- if (!empty($userValue))
- {
- $userValue = price2num($userValue,5);
- } else {
- $userValue = '';
- }
-
- //If the user set a comment, we add it to the log comment
- $comment = ((isset($_POST['note_holiday'][$userID]) && !empty($_POST['note_holiday'][$userID])) ? ' ('.$_POST['note_holiday'][$userID].')' : '');
-
- //print 'eee'.$val['rowid'].'-'.$userValue;
- if ($userValue != '')
- {
- // We add the modification to the log (must be before update of sold because we read current value of sold)
- $result=$holiday->addLogCP($user->id, $userID, $langs->transnoentitiesnoconv('ManualUpdate').$comment, $userValue, $val['rowid']);
- if ($result < 0)
- {
- setEventMessages($holiday->error, $holiday->errors, 'errors');
- $error++;
- }
-
- // Update of the days of the employee
- $result = $holiday->updateSoldeCP($userID, $userValue, $val['rowid']);
- if ($result < 0)
- {
- setEventMessages($holiday->error, $holiday->errors, 'errors');
- $error++;
- }
-
- // If it first update of balance, we set date to avoid to have sold incremented by new month
- /*
- $now=dol_now();
- $sql = "UPDATE ".MAIN_DB_PREFIX."holiday_config SET";
- $sql.= " value = '".dol_print_date($now,'%Y%m%d%H%M%S')."'";
- $sql.= " WHERE name = 'lastUpdate' and value IS NULL"; // Add value IS NULL to be sure to update only at init.
- dol_syslog('define_holiday update lastUpdate entry', LOG_DEBUG);
- $result = $db->query($sql);
- */
- }
+ $search_name='';
+ $toselect='';
+ $search_array_options=array();
}
- if (! $error) setEventMessages('UpdateConfCPOK', '', 'mesgs');
+ // Mass actions
+ /*
+ $objectclass='Skeleton';
+ $objectlabel='Skeleton';
+ $permtoread = $user->rights->skeleton->read;
+ $permtodelete = $user->rights->skeleton->delete;
+ $uploaddir = $conf->skeleton->dir_output;
+ include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
+ */
+
+ // Si il y a une action de mise à jour
+ if ($action == 'update' && isset($_POST['update_cp']))
+ {
+ $error = 0;
+
+ $typeleaves=$holiday->getTypes(1,1);
+
+ $userID = array_keys($_POST['update_cp']);
+ $userID = $userID[0];
+
+ foreach($typeleaves as $key => $val)
+ {
+ $userValue = $_POST['nb_holiday_'.$val['rowid']];
+ $userValue = $userValue[$userID];
+
+ if (!empty($userValue))
+ {
+ $userValue = price2num($userValue,5);
+ } else {
+ $userValue = '';
+ }
+
+ //If the user set a comment, we add it to the log comment
+ $comment = ((isset($_POST['note_holiday'][$userID]) && !empty($_POST['note_holiday'][$userID])) ? ' ('.$_POST['note_holiday'][$userID].')' : '');
+
+ //print 'eee'.$val['rowid'].'-'.$userValue;
+ if ($userValue != '')
+ {
+ // We add the modification to the log (must be before update of sold because we read current value of sold)
+ $result=$holiday->addLogCP($user->id, $userID, $langs->transnoentitiesnoconv('ManualUpdate').$comment, $userValue, $val['rowid']);
+ if ($result < 0)
+ {
+ setEventMessages($holiday->error, $holiday->errors, 'errors');
+ $error++;
+ }
+
+ // Update of the days of the employee
+ $result = $holiday->updateSoldeCP($userID, $userValue, $val['rowid']);
+ if ($result < 0)
+ {
+ setEventMessages($holiday->error, $holiday->errors, 'errors');
+ $error++;
+ }
+
+ // If it first update of balance, we set date to avoid to have sold incremented by new month
+ /*
+ $now=dol_now();
+ $sql = "UPDATE ".MAIN_DB_PREFIX."holiday_config SET";
+ $sql.= " value = '".dol_print_date($now,'%Y%m%d%H%M%S')."'";
+ $sql.= " WHERE name = 'lastUpdate' and value IS NULL"; // Add value IS NULL to be sure to update only at init.
+ dol_syslog('define_holiday update lastUpdate entry', LOG_DEBUG);
+ $result = $db->query($sql);
+ */
+ }
+ }
+
+ if (! $error) setEventMessages('UpdateConfCPOK', '', 'mesgs');
+ }
}
@@ -117,6 +171,17 @@ $userstatic=new User($db);
llxHeader('', $langs->trans('CPTitreMenu'));
+
+print '