diff --git a/controllers/StockController.php b/controllers/StockController.php index c6f0e82c..869b3427 100644 --- a/controllers/StockController.php +++ b/controllers/StockController.php @@ -81,6 +81,25 @@ class StockController extends BaseController ]); } + public function OfflineShoppingList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args) + { + $listId = 1; + if (isset($request->getQueryParams()['list'])) + { + $listId = $request->getQueryParams()['list']; + } + + return $this->AppContainer->view->render($response, 'offlineshoppinglist', [ + 'listItems' => $this->Database->shopping_list()->where('shopping_list_id = :1', $listId), + 'products' => $this->Database->products()->orderBy('name'), + 'quantityunits' => $this->Database->quantity_units()->orderBy('name'), + 'missingProducts' => $this->StockService->GetMissingProducts(), + 'productGroups' => $this->Database->product_groups()->orderBy('name'), + 'shoppingLists' => $this->Database->shopping_lists()->orderBy('name'), + 'selectedShoppingListId' => $listId + ]); + } + public function ProductsList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args) { return $this->AppContainer->view->render($response, 'products', [ diff --git a/routes.php b/routes.php index 577e50e6..8c839fd8 100644 --- a/routes.php +++ b/routes.php @@ -50,6 +50,7 @@ $app->group('', function() $this->get('/shoppinglist', '\Grocy\Controllers\StockController:ShoppingList'); $this->get('/shoppinglistitem/{itemId}', '\Grocy\Controllers\StockController:ShoppingListItemEditForm'); $this->get('/shoppinglist/{listId}', '\Grocy\Controllers\StockController:ShoppingListEditForm'); + $this->get('/offlineshoppinglist', '\Grocy\Controllers\StockController:OfflineShoppingList'); } // Recipe routes @@ -99,7 +100,7 @@ $app->group('', function() $this->get('/equipment', '\Grocy\Controllers\EquipmentController:Overview'); $this->get('/equipment/{equipmentId}', '\Grocy\Controllers\EquipmentController:EditForm'); } - + // Calendar routes if (GROCY_FEATURE_FLAG_CALENDAR) { @@ -119,9 +120,9 @@ $app->group('/api', function() // System $this->get('/system/info', '\Grocy\Controllers\SystemApiController:GetSystemInfo'); - $this->get('/system/db-changed-time', '\Grocy\Controllers\SystemApiController:GetDbChangedTime'); + $this->get('/system/db-changed-time', '\Grocy\Controllers\SystemApiController:GetDbChangedTime'); $this->post('/system/log-missing-localization', '\Grocy\Controllers\SystemApiController:LogMissingLocalization'); - + // Generic entity interaction $this->get('/objects/{entity}', '\Grocy\Controllers\GenericEntityApiController:GetObjects'); $this->get('/objects/{entity}/{objectId}', '\Grocy\Controllers\GenericEntityApiController:GetObject'); diff --git a/views/offlineshoppinglist.blade.php b/views/offlineshoppinglist.blade.php new file mode 100644 index 00000000..70f108e3 --- /dev/null +++ b/views/offlineshoppinglist.blade.php @@ -0,0 +1,59 @@ +@extends('layout.default') + +@section('title', $__t('Shopping list')) +@section('activeNav', 'shoppinglist') +@section('viewJsName', 'shoppinglist') + +@push('pageScripts') + + + +@endpush + +@push('pageStyles') + +@endpush + +@section('content') +
| + | {{ $__t('Product') }} / {{ $__t('Note') }} | +{{ $__t('Amount') }} | +Hiden product group | +Hidden status | +
|---|---|---|---|---|
| + |
+ @if(!empty($listItem->product_id)) {{ FindObjectInArrayByPropertyValue($products, 'id', $listItem->product_id)->name }} @else{!! nl2br($listItem->note) !!}@endif + |
+ + {{ $listItem->amount }} @if(!empty($listItem->product_id)){{ $__n($listItem->amount, FindObjectInArrayByPropertyValue($quantityunits, 'id', FindObjectInArrayByPropertyValue($products, 'id', $listItem->product_id)->qu_id_purchase)->name, FindObjectInArrayByPropertyValue($quantityunits, 'id', FindObjectInArrayByPropertyValue($products, 'id', $listItem->product_id)->qu_id_purchase)->name_plural) }}@endif + | ++ @if(!empty(FindObjectInArrayByPropertyValue($products, 'id', $listItem->product_id)->product_group_id)) {{ FindObjectInArrayByPropertyValue($productGroups, 'id', FindObjectInArrayByPropertyValue($products, 'id', $listItem->product_id)->product_group_id)->name }} @else {{ $__t('Ungrouped') }} @endif + | ++ @if(FindObjectInArrayByPropertyValue($missingProducts, 'id', $listItem->product_id) !== null) belowminstockamount @endif + | +