Report Documentation
Report Controller Documentation
File: /controllers/report.php
Purpose: Provides main reporting interface and navigation for comprehensive business reports
Last Updated: December 21, 2024
Total Functions: 2 (main actions)
Lines of Code: ~98
---
๐ Overview
The Report Controller serves as the central hub for the reporting system in the ERP application. It provides functionality for:
- โข Main reporting interface navigation
- โข Report category organization
- โข Report access control and permissions
- โข Integration with various specialized report controllers
- โข Report menu and dashboard display
- โข Centralized report configuration
- โข Cross-module reporting coordination
- โข Report template management
Primary Functions
- โ Display main reporting dashboard
- โ Provide report navigation interface
- โ Handle report category access
- โ Coordinate with specialized report controllers
- โ Manage report permissions and access
- โ Display report menus and categories
- โ Support report template integration
- โ Provide centralized report entry point
Related Controllers
- โข clientReportsController.php - Customer reports
- โข sellbillController.php - Sales reports
- โข buyBillController.php - Purchase reports
- โข storedetailController.php - Inventory reports
- โข incomeController.php - Financial reports
- โข expensesController.php - Expense reports
---
๐๏ธ Database Tables
Referenced Tables (via included controllers)
| Table Name | Purpose | Usage | |
|---|---|---|---|
| **sellbill** | Sales transactions | Sales reports and analytics | |
| **returnsellbill** | Sales returns | Return analysis | |
| **sellbillandrutern** | Combined transactions | Comprehensive sales data | |
| **client** | Customer data | Customer-based reporting | |
| **user** | System users | Report access control | |
| **programsettings** | System configuration | Report settings |
The controller includes several specialized reporting modules:
- โข
reportfunctions.php- Core reporting functions - โข Various DAO classes for data access
- โข Specialized report controllers for specific modules
---
๐ Key Functions
1. Default Action - Main Report Interface
Location: Lines 83-88
Purpose: Display the primary reporting dashboard and navigation
Process Flow:
1. Display header template
2. Show main report interface
3. Display footer template with report flag
Template Structure:
$smarty->display("report/show.html");
2. add - Report Main Dashboard
Location: Lines 90-94
Purpose: Display comprehensive reporting dashboard with authentication
Process Flow:
1. Check user authentication and permissions
2. Display header template
3. Show main reporting dashboard
4. Set offer client flag
5. Display footer template
Authentication Check:
include_once("../public/authentication.php");
Dashboard Display:
$smarty->display("report/showmain.html");
$smarty->assign("offerclient", 1);
---
๐ Workflows
Workflow 1: Report Access and Navigation
---
๐ URL Routes & Actions
| URL Parameter | Function Called | Description | |
|---|---|---|---|
| `do=` (empty) | Default action | Display main report interface | |
| `do=add` | Add/Main | Display authenticated reporting dashboard |
The report controller serves as a navigation hub that redirects to specialized controllers:
Customer Reports:
- โข Client debt reports
- โข Customer transaction history
- โข Payment analysis
- โข Area-based customer summaries
Sales Reports:
- โข Sales performance analysis
- โข Product sales reports
- โข Sales return analysis
- โข Sales representative reports
Inventory Reports:
- โข Stock level reports
- โข Product movement history
- โข Inventory valuation
- โข Reorder point analysis
Financial Reports:
- โข Income statements
- โข Expense analysis
- โข Profit and loss reports
- โข Cash flow analysis
---
๐งฎ Calculation Methods
Report Coordination
The controller acts primarily as a navigation interface and relies on included specialized controllers for actual calculations:
// Core reporting functions included
include("reportfunctions.php");
// Specialized DAOs for data access
require_once('../models/dao/SellbillDAO.class.php');
require_once('../models/dto/Sellbill.class.php');
// ... additional DAO includes
Template Variables
// Flag for report context
$smarty->assign("offerclient", 1);
// Report-specific variables set by individual functions
// (handled by specialized controllers)
---
๐ Security & Permissions
Authentication Requirements
// Authentication required for main dashboard
include_once("../public/authentication.php");
Access Control
- โข Basic authentication check for dashboard access
- โข Individual report controllers handle specific permissions
- โข User role-based report access (handled by included controllers)
Permission Levels
Individual reports may have different permission requirements:
- โข View-only access for basic users
- โข Full access for managers
- โข Administrative reports for admin users
- โข Client-specific data filtering based on user permissions
---
๐ Performance Considerations
Lightweight Controller
- โข Minimal processing in main controller
- โข Heavy lifting delegated to specialized controllers
- โข Efficient navigation structure
Template Management
- โข Separate templates for different report interfaces
- โข Modular design allows for efficient loading
- โข Template caching handled by Smarty framework
Resource Usage
- โข Low overhead for navigation
- โข Resource usage depends on selected reports
- โข Database connections managed by included DAOs
---
๐ Common Issues & Troubleshooting
1. Report Navigation Issues
Issue: Reports not accessible or throwing errors
Cause: Authentication or permission problems
Debug:
// Check session status
if (!isset($_SESSION['userid'])) {
echo "User not logged in";
}
// Verify user permissions
$userData = R::load('user', $_SESSION['userid']);
echo "User permissions: " . print_r($userData->permissions, true);
2. Template Not Found
Issue: Report templates not displaying
Cause: Missing template files or incorrect paths
Debug:
// Check template existence
$template_path = "report/show.html";
if (!file_exists($smarty->template_dir . "/" . $template_path)) {
echo "Template not found: " . $template_path;
}
3. Include File Errors
Issue: Required files not found
Cause: Missing or moved dependency files
Debug:
// Verify include files exist
$required_files = [
"../public/impOpreation.php",
"../public/include_dao.php",
"reportfunctions.php"
];
foreach ($required_files as $file) {
if (!file_exists($file)) {
echo "Missing required file: " . $file . "\n";
}
}
---
๐งช Testing Scenarios
Test Case 1: Basic Navigation
1. Access report controller without parameters
2. Verify main interface displays
3. Check navigation elements present
4. Test links to specialized reports
Test Case 2: Authenticated Dashboard
1. Login with valid user credentials
2. Access report controller with do=add
3. Verify dashboard displays correctly
4. Check user-specific report options
5. Test permission-based access
Test Case 3: Report Integration
1. Navigate to customer reports
2. Verify redirect to clientReportsController
3. Test parameter passing between controllers
4. Check report generation functions
Test Case 4: Permission Testing
1. Test with different user permission levels
2. Verify appropriate reports are accessible
3. Check restricted report access
4. Test admin vs regular user access
---
๐ Related Documentation
- โข CLAUDE.md - PHP 8.2 migration guide
- โข clientReportsController.md - Customer reporting
- โข sellbillController.php - Sales reporting
- โข buyBillController.php - Purchase reporting
- โข Database Schema Documentation - Table relationships
- โข User Permission System - Access control documentation
---
๐ง Configuration & Setup
Required Files
/controllers/report.php - Main controller
/controllers/reportfunctions.php - Core report functions
/views/report/show.html - Main interface template
/views/report/showmain.html - Dashboard template
/models/dao/ - Data access objects
/models/dto/ - Data transfer objects
Template Variables
// Available in report templates
$smarty->assign("offerclient", 1); // Client report flag
// User session variables
$_SESSION['userid'] // Current user ID
$_SESSION['user_permissions'] // User permission level
Include Dependencies
The controller includes multiple specialized reporting components:
- โข Core reporting functions
- โข Database access layers
- โข Specialized report controllers
- โข Template management system
---
๐ Future Enhancements
Potential Improvements
1. Report Scheduling: Add automated report generation
2. Export Options: PDF, Excel, CSV export capabilities
3. Report Caching: Cache frequently accessed reports
4. Custom Reports: User-defined report builder
5. Dashboard Widgets: Interactive report summaries
6. Mobile Interface: Responsive report viewing
7. Real-time Reports: Live data updates
8. Report Sharing: User collaboration features
Architecture Considerations
- โข Implement report caching for performance
- โข Add report queue system for large reports
- โข Consider microservices for heavy reporting tasks
- โข Implement report versioning and history
- โข Add report access logging and analytics
---
Documented By: AI Assistant
Review Status: โ Complete
Next Review: When reporting features are expanded