From 8bbb75a3f359dd80ec6eb81de565377b9cdac0ac Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Mon, 29 Jan 2018 09:37:33 -0400 Subject: [PATCH] rama de pruebas personales --- app/Resources/views/estado/edit.html.twig | 21 ++++ app/Resources/views/estado/index.html.twig | 107 ++++++++++++++++ app/Resources/views/estado/new.html.twig | 16 +++ app/Resources/views/estado/show.html.twig | 36 ++++++ .../PracticaBundle/Controller/estadoController.php | 136 +++++++++++++++++++++ src/UBV/PracticaBundle/Form/estadoType.php | 36 ++++++ .../Resources/views/Default/index.html.twig | 29 ++++- .../Tests/Controller/estadoControllerTest.php | 55 +++++++++ 8 files changed, 435 insertions(+), 1 deletion(-) create mode 100644 app/Resources/views/estado/edit.html.twig create mode 100644 app/Resources/views/estado/index.html.twig create mode 100644 app/Resources/views/estado/new.html.twig create mode 100644 app/Resources/views/estado/show.html.twig create mode 100644 src/UBV/PracticaBundle/Controller/estadoController.php create mode 100644 src/UBV/PracticaBundle/Form/estadoType.php create mode 100644 src/UBV/PracticaBundle/Tests/Controller/estadoControllerTest.php diff --git a/app/Resources/views/estado/edit.html.twig b/app/Resources/views/estado/edit.html.twig new file mode 100644 index 0000000..26cb310 --- /dev/null +++ b/app/Resources/views/estado/edit.html.twig @@ -0,0 +1,21 @@ +{% extends 'base.html.twig' %} + +{% block body %} +

Estado edit

+ + {{ form_start(edit_form) }} + {{ form_widget(edit_form) }} + + {{ form_end(edit_form) }} + + +{% endblock %} diff --git a/app/Resources/views/estado/index.html.twig b/app/Resources/views/estado/index.html.twig new file mode 100644 index 0000000..48ecb19 --- /dev/null +++ b/app/Resources/views/estado/index.html.twig @@ -0,0 +1,107 @@ +{% extends 'base.html.twig' %} + +{% block body %} +{% for type, flashMessage in app.session.flashbag.all() %} +
+ + {% if flashMessage.title is defined %} + {{ flashMessage.title }} + {{ flashMessage.message }} + {% else %} + {{ type }} + {% endif %} +
+ {% endfor %} +
+
+
+
+
Listado de Estados
+
+
+
+
+
+
+ +
+ + + + + + + + + + + {% for estado in estados %} + + + + + + + {% endfor %} + +
IDDescripcónCódigoAcciones
{{ loop.index }}{{ estado.descripcion | capitalize }}{{ estado.codigo }} +
    +    +    +    +
+
+
+
+
+
+
+
+
+
+
+ + + +{% endblock %} + +{% block javascripts %} + {{ parent() }} + + {% endblock javascripts %} diff --git a/app/Resources/views/estado/new.html.twig b/app/Resources/views/estado/new.html.twig new file mode 100644 index 0000000..460721b --- /dev/null +++ b/app/Resources/views/estado/new.html.twig @@ -0,0 +1,16 @@ +{% extends 'base.html.twig' %} + +{% block body %} +

Estado creation

+ + {{ form_start(form) }} + {{ form_widget(form) }} + + {{ form_end(form) }} + + +{% endblock %} diff --git a/app/Resources/views/estado/show.html.twig b/app/Resources/views/estado/show.html.twig new file mode 100644 index 0000000..b6edad6 --- /dev/null +++ b/app/Resources/views/estado/show.html.twig @@ -0,0 +1,36 @@ +{% extends 'base.html.twig' %} + +{% block body %} +

Estado

