diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php
index 81b9dbca14b..9b3494c762f 100644
--- a/htdocs/holiday/card.php
+++ b/htdocs/holiday/card.php
@@ -95,36 +95,41 @@ if ($action == 'create')
// If no start date
if (empty($date_debut))
{
- header('Location: '.$_SERVER["PHP_SELF"].'?action=request&error=nodatedebut');
- exit;
+ setEventMessages($langs->trans("NoDateDebut"), null, 'errors');
+ $error++;
+ $action='create';
}
// If no end date
if (empty($date_fin))
{
- header('Location: '.$_SERVER["PHP_SELF"].'?action=request&error=nodatefin');
- exit;
+ setEventMessages($langs->trans("NoDateFin"), null, 'errors');
+ $error++;
+ $action='create';
}
// If start date after end date
if ($date_debut > $date_fin)
{
- header('Location: '.$_SERVER["PHP_SELF"].'?action=request&error=datefin');
- exit;
+ setEventMessages($langs->trans("ErrorEndDateCP"), null, 'errors');
+ $error++;
+ $action='create';
}
// Check if there is already holiday for this period
$verifCP = $cp->verifDateHolidayCP($userID, $date_debut, $date_fin, $halfday);
if (! $verifCP)
{
- header('Location: '.$_SERVER["PHP_SELF"].'?action=request&error=alreadyCP');
- exit;
+ setEventMessages($langs->trans("alreadyCPexist"), null, 'errors');
+ $error++;
+ $action='create';
}
// If there is no Business Days within request
$nbopenedday=num_open_day($date_debut_gmt, $date_fin_gmt, 0, 1, $halfday);
if($nbopenedday < 0.5)
{
- header('Location: '.$_SERVER["PHP_SELF"].'?action=request&error=DureeHoliday');
- exit;
+ setEventMessages($langs->trans("ErrorDureeCP"), null, 'errors');
+ $error++;
+ $action='create';
}
// If no validator designated
@@ -823,10 +828,10 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create
print '
';
// Si la demande ne vient pas de l'agenda
if (! GETPOST('date_debut_')) {
- $form->select_date(-1,'date_debut_');
+ $form->select_date(-1, 'date_debut_', 0, 0, 0, '', 1, 1);
} else {
$tmpdate = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year'));
- $form->select_date($tmpdate,'date_debut_');
+ $form->select_date($tmpdate, 'date_debut_', 0, 0, 0, '', 1, 1);
}
print ' ';
print $form->selectarray('starthalfday', $listhalfday, (GETPOST('starthalfday')?GETPOST('starthalfday'):'morning'));
@@ -839,10 +844,10 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create
print ' | ';
// Si la demande ne vient pas de l'agenda
if (! GETPOST('date_fin_')) {
- $form->select_date(-1,'date_fin_');
+ $form->select_date(-1,'date_fin_', 0, 0, 0, '', 1, 1);
} else {
$tmpdate = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year'));
- $form->select_date($tmpdate,'date_fin_');
+ $form->select_date($tmpdate,'date_fin_', 0, 0, 0, '', 1, 1);
}
print ' ';
print $form->selectarray('endhalfday', $listhalfday, (GETPOST('endhalfday')?GETPOST('endhalfday'):'afternoon'));
@@ -861,7 +866,7 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create
print ' | ';
print '| '.$langs->trans("DescCP").' | ';
print '';
- print '';
+ print '';
print ' | ';
print '
';
diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php
index 35e952a6df7..92a93a0d357 100644
--- a/htdocs/holiday/define_holiday.php
+++ b/htdocs/holiday/define_holiday.php
@@ -106,46 +106,6 @@ if ($action == 'update' && isset($_POST['update_cp']))
if (! $error) setEventMessages('UpdateConfCPOK', '', 'mesgs');
}
-elseif($action == 'add_event')
-{
- $error = 0;
-
- $typeleaves=$holiday->getTypes(1,1);
-
- if(!empty($_POST['list_event']) && $_POST['list_event'] > 0) {
- $event = $_POST['list_event'];
- } else { $error++;
- }
-
- if(!empty($_POST['userCP']) && $_POST['userCP'] > 0) {
- $userCP = $_POST['userCP'];
- } else { $erro++;
- }
-
- if ($error)
- {
- setEventMessages('ErrorAddEventToUserCP', '', 'errors');
- }
- else
- {
- $nb_holiday = $holiday->getCPforUser($userCP);
- $add_holiday = $holiday->getValueEventCp($event);
- $new_holiday = $nb_holiday + $add_holiday;
-
- // add event to existing types of vacation
- foreach ($typeleaves as $key => $leave)
- {
- $vacationTypeID = $leave['rowid'];
-
- // On ajoute la modification dans le LOG
- $holiday->addLogCP($user->id,$userCP, $holiday->getNameEventCp($event),$new_holiday, $vacationTypeID);
-
- $holiday->updateSoldeCP($userCP,$new_holiday, $vacationTypeID);
- }
-
- setEventMessages('AddEventToUserOkCP', '', 'mesgs');
- }
-}
/*
@@ -186,25 +146,6 @@ if (is_numeric($listUsers) && $listUsers < 0)
$var=true;
$i = 0;
-/*
-$cp_events = $holiday->fetchEventsCP();
-if ($cp_events == 1)
-{
- print '
';
-}
-*/
-
$typeleaves=$holiday->getTypes(1,1);
if (count($typeleaves) == 0)