workPro Documentation
Implemented a new enhanced item information popup that displays quantities drilled down by DC level, showing how many items have been completed in each individual Distribution Center.
item-info-drilldown.phpLocation: /public/api/item-info-drilldown.php
Purpose: Fetch item details with DC-wise breakdown of quantities
Parameters:
itemId (required): The ID of the item to fetch details forResponse Structure:
{
"success": true,
"data": {
"item": {
"itemId": 1,
"itemCode": "CODE123",
"itemName": "Item Name",
"uom": "Unit",
"imagePath": "path/to/image.jpg",
"imageExists": true
},
"dcWiseQuantities": [
{
"dcId": 1,
"dcName": "DC New Delhi",
"boqQuantity": 100,
"doneQuantity": 45,
"completionPercentage": 45.0
},
{
"dcId": 2,
"dcName": "DC Mumbai",
"boqQuantity": 80,
"doneQuantity": 65,
"completionPercentage": 81.25
}
],
"summary": {
"totalBoqQuantity": 180,
"totalDoneQuantity": 110,
"completionPercentage": 61.11
}
}
}
Query Logic:
Item Details Query: Fetches basic item information from workpro.item table
DC-wise Breakdown Query:
dcId and joins with workpro.dc to get DC namesSUM(boq.totalQty) where itemId = :itemId and dcId = current_dcSUM(work.doneQty) via subquery joining work → boqSummary Totals: Aggregates all DC data for overall completion percentage
showItemInfo(itemId, dcId = null)Location: /public/all-work.php (lines 654-800+)
Changes:
item-info-drilldown.php API instead of item-info.phpdcId parameter (for backward compatibility, though not currently used)response.data.item - Basic item detailsresponse.data.dcWiseQuantities - Array of DC-wise breakdownsresponse.data.summary - Overall totalsDisplays:
Section 1: Item Header (3-column layout)
Section 2: Item Name (Full width)
Section 3: DC-wise Quantities Table A responsive table showing: | DC Name | BOQ Qty (Gold) | Done Qty (Green) | Completion % (Cyan) | |---------|---|---|---| | DC New Delhi | 100 | 45 | 45% | | DC Mumbai | 80 | 65 | 81.3% |
Section 4: Summary Totals (3-column layout)
User clicks Item Code in DataTable
↓
showItemInfo(itemId, dcId) called
↓
AJAX POST to api/item-info-drilldown.php
↓
API Query Groups by DC
↓
Returns item + dcWiseQuantities array
↓
JavaScript builds table from array
↓
Display in modal with DC-wise breakdown
Colors:
Table Styling:
| Aspect | Previous (item-info.php) | New (item-info-drilldown.php) |
|---|---|---|
| Data Returned | Aggregated totals only | DC-wise breakdown + summary |
| Use Case | Single DC filtering | Multi-DC comparison |
| Table Display | None | Full DC-wise quantities table |
| Flexibility | Limited to single DC | Compare all DCs at once |
Tables Used:
workpro.item - Basic item informationworkpro.boq - BOQ entries with itemId, dcId, totalQtyworkpro.dc - DC master data (dcName)workpro.work - Work entries with doneQty, boqIdJoin Path for Quantities:
work.boqId → boq.boqId
boq.itemId → item.itemId
boq.dcId → dc.dcId
// Click handler automatically passes itemId and dcId
$(document).on('click', '.item-info-link', function(e) {
e.preventDefault();
const itemId = $(this).data('item-id');
const dcId = $(this).data('dc-id'); // DC context from current row
showItemInfo(itemId, dcId); // dcId optional for future enhancement
});
/public/all-work.php
showItemInfo() functionitem-info.php to item-info-drilldown.php/public/api/item-info-drilldown.php (NEW)