From 53f174811a21841bbb449dd496d15ca254f71396 Mon Sep 17 00:00:00 2001 From: Wilmer Ramones Date: Sun, 24 Jul 2016 00:20:20 -0400 Subject: [PATCH] lograda la inscripcion con exito --- app/Resources/views/base_app.html.twig | 2 +- app/Resources/views/inscripcion/index.html.twig | 2 +- app/Resources/views/inscripcion/new.html.twig | 33 +-- .../views/ofertaacademica/index.html.twig | 35 +--- app/Resources/views/ofertaacademica/new.html.twig | 10 +- app/Resources/views/ofertaacademica/show.html.twig | 10 +- app/Resources/views/seccion/edit.html.twig | 21 ++ app/Resources/views/seccion/index.html.twig | 43 ++++ app/Resources/views/seccion/new.html.twig | 16 ++ app/Resources/views/seccion/show.html.twig | 40 ++++ src/AppBundle/Controller/InscripcionController.php | 14 +- .../Controller/OfertaAcademicaController.php | 2 +- src/AppBundle/Controller/SeccionController.php | 140 +++++++++++++ src/AppBundle/Entity/EstadoAcademico.php | 27 ++- src/AppBundle/Entity/Inscripcion.php | 27 ++- src/AppBundle/Entity/Inscripcion.php~ | 4 +- src/AppBundle/Entity/MallaCurricularUc.php | 5 + src/AppBundle/Entity/OfertaAcademica.php | 205 +++---------------- src/AppBundle/Entity/OfertaAcademica.php~ | 49 +---- src/AppBundle/Entity/Seccion.php | 221 ++++++++++++++++++++- src/AppBundle/Entity/Seccion.php~ | 90 +++++++++ src/AppBundle/Entity/UnidadCurricular.php | 3 +- src/AppBundle/Entity/UnidadCurricularVolumen.php | 4 + src/AppBundle/Form/InscripcionEditType.php | 2 +- src/AppBundle/Form/InscripcionType.php | 6 +- src/AppBundle/Form/OfertaAcademicaType.php | 28 +-- src/AppBundle/Form/SeccionType.php | 36 ++++ .../Tests/Controller/SeccionControllerTest.php | 55 +++++ 28 files changed, 781 insertions(+), 349 deletions(-) create mode 100644 app/Resources/views/seccion/edit.html.twig create mode 100644 app/Resources/views/seccion/index.html.twig create mode 100644 app/Resources/views/seccion/new.html.twig create mode 100644 app/Resources/views/seccion/show.html.twig create mode 100644 src/AppBundle/Controller/SeccionController.php create mode 100644 src/AppBundle/Entity/Seccion.php~ create mode 100644 src/AppBundle/Form/SeccionType.php create mode 100644 src/AppBundle/Tests/Controller/SeccionControllerTest.php diff --git a/app/Resources/views/base_app.html.twig b/app/Resources/views/base_app.html.twig index bb6411f..9fd74e0 100644 --- a/app/Resources/views/base_app.html.twig +++ b/app/Resources/views/base_app.html.twig @@ -88,7 +88,7 @@ diff --git a/app/Resources/views/inscripcion/index.html.twig b/app/Resources/views/inscripcion/index.html.twig index a51b7ca..a47fec4 100644 --- a/app/Resources/views/inscripcion/index.html.twig +++ b/app/Resources/views/inscripcion/index.html.twig @@ -37,7 +37,7 @@
{% for inscrita in estado_academico.hasInscripcion %}

- {{ inscrita.idOfertaAcademica.idMallaCurricularUc.idUnidadCurricularVolumen.idUnidadCurricular.nombre }} + {{ inscrita.idSeccion.ofertaAcademica.idMallaCurricularUc.idUnidadCurricularVolumen.idUnidadCurricular.nombre }}

{% endfor %} diff --git a/app/Resources/views/inscripcion/new.html.twig b/app/Resources/views/inscripcion/new.html.twig index b15d7bf..d0f3b10 100644 --- a/app/Resources/views/inscripcion/new.html.twig +++ b/app/Resources/views/inscripcion/new.html.twig @@ -2,19 +2,24 @@ {% block body %}

Inscripcion creation

-{{ dump(form.children.idOfertaAcademica.children) }} +
+
+ {% for o in oferta %} +
+ {{ o.idMallaCurricularUc }} + {% for seccion in o.seccion %} +
+ +
+
+ {% endfor %}
+{% endfor %} +
+ + +
-{% form_theme form 'bootstrap_3_horizontal_layout.html.twig' %} - {{ form_start(form) }} - {% for f in form.children.idOfertaAcademica.children %} - {{ form_widget(f) }} - {% endfor %} - - {{ form_end(form) }} - - {% endblock %} diff --git a/app/Resources/views/ofertaacademica/index.html.twig b/app/Resources/views/ofertaacademica/index.html.twig index 5e2abfd..e8a4597 100644 --- a/app/Resources/views/ofertaacademica/index.html.twig +++ b/app/Resources/views/ofertaacademica/index.html.twig @@ -1,37 +1,19 @@ -{% extends 'base_app.html.twig' %} +{% extends 'base.html.twig' %} {% block body %} - -
-
-
-

Oferta Academica Activa para el Eje

-
- -
- +

OfertaAcademica list

