This commit is contained in:
Thanakorn S
2026-02-19 14:48:40 +07:00
commit 9a50080ae5
221 changed files with 30788 additions and 0 deletions
@@ -0,0 +1,69 @@
<?php
session_start();
require '../../../preset.php';
require '../../../assets/utils/db_auth.php';
$id = (int)$data['id'];
// get existing log
$sql = "SELECT `log`
FROM md_product_category
WHERE
company_id = {$company_id} and
id = {$id}";
$sth = $pdo2->prepare($sql);
$sth->execute();
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
exit(json_encode($answer));
}
$row = $sth->fetch(PDO::FETCH_ASSOC);
$table_log = json_decode($row['log'] ?? '[]', true);
$table_log[] = $logging;
if ($id > 0) {
$sql = "UPDATE md_product_category SET
`category` = :category,
`slug` = :slug,
`description` = :description,
`status` = :status,
`log` = :log
WHERE id = :id AND company_id = :company_id";
$sth = $pdo2->prepare($sql);
$sth->execute([
":id" => $id,
":company_id" => $company_id,
":category" => $data["category"],
":slug" => $data["slug"],
":description" => $data["description"],
":status" => $data["status"],
":log" => json_encode($table_log),
]);
} else {
$sql = "INSERT INTO md_product_category
(company_id, category, slug, `description`, `status`, `log`)
VALUES
(:company_id, :category, :slug, :description, :status, :log)";
$sth = $pdo2->prepare($sql);
$sth->execute([
":company_id" => $company_id,
":category" => $data["category"],
":slug" => $data["slug"],
":description" => $data["description"],
":status" => $data["status"],
":log" => json_encode($table_log),
]);
}
$answer["success"] = 1;
exit(json_encode($answer));
?>
@@ -0,0 +1,79 @@
<?php
session_start();
require '../../../preset.php';
require '../../../assets/utils/db_auth.php';
$id = (int)$data['id'];
// get existing log
$sql = "SELECT `log`
FROM md_product
WHERE
company_id = {$company_id} and
id = {$id}";
$sth = $pdo2->prepare($sql);
$sth->execute();
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
exit(json_encode($answer));
}
$row = $sth->fetch(PDO::FETCH_ASSOC);
$table_log = json_decode($row['log'] ?? '[]', true);
$table_log[] = $logging;
if ($id > 0) {
$sql = "UPDATE md_product SET
product_name = :product_name,
sku = :sku,
price = :price,
category = :category,
product_image = :product_image,
`description` = :description,
`status` = :status,
`log` = :log
WHERE id = :id AND company_id = :company_id";
$sth = $pdo2->prepare($sql);
$sth->execute([
":id" => $id,
":company_id" => $company_id,
":product_name" => $data["product_name"],
":sku" => $data["sku"],
":price" => $data["price"],
":category" => $data["category"],
":product_image"=> $data["product_image"],
":description" => $data["description"],
":status" => $data["status"],
":log" => json_encode($table_log),
]);
} else {
$sql = "INSERT INTO md_product
(company_id, product_name, sku, price, category, product_image, `description`, `status`, `log`)
VALUES
(:company_id, :product_name, :sku, :price, :category, :product_image, :description, :status, :log)";
$sth = $pdo2->prepare($sql);
$sth->execute([
":company_id" => $company_id,
":product_name" => $data["product_name"],
":sku" => $data["sku"],
":price" => $data["price"],
":category" => $data["category"],
":product_image"=> $data["product_image"],
":description" => $data["description"],
":status" => $data["status"],
":log" => json_encode($table_log),
]);
}
$answer["success"] = 1;
exit(json_encode($answer));
?>
@@ -0,0 +1,99 @@
<?php
session_start();
require '../../../preset.php';
require '../../../assets/utils/db_auth.php';
$id = (int)($data['id'] ?? 0);
// get existing log
$sql = "SELECT `log`
FROM md_storage
WHERE company_id = :company_id
AND id = :id";
$sth = $pdo2->prepare($sql);
$sth->execute([
':company_id' => $company_id,
':id' => $id,
]);
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
exit(json_encode($answer));
}
$row = $sth->fetch(PDO::FETCH_ASSOC);
$table_log = json_decode($row['log'] ?? '[]', true);
if (!is_array($table_log)) $table_log = [];
// add new log entry (assumes $logging already prepared)
$table_log[] = $logging;
if ($id > 0) {
$sql = "UPDATE md_storage SET
warehouse = :warehouse,
zone = :zone,
aisle_from = :aisle_from,
aisle_to = :aisle_to,
rack_from = :rack_from,
rack_to = :rack_to,
description = :description,
status = :status,
`log` = :log
WHERE id = :id
AND company_id = :company_id";
$sth = $pdo2->prepare($sql);
$sth->execute([
":id" => $id,
":company_id" => $company_id,
":warehouse" => $data["warehouse"] ?? "",
":zone" => $data["zone"] ?? "",
":aisle_from" => $data["aisle_from"] ?? "",
":aisle_to" => $data["aisle_to"] ?? "",
":rack_from" => $data["rack_from"] ?? "",
":rack_to" => $data["rack_to"] ?? "",
":description" => $data["description"] ?? "",
":status" => (int)($data["status"] ?? 1),
":log" => json_encode($table_log, JSON_UNESCAPED_UNICODE),
]);
} else {
$sql = "INSERT INTO md_storage
(company_id, warehouse, zone, aisle_from, aisle_to, rack_from, rack_to, description, status, `log`)
VALUES
(:company_id, :warehouse, :zone, :aisle_from, :aisle_to, :rack_from, :rack_to, :description, :status, :log)";
$sth = $pdo2->prepare($sql);
$sth->execute([
":company_id" => $company_id,
":warehouse" => $data["warehouse"] ?? "",
":zone" => $data["zone"] ?? "",
":aisle_from" => $data["aisle_from"] ?? "",
":aisle_to" => $data["aisle_to"] ?? "",
":rack_from" => $data["rack_from"] ?? "",
":rack_to" => $data["rack_to"] ?? "",
":description" => $data["description"] ?? "",
":status" => (int)($data["status"] ?? 1),
":log" => json_encode($table_log, JSON_UNESCAPED_UNICODE),
]);
}
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
exit(json_encode($answer));
}
$answer["success"] = 1;
exit(json_encode($answer));
?>
@@ -0,0 +1,86 @@
<?php
session_start();
require '../../../preset.php';
require '../../../assets/utils/db_auth.php';
$id = (int)($data['id'] ?? 0);
// get existing log
$sql = "SELECT `log`
FROM md_warehouse
WHERE company_id = :company_id
AND id = :id";
$sth = $pdo2->prepare($sql);
$sth->execute([
':company_id' => $company_id,
':id' => $id,
]);
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
exit(json_encode($answer));
}
$row = $sth->fetch(PDO::FETCH_ASSOC);
$table_log = json_decode($row['log'] ?? '[]', true);
if (!is_array($table_log)) $table_log = [];
// add new log entry (assumes $logging already prepared)
$table_log[] = $logging;
if ($id > 0) {
$sql = "UPDATE md_warehouse SET
warehouse_name = :warehouse_name,
location = :location,
manager = :manager,
capacity = :capacity,
description = :description,
status = :status,
`log` = :log
WHERE id = :id
AND company_id = :company_id";
$sth = $pdo2->prepare($sql);
$sth->execute([
":id" => $id,
":company_id" => $company_id,
":warehouse_name" => $data["warehouse_name"] ?? "",
":location" => $data["location"] ?? "",
":manager" => (int)($data["manager"] ?? 0),
":capacity" => (int)($data["capacity"] ?? 0),
":description" => $data["description"] ?? "",
":status" => (int)($data["status"] ?? 1),
":log" => json_encode($table_log, JSON_UNESCAPED_UNICODE),
]);
} else {
$sql = "INSERT INTO md_warehouse
(company_id, warehouse_name, location, manager, capacity, description, status, `log`)
VALUES
(:company_id, :warehouse_name, :location, :manager, :capacity, :description, :status, :log)";
$sth = $pdo2->prepare($sql);
$sth->execute([
":company_id" => $company_id,
":warehouse_name" => $data["warehouse_name"] ?? "",
":location" => $data["location"] ?? "",
":manager" => (int)($data["manager"] ?? 0),
":capacity" => (int)($data["capacity"] ?? 0),
":description" => $data["description"] ?? "",
":status" => (int)($data["status"] ?? 1),
":log" => json_encode($table_log, JSON_UNESCAPED_UNICODE),
]);
}
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
exit(json_encode($answer));
}
$answer["success"] = 1;
exit(json_encode($answer));
?>
+22
View File
@@ -0,0 +1,22 @@
<?php
session_start();
require '../../../preset.php';
require '../../../assets/utils/db_auth.php';
$sql = "SELECT *
FROM user
WHERE
username not in ('support','extra')";
$sth = $pdo1->prepare($sql);
$sth->execute();
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
exit(json_encode($answer));
}
$answer["output"] = $sth->fetchAll(PDO::FETCH_ASSOC);
$answer["success"] = 1;
exit(json_encode($answer));
?>
+22
View File
@@ -0,0 +1,22 @@
<?php
session_start();
require '../../../preset.php';
require '../../../assets/utils/db_auth.php';
$sql = "SELECT *
FROM md_product
WHERE
company_id = {$company_id}";
$sth = $pdo2->prepare($sql);
$sth->execute();
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
exit(json_encode($answer));
}
$answer["output"] = $sth->fetchAll(PDO::FETCH_ASSOC);
$answer["success"] = 1;
exit(json_encode($answer));
?>
@@ -0,0 +1,22 @@
<?php
session_start();
require '../../../preset.php';
require '../../../assets/utils/db_auth.php';
$sql = "SELECT *
FROM md_product_category
WHERE
company_id = {$company_id}";
$sth = $pdo2->prepare($sql);
$sth->execute();
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
exit(json_encode($answer));
}
$answer["output"] = $sth->fetchAll(PDO::FETCH_ASSOC);
$answer["success"] = 1;
exit(json_encode($answer));
?>
@@ -0,0 +1,54 @@
<?php
session_start();
require '../../../preset.php';
require '../../../assets/utils/db_auth.php';
$id = (int)$data['id'];
// get data
$sql = "SELECT *
FROM md_product_category
WHERE
company_id = {$company_id} and
id = {$id}";
$sth = $pdo2->prepare($sql);
$sth->execute();
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
exit(json_encode($answer));
}
$json = $sth->fetch(PDO::FETCH_ASSOC);
$json = json_encode($json);
// delete data
$sql = "DELETE FROM md_product_category
WHERE
company_id = {$company_id} and
id = {$id}";
$sth = $pdo2->prepare($sql);
$sth->execute();
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
exit(json_encode($answer));
}
// insert into archive
$sql = "INSERT INTO archive (`company_id`,`user_id`,`date`,`json`) VALUES ({$company_id},{$user_id},NOW(),'{$jsona}')";
$sth = $pdo2->prepare($sql);
$sth->execute();
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
exit(json_encode($answer));
}
$answer["success"] = 1;
exit(json_encode($answer));
?>
@@ -0,0 +1,26 @@
<?php
session_start();
require '../../../preset.php';
require '../../../assets/utils/db_auth.php';
$id = (int)$data['id'];
$sql = "SELECT *
FROM md_product_category
WHERE
company_id = {$company_id} and
id = {$id}";
$sth = $pdo2->prepare($sql);
$sth->execute();
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
exit(json_encode($answer));
}
$answer["output"] = $sth->fetch(PDO::FETCH_ASSOC);
$answer["success"] = 1;
exit(json_encode($answer));
?>
@@ -0,0 +1,26 @@
<?php
session_start();
require '../../../preset.php';
require '../../../assets/utils/db_auth.php';
$id = (int)$data['id'];
$sql = "SELECT *
FROM md_product
WHERE
company_id = {$company_id} and
id = {$id}";
$sth = $pdo2->prepare($sql);
$sth->execute();
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
exit(json_encode($answer));
}
$answer["output"] = $sth->fetch(PDO::FETCH_ASSOC);
$answer["success"] = 1;
exit(json_encode($answer));
?>
@@ -0,0 +1,26 @@
<?php
session_start();
require '../../../preset.php';
require '../../../assets/utils/db_auth.php';
$id = (int)$data['id'];
$sql = "SELECT *
FROM md_storage
WHERE
company_id = {$company_id} and
id = {$id}";
$sth = $pdo2->prepare($sql);
$sth->execute();
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
exit(json_encode($answer));
}
$answer["output"] = $sth->fetch(PDO::FETCH_ASSOC);
$answer["success"] = 1;
exit(json_encode($answer));
?>
@@ -0,0 +1,26 @@
<?php
session_start();
require '../../../preset.php';
require '../../../assets/utils/db_auth.php';
$id = (int)$data['id'];
$sql = "SELECT *
FROM md_warehouse
WHERE
company_id = {$company_id} and
id = {$id}";
$sth = $pdo2->prepare($sql);
$sth->execute();
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
exit(json_encode($answer));
}
$answer["output"] = $sth->fetch(PDO::FETCH_ASSOC);
$answer["success"] = 1;
exit(json_encode($answer));
?>
+31
View File
@@ -0,0 +1,31 @@
<?php
session_start();
require '../../../preset.php';
require '../../../assets/utils/db_auth.php';
$sql = "SELECT a.*, b.warehouse_name
FROM md_storage a
LEFT JOIN md_warehouse b ON
a.company_id = b.company_id and
a.warehouse = b.id
WHERE
a.company_id = {$company_id}";
$sth = $pdo2->prepare($sql);
$sth->execute();
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
exit(json_encode($answer));
}
$answer["output"] = $sth->fetchAll(PDO::FETCH_ASSOC);
// modify output
foreach($answer["output"] as $key => $item){
}
$answer["success"] = 1;
exit(json_encode($answer));
?>
+36
View File
@@ -0,0 +1,36 @@
<?php
session_start();
require '../../../preset.php';
require '../../../assets/utils/db_auth.php';
$sql = "SELECT a.*
FROM md_warehouse a
WHERE
a.company_id = {$company_id}";
$sth = $pdo2->prepare($sql);
$sth->execute();
if ($sth->errorInfo()[0] != "00000" && !empty($sth->errorInfo()[0])) {
$answer["message"] = (empty($sth->errorInfo()[2])) ? $sth->errorInfo()[0] : $sth->errorInfo()[2];
exit(json_encode($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));
?>