Add unique key on table to follow leave request counter per type
This commit is contained in:
parent
3208d8d3ac
commit
97d399595f
@ -1286,7 +1286,7 @@ class Holiday extends CommonObject
|
|||||||
/**
|
/**
|
||||||
* Get list of Users or list of vacation balance.
|
* Get list of Users or list of vacation balance.
|
||||||
*
|
*
|
||||||
* @param boolean $stringlist If true return a string list of id. If false, return an array
|
* @param boolean $stringlist If true return a string list of id. If false, return an array with detail.
|
||||||
* @param boolean $type If true, read Dolibarr user list, if false, return vacation balance list.
|
* @param boolean $type If true, read Dolibarr user list, if false, return vacation balance list.
|
||||||
* @param string $filters Filters
|
* @param string $filters Filters
|
||||||
* @return array|string|int Return an array
|
* @return array|string|int Return an array
|
||||||
@ -1297,7 +1297,6 @@ class Holiday extends CommonObject
|
|||||||
|
|
||||||
dol_syslog(get_class($this)."::fetchUsers", LOG_DEBUG);
|
dol_syslog(get_class($this)."::fetchUsers", LOG_DEBUG);
|
||||||
|
|
||||||
// Si vrai donc pour user Dolibarr
|
|
||||||
if ($stringlist)
|
if ($stringlist)
|
||||||
{
|
{
|
||||||
if ($type)
|
if ($type)
|
||||||
@ -1356,7 +1355,7 @@ class Holiday extends CommonObject
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// We want only list of user id
|
// We want only list of vacation balance for user ids
|
||||||
$sql = "SELECT DISTINCT cpu.fk_user";
|
$sql = "SELECT DISTINCT cpu.fk_user";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu, ".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.user";
|
$sql.= " WHERE cpu.fk_user = u.user";
|
||||||
@ -1397,12 +1396,12 @@ class Holiday extends CommonObject
|
|||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // Si faux donc user Congés Payés
|
{ // Si faux donc return array
|
||||||
|
|
||||||
// List for Dolibarr users
|
// List for Dolibarr users
|
||||||
if ($type)
|
if ($type)
|
||||||
{
|
{
|
||||||
$sql = "SELECT u.rowid, u.lastname, u.firstname, u.gender, u.photo, u.employee, u.statut";
|
$sql = "SELECT u.rowid, u.lastname, u.firstname, u.gender, u.photo, u.employee, u.statut, u.fk_user";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."user as u";
|
$sql.= " FROM ".MAIN_DB_PREFIX."user as u";
|
||||||
|
|
||||||
if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
|
if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
|
||||||
@ -1440,6 +1439,7 @@ class Holiday extends CommonObject
|
|||||||
$tab_result[$i]['status'] = $obj->statut;
|
$tab_result[$i]['status'] = $obj->statut;
|
||||||
$tab_result[$i]['employee'] = $obj->employee;
|
$tab_result[$i]['employee'] = $obj->employee;
|
||||||
$tab_result[$i]['photo'] = $obj->photo;
|
$tab_result[$i]['photo'] = $obj->photo;
|
||||||
|
$tab_result[$i]['fk_user'] = $obj->fk_user;
|
||||||
//$tab_result[$i]['type'] = $obj->type;
|
//$tab_result[$i]['type'] = $obj->type;
|
||||||
//$tab_result[$i]['nb_holiday'] = $obj->nb_holiday;
|
//$tab_result[$i]['nb_holiday'] = $obj->nb_holiday;
|
||||||
|
|
||||||
@ -1458,7 +1458,7 @@ class Holiday extends CommonObject
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// List of vacation balance users
|
// List of vacation balance users
|
||||||
$sql = "SELECT cpu.fk_user, cpu.fk_type, cpu.nb_holiday, u.lastname, u.firstname";
|
$sql = "SELECT cpu.fk_user, cpu.fk_type, cpu.nb_holiday, u.lastname, u.firstname, u.gender, u.photo, u.employee, u.statut, u.fk_user";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu, ".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";
|
$sql.= " WHERE cpu.fk_user = u.rowid";
|
||||||
if ($filters) $sql.=$filters;
|
if ($filters) $sql.=$filters;
|
||||||
@ -1478,9 +1478,15 @@ class Holiday extends CommonObject
|
|||||||
$obj = $this->db->fetch_object($resql);
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
|
||||||
$tab_result[$i]['rowid'] = $obj->fk_user;
|
$tab_result[$i]['rowid'] = $obj->fk_user;
|
||||||
$tab_result[$i]['name'] = $obj->lastname;
|
$tab_result[$i]['name'] = $obj->lastname; // deprecated
|
||||||
$tab_result[$i]['lastname'] = $obj->lastname;
|
$tab_result[$i]['lastname'] = $obj->lastname;
|
||||||
$tab_result[$i]['firstname'] = $obj->firstname;
|
$tab_result[$i]['firstname'] = $obj->firstname;
|
||||||
|
$tab_result[$i]['gender'] = $obj->gender;
|
||||||
|
$tab_result[$i]['status'] = $obj->statut;
|
||||||
|
$tab_result[$i]['employee'] = $obj->employee;
|
||||||
|
$tab_result[$i]['photo'] = $obj->photo;
|
||||||
|
$tab_result[$i]['fk_user'] = $obj->fk_user;
|
||||||
|
|
||||||
$tab_result[$i]['type'] = $obj->type;
|
$tab_result[$i]['type'] = $obj->type;
|
||||||
$tab_result[$i]['nb_holiday'] = $obj->nb_holiday;
|
$tab_result[$i]['nb_holiday'] = $obj->nb_holiday;
|
||||||
|
|
||||||
|
|||||||
@ -36,6 +36,7 @@ $langs->load('hrm');
|
|||||||
$action=GETPOST('action','aZ09');
|
$action=GETPOST('action','aZ09');
|
||||||
|
|
||||||
$search_name=GETPOST('search_name', 'alpha');
|
$search_name=GETPOST('search_name', 'alpha');
|
||||||
|
$search_supervisor=GETPOST('search_supervisor', 'int');
|
||||||
|
|
||||||
// Load variable for pagination
|
// Load variable for pagination
|
||||||
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
|
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
|
||||||
@ -87,6 +88,7 @@ if (empty($reshook))
|
|||||||
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
|
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_name='';
|
$search_name='';
|
||||||
|
$search_supervisor='';
|
||||||
$toselect='';
|
$toselect='';
|
||||||
$search_array_options=array();
|
$search_array_options=array();
|
||||||
}
|
}
|
||||||
@ -202,9 +204,11 @@ if ($result < 0)
|
|||||||
setEventMessages($holiday->error, $holiday->errors, 'errors');
|
setEventMessages($holiday->error, $holiday->errors, 'errors');
|
||||||
}
|
}
|
||||||
|
|
||||||
$filters=natural_search(array('u.firstname','u.lastname'), $search_name);
|
$filters='';
|
||||||
|
$filters.=natural_search(array('u.firstname','u.lastname'), $search_name);
|
||||||
|
if ($search_supervisor > 0) $filters.=natural_search(array('u.fk_user'), $search_supervisor, 2);
|
||||||
|
|
||||||
$listUsers = $holiday->fetchUsers(false,true,$filters);
|
$listUsers = $holiday->fetchUsers(false, true, $filters);
|
||||||
if (is_numeric($listUsers) && $listUsers < 0)
|
if (is_numeric($listUsers) && $listUsers < 0)
|
||||||
{
|
{
|
||||||
setEventMessages($holiday->error, $holiday->errors, 'errors');
|
setEventMessages($holiday->error, $holiday->errors, 'errors');
|
||||||
@ -242,7 +246,16 @@ else
|
|||||||
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'" id="tablelines3">'."\n";
|
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'" id="tablelines3">'."\n";
|
||||||
|
|
||||||
print '<tr class="liste_titre_filter">';
|
print '<tr class="liste_titre_filter">';
|
||||||
|
|
||||||
|
// User
|
||||||
print '<td class="liste_titre"><input type="text" name="search_name" value="'.dol_escape_htmltag($search_name).'"></td>';
|
print '<td class="liste_titre"><input type="text" name="search_name" value="'.dol_escape_htmltag($search_name).'"></td>';
|
||||||
|
|
||||||
|
// Supervisor
|
||||||
|
print '<td class="liste_titre">';
|
||||||
|
print $form->select_dolusers($search_supervisor, 'search_supervisor', 1, null, 0, null, null, 0, 0, 0, '', 0, '', 'maxwidth200');
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
|
// Type of leave request
|
||||||
if (count($typeleaves))
|
if (count($typeleaves))
|
||||||
{
|
{
|
||||||
foreach($typeleaves as $key => $val)
|
foreach($typeleaves as $key => $val)
|
||||||
@ -266,23 +279,23 @@ else
|
|||||||
|
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
print_liste_field_titre('Employee', $_SERVER["PHP_SELF"]);
|
print_liste_field_titre('Employee', $_SERVER["PHP_SELF"]);
|
||||||
|
print_liste_field_titre('Supervisor', $_SERVER["PHP_SELF"]);
|
||||||
if (count($typeleaves))
|
if (count($typeleaves))
|
||||||
{
|
{
|
||||||
foreach($typeleaves as $key => $val)
|
foreach($typeleaves as $key => $val)
|
||||||
{
|
{
|
||||||
print '<th style="text-align:center">'.$val['label'].'</th>';
|
print_liste_field_titre($val['label'], $_SERVER["PHP_SELF"], '', '', '', 'align="center"');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print '<th>'.$langs->trans("NoLeaveWithCounterDefined").'</th>';
|
print_liste_field_titre($langs->trans("NoLeaveWithCounterDefined"), $_SERVER["PHP_SELF"], '', '', '', '');
|
||||||
}
|
}
|
||||||
print '<th style="text-align:center">';
|
print_liste_field_titre($langs->trans('Note'), $_SERVER["PHP_SELF"]);
|
||||||
if ($canedit) print $langs->trans('Note');
|
|
||||||
print '</th>';
|
|
||||||
print_liste_field_titre('');
|
print_liste_field_titre('');
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
|
$usersupervisor = new User($db);
|
||||||
|
|
||||||
foreach($listUsers as $users)
|
foreach($listUsers as $users)
|
||||||
{
|
{
|
||||||
@ -292,10 +305,6 @@ else
|
|||||||
if (($users['rowid'] != $user->id) && (! in_array($users['rowid'], $userchilds))) continue; // This user is not into hierarchy of current user, we hide it.
|
if (($users['rowid'] != $user->id) && (! in_array($users['rowid'], $userchilds))) continue; // This user is not into hierarchy of current user, we hide it.
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<tr class="oddeven">';
|
|
||||||
|
|
||||||
// User
|
|
||||||
print '<td>';
|
|
||||||
$userstatic->id=$users['rowid'];
|
$userstatic->id=$users['rowid'];
|
||||||
$userstatic->lastname=$users['lastname'];
|
$userstatic->lastname=$users['lastname'];
|
||||||
$userstatic->firstname=$users['firstname'];
|
$userstatic->firstname=$users['firstname'];
|
||||||
@ -303,9 +312,22 @@ else
|
|||||||
$userstatic->photo=$users['photo'];
|
$userstatic->photo=$users['photo'];
|
||||||
$userstatic->statut=$users['status'];
|
$userstatic->statut=$users['status'];
|
||||||
$userstatic->employee=$users['employee'];
|
$userstatic->employee=$users['employee'];
|
||||||
|
$userstatic->fk_user=$users['fk_user'];
|
||||||
|
|
||||||
|
if ($userstatic->fk_user > 0) $usersupervisor->fetch($userstatic->fk_user);
|
||||||
|
|
||||||
|
print '<tr class="oddeven">';
|
||||||
|
|
||||||
|
// User
|
||||||
|
print '<td>';
|
||||||
print $userstatic->getNomUrl(-1);
|
print $userstatic->getNomUrl(-1);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
|
// Supervisor
|
||||||
|
print '<td>';
|
||||||
|
if ($userstatic->fk_user > 0) print $usersupervisor->getNomUrl(-1);
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
// Amount for each type
|
// Amount for each type
|
||||||
if (count($typeleaves))
|
if (count($typeleaves))
|
||||||
{
|
{
|
||||||
@ -313,6 +335,8 @@ else
|
|||||||
{
|
{
|
||||||
$nbtoshow='';
|
$nbtoshow='';
|
||||||
if ($holiday->getCPforUser($users['rowid'], $val['rowid']) != '') $nbtoshow=price2num($holiday->getCPforUser($users['rowid'], $val['rowid']), 5);
|
if ($holiday->getCPforUser($users['rowid'], $val['rowid']) != '') $nbtoshow=price2num($holiday->getCPforUser($users['rowid'], $val['rowid']), 5);
|
||||||
|
|
||||||
|
//var_dump($users['rowid'].' - '.$val['rowid']);
|
||||||
print '<td style="text-align:center">';
|
print '<td style="text-align:center">';
|
||||||
if ($canedit) print '<input type="text"'.($canedit?'':' disabled="disabled"').' value="'.$nbtoshow.'" name="nb_holiday_'.$val['rowid'].'['.$users['rowid'].']" size="5" style="text-align: center;"/>';
|
if ($canedit) print '<input type="text"'.($canedit?'':' disabled="disabled"').' value="'.$nbtoshow.'" name="nb_holiday_'.$val['rowid'].'['.$users['rowid'].']" size="5" style="text-align: center;"/>';
|
||||||
else print $nbtoshow;
|
else print $nbtoshow;
|
||||||
@ -326,7 +350,7 @@ else
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Note
|
// Note
|
||||||
print '<td style="text-align:center">';
|
print '<td>';
|
||||||
if ($canedit) print '<input type="text"'.($canedit?'':' disabled="disabled"').' class="maxwidthonsmartphone" value="" name="note_holiday['.$users['rowid'].']" size="30"/>';
|
if ($canedit) print '<input type="text"'.($canedit?'':' disabled="disabled"').' class="maxwidthonsmartphone" value="" name="note_holiday['.$users['rowid'].']" size="30"/>';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td>';
|
print '<td>';
|
||||||
|
|||||||
@ -41,6 +41,10 @@ ALTER TABLE llx_website_page ADD COLUMN fk_user_modif integer;
|
|||||||
|
|
||||||
-- For 7.0
|
-- For 7.0
|
||||||
|
|
||||||
|
-- VMYSQL4.1 ALTER TABLE llx_holiday_users DROP PRIMARY KEY;
|
||||||
|
|
||||||
|
ALTER TABLE llx_holiday_users ADD UNIQUE INDEX uk_holiday_users(fk_user, fk_type, nb_holiday);
|
||||||
|
|
||||||
ALTER TABLE llx_product_fournisseur_price ADD COLUMN localtax1_tx double(6,3) DEFAULT 0;
|
ALTER TABLE llx_product_fournisseur_price ADD COLUMN localtax1_tx double(6,3) DEFAULT 0;
|
||||||
ALTER TABLE llx_product_fournisseur_price ADD COLUMN localtax1_type varchar(10) NOT NULL DEFAULT '0';
|
ALTER TABLE llx_product_fournisseur_price ADD COLUMN localtax1_type varchar(10) NOT NULL DEFAULT '0';
|
||||||
ALTER TABLE llx_product_fournisseur_price ADD COLUMN localtax2_tx double(6,3) DEFAULT 0;
|
ALTER TABLE llx_product_fournisseur_price ADD COLUMN localtax2_tx double(6,3) DEFAULT 0;
|
||||||
|
|||||||
19
htdocs/install/mysql/tables/llx_holiday_users.key.sql
Normal file
19
htdocs/install/mysql/tables/llx_holiday_users.key.sql
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
-- ===================================================================
|
||||||
|
-- Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
|
--
|
||||||
|
-- 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
|
||||||
|
-- the Free Software Foundation; either version 3 of the License, or
|
||||||
|
-- (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
|
||||||
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
--
|
||||||
|
-- ===================================================================
|
||||||
|
|
||||||
|
ALTER TABLE llx_holiday_users ADD UNIQUE INDEX uk_holiday_users(fk_user, fk_type, nb_holiday);
|
||||||
@ -20,5 +20,5 @@ CREATE TABLE llx_holiday_users
|
|||||||
(
|
(
|
||||||
fk_user integer NOT NULL,
|
fk_user integer NOT NULL,
|
||||||
fk_type integer NOT NULL,
|
fk_type integer NOT NULL,
|
||||||
nb_holiday real NOT NULL DEFAULT '0'
|
nb_holiday real NOT NULL DEFAULT 0
|
||||||
) ENGINE=innodb;
|
) ENGINE=innodb;
|
||||||
Loading…
Reference in New Issue
Block a user