Restaurantplaystation Documentation

Restaurant PlayStation Controller Documentation

File: /controllers/restaurantplaystation.php

Purpose: Manages PlayStation gaming stations, hourly gaming services, and integrated table-gaming operations

Last Updated: December 19, 2024

Total Functions: 8

Lines of Code: 524

---

๐Ÿ“‹ Overview

The Restaurant PlayStation Controller manages gaming station operations within the restaurant environment. It handles:

Primary Functions

Related Controllers

---

๐Ÿ—„๏ธ Database Tables

Primary Tables (Direct Operations)

Table NamePurposeKey Columns
**restaurantplaystation**Gaming station configid, name, hourPrice, hourPriceMulti, beingUsed, tableId, serviceId, deviceIdentification, subDeviceIdentification, useSubIdentification
**restaurantplaystationplay**Gaming sessionsid, playstationid, startsysDate, endsysDate, allMovesUnitedSellBillId, moveStartSysDate, finished, oldPsPlayid
### Integration Tables

Table NamePurposeRelationship
**restauranttable**Optional table linkrestaurantplaystation.tableId โ†’ restauranttable.id
**restauranthall**Hall assignmentThrough table relationship
**product**Auto-created servicerestaurantplaystation.serviceId โ†’ product.productid
**productcat**Gaming categoryAuto-created "ุจู„ุงูŠ ุณุชูŠุดู†" category
**sellbill**Gaming session billingrestaurantplaystationplay.allMovesUnitedSellBillId
### Reference Tables

Table NamePurposeRelationship
**youtubelink**Entertainment linksDisplay integration
**productunit**Service unitsFor gaming service products
**user**System usersCreator and access tracking
### Table Structure Details

restaurantplaystation columns:

restaurantplaystationplay columns:

---

๐Ÿ”ง Key Functions

1. add()

Purpose: Create new PlayStation station with auto-service creation

Called By: Form submission with ?do=add

Line: 216-264

Parameters (via $_POST):

Process Flow:

โ”Œโ”€ Create Gaming Category โ”€โ”€โ”
Auto-create "ุจู„ุงูŠ ุณุชูŠุดู†"
product category
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ–ผ
โ”Œโ”€ Create Gaming Service โ”€โ”€โ”€โ”
Auto-create product for
gaming time billing
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ–ผ
โ”Œโ”€ Create Table (Optional) โ”€โ”
If hasTable=1, create
linked restaurant table
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ–ผ
โ”Œโ”€ Create PlayStation โ”€โ”€โ”€โ”€โ”€โ”€โ”
Station configuration
with all references
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Code Example:

// Auto-create service category and product
$catId = addTheCategory();  // Creates "ุจู„ุงูŠ ุณุชูŠุดู†" category
$serviceId = addService($catId, $name);  // Creates gaming service

// Optional table creation
if ($hasTable == 1) {
    $restaurantTable->name = (count($check) > 0) ? $name . "_ps" : $name;
    $tableId = $restaurantTableDAO->insert($restaurantTable);
}

2. update()

Purpose: Update station configuration with complex table management

Called By: Form submission with ?do=update

Line: 266-351

Parameters (via $_POST):

Process Flow:

โ”Œโ”€ Update Service Product โ”€โ”€โ”
Keep same serviceId but
update product details
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ–ผ
โ”Œโ”€ Complex Table Logic โ”€โ”€โ”€โ”€โ”€โ”
4 scenarios:
1No table โ†’ Table
2Table โ†’ Table (update)
3No table โ†’ No table
4Table โ†’ No table (del)
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ–ผ
โ”Œโ”€ Update PlayStation โ”€โ”€โ”€โ”€โ”€โ”€โ”
Station configuration
with preserved status
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

3. delete()

Purpose: Soft delete station with table cleanup

Called By: ?do=delete&id=X

Line: 353-374

Parameters:

Process Flow:

โ”Œโ”€ Load PlayStation โ”€โ”€โ”€โ”€โ”
Get current config
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ–ผ
โ”Œโ”€ Soft Delete Station โ”€โ”
Set del = 1
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ–ผ
โ”Œโ”€ Delete Linked Table โ”€โ”
If tableId > 0,
soft delete table too
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

4. addTheCategory()

