-
+
+
+ placeholder="Type product sku..." autocomplete="off" required>
+
+
+
+
-
+
@@ -45,26 +49,26 @@
-
+
-
-
+
-
+
@@ -106,6 +110,7 @@
autoPrepare: true,
checkRequired: 0,
debugMode: 0,
+ action: 'manage',
onSuccess: function(res) {
window.location.href = "ics/stock_in.php";
@@ -123,6 +128,7 @@
url: "inventory/api/engine/warehouse.php",
autoPrepare: true,
checkRequired: 0,
+ action: 'read',
onSuccess: function(res) {
var option = `
`;
$.each(res.output, function(key, item) {
@@ -143,6 +149,7 @@
autoPrepare: true,
checkRequired: 0,
noLoading: true,
+ action: 'read',
onSuccess: function(res) {
var option = `
`;
$.each(res.output, function(key, item) {
@@ -163,6 +170,7 @@
autoPrepare: true,
checkRequired: 0,
noLoading: true,
+ action: 'read',
onSuccess: function(res) {
var option = `
`;
$.each(res.output, function(key, item) {
@@ -183,6 +191,7 @@
autoPrepare: true,
checkRequired: 0,
noLoading: true,
+ action: 'read',
onSuccess: function(res) {
var option = `
`;
$.each(res.output, function(key, item) {
diff --git a/app/inventory/api/engine/manage_warehouse.php b/app/inventory/api/engine/manage_warehouse.php
index 7caeb32..d0425c1 100644
--- a/app/inventory/api/engine/manage_warehouse.php
+++ b/app/inventory/api/engine/manage_warehouse.php
@@ -5,6 +5,8 @@ require '../../../assets/utils/db_auth.php';
$id = (int)($data['id'] ?? 0);
+$pdo2->beginTransaction();
+
// get existing log
$sql = "SELECT `log`
FROM md_warehouse
@@ -51,6 +53,7 @@ if ($id > 0) {
":status" => (int)($data["status"] ?? 1),
":log" => json_encode($table_log, JSON_UNESCAPED_UNICODE),
]);
+ db_check($sth, $answer);
} else {
@@ -70,10 +73,25 @@ if ($id > 0) {
":status" => (int)($data["status"] ?? 1),
":log" => json_encode($table_log, JSON_UNESCAPED_UNICODE),
]);
+ db_check($sth, $answer);
+
+
+
+ if(!empty($data["warehouse_name"])){
+ /**
+ * Create warehouse table
+ */
+ $safe_name = 'td_stock_' . preg_replace('/[^a-zA-Z0-9_]/', '', $data["warehouse_name"]);
+
+ $sql = "CREATE TABLE `$safe_name` LIKE `td_stock`";
+ $sth = $pdo2->prepare($sql);
+ $sth->execute();
+ db_check($sth, $answer);
+ }
}
-db_check($sth, $answer);
+$pdo2->commit();
$answer["success"] = 1;
exit(json_encode($answer));
diff --git a/app/inventory/manage_storage.php b/app/inventory/manage_storage.php
index a018887..8185301 100644
--- a/app/inventory/manage_storage.php
+++ b/app/inventory/manage_storage.php
@@ -90,6 +90,7 @@
autoPrepare: true,
checkRequired: 0,
debugMode: 0,
+ action: 'manage',
onSuccess: function(res) {
window.location.href = "inventory/warehouse.php";
@@ -106,6 +107,7 @@
url: "inventory/api/engine/warehouse.php",
autoPrepare: true,
checkRequired: 0,
+ action: 'read',
onSuccess: function(res) {
var option = ``;
$.each(res.output, function(key, item) {
@@ -124,6 +126,7 @@
url: "inventory/api/engine/retrieve_storage.php",
autoPrepare: true,
checkRequired: 0,
+ action: 'read',
onSuccess: function(res) {
$.each(res.output, function(key, item) {
diff --git a/app/inventory/manage_warehouse.php b/app/inventory/manage_warehouse.php
index 06ebc43..0b80f35 100644
--- a/app/inventory/manage_warehouse.php
+++ b/app/inventory/manage_warehouse.php
@@ -81,7 +81,7 @@
return ajax_request({
url: "inventory/api/engine/manage_warehouse.php",
autoPrepare: true,
- checkRequired: 0,
+ checkRequired: 1,
debugMode: 0,
action: 'manage',
onSuccess: function(res) {