mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
Creation of a report enable
This commit is contained in:
parent
c4f50d54d7
commit
302286c558
@ -57,6 +57,18 @@ class ReportController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function selectReportTypeAction($person_id, Request $request)
|
public function selectReportTypeAction($person_id, Request $request)
|
||||||
{
|
{
|
||||||
|
$cFGroupId = $request->query->get('cFGroup');
|
||||||
|
|
||||||
|
echo('----');
|
||||||
|
echo($cFGroupId);
|
||||||
|
echo('----');
|
||||||
|
|
||||||
|
if($cFGroupId) {
|
||||||
|
return $this->redirect(
|
||||||
|
$this->generateUrl('report_new',
|
||||||
|
array('person_id' => $person_id, 'cf_group_id' => $cFGroupId)));
|
||||||
|
}
|
||||||
|
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
$cFGroups = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')
|
$cFGroups = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')
|
||||||
@ -71,7 +83,6 @@ class ReportController extends Controller
|
|||||||
$form = $this->get('form.factory')
|
$form = $this->get('form.factory')
|
||||||
->createNamedBuilder(null, 'form', null, array(
|
->createNamedBuilder(null, 'form', null, array(
|
||||||
'method' => 'GET',
|
'method' => 'GET',
|
||||||
'action' => $this->generateUrl('report_new'),
|
|
||||||
'csrf_protection' => false
|
'csrf_protection' => false
|
||||||
))
|
))
|
||||||
->add('cFGroup', 'choice', array(
|
->add('cFGroup', 'choice', array(
|
||||||
@ -85,30 +96,50 @@ class ReportController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new Report entity.
|
* Displays a form to create a new Report entity.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function createAction(Request $request)
|
public function newAction($person_id, $cf_group_id, Request $request)
|
||||||
{
|
{
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
$entity = new Report();
|
$entity = new Report();
|
||||||
|
|
||||||
$cFGroupId = $request->query->get('cFGroup',null);
|
$cFGroup = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')->find($cf_group_id);
|
||||||
echo $cFGroupId;
|
$entity->setCFGroup($cFGroup);
|
||||||
die();
|
|
||||||
|
|
||||||
if($cFGroupId) {
|
$form = $this->createCreateForm($entity, $person_id, $cFGroup);
|
||||||
$entity.setCFGroup(
|
|
||||||
$em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')->find($cFGroupID)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$form = $this->createCreateForm($entity);
|
return $this->render('ChillReportBundle:Report:new.html.twig', array(
|
||||||
|
'entity' => $entity,
|
||||||
|
'form' => $form->createView(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Report entity.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function createAction($person_id, $cf_group_id, Request $request)
|
||||||
|
{
|
||||||
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
|
$entity = new Report();
|
||||||
|
$cFGroup = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')->find($cf_group_id);
|
||||||
|
|
||||||
|
$form = $this->createCreateForm($entity, $person_id, $cFGroup);
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
if ($form->isValid()) {
|
if ($form->isValid()) {
|
||||||
$em = $this->getDoctrine()->getManager();
|
$cFGroup = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')->find($cf_group_id);
|
||||||
|
$entity->setCFGroup($cFGroup);
|
||||||
|
|
||||||
|
$person = $em->getRepository('ChillPersonBundle:Person')->find($person_id);
|
||||||
|
$entity->setPerson($person);
|
||||||
|
|
||||||
|
$user = $this->get('security.context')->getToken()->getUser();
|
||||||
|
$entity->setUser($user);
|
||||||
|
|
||||||
$em->persist($entity);
|
$em->persist($entity);
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
@ -128,10 +159,11 @@ class ReportController extends Controller
|
|||||||
*
|
*
|
||||||
* @return \Symfony\Component\Form\Form The form
|
* @return \Symfony\Component\Form\Form The form
|
||||||
*/
|
*/
|
||||||
private function createCreateForm(Report $entity, $cFGroup)
|
private function createCreateForm(Report $entity, $person_id, $cFGroup)
|
||||||
{
|
{
|
||||||
$form = $this->createForm(new ReportType(), $entity, array(
|
$form = $this->createForm(new ReportType(), $entity, array(
|
||||||
'action' => $this->generateUrl('report_create'),
|
'action' => $this->generateUrl('report_create',
|
||||||
|
array('person_id' => $person_id, 'cf_group_id' => $cFGroup->getId())),
|
||||||
'method' => 'POST',
|
'method' => 'POST',
|
||||||
'em' => $this->getDoctrine()->getManager(),
|
'em' => $this->getDoctrine()->getManager(),
|
||||||
'cFGroup' => $cFGroup,
|
'cFGroup' => $cFGroup,
|
||||||
@ -142,33 +174,6 @@ class ReportController extends Controller
|
|||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Displays a form to create a new Report entity.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function newAction(Request $request)
|
|
||||||
{
|
|
||||||
$em = $this->getDoctrine()->getManager();
|
|
||||||
|
|
||||||
$entity = new Report();
|
|
||||||
|
|
||||||
$cFGroupId = $request->query->get('cFGroup');
|
|
||||||
|
|
||||||
if(! $cFGroupId) {
|
|
||||||
throw new Exception("Error Processing Request", 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
$cFGroup = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')->find($cFGroupId);
|
|
||||||
$entity->setCFGroup($cFGroup);
|
|
||||||
|
|
||||||
$form = $this->createCreateForm($entity, $cFGroup);
|
|
||||||
|
|
||||||
return $this->render('ChillReportBundle:Report:new.html.twig', array(
|
|
||||||
'entity' => $entity,
|
|
||||||
'form' => $form->createView(),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds and displays a Report entity.
|
* Finds and displays a Report entity.
|
||||||
*
|
*
|
||||||
|
@ -20,8 +20,6 @@ class ReportType extends AbstractType
|
|||||||
$transformer = new CustomFieldsGroupToIdTransformer($entityManager);
|
$transformer = new CustomFieldsGroupToIdTransformer($entityManager);
|
||||||
|
|
||||||
$builder
|
$builder
|
||||||
->add('user')
|
|
||||||
->add('person')
|
|
||||||
->add('date')
|
->add('date')
|
||||||
->add('scope')
|
->add('scope')
|
||||||
->add('cFData', 'custom_field', array('group' => $options['cFGroup']))
|
->add('cFData', 'custom_field', array('group' => $options['cFGroup']))
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
report_select_type:
|
report_select_type:
|
||||||
pattern: /person/{person_id}/report/create
|
pattern: /person/{person_id}/report/select/type/for/creation
|
||||||
defaults: { _controller: "ChillReportBundle:Report:selectReportType" }
|
defaults: { _controller: "ChillReportBundle:Report:selectReportType" }
|
||||||
options:
|
options:
|
||||||
menus:
|
menus:
|
||||||
@ -7,6 +7,19 @@ report_select_type:
|
|||||||
order: 100
|
order: 100
|
||||||
label: Add a report
|
label: Add a report
|
||||||
|
|
||||||
|
report_new:
|
||||||
|
path: /person/{person_id}/report/cfgroup/{cf_group_id}/new
|
||||||
|
defaults: { _controller: "ChillReportBundle:Report:new" }
|
||||||
|
|
||||||
|
report_create:
|
||||||
|
path: /person/{person_id}/report/cfgroup/{cf_group_id}/create
|
||||||
|
defaults: { _controller: "ChillReportBundle:Report:create" }
|
||||||
|
requirements: { _method: post }
|
||||||
|
|
||||||
|
report_show:
|
||||||
|
path: report/{id}/show
|
||||||
|
defaults: { _controller: "ChillReportBundle:Report:show" }
|
||||||
|
|
||||||
cl_custom_fields_report:
|
cl_custom_fields_report:
|
||||||
resource: "@ChillReportBundle/Resources/config/routing/report.yml"
|
resource: "@ChillReportBundle/Resources/config/routing/report.yml"
|
||||||
prefix: /report
|
prefix: /report
|
@ -6,15 +6,6 @@ report_show:
|
|||||||
path: /{id}/show
|
path: /{id}/show
|
||||||
defaults: { _controller: "ChillReportBundle:Report:show" }
|
defaults: { _controller: "ChillReportBundle:Report:show" }
|
||||||
|
|
||||||
report_new:
|
|
||||||
path: /new
|
|
||||||
defaults: { _controller: "ChillReportBundle:Report:new" }
|
|
||||||
|
|
||||||
report_create:
|
|
||||||
path: /create
|
|
||||||
defaults: { _controller: "ChillReportBundle:Report:create" }
|
|
||||||
requirements: { _method: post }
|
|
||||||
|
|
||||||
report_edit:
|
report_edit:
|
||||||
path: /{id}/edit
|
path: /{id}/edit
|
||||||
defaults: { _controller: "ChillReportBundle:Report:edit" }
|
defaults: { _controller: "ChillReportBundle:Report:edit" }
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{% extends '::base.html.twig' %}
|
{% extends "ChillMainBundle::layout.html.twig" %}
|
||||||
|
|
||||||
{% block body -%}
|
{% block content %}
|
||||||
<h1>Report creation</h1>
|
<h1>Report creation</h1>
|
||||||
|
|
||||||
{{ form(form) }}
|
{{ form(form) }}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
{% extends "ChillMainBundle::layout.html.twig" %}
|
{% extends "ChillMainBundle::layout.html.twig" %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
{% block content %}
|
|
||||||
|
|
||||||
{{ form_start(form) }}
|
{{ form_start(form) }}
|
||||||
{{ form_row(form) }}
|
{{ form_row(form) }}
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Userr</th>
|
<th>Userr</th>
|
||||||
<td>{{ entity.userr }}</td>
|
<td>{{ entity.user }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Person</th>
|
<th>Person</th>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user