Return JSON from any uncaught engine exception, stop the empty stock-out warehouse list aborting page boot, reject non-transfer rows in the transfer lookup, define the missing reset_input helper, and remove a stale unreferenced copy of confirm_order.php.
44 lines
1.8 KiB
PHP
44 lines
1.8 KiB
PHP
<?php
|
|
session_start();
|
|
require_once '../../../assets/utils/db_auth.php';
|
|
require_once '../../../assets/utils/classes/WarehouseManager.php';
|
|
|
|
$wh = new WarehouseManager($pdo2, $company_id);
|
|
$type = $data['type'] ?? '';
|
|
$sku = $data['product_sku'] ?? '';
|
|
$lot = $data['lot_number'] ?? '';
|
|
$id = (int)($data['id'] ?? 0);
|
|
|
|
// When type=from and a lot is selected, filter warehouses to only those
|
|
// holding that specific lot in an approved, bin-occupied stock-in row.
|
|
if ($type === 'from' && $sku && $lot) {
|
|
$answer['output'] = $wh->getWarehousesByLot($sku, $lot);
|
|
} else {
|
|
$answer['output'] = $wh->getWarehouseList($type, $sku, $id);
|
|
}
|
|
|
|
if (!empty($answer['output'])) {
|
|
$answer['success'] = 1;
|
|
|
|
} elseif ($type === 'from' && !$id && $sku === '') {
|
|
// A source ("from") list is filtered to warehouses holding the chosen
|
|
// product, so it is empty until a product has been picked. That is the
|
|
// normal starting state of a stock-out form, not a failure. Reporting
|
|
// it as one showed "create your first warehouse" on every fresh
|
|
// stock-out, and the rejected request aborted the page's boot sequence
|
|
// before the barcode scanner was initialised.
|
|
$answer['success'] = 1;
|
|
|
|
} elseif ($type === 'from' && $sku !== '') {
|
|
$answer['success'] = 0;
|
|
$answer['message'] = $lot
|
|
? 'No approved stock of this product and lot is available in any warehouse.'
|
|
: 'No approved stock of this product is available in any warehouse.';
|
|
|
|
} else {
|
|
$answer['success'] = 0;
|
|
$answer['message'] = 'No warehouse found. Please go to <b>Inventory → Warehouse</b> to create your first warehouse before using this page.';
|
|
}
|
|
exit(json_encode($answer));
|
|
?>
|