Fix: Nb of holidays was not using correct user
This commit is contained in:
parent
b0695d3bbb
commit
d6e907b69b
@ -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/user.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.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.'/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
|
// Protection if external user
|
||||||
if ($user->societe_id > 0) accessforbidden();
|
if ($user->societe_id > 0) accessforbidden();
|
||||||
@ -46,6 +51,8 @@ $offset = $conf->liste_limit * $page ;
|
|||||||
$pageprev = $page - 1;
|
$pageprev = $page - 1;
|
||||||
$pagenext = $page + 1;
|
$pagenext = $page + 1;
|
||||||
|
|
||||||
|
$id = GETPOST('id');
|
||||||
|
|
||||||
$search_ref = GETPOST('search_ref');
|
$search_ref = GETPOST('search_ref');
|
||||||
$month_create = GETPOST('month_create');
|
$month_create = GETPOST('month_create');
|
||||||
$year_create = GETPOST('year_create');
|
$year_create = GETPOST('year_create');
|
||||||
@ -72,6 +79,7 @@ $search_statut = GETPOST('select_statut');
|
|||||||
|
|
||||||
$holiday = new Holiday($db);
|
$holiday = new Holiday($db);
|
||||||
$holidaystatic=new Holiday($db);
|
$holidaystatic=new Holiday($db);
|
||||||
|
$fuser = new User($db);
|
||||||
|
|
||||||
// Update sold
|
// Update sold
|
||||||
$holiday->updateSold();
|
$holiday->updateSold();
|
||||||
@ -151,8 +159,15 @@ if(!empty($search_statut) && $search_statut != -1) {
|
|||||||
// Récupération de l'ID de l'utilisateur
|
// Récupération de l'ID de l'utilisateur
|
||||||
$user_id = $user->id;
|
$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
|
// 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);
|
||||||
}
|
}
|
||||||
@ -160,19 +175,6 @@ else
|
|||||||
{
|
{
|
||||||
$holiday_payes = $holiday->fetchAll($order,$filter);
|
$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
|
// Si erreur SQL
|
||||||
if ($holiday_payes == '-1')
|
if ($holiday_payes == '-1')
|
||||||
{
|
{
|
||||||
@ -190,13 +192,47 @@ if ($holiday_payes == '-1')
|
|||||||
*************************************/
|
*************************************/
|
||||||
|
|
||||||
$var=true; $num = count($holiday->holiday);
|
$var=true; $num = count($holiday->holiday);
|
||||||
$html = new Form($db);
|
$form = new Form($db);
|
||||||
$htmlother = new FormOther($db);
|
$formother = new FormOther($db);
|
||||||
|
|
||||||
|
if ($id > 0)
|
||||||
|
{
|
||||||
|
$head = user_prepare_head($fuser);
|
||||||
|
|
||||||
|
$title = $langs->trans("User");
|
||||||
|
dol_fiche_head($head, 'paidholidays', $title, 0, 'user');
|
||||||
|
|
||||||
|
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_barre_liste($langs->trans("ListeCP"), $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, "", $num);
|
||||||
|
|
||||||
print '<div class="tabBar">';
|
print '<div class="tabBar">';
|
||||||
|
}
|
||||||
|
|
||||||
$nbaquis=$holiday->getCPforUser($user->id);
|
|
||||||
|
$nbaquis=$holiday->getCPforUser($user_id);
|
||||||
$nbdeduced=$holiday->getConfCP('nbHolidayDeducted');
|
$nbdeduced=$holiday->getConfCP('nbHolidayDeducted');
|
||||||
$nb_holiday = $nbaquis / $nbdeduced;
|
$nb_holiday = $nbaquis / $nbdeduced;
|
||||||
print $langs->trans('SoldeCPUser',round($nb_holiday,2)).($nbdeduced != 1 ? ' ('.$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
|
// DATE CREATE
|
||||||
print '<td class="liste_titre" colspan="1" align="center">';
|
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.'">';
|
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>';
|
print '</td>';
|
||||||
|
|
||||||
// UTILISATEUR
|
// UTILISATEUR
|
||||||
if($user->rights->holiday->lire_tous) {
|
if($user->rights->holiday->lire_tous) {
|
||||||
print '<td class="liste_titre" align="left">';
|
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>';
|
print '</td>';
|
||||||
} else {
|
} else {
|
||||||
print '<td class="liste_titre"> </td>';
|
print '<td class="liste_titre"> </td>';
|
||||||
@ -246,7 +282,7 @@ if($user->rights->holiday->lire_tous){
|
|||||||
$validator = new UserGroup($db,$idGroupValid);
|
$validator = new UserGroup($db,$idGroupValid);
|
||||||
$valideur = $validator->listUsersForGroup();
|
$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>';
|
print '</td>';
|
||||||
} else {
|
} else {
|
||||||
print '<td class="liste_titre"> </td>';
|
print '<td class="liste_titre"> </td>';
|
||||||
@ -255,13 +291,13 @@ if($user->rights->holiday->lire_tous){
|
|||||||
// DATE DEBUT
|
// DATE DEBUT
|
||||||
print '<td class="liste_titre" colspan="1" align="center">';
|
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.'">';
|
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>';
|
print '</td>';
|
||||||
|
|
||||||
// DATE FIN
|
// DATE FIN
|
||||||
print '<td class="liste_titre" colspan="1" align="center">';
|
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.'">';
|
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>';
|
print '</td>';
|
||||||
|
|
||||||
// DUREE
|
// DUREE
|
||||||
@ -327,10 +363,13 @@ if($holiday_payes == '2')
|
|||||||
print '</table>';
|
print '</table>';
|
||||||
print '</form>';
|
print '</form>';
|
||||||
|
|
||||||
|
if ($user_id == $user->id)
|
||||||
|
{
|
||||||
print '<br>';
|
print '<br>';
|
||||||
print '<div style="float: right; margin-top: 8px;">';
|
print '<div style="float: right; margin-top: 8px;">';
|
||||||
print '<a href="./fiche.php?action=request" class="butAction">'.$langs->trans('AddCP').'</a>';
|
print '<a href="./fiche.php?action=request" class="butAction">'.$langs->trans('AddCP').'</a>';
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
llxFooter();
|
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.
|
DelayToRequestCP=Applications for holidays must be made at least <b>%s day(s)</b> before them.
|
||||||
MenuConfCP=Edit balance of holidays
|
MenuConfCP=Edit balance of holidays
|
||||||
UpdateAllCP=Update the 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.
|
ErrorEndDateCP=You must select an end date greater than the start date.
|
||||||
ErrorSQLCreateCP=An SQL error occurred during the creation:
|
ErrorSQLCreateCP=An SQL error occurred during the creation:
|
||||||
ErrorIDFicheCP=An error has occurred, the request for holidays does not exist.
|
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.
|
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
|
MenuConfCP=Mettre à jour solde
|
||||||
UpdateAllCP=Mettre à jour les congés
|
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.
|
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 :
|
ErrorSQLCreateCP=Une erreur SQL est survenue durant la création :
|
||||||
ErrorIDFicheCP=Une erreur est survenue, cette demande de congés n'existe pas.
|
ErrorIDFicheCP=Une erreur est survenue, cette demande de congés n'existe pas.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user