warehouse capacity and occupancy
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
session_start();
|
||||
require '../../../assets/utils/db_auth.php';
|
||||
require '../../../assets/utils/classes/WarehouseManager.php';
|
||||
|
||||
try {
|
||||
dbTransaction($pdo2, function($pdo) use ($data, $company_id, $logging) {
|
||||
@@ -48,17 +49,36 @@
|
||||
|
||||
$params[":id"] = $id;
|
||||
|
||||
$sth = $pdo->prepare($sql);
|
||||
$sth->execute($params);
|
||||
|
||||
$storage_id = $id;
|
||||
|
||||
} else {
|
||||
|
||||
$sql = "INSERT INTO md_storage
|
||||
(company_id, warehouse, zone, aisle_from, aisle_to, rack_from, rack_to, description, status, `log`)
|
||||
(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)";
|
||||
(:company_id, :warehouse, :zone, :aisle_from, :aisle_to,
|
||||
:rack_from, :rack_to, :description, :status, :log)";
|
||||
|
||||
$sth = $pdo->prepare($sql);
|
||||
$sth->execute($params);
|
||||
|
||||
$storage_id = (int) $pdo->lastInsertId();
|
||||
}
|
||||
|
||||
$sth = $pdo->prepare($sql);
|
||||
$sth->execute($params);
|
||||
|
||||
// Sync md_rack rows — same $pdo, inside the same transaction
|
||||
$wm = new WarehouseManager($pdo, $company_id);
|
||||
$wm->syncRacks($storage_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'],
|
||||
]);
|
||||
});
|
||||
|
||||
$answer["success"] = 1;
|
||||
@@ -69,7 +89,7 @@
|
||||
|
||||
} catch (Exception $e) {
|
||||
$answer["success"] = 0;
|
||||
$answer["message"] = "Something went wrong";
|
||||
$answer["message"] = $e->getMessage();
|
||||
}
|
||||
|
||||
exit(json_encode($answer));
|
||||
|
||||
Reference in New Issue
Block a user