more OOP and restructure utils
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
session_start();
|
||||
|
||||
require '../../../assets/utils/db_auth.php';
|
||||
require '../../../assets/utils/classes/FileUploader.php';
|
||||
|
||||
$id = (int)$data['id'];
|
||||
|
||||
@@ -57,6 +58,7 @@
|
||||
sku = :sku,
|
||||
price = :price,
|
||||
min_stock = :min_stock,
|
||||
reorder_point = :reorder_point,
|
||||
category = :category,
|
||||
product_image = :product_image,
|
||||
`description` = :description,
|
||||
@@ -72,6 +74,7 @@
|
||||
":sku" => $data["sku"],
|
||||
":price" => $data["price"],
|
||||
":min_stock" => $data["min_stock"],
|
||||
":reorder_point" => $data["reorder_point"],
|
||||
":category" => $data["category"],
|
||||
":product_image"=> $db_image_string,
|
||||
":description" => $data["description"],
|
||||
@@ -82,9 +85,9 @@
|
||||
} else {
|
||||
|
||||
$sql = "INSERT INTO md_product
|
||||
(company_id, product_name, sku, price, min_stock, category, product_image, `description`, `status`, `log`)
|
||||
(company_id, product_name, sku, price, min_stock, reorder_point, category, product_image, `description`, `status`, `log`)
|
||||
VALUES
|
||||
(:company_id, :product_name, :sku, :price, :min_stock, :category, :product_image, :description, :status, :log)";
|
||||
(:company_id, :product_name, :sku, :price, :min_stock, :reorder_point, :category, :product_image, :description, :status, :log)";
|
||||
|
||||
$sth = $pdo->prepare($sql);
|
||||
$sth->execute([
|
||||
@@ -93,6 +96,7 @@
|
||||
":sku" => $data["sku"],
|
||||
":price" => $data["price"],
|
||||
":min_stock" => $data["min_stock"],
|
||||
":reorder_point" => $data["reorder_point"],
|
||||
":category" => $data["category"],
|
||||
":product_image"=> $db_image_string,
|
||||
":description" => $data["description"],
|
||||
|
||||
@@ -3,10 +3,14 @@
|
||||
|
||||
require '../../../assets/utils/db_auth.php';
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM md_product
|
||||
$sql = "SELECT a.* , IFNULL(SUM(b.total_in-b.total_out),0) AS product_balance
|
||||
FROM md_product a
|
||||
LEFT JOIN warehouse_balance b ON
|
||||
a.company_id = b.company_id AND
|
||||
a.sku = b.product_sku
|
||||
WHERE
|
||||
company_id = {$company_id}";
|
||||
a.company_id = {$company_id}
|
||||
GROUP BY a.id";
|
||||
$sth = $pdo2->prepare($sql);
|
||||
$sth->execute([
|
||||
":company_id" => $company_id
|
||||
|
||||
@@ -3,10 +3,14 @@
|
||||
|
||||
require '../../../assets/utils/db_auth.php';
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM md_product_category
|
||||
$sql = "SELECT a.* , COUNT(b.id) AS product_count
|
||||
FROM md_product_category a
|
||||
LEFT JOIN md_product b ON
|
||||
a.company_id = b.company_id AND
|
||||
a.id = b.category
|
||||
WHERE
|
||||
company_id = {$company_id}";
|
||||
a.company_id = {$company_id}
|
||||
GROUP BY a.id";
|
||||
$sth = $pdo2->prepare($sql);
|
||||
$sth->execute([
|
||||
":company_id" => $company_id
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
require '../../../assets/utils/db_auth.php';
|
||||
require '../../../assets/utils/classes/Reports.php';
|
||||
|
||||
$report = new Reports($pdo2, $company_id);
|
||||
|
||||
$answer["total_category"] = $report->getTotalCategory();
|
||||
$answer["active_category"] = $report->getActiveCategory();
|
||||
$answer["inactive_category"] = $report->getInactiveCategory();
|
||||
$answer["total_product"] = $report->getTotalProduct();
|
||||
$answer["success"] = 1;
|
||||
exit(json_encode($answer));
|
||||
|
||||
?>
|
||||
@@ -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));
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
require '../../../assets/utils/db_auth.php';
|
||||
require '../../../assets/utils/classes/Reports.php';
|
||||
|
||||
$report = new Reports($pdo2, $company_id);
|
||||
|
||||
$answer["total_warehouse"] = $report->getTotalWarehouse();
|
||||
$answer["total_location"] = $report->getTotalLocation();
|
||||
$answer["total_capacity"] = $report->getTotalCapacity();
|
||||
$answer["total_product"] = $report->getTotalProduct();
|
||||
$answer["success"] = 1;
|
||||
|
||||
exit(json_encode($answer));
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user