Reuse existing shopping list items when adding products from the stock overview page (closes #375)

This commit is contained in:
Bernd Bestel
2019-09-24 18:27:50 +02:00
parent b0c7958891
commit 5351828e79
8 changed files with 63 additions and 13 deletions

View File

@@ -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();
}