mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 04:12:59 +00:00
Improve API related changes regarding multiple shopping lists (references #190)
This commit is contained in:
@@ -432,6 +432,11 @@ class StockService extends BaseService
|
||||
|
||||
public function AddMissingProductsToShoppingList($listId = 1)
|
||||
{
|
||||
if (!$this->ShoppingListExists($listId))
|
||||
{
|
||||
throw new \Exception('Shopping list does not exist');
|
||||
}
|
||||
|
||||
$missingProducts = $this->GetMissingProducts();
|
||||
foreach ($missingProducts as $missingProduct)
|
||||
{
|
||||
@@ -463,6 +468,11 @@ class StockService extends BaseService
|
||||
|
||||
public function ClearShoppingList($listId = 1)
|
||||
{
|
||||
if (!$this->ShoppingListExists($listId))
|
||||
{
|
||||
throw new \Exception('Shopping list does not exist');
|
||||
}
|
||||
|
||||
$this->Database->shopping_list()->where('shopping_list_id = :1', $listId)->delete();
|
||||
}
|
||||
|
||||
@@ -472,6 +482,12 @@ class StockService extends BaseService
|
||||
return $productRow !== null;
|
||||
}
|
||||
|
||||
private function ShoppingListExists($listId)
|
||||
{
|
||||
$shoppingListRow = $this->Database->shopping_lists()->where('id = :1', $listId)->fetch();
|
||||
return $shoppingListRow !== null;
|
||||
}
|
||||
|
||||
private function LoadBarcodeLookupPlugin()
|
||||
{
|
||||
$pluginName = defined('GROCY_STOCK_BARCODE_LOOKUP_PLUGIN') ? GROCY_STOCK_BARCODE_LOOKUP_PLUGIN : '';
|
||||
|
Reference in New Issue
Block a user