Commit e1cab739ee686598d51aed2f4b1dfea35405e6a0
1 parent
158864c8d0
Exists in
master
Creado el CRUD de los estudiantes y la sentencia de solo mostar las Unidades Cur…
…riculares de su malla
Showing
8 changed files
with
101 additions
and
26 deletions
Show diff stats
app/Resources/views/inscripcion/edit.html.twig
| 1 | -{% extends 'base.html.twig' %} | |
| 1 | +{% extends 'base_app.html.twig' %} | |
| 2 | 2 | |
| 3 | 3 | {% block body %} |
| 4 | 4 | <h1>Inscripcion edit</h1> |
| ... | ... | @@ -10,7 +10,7 @@ |
| 10 | 10 | |
| 11 | 11 | <ul> |
| 12 | 12 | <li> |
| 13 | - <a href="{{ path('ceapp_estudiante_inscripcion_index') }}">Back to the list</a> | |
| 13 | + <a href="{{ path('inscripcion_index') }}">Back to the list</a> | |
| 14 | 14 | </li> |
| 15 | 15 | <li> |
| 16 | 16 | {{ form_start(delete_form) }} | ... | ... |
app/Resources/views/inscripcion/index.html.twig
| ... | ... | @@ -15,7 +15,7 @@ |
| 15 | 15 | <h3> Unidades Curriculares Inscritas</h3> |
| 16 | 16 | </div> |
| 17 | 17 | <!-- /widget-header --> |
| 18 | - {% if not estado_academico.hasInscripcion %} | |
| 18 | + {% if not estado_academico.hasInscripcion | length > 0 %} | |
| 19 | 19 | <div class="widget-content"> |
| 20 | 20 | <div class="widget big-stats-container"> |
| 21 | 21 | <div class="widget-content"> |
| ... | ... | @@ -30,17 +30,20 @@ |
| 30 | 30 | <!-- /widget-content --> |
| 31 | 31 | </div> |
| 32 | 32 | </div> |
| 33 | - {% else %} | |
| 33 | +<!--Si Tiene inscripcion-->{% else %} | |
| 34 | 34 | <div class="widget-content"> |
| 35 | 35 | <div class="widget big-stats-container"> |
| 36 | 36 | <div class="widget-content"> |
| 37 | - <h6 class="bigstats"> | |
| 37 | + <div class="container"> | |
| 38 | 38 | {% for inscrita in estado_academico.hasInscripcion %} |
| 39 | - <p>{{ inscrita.idOfertaAcademica.idMallaCurricularUc.idUnidadCurricularVolumen.idUnidadCurricular.nombre }}</p> | |
| 39 | + <p> | |
| 40 | + {{ inscrita.idOfertaAcademica.idMallaCurricularUc.idUnidadCurricularVolumen.idUnidadCurricular.nombre }} | |
| 41 | + <a class="btn btn-warning btn-xs" href="{{ path('ceapp_estudiante_inscripcion_edit', { 'id': inscrita.id }) }}"><i class="fa fa-edit"></i></a> | |
| 42 | + </p> | |
| 40 | 43 | {% endfor %} |
| 41 | - </h6> | |
| 44 | + </div> | |
| 42 | 45 | <div class="col-md-2"> |
| 43 | - <a class="btn btn-primary" href="{{ path('ceapp_estudiante_inscripcion_new') }}">Inscribirme</a> | |
| 46 | + | |
| 44 | 47 | </div> |
| 45 | 48 | </div> |
| 46 | 49 | <!-- /widget-content --> | ... | ... |
app/Resources/views/inscripcion/show.html.twig
| ... | ... | @@ -7,7 +7,13 @@ |
| 7 | 7 | <tbody> |
| 8 | 8 | <tr> |
| 9 | 9 | <th>Id</th> |
| 10 | + <th>Uc</th> | |
| 11 | + <th>Seccion</th> | |
| 12 | + </tr> | |
| 13 | + <tr> | |
| 10 | 14 | <td>{{ inscripcion.id }}</td> |
| 15 | + <td>{{ inscripcion.idOfertaAcademica.idMallaCurricularUc.idUnidadCurricularVolumen.idUnidadCurricular.nombre }}</td> | |
| 16 | + <td>{{ inscripcion.idOfertaAcademica.idSeccion.nombre }}</td> | |
| 11 | 17 | </tr> |
| 12 | 18 | </tbody> |
| 13 | 19 | </table> | ... | ... |
src/AppBundle/Controller/InscripcionController.php
| ... | ... | @@ -7,7 +7,8 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
| 7 | 7 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; |
| 8 | 8 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
| 9 | 9 | use AppBundle\Entity\Inscripcion; |
| 10 | -use AppBundle\Form\InscripcionType; | |
| 10 | +use AppBundle\Entity\EstadoAcademico; | |
| 11 | + | |
| 11 | 12 | |
| 12 | 13 | /** |
| 13 | 14 | * Inscripcion controller. |
| ... | ... | @@ -42,7 +43,9 @@ class InscripcionController extends Controller |
| 42 | 43 | public function newAction(Request $request) |
| 43 | 44 | { |
| 44 | 45 | $inscripcion = $this->getDoctrine()->getRepository('AppBundle:EstadoAcademico')->findOneByIdRolInstitucion($this->getUser()->getIdRolInstitucion()); |
| 45 | - $form = $this->createForm('AppBundle\Form\InscripcionType', $inscripcion); | |
| 46 | + $form = $this->createForm('AppBundle\Form\InscripcionType', $inscripcion, array( | |
| 47 | + 'inscripcion' => $inscripcion | |
| 48 | + )); | |
| 46 | 49 | $form->handleRequest($request); |
| 47 | 50 | |
| 48 | 51 | if ($form->isSubmitted() && $form->isValid()) { |
| ... | ... | @@ -50,7 +53,7 @@ class InscripcionController extends Controller |
| 50 | 53 | $em->persist($inscripcion); |
| 51 | 54 | $em->flush(); |
| 52 | 55 | |
| 53 | - return $this->redirectToRoute('ceapp_estudiante_inscripcion_show', array('id' => $inscripcion->getId())); | |
| 56 | + return $this->redirectToRoute('inscripcion_index'); | |
| 54 | 57 | } |
| 55 | 58 | |
| 56 | 59 | return $this->render('inscripcion/new.html.twig', array( |
| ... | ... | @@ -83,12 +86,15 @@ class InscripcionController extends Controller |
| 83 | 86 | */ |
| 84 | 87 | public function editAction(Request $request, Inscripcion $inscripcion) |
| 85 | 88 | { |
| 89 | + $em = $this->getDoctrine()->getManager(); | |
| 86 | 90 | $deleteForm = $this->createDeleteForm($inscripcion); |
| 87 | - $editForm = $this->createForm('AppBundle\Form\InscripcionType', $inscripcion); | |
| 91 | + $estado_academico = $em->getRepository('AppBundle:EstadoAcademico')->findOneByIdRolInstitucion($this->getUser()->getIdRolInstitucion()); | |
| 92 | + $editForm = $this->createForm('AppBundle\Form\InscripcionEditType', $inscripcion); | |
| 88 | 93 | $editForm->handleRequest($request); |
| 89 | 94 | |
| 90 | 95 | if ($editForm->isSubmitted() && $editForm->isValid()) { |
| 91 | - $em = $this->getDoctrine()->getManager(); | |
| 96 | + // $em = $this->getDoctrine()->getManager(); | |
| 97 | + $em->persist($estado_academico); | |
| 92 | 98 | $em->persist($inscripcion); |
| 93 | 99 | $em->flush(); |
| 94 | 100 | |
| ... | ... | @@ -119,7 +125,7 @@ class InscripcionController extends Controller |
| 119 | 125 | $em->flush(); |
| 120 | 126 | } |
| 121 | 127 | |
| 122 | - return $this->redirectToRoute('ceapp_estudiante_inscripcion_index'); | |
| 128 | + return $this->redirectToRoute('inscripcion_index'); | |
| 123 | 129 | } |
| 124 | 130 | |
| 125 | 131 | /** | ... | ... |
src/AppBundle/Entity/EstadoAcademico.php
| ... | ... | @@ -84,7 +84,7 @@ class EstadoAcademico |
| 84 | 84 | * */ |
| 85 | 85 | protected $hasInscripcion; |
| 86 | 86 | |
| 87 | - private $OfertaAcademica; | |
| 87 | + private $idOfertaAcademica; | |
| 88 | 88 | |
| 89 | 89 | |
| 90 | 90 | |
| ... | ... | @@ -93,8 +93,9 @@ class EstadoAcademico |
| 93 | 93 | */ |
| 94 | 94 | public function __construct() |
| 95 | 95 | { |
| 96 | - $this->OfertaAcademica = new \Doctrine\Common\Collections\ArrayCollection(); | |
| 96 | + $this->idOfertaAcademica = new \Doctrine\Common\Collections\ArrayCollection(); | |
| 97 | 97 | $this->hasInscripcion = new \Doctrine\Common\Collections\ArrayCollection(); |
| 98 | + $this->fecha = new \DateTime(); | |
| 98 | 99 | } |
| 99 | 100 | |
| 100 | 101 | /** |
| ... | ... | @@ -280,30 +281,30 @@ class EstadoAcademico |
| 280 | 281 | |
| 281 | 282 | |
| 282 | 283 | /** |
| 283 | - * Get OfertaAcademica | |
| 284 | + * Get idOfertaAcademica | |
| 284 | 285 | * |
| 285 | 286 | * @return \Doctrine\Common\Collections\Collection |
| 286 | 287 | */ |
| 287 | - public function getOfertaAcademica() | |
| 288 | + public function getIdOfertaAcademica() | |
| 288 | 289 | { |
| 289 | - $ofertaAcademica = new \Doctrine\Common\Collections\ArrayCollection(); | |
| 290 | + $idOfertaAcademica = new \Doctrine\Common\Collections\ArrayCollection(); | |
| 290 | 291 | |
| 291 | 292 | foreach($this->hasInscripcion as $inscrita) |
| 292 | 293 | { |
| 293 | - $ofertaAcademica[] = $inscrita->getOfertaAcademica(); | |
| 294 | + $idOfertaAcademica[] = $inscrita->getIdOfertaAcademica(); | |
| 294 | 295 | } |
| 295 | 296 | |
| 296 | - return $ofertaAcademica; | |
| 297 | + return $idOfertaAcademica; | |
| 297 | 298 | } |
| 298 | 299 | |
| 299 | 300 | |
| 300 | 301 | /** |
| 301 | - * Set OfertaAcademica | |
| 302 | + * Set idOfertaAcademica | |
| 302 | 303 | * |
| 303 | 304 | */ |
| 304 | - public function setOfertaAcademica($ofertaAcademica) | |
| 305 | + public function setIdOfertaAcademica($idOfertaAcademica) | |
| 305 | 306 | { |
| 306 | - foreach($ofertaAcademica as $inscrita) | |
| 307 | + foreach($idOfertaAcademica as $inscrita) | |
| 307 | 308 | { |
| 308 | 309 | $inscripcion = new Inscripcion(); |
| 309 | 310 | ... | ... |
src/AppBundle/Entity/Inscripcion.php
| ... | ... | @@ -125,4 +125,9 @@ class Inscripcion |
| 125 | 125 | { |
| 126 | 126 | return $this->idEstatus; |
| 127 | 127 | } |
| 128 | + | |
| 129 | + | |
| 130 | + public function __toString() { | |
| 131 | + return $this->getIdOfertaAcademica()->getIdMallaCurricularUc()->getIdUnidadCurricularVolumen()->getIdUnidadCurricular()->getNombre(); | |
| 132 | + } | |
| 128 | 133 | } | ... | ... |
src/AppBundle/Form/InscripcionEditType.php
| ... | ... | @@ -0,0 +1,34 @@ |
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace AppBundle\Form; | |
| 4 | + | |
| 5 | +use Symfony\Component\Form\AbstractType; | |
| 6 | +use Symfony\Component\Form\FormBuilderInterface; | |
| 7 | +use Symfony\Component\OptionsResolver\OptionsResolver; | |
| 8 | +use Symfony\Bridge\Doctrine\Form\Type\EntityType; | |
| 9 | + | |
| 10 | +class InscripcionEditType extends AbstractType | |
| 11 | +{ | |
| 12 | + /** | |
| 13 | + * @param FormBuilderInterface $builder | |
| 14 | + * @param array $options | |
| 15 | + */ | |
| 16 | + public function buildForm(FormBuilderInterface $builder, array $options) | |
| 17 | + { | |
| 18 | + $builder | |
| 19 | + ->add('idOfertaAcademica') | |
| 20 | + ->add('idEstatus') | |
| 21 | + | |
| 22 | + ; | |
| 23 | + } | |
| 24 | + | |
| 25 | + /** | |
| 26 | + * @param OptionsResolver $resolver | |
| 27 | + */ | |
| 28 | + public function configureOptions(OptionsResolver $resolver) | |
| 29 | + { | |
| 30 | + $resolver->setDefaults(array( | |
| 31 | + 'data_class' => 'AppBundle\Entity\Inscripcion', | |
| 32 | + )); | |
| 33 | + } | |
| 34 | +} | ... | ... |
src/AppBundle/Form/InscripcionType.php
| ... | ... | @@ -6,6 +6,7 @@ use Symfony\Component\Form\AbstractType; |
| 6 | 6 | use Symfony\Component\Form\FormBuilderInterface; |
| 7 | 7 | use Symfony\Component\OptionsResolver\OptionsResolver; |
| 8 | 8 | use Symfony\Bridge\Doctrine\Form\Type\EntityType; |
| 9 | +use Doctrine\ORM\EntityRepository; | |
| 9 | 10 | |
| 10 | 11 | class InscripcionType extends AbstractType |
| 11 | 12 | { |
| ... | ... | @@ -15,14 +16,32 @@ class InscripcionType extends AbstractType |
| 15 | 16 | */ |
| 16 | 17 | public function buildForm(FormBuilderInterface $builder, array $options) |
| 17 | 18 | { |
| 19 | + $this->estado_academico = $options['inscripcion']; | |
| 20 | + if (count($this->estado_academico->getHasInscripcion()) == 0){ | |
| 21 | + $tray = 1; | |
| 22 | + $tram = 1; | |
| 23 | + } | |
| 24 | + echo $tray; | |
| 18 | 25 | $builder |
| 19 | 26 | /*->add('idRolInstitucion') |
| 20 | 27 | ->add('idOfertaAcademica') |
| 21 | 28 | ->add('idEstatus')*/ |
| 22 | - ->add('OfertaAcademica', EntityType::class, array( | |
| 29 | + ->add('idOfertaAcademica', EntityType::class, array( | |
| 23 | 30 | 'class' => 'AppBundle:OfertaAcademica', |
| 24 | 31 | 'expanded' => true, |
| 25 | - 'multiple' => true | |
| 32 | + 'multiple' => true, | |
| 33 | + 'query_builder' => function (EntityRepository $er) { | |
| 34 | + return $er->createQueryBuilder('u') | |
| 35 | + ->orderBy('u.idMallaCurricularUc', 'ASC') | |
| 36 | + ->innerJoin('u.idMallaCurricularUc', 'm', 'WITH', 'm.idTrayectoTramoModalidadTipoUc = ?2') | |
| 37 | + ->innerJoin('m.idTrayectoTramoModalidadTipoUc', 't', 'WITH', 't.idTrayecto = ?3') | |
| 38 | + ->where('u.idOfertaMallaCurricular = ?1 ') //que las uc conicidan con la malla del estado academico | |
| 39 | + ->setParameters(array( | |
| 40 | + 1 => $this->estado_academico->getIdOfertaMallaCurricular(), | |
| 41 | + 2 => 1, | |
| 42 | + 3 => 1 | |
| 43 | + )); | |
| 44 | + ;}, | |
| 26 | 45 | )) |
| 27 | 46 | ; |
| 28 | 47 | } |
| ... | ... | @@ -34,6 +53,7 @@ class InscripcionType extends AbstractType |
| 34 | 53 | { |
| 35 | 54 | $resolver->setDefaults(array( |
| 36 | 55 | 'data_class' => 'AppBundle\Entity\EstadoAcademico', |
| 56 | + 'inscripcion' => null, | |
| 37 | 57 | )); |
| 38 | 58 | } |
| 39 | 59 | } | ... | ... |