+ + + + + + + + + + + + + + + + +
Id{{ estado.id }}
Descripcion{{ estado.descripcion }}
Codigo{{ estado.codigo }}
+ + +{% endblock %} diff --git a/src/UBV/PracticaBundle/Controller/estadoController.php b/src/UBV/PracticaBundle/Controller/estadoController.php new file mode 100644 index 0000000..01404e4 --- /dev/null +++ b/src/UBV/PracticaBundle/Controller/estadoController.php @@ -0,0 +1,136 @@ +getDoctrine()->getManager(); + + $estados = $em->getRepository('UBVPracticaBundle:estado')->findAll(); + + return $this->render('estado/index.html.twig', array( + 'estados' => $estados, + )); + } + + /** + * Creates a new estado entity. + * + * @Route("/new", name="estado_new") + * @Method({"GET", "POST"}) + */ + public function newAction(Request $request) + { + $estado = new Estado(); + $form = $this->createForm('UBV\PracticaBundle\Form\estadoType', $estado); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $em = $this->getDoctrine()->getManager(); + $em->persist($estado); + $em->flush(); + + return $this->redirectToRoute('estado_index', array('id' => $estado->getId())); + } + + return $this->render('estado/new.html.twig', array( + 'estado' => $estado, + 'form' => $form->createView(), + )); + } + + /** + * Finds and displays a estado entity. + * + * @Route("/{id}", name="estado_show") + * @Method("GET") + */ + public function showAction(estado $estado) + { + $deleteForm = $this->createDeleteForm($estado); + + return $this->render('estado/show.html.twig', array( + 'estado' => $estado, + 'delete_form' => $deleteForm->createView(), + )); + } + + /** + * Displays a form to edit an existing estado entity. + * + * @Route("/{id}/edit", name="estado_edit") + * @Method({"GET", "POST"}) + */ + public function editAction(Request $request, estado $estado) + { + $deleteForm = $this->createDeleteForm($estado); + $editForm = $this->createForm('UBV\PracticaBundle\Form\estadoType', $estado); + $editForm->handleRequest($request); + + if ($editForm->isSubmitted() && $editForm->isValid()) { + $this->getDoctrine()->getManager()->flush(); + + return $this->redirectToRoute('estado_index', array('id' => $estado->getId())); + } + + return $this->render('estado/edit.html.twig', array( + 'estado' => $estado, + 'edit_form' => $editForm->createView(), + 'delete_form' => $deleteForm->createView(), + )); + } + + /** + * Deletes a estado entity. + * + * @Route("/{id}", name="estado_delete") + * @Method("DELETE") + */ + public function deleteAction(Request $request, estado $estado) + { + $form = $this->createDeleteForm($estado); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $em = $this->getDoctrine()->getManager(); + $em->remove($estado); + $em->flush(); + } + + return $this->redirectToRoute('estado_index'); + } + + /** + * Creates a form to delete a estado entity. + * + * @param estado $estado The estado entity + * + * @return \Symfony\Component\Form\Form The form + */ + private function createDeleteForm(estado $estado) + { + return $this->createFormBuilder() + ->setAction($this->generateUrl('estado_delete', array('id' => $estado->getId()))) + ->setMethod('DELETE') + ->getForm() + ; + } +} diff --git a/src/UBV/PracticaBundle/Form/estadoType.php b/src/UBV/PracticaBundle/Form/estadoType.php new file mode 100644 index 0000000..6d394c6 --- /dev/null +++ b/src/UBV/PracticaBundle/Form/estadoType.php @@ -0,0 +1,36 @@ +add('descripcion')->add('codigo'); + }/** + * {@inheritdoc} + */ + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults(array( + 'data_class' => 'UBV\PracticaBundle\Entity\estado' + )); + } + + /** + * {@inheritdoc} + */ + public function getBlockPrefix() + { + return 'ubv_practicabundle_estado'; + } + + +} diff --git a/src/UBV/PracticaBundle/Resources/views/Default/index.html.twig b/src/UBV/PracticaBundle/Resources/views/Default/index.html.twig index 2cc3e6b..21afde9 100644 --- a/src/UBV/PracticaBundle/Resources/views/Default/index.html.twig +++ b/src/UBV/PracticaBundle/Resources/views/Default/index.html.twig @@ -5,7 +5,34 @@ {% block Titulo %}

Practica UBV   Inicio

{% endblock %} - +
+
+
+
Jefe de Departamento
+
3
+
+
+
+
Encargado Almacen
+
70
+
+
+
+
Analista Administrador
+
11
+
+
+
+
Equipos
+
17
+
+ +
+
+
Reportes y Estadísticas
+
23
+
+
{% endblock %} diff --git a/src/UBV/PracticaBundle/Tests/Controller/estadoControllerTest.php b/src/UBV/PracticaBundle/Tests/Controller/estadoControllerTest.php new file mode 100644 index 0000000..2167a62 --- /dev/null +++ b/src/UBV/PracticaBundle/Tests/Controller/estadoControllerTest.php @@ -0,0 +1,55 @@ +request('GET', '/estado/'); + $this->assertEquals(200, $client->getResponse()->getStatusCode(), "Unexpected HTTP status code for GET /estado/"); + $crawler = $client->click($crawler->selectLink('Create a new entry')->link()); + + // Fill in the form and submit it + $form = $crawler->selectButton('Create')->form(array( + 'ubv_practicabundle_estado[field_name]' => 'Test', + // ... other fields to fill + )); + + $client->submit($form); + $crawler = $client->followRedirect(); + + // Check data in the show view + $this->assertGreaterThan(0, $crawler->filter('td:contains("Test")')->count(), 'Missing element td:contains("Test")'); + + // Edit the entity + $crawler = $client->click($crawler->selectLink('Edit')->link()); + + $form = $crawler->selectButton('Update')->form(array( + 'ubv_practicabundle_estado[field_name]' => 'Foo', + // ... other fields to fill + )); + + $client->submit($form); + $crawler = $client->followRedirect(); + + // Check the element contains an attribute with value equals "Foo" + $this->assertGreaterThan(0, $crawler->filter('[value="Foo"]')->count(), 'Missing element [value="Foo"]'); + + // Delete the entity + $client->submit($crawler->selectButton('Delete')->form()); + $crawler = $client->followRedirect(); + + // Check the entity has been delete on the list + $this->assertNotRegExp('/Foo/', $client->getResponse()->getContent()); + } + + */ +} -- 2.0.0