mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-01-06 09:02:59 +01:00
Fix: Nb of holidays was not using correct user
This commit is contained in:
@@ -30,6 +30,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
|
||||
|
||||
$langs->load('users');
|
||||
$langs->load('holidays');
|
||||
|
||||
// Protection if external user
|
||||
if ($user->societe_id > 0) accessforbidden();
|
||||
@@ -46,6 +51,8 @@ $offset = $conf->liste_limit * $page ;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
|
||||
$id = GETPOST('id');
|
||||
|
||||
$search_ref = GETPOST('search_ref');
|
||||
$month_create = GETPOST('month_create');
|
||||
$year_create = GETPOST('year_create');
|
||||
@@ -72,6 +79,7 @@ $search_statut = GETPOST('select_statut');
|
||||
|
||||
$holiday = new Holiday($db);
|
||||
$holidaystatic=new Holiday($db);
|
||||
$fuser = new User($db);
|
||||
|
||||
// Update sold
|
||||
$holiday->updateSold();
|
||||
@@ -151,28 +159,22 @@ if(!empty($search_statut) && $search_statut != -1) {
|
||||
// Récupération de l'ID de l'utilisateur
|
||||
$user_id = $user->id;
|
||||
|
||||
if ($id > 0)
|
||||
{
|
||||
// Charge utilisateur edite
|
||||
$fuser->fetch($id);
|
||||
$fuser->getrights();
|
||||
$user_id = $fuser->id;
|
||||
}
|
||||
// Récupération des congés payés de l'utilisateur ou de tous les users
|
||||
if (!$user->rights->holiday->lire_tous)
|
||||
if (!$user->rights->holiday->lire_tous || $id > 0)
|
||||
{
|
||||
$holiday_payes = $holiday->fetchByUser($user_id,$order,$filter);
|
||||
$holiday_payes = $holiday->fetchByUser($user_id,$order,$filter);
|
||||
}
|
||||
else
|
||||
{
|
||||
$holiday_payes = $holiday->fetchAll($order,$filter);
|
||||
}
|
||||
|
||||
// Si pas de congés payés
|
||||
if ($holiday_payes == 0)
|
||||
{
|
||||
print_fiche_titre($langs->trans('CPTitreMenu'));
|
||||
|
||||
print '<div class="tabBar">';
|
||||
print '<span>'.$langs->trans('NoCPforUser').'<br /><br />';
|
||||
print '<a href="./fiche.php?mainmenu=agenda&action=request" class="butAction">'.$langs->trans('AddCP').'</a></span>';
|
||||
print '</div>';
|
||||
exit();
|
||||
}
|
||||
|
||||
// Si erreur SQL
|
||||
if ($holiday_payes == '-1')
|
||||
{
|
||||
@@ -189,14 +191,48 @@ if ($holiday_payes == '-1')
|
||||
* Affichage du tableau des congés payés
|
||||
*************************************/
|
||||
|
||||
$var=true; $num = count($holiday->holiday);
|
||||
$html = new Form($db);
|
||||
$htmlother = new FormOther($db);
|
||||
print_barre_liste($langs->trans("ListeCP"), $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, "", $num);
|
||||
$var=true; $num = count($holiday->holiday);
|
||||
$form = new Form($db);
|
||||
$formother = new FormOther($db);
|
||||
|
||||
print '<div class="tabBar">';
|
||||
if ($id > 0)
|
||||
{
|
||||
$head = user_prepare_head($fuser);
|
||||
|
||||
$title = $langs->trans("User");
|
||||
dol_fiche_head($head, 'paidholidays', $title, 0, 'user');
|
||||
|
||||
$nbaquis=$holiday->getCPforUser($user->id);
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Ref
|
||||
print '<tr><td width="25%" valign="top">'.$langs->trans("Ref").'</td>';
|
||||
print '<td colspan="2">';
|
||||
print $form->showrefnav($fuser,'id','',$user->rights->user->user->lire || $user->admin);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Nom
|
||||
print '<tr><td width="25%" valign="top">'.$langs->trans("LastName").'</td>';
|
||||
print '<td colspan="2">'.$fuser->lastname.'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
// Prenom
|
||||
print '<tr><td width="25%" valign="top">'.$langs->trans("FirstName").'</td>';
|
||||
print '<td colspan="2">'.$fuser->firstname.'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
print '</table><br>';
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
print_barre_liste($langs->trans("ListeCP"), $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, "", $num);
|
||||
|
||||
print '<div class="tabBar">';
|
||||
}
|
||||
|
||||
|
||||
$nbaquis=$holiday->getCPforUser($user_id);
|
||||
$nbdeduced=$holiday->getConfCP('nbHolidayDeducted');
|
||||
$nb_holiday = $nbaquis / $nbdeduced;
|
||||
print $langs->trans('SoldeCPUser',round($nb_holiday,2)).($nbdeduced != 1 ? ' ('.$nbaquis.' / '.$nbdeduced.')' : '');
|
||||
@@ -223,13 +259,13 @@ print '<input class="flat" size="4" type="text" name="search_ref" value="'.$sear
|
||||
// DATE CREATE
|
||||
print '<td class="liste_titre" colspan="1" align="center">';
|
||||
print '<input class="flat" type="text" size="1" maxlength="2" name="month_create" value="'.$month_create.'">';
|
||||
$htmlother->select_year($year_create,'year_create',1, $min_year, $max_year);
|
||||
$formother->select_year($year_create,'year_create',1, $min_year, $max_year);
|
||||
print '</td>';
|
||||
|
||||
// UTILISATEUR
|
||||
if($user->rights->holiday->lire_tous) {
|
||||
print '<td class="liste_titre" align="left">';
|
||||
$html->select_users($search_employe,"search_employe",1,"",0,'');
|
||||
$form->select_users($search_employe,"search_employe",1,"",0,'');
|
||||
print '</td>';
|
||||
} else {
|
||||
print '<td class="liste_titre"> </td>';
|
||||
@@ -246,7 +282,7 @@ if($user->rights->holiday->lire_tous){
|
||||
$validator = new UserGroup($db,$idGroupValid);
|
||||
$valideur = $validator->listUsersForGroup();
|
||||
|
||||
$html->select_users($search_valideur,"search_valideur",1,"",0,$valideur,'');
|
||||
$form->select_users($search_valideur,"search_valideur",1,"",0,$valideur,'');
|
||||
print '</td>';
|
||||
} else {
|
||||
print '<td class="liste_titre"> </td>';
|
||||
@@ -255,13 +291,13 @@ if($user->rights->holiday->lire_tous){
|
||||
// DATE DEBUT
|
||||
print '<td class="liste_titre" colspan="1" align="center">';
|
||||
print '<input class="flat" type="text" size="1" maxlength="2" name="month_start" value="'.$month_start.'">';
|
||||
$htmlother->select_year($year_start,'year_start',1, $min_year, $max_year);
|
||||
$formother->select_year($year_start,'year_start',1, $min_year, $max_year);
|
||||
print '</td>';
|
||||
|
||||
// DATE FIN
|
||||
print '<td class="liste_titre" colspan="1" align="center">';
|
||||
print '<input class="flat" type="text" size="1" maxlength="2" name="month_end" value="'.$month_end.'">';
|
||||
$htmlother->select_year($year_end,'year_end',1, $min_year, $max_year);
|
||||
$formother->select_year($year_end,'year_end',1, $min_year, $max_year);
|
||||
print '</td>';
|
||||
|
||||
// DUREE
|
||||
@@ -327,10 +363,13 @@ if($holiday_payes == '2')
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
|
||||
print '<br>';
|
||||
print '<div style="float: right; margin-top: 8px;">';
|
||||
print '<a href="./fiche.php?action=request" class="butAction">'.$langs->trans('AddCP').'</a>';
|
||||
print '</div>';
|
||||
if ($user_id == $user->id)
|
||||
{
|
||||
print '<br>';
|
||||
print '<div style="float: right; margin-top: 8px;">';
|
||||
print '<a href="./fiche.php?action=request" class="butAction">'.$langs->trans('AddCP').'</a>';
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
llxFooter();
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ SendRequestCP=Creating demand for holidays
|
||||
DelayToRequestCP=Applications for holidays must be made at least <b>%s day(s)</b> before them.
|
||||
MenuConfCP=Edit balance of holidays
|
||||
UpdateAllCP=Update the holidays
|
||||
SoldeCPUser=Your balance of holidays is <b>%s</b> days.
|
||||
SoldeCPUser=Holidays balance is <b>%s</b> days.
|
||||
ErrorEndDateCP=You must select an end date greater than the start date.
|
||||
ErrorSQLCreateCP=An SQL error occurred during the creation:
|
||||
ErrorIDFicheCP=An error has occurred, the request for holidays does not exist.
|
||||
|
||||
@@ -26,7 +26,7 @@ SendRequestCP=Envoyer la demande de congés
|
||||
DelayToRequestCP=Les demandes de congés doivent être faites au moins <b>%s jours</b> avant la date</b> de ceux-ci.
|
||||
MenuConfCP=Mettre à jour solde
|
||||
UpdateAllCP=Mettre à jour les congés
|
||||
SoldeCPUser=Votre solde de congés est de <b>%s jours</b>.
|
||||
SoldeCPUser=Solde de congés: <b>%s jours</b>.
|
||||
ErrorEndDateCP=Vous devez choisir une date de fin supérieur à la date de début.
|
||||
ErrorSQLCreateCP=Une erreur SQL est survenue durant la création :
|
||||
ErrorIDFicheCP=Une erreur est survenue, cette demande de congés n'existe pas.
|
||||
|
||||
Reference in New Issue
Block a user