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:
- โข Creating and configuring PlayStation gaming stations
- โข Setting up hourly pricing for gaming services
- โข Managing device identification and sub-device configurations
- โข Automatic product/service creation for gaming time
- โข Integration with restaurant tables for combined dining-gaming
- โข Daily gaming session reports and analytics
- โข Session tracking with start/end times and billing integration
Primary Functions
- โ Create new PlayStation stations with pricing
- โ Edit existing station configurations
- โ Delete stations with cleanup
- โ Automatic service product creation
- โ Device identification management
- โ Table integration for dining-gaming
- โ Daily session reports with duration tracking
- โ Multi-user pricing tiers (single/multi-player)
Related Controllers
- โข sellbillController.php - Gaming session billing
- โข restauranthall.php - Hall management
- โข restauranttable.php - Table integration
- โข productController.php - Auto-created gaming services
- โข productCatController.php - Gaming category management
- โข restaurantKitchenPrinter.php - Order printing
---
๐๏ธ Database Tables
Primary Tables (Direct Operations)
| Table Name | Purpose | Key Columns | |
|---|---|---|---|
| **restaurantplaystation** | Gaming station config | id, name, hourPrice, hourPriceMulti, beingUsed, tableId, serviceId, deviceIdentification, subDeviceIdentification, useSubIdentification | |
| **restaurantplaystationplay** | Gaming sessions | id, playstationid, startsysDate, endsysDate, allMovesUnitedSellBillId, moveStartSysDate, finished, oldPsPlayid |
| Table Name | Purpose | Relationship | |
|---|---|---|---|
| **restauranttable** | Optional table link | restaurantplaystation.tableId โ restauranttable.id | |
| **restauranthall** | Hall assignment | Through table relationship | |
| **product** | Auto-created service | restaurantplaystation.serviceId โ product.productid | |
| **productcat** | Gaming category | Auto-created "ุจูุงู ุณุชูุดู" category | |
| **sellbill** | Gaming session billing | restaurantplaystationplay.allMovesUnitedSellBillId |
| Table Name | Purpose | Relationship | |
|---|---|---|---|
| **youtubelink** | Entertainment links | Display integration | |
| **productunit** | Service units | For gaming service products | |
| **user** | System users | Creator and access tracking |
restaurantplaystation columns:
- โข
id- Primary key, auto-increment - โข
name- Station name/identifier - โข
hourPrice- Single player hourly rate (DECIMAL) - โข
hourPriceMulti- Multi-player hourly rate (DECIMAL) - โข
beingUsed- Current usage status (0=available, 1=in use) - โข
tableId- Optional linked table ID (0 if standalone) - โข
serviceId- Auto-created product/service ID - โข
deviceIdentification- Device MAC/serial (VARCHAR) - โข
subDeviceIdentification- Secondary device ID - โข
useSubIdentification- Enable sub-device (0/1) - โข
userId- Creator user ID - โข
sysdate- Creation timestamp - โข
del- Soft delete flag
restaurantplaystationplay columns:
- โข
playstationid- Foreign key to station - โข
startsysDate- Session start time - โข
endsysDate- Session end time - โข
allMovesUnitedSellBillId- Billing reference - โข
moveStartSysDate- Actual usage start - โข
finished- Session completion flag - โข
oldPsPlayid- Legacy session reference
---
๐ง 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):
- โข
name- Station name - โข
hallid- Hall assignment (for table creation) - โข
hasTable- Create linked table (0/1) - โข
hourPrice- Single player hourly rate - โข
hourPriceMulti- Multi-player hourly rate - โข
deviceIdentification- Device ID - โข
subDeviceIdentification- Sub-device ID - โข
useSubIdentification- Enable sub-device (0/1)
Process Flow:
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):
- โข
id- Station ID to update - โข
oldhallid- Previous hall ID - โข
name- Updated station name - โข
hallid- New hall assignment - โข
hasTable- Table requirement (0/1) - โข
hourPrice- Updated single player rate - โข
hourPriceMulti- Updated multi-player rate - โข Device identification fields
Process Flow:
3. delete()
Purpose: Soft delete station with table cleanup
Called By: ?do=delete&id=X
Line: 353-374
Parameters:
- โข
id(GET) - Station ID to delete
Process Flow:
4. addTheCategory()
Purpose: Auto-create or find PlayStation product category
Line: 376-405
Returns: Category ID for gaming products
Process Flow:
5. addService()
Purpose: Create gaming service product
Line: 407-442
Parameters:
- โข
catId- Gaming category ID - โข
name- Service name (station name)
Returns: Product ID for gaming service
Process Flow:
6. updateService()
Purpose: Update existing gaming service product
Line: 444-485
Parameters:
- โข
catId- Category ID - โข
name- Updated service name - โข
serviceId- Existing service ID
7. dayReport()
Purpose: Generate daily gaming session reports
Called By: ?do=dayReport
Line: 153-196
Parameters (via $_POST):
- โข
datefrom- Report start date - โข
dateto- Report end date - โข
restaurantplaystationId- Specific station filter
Process Flow:
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:
- โข
data_arr- Data array for POST - โข
url- Target controller endpoint
Purpose: Enables calling product/category controllers for service creation
---
๐ Business Logic Flow
Station Creation with Service Integration
Gaming Session Workflow
Table-Gaming Integration
---
โ ๏ธ 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
- โข
../public/impOpreation.php- Core operations - โข
../public/config.php- Configuration - โข
../public/include_dao.php- Database access objects - โข
../public/authentication.php- User authentication
DAO Classes
- โข
RestaurantplaystationMySqlDAO- Station operations - โข
RestaurantplaystationMySqlExtDAO- Extended operations - โข
RestaurantplaystationplayMySqlDAO- Session tracking - โข
RestauranttableMySqlDAO- Table integration - โข
RestauranthallMySqlDAO- Hall data - โข
ProductcatMySqlDAO- Category management - โข
ProductunitMySqlExtDAO- Unit operations
Model Classes
- โข
Restaurantplaystation.class.php- Station entity - โข
Restaurantplaystationplay.class.php- Session entity - โข
Restauranttable.class.php- Table entity - โข
Productcat.class.php- Category entity
External Integrations
- โข
productController.php- Auto-service creation - โข
productCatController.php- Auto-category creation - โข CURL integration for cross-controller operations
Templates
- โข
restaurantplaystationview/add.html- Add station form - โข
restaurantplaystationview/show.html- Station listing - โข
restaurantplaystationview/edit.html- Edit station form - โข
restaurantplaystationview/dayReport.html- Session reports - โข Standard layout templates
---
Integration Notes:
- โข Gaming stations create billable services automatically
- โข Optional table integration enables dining-gaming combinations
- โข Session tracking provides detailed usage analytics
- โข Device identification supports complex gaming setups
- โข Hourly pricing model with single/multi-player rates
- โข Seamless integration with restaurant billing system via sell bills