FIX Type of leave request is required

This commit is contained in:
Laurent Destailleur 2015-10-17 01:32:05 +02:00
parent 4e3ee259b0
commit a2382bdde3

View File

@ -84,20 +84,26 @@ if ($action == 'create')
$description = trim(GETPOST('description')); $description = trim(GETPOST('description'));
$userID = GETPOST('userID'); $userID = GETPOST('userID');
// If no start date
if ($type <= 0)
{
setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), 'errors');
$error++;
$action='create';
}
// If no start date // If no start date
if (empty($date_debut)) if (empty($date_debut))
{ {
header('Location: card.php?action=request&error=nodatedebut'); header('Location: card.php?action=request&error=nodatedebut');
exit; exit;
} }
// If no end date // If no end date
if (empty($date_fin)) if (empty($date_fin))
{ {
header('Location: card.php?action=request&error=nodatefin'); header('Location: card.php?action=request&error=nodatefin');
exit; exit;
} }
// If start date after end date // If start date after end date
if ($date_debut > $date_fin) if ($date_debut > $date_fin)
{ {
@ -128,22 +134,27 @@ if ($action == 'create')
exit; exit;
} }
$cp->fk_user = $userid; $result = 0;
$cp->description = $description;
$cp->date_debut = $date_debut;
$cp->date_fin = $date_fin;
$cp->fk_validator = $valideur;
$cp->halfday = $halfday;
$cp->fk_type = $type;
$verif = $cp->create($user); if (! $error)
{
$cp->fk_user = $userid;
$cp->description = $description;
$cp->date_debut = $date_debut;
$cp->date_fin = $date_fin;
$cp->fk_validator = $valideur;
$cp->halfday = $halfday;
$cp->fk_type = $type;
$result = $cp->create($user);
}
// If no SQL error we redirect to the request card // If no SQL error we redirect to the request card
if ($verif > 0) if ($result > 0)
{ {
$db->commit(); $db->commit();
header('Location: card.php?id='.$verif); header('Location: card.php?id='.$result);
exit; exit;
} }
else else
@ -151,7 +162,7 @@ if ($action == 'create')
$db->rollback(); $db->rollback();
// Otherwise we display the request form with the SQL error message // Otherwise we display the request form with the SQL error message
header('Location: card.php?action=request&error=SQL_Create&msg='.$cp->error); header('Location: card.php?action=request');
exit; exit;
} }
} }