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') { // 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; } } else { $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 '
'; print '
' . $langs->trans("DeclarationDetails") . '
'; print '
'; print ''; print ''; print ''; // Date range (now mandatory and at the top) print ''; print ''; print ''; print ''; // Declaration name print ''; print ''; print ''; print ''; print '
' . $langs->trans("SelectPeriod") . ''; print ''; print ' - '; print ''; print '
' . $langs->trans("DateRangeHelp") . ''; print '
' . $langs->trans("DeclarationName") . ''; print ''; print '
' . $langs->trans("DeclarationNameHelp") . ''; print '
'; // Buttons print '
'; print ''; print '' . $langs->trans("Cancel") . ''; print '
'; print '
'; print '
'; // Print configuration section print '
'; print '
' . $langs->trans("DeclarationTVAConfiguration") . '
'; print '
'; print $langs->trans("ConfigurationInfo") . ' '; print '' . $langs->trans("ConfigurePCGAccounts") . ''; print '
'; print '
'; // Print footer llxFooter(); ?>