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:

Primary Functions

Related Controllers

---

๐Ÿ—„๏ธ Database Tables

Primary Tables (Direct Operations)

Table NamePurposeKey Columns
**restauranttable**Main table configurationid, name, hallid, beingUsed, userId, sysdate, del
### Related Tables

Table NamePurposeRelationship
**restauranthall**Hall master datarestauranttable.hallid โ†’ restauranthall.id
**restaurantplaystation**Gaming stationsReferences table via tableId
**sellbill**Order processingLinks to table for order management
**youtubelink**Entertainment linksDisplay integration
### Special Table IDs

Table IDPurposeHall IDName
**-1**Takeaway orders-1'ุชูŠูƒ ุฃูˆุงู‰' (Arabic for Takeaway)
**-2**Delivery orders-2'ุฏู„ูŠูุฑู‰' (Arabic for Delivery)
### Table Structure Details

restauranttable columns:

---

๐Ÿ”ง 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):

Process Flow:

โ”Œโ”€ Check Special Tables โ”€โ”
Takeaway (-1)
Delivery (-2)
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ–ผ
โ”Œโ”€ Create Missing โ”€โ”€โ”€โ”€โ”€โ”€โ”
Special Tables
(if not exist)
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ–ผ
โ”Œโ”€ Add Regular Table โ”€โ”€โ”€โ”
Set hall assignment
Set default status
Insert to database
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

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:

โ”Œโ”€ Query All Tables โ”€โ”
Tables (-1, -2)
โ””โ”€ Return Array โ”€โ”€โ”€โ”€โ”˜

3. edit()

Purpose: Load table data for editing

Called By: ?do=edit&id=X

Line: 184-191

Parameters:

Returns: Table object with current configuration

Process Flow:

โ”Œโ”€ Get Table ID โ”€โ”€โ”€โ”€โ”
Data
โ””โ”€ Return Object โ”€โ”€โ”˜

4. update()

Purpose: Update existing table configuration

Called By: Form submission with ?do=update

Line: 193-209

Parameters (via $_POST):

Process Flow:

โ”Œโ”€ Get Table ID โ”€โ”€โ”€โ”€โ”
Table Object
โ””โ”€ Save Changes โ”€โ”€โ”€โ”˜

5. delete()

Purpose: Delete a restaurant table

Called By: ?do=delete&id=X

Line: 211-222

Parameters:

Process Flow:

โ”Œโ”€ Get Table ID โ”€โ”€โ”€โ”€โ”
(not soft)
โ””โ”€ Remove Record โ”€โ”€โ”˜

Note: Includes commented code for special table cleanup logic

6. Standard Controller Actions

Purpose: Handle routing and display

Lines: 53-123

Actions:

---

๐Ÿ”„ Business Logic Flow

Special Table Auto-Creation

โ–ผ
โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
Check Takeaway
Table (-1)
Exists?
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
Create Takeaway
ID: -1
Hall: -1
Name: ุชูŠูƒ ุฃูˆุงู‰
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
Create Regular Table
- Assign to selected hall
- Set available status
- Insert with auto-ID
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Table Status Management

โ–ผ
โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
Set Default
Status
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” Order Assignment
Available for
Order
Assignment
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
Mark as Used
(by order
system)
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Special Table Usage

โ–ผ
โ”Œโ”€โ”€โ–ผโ”€โ”€โ”
POS
UI
โ””โ”€โ”€โ”ฌโ”€โ”€โ”˜
โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”
Service
Type?
โ””โ”€โ”ฌโ”€โ”ฌโ”€โ”ฌโ”€โ”€โ”€โ”˜
โ”‚
โ”‚ โ”‚ โ””โ”€โ”€ Table Service โ”€โ”€โ”
โ”‚
โ”‚ โ””โ”€โ”€โ”€ Delivery โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€ Use Table -2
โ””โ”€โ”€โ”€โ”€ Takeaway โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€ Use Table -1
โ–ผ
โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
Process Order
with Special
Table ID
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

---

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

DAO Classes

Model Classes

Templates

Special Methods

---

Integration Notes: