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));
|
||||
|
||||
Reference in New Issue
Block a user