diff --git a/declarationtva_create.php b/declarationtva_create.php index 164c495..2bd27a8 100644 --- a/declarationtva_create.php +++ b/declarationtva_create.php @@ -45,17 +45,24 @@ $end_date = GETPOST('end_date', 'alpha'); $error = ''; $success = ''; -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; +if ($action == 'create') { + // Check CSRF token + if (!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; + } } else { - $error = $langs->trans("ErrorCreatingDeclaration") . ": " . $declarationtva->error; + $error = $langs->trans("ErrorMissingDates"); } } @@ -80,6 +87,7 @@ print '