mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 04:12:59 +00:00
Implemented that chores can be assigned to users (closes #253)
This commit is contained in:
@@ -70,4 +70,37 @@ class ChoresApiController extends BaseApiController
|
||||
return $this->GenericErrorResponse($response, $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function CalculateNextExecutionAssignments(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||
{
|
||||
try
|
||||
{
|
||||
$requestBody = $request->getParsedBody();
|
||||
|
||||
$choreId = null;
|
||||
if (array_key_exists('chore_id', $requestBody) && !empty($requestBody['chore_id']) && is_numeric($requestBody['chore_id']))
|
||||
{
|
||||
$choreId = intval($requestBody['chore_id']);
|
||||
}
|
||||
|
||||
if ($choreId === null)
|
||||
{
|
||||
$chores = $this->Database->chores();
|
||||
foreach ($chores as $chore)
|
||||
{
|
||||
$this->ChoresService->CalculateNextExecutionAssignment($chore->id);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->ChoresService->CalculateNextExecutionAssignment($choreId);
|
||||
}
|
||||
|
||||
return $this->EmptyApiResponse($response);
|
||||
}
|
||||
catch (\Exception $ex)
|
||||
{
|
||||
return $this->GenericErrorResponse($response, $ex->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -28,7 +28,8 @@ class ChoresController extends BaseController
|
||||
'currentChores' => $this->ChoresService->GetCurrent(),
|
||||
'nextXDays' => $nextXDays,
|
||||
'userfields' => $this->UserfieldsService->GetFields('chores'),
|
||||
'userfieldValues' => $this->UserfieldsService->GetAllValues('chores')
|
||||
'userfieldValues' => $this->UserfieldsService->GetAllValues('chores'),
|
||||
'users' => $usersService->GetUsersAsDto()
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -60,21 +61,28 @@ class ChoresController extends BaseController
|
||||
|
||||
public function ChoreEditForm(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||
{
|
||||
$usersService = new UsersService();
|
||||
$users = $usersService->GetUsersAsDto();
|
||||
|
||||
if ($args['choreId'] == 'new')
|
||||
{
|
||||
return $this->AppContainer->view->render($response, 'choreform', [
|
||||
'periodTypes' => GetClassConstants('\Grocy\Services\ChoresService'),
|
||||
'periodTypes' => GetClassConstants('\Grocy\Services\ChoresService', 'CHORE_PERIOD_TYPE_'),
|
||||
'mode' => 'create',
|
||||
'userfields' => $this->UserfieldsService->GetFields('chores')
|
||||
'userfields' => $this->UserfieldsService->GetFields('chores'),
|
||||
'assignmentTypes' => GetClassConstants('\Grocy\Services\ChoresService', 'CHORE_ASSIGNMENT_TYPE_'),
|
||||
'users' => $users
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->AppContainer->view->render($response, 'choreform', [
|
||||
'chore' => $this->Database->chores($args['choreId']),
|
||||
'periodTypes' => GetClassConstants('\Grocy\Services\ChoresService'),
|
||||
'periodTypes' => GetClassConstants('\Grocy\Services\ChoresService', 'CHORE_PERIOD_TYPE_'),
|
||||
'mode' => 'edit',
|
||||
'userfields' => $this->UserfieldsService->GetFields('chores')
|
||||
'userfields' => $this->UserfieldsService->GetFields('chores'),
|
||||
'assignmentTypes' => GetClassConstants('\Grocy\Services\ChoresService', 'CHORE_ASSIGNMENT_TYPE_'),
|
||||
'users' => $users
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user