From 3834e16a7bb156683f75a6710225b8de704b4484 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Sun, 9 Nov 2014 19:19:28 +0100 Subject: [PATCH] Linking report <> person --- Controller/ReportController.php | 33 +++++++++++++++++++ Resources/config/routing.yml | 9 +++++ .../views/Report/select_report_type.html.twig | 13 ++++++++ 3 files changed, 55 insertions(+) create mode 100644 Resources/views/Report/select_report_type.html.twig diff --git a/Controller/ReportController.php b/Controller/ReportController.php index 7cd0288df..1bd09c25a 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -51,6 +51,39 @@ class ReportController extends Controller )); } + + /** + * Select the type of the Report + */ + public function selectReportTypeAction($person_id, Request $request) + { + $em = $this->getDoctrine()->getManager(); + + $cFGroups = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup') + ->findByEntity('Chill\ReportBundle\Entity\Report'); + + $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:select_report_type.html.twig', array( + 'form' => $form->createView() + )); + } + /** * Creates a new Report entity. * diff --git a/Resources/config/routing.yml b/Resources/config/routing.yml index e9f83604e..909cbf165 100644 --- a/Resources/config/routing.yml +++ b/Resources/config/routing.yml @@ -1,3 +1,12 @@ +report_select_type: + pattern: /person/{person_id}/report/create + defaults: { _controller: "ChillReportBundle:Report:selectReportType" } + options: + menus: + person: + order: 100 + label: Add a report + cl_custom_fields_report: resource: "@ChillReportBundle/Resources/config/routing/report.yml" prefix: /report \ No newline at end of file diff --git a/Resources/views/Report/select_report_type.html.twig b/Resources/views/Report/select_report_type.html.twig new file mode 100644 index 000000000..acaa3c01b --- /dev/null +++ b/Resources/views/Report/select_report_type.html.twig @@ -0,0 +1,13 @@ +{% extends "ChillMainBundle::layout.html.twig" %} + + + {% block content %} + + {{ form_start(form) }} + {{ form_row(form) }} + + {{ form_end(form) }} + +{% endblock %} \ No newline at end of file