hasRight("declarationtva", "declarationtva", "write")) { accessforbidden(); } // Load language files $langs->load("declarationtva@declarationtva"); // Initialize objects $declarationtva = new DeclarationTVA($db, $conf->entity); $config = new DeclarationTVA_Config($db, $conf->entity); $period = new DeclarationTVA_Period($db, $conf->entity); // Handle form submission $action = GETPOST('action', 'alpha'); $declaration_name = GETPOST('declaration_name', 'alpha'); $start_date = GETPOST('start_date', 'alpha'); $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; } else { $error = $langs->trans("ErrorCreatingDeclaration") . ": " . $declarationtva->error; } } elseif ($action == 'create' && (empty($start_date) || empty($end_date))) { $error = $langs->trans("ErrorMissingDates"); } // Page title $title = $langs->trans("CreateDeclaration"); llxHeader('', $title); // Print page header print load_fiche_titre($title, '', 'title_accountancy'); // Display messages if ($error) { setEventMessages($error, null, 'errors'); } if ($success) { setEventMessages($success, null, 'mesgs'); } // Print form print '