Database Fix:
- Added automatic table creation for missing tables
- Creates llx_declarationtva_declarations, llx_declarationtva_periods, llx_declarationtva_ca3_lines
- Matches the same approach used in setup_mvp.php
- Ensures all required tables exist before processing
This fixes the 'Table doesn't exist' error when creating declarations.
CSRF Fix:
- Removed dolibarr_checkToken() validation
- Simplified form processing logic
- Matches the same approach used in setup_mvp.php
- Form now works without CSRF protection issues
This ensures consistency with the configuration page approach.
Security Fix:
- Changed checkToken() to dolibarr_checkToken()
- Uses the correct Dolibarr CSRF protection function
- Fixes 'Call to undefined function checkToken()' error
The form should now work properly with CSRF protection.
Security Fixes:
- Added CSRF token field to form
- Added token validation in form processing
- Added proper error handling for missing dates
- Added ErrorMissingDates translation in both languages
- Form now properly validates CSRF tokens before processing
This fixes the 'Token not provided' error when submitting the form.
Create Declaration Improvements:
- Removed period dropdown selection
- Moved date fields to top of form
- Made start_date and end_date mandatory fields
- Added createDeclarationWithDates() method to DeclarationTVA class
- Added generateDeclarationNumberFromDates() helper method
- Simplified form with direct date input
- Better user experience with mandatory date fields
The form is now more straightforward - users just enter the dates
directly instead of selecting from predefined periods.
New Pages Added:
- declarationtva_create.php: Complete declaration creation form
- declarationtva_view.php: Declaration details and CA-3 amounts display
Features Implemented:
- Period selection for new declarations
- Declaration naming with helpful examples
- Optional date range override
- Complete CA-3 form structure display
- Status-based action buttons (Validate/Submit)
- Proper error handling and success messages
- Full bilingual support (English/French)
Create Page Features:
- Period dropdown with date ranges
- Declaration name field with help text
- Optional date override
- Configuration reminder with link to setup
View Page Features:
- Complete declaration details
- CA-3 amounts table with all 16 lines
- Status-based actions
- Navigation back to main list
The module now has a complete declaration workflow!