36 lines
1.2 KiB
PHP
36 lines
1.2 KiB
PHP
<?php
|
|
session_start();
|
|
|
|
require '../../../assets/utils/db_auth.php';
|
|
|
|
$sql = "SELECT
|
|
a.*,
|
|
COALESCE(r.total_racks, 0) AS capacity,
|
|
COALESCE(r.occupied_racks, 0) AS space_used,
|
|
COALESCE(r.unique_product, 0) AS unique_product,
|
|
c.name AS manager_name,
|
|
c.surname AS manager_surname
|
|
FROM md_warehouse a
|
|
LEFT JOIN (
|
|
SELECT
|
|
company_id, warehouse,
|
|
COUNT(*) AS total_racks,
|
|
COUNT(product_sku) AS occupied_racks,
|
|
COUNT(DISTINCT product_sku) AS unique_product
|
|
FROM md_rack
|
|
GROUP BY company_id, warehouse
|
|
) r ON a.company_id = r.company_id AND a.id = r.warehouse
|
|
LEFT JOIN wms.user c ON a.manager = c.user_id
|
|
WHERE a.company_id = :company_id";
|
|
|
|
$sth = $pdo2->prepare($sql);
|
|
$sth->execute([
|
|
":company_id" => $company_id
|
|
]);
|
|
db_check($sth, $answer);
|
|
|
|
$answer["output"] = $sth->fetchAll(PDO::FETCH_ASSOC);
|
|
$answer["success"] = 1;
|
|
exit(json_encode($answer));
|
|
|
|
?>
|