mirror of
https://github.com/grocy/grocy.git
synced 2026-04-07 05:16:15 +02:00
bug fixes following merge
This commit is contained in:
parent
6d049185cf
commit
a3f5efdd5b
|
|
@ -13,6 +13,7 @@ class BaseController
|
||||||
public function __construct(\DI\Container $container) {
|
public function __construct(\DI\Container $container) {
|
||||||
|
|
||||||
$this->AppContainer = $container;
|
$this->AppContainer = $container;
|
||||||
|
$this->View = $container->get('view');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function render($response, $page, $data = [])
|
protected function render($response, $page, $data = [])
|
||||||
|
|
@ -20,21 +21,21 @@ class BaseController
|
||||||
$container = $this->AppContainer;
|
$container = $this->AppContainer;
|
||||||
|
|
||||||
$versionInfo = $this->getApplicationService()->GetInstalledVersion();
|
$versionInfo = $this->getApplicationService()->GetInstalledVersion();
|
||||||
$container->view->set('version', $versionInfo->Version);
|
$this->View->set('version', $versionInfo->Version);
|
||||||
$container->view->set('releaseDate', $versionInfo->ReleaseDate);
|
$this->View->set('releaseDate', $versionInfo->ReleaseDate);
|
||||||
|
|
||||||
$localizationService = $this->getLocalizationService();
|
$localizationService = $this->getLocalizationService();
|
||||||
$container->view->set('__t', function(string $text, ...$placeholderValues) use($localizationService)
|
$this->View->set('__t', function(string $text, ...$placeholderValues) use($localizationService)
|
||||||
{
|
{
|
||||||
return $localizationService->__t($text, $placeholderValues);
|
return $localizationService->__t($text, $placeholderValues);
|
||||||
});
|
});
|
||||||
$container->view->set('__n', function($number, $singularForm, $pluralForm) use($localizationService)
|
$this->View->set('__n', function($number, $singularForm, $pluralForm) use($localizationService)
|
||||||
{
|
{
|
||||||
return $localizationService->__n($number, $singularForm, $pluralForm);
|
return $localizationService->__n($number, $singularForm, $pluralForm);
|
||||||
});
|
});
|
||||||
$container->view->set('GettextPo', $localizationService->GetPoAsJsonString());
|
$this->View->set('GettextPo', $localizationService->GetPoAsJsonString());
|
||||||
|
|
||||||
$container->view->set('U', function($relativePath, $isResource = false) use($container)
|
$this->View->set('U', function($relativePath, $isResource = false) use($container)
|
||||||
{
|
{
|
||||||
return $container->get('UrlManager')->ConstructUrl($relativePath, $isResource);
|
return $container->get('UrlManager')->ConstructUrl($relativePath, $isResource);
|
||||||
});
|
});
|
||||||
|
|
@ -44,7 +45,7 @@ class BaseController
|
||||||
{
|
{
|
||||||
$embedded = true;
|
$embedded = true;
|
||||||
}
|
}
|
||||||
$container->view->set('embedded', $embedded);
|
$this->View->set('embedded', $embedded);
|
||||||
|
|
||||||
$constants = get_defined_constants();
|
$constants = get_defined_constants();
|
||||||
foreach ($constants as $constant => $value)
|
foreach ($constants as $constant => $value)
|
||||||
|
|
@ -54,27 +55,24 @@ class BaseController
|
||||||
unset($constants[$constant]);
|
unset($constants[$constant]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$container->view->set('featureFlags', $constants);
|
$this->View->set('featureFlags', $constants);
|
||||||
|
|
||||||
$this->AppContainer = $container;
|
return $this->View->render($response, $page, $data);
|
||||||
|
|
||||||
return $this->AppContainer->view->render($response, $page, $data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function renderPage($response, $page, $data = [])
|
protected function renderPage($response, $page, $data = [])
|
||||||
{
|
{
|
||||||
$container = $this->AppContainer;
|
$this->View->set('userentitiesForSidebar', $this->getDatabase()->userentities()->where('show_in_sidebar_menu = 1')->orderBy('name'));
|
||||||
$container->view->set('userentitiesForSidebar', $this->getDatabase()->userentities()->where('show_in_sidebar_menu = 1')->orderBy('name'));
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$usersService = $this->getUsersService();
|
$usersService = $this->getUsersService();
|
||||||
if (defined('GROCY_USER_ID'))
|
if (defined('GROCY_USER_ID'))
|
||||||
{
|
{
|
||||||
$container->view->set('userSettings', $usersService->GetUserSettings(GROCY_USER_ID));
|
$this->View->set('userSettings', $usersService->GetUserSettings(GROCY_USER_ID));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$container->view->set('userSettings', null);
|
$this->View->set('userSettings', null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (\Exception $ex)
|
catch (\Exception $ex)
|
||||||
|
|
@ -82,7 +80,6 @@ class BaseController
|
||||||
// Happens when database is not initialised or migrated...
|
// Happens when database is not initialised or migrated...
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->AppContainer = $container;
|
|
||||||
return $this->render($response, $page, $data);
|
return $this->render($response, $page, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ class StockApiController extends BaseApiController
|
||||||
}
|
}
|
||||||
|
|
||||||
$bookingId = $this->getStockService()->AddProduct($args['productId'], $requestBody['amount'], $bestBeforeDate, $transactionType, date('Y-m-d'), $price, $locationId);
|
$bookingId = $this->getStockService()->AddProduct($args['productId'], $requestBody['amount'], $bestBeforeDate, $transactionType, date('Y-m-d'), $price, $locationId);
|
||||||
return $this->ApiResponse($response $this->getDatabase()->stock_log($bookingId));
|
return $this->ApiResponse($response, $this->getDatabase()->stock_log($bookingId));
|
||||||
}
|
}
|
||||||
catch (\Exception $ex)
|
catch (\Exception $ex)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ class StockController extends BaseController
|
||||||
$nextXDays = $usersService->GetUserSettings(GROCY_USER_ID)['stock_expring_soon_days'];
|
$nextXDays = $usersService->GetUserSettings(GROCY_USER_ID)['stock_expring_soon_days'];
|
||||||
|
|
||||||
return $this->AppContainer->view($response, 'stockentries', [
|
return $this->AppContainer->view($response, 'stockentries', [
|
||||||
'products' => $this->getDatabase(()->products()->orderBy('name'),
|
'products' => $this->getDatabase()->products()->orderBy('name'),
|
||||||
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name'),
|
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name'),
|
||||||
'locations' => $this->getDatabase()->locations()->orderBy('name'),
|
'locations' => $this->getDatabase()->locations()->orderBy('name'),
|
||||||
'stockEntries' => $this->getDatabase()->stock()->orderBy('product_id'),
|
'stockEntries' => $this->getDatabase()->stock()->orderBy('product_id'),
|
||||||
|
|
@ -73,7 +73,7 @@ class StockController extends BaseController
|
||||||
|
|
||||||
public function Transfer(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
public function Transfer(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'transfer', [
|
return $this->View->render($response, 'transfer', [
|
||||||
'products' => $this->getDatabase()->products()->orderBy('name'),
|
'products' => $this->getDatabase()->products()->orderBy('name'),
|
||||||
'recipes' => $this->getDatabase()->recipes()->orderBy('name'),
|
'recipes' => $this->getDatabase()->recipes()->orderBy('name'),
|
||||||
'locations' => $this->getDatabase()->locations()->orderBy('name')
|
'locations' => $this->getDatabase()->locations()->orderBy('name')
|
||||||
|
|
@ -90,7 +90,7 @@ class StockController extends BaseController
|
||||||
|
|
||||||
public function StockEntryEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
public function StockEntryEditForm(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'stockentryform', [
|
return $this->View->render($response, 'stockentryform', [
|
||||||
'stockEntry' => $this->getDatabase()->stock()->where('id', $args['entryId'])->fetch(),
|
'stockEntry' => $this->getDatabase()->stock()->where('id', $args['entryId'])->fetch(),
|
||||||
'products' => $this->getDatabase()->products()->orderBy('name'),
|
'products' => $this->getDatabase()->products()->orderBy('name'),
|
||||||
'locations' => $this->getDatabase()->locations()->orderBy('name')
|
'locations' => $this->getDatabase()->locations()->orderBy('name')
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user