Purpose: Auto-create or find PlayStation product category

Line: 376-405

Returns: Category ID for gaming products

Process Flow:

โ”Œโ”€ Check Existing โ”€โ”€โ”€โ”€โ”€โ”€โ”
Look for "ุจู„ุงูŠ ุณุชูŠุดู†"
category
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ–ผ
โ”Œโ”€ Create Category โ”€โ”€โ”€โ”€โ”€โ”
Use CURL to product
category controller
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

5. addService()

Purpose: Create gaming service product

Line: 407-442

Parameters:

Returns: Product ID for gaming service

Process Flow:

โ”Œโ”€ Prepare Product Data โ”
Gaming service config:
- isservice = 1
- No inventory
- Zero prices (set via
station pricing)
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ–ผ
โ”Œโ”€ CURL to Product โ”€โ”€โ”€โ”€โ”€โ”
Controller for
service creation
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

6. updateService()

Purpose: Update existing gaming service product

Line: 444-485

Parameters:

7. dayReport()

Purpose: Generate daily gaming session reports

Called By: ?do=dayReport

Line: 153-196

Parameters (via $_POST):

Process Flow:

โ”Œโ”€ Build Query Filters โ”€โ”
Date range, station
Default: today only
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ–ผ
โ”Œโ”€ Get Session Data โ”€โ”€โ”€โ”€โ”
billing references
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ–ผ
โ”Œโ”€ Calculate Durations โ”€โ”
Start/end times
Format H:i display
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Code Example:

foreach ($result as $sellbilldetail) {
    $sellbilldetail->startTime = date('H:i', strtotime($sellbilldetail->moveStartSysDate));
    $sellbilldetail->endTime = date('H:i', strtotime($sellbilldetail->endsysDate));
    
    $datetime1 = new DateTime($sellbilldetail->moveStartSysDate);
    $datetime2 = new DateTime($sellbilldetail->endsysDate);
    $interval = $datetime1->diff($datetime2);
    $sellbilldetail->duration = $interval->format('%h') . ":" . $interval->format('%i');
}

8. CURL_IT2()

Purpose: Internal CURL helper for cross-controller calls

Line: 487-523

Parameters:

Purpose: Enables calling product/category controllers for service creation

---

๐Ÿ”„ Business Logic Flow

Station Creation with Service Integration

โ–ผ
โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
Auto Product Management
โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚ 1. Create/Find Category
โ”‚ "ุจู„ุงูŠ ุณุชูŠุดู†"
โ”‚ 2. Create Gaming Serviceโ”‚
โ”‚ Product (isservice=1)โ”‚
โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
Optional Table Management
โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚ - Link serviceId โ”‚
โ”‚ If hasTable=1:
โ”‚ 1. Check name conflicts
โ”‚ 2. Create table
โ”‚ 3. Link to station
โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Gaming Session Workflow

โ–ผ
โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
Session Start
(External POS)
โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
Mark Station
beingUsed=1
โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
Gaming Session End
1Calculate total time
2Generate sell bill (via serviceId)
3Apply hourly pricing
4Mark station available
5Set finished=1 in session record
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Table-Gaming Integration

โ–ผ
โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
Combined Order
- Gaming time
- Food service
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
Unified Billing
- Gaming charges (hourly)
- Food/drink charges
- Single sell bill
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

---

โš ๏ธ Common Issues

1. Service Product Creation

Issue: Gaming stations require auto-created service products for billing

Solution: addTheCategory() and addService() handle automatic product setup

2. Table Management Complexity

Issue: 4 different table scenarios in update logic

Solution: Comprehensive if-else logic handles all transitions

3. Device Identification

Issue: Multiple device tracking for complex gaming setups

Solution: Primary and sub-device identification fields

4. Session Billing Integration

Issue: Gaming time must integrate with restaurant billing system

Solution: serviceId links to product system for automatic pricing

5. Arabic Text in Category

Issue: Auto-created category uses Arabic text "ุจู„ุงูŠ ุณุชูŠุดู†"

Solution: Ensure UTF-8 database encoding for proper display

---

๐Ÿ”— Dependencies

Required Files

DAO Classes

Model Classes

External Integrations

Templates

---

Integration Notes: