From bd4538604e01cffdbe31e5cfe064acdfaded6b22 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Mon, 10 Nov 2014 12:51:52 +0100 Subject: [PATCH] using person template --- Controller/ReportController.php | 17 +++++++--- Resources/config/routing.yml | 3 +- Resources/config/routing/report.yml | 4 --- Resources/views/Report/new.html.twig | 32 ++++++++++++------- .../views/Report/select_report_type.html.twig | 16 ++++++++++ Resources/views/Report/show.html.twig | 22 +++---------- 6 files changed, 55 insertions(+), 39 deletions(-) diff --git a/Controller/ReportController.php b/Controller/ReportController.php index caf8eaf47..eee4ca4cf 100644 --- a/Controller/ReportController.php +++ b/Controller/ReportController.php @@ -121,6 +121,8 @@ class ReportController extends Controller { $em = $this->getDoctrine()->getManager(); + $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); + $entity = new Report(); $cFGroup = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')->find($cf_group_id); @@ -131,6 +133,7 @@ class ReportController extends Controller return $this->render('ChillReportBundle:Report:new.html.twig', array( 'entity' => $entity, 'form' => $form->createView(), + 'person' => $person )); } @@ -161,7 +164,8 @@ class ReportController extends Controller $em->persist($entity); $em->flush(); - return $this->redirect($this->generateUrl('report_show', array('id' => $entity->getId()))); + return $this->redirect($this->generateUrl('report_show', + array('person_id' => $person_id,'id' => $entity->getId()))); } return $this->render('ChillReportBundle:Report:new.html.twig', array( @@ -196,21 +200,24 @@ class ReportController extends Controller * Finds and displays a Report entity. * */ - public function showAction($id) + public function showAction($id, $person_id) { $em = $this->getDoctrine()->getManager(); + $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); + $entity = $em->getRepository('ChillReportBundle:Report')->find($id); if (!$entity) { throw $this->createNotFoundException('Unable to find Report entity.'); } - $deleteForm = $this->createDeleteForm($id); + //$deleteForm = $this->createDeleteForm($id); return $this->render('ChillReportBundle:Report:show.html.twig', array( - 'entity' => $entity, - 'delete_form' => $deleteForm->createView(), + 'entity' => $entity, + 'person' => $person, + //'delete_form' => $deleteForm->createView(), )); } diff --git a/Resources/config/routing.yml b/Resources/config/routing.yml index 6554b7e4a..e7ada1e7d 100644 --- a/Resources/config/routing.yml +++ b/Resources/config/routing.yml @@ -6,7 +6,6 @@ report_select_type: person: order: 100 label: Add a report - report_new: path: /person/{person_id}/report/cfgroup/{cf_group_id}/new defaults: { _controller: "ChillReportBundle:Report:new" } @@ -17,7 +16,7 @@ report_create: requirements: { _method: post } report_show: - path: report/{id}/show + path: /person/{person_id}/report/{id}/show defaults: { _controller: "ChillReportBundle:Report:show" } cl_custom_fields_report: diff --git a/Resources/config/routing/report.yml b/Resources/config/routing/report.yml index 33e0aab6c..fe0bba6d9 100644 --- a/Resources/config/routing/report.yml +++ b/Resources/config/routing/report.yml @@ -2,10 +2,6 @@ report: path: / defaults: { _controller: "ChillReportBundle:Report:index" } -report_show: - path: /{id}/show - defaults: { _controller: "ChillReportBundle:Report:show" } - report_edit: path: /{id}/edit defaults: { _controller: "ChillReportBundle:Report:edit" } diff --git a/Resources/views/Report/new.html.twig b/Resources/views/Report/new.html.twig index 3a63af29e..5277d10f9 100644 --- a/Resources/views/Report/new.html.twig +++ b/Resources/views/Report/new.html.twig @@ -1,15 +1,25 @@ -{% extends "ChillMainBundle::layout.html.twig" %} +{# + * 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" %} -{% block content %} -

Report creation

+{% set activeRouteKey = 'report_select_type' %} +{% block title %}{{ 'Ajout d\' un rapport' |trans() }}{% endblock title %} + +{% block personcontent %} {{ form(form) }} - - {% endblock %} diff --git a/Resources/views/Report/select_report_type.html.twig b/Resources/views/Report/select_report_type.html.twig index af46ca14a..b5b609eec 100644 --- a/Resources/views/Report/select_report_type.html.twig +++ b/Resources/views/Report/select_report_type.html.twig @@ -1,3 +1,19 @@ +{# + * 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' %} diff --git a/Resources/views/Report/show.html.twig b/Resources/views/Report/show.html.twig index 1f555eaba..3528da240 100644 --- a/Resources/views/Report/show.html.twig +++ b/Resources/views/Report/show.html.twig @@ -14,11 +14,13 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . #} -{% extends "ChillMainBundle::layout.html.twig" %} +{% extends "ChillPersonBundle::layout.html.twig" %} -{% block content %} -

Report

+{% set activeRouteKey = 'report_select_type' %} +{% block title %}{{ 'Details d\' un rapport' |trans() }}{% endblock title %} + +{% block personcontent %} @@ -51,18 +53,4 @@
- - {% endblock %} \ No newline at end of file