diff --git a/Controller/SingleTaskController.php b/Controller/SingleTaskController.php index a4cf1c4ef..81f7efb3c 100644 --- a/Controller/SingleTaskController.php +++ b/Controller/SingleTaskController.php @@ -32,6 +32,7 @@ class SingleTaskController extends Controller */ public function newAction(Request $request) { + $personId = $request->query->getInt('person_id', null); if ($personId === null) { @@ -47,8 +48,8 @@ class SingleTaskController extends Controller } $task = (new SingleTask()) - ->setPerson($person) ->setAssignee($this->getUser()) + ->setPerson($person) ->setType('task_default') ; @@ -69,7 +70,7 @@ class SingleTaskController extends Controller $this->addFlash('success', "The task is created"); return $this->redirectToRoute('chill_task_task_list_by_person', [ - 'personId' => $task->getPerson()->getId() + 'person_id' => $task->getPerson()->getId() ]); } else { @@ -173,7 +174,7 @@ class SingleTaskController extends Controller $this->addFlash('success', "Success : task updated!"); return $this->redirectToRoute('chill_task_task_list_by_person', [ - 'personId' => $task->getPerson()->getId() + 'person_id' => $task->getPerson()->getId() ]); } else { @@ -253,7 +254,7 @@ class SingleTaskController extends Controller return $this->redirect($this->generateUrl( 'chill_task_task_list_by_person', array( - 'personId' => $personId + 'person_id' => $personId ))); } } @@ -308,7 +309,7 @@ class SingleTaskController extends Controller // Get parameters from url if ($request->query->has('person_id')) { - $personId = $request->query->get('person_id'); + $personId = $request->query->getInt('person_id', null); $person = $personRepository->find($personId); if ($person === null) { @@ -323,7 +324,7 @@ class SingleTaskController extends Controller if ($request->query->has('user_id')) { - $userId = $request->query->get('user_id'); + $userId = $request->query->getInt('user_id', null); $user = $this->getDoctrine()->getManager() ->getRepository('ChillMainBundle:User') ->find($userId); @@ -338,7 +339,7 @@ class SingleTaskController extends Controller if ($request->query->has('scope_id')) { - $scopeId = $request->query->get('scope_id'); + $scopeId = $request->query->getInt('scope_id', null); $scope = $this->getDoctrine()->getManager() ->getRepository('ChillMainBundle:Scope') ->find($scopeId); @@ -366,6 +367,8 @@ class SingleTaskController extends Controller $viewParams['isSingleStatus'] = $singleStatus = count($statuses) === 1; + $tasks_count = 0; + foreach($statuses as $status) { if($request->query->has('status') && FALSE === \in_array($status, $statuses)) { @@ -393,8 +396,13 @@ class SingleTaskController extends Controller $singleStatus ? $paginator->getCurrentPage()->getFirstItemNumber() : 0, $singleStatus ? $paginator->getItemsPerPage() : 10) ; + + $tasks_count = $tasks_count + $count; } + // total number of tasks + $viewParams['tasks_count'] = $tasks_count; + if ($request->query->has('person_id')){ $viewParams['layout'] = 'ChillPersonBundle::layout.html.twig'; } else { @@ -404,6 +412,7 @@ class SingleTaskController extends Controller return $this->render('ChillTaskBundle:SingleTask:index.html.twig', $viewParams); } + protected function getPersonParam(Request $request, EntityManagerInterface $em) { $person = $em->getRepository(Person::class) diff --git a/Resources/views/SingleTask/_list.html.twig b/Resources/views/SingleTask/_list.html.twig index 1fdb7efc6..6998ab331 100644 --- a/Resources/views/SingleTask/_list.html.twig +++ b/Resources/views/SingleTask/_list.html.twig @@ -62,7 +62,7 @@
{{ "There is no tasks."|trans }}
+ {% if person is not null %} + + {{ 'Add a new task' | trans }} + + {% endif %} + + + {% else %} - {% if single_task_ended_tasks is defined %} - {{ helper.date_status('Tasks with expired deadline', single_task_ended_tasks, single_task_ended_count, single_task_ended_paginator, 'ended', isSingleStatus, person) }} - {% endif %} + {% if single_task_ended_tasks is defined %} + {{ helper.date_status('Tasks with expired deadline', single_task_ended_tasks, single_task_ended_count, single_task_ended_paginator, 'ended', isSingleStatus, person) }} + {% endif %} - {% if single_task_warning_tasks is defined %} - {{ helper.date_status('Tasks with warning deadline reached', single_task_warning_tasks, single_task_warning_count, single_task_warning_paginator, 'warning', isSingleStatus, person) }} - {% endif %} + {% if single_task_warning_tasks is defined %} + {{ helper.date_status('Tasks with warning deadline reached', single_task_warning_tasks, single_task_warning_count, single_task_warning_paginator, 'warning', isSingleStatus, person) }} + {% endif %} - {% if single_task_current_tasks is defined %} - {{ helper.date_status('Current tasks', single_task_current_tasks, single_task_current_count, single_task_current_paginator, 'current', isSingleStatus, person) }} - {% endif %} + {% if single_task_current_tasks is defined %} + {{ helper.date_status('Current tasks', single_task_current_tasks, single_task_current_count, single_task_current_paginator, 'current', isSingleStatus, person) }} + {% endif %} - {% if single_task_not_started_tasks is defined %} - {{ helper.date_status('Tasks not started', single_task_not_started_tasks, single_task_not_started_count, single_task_not_started_paginator, 'not_started', isSingleStatus, person) }} - {% endif %} + {% if single_task_not_started_tasks is defined %} + {{ helper.date_status('Tasks not started', single_task_not_started_tasks, single_task_not_started_count, single_task_not_started_paginator, 'not_started', isSingleStatus, person) }} + {% endif %} - {% if single_task_closed_tasks is defined %} - {{ helper.date_status('Closed', single_task_closed_tasks, single_task_closed_count, single_task_closed_paginator, 'closed', isSingleStatus, person) }} - {% endif %} + {% if single_task_closed_tasks is defined %} + {{ helper.date_status('Closed', single_task_closed_tasks, single_task_closed_count, single_task_closed_paginator, 'closed', isSingleStatus, person) }} + {% endif %} + + {% if isSingleStatus == false %} +