Fix: Some fix into holiday module
This commit is contained in:
parent
bda39f25bf
commit
2f5709e3cb
@ -236,13 +236,15 @@ if ($action == 'confirm_delete' && $_GET['confirm'] == 'yes')
|
|||||||
if($user->rights->holiday->delete)
|
if($user->rights->holiday->delete)
|
||||||
{
|
{
|
||||||
$cp = new Holiday($db);
|
$cp = new Holiday($db);
|
||||||
$cp->fetch($_GET['id']);
|
$cp->fetch($id);
|
||||||
|
|
||||||
// Si c'est bien un brouillon
|
// Si c'est bien un brouillon
|
||||||
if($cp->statut == 1) {
|
if ($cp->statut == 1)
|
||||||
|
{
|
||||||
// Si l'utilisateur à le droit de lire cette demande, il peut la supprimer
|
// Si l'utilisateur à le droit de lire cette demande, il peut la supprimer
|
||||||
if($user->id == $cp->fk_user || $user->rights->holiday->lire_tous) {
|
if ($user->id == $cp->fk_user || $user->rights->holiday->lire_tous)
|
||||||
$cp->delete($_GET['id']);
|
{
|
||||||
|
$cp->delete($id);
|
||||||
header('Location: index.php');
|
header('Location: index.php');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@ -257,12 +259,10 @@ if ($action == 'confirm_delete' && $_GET['confirm'] == 'yes')
|
|||||||
if ($action == 'confirm_send')
|
if ($action == 'confirm_send')
|
||||||
{
|
{
|
||||||
$cp = new Holiday($db);
|
$cp = new Holiday($db);
|
||||||
$cp->fetch($_GET['id']);
|
$cp->fetch($id);
|
||||||
|
|
||||||
$userID = $user->id;
|
|
||||||
|
|
||||||
// Si brouillon et créateur
|
// Si brouillon et créateur
|
||||||
if($cp->statut == 1 && $userID == $cp->fk_user)
|
if($cp->statut == 1 && $user->id == $cp->fk_user)
|
||||||
{
|
{
|
||||||
$cp->statut = 2;
|
$cp->statut = 2;
|
||||||
|
|
||||||
@ -351,12 +351,10 @@ if ($action == 'confirm_send')
|
|||||||
if($action == 'confirm_valid')
|
if($action == 'confirm_valid')
|
||||||
{
|
{
|
||||||
$cp = new Holiday($db);
|
$cp = new Holiday($db);
|
||||||
$cp->fetch($_GET['id']);
|
$cp->fetch($id);
|
||||||
|
|
||||||
$userID = $user->id;
|
|
||||||
|
|
||||||
// Si statut en attente de validation et valideur = utilisateur
|
// Si statut en attente de validation et valideur = utilisateur
|
||||||
if($cp->statut == 2 && $userID == $cp->fk_validator)
|
if($cp->statut == 2 && $user->id == $cp->fk_validator)
|
||||||
{
|
{
|
||||||
|
|
||||||
$cp->date_valid = dol_now();
|
$cp->date_valid = dol_now();
|
||||||
@ -375,7 +373,7 @@ if($action == 'confirm_valid')
|
|||||||
$newSolde = $soldeActuel - ($nbJour*$cp->getConfCP('nbHolidayDeducted'));
|
$newSolde = $soldeActuel - ($nbJour*$cp->getConfCP('nbHolidayDeducted'));
|
||||||
|
|
||||||
// On ajoute la modification dans le LOG
|
// On ajoute la modification dans le LOG
|
||||||
$cp->addLogCP($userID,$cp->fk_user,'Event : '.$langs->transnoentitiesnoconv("Holiday"),$newSolde);
|
$cp->addLogCP($user->id, $cp->fk_user, 'Event : '.$langs->transnoentitiesnoconv("Holiday"), $newSolde);
|
||||||
|
|
||||||
// Mise à jour du solde
|
// Mise à jour du solde
|
||||||
$cp->updateSoldeCP($cp->fk_user,$newSolde);
|
$cp->updateSoldeCP($cp->fk_user,$newSolde);
|
||||||
@ -433,11 +431,9 @@ if ($action == 'confirm_refuse')
|
|||||||
$cp = new Holiday($db);
|
$cp = new Holiday($db);
|
||||||
$cp->fetch($_GET['id']);
|
$cp->fetch($_GET['id']);
|
||||||
|
|
||||||
$userID = $user->id;
|
|
||||||
|
|
||||||
// Si statut en attente de validation et valideur = utilisateur
|
// Si statut en attente de validation et valideur = utilisateur
|
||||||
if($cp->statut == 2 && $userID == $cp->fk_validator) {
|
if($cp->statut == 2 && $user->id == $cp->fk_validator)
|
||||||
|
{
|
||||||
$cp->date_refuse = date('Y-m-d H:i:s', time());
|
$cp->date_refuse = date('Y-m-d H:i:s', time());
|
||||||
$cp->fk_user_refuse = $user->id;
|
$cp->fk_user_refuse = $user->id;
|
||||||
$cp->statut = 5;
|
$cp->statut = 5;
|
||||||
@ -500,15 +496,13 @@ if ($action == 'confirm_refuse')
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Si Validation de la demande
|
// Si Validation de la demande
|
||||||
if ($action == 'confirm_cancel' && $_GET['confirm'] == 'yes')
|
if ($action == 'confirm_cancel' && GETPOST('confirm') == 'yes')
|
||||||
{
|
{
|
||||||
$cp = new Holiday($db);
|
$cp = new Holiday($db);
|
||||||
$cp->fetch($_GET['id']);
|
$cp->fetch($_GET['id']);
|
||||||
|
|
||||||
$userID = $user->id;
|
|
||||||
|
|
||||||
// Si statut en attente de validation et valideur = utilisateur
|
// Si statut en attente de validation et valideur = utilisateur
|
||||||
if ($cp->statut == 2 && $userID == $cp->fk_validator)
|
if ($cp->statut == 2 && ($user->id == $cp->fk_validator || $user->id == $cp->fk_user))
|
||||||
{
|
{
|
||||||
$cp->date_cancel = dol_now();
|
$cp->date_cancel = dol_now();
|
||||||
$cp->fk_user_cancel = $user->id;
|
$cp->fk_user_cancel = $user->id;
|
||||||
@ -761,9 +755,6 @@ else
|
|||||||
$userRequest = new User($db);
|
$userRequest = new User($db);
|
||||||
$userRequest->fetch($cp->fk_user);
|
$userRequest->fetch($cp->fk_user);
|
||||||
|
|
||||||
// Utilisateur connecté
|
|
||||||
$userID = $user->id;
|
|
||||||
|
|
||||||
//print_fiche_titre($langs->trans('TitreRequestCP'));
|
//print_fiche_titre($langs->trans('TitreRequestCP'));
|
||||||
|
|
||||||
// Si il y a une erreur
|
// Si il y a une erreur
|
||||||
@ -816,21 +807,21 @@ else
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Si envoi en validation
|
// Si envoi en validation
|
||||||
if ($action == 'sendToValidate' && $cp->statut == 1 && $userID == $cp->fk_user)
|
if ($action == 'sendToValidate' && $cp->statut == 1 && $user->id == $cp->fk_user)
|
||||||
{
|
{
|
||||||
$ret=$form->form_confirm("fiche.php?id=".$id,$langs->trans("TitleToValidCP"),$langs->trans("ConfirmToValidCP"),"confirm_send", '', 1, 1);
|
$ret=$form->form_confirm("fiche.php?id=".$id,$langs->trans("TitleToValidCP"),$langs->trans("ConfirmToValidCP"),"confirm_send", '', 1, 1);
|
||||||
if ($ret == 'html') print '<br />';
|
if ($ret == 'html') print '<br />';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Si validation de la demande
|
// Si validation de la demande
|
||||||
if ($action == 'valid' && $cp->statut == 2 && $userID == $cp->fk_validator)
|
if ($action == 'valid' && $cp->statut == 2 && $user->id == $cp->fk_validator)
|
||||||
{
|
{
|
||||||
$ret=$form->form_confirm("fiche.php?id=".$id,$langs->trans("TitleValidCP"),$langs->trans("ConfirmValidCP"),"confirm_valid", '', 1, 1);
|
$ret=$form->form_confirm("fiche.php?id=".$id,$langs->trans("TitleValidCP"),$langs->trans("ConfirmValidCP"),"confirm_valid", '', 1, 1);
|
||||||
if ($ret == 'html') print '<br />';
|
if ($ret == 'html') print '<br />';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Si refus de la demande
|
// Si refus de la demande
|
||||||
if ($action == 'refuse' && $cp->statut == 2 && $userID == $cp->fk_validator)
|
if ($action == 'refuse' && $cp->statut == 2 && $user->id == $cp->fk_validator)
|
||||||
{
|
{
|
||||||
$array_input = array(array('type'=>"text",'label'=>"Entrez ci-dessous un motif de refus :",'name'=>"detail_refuse",'size'=>"50",'value'=>""));
|
$array_input = array(array('type'=>"text",'label'=>"Entrez ci-dessous un motif de refus :",'name'=>"detail_refuse",'size'=>"50",'value'=>""));
|
||||||
$ret=$form->form_confirm("fiche.php?id=".$id."&action=confirm_refuse", $langs->trans("TitleRefuseCP"), "", "confirm_refuse", $array_input, 1, 0);
|
$ret=$form->form_confirm("fiche.php?id=".$id."&action=confirm_refuse", $langs->trans("TitleRefuseCP"), "", "confirm_refuse", $array_input, 1, 0);
|
||||||
@ -838,7 +829,7 @@ else
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Si annulation de la demande
|
// Si annulation de la demande
|
||||||
if ($action == 'cancel' && $cp->statut == 2 && $userID == $cp->fk_validator)
|
if ($action == 'cancel' && $cp->statut == 2 && ($user->id == $cp->fk_validator || $user->id == $cp->fk_user))
|
||||||
{
|
{
|
||||||
$ret=$form->form_confirm("fiche.php?id=".$id,$langs->trans("TitleCancelCP"),$langs->trans("ConfirmCancelCP"),"confirm_cancel", '', 1, 1);
|
$ret=$form->form_confirm("fiche.php?id=".$id,$langs->trans("TitleCancelCP"),$langs->trans("ConfirmCancelCP"),"confirm_cancel", '', 1, 1);
|
||||||
if ($ret == 'html') print '<br />';
|
if ($ret == 'html') print '<br />';
|
||||||
@ -1036,16 +1027,16 @@ else
|
|||||||
print '<a href="fiche.php?id='.$_GET['id'].'&action=delete" class="butActionDelete">'.$langs->trans("DeleteCP").'</a>';
|
print '<a href="fiche.php?id='.$_GET['id'].'&action=delete" class="butActionDelete">'.$langs->trans("DeleteCP").'</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Si le statut est en attente de validation et que le valideur est connecté
|
if ($user->id == $cp->fk_validator && $cp->statut == 2)
|
||||||
if ($userID == $cp->fk_validator && $cp->statut == 2)
|
|
||||||
{
|
{
|
||||||
print '<a href="fiche.php?id='.$_GET['id'].'&action=valid" class="butAction">'.$langs->trans("Approve").'</a>';
|
print '<a href="fiche.php?id='.$_GET['id'].'&action=valid" class="butAction">'.$langs->trans("Approve").'</a>';
|
||||||
print '<a href="fiche.php?id='.$_GET['id'].'&action=refuse" class="butAction">'.$langs->trans("ActionRefuseCP").'</a>';
|
print '<a href="fiche.php?id='.$_GET['id'].'&action=refuse" class="butAction">'.$langs->trans("ActionRefuseCP").'</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($userID == $cp->fk_validator && $cp->statut == 2) || ($cp->date_debut > dol_now()) || $user->admin)
|
if (($user->id == $cp->fk_validator || $user->id == $cp->fk_user) && $cp->statut == 2)
|
||||||
{
|
{
|
||||||
print '<a href="fiche.php?id='.$_GET['id'].'&action=cancel" class="butAction">'.$langs->trans("ActionCancelCP").'</a>';
|
if (($cp->date_debut > dol_now()) || $user->admin) print '<a href="fiche.php?id='.$_GET['id'].'&action=cancel" class="butAction">'.$langs->trans("ActionCancelCP").'</a>';
|
||||||
|
else print '<a href="#" class="butActionRefused" title="'.$langs->trans("HolidayStarted").'">'.$langs->trans("ActionCancelCP").'</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user