mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 12:20:22 +00:00
Implemented multiple/named shopping lists (closes #190)
This commit is contained in:
@@ -430,7 +430,7 @@ class StockService extends BaseService
|
||||
return $this->Database->lastInsertId();
|
||||
}
|
||||
|
||||
public function AddMissingProductsToShoppingList()
|
||||
public function AddMissingProductsToShoppingList($listId = 1)
|
||||
{
|
||||
$missingProducts = $this->GetMissingProducts();
|
||||
foreach ($missingProducts as $missingProduct)
|
||||
@@ -444,7 +444,8 @@ class StockService extends BaseService
|
||||
if ($alreadyExistingEntry->amount < $amountToAdd)
|
||||
{
|
||||
$alreadyExistingEntry->update(array(
|
||||
'amount' => $amountToAdd
|
||||
'amount' => $amountToAdd,
|
||||
'shopping_list_id' => $listId
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -452,16 +453,17 @@ class StockService extends BaseService
|
||||
{
|
||||
$shoppinglistRow = $this->Database->shopping_list()->createRow(array(
|
||||
'product_id' => $missingProduct->id,
|
||||
'amount' => $amountToAdd
|
||||
'amount' => $amountToAdd,
|
||||
'shopping_list_id' => $listId
|
||||
));
|
||||
$shoppinglistRow->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function ClearShoppingList()
|
||||
public function ClearShoppingList($listId = 1)
|
||||
{
|
||||
$this->Database->shopping_list()->delete();
|
||||
$this->Database->shopping_list()->where('shopping_list_id = :1', $listId)->delete();
|
||||
}
|
||||
|
||||
private function ProductExists($productId)
|
||||
|
Reference in New Issue
Block a user