+ +
- - - - - - - + {% for ofertaAcademica in ofertaAcademicas %} - - - - - - - +
MallaCodigo UCUnidad CurricularModalidadTipoAulaCupoId Actions
{{ofertaAcademica.idMallaCurricularUc.idMallaCurricular.codigo}}{{ofertaAcademica.idMallaCurricularUc.idUnidadCurricularVolumen.idUnidadCurricular.codigo}}{{ofertaAcademica.idMallaCurricularUc.idUnidadCurricularVolumen.idUnidadCurricular}}{{ofertaAcademica.idMallaCurricularUc.idTrayectoTramoModalidadTipoUc.idModalidad}}{{ofertaAcademica.idMallaCurricularUc.idTrayectoTramoModalidadTipoUc.idTipoUc}}{{ ofertaAcademica.aula }}{{ ofertaAcademica.cupo }}{{ ofertaAcademica.id }} - - - - - {% endblock %} diff --git a/app/Resources/views/ofertaacademica/new.html.twig b/app/Resources/views/ofertaacademica/new.html.twig index 180e152..c792f4b 100644 --- a/app/Resources/views/ofertaacademica/new.html.twig +++ b/app/Resources/views/ofertaacademica/new.html.twig @@ -1,9 +1,8 @@ -{% extends 'base_app.html.twig' %} +{% extends 'base.html.twig' %} {% block body %} -
-

Creacion de Oferta Academica

-{% form_theme form 'bootstrap_3_horizontal_layout.html.twig' %} +

OfertaAcademica creation

+ {{ form_start(form) }} {{ form_widget(form) }} @@ -11,8 +10,7 @@ -
{% endblock %} diff --git a/app/Resources/views/ofertaacademica/show.html.twig b/app/Resources/views/ofertaacademica/show.html.twig index b0677ee..0abc702 100644 --- a/app/Resources/views/ofertaacademica/show.html.twig +++ b/app/Resources/views/ofertaacademica/show.html.twig @@ -6,14 +6,6 @@ - - - - - - - - @@ -22,7 +14,7 @@
  • - Back to the list + Back to the list
  • Edit diff --git a/app/Resources/views/seccion/edit.html.twig b/app/Resources/views/seccion/edit.html.twig new file mode 100644 index 0000000..84774f7 --- /dev/null +++ b/app/Resources/views/seccion/edit.html.twig @@ -0,0 +1,21 @@ +{% extends 'base.html.twig' %} + +{% block body %} +

    Seccion edit

    + + {{ form_start(edit_form) }} + {{ form_widget(edit_form) }} + + {{ form_end(edit_form) }} + +
      +
    • + Back to the list +
    • +
    • + {{ form_start(delete_form) }} + + {{ form_end(delete_form) }} +
    • +
    +{% endblock %} diff --git a/app/Resources/views/seccion/index.html.twig b/app/Resources/views/seccion/index.html.twig new file mode 100644 index 0000000..c4d936e --- /dev/null +++ b/app/Resources/views/seccion/index.html.twig @@ -0,0 +1,43 @@ +{% extends 'base.html.twig' %} + +{% block body %} +

    Seccion list

    + +
Aula{{ ofertaAcademica.aula }}
Cupo{{ ofertaAcademica.cupo }}
Id {{ ofertaAcademica.id }}
+ + + + + + + + + + + {% for seccion in seccions %} + + + + + + + + {% endfor %} + +
NombreAulaCupoIdActions
{{ seccion.nombre }}{{ seccion.aula }}{{ seccion.cupo }}{{ seccion.id }} + +
+ + +{% endblock %} diff --git a/app/Resources/views/seccion/new.html.twig b/app/Resources/views/seccion/new.html.twig new file mode 100644 index 0000000..6cec045 --- /dev/null +++ b/app/Resources/views/seccion/new.html.twig @@ -0,0 +1,16 @@ +{% extends 'base.html.twig' %} + +{% block body %} +

Seccion creation

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

Seccion

+ + + + + + + + + + + + + + + + + + + + +
Nombre{{ seccion.nombre }}
Aula{{ seccion.aula }}
Cupo{{ seccion.cupo }}
Id{{ seccion.id }}
+ +
    +
  • + Back to the list +
  • +
  • + Edit +
  • +
  • + {{ form_start(delete_form) }} + + {{ form_end(delete_form) }} +
  • +
