diff --git a/declarationtva_create.php b/declarationtva_create.php index cca2e16..9b9d6dc 100644 --- a/declarationtva_create.php +++ b/declarationtva_create.php @@ -45,25 +45,20 @@ $end_date = GETPOST('end_date', 'alpha'); $error = ''; $success = ''; -if ($action == 'create') { - // Check CSRF token - if (!dolibarr_checkToken()) { - $error = $langs->trans("ErrorCSRFToken"); - } elseif (!empty($start_date) && !empty($end_date)) { - // Create the declaration with dates - $declaration_id = $declarationtva->createDeclarationWithDates($start_date, $end_date, $declaration_name); - - if ($declaration_id > 0) { - $success = $langs->trans("DeclarationCreated"); - // Redirect to view the created declaration - header("Location: declarationtva_view.php?id=" . $declaration_id); - exit; - } else { - $error = $langs->trans("ErrorCreatingDeclaration") . ": " . $declarationtva->error; - } +if ($action == 'create' && !empty($start_date) && !empty($end_date)) { + // Create the declaration with dates + $declaration_id = $declarationtva->createDeclarationWithDates($start_date, $end_date, $declaration_name); + + if ($declaration_id > 0) { + $success = $langs->trans("DeclarationCreated"); + // Redirect to view the created declaration + header("Location: declarationtva_view.php?id=" . $declaration_id); + exit; } else { - $error = $langs->trans("ErrorMissingDates"); + $error = $langs->trans("ErrorCreatingDeclaration") . ": " . $declarationtva->error; } +} elseif ($action == 'create' && (empty($start_date) || empty($end_date))) { + $error = $langs->trans("ErrorMissingDates"); } // Page title