mirror of
https://github.com/grocy/grocy.git
synced 2025-08-18 03:25:50 +00:00
Convert services to singletons and use lazy loading to improve performance (#479)
* use singletons to reduce need to recreate the same objects * unable to make the constructor private * comment out debug printing to log file * correct typo of treating self() as a var instead of a function * utilise Localisation service as a singleton * fix errent line that should have been commented * remove phpinfo * correct mistake in stock controller * try storing app in apcu * serialise inside the app closures * get timings for db-changed-time * get timings for db-changed-time * store localisation service in apcu * stor translations in apcu instead of localisation service (due to database connection) * correct syntax error * forgot to uncomment instance map * correct indentation and variable out of scope * more timings for app execution time * try apc caching for views * correct scope for Pot variable * remove additional fopen * correct timings for app build time * correct timings for app object build time * correct timings for app route build time * get timings for routing timings * get more in depth timings for routing loading * fix more in depth timings for routing loading * start investigating session auth middleware creation * start investigating session auth middleware creation * start investigating Login controller time * start investigating Login controller time * in depth look at Logincontroller timings * comment out debug printing * lazily obtain valus for page rendering * correct syntax error * correct scope of variable * correct visibiity of methds inherited from BaseController * missing use for Userfieldsservice * lazy loading of open api spec * lazy loading of users service * lazy loading of batteries service * lazy loading of services in controllers * lazy loading of services in services * correct mistake * fix userservice * fix userservice * fix userfieldservice * fix chores service * fix calendar service * remove Dockerfile used for development * Remove docker compose file used for development * Clean up app.php * remove last diff * Clean up base controller * Clean up controllers * lean up middleware * Clean up and tuen all services into singletons * remove debug from routes.php * remove acpu from localisation * Complete removal of acpu from localisation * fixes for things broken * More fixes following merge * Fix for start up bug. Re factoring singleton code had brroken due to scope of clas var. * fix bug where getUsersService is declared twice * bug fixes following merge * bug fixes following merge * bug fixes following merge * bug fixes following merge * bug fixes following merge * Fix all the not working things... * Deleted off-topic files * Deleted off-topic files Co-authored-by: Bernd Bestel <bernd@berrnd.de>
This commit is contained in:
@@ -2,99 +2,90 @@
|
||||
|
||||
namespace Grocy\Controllers;
|
||||
|
||||
use \Grocy\Services\StockService;
|
||||
use \Grocy\Services\UsersService;
|
||||
use \Grocy\Services\UserfieldsService;
|
||||
|
||||
class StockController extends BaseController
|
||||
{
|
||||
|
||||
public function __construct(\DI\Container $container)
|
||||
{
|
||||
parent::__construct($container);
|
||||
$this->StockService = new StockService();
|
||||
$this->UserfieldsService = new UserfieldsService();
|
||||
}
|
||||
|
||||
protected $StockService;
|
||||
protected $UserfieldsService;
|
||||
|
||||
public function Overview(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||
{
|
||||
$usersService = new UsersService();
|
||||
$usersService = $this->getUsersService();
|
||||
$nextXDays = $usersService->GetUserSettings(GROCY_USER_ID)['stock_expring_soon_days'];
|
||||
|
||||
return $this->View->render($response, 'stockoverview', [
|
||||
'products' => $this->Database->products()->orderBy('name'),
|
||||
'quantityunits' => $this->Database->quantity_units()->orderBy('name'),
|
||||
'locations' => $this->Database->locations()->orderBy('name'),
|
||||
'currentStock' => $this->StockService->GetCurrentStock(true),
|
||||
'currentStockLocations' => $this->StockService->GetCurrentStockLocations(),
|
||||
'missingProducts' => $this->StockService->GetMissingProducts(),
|
||||
return $this->renderPage($response, 'stockoverview', [
|
||||
'products' => $this->getDatabase()->products()->orderBy('name'),
|
||||
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name'),
|
||||
'locations' => $this->getDatabase()->locations()->orderBy('name'),
|
||||
'currentStock' => $this->getStockService()->GetCurrentStock(true),
|
||||
'currentStockLocations' => $this->getStockService()->GetCurrentStockLocations(),
|
||||
'missingProducts' => $this->getStockService()->GetMissingProducts(),
|
||||
'nextXDays' => $nextXDays,
|
||||
'productGroups' => $this->Database->product_groups()->orderBy('name'),
|
||||
'userfields' => $this->UserfieldsService->GetFields('products'),
|
||||
'userfieldValues' => $this->UserfieldsService->GetAllValues('products')
|
||||
'productGroups' => $this->getDatabase()->product_groups()->orderBy('name'),
|
||||
'userfields' => $this->getUserfieldsService()->GetFields('products'),
|
||||
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('products')
|
||||
]);
|
||||
}
|
||||
|
||||
public function Stockentries(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||
{
|
||||
$usersService = new UsersService();
|
||||
$usersService = $this->getUsersService();
|
||||
$nextXDays = $usersService->GetUserSettings(GROCY_USER_ID)['stock_expring_soon_days'];
|
||||
|
||||
return $this->View->render($response, 'stockentries', [
|
||||
'products' => $this->Database->products()->orderBy('name'),
|
||||
'quantityunits' => $this->Database->quantity_units()->orderBy('name'),
|
||||
'locations' => $this->Database->locations()->orderBy('name'),
|
||||
'stockEntries' => $this->Database->stock()->orderBy('product_id'),
|
||||
'currentStockLocations' => $this->StockService->GetCurrentStockLocations(),
|
||||
return $this->renderPage($response, 'stockentries', [
|
||||
'products' => $this->getDatabase()->products()->orderBy('name'),
|
||||
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name'),
|
||||
'locations' => $this->getDatabase()->locations()->orderBy('name'),
|
||||
'stockEntries' => $this->getDatabase()->stock()->orderBy('product_id'),
|
||||
'currentStockLocations' => $this->getStockService()->GetCurrentStockLocations(),
|
||||
'nextXDays' => $nextXDays,
|
||||
'userfields' => $this->UserfieldsService->GetFields('products'),
|
||||
'userfieldValues' => $this->UserfieldsService->GetAllValues('products')
|
||||
'userfields' => $this->getUserfieldsService()->GetFields('products'),
|
||||
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('products')
|
||||
]);
|
||||
}
|
||||
|
||||
public function Purchase(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||
{
|
||||
return $this->View->render($response, 'purchase', [
|
||||
'products' => $this->Database->products()->orderBy('name'),
|
||||
'locations' => $this->Database->locations()->orderBy('name')
|
||||
return $this->renderPage($response, 'purchase', [
|
||||
'products' => $this->getDatabase()->products()->orderBy('name'),
|
||||
'locations' => $this->getDatabase()->locations()->orderBy('name')
|
||||
]);
|
||||
}
|
||||
|
||||
public function Consume(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||
{
|
||||
return $this->View->render($response, 'consume', [
|
||||
'products' => $this->Database->products()->orderBy('name'),
|
||||
'recipes' => $this->Database->recipes()->orderBy('name'),
|
||||
'locations' => $this->Database->locations()->orderBy('name')
|
||||
return $this->renderPage($response, 'consume', [
|
||||
'products' => $this->getDatabase()->products()->orderBy('name'),
|
||||
'recipes' => $this->getDatabase()->recipes()->orderBy('name'),
|
||||
'locations' => $this->getDatabase()->locations()->orderBy('name')
|
||||
]);
|
||||
}
|
||||
|
||||
public function Transfer(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||
{
|
||||
return $this->View->render($response, 'transfer', [
|
||||
'products' => $this->Database->products()->orderBy('name'),
|
||||
'recipes' => $this->Database->recipes()->orderBy('name'),
|
||||
'locations' => $this->Database->locations()->orderBy('name')
|
||||
return $this->renderPage($response, 'transfer', [
|
||||
'products' => $this->getDatabase()->products()->orderBy('name'),
|
||||
'recipes' => $this->getDatabase()->recipes()->orderBy('name'),
|
||||
'locations' => $this->getDatabase()->locations()->orderBy('name')
|
||||
]);
|
||||
}
|
||||
|
||||
public function Inventory(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||
{
|
||||
return $this->View->render($response, 'inventory', [
|
||||
'products' => $this->Database->products()->orderBy('name'),
|
||||
'locations' => $this->Database->locations()->orderBy('name')
|
||||
return $this->renderPage($response, 'inventory', [
|
||||
'products' => $this->getDatabase()->products()->orderBy('name'),
|
||||
'locations' => $this->getDatabase()->locations()->orderBy('name')
|
||||
]);
|
||||
}
|
||||
|
||||
public function StockEntryEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||
{
|
||||
return $this->View->render($response, 'stockentryform', [
|
||||
'stockEntry' => $this->Database->stock()->where('id', $args['entryId'])->fetch(),
|
||||
'products' => $this->Database->products()->orderBy('name'),
|
||||
'locations' => $this->Database->locations()->orderBy('name')
|
||||
return $this->renderPage($response, 'stockentryform', [
|
||||
'stockEntry' => $this->getDatabase()->stock()->where('id', $args['entryId'])->fetch(),
|
||||
'products' => $this->getDatabase()->products()->orderBy('name'),
|
||||
'locations' => $this->getDatabase()->locations()->orderBy('name')
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -106,65 +97,65 @@ class StockController extends BaseController
|
||||
$listId = $request->getQueryParams()['list'];
|
||||
}
|
||||
|
||||
return $this->View->render($response, 'shoppinglist', [
|
||||
'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'),
|
||||
return $this->renderPage($response, 'shoppinglist', [
|
||||
'listItems' => $this->getDatabase()->shopping_list()->where('shopping_list_id = :1', $listId),
|
||||
'products' => $this->getDatabase()->products()->orderBy('name'),
|
||||
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name'),
|
||||
'missingProducts' => $this->getStockService()->GetMissingProducts(),
|
||||
'productGroups' => $this->getDatabase()->product_groups()->orderBy('name'),
|
||||
'shoppingLists' => $this->getDatabase()->shopping_lists()->orderBy('name'),
|
||||
'selectedShoppingListId' => $listId,
|
||||
'userfields' => $this->UserfieldsService->GetFields('products'),
|
||||
'userfieldValues' => $this->UserfieldsService->GetAllValues('products')
|
||||
'userfields' => $this->getUserfieldsService()->GetFields('products'),
|
||||
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('products')
|
||||
]);
|
||||
}
|
||||
|
||||
public function ProductsList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||
{
|
||||
return $this->View->render($response, 'products', [
|
||||
'products' => $this->Database->products()->orderBy('name'),
|
||||
'locations' => $this->Database->locations()->orderBy('name'),
|
||||
'quantityunits' => $this->Database->quantity_units()->orderBy('name'),
|
||||
'productGroups' => $this->Database->product_groups()->orderBy('name'),
|
||||
'userfields' => $this->UserfieldsService->GetFields('products'),
|
||||
'userfieldValues' => $this->UserfieldsService->GetAllValues('products')
|
||||
return $this->renderPage($response, 'products', [
|
||||
'products' => $this->getDatabase()->products()->orderBy('name'),
|
||||
'locations' => $this->getDatabase()->locations()->orderBy('name'),
|
||||
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name'),
|
||||
'productGroups' => $this->getDatabase()->product_groups()->orderBy('name'),
|
||||
'userfields' => $this->getUserfieldsService()->GetFields('products'),
|
||||
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('products')
|
||||
]);
|
||||
}
|
||||
|
||||
public function StockSettings(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||
{
|
||||
return $this->View->render($response, 'stocksettings', [
|
||||
'locations' => $this->Database->locations()->orderBy('name'),
|
||||
'quantityunits' => $this->Database->quantity_units()->orderBy('name'),
|
||||
'productGroups' => $this->Database->product_groups()->orderBy('name')
|
||||
return $this->renderPage($response, 'stocksettings', [
|
||||
'locations' => $this->getDatabase()->locations()->orderBy('name'),
|
||||
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name'),
|
||||
'productGroups' => $this->getDatabase()->product_groups()->orderBy('name')
|
||||
]);
|
||||
}
|
||||
|
||||
public function LocationsList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||
{
|
||||
return $this->View->render($response, 'locations', [
|
||||
'locations' => $this->Database->locations()->orderBy('name'),
|
||||
'userfields' => $this->UserfieldsService->GetFields('locations'),
|
||||
'userfieldValues' => $this->UserfieldsService->GetAllValues('locations')
|
||||
return $this->renderPage($response, 'locations', [
|
||||
'locations' => $this->getDatabase()->locations()->orderBy('name'),
|
||||
'userfields' => $this->getUserfieldsService()->GetFields('locations'),
|
||||
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('locations')
|
||||
]);
|
||||
}
|
||||
|
||||
public function ProductGroupsList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||
{
|
||||
return $this->View->render($response, 'productgroups', [
|
||||
'productGroups' => $this->Database->product_groups()->orderBy('name'),
|
||||
'products' => $this->Database->products()->orderBy('name'),
|
||||
'userfields' => $this->UserfieldsService->GetFields('product_groups'),
|
||||
'userfieldValues' => $this->UserfieldsService->GetAllValues('product_groups')
|
||||
return $this->renderPage($response, 'productgroups', [
|
||||
'productGroups' => $this->getDatabase()->product_groups()->orderBy('name'),
|
||||
'products' => $this->getDatabase()->products()->orderBy('name'),
|
||||
'userfields' => $this->getUserfieldsService()->GetFields('product_groups'),
|
||||
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('product_groups')
|
||||
]);
|
||||
}
|
||||
|
||||
public function QuantityUnitsList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||
{
|
||||
return $this->View->render($response, 'quantityunits', [
|
||||
'quantityunits' => $this->Database->quantity_units()->orderBy('name'),
|
||||
'userfields' => $this->UserfieldsService->GetFields('quantity_units'),
|
||||
'userfieldValues' => $this->UserfieldsService->GetAllValues('quantity_units')
|
||||
return $this->renderPage($response, 'quantityunits', [
|
||||
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name'),
|
||||
'userfields' => $this->getUserfieldsService()->GetFields('quantity_units'),
|
||||
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('quantity_units')
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -172,30 +163,30 @@ class StockController extends BaseController
|
||||
{
|
||||
if ($args['productId'] == 'new')
|
||||
{
|
||||
return $this->View->render($response, 'productform', [
|
||||
'locations' => $this->Database->locations()->orderBy('name'),
|
||||
'quantityunits' => $this->Database->quantity_units()->orderBy('name'),
|
||||
'productgroups' => $this->Database->product_groups()->orderBy('name'),
|
||||
'userfields' => $this->UserfieldsService->GetFields('products'),
|
||||
'products' => $this->Database->products()->where('parent_product_id IS NULL')->orderBy('name'),
|
||||
return $this->renderPage($response, 'productform', [
|
||||
'locations' => $this->getDatabase()->locations()->orderBy('name'),
|
||||
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name'),
|
||||
'productgroups' => $this->getDatabase()->product_groups()->orderBy('name'),
|
||||
'userfields' => $this->getUserfieldsService()->GetFields('products'),
|
||||
'products' => $this->getDatabase()->products()->where('parent_product_id IS NULL')->orderBy('name'),
|
||||
'isSubProductOfOthers' => false,
|
||||
'mode' => 'create'
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$product = $this->Database->products($args['productId']);
|
||||
$product = $this->getDatabase()->products($args['productId']);
|
||||
|
||||
return $this->View->render($response, 'productform', [
|
||||
return $this->renderPage($response, 'productform', [
|
||||
'product' => $product,
|
||||
'locations' => $this->Database->locations()->orderBy('name'),
|
||||
'quantityunits' => $this->Database->quantity_units()->orderBy('name'),
|
||||
'productgroups' => $this->Database->product_groups()->orderBy('name'),
|
||||
'userfields' => $this->UserfieldsService->GetFields('products'),
|
||||
'products' => $this->Database->products()->where('id != :1 AND parent_product_id IS NULL', $product->id)->orderBy('name'),
|
||||
'isSubProductOfOthers' => $this->Database->products()->where('parent_product_id = :1', $product->id)->count() !== 0,
|
||||
'locations' => $this->getDatabase()->locations()->orderBy('name'),
|
||||
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name'),
|
||||
'productgroups' => $this->getDatabase()->product_groups()->orderBy('name'),
|
||||
'userfields' => $this->getUserfieldsService()->GetFields('products'),
|
||||
'products' => $this->getDatabase()->products()->where('id != :1 AND parent_product_id IS NULL', $product->id)->orderBy('name'),
|
||||
'isSubProductOfOthers' => $this->getDatabase()->products()->where('parent_product_id = :1', $product->id)->count() !== 0,
|
||||
'mode' => 'edit',
|
||||
'quConversions' => $this->Database->quantity_unit_conversions()
|
||||
'quConversions' => $this->getDatabase()->quantity_unit_conversions()
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -204,17 +195,17 @@ class StockController extends BaseController
|
||||
{
|
||||
if ($args['locationId'] == 'new')
|
||||
{
|
||||
return $this->View->render($response, 'locationform', [
|
||||
return $this->renderPage($response, 'locationform', [
|
||||
'mode' => 'create',
|
||||
'userfields' => $this->UserfieldsService->GetFields('locations')
|
||||
'userfields' => $this->getUserfieldsService()->GetFields('locations')
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->View->render($response, 'locationform', [
|
||||
'location' => $this->Database->locations($args['locationId']),
|
||||
return $this->renderPage($response, 'locationform', [
|
||||
'location' => $this->getDatabase()->locations($args['locationId']),
|
||||
'mode' => 'edit',
|
||||
'userfields' => $this->UserfieldsService->GetFields('locations')
|
||||
'userfields' => $this->getUserfieldsService()->GetFields('locations')
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -223,17 +214,17 @@ class StockController extends BaseController
|
||||
{
|
||||
if ($args['productGroupId'] == 'new')
|
||||
{
|
||||
return $this->View->render($response, 'productgroupform', [
|
||||
return $this->renderPage($response, 'productgroupform', [
|
||||
'mode' => 'create',
|
||||
'userfields' => $this->UserfieldsService->GetFields('product_groups')
|
||||
'userfields' => $this->getUserfieldsService()->GetFields('product_groups')
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->View->render($response, 'productgroupform', [
|
||||
'group' => $this->Database->product_groups($args['productGroupId']),
|
||||
return $this->renderPage($response, 'productgroupform', [
|
||||
'group' => $this->getDatabase()->product_groups($args['productGroupId']),
|
||||
'mode' => 'edit',
|
||||
'userfields' => $this->UserfieldsService->GetFields('product_groups')
|
||||
'userfields' => $this->getUserfieldsService()->GetFields('product_groups')
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -242,25 +233,25 @@ class StockController extends BaseController
|
||||
{
|
||||
if ($args['quantityunitId'] == 'new')
|
||||
{
|
||||
return $this->View->render($response, 'quantityunitform', [
|
||||
return $this->renderPage($response, 'quantityunitform', [
|
||||
'mode' => 'create',
|
||||
'userfields' => $this->UserfieldsService->GetFields('quantity_units'),
|
||||
'pluralCount' => $this->LocalizationService->GetPluralCount(),
|
||||
'pluralRule' => $this->LocalizationService->GetPluralDefinition()
|
||||
'userfields' => $this->getUserfieldsService()->GetFields('quantity_units'),
|
||||
'pluralCount' => $this->getLocalizationService()->GetPluralCount(),
|
||||
'pluralRule' => $this->getLocalizationService()->GetPluralDefinition()
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$quantityUnit = $this->Database->quantity_units($args['quantityunitId']);
|
||||
$quantityUnit = $this->getDatabase()->quantity_units($args['quantityunitId']);
|
||||
|
||||
return $this->View->render($response, 'quantityunitform', [
|
||||
return $this->renderPage($response, 'quantityunitform', [
|
||||
'quantityUnit' => $quantityUnit,
|
||||
'mode' => 'edit',
|
||||
'userfields' => $this->UserfieldsService->GetFields('quantity_units'),
|
||||
'pluralCount' => $this->LocalizationService->GetPluralCount(),
|
||||
'pluralRule' => $this->LocalizationService->GetPluralDefinition(),
|
||||
'defaultQuConversions' => $this->Database->quantity_unit_conversions()->where('from_qu_id = :1 AND product_id IS NULL', $quantityUnit->id),
|
||||
'quantityUnits' => $this->Database->quantity_units()
|
||||
'userfields' => $this->getUserfieldsService()->GetFields('quantity_units'),
|
||||
'pluralCount' => $this->getLocalizationService()->GetPluralCount(),
|
||||
'pluralRule' => $this->getLocalizationService()->GetPluralDefinition(),
|
||||
'defaultQuConversions' => $this->getDatabase()->quantity_unit_conversions()->where('from_qu_id = :1 AND product_id IS NULL', $quantityUnit->id),
|
||||
'quantityUnits' => $this->getDatabase()->quantity_units()
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -269,18 +260,18 @@ class StockController extends BaseController
|
||||
{
|
||||
if ($args['itemId'] == 'new')
|
||||
{
|
||||
return $this->View->render($response, 'shoppinglistitemform', [
|
||||
'products' => $this->Database->products()->orderBy('name'),
|
||||
'shoppingLists' => $this->Database->shopping_lists()->orderBy('name'),
|
||||
return $this->renderPage($response, 'shoppinglistitemform', [
|
||||
'products' => $this->getDatabase()->products()->orderBy('name'),
|
||||
'shoppingLists' => $this->getDatabase()->shopping_lists()->orderBy('name'),
|
||||
'mode' => 'create'
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->View->render($response, 'shoppinglistitemform', [
|
||||
'listItem' => $this->Database->shopping_list($args['itemId']),
|
||||
'products' => $this->Database->products()->orderBy('name'),
|
||||
'shoppingLists' => $this->Database->shopping_lists()->orderBy('name'),
|
||||
return $this->renderPage($response, 'shoppinglistitemform', [
|
||||
'listItem' => $this->getDatabase()->shopping_list($args['itemId']),
|
||||
'products' => $this->getDatabase()->products()->orderBy('name'),
|
||||
'shoppingLists' => $this->getDatabase()->shopping_lists()->orderBy('name'),
|
||||
'mode' => 'edit'
|
||||
]);
|
||||
}
|
||||
@@ -290,14 +281,14 @@ class StockController extends BaseController
|
||||
{
|
||||
if ($args['listId'] == 'new')
|
||||
{
|
||||
return $this->View->render($response, 'shoppinglistform', [
|
||||
return $this->renderPage($response, 'shoppinglistform', [
|
||||
'mode' => 'create'
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->View->render($response, 'shoppinglistform', [
|
||||
'shoppingList' => $this->Database->shopping_lists($args['listId']),
|
||||
return $this->renderPage($response, 'shoppinglistform', [
|
||||
'shoppingList' => $this->getDatabase()->shopping_lists($args['listId']),
|
||||
'mode' => 'edit'
|
||||
]);
|
||||
}
|
||||
@@ -305,26 +296,26 @@ class StockController extends BaseController
|
||||
|
||||
public function ShoppingListSettings(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||
{
|
||||
return $this->View->render($response, 'shoppinglistsettings');
|
||||
return $this->renderPage($response, 'shoppinglistsettings');
|
||||
}
|
||||
|
||||
public function Journal(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||
{
|
||||
return $this->View->render($response, 'stockjournal', [
|
||||
'stockLog' => $this->Database->stock_log()->orderBy('row_created_timestamp', 'DESC'),
|
||||
'locations' => $this->Database->locations()->orderBy('name'),
|
||||
'products' => $this->Database->products()->orderBy('name'),
|
||||
'quantityunits' => $this->Database->quantity_units()->orderBy('name')
|
||||
return $this->renderPage($response, 'stockjournal', [
|
||||
'stockLog' => $this->getDatabase()->stock_log()->orderBy('row_created_timestamp', 'DESC'),
|
||||
'locations' => $this->getDatabase()->locations()->orderBy('name'),
|
||||
'products' => $this->getDatabase()->products()->orderBy('name'),
|
||||
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name')
|
||||
]);
|
||||
}
|
||||
|
||||
public function LocationContentSheet(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||
{
|
||||
return $this->View->render($response, 'locationcontentsheet', [
|
||||
'products' => $this->Database->products()->orderBy('name'),
|
||||
'quantityunits' => $this->Database->quantity_units()->orderBy('name'),
|
||||
'locations' => $this->Database->locations()->orderBy('name'),
|
||||
'currentStockLocationContent' => $this->StockService->GetCurrentStockLocationContent()
|
||||
return $this->renderPage($response, 'locationcontentsheet', [
|
||||
'products' => $this->getDatabase()->products()->orderBy('name'),
|
||||
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name'),
|
||||
'locations' => $this->getDatabase()->locations()->orderBy('name'),
|
||||
'currentStockLocationContent' => $this->getStockService()->GetCurrentStockLocationContent()
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -333,32 +324,32 @@ class StockController extends BaseController
|
||||
$product = null;
|
||||
if (isset($request->getQueryParams()['product']))
|
||||
{
|
||||
$product = $this->Database->products($request->getQueryParams()['product']);
|
||||
$product = $this->getDatabase()->products($request->getQueryParams()['product']);
|
||||
}
|
||||
|
||||
$defaultQuUnit = null;
|
||||
if (isset($request->getQueryParams()['qu-unit']))
|
||||
{
|
||||
$defaultQuUnit = $this->Database->quantity_units($request->getQueryParams()['qu-unit']);
|
||||
$defaultQuUnit = $this->getDatabase()->quantity_units($request->getQueryParams()['qu-unit']);
|
||||
}
|
||||
|
||||
if ($args['quConversionId'] == 'new')
|
||||
{
|
||||
return $this->View->render($response, 'quantityunitconversionform', [
|
||||
return $this->renderPage($response, 'quantityunitconversionform', [
|
||||
'mode' => 'create',
|
||||
'userfields' => $this->UserfieldsService->GetFields('quantity_unit_conversions'),
|
||||
'quantityunits' => $this->Database->quantity_units()->orderBy('name'),
|
||||
'userfields' => $this->getUserfieldsService()->GetFields('quantity_unit_conversions'),
|
||||
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name'),
|
||||
'product' => $product,
|
||||
'defaultQuUnit' => $defaultQuUnit
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->View->render($response, 'quantityunitconversionform', [
|
||||
'quConversion' => $this->Database->quantity_unit_conversions($args['quConversionId']),
|
||||
return $this->renderPage($response, 'quantityunitconversionform', [
|
||||
'quConversion' => $this->getDatabase()->quantity_unit_conversions($args['quConversionId']),
|
||||
'mode' => 'edit',
|
||||
'userfields' => $this->UserfieldsService->GetFields('quantity_unit_conversions'),
|
||||
'quantityunits' => $this->Database->quantity_units()->orderBy('name'),
|
||||
'userfields' => $this->getUserfieldsService()->GetFields('quantity_unit_conversions'),
|
||||
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name'),
|
||||
'product' => $product,
|
||||
'defaultQuUnit' => $defaultQuUnit
|
||||
]);
|
||||
@@ -367,8 +358,8 @@ class StockController extends BaseController
|
||||
|
||||
public function QuantityUnitPluralFormTesting(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||
{
|
||||
return $this->View->render($response, 'quantityunitpluraltesting', [
|
||||
'quantityUnits' => $this->Database->quantity_units()->orderBy('name')
|
||||
return $this->renderPage($response, 'quantityunitpluraltesting', [
|
||||
'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name')
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user