Files
wms-app/app/ics/api/engine/retrieve_rack.php
T
2026-03-21 14:58:15 +07:00

57 lines
1.5 KiB
PHP

<?php
session_start();
require '../../../assets/utils/db_auth.php';
// identity source of zone and aisle
if(empty($data["type"])){
$warehouse = (int)$data['warehouse'];
$zone = $data['zone'];
$aisle = $data["aisle"];
}else{
$warehouse = (int)$data['warehouse_'.$data["type"]];
$zone = $data['zone_'.$data["type"]];
$aisle = $data["aisle_".$data["type"]];
}
// Detect if numeric and zero-pad both input and query columns
if (is_numeric($aisle)) {
$aisle = str_pad($aisle, 5, '0', STR_PAD_LEFT);
$condition = "LPAD(aisle_from, 5, '0') <= :aisle_from AND LPAD(aisle_to, 5, '0') >= :aisle_to";
} else {
$condition = ":aisle_from >= aisle_from AND :aisle_to <= aisle_to";
}
$id = (int)$data['id'];
$sql = "SELECT *
FROM md_storage
WHERE
company_id = :company_id and
warehouse = :warehouse and
`zone` = :zone and
$condition
";
$sth = $pdo2->prepare($sql);
$sth->execute([
":company_id" => $company_id,
":warehouse" => $warehouse,
":zone" => $zone,
":aisle_from" => $aisle,
":aisle_to" => $aisle
]);
db_check($sth, $answer);
$pre = $sth->fetchAll(PDO::FETCH_ASSOC);
$output = [];
foreach ($pre as $key => $value) {
$output = array_merge($output, range($value["rack_from"], $value["rack_to"]));
}
$answer["output"] = $output;
$answer["success"] = 1;
exit(json_encode($answer));
?>