Restaurant Order Management Documentation (restoredController)
File: /controllers/sellbillController.php (Restaurant functions)
Purpose: Restaurant order processing, table management, and POS operations integrated within the sales system
Last Updated: December 19, 2024
Total Functions: 15+ (restaurant-specific)
Lines of Code: ~500+ (restaurant sections)
---
๐ Overview
The Restaurant Order Management functionality is integrated into the sellbillController.php and manages complete restaurant operations. This serves as the "restoredController" for:
- โข Restaurant order creation and management
- โข Table-based order processing (dining, takeaway, delivery)
- โข Kitchen order printing and workflow
- โข POS billing integration with restaurant services
- โข Multi-table order management
- โข Gaming station billing integration
- โข Restaurant-specific reporting and analytics
- โข User permission-based table access control
Primary Functions
- โ Restaurant bill creation and processing
- โ Table-based order management
- โ Takeaway and delivery order processing
- โ Kitchen printer integration
- โ Multi-payment method support
- โ Gaming station billing
- โ Restaurant order reporting
- โ User permission-based access control
Related Controllers
- โข restauranthall.php - Hall configuration and management
- โข restauranttable.php - Table setup and assignment
- โข restaurantplaystation.php - Gaming station integration
- โข restaurantKitchenPrinter.php - Kitchen printing
- โข productController.php - Menu item management
- โข clientController.php - Customer management for delivery
---
๐๏ธ Database Tables
Primary Tables (Restaurant Operations)
| Table Name | Purpose | Key Columns | |
|---|---|---|---|
| **restaurantorder** | Main restaurant orders | id, sellBillId, tableId, totalBill, discount, netBill, rest, tax, hallPrice, finished, sysdate | |
| **restaurantorderdetail** | Order line items | id, orderId, productId, quantity, price, total | |
| **restaurantorderdeliverydetail** | Delivery information | orderId, customerName, phone, address, deliveryTime | |
| **restaurantkitchenprint** | Kitchen print queue | Print jobs and status tracking |
| Table Name | Purpose | Relationship | |
|---|---|---|---|
| **sellbill** | Main billing system | restaurantorder.sellBillId โ sellbill.sellbillid | |
| **sellbilldetail** | Bill line items | Integration with restaurant order details | |
| **restauranttable** | Table management | restaurantorder.tableId โ restauranttable.id | |
| **restauranthall** | Hall configuration | Through table relationships |
| Table ID | Service Type | Description | |
|---|---|---|---|
| **> 0** | Dining tables | Regular restaurant tables | |
| **-1** | Takeaway | ุชูู ุฃูุงู orders | |
| **-2** | Delivery | ุฏูููุฑู orders |
| Table Name | Purpose | Relationship | |
|---|---|---|---|
| **client** | Customer data | For delivery and takeaway orders | |
| **save** | Cash registers | Payment processing | |
| **savedaily** | Daily cash movements | Restaurant sales tracking | |
| **dailyentry** | Accounting entries | Auto-generated from restaurant bills |
๐ง Key Functions
1. addresBill (Main Restaurant POS)
Purpose: Primary restaurant POS interface for order management
Called By: ?do=addresBill
Line: 1777-1900+
Parameters:
- โข
id(GET) - Edit existing order ID - โข
tableId(GET) - Table assignment
Process Flow:
Code Example:
// Load order for editing
if ($OrdereditId) {
$restaurantOrder = $restaurantOrderDAO->load($OrdereditId);
$sellBilldata = $mySellbillRecord->load($restaurantOrder->sellBillId);
$restaurantOrder->finished = 0;
$restaurantOrderDAO->update($restaurantOrder);
// Mark other table orders as finished
R::exec("UPDATE `restaurantorder` SET `finished`= 1 WHERE id != '$OrdereditId'
and tableId = '$tableId'");
}
2. addRestaurantBill()
Purpose: Convert restaurant order to sell bill with all integrations
Called By: Restaurant order processing
Line: 10807-11200+
Parameters:
- โข
$restaurantOrder- Restaurant order object - โข
$restaurantOrderDetails- Array of order items
Process Flow:
Key Features:
- โข Automatic client selection for delivery/takeaway
- โข Hall-based pricing integration
- โข Tax calculation for restaurant orders
- โข Inventory validation and updates
- โข Accounting entry generation
3. Restaurant Order Workflow
Purpose: Handle complete restaurant order lifecycle
Lines: 1920-2000 (processing section)
Process Flow:
4. Table Access Control
Purpose: Control user access to different service types
Lines: 1814-1845
Permission Logic:
Code Example:
// Permission-based table filtering
if ($Usergroupdata->takeAway == 0 && $Usergroupdata->delivery == 0 && $Usergroupdata->hall == 0) {
$queryString = ' and restauranttable.id = -1000 '; // No access
} else {
$queryString = ' and ( ';
if ($Usergroupdata->hall == 1) {
$queryString .= ' restauranttable.id > 0 '; // Regular tables
}
if ($Usergroupdata->takeAway == 1) {
$queryString .= ' restauranttable.id = -1 '; // Takeaway
}
if ($Usergroupdata->delivery == 1) {
$queryString .= ' restauranttable.id = -2 '; // Delivery
}
$queryString .= ' ) ';
}
5. Kitchen Printer Integration
Purpose: Send orders to kitchen printers
Integration: With restaurantKitchenPrinter system
Process Flow:
6. Gaming Station Integration
Purpose: Handle PlayStation billing through restaurant system
Integration: With restaurantplaystation controller
Process Flow:
---
๐ Business Logic Flow
Complete Restaurant Order Workflow
Service Type Handling
---
โ ๏ธ Common Issues
1. Table State Management
Issue: Tables can have conflicting order states
Solution: finished flag ensures only one active order per table
2. Client Assignment for Delivery/Takeaway
Issue: Delivery orders require customer information
Solution: clientShowTawla setting controls client selection display
3. Inventory Integration
Issue: Restaurant orders must update inventory correctly
Solution: Integrated with standard sell bill inventory management
4. Kitchen Printer Queue
Issue: Orders must reach kitchen systems reliably
Solution: Kitchen print job queue with status tracking
5. Gaming Station Billing
Issue: Combined gaming and food orders need proper calculation
Solution: Service products integration through restaurant billing
---
๐ 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 (Restaurant-specific)
- โข
RestaurantorderMySqlDAO- Order operations - โข
RestaurantorderMySqlExtDAO- Extended order operations - โข
RestaurantorderdetailsMySqlDAO- Order details - โข
RestauranttableMySqlDAO- Table management - โข
RestaurantkitchenprintMySqlDAO- Kitchen printing
Model Classes
- โข
Restaurantorder.class.php- Order entity - โข
Restaurantorderdetail.class.php- Order detail entity - โข
Restaurantorderdeliverydetail.class.php- Delivery info entity - โข
Restaurantkitchenprint.class.php- Kitchen print entity
Integration Dependencies
- โข Standard sell bill system (sellbillController main functions)
- โข Product management system for menu items
- โข Client management for delivery orders
- โข Inventory management for stock updates
- โข Accounting system for financial entries
Templates
- โข
resturant/bill.html- Main restaurant POS interface - โข Kitchen printer templates for order display
- โข Standard sell bill templates for receipts
Permission System
- โข User group settings for service type access
- โข Hall-specific user permissions
- โข Table access control based on user groups
---
Integration Notes:
- โข Restaurant functionality is fully integrated into the main sell bill system
- โข Orders flow through standard billing processes with restaurant-specific enhancements
- โข Kitchen integration provides real-time order communication
- โข Gaming station billing seamlessly integrates with food service
- โข Multi-service type support (dining, takeaway, delivery) with proper workflow management
- โข Complete audit trail through standard accounting integration