mirror of
https://github.com/grocy/grocy.git
synced 2026-04-05 12:26:15 +02:00
Fixed error when using notes instead of products
This commit is contained in:
parent
b3be8b155f
commit
97f9d486cd
|
|
@ -951,24 +951,28 @@ class StockService extends BaseService
|
||||||
$result_product = array();
|
$result_product = array();
|
||||||
$result_quantity = array();
|
$result_quantity = array();
|
||||||
$rowsShoppingListProducts = $this->getDatabase()->uihelper_shopping_list()->where('shopping_list_id = :1', $listId)->fetchAll();
|
$rowsShoppingListProducts = $this->getDatabase()->uihelper_shopping_list()->where('shopping_list_id = :1', $listId)->fetchAll();
|
||||||
foreach ($rowsShoppingListProducts as $row) {
|
foreach ($rowsShoppingListProducts as $row)
|
||||||
$product = $this->getDatabase()->products()->where('id = :1', $row->product_id)->fetch();
|
{
|
||||||
$conversion = $this->getDatabase()->quantity_unit_conversions_resolved()->where('product_id = :1 AND from_qu_id = :2 AND to_qu_id = :3', $product->id, $product->qu_id_stock, $row->qu_id)->fetch();
|
$isValidProduct = ($row->product_id != null && $row->product_id != "");
|
||||||
$factor = 1.0;
|
if ($isValidProduct)
|
||||||
if ($conversion != null)
|
|
||||||
{
|
{
|
||||||
$factor = floatval($conversion->factor);
|
$product = $this->getDatabase()->products()->where('id = :1', $row->product_id)->fetch();
|
||||||
}
|
$conversion = $this->getDatabase()->quantity_unit_conversions_resolved()->where('product_id = :1 AND from_qu_id = :2 AND to_qu_id = :3', $product->id, $product->qu_id_stock, $row->qu_id)->fetch();
|
||||||
$amount = round($row->amount * $factor);
|
$factor = 1.0;
|
||||||
$note = "";
|
if ($conversion != null)
|
||||||
if (GROCY_TPRINTER_PRINT_NOTES)
|
|
||||||
{
|
|
||||||
if ($row->note != "")
|
|
||||||
{
|
{
|
||||||
$note = ' (' . $row->note . ')';
|
$factor = floatval($conversion->factor);
|
||||||
|
}
|
||||||
|
$amount = round($row->amount * $factor);
|
||||||
|
$note = "";
|
||||||
|
if (GROCY_TPRINTER_PRINT_NOTES)
|
||||||
|
{
|
||||||
|
if ($row->note != "") {
|
||||||
|
$note = ' (' . $row->note . ')';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (GROCY_TPRINTER_PRINT_QUANTITY_NAME)
|
if (GROCY_TPRINTER_PRINT_QUANTITY_NAME && $isValidProduct)
|
||||||
{
|
{
|
||||||
$quantityname = $row->qu_name;
|
$quantityname = $row->qu_name;
|
||||||
if ($amount > 1)
|
if ($amount > 1)
|
||||||
|
|
@ -980,8 +984,17 @@ class StockService extends BaseService
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
array_push($result_quantity, $amount);
|
if ($isValidProduct)
|
||||||
array_push($result_product, $row->product_name . $note);
|
{
|
||||||
|
array_push($result_quantity, $amount);
|
||||||
|
array_push($result_product, $row->product_name . $note);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
array_push($result_quantity, round($row->amount));
|
||||||
|
array_push($result_product, $row->note);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Add padding to look nicer
|
//Add padding to look nicer
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user