more OOP and restructure utils

This commit is contained in:
Thanakorn S
2026-04-22 15:55:18 +07:00
parent 8834d672ba
commit 35dd1a9fce
31 changed files with 1417 additions and 494 deletions
+9 -16
View File
@@ -3,10 +3,17 @@
require '../../../assets/utils/db_auth.php';
$sql = "SELECT a.*
$sql = "SELECT a.*, IFNULL(COUNT(DISTINCT b.product_sku), 0) AS unique_product,
c.name AS manager_name, c.surname AS manager_surname
FROM md_warehouse a
LEFT JOIN warehouse_balance b ON
a.company_id = b.company_id AND
a.id = b.warehouse_id
LEFT JOIN wms.user c ON
a.manager = c.user_id
WHERE
a.company_id = :company_id";
a.company_id = :company_id
GROUP BY a.id";
$sth = $pdo2->prepare($sql);
$sth->execute([
":company_id" => $company_id
@@ -14,20 +21,6 @@
db_check($sth, $answer);
$answer["output"] = $sth->fetchAll(PDO::FETCH_ASSOC);
// modify output
foreach($answer["output"] as $key => $item){
// status
if($item["status"]==1){
$answer["output"][$key]["status"] = 'Active';
$answer["output"][$key]["bg_class"] = 'success';
}else{
$answer["output"][$key]["status"] = 'Inactive';
$answer["output"][$key]["bg_class"] = 'secondary';
}
}
$answer["success"] = 1;
exit(json_encode($answer));