mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 04:12:59 +00:00
Reuse existing shopping list items when adding products from the stock overview page (closes #375)
This commit is contained in:
@@ -569,7 +569,7 @@ class StockService extends BaseService
|
||||
}
|
||||
}
|
||||
|
||||
public function AddProductToShoppingList($productId, $amount = 1, $listId = 1)
|
||||
public function AddProductToShoppingList($productId, $amount = 1, $note = null, $listId = 1)
|
||||
{
|
||||
if (!$this->ShoppingListExists($listId))
|
||||
{
|
||||
@@ -586,7 +586,8 @@ class StockService extends BaseService
|
||||
{
|
||||
$alreadyExistingEntry->update(array(
|
||||
'amount' => ($alreadyExistingEntry->amount + $amount),
|
||||
'shopping_list_id' => $listId
|
||||
'shopping_list_id' => $listId,
|
||||
'note' => $note
|
||||
));
|
||||
}
|
||||
else // Insert
|
||||
@@ -594,7 +595,8 @@ class StockService extends BaseService
|
||||
$shoppinglistRow = $this->Database->shopping_list()->createRow(array(
|
||||
'product_id' => $productId,
|
||||
'amount' => $amount,
|
||||
'shopping_list_id' => $listId
|
||||
'shopping_list_id' => $listId,
|
||||
'note' => $note
|
||||
));
|
||||
$shoppinglistRow->save();
|
||||
}
|
||||
|
Reference in New Issue
Block a user