warehouse capacity and occupancy
This commit is contained in:
@@ -11,6 +11,12 @@ class Reports
|
||||
$this->companyId = $companyId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Master Data Summary:
|
||||
* - Total Categories: Count of all categories in md_product_category for the company.
|
||||
* - Active Categories: Count of categories where status = 1.
|
||||
* - Inactive Categories: Count of categories where status = 0.
|
||||
*/
|
||||
public function getTotalCategory(): int
|
||||
{
|
||||
$sql = "SELECT COUNT(*)
|
||||
@@ -41,7 +47,8 @@ class Reports
|
||||
{
|
||||
$sql = "SELECT COUNT(*)
|
||||
FROM md_warehouse
|
||||
WHERE company_id = :company_id";
|
||||
WHERE company_id = :company_id
|
||||
AND `status` = 1";
|
||||
return (int) $this->fetchScalar($sql);
|
||||
}
|
||||
|
||||
@@ -49,18 +56,39 @@ class Reports
|
||||
{
|
||||
$sql = "SELECT COUNT(DISTINCT `location`)
|
||||
FROM md_warehouse
|
||||
WHERE company_id = :company_id
|
||||
AND `status` = 1";
|
||||
return (int) $this->fetchScalar($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Total capacity = total count of active racks across all warehouses.
|
||||
* One rack = one storage position (holds one product unit).
|
||||
*/
|
||||
public function getTotalCapacity(): int
|
||||
{
|
||||
$sql = "SELECT COUNT(*)
|
||||
FROM md_rack
|
||||
WHERE company_id = :company_id";
|
||||
return (int) $this->fetchScalar($sql);
|
||||
}
|
||||
|
||||
public function getTotalCapacity(): float
|
||||
/**
|
||||
* Space Used = count of racks currently occupied (product_sku IS NOT NULL).
|
||||
*/
|
||||
public function getSpaceUsed(): int
|
||||
{
|
||||
$sql = "SELECT SUM(capacity)
|
||||
FROM md_warehouse
|
||||
WHERE company_id = :company_id";
|
||||
return (float) $this->fetchScalar($sql);
|
||||
$sql = "SELECT COUNT(*)
|
||||
FROM md_rack
|
||||
WHERE company_id = :company_id
|
||||
AND product_sku IS NOT NULL";
|
||||
return (int) $this->fetchScalar($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Product Count = total count of distinct products in the md_product table for the company.
|
||||
* Low Stock Count = count of products where current stock balance (total_in - total_out) is less than the min_stock defined in md_product.
|
||||
*/
|
||||
public function getTotalProduct(): int
|
||||
{
|
||||
$sql = "SELECT COUNT(*)
|
||||
|
||||
Reference in New Issue
Block a user