Restauranttable Documentation
Restaurant Table Controller Documentation
File: /controllers/restauranttable.php
Purpose: Manages restaurant tables, dining arrangements, and special service types (takeaway/delivery)
Last Updated: December 19, 2024
Total Functions: 6
Lines of Code: 223
---
๐ Overview
The Restaurant Table Controller manages individual table configurations within restaurant halls. It handles:
- โข Creating and managing restaurant tables
- โข Automatic takeaway and delivery table setup
- โข Table occupancy status tracking
- โข Table-hall relationships and assignments
- โข Special table types (-1 for takeaway, -2 for delivery)
- โข Integration with PlayStation gaming stations
Primary Functions
- โ Create new restaurant tables
- โ Edit existing table configurations
- โ Delete tables (hard delete)
- โ View all tables with hall information
- โ Automatic special table management (takeaway/delivery)
- โ Table occupancy tracking
- โ Hall-based table organization
Related Controllers
- โข restauranthall.php - Hall management for table assignment
- โข sellbillController.php - Order processing for tables
- โข restaurantplaystation.php - Gaming station integration
- โข restaurantKitchenPrinter.php - Kitchen order printing
- โข userController.php - User management
- โข productController.php - Menu item management
---
๐๏ธ Database Tables
Primary Tables (Direct Operations)
| Table Name | Purpose | Key Columns |
|---|---|---|
| **restauranttable** | Main table configuration | id, name, hallid, beingUsed, userId, sysdate, del |
| Table Name | Purpose | Relationship | |
|---|---|---|---|
| **restauranthall** | Hall master data | restauranttable.hallid โ restauranthall.id | |
| **restaurantplaystation** | Gaming stations | References table via tableId | |
| **sellbill** | Order processing | Links to table for order management | |
| **youtubelink** | Entertainment links | Display integration |
| Table ID | Purpose | Hall ID | Name | |
|---|---|---|---|---|
| **-1** | Takeaway orders | -1 | 'ุชูู ุฃูุงู' (Arabic for Takeaway) | |
| **-2** | Delivery orders | -2 | 'ุฏูููุฑู' (Arabic for Delivery) |
restauranttable columns:
- โข
id- Primary key (special IDs: -1 takeaway, -2 delivery) - โข
name- Table identifier/number - โข
hallid- Foreign key to restauranthall (or special hall IDs) - โข
beingUsed- Occupancy status (0=available, 1=occupied) - โข
userId- Creator user ID - โข
sysdate- Creation date - โข
del- Deletion flag (0=active, 1=deleted)
---
๐ง Key Functions
1. add()
Purpose: Create a new restaurant table with automatic special table setup
Called By: Form submission with ?do=add
Line: 132-174
Parameters (via $_POST):
- โข
name- Table name/number - โข
hallid- Hall assignment
Process Flow:
Code Example:
// Auto-create takeaway table if missing
$takeAway = $restaurantTableDAO->load(-1);
if (!isset($takeAway->id) || $takeAway->id != -1) {
$restaurantTable->id = -1;
$restaurantTable->name = 'ุชูู ุฃูุงู';
$restaurantTable->hallid = -1;
$restaurantTable->beingUsed = 0;
$restaurantTableEX->insertWithId($restaurantTable);
}
2. show()
Purpose: Retrieve all restaurant tables
Called By: ?do=show
Line: 176-182
Returns: Array of all restaurant table objects
Process Flow:
3. edit()
Purpose: Load table data for editing
Called By: ?do=edit&id=X
Line: 184-191
Parameters:
- โข
id(GET) - Table ID to edit
Returns: Table object with current configuration
Process Flow:
4. update()
Purpose: Update existing table configuration
Called By: Form submission with ?do=update
Line: 193-209
Parameters (via $_POST):
- โข
id- Table ID to update - โข
name- Updated table name - โข
hallid- Updated hall assignment
Process Flow:
5. delete()
Purpose: Delete a restaurant table
Called By: ?do=delete&id=X
Line: 211-222
Parameters:
- โข
id(GET) - Table ID to delete
Process Flow:
Note: Includes commented code for special table cleanup logic
6. Standard Controller Actions
Purpose: Handle routing and display
Lines: 53-123
Actions:
- โข Default (empty do) - Show add form with halls
- โข
add- Process new table creation - โข
show- Display all tables with YouTube links - โข
edit- Show edit form with hall selection - โข
update- Process table updates - โข
delete- Remove table - โข
success/error- Show result pages
---
๐ Business Logic Flow
Special Table Auto-Creation
Table Status Management
Special Table Usage
---
โ ๏ธ Common Issues
1. Special Table Management
Issue: Special tables (-1, -2) must exist for takeaway/delivery orders
Solution: Auto-creation logic ensures they exist before processing regular tables
2. Hall Assignment Validation
Issue: Tables must be assigned to valid halls
Solution: Form includes hall dropdown from restaurant hall table
3. Table Occupancy Tracking
Issue: beingUsed status must be properly managed by order system
Solution: Status is set by restaurant ordering system, not this controller
4. Arabic Text Encoding
Issue: Special table names use Arabic text
Solution: Database must support UTF-8 encoding for proper display
---
๐ Dependencies
Required Files
- โข
../public/impOpreation.php- Core operations - โข
../public/config.php- Configuration - โข
../public/include_dao.php- Database access objects - โข
../public/authentication.php- User authentication
DAO Classes
- โข
RestauranttableMySqlDAO- Standard database operations - โข
RestauranttableMySqlExtDAO- Extended operations (insertWithId) - โข
RestauranthallMySqlDAO- Hall data access - โข
YoutubeLinkMySqlDAO- Entertainment links
Model Classes
- โข
Restauranttable.class.php- Table entity - โข
Restauranthall.class.php- Hall entity - โข
YoutubeLink.class.php- Entertainment entity
Templates
- โข
restauranttableview/add.html- Add table form - โข
restauranttableview/show.html- Table listing - โข
restauranttableview/edit.html- Edit table form - โข
header.html/footer.html- Layout templates - โข
succes.html/error.html- Result pages
Special Methods
- โข
insertWithId()- Extended DAO method for inserting with specific ID - โข
queryByName()- Check for duplicate table names (referenced in PlayStation controller)
---
Integration Notes:
- โข Tables are the primary unit for restaurant order assignment
- โข Special tables (-1, -2) handle off-premise orders (takeaway/delivery)
- โข Gaming stations (PlayStation) can be linked to specific tables
- โข Hall assignment enables organized restaurant layout management
- โข Table status (beingUsed) is managed by the ordering system for occupancy tracking