stock database design
This commit is contained in:
@@ -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));
|
||||
|
||||
@@ -90,6 +90,7 @@
|
||||
autoPrepare: true,
|
||||
checkRequired: 0,
|
||||
debugMode: 0,
|
||||
action: 'manage',
|
||||
onSuccess: function(res) {
|
||||
|
||||
window.location.href = "<?php echo $server_url?>inventory/warehouse.php";
|
||||
@@ -106,6 +107,7 @@
|
||||
url: "<?php echo $server_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: "<?php echo $server_url?>inventory/api/engine/retrieve_storage.php",
|
||||
autoPrepare: true,
|
||||
checkRequired: 0,
|
||||
action: 'read',
|
||||
onSuccess: function(res) {
|
||||
|
||||
$.each(res.output, function(key, item) {
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
return ajax_request({
|
||||
url: "<?php echo $server_url?>inventory/api/engine/manage_warehouse.php",
|
||||
autoPrepare: true,
|
||||
checkRequired: 0,
|
||||
checkRequired: 1,
|
||||
debugMode: 0,
|
||||
action: 'manage',
|
||||
onSuccess: function(res) {
|
||||
|
||||
Reference in New Issue
Block a user