+{% endblock %} diff --git a/src/AppBundle/Controller/InscripcionController.php b/src/AppBundle/Controller/InscripcionController.php index 6aba536..f631998 100644 --- a/src/AppBundle/Controller/InscripcionController.php +++ b/src/AppBundle/Controller/InscripcionController.php @@ -48,12 +48,21 @@ class InscripcionController extends Controller array('idMallaCurricularUc' => 'ASC') ); + $seccion = $this->getDoctrine()->getRepository('AppBundle:Seccion')->findAll(); + $form = $this->createForm('AppBundle\Form\InscripcionType', $ea, array('inscripcion' => $ea,)); $form->handleRequest($request); - if ($form->isSubmitted() && $form->isValid()) { + if ($request->isMethod("POST")) { + //var_dump($request->request->get('seccion')['idSeccion']); exit; $em = $this->getDoctrine()->getManager(); + + foreach ($request->request->get('seccion')['idSeccion'] as $s ){ + $inscripcion = $this->getDoctrine()->getRepository('AppBundle:Seccion')->findOneById($s); + //var_dump($inscripcion->getId()); exit; + $ea->setIdSeccion($inscripcion); + }; $em->persist($ea); $em->flush(); @@ -62,7 +71,8 @@ class InscripcionController extends Controller return $this->render('inscripcion/new.html.twig', array( 'estado_academico' => $ea, - 'oferta' => $oferta, + 'oferta' => $oferta, + 'seccion' => $seccion, 'form' => $form->createView() )); } diff --git a/src/AppBundle/Controller/OfertaAcademicaController.php b/src/AppBundle/Controller/OfertaAcademicaController.php index e3eafc4..1d940e1 100644 --- a/src/AppBundle/Controller/OfertaAcademicaController.php +++ b/src/AppBundle/Controller/OfertaAcademicaController.php @@ -19,7 +19,7 @@ class OfertaAcademicaController extends Controller /** * Lists all OfertaAcademica entities. * - * @Route("/", name="oferta_academica_index") + * @Route("/", name="ceapp_gestion_oferta_academica_index") * @Method("GET") */ public function indexAction() diff --git a/src/AppBundle/Controller/SeccionController.php b/src/AppBundle/Controller/SeccionController.php new file mode 100644 index 0000000..12089ce --- /dev/null +++ b/src/AppBundle/Controller/SeccionController.php @@ -0,0 +1,140 @@ +getDoctrine()->getManager(); + + $seccions = $em->getRepository('AppBundle:Seccion')->findAll(); + + return $this->render('seccion/index.html.twig', array( + 'seccions' => $seccions, + )); + } + + /** + * Creates a new Seccion entity. + * + * @Route("/new", name="ceapp_gestion_oferta_academica_seccion_new") + * @Method({"GET", "POST"}) + */ + public function newAction(Request $request) + { + $seccion = new Seccion(); + $form = $this->createForm('AppBundle\Form\SeccionType', $seccion); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $em = $this->getDoctrine()->getManager(); + $em->persist($seccion); + $em->flush(); + + return $this->redirectToRoute('ceapp_gestion_oferta_academica_seccion_show', array('id' => $seccion->getId())); + } + + return $this->render('seccion/new.html.twig', array( + 'seccion' => $seccion, + 'form' => $form->createView(), + )); + } + + /** + * Finds and displays a Seccion entity. + * + * @Route("/{id}", name="ceapp_gestion_oferta_academica_seccion_show") + * @Method("GET") + */ + public function showAction(Seccion $seccion) + { + $deleteForm = $this->createDeleteForm($seccion); + + return $this->render('seccion/show.html.twig', array( + 'seccion' => $seccion, + 'delete_form' => $deleteForm->createView(), + )); + } + + /** + * Displays a form to edit an existing Seccion entity. + * + * @Route("/{id}/edit", name="ceapp_gestion_oferta_academica_seccion_edit") + * @Method({"GET", "POST"}) + */ + public function editAction(Request $request, Seccion $seccion) + { + $deleteForm = $this->createDeleteForm($seccion); + $editForm = $this->createForm('AppBundle\Form\SeccionType', $seccion); + $editForm->handleRequest($request); + + if ($editForm->isSubmitted() && $editForm->isValid()) { + $em = $this->getDoctrine()->getManager(); + $em->persist($seccion); + $em->flush(); + + return $this->redirectToRoute('ceapp_gestion_oferta_academica_seccion_edit', array('id' => $seccion->getId())); + } + + return $this->render('seccion/edit.html.twig', array( + 'seccion' => $seccion, + 'edit_form' => $editForm->createView(), + 'delete_form' => $deleteForm->createView(), + )); + } + + /** + * Deletes a Seccion entity. + * + * @Route("/{id}", name="ceapp_gestion_oferta_academica_seccion_delete") + * @Method("DELETE") + */ + public function deleteAction(Request $request, Seccion $seccion) + { + $form = $this->createDeleteForm($seccion); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $em = $this->getDoctrine()->getManager(); + $em->remove($seccion); + $em->flush(); + } + + return $this->redirectToRoute('ceapp_gestion_oferta_academica_seccion_index'); + } + + /** + * Creates a form to delete a Seccion entity. + * + * @param Seccion $seccion The Seccion entity + * + * @return \Symfony\Component\Form\Form The form + */ + private function createDeleteForm(Seccion $seccion) + { + return $this->createFormBuilder() + ->setAction($this->generateUrl('ceapp_gestion_oferta_academica_seccion_delete', array('id' => $seccion->getId()))) + ->setMethod('DELETE') + ->getForm() + ; + } +} diff --git a/src/AppBundle/Entity/EstadoAcademico.php b/src/AppBundle/Entity/EstadoAcademico.php index 6f31e73..fbfd367 100644 --- a/src/AppBundle/Entity/EstadoAcademico.php +++ b/src/AppBundle/Entity/EstadoAcademico.php @@ -84,7 +84,7 @@ class EstadoAcademico * */ protected $hasInscripcion; - private $idOfertaAcademica; + private $idSeccion; @@ -93,7 +93,7 @@ class EstadoAcademico */ public function __construct() { - $this->idOfertaAcademica = new \Doctrine\Common\Collections\ArrayCollection(); + $this->idSeccion = new \Doctrine\Common\Collections\ArrayCollection(); $this->hasInscripcion = new \Doctrine\Common\Collections\ArrayCollection(); $this->fecha = new \DateTime(); } @@ -285,35 +285,32 @@ class EstadoAcademico * * @return \Doctrine\Common\Collections\Collection */ - public function getIdOfertaAcademica() + public function getIdSeccion() { - $idOfertaAcademica = new \Doctrine\Common\Collections\ArrayCollection(); + $idSeccion = new \Doctrine\Common\Collections\ArrayCollection(); foreach($this->hasInscripcion as $inscrita) { - $idOfertaAcademica[] = $inscrita->getIdOfertaAcademica(); + $idSeccion[] = $inscrita->getIdSeccion(); } - return $idOfertaAcademica; + return $idSeccion; } /** - * Set idOfertaAcademica + * Set idSeccion * */ - public function setIdOfertaAcademica($idOfertaAcademica) + public function setIdSeccion($idSeccion) { - foreach($idOfertaAcademica as $inscrita) - { - $inscripcion = new Inscripcion(); - + + $inscripcion = new Inscripcion(); $inscripcion->setIdEstadoAcademico($this); - $inscripcion->setIdOfertaAcademica($inscrita); + $inscripcion->setIdSeccion($idSeccion); $inscripcion->setIdEstatus($this->getIdDocenteServicio()->getIdEstatus()); - $this->addHasInscripcion($inscripcion); - } + } } diff --git a/src/AppBundle/Entity/Inscripcion.php b/src/AppBundle/Entity/Inscripcion.php index f96d153..24f3e7a 100644 --- a/src/AppBundle/Entity/Inscripcion.php +++ b/src/AppBundle/Entity/Inscripcion.php @@ -29,10 +29,10 @@ class Inscripcion private $idEstadoAcademico; /** - * @ORM\ManyToOne(targetEntity="AppBundle\Entity\OfertaAcademica", inversedBy="hasInscripcion") + * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Seccion", inversedBy="hasInscripcion") * @ORM\JoinColumn(name="oferta_academica_id", referencedColumnName="id") * */ - private $idOfertaAcademica; + private $idSeccion; /** @@ -47,6 +47,8 @@ class Inscripcion + + /** * Get id * @@ -81,26 +83,26 @@ class Inscripcion } /** - * Set idOfertaAcademica + * Set idSeccion * - * @param \AppBundle\Entity\OfertaAcademica $idOfertaAcademica + * @param \AppBundle\Entity\Seccion $idSeccion * @return Inscripcion */ - public function setIdOfertaAcademica(\AppBundle\Entity\OfertaAcademica $idOfertaAcademica = null) + public function setIdSeccion(\AppBundle\Entity\Seccion $idSeccion = null) { - $this->idOfertaAcademica = $idOfertaAcademica; + $this->idSeccion = $idSeccion; return $this; } /** - * Get idOfertaAcademica + * Get idSeccion * - * @return \AppBundle\Entity\OfertaAcademica + * @return \AppBundle\Entity\Seccion */ - public function getIdOfertaAcademica() + public function getIdSeccion() { - return $this->idOfertaAcademica; + return $this->idSeccion; } /** @@ -125,9 +127,4 @@ class Inscripcion { return $this->idEstatus; } - - - public function __toString() { - return $this->getIdOfertaAcademica()->getIdMallaCurricularUc()->getIdUnidadCurricularVolumen()->getIdUnidadCurricular()->getNombre(); - } } diff --git a/src/AppBundle/Entity/Inscripcion.php~ b/src/AppBundle/Entity/Inscripcion.php~ index 9d6e103..0b51caa 100644 --- a/src/AppBundle/Entity/Inscripcion.php~ +++ b/src/AppBundle/Entity/Inscripcion.php~ @@ -32,7 +32,7 @@ class Inscripcion * @ORM\ManyToOne(targetEntity="AppBundle\Entity\OfertaAcademica", inversedBy="hasInscripcion") * @ORM\JoinColumn(name="oferta_academica_id", referencedColumnName="id") * */ - private $idOfertaAcademica; + private $idSeccion; /** @@ -46,4 +46,6 @@ class Inscripcion private $idEstatus; + + } diff --git a/src/AppBundle/Entity/MallaCurricularUc.php b/src/AppBundle/Entity/MallaCurricularUc.php index 1145fd2..2bbb71c 100644 --- a/src/AppBundle/Entity/MallaCurricularUc.php +++ b/src/AppBundle/Entity/MallaCurricularUc.php @@ -163,4 +163,9 @@ class MallaCurricularUc } + public function __toString() + { + return $this->getIdUnidadCurricularVolumen()->getIdUnidadCurricular()->getNombre(); + } + } diff --git a/src/AppBundle/Entity/OfertaAcademica.php b/src/AppBundle/Entity/OfertaAcademica.php index 5be4b2a..a4232d5 100644 --- a/src/AppBundle/Entity/OfertaAcademica.php +++ b/src/AppBundle/Entity/OfertaAcademica.php @@ -7,24 +7,23 @@ use Doctrine\ORM\Mapping as ORM; /** * OfertaAcademica * - * @ORM\Table(name="oferta_academica", uniqueConstraints={@ORM\UniqueConstraint(name="i_oferta_academica", columns={"id_malla_curricular_uc", "id_seccion", "id_oferta_malla_curricular"})}, indexes={@ORM\Index(name="fki_oferta_malla_curricular_oferta_academica", columns={"id_oferta_malla_curricular"}), @ORM\Index(name="fki_seccion_oferta_academica", columns={"id_seccion"}), @ORM\Index(name="fki_turno_oferta_academica", columns={"id_turno"}), @ORM\Index(name="fki_rol_institucion_oferta_academica", columns={"id_rol_institucion"}), @ORM\Index(name="fki_malla_curricular_uc_oferta_academica", columns={"id_malla_curricular_uc"})}) + * @ORM\Table(name="oferta_academica", + * uniqueConstraints= + * {@ORM\UniqueConstraint(name="i_oferta_academica", + * columns={"id_malla_curricular_uc", "id_oferta_malla_curricular"}) + * }, + * indexes={ + * @ORM\Index(name="fki_oferta_malla_curricular_oferta_academica", + * columns={"id_oferta_malla_curricular"}), + * @ORM\Index(name="fki_malla_curricular_uc_oferta_academica", + * columns={"id_malla_curricular_uc"}) + * } + * ) * @ORM\Entity */ class OfertaAcademica { - /** - * @var string - * - * @ORM\Column(name="aula", type="string", length=10, nullable=true, options={"comment" = "Indica el aula donde se va a dictar la unidad curricular (EN OBSERVACION, ESTE VALOR PUEDE SER VARIABLE PARA UNA MISMA OFERTA)"}) - */ - private $aula; - - /** - * @var string - * - * @ORM\Column(name="cupo", type="decimal", precision=2, scale=0, nullable=false, options={"comment" = "Indica el numero de cupos para esa oferta"}) - */ - private $cupo; + /** * @var integer @@ -48,41 +47,14 @@ class OfertaAcademica private $idMallaCurricularUc; - /** - * @ORM\OneToMany(targetEntity="AppBundle\Entity\Inscripcion" , mappedBy="idOfertaAcademica" , cascade={"all"}) - * */ - protected $hasInscripcion; /** - * @var \AppBundle\Entity\Turno - * - * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Turno") - * @ORM\JoinColumns({ - * @ORM\JoinColumn(name="id_turno", referencedColumnName="id", nullable=false) - * }) - */ - private $idTurno; - - /** - * @var \AppBundle\Entity\Seccion - * - * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Seccion") - * @ORM\JoinColumns({ - * @ORM\JoinColumn(name="id_seccion", referencedColumnName="id", nullable=false) - * }) + * @ORM\OneToMany(targetEntity="Seccion", mappedBy="ofertaAcademica") */ - private $idSeccion; + private $seccion; - /** - * @var \AppBundle\Entity\RolInstitucion - * - * @ORM\ManyToOne(targetEntity="AppBundle\Entity\RolInstitucion") - * @ORM\JoinColumns({ - * @ORM\JoinColumn(name="id_rol_institucion", referencedColumnName="id", nullable=false) - * }) - */ - private $idRolInstitucion; + /** * @var \AppBundle\Entity\OfertaMallaCurricular @@ -94,60 +66,12 @@ class OfertaAcademica */ private $idOfertaMallaCurricular; - - /** * Constructor */ public function __construct() { - $this->hasInscripcion = new \Doctrine\Common\Collections\ArrayCollection(); - } - - /** - * Set aula - * - * @param string $aula - * @return OfertaAcademica - */ - public function setAula($aula) - { - $this->aula = $aula; - - return $this; - } - - /** - * Get aula - * - * @return string - */ - public function getAula() - { - return $this->aula; - } - - /** - * Set cupo - * - * @param string $cupo - * @return OfertaAcademica - */ - public function setCupo($cupo) - { - $this->cupo = $cupo; - - return $this; - } - - /** - * Get cupo - * - * @return string - */ - public function getCupo() - { - return $this->cupo; + $this->seccion = new \Doctrine\Common\Collections\ArrayCollection(); } /** @@ -184,105 +108,36 @@ class OfertaAcademica } /** - * Add hasInscripcion + * Add seccion * - * @param \AppBundle\Entity\Inscripcion $hasInscripcion + * @param \AppBundle\Entity\Seccion $seccion * @return OfertaAcademica */ - public function addHasInscripcion(\AppBundle\Entity\Inscripcion $hasInscripcion) + public function addSeccion(\AppBundle\Entity\Seccion $seccion) { - $this->hasInscripcion[] = $hasInscripcion; + $this->seccion[] = $seccion; return $this; } /** - * Remove hasInscripcion + * Remove seccion * - * @param \AppBundle\Entity\Inscripcion $hasInscripcion + * @param \AppBundle\Entity\Seccion $seccion */ - public function removeHasInscripcion(\AppBundle\Entity\Inscripcion $hasInscripcion) + public function removeSeccion(\AppBundle\Entity\Seccion $seccion) { - $this->hasInscripcion->removeElement($hasInscripcion); + $this->seccion->removeElement($seccion); } /** - * Get hasInscripcion + * Get seccion * * @return \Doctrine\Common\Collections\Collection */ - public function getHasInscripcion() - { - return $this->hasInscripcion; - } - - /** - * Set idTurno - * - * @param \AppBundle\Entity\Turno $idTurno - * @return OfertaAcademica - */ - public function setIdTurno(\AppBundle\Entity\Turno $idTurno) - { - $this->idTurno = $idTurno; - - return $this; - } - - /** - * Get idTurno - * - * @return \AppBundle\Entity\Turno - */ - public function getIdTurno() - { - return $this->idTurno; - } - - /** - * Set idSeccion - * - * @param \AppBundle\Entity\Seccion $idSeccion - * @return OfertaAcademica - */ - public function setIdSeccion(\AppBundle\Entity\Seccion $idSeccion) - { - $this->idSeccion = $idSeccion; - - return $this; - } - - /** - * Get idSeccion - * - * @return \AppBundle\Entity\Seccion - */ - public function getIdSeccion() - { - return $this->idSeccion; - } - - /** - * Set idRolInstitucion - * - * @param \AppBundle\Entity\RolInstitucion $idRolInstitucion - * @return OfertaAcademica - */ - public function setIdRolInstitucion(\AppBundle\Entity\RolInstitucion $idRolInstitucion) - { - $this->idRolInstitucion = $idRolInstitucion; - - return $this; - } - - /** - * Get idRolInstitucion - * - * @return \AppBundle\Entity\RolInstitucion - */ - public function getIdRolInstitucion() + public function getSeccion() { - return $this->idRolInstitucion; + return $this->seccion; } /** @@ -309,8 +164,6 @@ class OfertaAcademica } public function __toString() { - return - $this->getIdMallaCurricularUc()->getIdUnidadCurricularVolumen()->getIdUnidadCurricular()->getNombre() - . " Seccion: " . $this->getIdSeccion()->getNombre(); + return $this->getIdMallaCurricularUc()->getIdUnidadCurricularVolumen()->getIdUnidadCurricular()->getNombre(); } } diff --git a/src/AppBundle/Entity/OfertaAcademica.php~ b/src/AppBundle/Entity/OfertaAcademica.php~ index 77fff80..71af7a7 100644 --- a/src/AppBundle/Entity/OfertaAcademica.php~ +++ b/src/AppBundle/Entity/OfertaAcademica.php~ @@ -12,19 +12,7 @@ use Doctrine\ORM\Mapping as ORM; */ class OfertaAcademica { - /** - * @var string - * - * @ORM\Column(name="aula", type="string", length=10, nullable=true, options={"comment" = "Indica el aula donde se va a dictar la unidad curricular (EN OBSERVACION, ESTE VALOR PUEDE SER VARIABLE PARA UNA MISMA OFERTA)"}) - */ - private $aula; - - /** - * @var string - * - * @ORM\Column(name="cupo", type="decimal", precision=2, scale=0, nullable=false, options={"comment" = "Indica el numero de cupos para esa oferta"}) - */ - private $cupo; + /** * @var integer @@ -48,41 +36,14 @@ class OfertaAcademica private $idMallaCurricularUc; - /** - * @ORM\OneToMany(targetEntity="AppBundle\Entity\Inscripcion" , mappedBy="idOfertaAcademica" , cascade={"all"}) - * */ - protected $hasInscripcion; /** - * @var \AppBundle\Entity\Turno - * - * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Turno") - * @ORM\JoinColumns({ - * @ORM\JoinColumn(name="id_turno", referencedColumnName="id", nullable=false) - * }) - */ - private $idTurno; - - /** - * @var \AppBundle\Entity\Seccion - * - * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Seccion") - * @ORM\JoinColumns({ - * @ORM\JoinColumn(name="id_seccion", referencedColumnName="id", nullable=false) - * }) + * @ORM\OneToMany(targetEntity="Seccion", mappedBy="ofertaAcademica") */ - private $idSeccion; + private $seccion; - /** - * @var \AppBundle\Entity\RolInstitucion - * - * @ORM\ManyToOne(targetEntity="AppBundle\Entity\RolInstitucion") - * @ORM\JoinColumns({ - * @ORM\JoinColumn(name="id_rol_institucion", referencedColumnName="id", nullable=false) - * }) - */ - private $idRolInstitucion; + /** * @var \AppBundle\Entity\OfertaMallaCurricular @@ -94,6 +55,4 @@ class OfertaAcademica */ private $idOfertaMallaCurricular; - - } diff --git a/src/AppBundle/Entity/Seccion.php b/src/AppBundle/Entity/Seccion.php index 25b4889..e37fb43 100644 --- a/src/AppBundle/Entity/Seccion.php +++ b/src/AppBundle/Entity/Seccion.php @@ -7,7 +7,19 @@ use Doctrine\ORM\Mapping as ORM; /** * Seccion * - * @ORM\Table(name="seccion", uniqueConstraints={@ORM\UniqueConstraint(name="uq_seccion", columns={"nombre"})}) + * @ORM\Table(name="seccion", + * uniqueConstraints= + * {@ORM\UniqueConstraint(name="uq_seccion", + * columns={"nombre", "id_turno"}) + * }, + * indexes={ + * @ORM\Index(name="fki_turno_oferta_academica", + * columns={"id_turno"}), + * @ORM\Index(name="fki_rol_institucion_oferta_academica", + * columns={"id_rol_institucion"}), + + * } + * ) * @ORM\Entity */ class Seccion @@ -18,6 +30,46 @@ class Seccion * @ORM\Column(name="nombre", type="string", length=20, nullable=false, options={"comment" = "nombre de la seccion"}) */ private $nombre; + + /** + * @var string + * + * @ORM\Column(name="aula", type="string", length=10, nullable=true, options={"comment" = "Indica el aula donde se va a dictar la unidad curricular (EN OBSERVACION, ESTE VALOR PUEDE SER VARIABLE PARA UNA MISMA OFERTA)"}) + */ + private $aula; + + /** + * @var string + * + * @ORM\Column(name="cupo", type="decimal", precision=2, scale=0, nullable=false, options={"comment" = "Indica el numero de cupos para esa oferta"}) + */ + private $cupo; + + /** + * @ORM\OneToMany(targetEntity="AppBundle\Entity\Inscripcion" , mappedBy="idSeccion" , cascade={"all"}) + * */ + protected $hasInscripcion; + + + /** + * @var \AppBundle\Entity\Turno + * + * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Turno") + * @ORM\JoinColumns({ + * @ORM\JoinColumn(name="id_turno", referencedColumnName="id", nullable=false) + * }) + */ + private $idTurno; + + /** + * @var \AppBundle\Entity\RolInstitucion + * + * @ORM\ManyToOne(targetEntity="AppBundle\Entity\RolInstitucion") + * @ORM\JoinColumns({ + * @ORM\JoinColumn(name="id_rol_institucion", referencedColumnName="id", nullable=false) + * }) + */ + private $idRolInstitucion; /** * @var integer @@ -28,8 +80,22 @@ class Seccion * @ORM\SequenceGenerator(sequenceName="seccion_id_seq", allocationSize=1, initialValue=1) */ private $id; + + /** + * @ORM\ManyToOne(targetEntity="OfertaAcademica", inversedBy="seccion") + * @ORM\JoinColumn(name="oferta_academica_id", referencedColumnName="id") + */ + private $ofertaAcademica; + + /** + * Constructor + */ + public function __construct() + { + $this->hasInscripcion = new \Doctrine\Common\Collections\ArrayCollection(); + } /** * Set nombre @@ -55,6 +121,52 @@ class Seccion } /** + * Set aula + * + * @param string $aula + * @return Seccion + */ + public function setAula($aula) + { + $this->aula = $aula; + + return $this; + } + + /** + * Get aula + * + * @return string + */ + public function getAula() + { + return $this->aula; + } + + /** + * Set cupo + * + * @param string $cupo + * @return Seccion + */ + public function setCupo($cupo) + { + $this->cupo = $cupo; + + return $this; + } + + /** + * Get cupo + * + * @return string + */ + public function getCupo() + { + return $this->cupo; + } + + /** * Get id * * @return integer @@ -63,13 +175,116 @@ class Seccion { return $this->id; } + + /** + * Add hasInscripcion + * + * @param \AppBundle\Entity\Inscripcion $hasInscripcion + * @return Seccion + */ + public function addHasInscripcion(\AppBundle\Entity\Inscripcion $hasInscripcion) + { + $this->hasInscripcion[] = $hasInscripcion; + + return $this; + } + + /** + * Remove hasInscripcion + * + * @param \AppBundle\Entity\Inscripcion $hasInscripcion + */ + public function removeHasInscripcion(\AppBundle\Entity\Inscripcion $hasInscripcion) + { + $this->hasInscripcion->removeElement($hasInscripcion); + } + + /** + * Get hasInscripcion + * + * @return \Doctrine\Common\Collections\Collection + */ + public function getHasInscripcion() + { + return $this->hasInscripcion; + } + + /** + * Set idTurno + * + * @param \AppBundle\Entity\Turno $idTurno + * @return Seccion + */ + public function setIdTurno(\AppBundle\Entity\Turno $idTurno) + { + $this->idTurno = $idTurno; + + return $this; + } + + /** + * Get idTurno + * + * @return \AppBundle\Entity\Turno + */ + public function getIdTurno() + { + return $this->idTurno; + } + + /** + * Set idRolInstitucion + * + * @param \AppBundle\Entity\RolInstitucion $idRolInstitucion + * @return Seccion + */ + public function setIdRolInstitucion(\AppBundle\Entity\RolInstitucion $idRolInstitucion) + { + $this->idRolInstitucion = $idRolInstitucion; + + return $this; + } + + /** + * Get idRolInstitucion + * + * @return \AppBundle\Entity\RolInstitucion + */ + public function getIdRolInstitucion() + { + return $this->idRolInstitucion; + } + + /** + * Set ofertaAcademica + * + * @param \AppBundle\Entity\OfertaAcademica $ofertaAcademica + * @return Seccion + */ + public function setOfertaAcademica(\AppBundle\Entity\OfertaAcademica $ofertaAcademica = null) + { + $this->ofertaAcademica = $ofertaAcademica; + + return $this; + } + + /** + * Get ofertaAcademica + * + * @return \AppBundle\Entity\OfertaAcademica + */ + public function getOfertaAcademica() + { + return $this->ofertaAcademica; + } /** * * @return string */ - public function __toString() { + public function __toString() + { return $this->getNombre(); } -} \ No newline at end of file +} diff --git a/src/AppBundle/Entity/Seccion.php~ b/src/AppBundle/Entity/Seccion.php~ new file mode 100644 index 0000000..7e5aa9c --- /dev/null +++ b/src/AppBundle/Entity/Seccion.php~ @@ -0,0 +1,90 @@ +getNombre(); + } +} \ No newline at end of file diff --git a/src/AppBundle/Entity/UnidadCurricular.php b/src/AppBundle/Entity/UnidadCurricular.php index 7e86fd5..51ccd04 100644 --- a/src/AppBundle/Entity/UnidadCurricular.php +++ b/src/AppBundle/Entity/UnidadCurricular.php @@ -161,7 +161,8 @@ class UnidadCurricular * @return string */ - public function __toString() { + public function __toString() + { return $this->getNombre(); } } diff --git a/src/AppBundle/Entity/UnidadCurricularVolumen.php b/src/AppBundle/Entity/UnidadCurricularVolumen.php index 591d0f7..e7ea482 100644 --- a/src/AppBundle/Entity/UnidadCurricularVolumen.php +++ b/src/AppBundle/Entity/UnidadCurricularVolumen.php @@ -101,4 +101,8 @@ class UnidadCurricularVolumen { return $this->idUnidadCurricular; } + + public function __toString() { + return $this->getIdUnidadCurricular(); + } } diff --git a/src/AppBundle/Form/InscripcionEditType.php b/src/AppBundle/Form/InscripcionEditType.php index f7c20f0..1d5e6a0 100644 --- a/src/AppBundle/Form/InscripcionEditType.php +++ b/src/AppBundle/Form/InscripcionEditType.php @@ -16,7 +16,7 @@ class InscripcionEditType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $builder - ->add('idOfertaAcademica') + ->add('idSeccion') ->add('idEstatus') ; diff --git a/src/AppBundle/Form/InscripcionType.php b/src/AppBundle/Form/InscripcionType.php index 40b060f..55cbc7c 100644 --- a/src/AppBundle/Form/InscripcionType.php +++ b/src/AppBundle/Form/InscripcionType.php @@ -26,10 +26,10 @@ class InscripcionType extends AbstractType /*->add('idRolInstitucion') ->add('idOfertaAcademica') ->add('idEstatus')*/ - ->add('idOfertaAcademica', EntityType::class, array( + ->add('idSeccion', EntityType::class, array( 'class' => 'AppBundle:OfertaAcademica', 'expanded' => true, - 'multiple' => true, + 'multiple' => true, 'query_builder' => function (EntityRepository $er) { return $er->createQueryBuilder('u') ->orderBy('u.idMallaCurricularUc', 'ASC') @@ -40,7 +40,7 @@ class InscripcionType extends AbstractType 2 => 1, )); ;}, - 'group_by' => 'idSeccion' + )) ; diff --git a/src/AppBundle/Form/OfertaAcademicaType.php b/src/AppBundle/Form/OfertaAcademicaType.php index ebcda96..9bf8f4c 100644 --- a/src/AppBundle/Form/OfertaAcademicaType.php +++ b/src/AppBundle/Form/OfertaAcademicaType.php @@ -5,7 +5,6 @@ namespace AppBundle\Form; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; -use Symfony\Bridge\Doctrine\Form\Type\EntityType; class OfertaAcademicaType extends AbstractType { @@ -15,31 +14,8 @@ class OfertaAcademicaType extends AbstractType */ public function buildForm(FormBuilderInterface $builder, array $options) { - $builder - ->add('idMallaCurricularUc', EntityType::class, array( - 'label' => false, - 'placeholder' => 'Seleccione Unidad Curricular', - 'class' => 'AppBundle:MallaCurricularUc', - 'choice_label' => 'idUnidadCurricularVolumen.idUnidadCurricular', - 'group_by' => function($val, $key, $index) { - - return "Trayecto: " . $val->getIdTrayectoTramoModalidadTipoUc()->getIdTrayecto() - . " Tramo: " . $val->getIdTrayectoTramoModalidadTipoUc()->getIdTramo() . ". " - . $val->getIdTrayectoTramoModalidadTipoUc()->getIdModalidad() - . "( " . $val->getIdTrayectoTramoModalidadTipoUc()->getIdTipoUc() . " )" - ; - }, - - )) - ->add('idTurno') - ->add('idSeccion') - ->add('aula') - ->add('cupo') - ->add('idRolInstitucion', EntityType::class, array( - 'class' => 'AppBundle:RolInstitucion', - 'placeholder' => 'Seleccione Docente a Dictar UC', - 'label' => false - )) + $builder + ->add('idMallaCurricularUc') ->add('idOfertaMallaCurricular') ; } diff --git a/src/AppBundle/Form/SeccionType.php b/src/AppBundle/Form/SeccionType.php new file mode 100644 index 0000000..0b8c842 --- /dev/null +++ b/src/AppBundle/Form/SeccionType.php @@ -0,0 +1,36 @@ +add('nombre') + ->add('aula') + ->add('cupo') + ->add('idTurno') + ->add('idRolInstitucion') + ->add('ofertaAcademica') + ; + } + + /** + * @param OptionsResolver $resolver + */ + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults(array( + 'data_class' => 'AppBundle\Entity\Seccion' + )); + } +} diff --git a/src/AppBundle/Tests/Controller/SeccionControllerTest.php b/src/AppBundle/Tests/Controller/SeccionControllerTest.php new file mode 100644 index 0000000..25d1b99 --- /dev/null +++ b/src/AppBundle/Tests/Controller/SeccionControllerTest.php @@ -0,0 +1,55 @@ +request('GET', '/ceapp/gestion/oferta_academica/seccion/'); + $this->assertEquals(200, $client->getResponse()->getStatusCode(), "Unexpected HTTP status code for GET /ceapp/gestion/oferta_academica/seccion/"); + $crawler = $client->click($crawler->selectLink('Create a new entry')->link()); + + // Fill in the form and submit it + $form = $crawler->selectButton('Create')->form(array( + 'appbundle_seccion[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( + 'appbundle_seccion[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