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 Inventory → Warehouse to create your first warehouse before using this page.'; } exit(json_encode($answer)); ?>