๐Ÿ“š ERP Documentation Viewer

Beautiful, colorful documentation for your ERP system

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:

Primary Functions

Related Controllers

---

๐Ÿ—„๏ธ Database Tables

Primary Tables (Restaurant Operations)

Table NamePurposeKey Columns
**restaurantorder**Main restaurant ordersid, sellBillId, tableId, totalBill, discount, netBill, rest, tax, hallPrice, finished, sysdate
**restaurantorderdetail**Order line itemsid, orderId, productId, quantity, price, total
**restaurantorderdeliverydetail**Delivery informationorderId, customerName, phone, address, deliveryTime
**restaurantkitchenprint**Kitchen print queuePrint jobs and status tracking
### Integration Tables

Table NamePurposeRelationship
**sellbill**Main billing systemrestaurantorder.sellBillId โ†’ sellbill.sellbillid
**sellbilldetail**Bill line itemsIntegration with restaurant order details
**restauranttable**Table managementrestaurantorder.tableId โ†’ restauranttable.id
**restauranthall**Hall configurationThrough table relationships
### Special Table IDs

Table IDService TypeDescription
**> 0**Dining tablesRegular restaurant tables
**-1**TakeawayุชูŠูƒ ุฃูˆุงู‰ orders
**-2**Deliveryุฏู„ูŠูุฑู‰ orders
### Financial Integration

Table NamePurposeRelationship
**client**Customer dataFor delivery and takeaway orders
**save**Cash registersPayment processing
**savedaily**Daily cash movementsRestaurant sales tracking
**dailyentry**Accounting entriesAuto-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:

Process Flow:

โ”Œโ”€ Load Recent Orders โ”€โ”€โ”
Last 20 restaurant
orders for reference
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ–ผ
โ”Œโ”€ Handle Order Edit โ”€โ”€โ”€โ”
If editing existing:
- Load order data
- Load client data
- Set finished=0
- Mark other orders
finished=1
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ–ผ
โ”Œโ”€ User Permission โ”€โ”€โ”€โ”€โ”€โ”
Check takeaway,
delivery, hall access
Build table query
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ–ผ
โ”Œโ”€ Display POS โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
Restaurant billing
interface with tables
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

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:

Process Flow:

โ”Œโ”€ Setup Bill Data โ”€โ”€โ”€โ”€โ”€โ”
billnameId = 3
Default client = 1
Handle delivery/take
away client selection
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ–ผ
โ”Œโ”€ Calculate Pricing โ”€โ”€โ”€โ”
Hall price type
Tax calculations
Discount processing
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ–ผ
โ”Œโ”€ Inventory Validation โ”
Check stock levels
Validate quantities
Handle size/color
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ–ผ
โ”Œโ”€ Create Sell Bill โ”€โ”€โ”€โ”€โ”
Create bill record
Process bill details
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ–ผ
โ”Œโ”€ Update Systems โ”€โ”€โ”€โ”€โ”€โ”€โ”
Update inventory
Create accounting
entries
Update client debt
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Key Features:

3. Restaurant Order Workflow

Purpose: Handle complete restaurant order lifecycle

Lines: 1920-2000 (processing section)

Process Flow:

โ”Œโ”€ Table Selection โ”€โ”€โ”€โ”€โ”€โ”
User selects table
or takeaway/delivery
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ–ผ
โ”Œโ”€ Check Existing โ”€โ”€โ”€โ”€โ”€โ”€โ”
Look for unfinished
order on table
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ–ผ
โ”Œโ”€ Order Processing โ”€โ”€โ”€โ”€โ”
If existing order:
- Load details
- Add/edit items
If new order:
- Create new record
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ–ผ
โ”Œโ”€ Billing Integration โ”€โ”
Calculate totals
Apply discounts
Process payments
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ–ผ
โ”Œโ”€ Kitchen Integration โ”€โ”
Send to kitchen
printer queue
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

4. Table Access Control

Purpose: Control user access to different service types

Lines: 1814-1845

Permission Logic:

โ–ผ
โ–ผ
โ”Œโ”€ Check Permissions โ”€โ”€โ”€โ”
takeAway: 0/1
delivery: 0/1
hall: 0/1
seeAllHalls: 0/1
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ–ผ
โ”Œโ”€ Build Query Filter โ”€โ”
Based on permissions:
- All tables
- Specific types only
- No access (-1000)
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ–ผ
โ”Œโ”€ Display Tables โ”€โ”€โ”€โ”€โ”€โ”€โ”
Show authorized
tables only
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

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:

โ–ผ
โ–ผ
โ”Œโ”€ Kitchen Print Job โ”€โ”€โ”€โ”
Create print record
in kitchen queue
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ–ผ
โ”Œโ”€ Kitchen Display โ”€โ”€โ”€โ”€โ”€โ”
Show order details
on kitchen screen
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

6. Gaming Station Integration

Purpose: Handle PlayStation billing through restaurant system

Integration: With restaurantplaystation controller

Process Flow:

โ–ผ
โ–ผ
โ”Œโ”€ Calculate Time โ”€โ”€โ”€โ”€โ”€โ”€โ”
Session duration
Apply hourly rates
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ–ผ
โ”Œโ”€ Create Service Bill โ”€โ”
Use gaming service
product from station
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ–ผ
โ”Œโ”€ Add to Table Order โ”€โ”€โ”
If table has food
orders, combine
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

---

๐Ÿ”„ Business Logic Flow

Complete Restaurant Order Workflow

โ–ผ
โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
Service Type Selection
โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚ Dining (Table > 0)
โ”‚ Takeaway (Table -1)
โ”‚ Delivery (Table -2)
โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
Table Assignment
โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚ Check table status
โ”‚ Look for existing order
โ”‚ Set table as in use
โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
Order Management
โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚ - Print orders โ”‚
โ”‚ Add menu items
โ”‚ Calculate pricing
โ”‚ Apply discounts
โ”‚ โ”‚ Handle modifications โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
Billing & Payment
โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚ Generate sell bill
โ”‚ Process payments
โ”‚ Update inventory
โ”‚ Create accounting
โ”‚ Print receipts
โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Service Type Handling

โ–ผ
โ”Œโ”€โ”€โ–ผโ”€โ”€โ”€โ”
Type
โ””โ”€โ”€โ”ฌโ”€โ”€โ”€โ”˜
โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”
Service
Type
โ””โ”€โ”ฌโ”€โ”ฌโ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚
โ”‚ โ”‚ โ””โ”€โ”€ Delivery โ”€โ”€โ”€โ”€โ”€โ”
โ”‚
โ”‚ โ””โ”€โ”€ Takeaway โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€ Client Selection Required
โ””โ”€โ”€ Dining โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€ Table Service
โ–ผ
โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
- Hall pricing
- Kitchen print
- Table status
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

---

โš ๏ธ 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

DAO Classes (Restaurant-specific)

Model Classes

Integration Dependencies

Templates

Permission System

---

Integration Notes:

โ†‘