Files
grocy/controllers/StockController.php

511 lines
24 KiB
PHP
Raw Normal View History

2018-04-11 19:49:35 +02:00
<?php
namespace Grocy\Controllers;
2020-10-31 10:25:33 -05:00
use Grocy\Services\RecipesService;
2018-04-11 19:49:35 +02:00
class StockController extends BaseController
{
public function Consume(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
2018-04-11 19:49:35 +02:00
{
Qu factor purchase to stock & Product Barcode Details (#801) * Puchase add qu_factor_to_stock * qu_factor_purchase_to_stock for stock edit * product barcodes with QU and Stores * remove product barcode tags * migrations/0103 add value and factor_puchase_amount to stock_current and stock_current_location_content * Remove unused method * StockService#GetProductDetails: include stock_value * productcard: include stock_value * Add Purchase Factor to Stock Overview * update demo data with stock qu_factor_purchase_to_stock * recipes_pos_resolved update * avg_price and oldest_price in product details * add average price to product card * hint for recipe costs not included if not in stock * Round value and factor_purchas_amount. Include currency for stock value * Add factor_purchase_amount to product card stock amount * Allow editing qu_factor_purchase_to_stock for stock entries * fix update qu_factor_purchase_to_stock for Transfers * Add barcode to existing product update to add to product_barcodes table * Add barcode to new product workflow update to add to product_barcodes table * *** Price now saved as 1 QU to stock in stock tables *** * remove column product barcode and use product_barcodes * Allow products to be deactivated instead of deleted * Embedded barcode and qu-conversion with page reload on change * Save current product barcode into new product_barcodes table * Embedded popup for product group add/edit * barcode scanner added to product barcodes input * Edit product qu_stock is unavailable after first purchase * StockOverview: Filters break when columns are reordered so for now just disable colReorder * view stockoverview.blade: display product_group column * Review Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2020-08-17 14:47:33 -05:00
$sql = 'select group_concat(barcode) barcodes, product_id from product_barcodes group by product_id';
$productBarcodes = $this->getDatabaseService()->ExecuteDbQuery($sql)->fetchAll(\PDO::FETCH_OBJ);
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>
2020-03-01 23:47:47 +07:00
return $this->renderPage($response, 'consume', [
Qu factor purchase to stock & Product Barcode Details (#801) * Puchase add qu_factor_to_stock * qu_factor_purchase_to_stock for stock edit * product barcodes with QU and Stores * remove product barcode tags * migrations/0103 add value and factor_puchase_amount to stock_current and stock_current_location_content * Remove unused method * StockService#GetProductDetails: include stock_value * productcard: include stock_value * Add Purchase Factor to Stock Overview * update demo data with stock qu_factor_purchase_to_stock * recipes_pos_resolved update * avg_price and oldest_price in product details * add average price to product card * hint for recipe costs not included if not in stock * Round value and factor_purchas_amount. Include currency for stock value * Add factor_purchase_amount to product card stock amount * Allow editing qu_factor_purchase_to_stock for stock entries * fix update qu_factor_purchase_to_stock for Transfers * Add barcode to existing product update to add to product_barcodes table * Add barcode to new product workflow update to add to product_barcodes table * *** Price now saved as 1 QU to stock in stock tables *** * remove column product barcode and use product_barcodes * Allow products to be deactivated instead of deleted * Embedded barcode and qu-conversion with page reload on change * Save current product barcode into new product_barcodes table * Embedded popup for product group add/edit * barcode scanner added to product barcodes input * Edit product qu_stock is unavailable after first purchase * StockOverview: Filters break when columns are reordered so for now just disable colReorder * view stockoverview.blade: display product_group column * Review Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2020-08-17 14:47:33 -05:00
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name'),
2020-08-31 20:40:31 +02:00
'barcodes' => $productBarcodes,
'recipes' => $this->getDatabase()->recipes()->where('type', RecipesService::RECIPE_TYPE_NORMAL)->orderBy('name', 'COLLATE NOCASE'),
'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE'),
'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved()
2018-04-11 19:49:35 +02:00
]);
}
public function Inventory(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
2018-04-11 19:49:35 +02:00
{
Qu factor purchase to stock & Product Barcode Details (#801) * Puchase add qu_factor_to_stock * qu_factor_purchase_to_stock for stock edit * product barcodes with QU and Stores * remove product barcode tags * migrations/0103 add value and factor_puchase_amount to stock_current and stock_current_location_content * Remove unused method * StockService#GetProductDetails: include stock_value * productcard: include stock_value * Add Purchase Factor to Stock Overview * update demo data with stock qu_factor_purchase_to_stock * recipes_pos_resolved update * avg_price and oldest_price in product details * add average price to product card * hint for recipe costs not included if not in stock * Round value and factor_purchas_amount. Include currency for stock value * Add factor_purchase_amount to product card stock amount * Allow editing qu_factor_purchase_to_stock for stock entries * fix update qu_factor_purchase_to_stock for Transfers * Add barcode to existing product update to add to product_barcodes table * Add barcode to new product workflow update to add to product_barcodes table * *** Price now saved as 1 QU to stock in stock tables *** * remove column product barcode and use product_barcodes * Allow products to be deactivated instead of deleted * Embedded barcode and qu-conversion with page reload on change * Save current product barcode into new product_barcodes table * Embedded popup for product group add/edit * barcode scanner added to product barcodes input * Edit product qu_stock is unavailable after first purchase * StockOverview: Filters break when columns are reordered so for now just disable colReorder * view stockoverview.blade: display product_group column * Review Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2020-08-17 14:47:33 -05:00
$sql = 'select group_concat(barcode) barcodes, product_id from product_barcodes group by product_id';
$productBarcodes = $this->getDatabaseService()->ExecuteDbQuery($sql)->fetchAll(\PDO::FETCH_OBJ);
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>
2020-03-01 23:47:47 +07:00
return $this->renderPage($response, 'inventory', [
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
2020-08-31 20:40:31 +02:00
'barcodes' => $productBarcodes,
'shoppinglocations' => $this->getDatabase()->shopping_locations()->orderBy('name', 'COLLATE NOCASE'),
'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE'),
'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved()
2018-04-11 19:49:35 +02:00
]);
}
2020-08-31 20:40:31 +02:00
public function Journal(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$usersService = $this->getUsersService();
2020-08-31 20:40:31 +02:00
return $this->renderPage($response, 'stockjournal', [
'stockLog' => $this->getDatabase()->uihelper_stock_journal()->orderBy('row_created_timestamp', 'DESC'),
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE'),
'users' => $usersService->GetUsersAsDto(),
'transactionTypes' => GetClassConstants('\Grocy\Services\StockService', 'TRANSACTION_TYPE_'),
]);
}
2020-08-31 20:40:31 +02:00
public function LocationContentSheet(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
2018-04-11 19:49:35 +02:00
{
2020-08-31 20:40:31 +02:00
return $this->renderPage($response, 'locationcontentsheet', [
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE'),
2020-08-31 20:40:31 +02:00
'currentStockLocationContent' => $this->getStockService()->GetCurrentStockLocationContent()
2018-04-11 19:49:35 +02:00
]);
}
2020-08-31 20:40:31 +02:00
public function LocationEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
2020-08-31 20:40:31 +02:00
if ($args['locationId'] == 'new')
{
return $this->renderPage($response, 'locationform', [
'mode' => 'create',
'userfields' => $this->getUserfieldsService()->GetFields('locations')
]);
}
else
{
return $this->renderPage($response, 'locationform', [
'location' => $this->getDatabase()->locations($args['locationId']),
'mode' => 'edit',
'userfields' => $this->getUserfieldsService()->GetFields('locations')
]);
}
}
public function LocationsList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
2018-04-11 19:49:35 +02: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>
2020-03-01 23:47:47 +07:00
return $this->renderPage($response, 'locations', [
'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE'),
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>
2020-03-01 23:47:47 +07:00
'userfields' => $this->getUserfieldsService()->GetFields('locations'),
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('locations')
2018-04-11 19:49:35 +02:00
]);
}
2020-08-31 20:40:31 +02:00
public function Overview(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
2020-08-31 20:40:31 +02:00
$usersService = $this->getUsersService();
$nextXDays = $usersService->GetUserSettings(GROCY_USER_ID)['stock_due_soon_days'];
2020-08-31 20:40:31 +02:00
return $this->renderPage($response, 'stockoverview', [
'currentStock' => $this->getStockService()->GetCurrentStockOverview(),
'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE'),
2020-08-31 20:40:31 +02:00
'currentStockLocations' => $this->getStockService()->GetCurrentStockLocations(),
'nextXDays' => $nextXDays,
'productGroups' => $this->getDatabase()->product_groups()->orderBy('name', 'COLLATE NOCASE'),
2020-08-31 20:40:31 +02:00
'userfields' => $this->getUserfieldsService()->GetFields('products'),
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('products')
2018-09-24 13:02:52 +02:00
]);
}
2020-08-31 20:40:31 +02:00
public function ProductBarcodesEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
2018-04-11 19:49:35 +02:00
{
2020-08-31 20:40:31 +02:00
$product = null;
if (isset($request->getQueryParams()['product']))
{
$product = $this->getDatabase()->products($request->getQueryParams()['product']);
}
if ($args['productBarcodeId'] == 'new')
{
return $this->renderPage($response, 'productbarcodeform', [
2020-08-31 20:40:31 +02:00
'mode' => 'create',
'barcodes' => $this->getDatabase()->product_barcodes()->orderBy('barcode'),
'product' => $product,
'shoppinglocations' => $this->getDatabase()->shopping_locations()->orderBy('name', 'COLLATE NOCASE'),
'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved(),
'userfields' => $this->getUserfieldsService()->GetFields('product_barcodes')
2020-08-31 20:40:31 +02:00
]);
}
else
{
return $this->renderPage($response, 'productbarcodeform', [
2020-08-31 20:40:31 +02:00
'mode' => 'edit',
'barcode' => $this->getDatabase()->product_barcodes($args['productBarcodeId']),
'product' => $product,
'shoppinglocations' => $this->getDatabase()->shopping_locations()->orderBy('name', 'COLLATE NOCASE'),
'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved(),
'userfields' => $this->getUserfieldsService()->GetFields('product_barcodes')
2020-08-31 20:40:31 +02:00
]);
}
2018-04-11 19:49:35 +02:00
}
public function ProductEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
2018-04-11 19:49:35 +02:00
{
if ($args['productId'] == 'new')
{
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>
2020-03-01 23:47:47 +07:00
return $this->renderPage($response, 'productform', [
2020-08-31 20:40:31 +02:00
'locations' => $this->getDatabase()->locations()->orderBy('name'),
'barcodes' => $this->getDatabase()->product_barcodes()->orderBy('barcode'),
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'shoppinglocations' => $this->getDatabase()->shopping_locations()->orderBy('name', 'COLLATE NOCASE'),
'productgroups' => $this->getDatabase()->product_groups()->orderBy('name', 'COLLATE NOCASE'),
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>
2020-03-01 23:47:47 +07:00
'userfields' => $this->getUserfieldsService()->GetFields('products'),
'products' => $this->getDatabase()->products()->where('parent_product_id IS NULL and active = 1')->orderBy('name', 'COLLATE NOCASE'),
'isSubProductOfOthers' => false,
2018-04-11 19:49:35 +02:00
'mode' => 'create'
]);
}
else
{
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>
2020-03-01 23:47:47 +07:00
$product = $this->getDatabase()->products($args['productId']);
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>
2020-03-01 23:47:47 +07:00
return $this->renderPage($response, 'productform', [
2020-08-31 20:40:31 +02:00
'product' => $product,
'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE'),
2020-08-31 20:40:31 +02:00
'barcodes' => $this->getDatabase()->product_barcodes()->orderBy('barcode'),
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'shoppinglocations' => $this->getDatabase()->shopping_locations()->orderBy('name', 'COLLATE NOCASE'),
'productgroups' => $this->getDatabase()->product_groups()->orderBy('name', 'COLLATE NOCASE'),
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>
2020-03-01 23:47:47 +07:00
'userfields' => $this->getUserfieldsService()->GetFields('products'),
'products' => $this->getDatabase()->products()->where('id != :1 AND parent_product_id IS NULL and active = 1', $product->id)->orderBy('name', 'COLLATE NOCASE'),
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>
2020-03-01 23:47:47 +07:00
'isSubProductOfOthers' => $this->getDatabase()->products()->where('parent_product_id = :1', $product->id)->count() !== 0,
'mode' => 'edit',
'quConversions' => $this->getDatabase()->quantity_unit_conversions(),
'productBarcodeUserfields' => $this->getUserfieldsService()->GetFields('product_barcodes'),
'productBarcodeUserfieldValues' => $this->getUserfieldsService()->GetAllValues('product_barcodes')
2018-04-11 19:49:35 +02:00
]);
}
}
2020-08-31 20:40:31 +02:00
public function ProductGroupEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
2018-04-11 19:49:35 +02:00
{
2020-08-31 20:40:31 +02:00
if ($args['productGroupId'] == 'new')
2018-04-11 19:49:35 +02:00
{
2020-08-31 20:40:31 +02:00
return $this->renderPage($response, 'productgroupform', [
'mode' => 'create',
2020-08-31 20:40:31 +02:00
'userfields' => $this->getUserfieldsService()->GetFields('product_groups')
2018-04-11 19:49:35 +02:00
]);
}
else
{
2020-08-31 20:40:31 +02:00
return $this->renderPage($response, 'productgroupform', [
'group' => $this->getDatabase()->product_groups($args['productGroupId']),
'mode' => 'edit',
2020-08-31 20:40:31 +02:00
'userfields' => $this->getUserfieldsService()->GetFields('product_groups')
2018-04-11 19:49:35 +02:00
]);
}
}
2020-08-31 20:40:31 +02:00
public function ProductGroupsList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
2020-08-31 20:40:31 +02:00
return $this->renderPage($response, 'productgroups', [
'productGroups' => $this->getDatabase()->product_groups()->orderBy('name', 'COLLATE NOCASE'),
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
2020-08-31 20:40:31 +02:00
'userfields' => $this->getUserfieldsService()->GetFields('product_groups'),
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('product_groups')
]);
}
public function ProductsList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
if (isset($request->getQueryParams()['include_disabled']))
{
$products = $this->getDatabase()->products()->orderBy('name', 'COLLATE NOCASE');
}
else
{
$products = $this->getDatabase()->products()->where('active = 1')->orderBy('name', 'COLLATE NOCASE');
}
2020-08-31 20:40:31 +02:00
return $this->renderPage($response, 'products', [
'products' => $products,
'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE'),
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'productGroups' => $this->getDatabase()->product_groups()->orderBy('name', 'COLLATE NOCASE'),
'shoppingLocations' => $this->getDatabase()->shopping_locations()->orderBy('name', 'COLLATE NOCASE'),
2020-08-31 20:40:31 +02:00
'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)
{
$sql = 'select group_concat(barcode) barcodes, product_id from product_barcodes group by product_id';
$productBarcodes = $this->getDatabaseService()->ExecuteDbQuery($sql)->fetchAll(\PDO::FETCH_OBJ);
return $this->renderPage($response, 'purchase', [
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
2020-08-31 20:40:31 +02:00
'barcodes' => $productBarcodes,
'shoppinglocations' => $this->getDatabase()->shopping_locations()->orderBy('name', 'COLLATE NOCASE'),
'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE'),
'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved()
2020-08-31 20:40:31 +02:00
]);
}
public function QuantityUnitConversionEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$product = null;
if (isset($request->getQueryParams()['product']))
{
2020-08-31 20:40:31 +02:00
$product = $this->getDatabase()->products($request->getQueryParams()['product']);
}
2020-08-31 20:40:31 +02:00
$defaultQuUnit = null;
if (isset($request->getQueryParams()['qu-unit']))
{
2020-08-31 20:40:31 +02:00
$defaultQuUnit = $this->getDatabase()->quantity_units($request->getQueryParams()['qu-unit']);
}
2020-08-31 20:40:31 +02:00
if ($args['quConversionId'] == 'new')
2018-09-24 13:02:52 +02:00
{
2020-08-31 20:40:31 +02:00
return $this->renderPage($response, 'quantityunitconversionform', [
'mode' => 'create',
2020-08-31 20:40:31 +02:00
'userfields' => $this->getUserfieldsService()->GetFields('quantity_unit_conversions'),
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
2020-08-31 20:40:31 +02:00
'product' => $product,
'defaultQuUnit' => $defaultQuUnit
2018-09-24 13:02:52 +02:00
]);
}
else
{
2020-08-31 20:40:31 +02:00
return $this->renderPage($response, 'quantityunitconversionform', [
'quConversion' => $this->getDatabase()->quantity_unit_conversions($args['quConversionId']),
'mode' => 'edit',
2020-08-31 20:40:31 +02:00
'userfields' => $this->getUserfieldsService()->GetFields('quantity_unit_conversions'),
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
2020-08-31 20:40:31 +02:00
'product' => $product,
'defaultQuUnit' => $defaultQuUnit
2018-09-24 13:02:52 +02:00
]);
}
}
public function QuantityUnitEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
2018-04-11 19:49:35 +02:00
{
if ($args['quantityunitId'] == 'new')
{
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>
2020-03-01 23:47:47 +07:00
return $this->renderPage($response, 'quantityunitform', [
'mode' => 'create',
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>
2020-03-01 23:47:47 +07:00
'userfields' => $this->getUserfieldsService()->GetFields('quantity_units'),
'pluralCount' => $this->getLocalizationService()->GetPluralCount(),
'pluralRule' => $this->getLocalizationService()->GetPluralDefinition()
2018-04-11 19:49:35 +02:00
]);
}
else
{
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>
2020-03-01 23:47:47 +07:00
$quantityUnit = $this->getDatabase()->quantity_units($args['quantityunitId']);
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>
2020-03-01 23:47:47 +07:00
return $this->renderPage($response, 'quantityunitform', [
2020-08-31 20:40:31 +02:00
'quantityUnit' => $quantityUnit,
'mode' => 'edit',
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>
2020-03-01 23:47:47 +07:00
'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()
2018-04-11 19:49:35 +02:00
]);
}
2020-08-31 20:40:31 +02:00
}
public function QuantityUnitPluralFormTesting(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->renderPage($response, 'quantityunitpluraltesting', [
'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE')
2020-08-31 20:40:31 +02:00
]);
}
public function QuantityUnitsList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
return $this->renderPage($response, 'quantityunits', [
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
2020-08-31 20:40:31 +02:00
'userfields' => $this->getUserfieldsService()->GetFields('quantity_units'),
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('quantity_units')
]);
}
public function ShoppingList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$listId = 1;
if (isset($request->getQueryParams()['list']))
{
$listId = $request->getQueryParams()['list'];
}
return $this->renderPage($response, 'shoppinglist', [
'listItems' => $this->getDatabase()->uihelper_shopping_list()->where('shopping_list_id = :1', $listId),
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
2020-08-31 20:40:31 +02:00
'missingProducts' => $this->getStockService()->GetMissingProducts(),
'shoppingLists' => $this->getDatabase()->shopping_lists()->orderBy('name', 'COLLATE NOCASE'),
2020-08-31 20:40:31 +02:00
'selectedShoppingListId' => $listId,
'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved(),
'productUserfields' => $this->getUserfieldsService()->GetFields('products'),
'productUserfieldValues' => $this->getUserfieldsService()->GetAllValues('products'),
'userfields' => $this->getUserfieldsService()->GetFields('shopping_list'),
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('shopping_list')
2020-08-31 20:40:31 +02:00
]);
}
public function ShoppingListEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
if ($args['listId'] == 'new')
{
return $this->renderPage($response, 'shoppinglistform', [
'mode' => 'create',
'userfields' => $this->getUserfieldsService()->GetFields('shopping_lists')
2020-08-31 20:40:31 +02:00
]);
}
else
{
return $this->renderPage($response, 'shoppinglistform', [
'shoppingList' => $this->getDatabase()->shopping_lists($args['listId']),
'mode' => 'edit',
'userfields' => $this->getUserfieldsService()->GetFields('shopping_lists')
2020-08-31 20:40:31 +02:00
]);
}
2018-04-11 19:49:35 +02:00
}
public function ShoppingListItemEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
2018-04-11 19:49:35 +02:00
{
if ($args['itemId'] == 'new')
{
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>
2020-03-01 23:47:47 +07:00
return $this->renderPage($response, 'shoppinglistitemform', [
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'shoppingLists' => $this->getDatabase()->shopping_lists()->orderBy('name', 'COLLATE NOCASE'),
'mode' => 'create',
'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved(),
'userfields' => $this->getUserfieldsService()->GetFields('shopping_list')
2018-04-11 19:49:35 +02:00
]);
}
else
{
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>
2020-03-01 23:47:47 +07:00
return $this->renderPage($response, 'shoppinglistitemform', [
2020-08-31 20:40:31 +02:00
'listItem' => $this->getDatabase()->shopping_list($args['itemId']),
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'shoppingLists' => $this->getDatabase()->shopping_lists()->orderBy('name', 'COLLATE NOCASE'),
'mode' => 'edit',
'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved(),
'userfields' => $this->getUserfieldsService()->GetFields('shopping_list')
2018-04-11 19:49:35 +02:00
]);
}
}
2020-08-31 20:40:31 +02:00
public function ShoppingListSettings(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
2020-08-31 20:40:31 +02:00
return $this->renderPage($response, 'shoppinglistsettings');
}
public function ShoppingLocationEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
if ($args['shoppingLocationId'] == 'new')
{
2020-08-31 20:40:31 +02:00
return $this->renderPage($response, 'shoppinglocationform', [
'mode' => 'create',
'userfields' => $this->getUserfieldsService()->GetFields('shopping_locations')
]);
}
else
{
2020-08-31 20:40:31 +02:00
return $this->renderPage($response, 'shoppinglocationform', [
'shoppinglocation' => $this->getDatabase()->shopping_locations($args['shoppingLocationId']),
'mode' => 'edit',
'userfields' => $this->getUserfieldsService()->GetFields('shopping_locations')
]);
}
}
2020-08-31 20:40:31 +02:00
public function ShoppingLocationsList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
2020-08-31 20:40:31 +02:00
return $this->renderPage($response, 'shoppinglocations', [
'shoppinglocations' => $this->getDatabase()->shopping_locations()->orderBy('name', 'COLLATE NOCASE'),
2020-08-31 20:40:31 +02:00
'userfields' => $this->getUserfieldsService()->GetFields('shopping_locations'),
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('shopping_locations')
]);
}
2020-08-31 20:40:31 +02:00
public function StockEntryEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
2020-08-31 20:40:31 +02:00
return $this->renderPage($response, 'stockentryform', [
'stockEntry' => $this->getDatabase()->stock()->where('id', $args['entryId'])->fetch(),
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'shoppinglocations' => $this->getDatabase()->shopping_locations()->orderBy('name', 'COLLATE NOCASE'),
'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE')
]);
}
2020-08-31 20:40:31 +02:00
public function StockSettings(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
2020-08-31 20:40:31 +02:00
return $this->renderPage($response, 'stocksettings', [
'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE'),
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'productGroups' => $this->getDatabase()->product_groups()->orderBy('name', 'COLLATE NOCASE')
]);
}
2020-08-31 20:40:31 +02:00
public function Stockentries(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
Qu factor purchase to stock & Product Barcode Details (#801) * Puchase add qu_factor_to_stock * qu_factor_purchase_to_stock for stock edit * product barcodes with QU and Stores * remove product barcode tags * migrations/0103 add value and factor_puchase_amount to stock_current and stock_current_location_content * Remove unused method * StockService#GetProductDetails: include stock_value * productcard: include stock_value * Add Purchase Factor to Stock Overview * update demo data with stock qu_factor_purchase_to_stock * recipes_pos_resolved update * avg_price and oldest_price in product details * add average price to product card * hint for recipe costs not included if not in stock * Round value and factor_purchas_amount. Include currency for stock value * Add factor_purchase_amount to product card stock amount * Allow editing qu_factor_purchase_to_stock for stock entries * fix update qu_factor_purchase_to_stock for Transfers * Add barcode to existing product update to add to product_barcodes table * Add barcode to new product workflow update to add to product_barcodes table * *** Price now saved as 1 QU to stock in stock tables *** * remove column product barcode and use product_barcodes * Allow products to be deactivated instead of deleted * Embedded barcode and qu-conversion with page reload on change * Save current product barcode into new product_barcodes table * Embedded popup for product group add/edit * barcode scanner added to product barcodes input * Edit product qu_stock is unavailable after first purchase * StockOverview: Filters break when columns are reordered so for now just disable colReorder * view stockoverview.blade: display product_group column * Review Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2020-08-17 14:47:33 -05:00
{
2020-08-31 20:40:31 +02:00
$usersService = $this->getUsersService();
$nextXDays = $usersService->GetUserSettings(GROCY_USER_ID)['stock_due_soon_days'];
Qu factor purchase to stock & Product Barcode Details (#801) * Puchase add qu_factor_to_stock * qu_factor_purchase_to_stock for stock edit * product barcodes with QU and Stores * remove product barcode tags * migrations/0103 add value and factor_puchase_amount to stock_current and stock_current_location_content * Remove unused method * StockService#GetProductDetails: include stock_value * productcard: include stock_value * Add Purchase Factor to Stock Overview * update demo data with stock qu_factor_purchase_to_stock * recipes_pos_resolved update * avg_price and oldest_price in product details * add average price to product card * hint for recipe costs not included if not in stock * Round value and factor_purchas_amount. Include currency for stock value * Add factor_purchase_amount to product card stock amount * Allow editing qu_factor_purchase_to_stock for stock entries * fix update qu_factor_purchase_to_stock for Transfers * Add barcode to existing product update to add to product_barcodes table * Add barcode to new product workflow update to add to product_barcodes table * *** Price now saved as 1 QU to stock in stock tables *** * remove column product barcode and use product_barcodes * Allow products to be deactivated instead of deleted * Embedded barcode and qu-conversion with page reload on change * Save current product barcode into new product_barcodes table * Embedded popup for product group add/edit * barcode scanner added to product barcodes input * Edit product qu_stock is unavailable after first purchase * StockOverview: Filters break when columns are reordered so for now just disable colReorder * view stockoverview.blade: display product_group column * Review Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2020-08-17 14:47:33 -05:00
2020-08-31 20:40:31 +02:00
return $this->renderPage($response, 'stockentries', [
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE'),
'shoppinglocations' => $this->getDatabase()->shopping_locations()->orderBy('name', 'COLLATE NOCASE'),
2020-08-31 20:40:31 +02:00
'stockEntries' => $this->getDatabase()->stock()->orderBy('product_id'),
'currentStockLocations' => $this->getStockService()->GetCurrentStockLocations(),
'nextXDays' => $nextXDays,
'userfields' => $this->getUserfieldsService()->GetFields('products'),
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('products')
]);
Qu factor purchase to stock & Product Barcode Details (#801) * Puchase add qu_factor_to_stock * qu_factor_purchase_to_stock for stock edit * product barcodes with QU and Stores * remove product barcode tags * migrations/0103 add value and factor_puchase_amount to stock_current and stock_current_location_content * Remove unused method * StockService#GetProductDetails: include stock_value * productcard: include stock_value * Add Purchase Factor to Stock Overview * update demo data with stock qu_factor_purchase_to_stock * recipes_pos_resolved update * avg_price and oldest_price in product details * add average price to product card * hint for recipe costs not included if not in stock * Round value and factor_purchas_amount. Include currency for stock value * Add factor_purchase_amount to product card stock amount * Allow editing qu_factor_purchase_to_stock for stock entries * fix update qu_factor_purchase_to_stock for Transfers * Add barcode to existing product update to add to product_barcodes table * Add barcode to new product workflow update to add to product_barcodes table * *** Price now saved as 1 QU to stock in stock tables *** * remove column product barcode and use product_barcodes * Allow products to be deactivated instead of deleted * Embedded barcode and qu-conversion with page reload on change * Save current product barcode into new product_barcodes table * Embedded popup for product group add/edit * barcode scanner added to product barcodes input * Edit product qu_stock is unavailable after first purchase * StockOverview: Filters break when columns are reordered so for now just disable colReorder * view stockoverview.blade: display product_group column * Review Co-authored-by: Bernd Bestel <bernd@berrnd.de>
2020-08-17 14:47:33 -05:00
}
2020-08-31 20:40:31 +02:00
public function Transfer(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
2020-08-31 20:40:31 +02:00
$sql = 'select group_concat(barcode) barcodes, product_id from product_barcodes group by product_id';
$productBarcodes = $this->getDatabaseService()->ExecuteDbQuery($sql)->fetchAll(\PDO::FETCH_OBJ);
2020-08-31 20:40:31 +02:00
return $this->renderPage($response, 'transfer', [
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
2020-08-31 20:40:31 +02:00
'barcodes' => $productBarcodes,
'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE'),
'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved()
2020-08-31 20:40:31 +02:00
]);
}
2020-08-31 20:40:31 +02:00
public function __construct(\DI\Container $container)
{
2020-08-31 20:40:31 +02:00
parent::__construct($container);
}
public function JournalSummary(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$entries = $this->getDatabase()->uihelper_stock_journal_summary();
if (isset($request->getQueryParams()['product_id']))
{
$entries = $entries->where('product_id', $request->getQueryParams()['product_id']);
}
if (isset($request->getQueryParams()['user_id']))
{
$entries = $entries->where('user_id', $request->getQueryParams()['user_id']);
}
if (isset($request->getQueryParams()['transaction_type']))
{
$entries = $entries->where('transaction_type', $request->getQueryParams()['transaction_type']);
}
$usersService = $this->getUsersService();
return $this->renderPage($response, 'stockjournalsummary', [
'entries' => $entries,
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'users' => $usersService->GetUsersAsDto(),
'transactionTypes' => GetClassConstants('\Grocy\Services\StockService', 'TRANSACTION_TYPE_')
]);
}
2018-04-11 19:49:35 +02:00
}