Notices Controller Documentation
File: /controllers/noticesController.php
Purpose: System notifications and alerts management for inventory, bills, checks, and operational status
Last Updated: December 20, 2024
Total Functions: 15+
Lines of Code: ~817
---
๐ Overview
The Notices Controller provides comprehensive business notifications including low inventory alerts, bill due dates, check processing status, workshop delays, and insurance approvals. It serves as a central dashboard for monitoring critical business operations requiring attention.
Primary Functions
- โ Inventory level monitoring and alerts
- โ Product sales tracking and non-selling product identification
- โ Check processing notifications (clients and suppliers)
- โ Bill payment due date alerts
- โ Workshop order delay notifications
- โ Insurance bill approval status
- โ Premium payment reminders
- โ Product request notifications
- โ Category-based filtering and reporting
---
๐๏ธ Database Tables
Core Notification Tables
| Table Name | Purpose | Key Columns | |
|---|---|---|---|
| **product** | Product master data | productid, productName, productCatId | |
| **storedetail** | Inventory quantities | storedetailid, productid, storedetailquantity, storeid | |
| **sellbilldetail** | Sales transaction details | sellbilldetailproductid, sellbilldetaildate | |
| **datedchecked** | Post-dated checks | datedcheckedid, checkvalue, clientnum, addtype, done | |
| **kempiala** | Promissory notes | kempialaid, kempialadate, kempialavalue |
| Table Name | Purpose | Key Columns | |
|---|---|---|---|
| **toworkshoporder** | Workshop orders | toworkshoporderid, deliverworkshopdate, recieveworkshopdate, orderstatus | |
| **bills** | Service bills | billid, clientid, insurance, approved, notifseen | |
| **premium** | Premium payments | premiumid, premiumdate, userid |
๐ Key Functions
1. Default Dashboard - System Notifications Overview
Location: Lines 231-291
Purpose: Display comprehensive business notification dashboard
Process Flow:
1. Category Data: Load product categories for filtering
2. Store Loading: Load warehouse/store information
3. Product Analysis: Get low stock and non-selling products
4. Bill Analysis: Check overdue bills and payments
5. Check Processing: Monitor dated checks requiring attention
6. Workshop Orders: Track delayed workshop operations
7. Insurance Bills: Monitor insurance approval status
8. Premium Tracking: Check due premium payments
2. showallproductbystorename() - Store-Specific Product Analysis
Location: Lines 480-510
Purpose: Analyze product levels filtered by store and category
Features:
- โข Store-specific filtering
- โข Category hierarchy support
- โข Product path generation for display
- โข Quantity threshold monitoring
3. productnotsellbystorename() - Non-Selling Product Detection
Location: Lines 546-582
Purpose: Identify products with no sales in past 7 days by store
4. getToWorkshopOrderNoticeInDetails() - Workshop Delay Monitoring
Location: Lines 658-711
Purpose: Monitor workshop order delays across different stages
Delay Types Monitored:
- โข Delivery Delays: Orders not delivered to workshop on time
- โข Workshop Delays: Orders not completed by workshop deadline
- โข Return Delays: Completed orders not returned to branch on time
5. getInsuranceBillNotif() - Insurance Processing Alerts
Location: Lines 723-793
Purpose: Track insurance bill approval status and notifications
Status Types:
- โข Waiting Bills: Pending approval (
approved = 0) - โข Approved Bills: Recently approved (
approved = 1) - โข Rejected Bills: Recently rejected (
approved = 2)
6. getPremiumTodays() - Premium Due Notifications
Location: Lines 796-805
Purpose: Get premium payments due today for current user
---
๐ Workflows
Notification Dashboard Workflow
---
๐ URL Routes & Actions
| URL Parameter | Function | Description | |
|---|---|---|---|
| `do=` (empty) | Default | Main notifications dashboard | |
| `do=show` | Store filter | Filter by specific store | |
| `do=showproductnotsell` | Non-selling | Show non-selling products by store | |
| `do=editprint` | Bill print | Print promissory note details | |
| `do=editprint2` | Check print | Print check details |
- โข
supplierid- Store/supplier filter ID - โข
level- Category level for hierarchical filtering - โข
productCatId{N}- Category ID for level N filtering
---
๐งฎ Calculation Methods
Time-Based Calculations
// Workshop delay calculation
function dateTimeDiff($dateTime1, $dateTime2) {
$dateTime1 = new DateTime($dateTime1);
$dateTime2 = new DateTime($dateTime2);
$diff = $dateTime2->diff($dateTime1);
$hours = $diff->h + ($diff->days * 24);
return $hours;
}
Product Path Generation
// Recursive category path building
$parentId = $product->productCatId;
$pathArr = getProductPath_recursive1($parentId, $categories, 0);
$request->productName = $product->productName . '/' . $pathArr;
---
๐ Security & Performance
Performance Considerations
- โข Multiple Query Execution: Dashboard runs many analysis queries
- โข Date Range Calculations: 7-day lookbacks on transaction tables
- โข Recursive Path Building: Category hierarchy traversal
- โข User Permission Filtering: Role-based data access
Required Indexes
- โข
sellbilldetail(sellbilldetailproductid, sellbilldetaildate) - โข
datedchecked(checkdate, addtype, done) - โข
toworkshoporder(orderstatus, deliverworkshopdate) - โข
bills(insurance, approved, notifseen)
---
๐ Related Documentation
- โข CLAUDE.md - PHP 8.2 migration guide
- โข noticefunctions.md - Notice utility functions
- โข productController.md - Product management
---
Documented By: AI Assistant
Review Status: โ Complete
Next Review: When major changes occur