mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 17:45:39 +00:00
69 lines
2.1 KiB
PHP
69 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace Grocy\Controllers;
|
|
|
|
use \Grocy\Services\ChoresService;
|
|
|
|
class ChoresController extends BaseController
|
|
{
|
|
public function __construct(\Slim\Container $container)
|
|
{
|
|
parent::__construct($container);
|
|
$this->ChoresService = new ChoresService();
|
|
}
|
|
|
|
protected $ChoresService;
|
|
|
|
public function Overview(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
|
{
|
|
return $this->AppContainer->view->render($response, 'choresoverview', [
|
|
'chores' => $this->Database->chores()->orderBy('name'),
|
|
'currentChores' => $this->ChoresService->GetCurrent(),
|
|
'nextXDays' => 5
|
|
]);
|
|
}
|
|
|
|
public function TrackChoreExecution(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
|
{
|
|
return $this->AppContainer->view->render($response, 'choretracking', [
|
|
'chores' => $this->Database->chores()->orderBy('name'),
|
|
'users' => $this->Database->users()->orderBy('username')
|
|
]);
|
|
}
|
|
|
|
public function ChoresList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
|
{
|
|
return $this->AppContainer->view->render($response, 'chores', [
|
|
'chores' => $this->Database->chores()->orderBy('name')
|
|
]);
|
|
}
|
|
|
|
public function Journal(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
|
{
|
|
return $this->AppContainer->view->render($response, 'choresjournal', [
|
|
'choresLog' => $this->Database->chores_log()->orderBy('tracked_time', 'DESC'),
|
|
'chores' => $this->Database->chores()->orderBy('name'),
|
|
'users' => $this->Database->users()->orderBy('username')
|
|
]);
|
|
}
|
|
|
|
public function ChoreEditForm(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
|
{
|
|
if ($args['choreId'] == 'new')
|
|
{
|
|
return $this->AppContainer->view->render($response, 'choreform', [
|
|
'periodTypes' => GetClassConstants('\Grocy\Services\ChoresService'),
|
|
'mode' => 'create'
|
|
]);
|
|
}
|
|
else
|
|
{
|
|
return $this->AppContainer->view->render($response, 'choreform', [
|
|
'chore' => $this->Database->chores($args['choreId']),
|
|
'periodTypes' => GetClassConstants('\Grocy\Services\ChoresService'),
|
|
'mode' => 'edit'
|
|
]);
|
|
}
|
|
}
|
|
}
|