mirror of
https://github.com/grocy/grocy.git
synced 2026-03-27 23:29:25 +01:00
added stock entry data if barcode is stock entry
This commit is contained in:
parent
02f5452c75
commit
7aa4c30a02
|
|
@ -621,7 +621,22 @@ class StockApiController extends BaseApiController
|
|||
try
|
||||
{
|
||||
$productId = $this->getStockService()->GetProductIdFromBarcode($args['barcode']);
|
||||
return $this->ApiResponse($response, $this->getStockService()->GetProductDetails($productId));
|
||||
$product_data = $this->getStockService()->GetProductDetails($productId);
|
||||
|
||||
if (Grocycode::Validate($args['barcode']))
|
||||
{
|
||||
$gc = new Grocycode($args['barcode']);
|
||||
|
||||
if ($gc->GetExtraData())
|
||||
{
|
||||
$stock_data = $this->getDatabase()->stock()->where('stock_id', $gc->GetExtraData()[0])->fetch();
|
||||
$data = $product_data + ['stock_entry' => $stock_data];
|
||||
} else {
|
||||
$data = $product_data + ['stock_entry' => null];
|
||||
}
|
||||
}
|
||||
|
||||
return $this->ApiResponse($response, $data);
|
||||
}
|
||||
catch (\Exception $ex)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user