more OOP and restructure utils
This commit is contained in:
@@ -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));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user