mirror of
https://github.com/grocy/grocy.git
synced 2026-04-05 20:36:15 +02:00
lazily obtain valus for page rendering
This commit is contained in:
parent
89b959b3c9
commit
76beb4779e
|
|
@ -12,29 +12,30 @@ class BaseController
|
||||||
public function __construct(\Slim\Container $container) {
|
public function __construct(\Slim\Container $container) {
|
||||||
#$fp = fopen('/config/data/sql.log', 'a');
|
#$fp = fopen('/config/data/sql.log', 'a');
|
||||||
#$time_start = microtime(true);
|
#$time_start = microtime(true);
|
||||||
$databaseService = DatabaseService::getInstance();
|
|
||||||
$this->Database = $databaseService->GetDbConnection();
|
|
||||||
#fwrite($fp, "%%% Login controller - parent construstor database time : " . round((microtime(true) - $time_start),6) . "\n");
|
|
||||||
|
|
||||||
$localizationService = LocalizationService::getInstance(GROCY_CULTURE);
|
$this->AppContainer = $container;
|
||||||
$this->LocalizationService = $localizationService;
|
#fwrite($fp, "%%% Login controller - parent construstor total time : " . round((microtime(true) - $time_start),6) . "\n");
|
||||||
#fwrite($fp, "%%% Login controller - parent construstor localisation time : " . round((microtime(true) - $time_start),6) . "\n");
|
#fclose($fp);
|
||||||
|
}
|
||||||
|
|
||||||
$applicationService = ApplicationService::getInstance();
|
private function render($response, $page, $data = [])
|
||||||
$versionInfo = $applicationService->GetInstalledVersion();
|
{
|
||||||
|
$container = $this->AppContainer;
|
||||||
|
|
||||||
|
$versionInfo = $this->getApplicationService()->GetInstalledVersion();
|
||||||
$container->view->set('version', $versionInfo->Version);
|
$container->view->set('version', $versionInfo->Version);
|
||||||
$container->view->set('releaseDate', $versionInfo->ReleaseDate);
|
$container->view->set('releaseDate', $versionInfo->ReleaseDate);
|
||||||
#fwrite($fp, "%%% Login controller - parent construstor application service time : " . round((microtime(true) - $time_start),6) . "\n");
|
#fwrite($fp, "%%% Login controller - parent construstor application service time : " . round((microtime(true) - $time_start),6) . "\n");
|
||||||
|
|
||||||
$container->view->set('__t', function(string $text, ...$placeholderValues) use($localizationService)
|
$container->view->set('__t', function(string $text, ...$placeholderValues) use($this->getLocalizationService())
|
||||||
{
|
{
|
||||||
return $localizationService->__t($text, $placeholderValues);
|
return $this->getLocalizationService()->__t($text, $placeholderValues);
|
||||||
});
|
});
|
||||||
$container->view->set('__n', function($number, $singularForm, $pluralForm) use($localizationService)
|
$container->view->set('__n', function($number, $singularForm, $pluralForm) use($this->getLocalizationService())
|
||||||
{
|
{
|
||||||
return $localizationService->__n($number, $singularForm, $pluralForm);
|
return $this->getLocalizationService()->__n($number, $singularForm, $pluralForm);
|
||||||
});
|
});
|
||||||
$container->view->set('GettextPo', $localizationService->GetPoAsJsonString());
|
$container->view->set('GettextPo', $this->getLocalizationService()->GetPoAsJsonString());
|
||||||
|
|
||||||
$container->view->set('U', function($relativePath, $isResource = false) use($container)
|
$container->view->set('U', function($relativePath, $isResource = false) use($container)
|
||||||
{
|
{
|
||||||
|
|
@ -58,9 +59,15 @@ class BaseController
|
||||||
}
|
}
|
||||||
$container->view->set('featureFlags', $constants);
|
$container->view->set('featureFlags', $constants);
|
||||||
|
|
||||||
$container->view->set('userentitiesForSidebar', $this->Database->userentities()->where('show_in_sidebar_menu = 1')->orderBy('name'));
|
$this->AppContainer = $container;
|
||||||
#fwrite($fp, "%%% Login controller - parent construstor view time : " . round((microtime(true) - $time_start),6) . "\n");
|
|
||||||
|
|
||||||
|
return $this->AppContainer->view->render($response, $page, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function renderPage($response, $page, $data = [])
|
||||||
|
{
|
||||||
|
$container = $this->AppContainer;
|
||||||
|
$container->view->set('userentitiesForSidebar', $this->getDatabase()->userentities()->where('show_in_sidebar_menu = 1')->orderBy('name'));
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$usersService = new UsersService();
|
$usersService = new UsersService();
|
||||||
|
|
@ -79,11 +86,39 @@ class BaseController
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->AppContainer = $container;
|
$this->AppContainer = $container;
|
||||||
#fwrite($fp, "%%% Login controller - parent construstor total time : " . round((microtime(true) - $time_start),6) . "\n");
|
return $this->render($response, $page, $data);
|
||||||
#fclose($fp);
|
}
|
||||||
|
|
||||||
|
private function getDatabaseService()
|
||||||
|
{
|
||||||
|
return DatabaseService::getInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getDatabase()
|
||||||
|
{
|
||||||
|
return $this->getDatabaseService()->GetDbConnection();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getLocalizationService()
|
||||||
|
{
|
||||||
|
return LocalizationService::getInstance(GROCY_CULTURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getApplicationservice()
|
||||||
|
{
|
||||||
|
return ApplicationService::getInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
private $userfieldsService = null;
|
||||||
|
|
||||||
|
private function getUserfieldsService()
|
||||||
|
{
|
||||||
|
if($this->userfieldsService == null)
|
||||||
|
{
|
||||||
|
$this->userfieldsService = new UserfieldsService();
|
||||||
|
}
|
||||||
|
return $this->userfieldsService;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected $AppContainer;
|
protected $AppContainer;
|
||||||
protected $Database;
|
|
||||||
protected $LocalizationService;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ class BatteriesApiController extends BaseApiController
|
||||||
}
|
}
|
||||||
|
|
||||||
$chargeCycleId = $this->BatteriesService->TrackChargeCycle($args['batteryId'], $trackedTime);
|
$chargeCycleId = $this->BatteriesService->TrackChargeCycle($args['batteryId'], $trackedTime);
|
||||||
return $this->ApiResponse($this->Database->battery_charge_cycles($chargeCycleId));
|
return $this->ApiResponse($this->getDatabase()->battery_charge_cycles($chargeCycleId));
|
||||||
}
|
}
|
||||||
catch (\Exception $ex)
|
catch (\Exception $ex)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ class BatteriesController extends BaseController
|
||||||
{
|
{
|
||||||
parent::__construct($container);
|
parent::__construct($container);
|
||||||
$this->BatteriesService = new BatteriesService();
|
$this->BatteriesService = new BatteriesService();
|
||||||
$this->UserfieldsService = new UserfieldsService();
|
#$this->UserfieldsService = new UserfieldsService();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected $BatteriesService;
|
protected $BatteriesService;
|
||||||
|
|
@ -23,28 +23,28 @@ class BatteriesController extends BaseController
|
||||||
$usersService = new UsersService();
|
$usersService = new UsersService();
|
||||||
$nextXDays = $usersService->GetUserSettings(GROCY_USER_ID)['batteries_due_soon_days'];
|
$nextXDays = $usersService->GetUserSettings(GROCY_USER_ID)['batteries_due_soon_days'];
|
||||||
|
|
||||||
return $this->AppContainer->view->render($response, 'batteriesoverview', [
|
return $this->renderPage($response, 'batteriesoverview', [
|
||||||
'batteries' => $this->Database->batteries()->orderBy('name'),
|
'batteries' => $this->getDatabase()->batteries()->orderBy('name'),
|
||||||
'current' => $this->BatteriesService->GetCurrent(),
|
'current' => $this->BatteriesService->GetCurrent(),
|
||||||
'nextXDays' => $nextXDays,
|
'nextXDays' => $nextXDays,
|
||||||
'userfields' => $this->UserfieldsService->GetFields('batteries'),
|
'userfields' => $this->getUserfieldsService()->GetFields('batteries'),
|
||||||
'userfieldValues' => $this->UserfieldsService->GetAllValues('batteries')
|
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('batteries')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function TrackChargeCycle(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
public function TrackChargeCycle(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'batterytracking', [
|
return $this->renderPage($response, 'batterytracking', [
|
||||||
'batteries' => $this->Database->batteries()->orderBy('name')
|
'batteries' => $this->getDatabase()->batteries()->orderBy('name')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function BatteriesList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
public function BatteriesList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'batteries', [
|
return $this->renderPage($response, 'batteries', [
|
||||||
'batteries' => $this->Database->batteries()->orderBy('name'),
|
'batteries' => $this->getDatabase()->batteries()->orderBy('name'),
|
||||||
'userfields' => $this->UserfieldsService->GetFields('batteries'),
|
'userfields' => $this->getUserfieldsService()->GetFields('batteries'),
|
||||||
'userfieldValues' => $this->UserfieldsService->GetAllValues('batteries')
|
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('batteries')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -52,31 +52,31 @@ class BatteriesController extends BaseController
|
||||||
{
|
{
|
||||||
if ($args['batteryId'] == 'new')
|
if ($args['batteryId'] == 'new')
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'batteryform', [
|
return $this->renderPage($response, 'batteryform', [
|
||||||
'mode' => 'create',
|
'mode' => 'create',
|
||||||
'userfields' => $this->UserfieldsService->GetFields('batteries')
|
'userfields' => $this->getUserfieldsService()->GetFields('batteries')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'batteryform', [
|
return $this->renderPage($response, 'batteryform', [
|
||||||
'battery' => $this->Database->batteries($args['batteryId']),
|
'battery' => $this->getDatabase()->batteries($args['batteryId']),
|
||||||
'mode' => 'edit',
|
'mode' => 'edit',
|
||||||
'userfields' => $this->UserfieldsService->GetFields('batteries')
|
'userfields' => $this->getUserfieldsService()->GetFields('batteries')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function Journal(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
public function Journal(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'batteriesjournal', [
|
return $this->renderPage($response, 'batteriesjournal', [
|
||||||
'chargeCycles' => $this->Database->battery_charge_cycles()->orderBy('tracked_time', 'DESC'),
|
'chargeCycles' => $this->getDatabase()->battery_charge_cycles()->orderBy('tracked_time', 'DESC'),
|
||||||
'batteries' => $this->Database->batteries()->orderBy('name')
|
'batteries' => $this->getDatabase()->batteries()->orderBy('name')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function BatteriesSettings(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
public function BatteriesSettings(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'batteriessettings');
|
return $this->renderPage($response, 'batteriessettings');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ class CalendarController extends BaseController
|
||||||
|
|
||||||
public function Overview(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
public function Overview(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'calendar', [
|
return $this->renderPage($response, 'calendar', [
|
||||||
'fullcalendarEventSources' => $this->CalendarService->GetEvents()
|
'fullcalendarEventSources' => $this->CalendarService->GetEvents()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ class ChoresApiController extends BaseApiController
|
||||||
}
|
}
|
||||||
|
|
||||||
$choreExecutionId = $this->ChoresService->TrackChore($args['choreId'], $trackedTime, $doneBy);
|
$choreExecutionId = $this->ChoresService->TrackChore($args['choreId'], $trackedTime, $doneBy);
|
||||||
return $this->ApiResponse($this->Database->chores_log($choreExecutionId));
|
return $this->ApiResponse($this->getDatabase()->chores_log($choreExecutionId));
|
||||||
}
|
}
|
||||||
catch (\Exception $ex)
|
catch (\Exception $ex)
|
||||||
{
|
{
|
||||||
|
|
@ -85,7 +85,7 @@ class ChoresApiController extends BaseApiController
|
||||||
|
|
||||||
if ($choreId === null)
|
if ($choreId === null)
|
||||||
{
|
{
|
||||||
$chores = $this->Database->chores();
|
$chores = $this->getDatabase()->chores();
|
||||||
foreach ($chores as $chore)
|
foreach ($chores as $chore)
|
||||||
{
|
{
|
||||||
$this->ChoresService->CalculateNextExecutionAssignment($chore->id);
|
$this->ChoresService->CalculateNextExecutionAssignment($chore->id);
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,8 @@ class ChoresController extends BaseController
|
||||||
$usersService = new UsersService();
|
$usersService = new UsersService();
|
||||||
$nextXDays = $usersService->GetUserSettings(GROCY_USER_ID)['chores_due_soon_days'];
|
$nextXDays = $usersService->GetUserSettings(GROCY_USER_ID)['chores_due_soon_days'];
|
||||||
|
|
||||||
return $this->AppContainer->view->render($response, 'choresoverview', [
|
return $this->renderPage($response, 'choresoverview', [
|
||||||
'chores' => $this->Database->chores()->orderBy('name'),
|
'chores' => $this->getDatabase()->chores()->orderBy('name'),
|
||||||
'currentChores' => $this->ChoresService->GetCurrent(),
|
'currentChores' => $this->ChoresService->GetCurrent(),
|
||||||
'nextXDays' => $nextXDays,
|
'nextXDays' => $nextXDays,
|
||||||
'userfields' => $this->UserfieldsService->GetFields('chores'),
|
'userfields' => $this->UserfieldsService->GetFields('chores'),
|
||||||
|
|
@ -35,16 +35,16 @@ class ChoresController extends BaseController
|
||||||
|
|
||||||
public function TrackChoreExecution(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
public function TrackChoreExecution(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'choretracking', [
|
return $this->renderPage($response, 'choretracking', [
|
||||||
'chores' => $this->Database->chores()->orderBy('name'),
|
'chores' => $this->getDatabase()->chores()->orderBy('name'),
|
||||||
'users' => $this->Database->users()->orderBy('username')
|
'users' => $this->getDatabase()->users()->orderBy('username')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function ChoresList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
public function ChoresList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'chores', [
|
return $this->renderPage($response, 'chores', [
|
||||||
'chores' => $this->Database->chores()->orderBy('name'),
|
'chores' => $this->getDatabase()->chores()->orderBy('name'),
|
||||||
'userfields' => $this->UserfieldsService->GetFields('chores'),
|
'userfields' => $this->UserfieldsService->GetFields('chores'),
|
||||||
'userfieldValues' => $this->UserfieldsService->GetAllValues('chores')
|
'userfieldValues' => $this->UserfieldsService->GetAllValues('chores')
|
||||||
]);
|
]);
|
||||||
|
|
@ -52,10 +52,10 @@ class ChoresController extends BaseController
|
||||||
|
|
||||||
public function Journal(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
public function Journal(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'choresjournal', [
|
return $this->renderPage($response, 'choresjournal', [
|
||||||
'choresLog' => $this->Database->chores_log()->orderBy('tracked_time', 'DESC'),
|
'choresLog' => $this->getDatabase()->chores_log()->orderBy('tracked_time', 'DESC'),
|
||||||
'chores' => $this->Database->chores()->orderBy('name'),
|
'chores' => $this->getDatabase()->chores()->orderBy('name'),
|
||||||
'users' => $this->Database->users()->orderBy('username')
|
'users' => $this->getDatabase()->users()->orderBy('username')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -66,31 +66,31 @@ class ChoresController extends BaseController
|
||||||
|
|
||||||
if ($args['choreId'] == 'new')
|
if ($args['choreId'] == 'new')
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'choreform', [
|
return $this->renderPage($response, 'choreform', [
|
||||||
'periodTypes' => GetClassConstants('\Grocy\Services\ChoresService', 'CHORE_PERIOD_TYPE_'),
|
'periodTypes' => GetClassConstants('\Grocy\Services\ChoresService', 'CHORE_PERIOD_TYPE_'),
|
||||||
'mode' => 'create',
|
'mode' => 'create',
|
||||||
'userfields' => $this->UserfieldsService->GetFields('chores'),
|
'userfields' => $this->UserfieldsService->GetFields('chores'),
|
||||||
'assignmentTypes' => GetClassConstants('\Grocy\Services\ChoresService', 'CHORE_ASSIGNMENT_TYPE_'),
|
'assignmentTypes' => GetClassConstants('\Grocy\Services\ChoresService', 'CHORE_ASSIGNMENT_TYPE_'),
|
||||||
'users' => $users,
|
'users' => $users,
|
||||||
'products' => $this->Database->products()->orderBy('name')
|
'products' => $this->getDatabase()->products()->orderBy('name')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'choreform', [
|
return $this->renderPage($response, 'choreform', [
|
||||||
'chore' => $this->Database->chores($args['choreId']),
|
'chore' => $this->getDatabase()->chores($args['choreId']),
|
||||||
'periodTypes' => GetClassConstants('\Grocy\Services\ChoresService', 'CHORE_PERIOD_TYPE_'),
|
'periodTypes' => GetClassConstants('\Grocy\Services\ChoresService', 'CHORE_PERIOD_TYPE_'),
|
||||||
'mode' => 'edit',
|
'mode' => 'edit',
|
||||||
'userfields' => $this->UserfieldsService->GetFields('chores'),
|
'userfields' => $this->UserfieldsService->GetFields('chores'),
|
||||||
'assignmentTypes' => GetClassConstants('\Grocy\Services\ChoresService', 'CHORE_ASSIGNMENT_TYPE_'),
|
'assignmentTypes' => GetClassConstants('\Grocy\Services\ChoresService', 'CHORE_ASSIGNMENT_TYPE_'),
|
||||||
'users' => $users,
|
'users' => $users,
|
||||||
'products' => $this->Database->products()->orderBy('name')
|
'products' => $this->getDatabase()->products()->orderBy('name')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function ChoresSettings(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
public function ChoresSettings(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'choressettings');
|
return $this->renderPage($response, 'choressettings');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,8 @@ class EquipmentController extends BaseController
|
||||||
|
|
||||||
public function Overview(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
public function Overview(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'equipment', [
|
return $this->renderPage($response, 'equipment', [
|
||||||
'equipment' => $this->Database->equipment()->orderBy('name'),
|
'equipment' => $this->getDatabase()->equipment()->orderBy('name'),
|
||||||
'userfields' => $this->UserfieldsService->GetFields('equipment'),
|
'userfields' => $this->UserfieldsService->GetFields('equipment'),
|
||||||
'userfieldValues' => $this->UserfieldsService->GetAllValues('equipment')
|
'userfieldValues' => $this->UserfieldsService->GetAllValues('equipment')
|
||||||
]);
|
]);
|
||||||
|
|
@ -27,15 +27,15 @@ class EquipmentController extends BaseController
|
||||||
{
|
{
|
||||||
if ($args['equipmentId'] == 'new')
|
if ($args['equipmentId'] == 'new')
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'equipmentform', [
|
return $this->renderPage($response, 'equipmentform', [
|
||||||
'mode' => 'create',
|
'mode' => 'create',
|
||||||
'userfields' => $this->UserfieldsService->GetFields('equipment')
|
'userfields' => $this->UserfieldsService->GetFields('equipment')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'equipmentform', [
|
return $this->renderPage($response, 'equipmentform', [
|
||||||
'equipment' => $this->Database->equipment($args['equipmentId']),
|
'equipment' => $this->getDatabase()->equipment($args['equipmentId']),
|
||||||
'mode' => 'edit',
|
'mode' => 'edit',
|
||||||
'userfields' => $this->UserfieldsService->GetFields('equipment')
|
'userfields' => $this->UserfieldsService->GetFields('equipment')
|
||||||
]);
|
]);
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ class GenericEntityApiController extends BaseApiController
|
||||||
{
|
{
|
||||||
if ($this->IsValidEntity($args['entity']) && !$this->IsEntityWithPreventedListing($args['entity']))
|
if ($this->IsValidEntity($args['entity']) && !$this->IsEntityWithPreventedListing($args['entity']))
|
||||||
{
|
{
|
||||||
return $this->ApiResponse($this->Database->{$args['entity']}());
|
return $this->ApiResponse($this->getDatabase()->{$args['entity']}());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -30,7 +30,7 @@ class GenericEntityApiController extends BaseApiController
|
||||||
{
|
{
|
||||||
if ($this->IsValidEntity($args['entity']) && !$this->IsEntityWithPreventedListing($args['entity']))
|
if ($this->IsValidEntity($args['entity']) && !$this->IsEntityWithPreventedListing($args['entity']))
|
||||||
{
|
{
|
||||||
return $this->ApiResponse($this->Database->{$args['entity']}($args['objectId']));
|
return $this->ApiResponse($this->getDatabase()->{$args['entity']}($args['objectId']));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -51,11 +51,11 @@ class GenericEntityApiController extends BaseApiController
|
||||||
throw new \Exception('Request body could not be parsed (probably invalid JSON format or missing/wrong Content-Type header)');
|
throw new \Exception('Request body could not be parsed (probably invalid JSON format or missing/wrong Content-Type header)');
|
||||||
}
|
}
|
||||||
|
|
||||||
$newRow = $this->Database->{$args['entity']}()->createRow($requestBody);
|
$newRow = $this->getDatabase()->{$args['entity']}()->createRow($requestBody);
|
||||||
$newRow->save();
|
$newRow->save();
|
||||||
$success = $newRow->isClean();
|
$success = $newRow->isClean();
|
||||||
return $this->ApiResponse(array(
|
return $this->ApiResponse(array(
|
||||||
'created_object_id' => $this->Database->lastInsertId()
|
'created_object_id' => $this->getDatabase()->lastInsertId()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
catch (\Exception $ex)
|
catch (\Exception $ex)
|
||||||
|
|
@ -82,7 +82,7 @@ class GenericEntityApiController extends BaseApiController
|
||||||
throw new \Exception('Request body could not be parsed (probably invalid JSON format or missing/wrong Content-Type header)');
|
throw new \Exception('Request body could not be parsed (probably invalid JSON format or missing/wrong Content-Type header)');
|
||||||
}
|
}
|
||||||
|
|
||||||
$row = $this->Database->{$args['entity']}($args['objectId']);
|
$row = $this->getDatabase()->{$args['entity']}($args['objectId']);
|
||||||
$row->update($requestBody);
|
$row->update($requestBody);
|
||||||
$success = $row->isClean();
|
$success = $row->isClean();
|
||||||
return $this->EmptyApiResponse($response);
|
return $this->EmptyApiResponse($response);
|
||||||
|
|
@ -102,7 +102,7 @@ class GenericEntityApiController extends BaseApiController
|
||||||
{
|
{
|
||||||
if ($this->IsValidEntity($args['entity']))
|
if ($this->IsValidEntity($args['entity']))
|
||||||
{
|
{
|
||||||
$row = $this->Database->{$args['entity']}($args['objectId']);
|
$row = $this->getDatabase()->{$args['entity']}($args['objectId']);
|
||||||
$row->delete();
|
$row->delete();
|
||||||
$success = $row->isClean();
|
$success = $row->isClean();
|
||||||
return $this->EmptyApiResponse($response);
|
return $this->EmptyApiResponse($response);
|
||||||
|
|
@ -119,7 +119,7 @@ class GenericEntityApiController extends BaseApiController
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return $this->ApiResponse($this->Database->{$args['entity']}()->where('name LIKE ?', '%' . $args['searchString'] . '%'));
|
return $this->ApiResponse($this->getDatabase()->{$args['entity']}()->where('name LIKE ?', '%' . $args['searchString'] . '%'));
|
||||||
}
|
}
|
||||||
catch (\PDOException $ex)
|
catch (\PDOException $ex)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ class GenericEntityController extends BaseController
|
||||||
|
|
||||||
public function UserfieldsList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
public function UserfieldsList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'userfields', [
|
return $this->renderPage($response, 'userfields', [
|
||||||
'userfields' => $this->UserfieldsService->GetAllFields(),
|
'userfields' => $this->UserfieldsService->GetAllFields(),
|
||||||
'entities' => $this->UserfieldsService->GetEntities()
|
'entities' => $this->UserfieldsService->GetEntities()
|
||||||
]);
|
]);
|
||||||
|
|
@ -24,18 +24,18 @@ class GenericEntityController extends BaseController
|
||||||
|
|
||||||
public function UserentitiesList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
public function UserentitiesList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'userentities', [
|
return $this->renderPage($response, 'userentities', [
|
||||||
'userentities' => $this->Database->userentities()->orderBy('name')
|
'userentities' => $this->getDatabase()->userentities()->orderBy('name')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function UserobjectsList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
public function UserobjectsList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||||
{
|
{
|
||||||
$userentity = $this->Database->userentities()->where('name = :1', $args['userentityName'])->fetch();
|
$userentity = $this->getDatabase()->userentities()->where('name = :1', $args['userentityName'])->fetch();
|
||||||
|
|
||||||
return $this->AppContainer->view->render($response, 'userobjects', [
|
return $this->renderPage($response, 'userobjects', [
|
||||||
'userentity' => $userentity,
|
'userentity' => $userentity,
|
||||||
'userobjects' => $this->Database->userobjects()->where('userentity_id = :1', $userentity->id),
|
'userobjects' => $this->getDatabase()->userobjects()->where('userentity_id = :1', $userentity->id),
|
||||||
'userfields' => $this->UserfieldsService->GetFields('userentity-' . $args['userentityName']),
|
'userfields' => $this->UserfieldsService->GetFields('userentity-' . $args['userentityName']),
|
||||||
'userfieldValues' => $this->UserfieldsService->GetAllValues('userentity-' . $args['userentityName'])
|
'userfieldValues' => $this->UserfieldsService->GetAllValues('userentity-' . $args['userentityName'])
|
||||||
]);
|
]);
|
||||||
|
|
@ -45,7 +45,7 @@ class GenericEntityController extends BaseController
|
||||||
{
|
{
|
||||||
if ($args['userfieldId'] == 'new')
|
if ($args['userfieldId'] == 'new')
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'userfieldform', [
|
return $this->renderPage($response, 'userfieldform', [
|
||||||
'mode' => 'create',
|
'mode' => 'create',
|
||||||
'userfieldTypes' => $this->UserfieldsService->GetFieldTypes(),
|
'userfieldTypes' => $this->UserfieldsService->GetFieldTypes(),
|
||||||
'entities' => $this->UserfieldsService->GetEntities()
|
'entities' => $this->UserfieldsService->GetEntities()
|
||||||
|
|
@ -53,7 +53,7 @@ class GenericEntityController extends BaseController
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'userfieldform', [
|
return $this->renderPage($response, 'userfieldform', [
|
||||||
'mode' => 'edit',
|
'mode' => 'edit',
|
||||||
'userfield' => $this->UserfieldsService->GetField($args['userfieldId']),
|
'userfield' => $this->UserfieldsService->GetField($args['userfieldId']),
|
||||||
'userfieldTypes' => $this->UserfieldsService->GetFieldTypes(),
|
'userfieldTypes' => $this->UserfieldsService->GetFieldTypes(),
|
||||||
|
|
@ -66,26 +66,26 @@ class GenericEntityController extends BaseController
|
||||||
{
|
{
|
||||||
if ($args['userentityId'] == 'new')
|
if ($args['userentityId'] == 'new')
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'userentityform', [
|
return $this->renderPage($response, 'userentityform', [
|
||||||
'mode' => 'create'
|
'mode' => 'create'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'userentityform', [
|
return $this->renderPage($response, 'userentityform', [
|
||||||
'mode' => 'edit',
|
'mode' => 'edit',
|
||||||
'userentity' => $this->Database->userentities($args['userentityId'])
|
'userentity' => $this->getDatabase()->userentities($args['userentityId'])
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function UserobjectEditForm(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
public function UserobjectEditForm(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||||
{
|
{
|
||||||
$userentity = $this->Database->userentities()->where('name = :1', $args['userentityName'])->fetch();
|
$userentity = $this->getDatabase()->userentities()->where('name = :1', $args['userentityName'])->fetch();
|
||||||
|
|
||||||
if ($args['userobjectId'] == 'new')
|
if ($args['userobjectId'] == 'new')
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'userobjectform', [
|
return $this->renderPage($response, 'userobjectform', [
|
||||||
'userentity' => $userentity,
|
'userentity' => $userentity,
|
||||||
'mode' => 'create',
|
'mode' => 'create',
|
||||||
'userfields' => $this->UserfieldsService->GetFields('userentity-' . $args['userentityName'])
|
'userfields' => $this->UserfieldsService->GetFields('userentity-' . $args['userentityName'])
|
||||||
|
|
@ -93,10 +93,10 @@ class GenericEntityController extends BaseController
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'userobjectform', [
|
return $this->renderPage($response, 'userobjectform', [
|
||||||
'userentity' => $userentity,
|
'userentity' => $userentity,
|
||||||
'mode' => 'edit',
|
'mode' => 'edit',
|
||||||
'userobject' => $this->Database->userobjects($args['userobjectId']),
|
'userobject' => $this->getDatabase()->userobjects($args['userobjectId']),
|
||||||
'userfields' => $this->UserfieldsService->GetFields('userentity-' . $args['userentityName'])
|
'userfields' => $this->UserfieldsService->GetFields('userentity-' . $args['userentityName'])
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ class LoginController extends BaseController
|
||||||
$postParams = $request->getParsedBody();
|
$postParams = $request->getParsedBody();
|
||||||
if (isset($postParams['username']) && isset($postParams['password']))
|
if (isset($postParams['username']) && isset($postParams['password']))
|
||||||
{
|
{
|
||||||
$user = $this->Database->users()->where('username', $postParams['username'])->fetch();
|
$user = $this->getDatabase()->users()->where('username', $postParams['username'])->fetch();
|
||||||
$inputPassword = $postParams['password'];
|
$inputPassword = $postParams['password'];
|
||||||
$stayLoggedInPermanently = $postParams['stay_logged_in'] == 'on';
|
$stayLoggedInPermanently = $postParams['stay_logged_in'] == 'on';
|
||||||
|
|
||||||
|
|
@ -72,7 +72,7 @@ class LoginController extends BaseController
|
||||||
|
|
||||||
public function LoginPage(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
public function LoginPage(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'login');
|
return $this->renderPage($response, 'login');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function Logout(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
public function Logout(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace Grocy\Controllers;
|
namespace Grocy\Controllers;
|
||||||
|
|
||||||
use \Grocy\Services\ApplicationService;
|
#use \Grocy\Services\ApplicationService;
|
||||||
use \Grocy\Services\ApiKeyService;
|
use \Grocy\Services\ApiKeyService;
|
||||||
|
|
||||||
class OpenApiController extends BaseApiController
|
class OpenApiController extends BaseApiController
|
||||||
|
|
@ -17,12 +17,12 @@ class OpenApiController extends BaseApiController
|
||||||
|
|
||||||
public function DocumentationUi(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
public function DocumentationUi(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'openapiui');
|
return $this->render($response, 'openapiui');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function DocumentationSpec(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
public function DocumentationSpec(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||||
{
|
{
|
||||||
$applicationService = ApplicationService::getInstance();
|
$applicationService = $this->getApplicationService;
|
||||||
|
|
||||||
$versionInfo = $applicationService->GetInstalledVersion();
|
$versionInfo = $applicationService->GetInstalledVersion();
|
||||||
$this->OpenApiSpec->info->version = $versionInfo->Version;
|
$this->OpenApiSpec->info->version = $versionInfo->Version;
|
||||||
|
|
@ -34,9 +34,9 @@ class OpenApiController extends BaseApiController
|
||||||
|
|
||||||
public function ApiKeysList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
public function ApiKeysList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'manageapikeys', [
|
return $this->renderPage($response, 'manageapikeys', [
|
||||||
'apiKeys' => $this->Database->api_keys(),
|
'apiKeys' => $this->getDatabase()->api_keys(),
|
||||||
'users' => $this->Database->users()
|
'users' => $this->getDatabase()->users()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,11 +21,11 @@ class RecipesController extends BaseController
|
||||||
{
|
{
|
||||||
if (isset($request->getQueryParams()['include-internal']))
|
if (isset($request->getQueryParams()['include-internal']))
|
||||||
{
|
{
|
||||||
$recipes = $this->Database->recipes()->orderBy('name');
|
$recipes = $this->getDatabase()->recipes()->orderBy('name');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$recipes = $this->Database->recipes()->where('type', RecipesService::RECIPE_TYPE_NORMAL)->orderBy('name');
|
$recipes = $this->getDatabase()->recipes()->where('type', RecipesService::RECIPE_TYPE_NORMAL)->orderBy('name');
|
||||||
}
|
}
|
||||||
$recipesResolved = $this->RecipesService->GetRecipesResolved();
|
$recipesResolved = $this->RecipesService->GetRecipesResolved();
|
||||||
|
|
||||||
|
|
@ -33,21 +33,21 @@ class RecipesController extends BaseController
|
||||||
$selectedRecipePositionsResolved = null;
|
$selectedRecipePositionsResolved = null;
|
||||||
if (isset($request->getQueryParams()['recipe']))
|
if (isset($request->getQueryParams()['recipe']))
|
||||||
{
|
{
|
||||||
$selectedRecipe = $this->Database->recipes($request->getQueryParams()['recipe']);
|
$selectedRecipe = $this->getDatabase()->recipes($request->getQueryParams()['recipe']);
|
||||||
$selectedRecipePositionsResolved = $this->Database->recipes_pos_resolved()->where('recipe_id', $request->getQueryParams()['recipe'])->orderBy('ingredient_group');
|
$selectedRecipePositionsResolved = $this->getDatabase()->recipes_pos_resolved()->where('recipe_id', $request->getQueryParams()['recipe'])->orderBy('ingredient_group');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
foreach ($recipes as $recipe)
|
foreach ($recipes as $recipe)
|
||||||
{
|
{
|
||||||
$selectedRecipe = $recipe;
|
$selectedRecipe = $recipe;
|
||||||
$selectedRecipePositionsResolved = $this->Database->recipes_pos_resolved()->where('recipe_id', $recipe->id)->orderBy('ingredient_group');
|
$selectedRecipePositionsResolved = $this->getDatabase()->recipes_pos_resolved()->where('recipe_id', $recipe->id)->orderBy('ingredient_group');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$selectedRecipeSubRecipes = $this->Database->recipes()->where('id IN (SELECT includes_recipe_id FROM recipes_nestings_resolved WHERE recipe_id = :1 AND includes_recipe_id != :1)', $selectedRecipe->id)->orderBy('name')->fetchAll();
|
$selectedRecipeSubRecipes = $this->getDatabase()->recipes()->where('id IN (SELECT includes_recipe_id FROM recipes_nestings_resolved WHERE recipe_id = :1 AND includes_recipe_id != :1)', $selectedRecipe->id)->orderBy('name')->fetchAll();
|
||||||
$selectedRecipeSubRecipesPositions = $this->Database->recipes_pos_resolved()->where('recipe_id = :1', $selectedRecipe->id)->orderBy('ingredient_group')->fetchAll();
|
$selectedRecipeSubRecipesPositions = $this->getDatabase()->recipes_pos_resolved()->where('recipe_id = :1', $selectedRecipe->id)->orderBy('ingredient_group')->fetchAll();
|
||||||
|
|
||||||
$includedRecipeIdsAbsolute = array();
|
$includedRecipeIdsAbsolute = array();
|
||||||
$includedRecipeIdsAbsolute[] = $selectedRecipe->id;
|
$includedRecipeIdsAbsolute[] = $selectedRecipe->id;
|
||||||
|
|
@ -56,14 +56,14 @@ class RecipesController extends BaseController
|
||||||
$includedRecipeIdsAbsolute[] = $subRecipe->id;
|
$includedRecipeIdsAbsolute[] = $subRecipe->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->AppContainer->view->render($response, 'recipes', [
|
return $this->renderPage($response, 'recipes', [
|
||||||
'recipes' => $recipes,
|
'recipes' => $recipes,
|
||||||
'recipesResolved' => $recipesResolved,
|
'recipesResolved' => $recipesResolved,
|
||||||
'recipePositionsResolved' => $this->Database->recipes_pos_resolved(),
|
'recipePositionsResolved' => $this->getDatabase()->recipes_pos_resolved(),
|
||||||
'selectedRecipe' => $selectedRecipe,
|
'selectedRecipe' => $selectedRecipe,
|
||||||
'selectedRecipePositionsResolved' => $selectedRecipePositionsResolved,
|
'selectedRecipePositionsResolved' => $selectedRecipePositionsResolved,
|
||||||
'products' => $this->Database->products(),
|
'products' => $this->getDatabase()->products(),
|
||||||
'quantityUnits' => $this->Database->quantity_units(),
|
'quantityUnits' => $this->getDatabase()->quantity_units(),
|
||||||
'selectedRecipeSubRecipes' => $selectedRecipeSubRecipes,
|
'selectedRecipeSubRecipes' => $selectedRecipeSubRecipes,
|
||||||
'selectedRecipeSubRecipesPositions' => $selectedRecipeSubRecipesPositions,
|
'selectedRecipeSubRecipesPositions' => $selectedRecipeSubRecipesPositions,
|
||||||
'includedRecipeIdsAbsolute' => $includedRecipeIdsAbsolute,
|
'includedRecipeIdsAbsolute' => $includedRecipeIdsAbsolute,
|
||||||
|
|
@ -71,7 +71,7 @@ class RecipesController extends BaseController
|
||||||
'selectedRecipeTotalCalories' => FindObjectInArrayByPropertyValue($recipesResolved, 'recipe_id', $selectedRecipe->id)->calories,
|
'selectedRecipeTotalCalories' => FindObjectInArrayByPropertyValue($recipesResolved, 'recipe_id', $selectedRecipe->id)->calories,
|
||||||
'userfields' => $this->UserfieldsService->GetFields('recipes'),
|
'userfields' => $this->UserfieldsService->GetFields('recipes'),
|
||||||
'userfieldValues' => $this->UserfieldsService->GetAllValues('recipes'),
|
'userfieldValues' => $this->UserfieldsService->GetAllValues('recipes'),
|
||||||
'quantityUnitConversionsResolved' => $this->Database->quantity_unit_conversions_resolved()
|
'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -80,26 +80,26 @@ class RecipesController extends BaseController
|
||||||
$recipeId = $args['recipeId'];
|
$recipeId = $args['recipeId'];
|
||||||
if ($recipeId == 'new')
|
if ($recipeId == 'new')
|
||||||
{
|
{
|
||||||
$newRecipe = $this->Database->recipes()->where('type', RecipesService::RECIPE_TYPE_NORMAL)->createRow(array(
|
$newRecipe = $this->getDatabase()->recipes()->where('type', RecipesService::RECIPE_TYPE_NORMAL)->createRow(array(
|
||||||
'name' => $this->LocalizationService->__t('New recipe')
|
'name' => $this->getLocalizationService()->__t('New recipe')
|
||||||
));
|
));
|
||||||
$newRecipe->save();
|
$newRecipe->save();
|
||||||
|
|
||||||
$recipeId = $this->Database->lastInsertId();
|
$recipeId = $this->getDatabase()->lastInsertId();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->AppContainer->view->render($response, 'recipeform', [
|
return $this->renderPage($response, 'recipeform', [
|
||||||
'recipe' => $this->Database->recipes($recipeId),
|
'recipe' => $this->getDatabase()->recipes($recipeId),
|
||||||
'recipePositions' => $this->Database->recipes_pos()->where('recipe_id', $recipeId),
|
'recipePositions' => $this->getDatabase()->recipes_pos()->where('recipe_id', $recipeId),
|
||||||
'mode' => 'edit',
|
'mode' => 'edit',
|
||||||
'products' => $this->Database->products(),
|
'products' => $this->getDatabase()->products(),
|
||||||
'quantityunits' => $this->Database->quantity_units(),
|
'quantityunits' => $this->getDatabase()->quantity_units(),
|
||||||
'recipePositionsResolved' => $this->RecipesService->GetRecipesPosResolved(),
|
'recipePositionsResolved' => $this->RecipesService->GetRecipesPosResolved(),
|
||||||
'recipesResolved' => $this->RecipesService->GetRecipesResolved(),
|
'recipesResolved' => $this->RecipesService->GetRecipesResolved(),
|
||||||
'recipes' => $this->Database->recipes()->where('type', RecipesService::RECIPE_TYPE_NORMAL)->orderBy('name'),
|
'recipes' => $this->getDatabase()->recipes()->where('type', RecipesService::RECIPE_TYPE_NORMAL)->orderBy('name'),
|
||||||
'recipeNestings' => $this->Database->recipes_nestings()->where('recipe_id', $recipeId),
|
'recipeNestings' => $this->getDatabase()->recipes_nestings()->where('recipe_id', $recipeId),
|
||||||
'userfields' => $this->UserfieldsService->GetFields('recipes'),
|
'userfields' => $this->UserfieldsService->GetFields('recipes'),
|
||||||
'quantityUnitConversionsResolved' => $this->Database->quantity_unit_conversions_resolved()
|
'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -107,34 +107,34 @@ class RecipesController extends BaseController
|
||||||
{
|
{
|
||||||
if ($args['recipePosId'] == 'new')
|
if ($args['recipePosId'] == 'new')
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'recipeposform', [
|
return $this->renderPage($response, 'recipeposform', [
|
||||||
'mode' => 'create',
|
'mode' => 'create',
|
||||||
'recipe' => $this->Database->recipes($args['recipeId']),
|
'recipe' => $this->getDatabase()->recipes($args['recipeId']),
|
||||||
'recipePos' => new \stdClass(),
|
'recipePos' => new \stdClass(),
|
||||||
'products' => $this->Database->products()->orderBy('name'),
|
'products' => $this->getDatabase()->products()->orderBy('name'),
|
||||||
'quantityUnits' => $this->Database->quantity_units()->orderBy('name'),
|
'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name'),
|
||||||
'quantityUnitConversionsResolved' => $this->Database->quantity_unit_conversions_resolved()
|
'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'recipeposform', [
|
return $this->renderPage($response, 'recipeposform', [
|
||||||
'mode' => 'edit',
|
'mode' => 'edit',
|
||||||
'recipe' => $this->Database->recipes($args['recipeId']),
|
'recipe' => $this->getDatabase()->recipes($args['recipeId']),
|
||||||
'recipePos' => $this->Database->recipes_pos($args['recipePosId']),
|
'recipePos' => $this->getDatabase()->recipes_pos($args['recipePosId']),
|
||||||
'products' => $this->Database->products()->orderBy('name'),
|
'products' => $this->getDatabase()->products()->orderBy('name'),
|
||||||
'quantityUnits' => $this->Database->quantity_units()->orderBy('name'),
|
'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name'),
|
||||||
'quantityUnitConversionsResolved' => $this->Database->quantity_unit_conversions_resolved()
|
'quantityUnitConversionsResolved' => $this->getDatabase()->quantity_unit_conversions_resolved()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function MealPlan(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
public function MealPlan(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||||
{
|
{
|
||||||
$recipes = $this->Database->recipes()->where('type', RecipesService::RECIPE_TYPE_NORMAL)->fetchAll();
|
$recipes = $this->getDatabase()->recipes()->where('type', RecipesService::RECIPE_TYPE_NORMAL)->fetchAll();
|
||||||
|
|
||||||
$events = array();
|
$events = array();
|
||||||
foreach($this->Database->meal_plan() as $mealPlanEntry)
|
foreach($this->getDatabase()->meal_plan() as $mealPlanEntry)
|
||||||
{
|
{
|
||||||
$recipe = FindObjectInArrayByPropertyValue($recipes, 'id', $mealPlanEntry['recipe_id']);
|
$recipe = FindObjectInArrayByPropertyValue($recipes, 'id', $mealPlanEntry['recipe_id']);
|
||||||
$title = '';
|
$title = '';
|
||||||
|
|
@ -153,10 +153,10 @@ class RecipesController extends BaseController
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->AppContainer->view->render($response, 'mealplan', [
|
return $this->renderPage($response, 'mealplan', [
|
||||||
'fullcalendarEventSources' => $events,
|
'fullcalendarEventSources' => $events,
|
||||||
'recipes' => $recipes,
|
'recipes' => $recipes,
|
||||||
'internalRecipes' => $this->Database->recipes()->whereNot('type', RecipesService::RECIPE_TYPE_NORMAL)->fetchAll(),
|
'internalRecipes' => $this->getDatabase()->recipes()->whereNot('type', RecipesService::RECIPE_TYPE_NORMAL)->fetchAll(),
|
||||||
'recipesResolved' => $this->RecipesService->GetRecipesResolved()
|
'recipesResolved' => $this->RecipesService->GetRecipesResolved()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ class StockApiController extends BaseApiController
|
||||||
}
|
}
|
||||||
|
|
||||||
$bookingId = $this->StockService->AddProduct($args['productId'], $requestBody['amount'], $bestBeforeDate, $transactionType, date('Y-m-d'), $price, $locationId);
|
$bookingId = $this->StockService->AddProduct($args['productId'], $requestBody['amount'], $bestBeforeDate, $transactionType, date('Y-m-d'), $price, $locationId);
|
||||||
return $this->ApiResponse($this->Database->stock_log($bookingId));
|
return $this->ApiResponse($this->getDatabase()->stock_log($bookingId));
|
||||||
}
|
}
|
||||||
catch (\Exception $ex)
|
catch (\Exception $ex)
|
||||||
{
|
{
|
||||||
|
|
@ -160,7 +160,7 @@ class StockApiController extends BaseApiController
|
||||||
}
|
}
|
||||||
|
|
||||||
$bookingId = $this->StockService->ConsumeProduct($args['productId'], $requestBody['amount'], $spoiled, $transactionType, $specificStockEntryId, $recipeId);
|
$bookingId = $this->StockService->ConsumeProduct($args['productId'], $requestBody['amount'], $spoiled, $transactionType, $specificStockEntryId, $recipeId);
|
||||||
$result = $this->ApiResponse($this->Database->stock_log($bookingId));
|
$result = $this->ApiResponse($this->getDatabase()->stock_log($bookingId));
|
||||||
}
|
}
|
||||||
catch (\Exception $ex)
|
catch (\Exception $ex)
|
||||||
{
|
{
|
||||||
|
|
@ -219,7 +219,7 @@ class StockApiController extends BaseApiController
|
||||||
}
|
}
|
||||||
|
|
||||||
$bookingId = $this->StockService->InventoryProduct($args['productId'], $requestBody['new_amount'], $bestBeforeDate, $locationId, $price);
|
$bookingId = $this->StockService->InventoryProduct($args['productId'], $requestBody['new_amount'], $bestBeforeDate, $locationId, $price);
|
||||||
return $this->ApiResponse($this->Database->stock_log($bookingId));
|
return $this->ApiResponse($this->getDatabase()->stock_log($bookingId));
|
||||||
}
|
}
|
||||||
catch (\Exception $ex)
|
catch (\Exception $ex)
|
||||||
{
|
{
|
||||||
|
|
@ -263,7 +263,7 @@ class StockApiController extends BaseApiController
|
||||||
}
|
}
|
||||||
|
|
||||||
$bookingId = $this->StockService->OpenProduct($args['productId'], $requestBody['amount'], $specificStockEntryId);
|
$bookingId = $this->StockService->OpenProduct($args['productId'], $requestBody['amount'], $specificStockEntryId);
|
||||||
return $this->ApiResponse($this->Database->stock_log($bookingId));
|
return $this->ApiResponse($this->getDatabase()->stock_log($bookingId));
|
||||||
}
|
}
|
||||||
catch (\Exception $ex)
|
catch (\Exception $ex)
|
||||||
{
|
{
|
||||||
|
|
@ -467,7 +467,7 @@ class StockApiController extends BaseApiController
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$stockLogRow = $this->Database->stock_log($args['bookingId']);
|
$stockLogRow = $this->getDatabase()->stock_log($args['bookingId']);
|
||||||
|
|
||||||
if ($stockLogRow === null)
|
if ($stockLogRow === null)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -16,36 +16,34 @@ class StockController extends BaseController
|
||||||
#fclose($fp);
|
#fclose($fp);
|
||||||
parent::__construct($container);
|
parent::__construct($container);
|
||||||
$this->StockService = new StockService();
|
$this->StockService = new StockService();
|
||||||
$this->UserfieldsService = new UserfieldsService();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected $StockService;
|
protected $StockService;
|
||||||
protected $UserfieldsService;
|
|
||||||
|
|
||||||
public function Overview(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
public function Overview(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||||
{
|
{
|
||||||
$usersService = new UsersService();
|
$usersService = new UsersService();
|
||||||
$nextXDays = $usersService->GetUserSettings(GROCY_USER_ID)['stock_expring_soon_days'];
|
$nextXDays = $usersService->GetUserSettings(GROCY_USER_ID)['stock_expring_soon_days'];
|
||||||
|
|
||||||
return $this->AppContainer->view->render($response, 'stockoverview', [
|
return $this->renderPage($response, 'stockoverview', [
|
||||||
'products' => $this->Database->products()->orderBy('name'),
|
'products' => $this->getDatabase()->products()->orderBy('name'),
|
||||||
'quantityunits' => $this->Database->quantity_units()->orderBy('name'),
|
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name'),
|
||||||
'locations' => $this->Database->locations()->orderBy('name'),
|
'locations' => $this->getDatabase()->locations()->orderBy('name'),
|
||||||
'currentStock' => $this->StockService->GetCurrentStock(true),
|
'currentStock' => $this->StockService->GetCurrentStock(true),
|
||||||
'currentStockLocations' => $this->StockService->GetCurrentStockLocations(),
|
'currentStockLocations' => $this->StockService->GetCurrentStockLocations(),
|
||||||
'missingProducts' => $this->StockService->GetMissingProducts(),
|
'missingProducts' => $this->StockService->GetMissingProducts(),
|
||||||
'nextXDays' => $nextXDays,
|
'nextXDays' => $nextXDays,
|
||||||
'productGroups' => $this->Database->product_groups()->orderBy('name'),
|
'productGroups' => $this->getDatabase()->product_groups()->orderBy('name'),
|
||||||
'userfields' => $this->UserfieldsService->GetFields('products'),
|
'userfields' => $this->getUserfieldsService()->GetFields('products'),
|
||||||
'userfieldValues' => $this->UserfieldsService->GetAllValues('products')
|
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('products')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function Purchase(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
public function Purchase(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'purchase', [
|
return $this->renderPage($response, 'purchase', [
|
||||||
'products' => $this->Database->products()->orderBy('name'),
|
'products' => $this->getDatabase()->products()->orderBy('name'),
|
||||||
'locations' => $this->Database->locations()->orderBy('name')
|
'locations' => $this->getDatabase()->locations()->orderBy('name')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -54,9 +52,9 @@ class StockController extends BaseController
|
||||||
#$fp = fopen('/www/data/sql.log', 'a');
|
#$fp = fopen('/www/data/sql.log', 'a');
|
||||||
#fwrite($fp, "???executing consume stock");
|
#fwrite($fp, "???executing consume stock");
|
||||||
#$time_start = microtime(true);
|
#$time_start = microtime(true);
|
||||||
$result = $this->AppContainer->view->render($response, 'consume', [
|
$result = $this->renderPage($response, 'consume', [
|
||||||
'products' => $this->Database->products()->orderBy('name'),
|
'products' => $this->getDatabase()->products()->orderBy('name'),
|
||||||
'recipes' => $this->Database->recipes()->orderBy('name')
|
'recipes' => $this->getDatabase()->recipes()->orderBy('name')
|
||||||
]);
|
]);
|
||||||
#fwrite($fp, "???Total execution time in seconds: " . round((microtime(true) - $time_start),6) . "\n");
|
#fwrite($fp, "???Total execution time in seconds: " . round((microtime(true) - $time_start),6) . "\n");
|
||||||
#fclose($fp);
|
#fclose($fp);
|
||||||
|
|
@ -65,9 +63,9 @@ class StockController extends BaseController
|
||||||
|
|
||||||
public function Inventory(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
public function Inventory(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'inventory', [
|
return $this->renderPage($response, 'inventory', [
|
||||||
'products' => $this->Database->products()->orderBy('name'),
|
'products' => $this->getDatabase()->products()->orderBy('name'),
|
||||||
'locations' => $this->Database->locations()->orderBy('name')
|
'locations' => $this->getDatabase()->locations()->orderBy('name')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -79,65 +77,65 @@ class StockController extends BaseController
|
||||||
$listId = $request->getQueryParams()['list'];
|
$listId = $request->getQueryParams()['list'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->AppContainer->view->render($response, 'shoppinglist', [
|
return $this->renderPage($response, 'shoppinglist', [
|
||||||
'listItems' => $this->Database->shopping_list()->where('shopping_list_id = :1', $listId),
|
'listItems' => $this->getDatabase()->shopping_list()->where('shopping_list_id = :1', $listId),
|
||||||
'products' => $this->Database->products()->orderBy('name'),
|
'products' => $this->getDatabase()->products()->orderBy('name'),
|
||||||
'quantityunits' => $this->Database->quantity_units()->orderBy('name'),
|
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name'),
|
||||||
'missingProducts' => $this->StockService->GetMissingProducts(),
|
'missingProducts' => $this->StockService->GetMissingProducts(),
|
||||||
'productGroups' => $this->Database->product_groups()->orderBy('name'),
|
'productGroups' => $this->getDatabase()->product_groups()->orderBy('name'),
|
||||||
'shoppingLists' => $this->Database->shopping_lists()->orderBy('name'),
|
'shoppingLists' => $this->getDatabase()->shopping_lists()->orderBy('name'),
|
||||||
'selectedShoppingListId' => $listId,
|
'selectedShoppingListId' => $listId,
|
||||||
'userfields' => $this->UserfieldsService->GetFields('products'),
|
'userfields' => $this->getUserfieldsService()->GetFields('products'),
|
||||||
'userfieldValues' => $this->UserfieldsService->GetAllValues('products')
|
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('products')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function ProductsList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
public function ProductsList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'products', [
|
return $this->renderPage($response, 'products', [
|
||||||
'products' => $this->Database->products()->orderBy('name'),
|
'products' => $this->getDatabase()->products()->orderBy('name'),
|
||||||
'locations' => $this->Database->locations()->orderBy('name'),
|
'locations' => $this->getDatabase()->locations()->orderBy('name'),
|
||||||
'quantityunits' => $this->Database->quantity_units()->orderBy('name'),
|
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name'),
|
||||||
'productGroups' => $this->Database->product_groups()->orderBy('name'),
|
'productGroups' => $this->getDatabase()->product_groups()->orderBy('name'),
|
||||||
'userfields' => $this->UserfieldsService->GetFields('products'),
|
'userfields' => $this->getUserfieldsService()->GetFields('products'),
|
||||||
'userfieldValues' => $this->UserfieldsService->GetAllValues('products')
|
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('products')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function StockSettings(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
public function StockSettings(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'stocksettings', [
|
return $this->renderPage($response, 'stocksettings', [
|
||||||
'locations' => $this->Database->locations()->orderBy('name'),
|
'locations' => $this->getDatabase()->locations()->orderBy('name'),
|
||||||
'quantityunits' => $this->Database->quantity_units()->orderBy('name'),
|
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name'),
|
||||||
'productGroups' => $this->Database->product_groups()->orderBy('name')
|
'productGroups' => $this->getDatabase()->product_groups()->orderBy('name')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function LocationsList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
public function LocationsList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'locations', [
|
return $this->renderPage($response, 'locations', [
|
||||||
'locations' => $this->Database->locations()->orderBy('name'),
|
'locations' => $this->getDatabase()->locations()->orderBy('name'),
|
||||||
'userfields' => $this->UserfieldsService->GetFields('locations'),
|
'userfields' => $this->getUserfieldsService()->GetFields('locations'),
|
||||||
'userfieldValues' => $this->UserfieldsService->GetAllValues('locations')
|
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('locations')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function ProductGroupsList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
public function ProductGroupsList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'productgroups', [
|
return $this->renderPage($response, 'productgroups', [
|
||||||
'productGroups' => $this->Database->product_groups()->orderBy('name'),
|
'productGroups' => $this->getDatabase()->product_groups()->orderBy('name'),
|
||||||
'products' => $this->Database->products()->orderBy('name'),
|
'products' => $this->getDatabase()->products()->orderBy('name'),
|
||||||
'userfields' => $this->UserfieldsService->GetFields('product_groups'),
|
'userfields' => $this->getUserfieldsService()->GetFields('product_groups'),
|
||||||
'userfieldValues' => $this->UserfieldsService->GetAllValues('product_groups')
|
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('product_groups')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function QuantityUnitsList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
public function QuantityUnitsList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'quantityunits', [
|
return $this->renderPage($response, 'quantityunits', [
|
||||||
'quantityunits' => $this->Database->quantity_units()->orderBy('name'),
|
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name'),
|
||||||
'userfields' => $this->UserfieldsService->GetFields('quantity_units'),
|
'userfields' => $this->getUserfieldsService()->GetFields('quantity_units'),
|
||||||
'userfieldValues' => $this->UserfieldsService->GetAllValues('quantity_units')
|
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('quantity_units')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -145,30 +143,30 @@ class StockController extends BaseController
|
||||||
{
|
{
|
||||||
if ($args['productId'] == 'new')
|
if ($args['productId'] == 'new')
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'productform', [
|
return $this->renderPage($response, 'productform', [
|
||||||
'locations' => $this->Database->locations()->orderBy('name'),
|
'locations' => $this->getDatabase()->locations()->orderBy('name'),
|
||||||
'quantityunits' => $this->Database->quantity_units()->orderBy('name'),
|
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name'),
|
||||||
'productgroups' => $this->Database->product_groups()->orderBy('name'),
|
'productgroups' => $this->getDatabase()->product_groups()->orderBy('name'),
|
||||||
'userfields' => $this->UserfieldsService->GetFields('products'),
|
'userfields' => $this->getUserfieldsService()->GetFields('products'),
|
||||||
'products' => $this->Database->products()->where('parent_product_id IS NULL')->orderBy('name'),
|
'products' => $this->getDatabase()->products()->where('parent_product_id IS NULL')->orderBy('name'),
|
||||||
'isSubProductOfOthers' => false,
|
'isSubProductOfOthers' => false,
|
||||||
'mode' => 'create'
|
'mode' => 'create'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$product = $this->Database->products($args['productId']);
|
$product = $this->getDatabase()->products($args['productId']);
|
||||||
|
|
||||||
return $this->AppContainer->view->render($response, 'productform', [
|
return $this->renderPage($response, 'productform', [
|
||||||
'product' => $product,
|
'product' => $product,
|
||||||
'locations' => $this->Database->locations()->orderBy('name'),
|
'locations' => $this->getDatabase()->locations()->orderBy('name'),
|
||||||
'quantityunits' => $this->Database->quantity_units()->orderBy('name'),
|
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name'),
|
||||||
'productgroups' => $this->Database->product_groups()->orderBy('name'),
|
'productgroups' => $this->getDatabase()->product_groups()->orderBy('name'),
|
||||||
'userfields' => $this->UserfieldsService->GetFields('products'),
|
'userfields' => $this->getUserfieldsService()->GetFields('products'),
|
||||||
'products' => $this->Database->products()->where('id != :1 AND parent_product_id IS NULL', $product->id)->orderBy('name'),
|
'products' => $this->getDatabase()->products()->where('id != :1 AND parent_product_id IS NULL', $product->id)->orderBy('name'),
|
||||||
'isSubProductOfOthers' => $this->Database->products()->where('parent_product_id = :1', $product->id)->count() !== 0,
|
'isSubProductOfOthers' => $this->getDatabase()->products()->where('parent_product_id = :1', $product->id)->count() !== 0,
|
||||||
'mode' => 'edit',
|
'mode' => 'edit',
|
||||||
'quConversions' => $this->Database->quantity_unit_conversions()
|
'quConversions' => $this->getDatabase()->quantity_unit_conversions()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -177,17 +175,17 @@ class StockController extends BaseController
|
||||||
{
|
{
|
||||||
if ($args['locationId'] == 'new')
|
if ($args['locationId'] == 'new')
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'locationform', [
|
return $this->renderPage($response, 'locationform', [
|
||||||
'mode' => 'create',
|
'mode' => 'create',
|
||||||
'userfields' => $this->UserfieldsService->GetFields('locations')
|
'userfields' => $this->getUserfieldsService()->GetFields('locations')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'locationform', [
|
return $this->renderPage($response, 'locationform', [
|
||||||
'location' => $this->Database->locations($args['locationId']),
|
'location' => $this->getDatabase()->locations($args['locationId']),
|
||||||
'mode' => 'edit',
|
'mode' => 'edit',
|
||||||
'userfields' => $this->UserfieldsService->GetFields('locations')
|
'userfields' => $this->getUserfieldsService()->GetFields('locations')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -196,17 +194,17 @@ class StockController extends BaseController
|
||||||
{
|
{
|
||||||
if ($args['productGroupId'] == 'new')
|
if ($args['productGroupId'] == 'new')
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'productgroupform', [
|
return $this->renderPage($response, 'productgroupform', [
|
||||||
'mode' => 'create',
|
'mode' => 'create',
|
||||||
'userfields' => $this->UserfieldsService->GetFields('product_groups')
|
'userfields' => $this->getUserfieldsService()->GetFields('product_groups')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'productgroupform', [
|
return $this->renderPage($response, 'productgroupform', [
|
||||||
'group' => $this->Database->product_groups($args['productGroupId']),
|
'group' => $this->getDatabase()->product_groups($args['productGroupId']),
|
||||||
'mode' => 'edit',
|
'mode' => 'edit',
|
||||||
'userfields' => $this->UserfieldsService->GetFields('product_groups')
|
'userfields' => $this->getUserfieldsService()->GetFields('product_groups')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -215,25 +213,25 @@ class StockController extends BaseController
|
||||||
{
|
{
|
||||||
if ($args['quantityunitId'] == 'new')
|
if ($args['quantityunitId'] == 'new')
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'quantityunitform', [
|
return $this->renderPage($response, 'quantityunitform', [
|
||||||
'mode' => 'create',
|
'mode' => 'create',
|
||||||
'userfields' => $this->UserfieldsService->GetFields('quantity_units'),
|
'userfields' => $this->getUserfieldsService()->GetFields('quantity_units'),
|
||||||
'pluralCount' => $this->LocalizationService->GetPluralCount(),
|
'pluralCount' => $this->getLocalizationService()->GetPluralCount(),
|
||||||
'pluralRule' => $this->LocalizationService->GetPluralDefinition()
|
'pluralRule' => $this->getLocalizationService()->GetPluralDefinition()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$quantityUnit = $this->Database->quantity_units($args['quantityunitId']);
|
$quantityUnit = $this->getDatabase()->quantity_units($args['quantityunitId']);
|
||||||
|
|
||||||
return $this->AppContainer->view->render($response, 'quantityunitform', [
|
return $this->renderPage($response, 'quantityunitform', [
|
||||||
'quantityUnit' => $quantityUnit,
|
'quantityUnit' => $quantityUnit,
|
||||||
'mode' => 'edit',
|
'mode' => 'edit',
|
||||||
'userfields' => $this->UserfieldsService->GetFields('quantity_units'),
|
'userfields' => $this->getUserfieldsService()->GetFields('quantity_units'),
|
||||||
'pluralCount' => $this->LocalizationService->GetPluralCount(),
|
'pluralCount' => $this->getLocalizationService()->GetPluralCount(),
|
||||||
'pluralRule' => $this->LocalizationService->GetPluralDefinition(),
|
'pluralRule' => $this->getLocalizationService()->GetPluralDefinition(),
|
||||||
'defaultQuConversions' => $this->Database->quantity_unit_conversions()->where('from_qu_id = :1 AND product_id IS NULL', $quantityUnit->id),
|
'defaultQuConversions' => $this->getDatabase()->quantity_unit_conversions()->where('from_qu_id = :1 AND product_id IS NULL', $quantityUnit->id),
|
||||||
'quantityUnits' => $this->Database->quantity_units()
|
'quantityUnits' => $this->getDatabase()->quantity_units()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -242,18 +240,18 @@ class StockController extends BaseController
|
||||||
{
|
{
|
||||||
if ($args['itemId'] == 'new')
|
if ($args['itemId'] == 'new')
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'shoppinglistitemform', [
|
return $this->renderPage($response, 'shoppinglistitemform', [
|
||||||
'products' => $this->Database->products()->orderBy('name'),
|
'products' => $this->getDatabase()->products()->orderBy('name'),
|
||||||
'shoppingLists' => $this->Database->shopping_lists()->orderBy('name'),
|
'shoppingLists' => $this->getDatabase()->shopping_lists()->orderBy('name'),
|
||||||
'mode' => 'create'
|
'mode' => 'create'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'shoppinglistitemform', [
|
return $this->renderPage($response, 'shoppinglistitemform', [
|
||||||
'listItem' => $this->Database->shopping_list($args['itemId']),
|
'listItem' => $this->getDatabase()->shopping_list($args['itemId']),
|
||||||
'products' => $this->Database->products()->orderBy('name'),
|
'products' => $this->getDatabase()->products()->orderBy('name'),
|
||||||
'shoppingLists' => $this->Database->shopping_lists()->orderBy('name'),
|
'shoppingLists' => $this->getDatabase()->shopping_lists()->orderBy('name'),
|
||||||
'mode' => 'edit'
|
'mode' => 'edit'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
@ -263,14 +261,14 @@ class StockController extends BaseController
|
||||||
{
|
{
|
||||||
if ($args['listId'] == 'new')
|
if ($args['listId'] == 'new')
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'shoppinglistform', [
|
return $this->renderPage($response, 'shoppinglistform', [
|
||||||
'mode' => 'create'
|
'mode' => 'create'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'shoppinglistform', [
|
return $this->renderPage($response, 'shoppinglistform', [
|
||||||
'shoppingList' => $this->Database->shopping_lists($args['listId']),
|
'shoppingList' => $this->getDatabase()->shopping_lists($args['listId']),
|
||||||
'mode' => 'edit'
|
'mode' => 'edit'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
@ -278,19 +276,19 @@ class StockController extends BaseController
|
||||||
|
|
||||||
public function Journal(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
public function Journal(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'stockjournal', [
|
return $this->renderPage($response, 'stockjournal', [
|
||||||
'stockLog' => $this->Database->stock_log()->orderBy('row_created_timestamp', 'DESC'),
|
'stockLog' => $this->getDatabase()->stock_log()->orderBy('row_created_timestamp', 'DESC'),
|
||||||
'products' => $this->Database->products()->orderBy('name'),
|
'products' => $this->getDatabase()->products()->orderBy('name'),
|
||||||
'quantityunits' => $this->Database->quantity_units()->orderBy('name')
|
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function LocationContentSheet(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
public function LocationContentSheet(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'locationcontentsheet', [
|
return $this->renderPage($response, 'locationcontentsheet', [
|
||||||
'products' => $this->Database->products()->orderBy('name'),
|
'products' => $this->getDatabase()->products()->orderBy('name'),
|
||||||
'quantityunits' => $this->Database->quantity_units()->orderBy('name'),
|
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name'),
|
||||||
'locations' => $this->Database->locations()->orderBy('name'),
|
'locations' => $this->getDatabase()->locations()->orderBy('name'),
|
||||||
'currentStockLocationContent' => $this->StockService->GetCurrentStockLocationContent()
|
'currentStockLocationContent' => $this->StockService->GetCurrentStockLocationContent()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
@ -300,32 +298,32 @@ class StockController extends BaseController
|
||||||
$product = null;
|
$product = null;
|
||||||
if (isset($request->getQueryParams()['product']))
|
if (isset($request->getQueryParams()['product']))
|
||||||
{
|
{
|
||||||
$product = $this->Database->products($request->getQueryParams()['product']);
|
$product = $this->getDatabase()->products($request->getQueryParams()['product']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$defaultQuUnit = null;
|
$defaultQuUnit = null;
|
||||||
if (isset($request->getQueryParams()['qu-unit']))
|
if (isset($request->getQueryParams()['qu-unit']))
|
||||||
{
|
{
|
||||||
$defaultQuUnit = $this->Database->quantity_units($request->getQueryParams()['qu-unit']);
|
$defaultQuUnit = $this->getDatabase()->quantity_units($request->getQueryParams()['qu-unit']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($args['quConversionId'] == 'new')
|
if ($args['quConversionId'] == 'new')
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'quantityunitconversionform', [
|
return $this->renderPage($response, 'quantityunitconversionform', [
|
||||||
'mode' => 'create',
|
'mode' => 'create',
|
||||||
'userfields' => $this->UserfieldsService->GetFields('quantity_unit_conversions'),
|
'userfields' => $this->getUserfieldsService()->GetFields('quantity_unit_conversions'),
|
||||||
'quantityunits' => $this->Database->quantity_units()->orderBy('name'),
|
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name'),
|
||||||
'product' => $product,
|
'product' => $product,
|
||||||
'defaultQuUnit' => $defaultQuUnit
|
'defaultQuUnit' => $defaultQuUnit
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'quantityunitconversionform', [
|
return $this->renderPage($response, 'quantityunitconversionform', [
|
||||||
'quConversion' => $this->Database->quantity_unit_conversions($args['quConversionId']),
|
'quConversion' => $this->getDatabase()->quantity_unit_conversions($args['quConversionId']),
|
||||||
'mode' => 'edit',
|
'mode' => 'edit',
|
||||||
'userfields' => $this->UserfieldsService->GetFields('quantity_unit_conversions'),
|
'userfields' => $this->getUserfieldsService()->GetFields('quantity_unit_conversions'),
|
||||||
'quantityunits' => $this->Database->quantity_units()->orderBy('name'),
|
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name'),
|
||||||
'product' => $product,
|
'product' => $product,
|
||||||
'defaultQuUnit' => $defaultQuUnit
|
'defaultQuUnit' => $defaultQuUnit
|
||||||
]);
|
]);
|
||||||
|
|
@ -334,8 +332,8 @@ class StockController extends BaseController
|
||||||
|
|
||||||
public function QuantityUnitPluralFormTesting(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
public function QuantityUnitPluralFormTesting(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'quantityunitpluraltesting', [
|
return $this->renderPage($response, 'quantityunitpluraltesting', [
|
||||||
'quantityUnits' => $this->Database->quantity_units()->orderBy('name')
|
'quantityUnits' => $this->getDatabase()->quantity_units()->orderBy('name')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,20 +2,19 @@
|
||||||
|
|
||||||
namespace Grocy\Controllers;
|
namespace Grocy\Controllers;
|
||||||
|
|
||||||
use \Grocy\Services\DatabaseService;
|
#use \Grocy\Services\DatabaseService;
|
||||||
use \Grocy\Services\ApplicationService;
|
#use \Grocy\Services\ApplicationService;
|
||||||
|
|
||||||
class SystemApiController extends BaseApiController
|
class SystemApiController extends BaseApiController
|
||||||
{
|
{
|
||||||
public function __construct(\Slim\Container $container)
|
public function __construct(\Slim\Container $container)
|
||||||
{
|
{
|
||||||
parent::__construct($container);
|
parent::__construct($container);
|
||||||
$this->DatabaseService = DatabaseService::getInstance();
|
#$this->ApplicationService = ApplicationService::getInstance();
|
||||||
$this->ApplicationService = ApplicationService::getInstance();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected $DatabaseService;
|
#protected $DatabaseService;
|
||||||
protected $ApplicationService;
|
#protected $ApplicationService;
|
||||||
|
|
||||||
public function GetDbChangedTime(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
public function GetDbChangedTime(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||||
{
|
{
|
||||||
|
|
@ -23,14 +22,14 @@ class SystemApiController extends BaseApiController
|
||||||
#fwrite($fp, "---- getting db changed time ----\n");
|
#fwrite($fp, "---- getting db changed time ----\n");
|
||||||
#$time_start = microtime(true);
|
#$time_start = microtime(true);
|
||||||
$response = $this->ApiResponse(array(
|
$response = $this->ApiResponse(array(
|
||||||
'changed_time' => $this->DatabaseService->GetDbChangedTime()
|
'changed_time' => $this->getDatabaseService()->GetDbChangedTime()
|
||||||
));
|
));
|
||||||
#fwrite($fp, "----Total execution time in seconds: " . round((microtime(true) - $time_start),4) . "\n");
|
#fwrite($fp, "----Total execution time in seconds: " . round((microtime(true) - $time_start),4) . "\n");
|
||||||
#fwrite($fp, "---- time obtained ----\n");
|
#fwrite($fp, "---- time obtained ----\n");
|
||||||
#fclose($fp);
|
#fclose($fp);
|
||||||
return $response;
|
return $response;
|
||||||
#return $this->ApiResponse(array(
|
#return $this->ApiResponse(array(
|
||||||
# 'changed_time' => $this->DatabaseService->GetDbChangedTime()
|
# 'changed_time' => $this->getDatabaseService()->GetDbChangedTime()
|
||||||
#));
|
#));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -42,7 +41,7 @@ class SystemApiController extends BaseApiController
|
||||||
{
|
{
|
||||||
$requestBody = $request->getParsedBody();
|
$requestBody = $request->getParsedBody();
|
||||||
|
|
||||||
$this->LocalizationService->CheckAndAddMissingTranslationToPot($requestBody['text']);
|
$this->getLocalizationService()->CheckAndAddMissingTranslationToPot($requestBody['text']);
|
||||||
return $this->EmptyApiResponse($response);
|
return $this->EmptyApiResponse($response);
|
||||||
}
|
}
|
||||||
catch (\Exception $ex)
|
catch (\Exception $ex)
|
||||||
|
|
@ -54,6 +53,6 @@ class SystemApiController extends BaseApiController
|
||||||
|
|
||||||
public function GetSystemInfo(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
public function GetSystemInfo(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||||
{
|
{
|
||||||
return $this->ApiResponse($this->ApplicationService->GetSystemInfo());
|
return $this->ApiResponse($this->getApplicationService()->GetSystemInfo());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,18 +2,18 @@
|
||||||
|
|
||||||
namespace Grocy\Controllers;
|
namespace Grocy\Controllers;
|
||||||
|
|
||||||
use \Grocy\Services\ApplicationService;
|
#use \Grocy\Services\ApplicationService;
|
||||||
use \Grocy\Services\DatabaseMigrationService;
|
use \Grocy\Services\DatabaseMigrationService;
|
||||||
use \Grocy\Services\DemoDataGeneratorService;
|
use \Grocy\Services\DemoDataGeneratorService;
|
||||||
|
|
||||||
class SystemController extends BaseController
|
class SystemController extends BaseController
|
||||||
{
|
{
|
||||||
protected $ApplicationService;
|
#protected $ApplicationService;
|
||||||
|
|
||||||
public function __construct(\Slim\Container $container)
|
public function __construct(\Slim\Container $container)
|
||||||
{
|
{
|
||||||
parent::__construct($container);
|
parent::__construct($container);
|
||||||
$this->ApplicationService = ApplicationService::getInstance();
|
#$this->ApplicationService = ApplicationService::getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function Root(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
public function Root(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||||
|
|
@ -96,14 +96,14 @@ class SystemController extends BaseController
|
||||||
|
|
||||||
public function About(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
public function About(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'about', [
|
return $this->renderPage($response, 'about', [
|
||||||
'system_info' => $this->ApplicationService->GetSystemInfo(),
|
'system_info' => $this->getApplicationService()->GetSystemInfo(),
|
||||||
'changelog' => $this->ApplicationService->GetChangelog()
|
'changelog' => $this->getApplicationService()->GetChangelog()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function BarcodeScannerTesting(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
public function BarcodeScannerTesting(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'barcodescannertesting');
|
return $this->renderPage($response, 'barcodescannertesting');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ class TasksController extends BaseController
|
||||||
{
|
{
|
||||||
if (isset($request->getQueryParams()['include_done']))
|
if (isset($request->getQueryParams()['include_done']))
|
||||||
{
|
{
|
||||||
$tasks = $this->Database->tasks()->orderBy('name');
|
$tasks = $this->getDatabase()->tasks()->orderBy('name');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -32,11 +32,11 @@ class TasksController extends BaseController
|
||||||
$usersService = new UsersService();
|
$usersService = new UsersService();
|
||||||
$nextXDays = $usersService->GetUserSettings(GROCY_USER_ID)['tasks_due_soon_days'];
|
$nextXDays = $usersService->GetUserSettings(GROCY_USER_ID)['tasks_due_soon_days'];
|
||||||
|
|
||||||
return $this->AppContainer->view->render($response, 'tasks', [
|
return $this->renderPage($response, 'tasks', [
|
||||||
'tasks' => $tasks,
|
'tasks' => $tasks,
|
||||||
'nextXDays' => $nextXDays,
|
'nextXDays' => $nextXDays,
|
||||||
'taskCategories' => $this->Database->task_categories()->orderBy('name'),
|
'taskCategories' => $this->getDatabase()->task_categories()->orderBy('name'),
|
||||||
'users' => $this->Database->users(),
|
'users' => $this->getDatabase()->users(),
|
||||||
'userfields' => $this->UserfieldsService->GetFields('tasks'),
|
'userfields' => $this->UserfieldsService->GetFields('tasks'),
|
||||||
'userfieldValues' => $this->UserfieldsService->GetAllValues('tasks')
|
'userfieldValues' => $this->UserfieldsService->GetAllValues('tasks')
|
||||||
]);
|
]);
|
||||||
|
|
@ -46,20 +46,20 @@ class TasksController extends BaseController
|
||||||
{
|
{
|
||||||
if ($args['taskId'] == 'new')
|
if ($args['taskId'] == 'new')
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'taskform', [
|
return $this->renderPage($response, 'taskform', [
|
||||||
'mode' => 'create',
|
'mode' => 'create',
|
||||||
'taskCategories' => $this->Database->task_categories()->orderBy('name'),
|
'taskCategories' => $this->getDatabase()->task_categories()->orderBy('name'),
|
||||||
'users' => $this->Database->users()->orderBy('username'),
|
'users' => $this->getDatabase()->users()->orderBy('username'),
|
||||||
'userfields' => $this->UserfieldsService->GetFields('tasks')
|
'userfields' => $this->UserfieldsService->GetFields('tasks')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'taskform', [
|
return $this->renderPage($response, 'taskform', [
|
||||||
'task' => $this->Database->tasks($args['taskId']),
|
'task' => $this->getDatabase()->tasks($args['taskId']),
|
||||||
'mode' => 'edit',
|
'mode' => 'edit',
|
||||||
'taskCategories' => $this->Database->task_categories()->orderBy('name'),
|
'taskCategories' => $this->getDatabase()->task_categories()->orderBy('name'),
|
||||||
'users' => $this->Database->users()->orderBy('username'),
|
'users' => $this->getDatabase()->users()->orderBy('username'),
|
||||||
'userfields' => $this->UserfieldsService->GetFields('tasks')
|
'userfields' => $this->UserfieldsService->GetFields('tasks')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
@ -67,8 +67,8 @@ class TasksController extends BaseController
|
||||||
|
|
||||||
public function TaskCategoriesList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
public function TaskCategoriesList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'taskcategories', [
|
return $this->renderPage($response, 'taskcategories', [
|
||||||
'taskCategories' => $this->Database->task_categories()->orderBy('name'),
|
'taskCategories' => $this->getDatabase()->task_categories()->orderBy('name'),
|
||||||
'userfields' => $this->UserfieldsService->GetFields('task_categories'),
|
'userfields' => $this->UserfieldsService->GetFields('task_categories'),
|
||||||
'userfieldValues' => $this->UserfieldsService->GetAllValues('task_categories')
|
'userfieldValues' => $this->UserfieldsService->GetAllValues('task_categories')
|
||||||
]);
|
]);
|
||||||
|
|
@ -78,15 +78,15 @@ class TasksController extends BaseController
|
||||||
{
|
{
|
||||||
if ($args['categoryId'] == 'new')
|
if ($args['categoryId'] == 'new')
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'taskcategoryform', [
|
return $this->renderPage($response, 'taskcategoryform', [
|
||||||
'mode' => 'create',
|
'mode' => 'create',
|
||||||
'userfields' => $this->UserfieldsService->GetFields('task_categories')
|
'userfields' => $this->UserfieldsService->GetFields('task_categories')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'taskcategoryform', [
|
return $this->renderPage($response, 'taskcategoryform', [
|
||||||
'category' => $this->Database->task_categories($args['categoryId']),
|
'category' => $this->getDatabase()->task_categories($args['categoryId']),
|
||||||
'mode' => 'edit',
|
'mode' => 'edit',
|
||||||
'userfields' => $this->UserfieldsService->GetFields('task_categories')
|
'userfields' => $this->UserfieldsService->GetFields('task_categories')
|
||||||
]);
|
]);
|
||||||
|
|
@ -95,6 +95,6 @@ class TasksController extends BaseController
|
||||||
|
|
||||||
public function TasksSettings(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
public function TasksSettings(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'taskssettings');
|
return $this->renderPage($response, 'taskssettings');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@ class UsersController extends BaseController
|
||||||
{
|
{
|
||||||
public function UsersList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
public function UsersList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'users', [
|
return $this->renderPage($response, 'users', [
|
||||||
'users' => $this->Database->users()->orderBy('username')
|
'users' => $this->getDatabase()->users()->orderBy('username')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -15,14 +15,14 @@ class UsersController extends BaseController
|
||||||
{
|
{
|
||||||
if ($args['userId'] == 'new')
|
if ($args['userId'] == 'new')
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'userform', [
|
return $this->renderPage($response, 'userform', [
|
||||||
'mode' => 'create'
|
'mode' => 'create'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'userform', [
|
return $this->renderPage($response, 'userform', [
|
||||||
'user' => $this->Database->users($args['userId']),
|
'user' => $this->getDatabase()->users($args['userId']),
|
||||||
'mode' => 'edit'
|
'mode' => 'edit'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user