Commit 8bbb75a3f359dd80ec6eb81de565377b9cdac0ac
1 parent
8c45a84511
Exists in
feature/Edgar
rama de pruebas personales
Showing
8 changed files
with
435 additions
and
1 deletions
Show diff stats
app/Resources/views/estado/edit.html.twig
| @@ -0,0 +1,21 @@ | @@ -0,0 +1,21 @@ | ||
| 1 | +{% extends 'base.html.twig' %} | ||
| 2 | + | ||
| 3 | +{% block body %} | ||
| 4 | + <h1>Estado edit</h1> | ||
| 5 | + | ||
| 6 | + {{ form_start(edit_form) }} | ||
| 7 | + {{ form_widget(edit_form) }} | ||
| 8 | + <input type="submit" value="Edit" /> | ||
| 9 | + {{ form_end(edit_form) }} | ||
| 10 | + | ||
| 11 | + <ul> | ||
| 12 | + <li> | ||
| 13 | + <a href="{{ path('estado_index') }}">Back to the list</a> | ||
| 14 | + </li> | ||
| 15 | + <li> | ||
| 16 | + {{ form_start(delete_form) }} | ||
| 17 | + <input type="submit" value="Delete"> | ||
| 18 | + {{ form_end(delete_form) }} | ||
| 19 | + </li> | ||
| 20 | + </ul> | ||
| 21 | +{% endblock %} |
app/Resources/views/estado/index.html.twig
| @@ -0,0 +1,107 @@ | @@ -0,0 +1,107 @@ | ||
| 1 | +{% extends 'base.html.twig' %} | ||
| 2 | + | ||
| 3 | +{% block body %} | ||
| 4 | +{% for type, flashMessage in app.session.flashbag.all() %} | ||
| 5 | + <div class="alert alert-{{ type }} fade in"> | ||
| 6 | + <button class="close" data-dismiss="alert" type="button">×</button> | ||
| 7 | + {% if flashMessage.title is defined %} | ||
| 8 | + <strong>{{ flashMessage.title }}</strong> | ||
| 9 | + {{ flashMessage.message }} | ||
| 10 | + {% else %} | ||
| 11 | + {{ type }} | ||
| 12 | + {% endif %} | ||
| 13 | + </div> | ||
| 14 | + {% endfor %} | ||
| 15 | + <div class="row"> | ||
| 16 | + <div class="col-lg-12"> | ||
| 17 | + <div class="portlet"> | ||
| 18 | + <div class="portlet-header"> | ||
| 19 | + <div class="caption">Listado de Estados</div> | ||
| 20 | + </div> | ||
| 21 | + <div class="portlet-body"> | ||
| 22 | + <div class="table-tools"> | ||
| 23 | + <div class="row"> | ||
| 24 | + <div class="col-lg-12"> | ||
| 25 | + <div class="portlet-body"> | ||
| 26 | + <div class="table-tools"> | ||
| 27 | + <a href="{{ path('estado_new') }}"> | ||
| 28 | + <button type="button" class="btn btn-red mrs"><i class="fa fa-plus"></i> | ||
| 29 | + Agregar | ||
| 30 | + </button> | ||
| 31 | + </a> | ||
| 32 | + </div> | ||
| 33 | + <div class="table-responsive mtl"> | ||
| 34 | + <table class="table table-striped table-bordered table-hover"> | ||
| 35 | + <thead> | ||
| 36 | + <tr> | ||
| 37 | + <th class="text-center">ID</th> | ||
| 38 | + <th class="text-center">Descripcón</th> | ||
| 39 | + <th class="text-center">Código</th> | ||
| 40 | + <th class="text-center">Acciones</th> | ||
| 41 | + </tr> | ||
| 42 | + </thead> | ||
| 43 | + <tbody> | ||
| 44 | + {% for estado in estados %} | ||
| 45 | + <tr> | ||
| 46 | + <td class="text-center "><a href="{{ path('estado_show', { 'id': estado.id }) }}">{{ loop.index }}</a></td> | ||
| 47 | + <td class="text-center">{{ estado.descripcion | capitalize }}</td> | ||
| 48 | + <td class="text-center">{{ estado.codigo }}</td> | ||
| 49 | + <td class="text-center"> | ||
| 50 | + <ul> | ||
| 51 | + <a href="{{ path('estado_show', { 'id': estado.id }) }}"><span title="Mostrar" class="glyphicon text-info glyphicon-eye-open"></span></a> | ||
| 52 | + <a href="{{ path('estado_edit', { 'id': estado.id }) }}"<span title="Editar" class="glyphicon text-warning glyphicon-edit"></span></a> | ||
| 53 | + <a data-whatever="{{estado.id}}" data-toggle="modal" data-target="#myModal" href="#"><span title="Eliminar" class="glyphicon text-orange glyphicon-trash"></span></a> | ||
| 54 | + </ul> | ||
| 55 | + </td> | ||
| 56 | + </tr> | ||
| 57 | + {% endfor %} | ||
| 58 | + </tbody> | ||
| 59 | + </table> | ||
| 60 | + </div> | ||
| 61 | + </div> | ||
| 62 | + </div> | ||
| 63 | + </div> | ||
| 64 | + </div> | ||
| 65 | + </div> | ||
| 66 | + </div> | ||
| 67 | + </div> | ||
| 68 | + </div> | ||
| 69 | + <!--modal para eliminar --> | ||
| 70 | + <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> | ||
| 71 | + <div class="modal-dialog"> | ||
| 72 | + <div class="modal-content"> | ||
| 73 | + <div class="modal-header"> | ||
| 74 | + <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> | ||
| 75 | + <h4 class="modal-title" id="myModalLabel">Eliminar!!!</h4> | ||
| 76 | + </div> | ||
| 77 | + <div class="modal-body"> | ||
| 78 | + <h4>El Registro no se puede Eliminar. Esta siendo referido en otra tabla.</h4> | ||
| 79 | + </div> | ||
| 80 | + <div class="modal-footer"> | ||
| 81 | + <a class="btn btn-default" type="button" class="close" data-dismiss="modal" aria-label="Close" >volver</a> | ||
| 82 | + </div> | ||
| 83 | + </div> | ||
| 84 | + </div> | ||
| 85 | + </div> | ||
| 86 | + <!--fin del modal--> | ||
| 87 | +{% endblock %} | ||
| 88 | + | ||
| 89 | +{% block javascripts %} | ||
| 90 | + {{ parent() }} | ||
| 91 | + <script> | ||
| 92 | + $('#myModal').on('show.bs.modal', function (event) { | ||
| 93 | + var button = $(event.relatedTarget) // Button that triggered the modal | ||
| 94 | + var recipient = button.data('whatever') // Extract info from data-* attributes | ||
| 95 | + | ||
| 96 | + // If necessary, you could initiate an AJAX request here (and then do the updating in a callback). | ||
| 97 | + // Update the modal's content. We'll use jQuery here, but you could use a data binding library or other methods instead. | ||
| 98 | + var modal = $(this) | ||
| 99 | + var ruta = "{{path('estado_delete', { 'id': "borrar_id" })}}"; | ||
| 100 | + | ||
| 101 | + var borrar = ruta.replace("borrar_id", recipient); | ||
| 102 | + modal.find('#borrar').attr("href", borrar); | ||
| 103 | + | ||
| 104 | + | ||
| 105 | + }); | ||
| 106 | + </script> | ||
| 107 | + {% endblock javascripts %} |
app/Resources/views/estado/new.html.twig
| @@ -0,0 +1,16 @@ | @@ -0,0 +1,16 @@ | ||
| 1 | +{% extends 'base.html.twig' %} | ||
| 2 | + | ||
| 3 | +{% block body %} | ||
| 4 | + <h1>Estado creation</h1> | ||
| 5 | + | ||
| 6 | + {{ form_start(form) }} | ||
| 7 | + {{ form_widget(form) }} | ||
| 8 | + <input type="submit" value="Create" /> | ||
| 9 | + {{ form_end(form) }} | ||
| 10 | + | ||
| 11 | + <ul> | ||
| 12 | + <li> | ||
| 13 | + <a href="{{ path('estado_index') }}">Back to the list</a> | ||
| 14 | + </li> | ||
| 15 | + </ul> | ||
| 16 | +{% endblock %} |
app/Resources/views/estado/show.html.twig
| @@ -0,0 +1,36 @@ | @@ -0,0 +1,36 @@ | ||
| 1 | +{% extends 'base.html.twig' %} | ||
| 2 | + | ||
| 3 | +{% block body %} | ||
| 4 | + <h1>Estado</h1> | ||
| 5 | + | ||
| 6 | + <table> | ||
| 7 | + <tbody> | ||
| 8 | + <tr> | ||
| 9 | + <th>Id</th> | ||
| 10 | + <td>{{ estado.id }}</td> | ||
| 11 | + </tr> | ||
| 12 | + <tr> | ||
| 13 | + <th>Descripcion</th> | ||
| 14 | + <td>{{ estado.descripcion }}</td> | ||
| 15 | + </tr> | ||
| 16 | + <tr> | ||
| 17 | + <th>Codigo</th> | ||
| 18 | + <td>{{ estado.codigo }}</td> | ||
| 19 | + </tr> | ||
| 20 | + </tbody> | ||
| 21 | + </table> | ||
| 22 | + | ||
| 23 | + <ul> | ||
| 24 | + <li> | ||
| 25 | + <a href="{{ path('estado_index') }}">Back to the list</a> | ||
| 26 | + </li> | ||
| 27 | + <li> | ||
| 28 | + <a href="{{ path('estado_edit', { 'id': estado.id }) }}">Edit</a> | ||
| 29 | + </li> | ||
| 30 | + <li> | ||
| 31 | + {{ form_start(delete_form) }} | ||
| 32 | + <input type="submit" value="Delete"> | ||
| 33 | + {{ form_end(delete_form) }} | ||
| 34 | + </li> | ||
| 35 | + </ul> | ||
| 36 | +{% endblock %} |
src/UBV/PracticaBundle/Controller/estadoController.php
| @@ -0,0 +1,136 @@ | @@ -0,0 +1,136 @@ | ||
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace UBV\PracticaBundle\Controller; | ||
| 4 | + | ||
| 5 | +use UBV\PracticaBundle\Entity\estado; | ||
| 6 | +use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
| 7 | +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; | ||
| 8 | +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;use Symfony\Component\HttpFoundation\Request; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * Estado controller. | ||
| 12 | + * | ||
| 13 | + * @Route("estado") | ||
| 14 | + */ | ||
| 15 | +class estadoController extends Controller | ||
| 16 | +{ | ||
| 17 | + /** | ||
| 18 | + * Lists all estado entities. | ||
| 19 | + * | ||
| 20 | + * @Route("/", name="estado_index") | ||
| 21 | + * @Method("GET") | ||
| 22 | + */ | ||
| 23 | + public function indexAction() | ||
| 24 | + { | ||
| 25 | + $em = $this->getDoctrine()->getManager(); | ||
| 26 | + | ||
| 27 | + $estados = $em->getRepository('UBVPracticaBundle:estado')->findAll(); | ||
| 28 | + | ||
| 29 | + return $this->render('estado/index.html.twig', array( | ||
| 30 | + 'estados' => $estados, | ||
| 31 | + )); | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + /** | ||
| 35 | + * Creates a new estado entity. | ||
| 36 | + * | ||
| 37 | + * @Route("/new", name="estado_new") | ||
| 38 | + * @Method({"GET", "POST"}) | ||
| 39 | + */ | ||
| 40 | + public function newAction(Request $request) | ||
| 41 | + { | ||
| 42 | + $estado = new Estado(); | ||
| 43 | + $form = $this->createForm('UBV\PracticaBundle\Form\estadoType', $estado); | ||
| 44 | + $form->handleRequest($request); | ||
| 45 | + | ||
| 46 | + if ($form->isSubmitted() && $form->isValid()) { | ||
| 47 | + $em = $this->getDoctrine()->getManager(); | ||
| 48 | + $em->persist($estado); | ||
| 49 | + $em->flush(); | ||
| 50 | + | ||
| 51 | + return $this->redirectToRoute('estado_index', array('id' => $estado->getId())); | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + return $this->render('estado/new.html.twig', array( | ||
| 55 | + 'estado' => $estado, | ||
| 56 | + 'form' => $form->createView(), | ||
| 57 | + )); | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + /** | ||
| 61 | + * Finds and displays a estado entity. | ||
| 62 | + * | ||
| 63 | + * @Route("/{id}", name="estado_show") | ||
| 64 | + * @Method("GET") | ||
| 65 | + */ | ||
| 66 | + public function showAction(estado $estado) | ||
| 67 | + { | ||
| 68 | + $deleteForm = $this->createDeleteForm($estado); | ||
| 69 | + | ||
| 70 | + return $this->render('estado/show.html.twig', array( | ||
| 71 | + 'estado' => $estado, | ||
| 72 | + 'delete_form' => $deleteForm->createView(), | ||
| 73 | + )); | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + /** | ||
| 77 | + * Displays a form to edit an existing estado entity. | ||
| 78 | + * | ||
| 79 | + * @Route("/{id}/edit", name="estado_edit") | ||
| 80 | + * @Method({"GET", "POST"}) | ||
| 81 | + */ | ||
| 82 | + public function editAction(Request $request, estado $estado) | ||
| 83 | + { | ||
| 84 | + $deleteForm = $this->createDeleteForm($estado); | ||
| 85 | + $editForm = $this->createForm('UBV\PracticaBundle\Form\estadoType', $estado); | ||
| 86 | + $editForm->handleRequest($request); | ||
| 87 | + | ||
| 88 | + if ($editForm->isSubmitted() && $editForm->isValid()) { | ||
| 89 | + $this->getDoctrine()->getManager()->flush(); | ||
| 90 | + | ||
| 91 | + return $this->redirectToRoute('estado_index', array('id' => $estado->getId())); | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + return $this->render('estado/edit.html.twig', array( | ||
| 95 | + 'estado' => $estado, | ||
| 96 | + 'edit_form' => $editForm->createView(), | ||
| 97 | + 'delete_form' => $deleteForm->createView(), | ||
| 98 | + )); | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + /** | ||
| 102 | + * Deletes a estado entity. | ||
| 103 | + * | ||
| 104 | + * @Route("/{id}", name="estado_delete") | ||
| 105 | + * @Method("DELETE") | ||
| 106 | + */ | ||
| 107 | + public function deleteAction(Request $request, estado $estado) | ||
| 108 | + { | ||
| 109 | + $form = $this->createDeleteForm($estado); | ||
| 110 | + $form->handleRequest($request); | ||
| 111 | + | ||
| 112 | + if ($form->isSubmitted() && $form->isValid()) { | ||
| 113 | + $em = $this->getDoctrine()->getManager(); | ||
| 114 | + $em->remove($estado); | ||
| 115 | + $em->flush(); | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | + return $this->redirectToRoute('estado_index'); | ||
| 119 | + } | ||
| 120 | + | ||
| 121 | + /** | ||
| 122 | + * Creates a form to delete a estado entity. | ||
| 123 | + * | ||
| 124 | + * @param estado $estado The estado entity | ||
| 125 | + * | ||
| 126 | + * @return \Symfony\Component\Form\Form The form | ||
| 127 | + */ | ||
| 128 | + private function createDeleteForm(estado $estado) | ||
| 129 | + { | ||
| 130 | + return $this->createFormBuilder() | ||
| 131 | + ->setAction($this->generateUrl('estado_delete', array('id' => $estado->getId()))) | ||
| 132 | + ->setMethod('DELETE') | ||
| 133 | + ->getForm() | ||
| 134 | + ; | ||
| 135 | + } | ||
| 136 | +} |
src/UBV/PracticaBundle/Form/estadoType.php
| @@ -0,0 +1,36 @@ | @@ -0,0 +1,36 @@ | ||
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace UBV\PracticaBundle\Form; | ||
| 4 | + | ||
| 5 | +use Symfony\Component\Form\AbstractType; | ||
| 6 | +use Symfony\Component\Form\FormBuilderInterface; | ||
| 7 | +use Symfony\Component\OptionsResolver\OptionsResolver; | ||
| 8 | + | ||
| 9 | +class estadoType extends AbstractType | ||
| 10 | +{ | ||
| 11 | + /** | ||
| 12 | + * {@inheritdoc} | ||
| 13 | + */ | ||
| 14 | + public function buildForm(FormBuilderInterface $builder, array $options) | ||
| 15 | + { | ||
| 16 | + $builder->add('descripcion')->add('codigo'); | ||
| 17 | + }/** | ||
| 18 | + * {@inheritdoc} | ||
| 19 | + */ | ||
| 20 | + public function configureOptions(OptionsResolver $resolver) | ||
| 21 | + { | ||
| 22 | + $resolver->setDefaults(array( | ||
| 23 | + 'data_class' => 'UBV\PracticaBundle\Entity\estado' | ||
| 24 | + )); | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + /** | ||
| 28 | + * {@inheritdoc} | ||
| 29 | + */ | ||
| 30 | + public function getBlockPrefix() | ||
| 31 | + { | ||
| 32 | + return 'ubv_practicabundle_estado'; | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + | ||
| 36 | +} |
src/UBV/PracticaBundle/Resources/views/Default/index.html.twig
| @@ -5,7 +5,34 @@ | @@ -5,7 +5,34 @@ | ||
| 5 | {% block Titulo %}<h1 class="all-tittles">Practica UBV <small> Inicio</small></h1>{% endblock %} | 5 | {% block Titulo %}<h1 class="all-tittles">Practica UBV <small> Inicio</small></h1>{% endblock %} |
| 6 | </div> | 6 | </div> |
| 7 | </div> | 7 | </div> |
| 8 | - | 8 | + <section class="full-reset text-center" style="padding: 40px 0;"> |
| 9 | + <article class="tile"> | ||
| 10 | + <div class="tile-icon full-reset"><a href=""><i class="zmdi zmdi-face"></i></a></div> | ||
| 11 | + <div class="tile-name all-tittles">Jefe de Departamento</div> | ||
| 12 | + <div class="tile-num full-reset">3</div> | ||
| 13 | + </article> | ||
| 14 | + <article class="tile"> | ||
| 15 | + <div class="tile-icon full-reset"><a href=""><i class="zmdi zmdi-balance zmdi-hc-fw"></i></a></div> | ||
| 16 | + <div class="tile-name all-tittles">Encargado Almacen</div> | ||
| 17 | + <div class="tile-num full-reset">70</div> | ||
| 18 | + </article> | ||
| 19 | + <article class="tile"> | ||
| 20 | + <div class="tile-icon full-reset"><a href=""><i class="zmdi zmdi-male-alt"></i></a></div> | ||
| 21 | + <div class="tile-name all-tittles">Analista Administrador</div> | ||
| 22 | + <div class="tile-num full-reset">11</div> | ||
| 23 | + </article> | ||
| 24 | + <article class="tile"> | ||
| 25 | + <div class="tile-icon full-reset"><a href=""><i class="zmdi zmdi-laptop"></i></a></div> | ||
| 26 | + <div class="tile-name all-tittles" style="width: 90%;">Equipos</div> | ||
| 27 | + <div class="tile-num full-reset">17</div> | ||
| 28 | + </article> | ||
| 29 | + | ||
| 30 | + <article class="tile"> | ||
| 31 | + <div class="tile-icon full-reset"><a href=""><i class="zmdi zmdi-trending-up"></i></a></div> | ||
| 32 | + <div class="tile-name all-tittles" style="width: 90%;">Reportes y Estadísticas</div> | ||
| 33 | + <div class="tile-num full-reset">23</div> | ||
| 34 | + </article> | ||
| 35 | + </section> | ||
| 9 | 36 | ||
| 10 | {% endblock %} | 37 | {% endblock %} |
| 11 | 38 |
src/UBV/PracticaBundle/Tests/Controller/estadoControllerTest.php
| @@ -0,0 +1,55 @@ | @@ -0,0 +1,55 @@ | ||
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace UBV\PracticaBundle\Tests\Controller; | ||
| 4 | + | ||
| 5 | +use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; | ||
| 6 | + | ||
| 7 | +class estadoControllerTest extends WebTestCase | ||
| 8 | +{ | ||
| 9 | + /* | ||
| 10 | + public function testCompleteScenario() | ||
| 11 | + { | ||
| 12 | + // Create a new client to browse the application | ||
| 13 | + $client = static::createClient(); | ||
| 14 | + | ||
| 15 | + // Create a new entry in the database | ||
| 16 | + $crawler = $client->request('GET', '/estado/'); | ||
| 17 | + $this->assertEquals(200, $client->getResponse()->getStatusCode(), "Unexpected HTTP status code for GET /estado/"); | ||
| 18 | + $crawler = $client->click($crawler->selectLink('Create a new entry')->link()); | ||
| 19 | + | ||
| 20 | + // Fill in the form and submit it | ||
| 21 | + $form = $crawler->selectButton('Create')->form(array( | ||
| 22 | + 'ubv_practicabundle_estado[field_name]' => 'Test', | ||
| 23 | + // ... other fields to fill | ||
| 24 | + )); | ||
| 25 | + | ||
| 26 | + $client->submit($form); | ||
| 27 | + $crawler = $client->followRedirect(); | ||
| 28 | + | ||
| 29 | + // Check data in the show view | ||
| 30 | + $this->assertGreaterThan(0, $crawler->filter('td:contains("Test")')->count(), 'Missing element td:contains("Test")'); | ||
| 31 | + | ||
| 32 | + // Edit the entity | ||
| 33 | + $crawler = $client->click($crawler->selectLink('Edit')->link()); | ||
| 34 | + | ||
| 35 | + $form = $crawler->selectButton('Update')->form(array( | ||
| 36 | + 'ubv_practicabundle_estado[field_name]' => 'Foo', | ||
| 37 | + // ... other fields to fill | ||
| 38 | + )); | ||
| 39 | + | ||
| 40 | + $client->submit($form); | ||
| 41 | + $crawler = $client->followRedirect(); | ||
| 42 | + | ||
| 43 | + // Check the element contains an attribute with value equals "Foo" | ||
| 44 | + $this->assertGreaterThan(0, $crawler->filter('[value="Foo"]')->count(), 'Missing element [value="Foo"]'); | ||
| 45 | + | ||
| 46 | + // Delete the entity | ||
| 47 | + $client->submit($crawler->selectButton('Delete')->form()); | ||
| 48 | + $crawler = $client->followRedirect(); | ||
| 49 | + | ||
| 50 | + // Check the entity has been delete on the list | ||
| 51 | + $this->assertNotRegExp('/Foo/', $client->getResponse()->getContent()); | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + */ | ||
| 55 | +} |