diff --git a/htdocs/holiday/admin/holiday.php b/htdocs/holiday/admin/holiday.php
index dbb8dc67d74..c7ecb17f1da 100644
--- a/htdocs/holiday/admin/holiday.php
+++ b/htdocs/holiday/admin/holiday.php
@@ -32,6 +32,8 @@ require_once DOL_DOCUMENT_ROOT. '/user/class/user.class.php';
require_once DOL_DOCUMENT_ROOT. '/user/class/usergroup.class.php';
$action=GETPOST('action');
+$optName=GETPOST('optName');
+$optValue=GETPOST('optValue');
$langs->load("admin");
$langs->load("holiday");
@@ -155,7 +157,6 @@ if ($action == "add")
$message.= '
'.$langs->trans('AddCPforUsers').'
';
}
-
dol_htmloutput_mesg($message);
@@ -163,45 +164,41 @@ if ($action == "add")
}
elseif ($action == 'create_event')
{
- $error = false;
+ $error = 0;
- if (!empty($_POST['optName']))
+ $optName = trim($optName);
+ $optValue = price2num($optValue,2);
+
+ if (! $optName)
{
- $optName = trim($_POST['optName']);
- } else {
- $error = true;
+ $message=''.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Name")).'
';
+ $error++;
}
-
- if (!empty($_POST['optValue']))
+ if (! $optValue > 0)
{
- $optValue = price2num($_POST['optValue'],2);
- } else {
- $error = true;
+ $message=''.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Value")).'
';
+ $error++;
}
$cp->optName = $optName;
$cp->optValue = $optValue;
- if($error)
- {
- $message = 'ErrorCreateEventCP';
- }
- else
+ if (! $error)
{
$result = $cp->createEventCP($user);
-
if($result > 0)
{
$message = 'OkCreateEventCP';
+ $optName='';
+ $optValue='';
}
else
{
- $message = 'ErrorCreateEventCP';
+ $message = ''.$cp->error.'
';
}
}
dol_htmloutput_mesg($message);
-
}
elseif($action == 'event' && isset($_POST['update_event']))
{
@@ -210,10 +207,10 @@ elseif($action == 'event' && isset($_POST['update_event']))
$eventId = array_keys($_POST['update_event']);
$eventId = $eventId[0];
- $eventName = $_POST['optName'];
+ $eventName = $optName;
$eventName = $eventName[$eventId];
- $eventValue = $_POST['optValue'];
+ $eventValue = $optValue;
$eventValue = $eventValue[$eventId];
if(!empty($eventName)) {
@@ -242,7 +239,6 @@ elseif($action == 'event' && isset($_POST['update_event']))
}
dol_htmloutput_mesg($message);
-
}
elseif($action && isset($_POST['delete_event']))
{
@@ -353,16 +349,14 @@ if($cp_events == 1) {
print '