diff --git a/Controller/ReportController.php b/Controller/ReportController.php index eee4ca4cf..37a832acb 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -38,35 +38,17 @@ class ReportController extends Controller * Lists all Report entities. * */ - public function indexAction(Request $request) + public function listAction($person_id, Request $request) { $em = $this->getDoctrine()->getManager(); - $entities = $em->getRepository('ChillReportBundle:Report')->findAll(); + $reports = $em->getRepository('ChillReportBundle:Report')->findByPerson($person_id); - $cFGroups = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup') - ->findByEntity('Chill\ReportBundle\Entity\Report'); + $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); - $cFGroupsChoice = array(); - - foreach ($cFGroups as $cFGroup) { - $cFGroupsChoice[$cFGroup->getId()] = $cFGroup->getName($request->getLocale()); - } - - $form = $this->get('form.factory') - ->createNamedBuilder(null, 'form', null, array( - 'method' => 'GET', - 'action' => $this->generateUrl('report_new'), - 'csrf_protection' => false - )) - ->add('cFGroup', 'choice', array( - 'choices' => $cFGroupsChoice - )) - ->getForm(); - - return $this->render('ChillReportBundle:Report:index.html.twig', array( - 'entities' => $entities, - 'form' => $form->createView() + return $this->render('ChillReportBundle:Report:list.html.twig', array( + 'reports' => $reports, + 'person' => $person )); } diff --git a/Resources/config/routing.yml b/Resources/config/routing.yml index e7ada1e7d..73c24c81f 100644 --- a/Resources/config/routing.yml +++ b/Resources/config/routing.yml @@ -15,6 +15,15 @@ report_create: defaults: { _controller: "ChillReportBundle:Report:create" } requirements: { _method: post } +report_list: + path: /person/{person_id}/report/list + defaults: { _controller: "ChillReportBundle:Report:list" } + options: + menus: + person: + order: 101 + label: Report list + report_show: path: /person/{person_id}/report/{id}/show defaults: { _controller: "ChillReportBundle:Report:show" } diff --git a/Resources/views/Report/index.html.twig b/Resources/views/Report/index.html.twig deleted file mode 100644 index c021d8dbc..000000000 --- a/Resources/views/Report/index.html.twig +++ /dev/null @@ -1,51 +0,0 @@ -{% extends '::base.html.twig' %} - -{% block body -%} -

Report list

- - - - - - - - - - - - - - - - {% for entity in entities %} - - - - - - - - - - - {% endfor %} - -
IdUserrPersonDateScopeCfdataCfgroupActions
{{ entity.id }}{{ entity.userr }}{{ entity.person }}{% if entity.date %}{{ entity.date|date('Y-m-d H:i:s') }}{% endif %}{{ entity.scope }}{{ entity.cFData }}{{ entity.cFGroup }} - -
- - - {{ form_start(form) }} - {{ form_row(form) }} - - {{ form_end(form) }} -{% endblock %} diff --git a/Resources/views/Report/list.html.twig b/Resources/views/Report/list.html.twig new file mode 100644 index 000000000..f92269d75 --- /dev/null +++ b/Resources/views/Report/list.html.twig @@ -0,0 +1,44 @@ +{# + * Copyright (C) 2014, Champs Libres Cooperative SCRLFS, + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . +#} +{% extends "ChillPersonBundle::layout.html.twig" %} + +{% set activeRouteKey = 'report_select_type' %} + +{% block title %}{{ 'List des rapports' |trans() }}{% endblock title %} + +{% block personcontent %} + + + + + + + + + + + {% for report in reports %} + + + + + + + {% endfor %} + +
{{ 'Date' | trans }}{{ 'Report Type' | trans }}{{ 'Report Scope' | trans }}
{% if report.date %}{{ report.date|date('d-m-Y') }}{% endif %}{{ report.cFGroup.getName(app.request.locale) }}{{ report.scope }}{{ 'update' | trans }}
+{% endblock %}