From 32adfbad7bf2100bdee5d1b4e3ea823b74d0494c Mon Sep 17 00:00:00 2001 From: Wilmer Ramones Date: Fri, 14 Oct 2016 12:35:14 -0400 Subject: [PATCH] creada la estructura, la entidad, el controlador, la vista y la plantilla para solicitar ascenso --- app/Resources/views/base_app.html.twig | 2 +- app/Resources/views/solicitudes/ascenso.html.twig | 60 +++ src/AppBundle/Controller/AscensoController.php | 173 +++++++++ src/AppBundle/Entity/Ascenso.php | 444 ++++++++++++++++++++++ src/AppBundle/Entity/Ascenso.php~ | 421 ++++++++++++++++++++ src/AppBundle/Form/AscensoType.php | 175 +++++++++ 6 files changed, 1274 insertions(+), 1 deletion(-) create mode 100644 app/Resources/views/solicitudes/ascenso.html.twig create mode 100644 src/AppBundle/Controller/AscensoController.php create mode 100644 src/AppBundle/Entity/Ascenso.php create mode 100644 src/AppBundle/Entity/Ascenso.php~ create mode 100644 src/AppBundle/Form/AscensoType.php diff --git a/app/Resources/views/base_app.html.twig b/app/Resources/views/base_app.html.twig index 643391f..b25babb 100644 --- a/app/Resources/views/base_app.html.twig +++ b/app/Resources/views/base_app.html.twig @@ -59,7 +59,7 @@ diff --git a/app/Resources/views/solicitudes/ascenso.html.twig b/app/Resources/views/solicitudes/ascenso.html.twig new file mode 100644 index 0000000..4dd4205 --- /dev/null +++ b/app/Resources/views/solicitudes/ascenso.html.twig @@ -0,0 +1,60 @@ +{% extends 'base_app.html.twig' %} + +{% block stylesheets %} + {{ parent() }} + + +{% endblock %} + + + +{% block body %} +
+

+ Estimado (a) Docente + {{app.user.idRolInstitucion.idRol.idPersona.primerNombre}} + {{app.user.idRolInstitucion.idRol.idPersona.primerApellido}}, + En este apartado usted podrá solicitar el ascenso al siguiente escalafón. + +

+
+
+
+

Solicitud de Ascenso

+ {% form_theme form 'bootstrap_3_layout.html.twig' %} + {{ form_start(form) }} + {{ form_widget(form) }} + {{ form_end(form) }} +
+ +
+ + +{% endblock %} + + + + +{% block javascripts %} + {{ parent() }} + +{% endblock %} diff --git a/src/AppBundle/Controller/AscensoController.php b/src/AppBundle/Controller/AscensoController.php new file mode 100644 index 0000000..f091c68 --- /dev/null +++ b/src/AppBundle/Controller/AscensoController.php @@ -0,0 +1,173 @@ +getDoctrine()->getRepository('AppBundle:DocenteEscala')->findOneBy( + array('idRolInstitucion' => $this->getUser()->getIdRolInstitucion()), + array('id' => 'DESC') + ); + + $siguiente = $escala->getIdEscala()->getId() + 1; + $ascenso = new Ascenso(); + if($siguiente < 6){ + $nueva_escala = $this->getDoctrine()->getRepository('AppBundle:Escalafones')->findOneById($siguiente); + } + + + + + + $form = $this->createForm('AppBundle\Form\AscensoType'); + $form->handleRequest($request); + + + if ($form->isSubmitted() && $form->isValid()) { + + $ascenso = new Ascenso(); + // $file stores the uploaded PDF file + /** @var UploadedFile $constanciaTrabajo */ + $constanciaTrabajo = $form->get('trabajo')->getData(); + /** @var UploadedFile $constanciaPregrado */ + $constanciaExpediente = $form->get('expediente')->getData(); + /** @var UploadedFile $constanciaPregrado */ + $constanciaPida = $form->get('pida')->getData(); + /** @var UploadedFile $constanciaPregrado */ + $constanciaNai = $form->get('nai')->getData(); + /** @var UploadedFile $constanciaPregrado */ + $constanciaInvestigacion = $form->get('investigacion')->getData(); + + + + // Generate a unique name for the file before saving it + $nombreTrabajo = md5(uniqid()).'.'.$constanciaTrabajo->guessExtension(); + $nombreExpediente = md5(uniqid()).'.'.$constanciaExpediente->guessExtension(); + $nombrePida = md5(uniqid()).'.'.$constanciaPida->guessExtension(); + $nombreNai = md5(uniqid()).'.'.$constanciaNai->guessExtension(); + $nombreInvestigacion = md5(uniqid()).'.'.$constanciaInvestigacion->guessExtension(); + + // Guardar el archivo y crear la miniatura de cada uno + $constanciaTrabajo->move( + $this->container->getParameter('ascenso_directory'), + $nombreTrabajo + ); + thumbnail($nombreTrabajo, $this->container->getParameter('ascenso_directory'), $this->container->getParameter('ascenso_thumb_directory')); + + + $constanciaExpediente->move( + $this->container->getParameter('ascenso_directory'), + $nombreExpediente + ); + thumbnail($nombreExpediente, $this->container->getParameter('ascenso_directory'), $this->container->getParameter('ascenso_thumb_directory')); + + $constanciaPida->move( + $this->container->getParameter('ascenso_directory'), + $nombrePida + ); + thumbnail($nombrePida, $this->container->getParameter('ascenso_directory'), $this->container->getParameter('ascenso_thumb_directory')); + + + $constanciaNai->move( + $this->container->getParameter('ascenso_directory'), + $nombreNai + ); + thumbnail($nombreNai, $this->container->getParameter('ascenso_directory'), $this->container->getParameter('ascenso_thumb_directory')); + + if($form->get('investigacion')->getData()) { + /** @var UploadedFile $constanciaPostgrado */ + $constanciaInvestigacion = $form->get('investigacion')->getData(); + $nombreInvestigacion = md5(uniqid()).'.'.$constanciaInvestigacion->guessExtension(); + $constanciaInvestigacion->move( + $this->container->getParameter('ascenso_directory'), + $nombreInvestigacion + ); + thumbnail($nombreInvestigacion, $this->container->getParameter('ascenso_directory'), $this->container->getParameter('ascenso_thumb_directory')); + $ascenso->setInvestigacion($nombreInvestigacion); + } + $em = $this->getDoctrine()->getManager(); + + $ascenso->setTrabajo($nombreTrabajo); + $ascenso->setExpediente($nombreExpediente); + $ascenso->setIdRolInstitucion($this->getUser()->getIdRolInstitucion()); + $ascenso->setPida($nombrePida); + $ascenso->setNai($nombreNai); + $ascenso->setInvestigacion($nombreInvestigacion); + $ascenso->setTituloTrabajo($form->get('titulo_trabajo')->getData()); + $ascenso->setIdEscalafones($nueva_escala); + $ascenso->setIdEstatus($this->getDoctrine()->getRepository('AppBundle:Estatus')->findOneById(2)); + + + if ($form->get('pertinencia')->getData()){ + + $constanciaPertinencia = $form->get('pertinencia')->getData(); + $nombrePertinencia = md5(uniqid()).'.'.$constanciaPertinencia->guessExtension(); + $constanciaPertinencia->move( + $this->container->getParameter('ascenso_directory'), + $nombrePertinencia + ); + thumbnail($nombrePertinencia, $this->container->getParameter('ascenso_directory'), $this->container->getParameter('ascenso_thumb_directory')); + $ascenso->setPertinencia($nombrePertinencia); + $ascenso->setIdLineaInvestigacion($form->get('lineas_investigacion')->getData()); + + } + + + + + //Crear la solicitud de Servicio + $servicios = new DocenteServicio(); + + $servicios->setIdRolInstitucion($this->getUser()->getIdRolInstitucion()); + $servicios->setIdServicioCe($this->getDoctrine()->getRepository('AppBundle:ServiciosCe')->findOneById(5)); + $servicios->setIdEstatus($this->getDoctrine()->getRepository('AppBundle:estatus')->findOneById(2)); + + $em->persist($servicios); + $em->persist($ascenso); + + $em->flush(); //guarda en la base de datos + + + + + return $this->redirect($this->generateUrl('cea_index')); + } + + return $this->render( + 'solicitudes/ascenso.html.twig', + array('form' => $form->createView()) + ); + } + + + +} + diff --git a/src/AppBundle/Entity/Ascenso.php b/src/AppBundle/Entity/Ascenso.php new file mode 100644 index 0000000..c6464c6 --- /dev/null +++ b/src/AppBundle/Entity/Ascenso.php @@ -0,0 +1,444 @@ +fecha_creacion = new \DateTime(); + $this->fecha_ultima_actualizacion = new \DateTime(); + } + + public function getFechaCreacion() + { + return $this->fecha_creacion; + + } + + + /** + * @ORM\PreUpdate + */ + public function setFechaUltimaActualizacion() + { + $this->fecha_utlima_actualizacion = new \DateTime(); + } + + + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set trabajo + * + * @param string $trabajo + * @return Ascenso + */ + public function setTrabajo($trabajo) + { + $this->trabajo = $trabajo; + + return $this; + } + + /** + * Get trabajo + * + * @return string + */ + public function getTrabajo() + { + return $this->trabajo; + } + + /** + * Set expediente + * + * @param string $expediente + * @return Ascenso + */ + public function setExpediente($expediente) + { + $this->expediente = $expediente; + + return $this; + } + + /** + * Get expediente + * + * @return string + */ + public function getExpediente() + { + return $this->expediente; + } + + /** + * Set pida + * + * @param string $pida + * @return Ascenso + */ + public function setPida($pida) + { + $this->pida = $pida; + + return $this; + } + + /** + * Get pida + * + * @return string + */ + public function getPida() + { + return $this->pida; + } + + /** + * Set nai + * + * @param string $nai + * @return Ascenso + */ + public function setNai($nai) + { + $this->nai = $nai; + + return $this; + } + + /** + * Get nai + * + * @return string + */ + public function getNai() + { + return $this->nai; + } + + /** + * Set investigacion + * + * @param string $investigacion + * @return Ascenso + */ + public function setInvestigacion($investigacion) + { + $this->investigacion = $investigacion; + + return $this; + } + + /** + * Get investigacion + * + * @return string + */ + public function getInvestigacion() + { + return $this->investigacion; + } + + /** + * Set pertinencia + * + * @param string $pertinencia + * @return Ascenso + */ + public function setPertinencia($pertinencia) + { + $this->pertinencia = $pertinencia; + + return $this; + } + + /** + * Get pertinencia + * + * @return string + */ + public function getPertinencia() + { + return $this->pertinencia; + } + + /** + * Set tituloTrabajo + * + * @param string $tituloTrabajo + * @return Ascenso + */ + public function setTituloTrabajo($tituloTrabajo) + { + $this->tituloTrabajo = $tituloTrabajo; + + return $this; + } + + /** + * Get tituloTrabajo + * + * @return string + */ + public function getTituloTrabajo() + { + return $this->tituloTrabajo; + } + + /** + * Set observacion + * + * @param string $observacion + * @return Ascenso + */ + public function setObservacion($observacion) + { + $this->observacion = $observacion; + + return $this; + } + + /** + * Get observacion + * + * @return string + */ + public function getObservacion() + { + return $this->observacion; + } + + /** + * Get fecha_ultima_actualizacion + * + * @return \DateTime + */ + public function getFechaUltimaActualizacion() + { + return $this->fecha_ultima_actualizacion; + } + + /** + * Set idRolInstitucion + * + * @param \AppBundle\Entity\RolInstitucion $idRolInstitucion + * @return Ascenso + */ + 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 idEstatus + * + * @param \AppBundle\Entity\Estatus $idEstatus + * @return Ascenso + */ + public function setIdEstatus(\AppBundle\Entity\Estatus $idEstatus) + { + $this->idEstatus = $idEstatus; + + return $this; + } + + /** + * Get idEstatus + * + * @return \AppBundle\Entity\Estatus + */ + public function getIdEstatus() + { + return $this->idEstatus; + } + + + + + + /** + * Set idEscalafones + * + * @param \AppBundle\Entity\Escalafones $idEscalafones + * @return Ascenso + */ + public function setIdEscalafones(\AppBundle\Entity\Escalafones $idEscalafones) + { + $this->idEscalafones = $idEscalafones; + + return $this; + } + + /** + * Get idEscalafones + * + * @return \AppBundle\Entity\Escalafones + */ + public function getIdEscalafones() + { + return $this->idEscalafones; + } +} diff --git a/src/AppBundle/Entity/Ascenso.php~ b/src/AppBundle/Entity/Ascenso.php~ new file mode 100644 index 0000000..602ffd8 --- /dev/null +++ b/src/AppBundle/Entity/Ascenso.php~ @@ -0,0 +1,421 @@ +fecha_creacion = new \DateTime(); + $this->fecha_ultima_actualizacion = new \DateTime(); + } + + public function getFechaCreacion() + { + return $this->fecha_creacion; + + } + + + /** + * @ORM\PreUpdate + */ + public function setFechaUltimaActualizacion() + { + $this->fecha_utlima_actualizacion = new \DateTime(); + } + + + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set trabajo + * + * @param string $trabajo + * @return Ascenso + */ + public function setTrabajo($trabajo) + { + $this->trabajo = $trabajo; + + return $this; + } + + /** + * Get trabajo + * + * @return string + */ + public function getTrabajo() + { + return $this->trabajo; + } + + /** + * Set expediente + * + * @param string $expediente + * @return Ascenso + */ + public function setExpediente($expediente) + { + $this->expediente = $expediente; + + return $this; + } + + /** + * Get expediente + * + * @return string + */ + public function getExpediente() + { + return $this->expediente; + } + + /** + * Set pida + * + * @param string $pida + * @return Ascenso + */ + public function setPida($pida) + { + $this->pida = $pida; + + return $this; + } + + /** + * Get pida + * + * @return string + */ + public function getPida() + { + return $this->pida; + } + + /** + * Set nai + * + * @param string $nai + * @return Ascenso + */ + public function setNai($nai) + { + $this->nai = $nai; + + return $this; + } + + /** + * Get nai + * + * @return string + */ + public function getNai() + { + return $this->nai; + } + + /** + * Set investigacion + * + * @param string $investigacion + * @return Ascenso + */ + public function setInvestigacion($investigacion) + { + $this->investigacion = $investigacion; + + return $this; + } + + /** + * Get investigacion + * + * @return string + */ + public function getInvestigacion() + { + return $this->investigacion; + } + + /** + * Set pertinencia + * + * @param string $pertinencia + * @return Ascenso + */ + public function setPertinencia($pertinencia) + { + $this->pertinencia = $pertinencia; + + return $this; + } + + /** + * Get pertinencia + * + * @return string + */ + public function getPertinencia() + { + return $this->pertinencia; + } + + /** + * Set tituloTrabajo + * + * @param string $tituloTrabajo + * @return Ascenso + */ + public function setTituloTrabajo($tituloTrabajo) + { + $this->tituloTrabajo = $tituloTrabajo; + + return $this; + } + + /** + * Get tituloTrabajo + * + * @return string + */ + public function getTituloTrabajo() + { + return $this->tituloTrabajo; + } + + /** + * Set observacion + * + * @param string $observacion + * @return Ascenso + */ + public function setObservacion($observacion) + { + $this->observacion = $observacion; + + return $this; + } + + /** + * Get observacion + * + * @return string + */ + public function getObservacion() + { + return $this->observacion; + } + + /** + * Get fecha_ultima_actualizacion + * + * @return \DateTime + */ + public function getFechaUltimaActualizacion() + { + return $this->fecha_ultima_actualizacion; + } + + /** + * Set idRolInstitucion + * + * @param \AppBundle\Entity\RolInstitucion $idRolInstitucion + * @return Ascenso + */ + 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 idEstatus + * + * @param \AppBundle\Entity\Estatus $idEstatus + * @return Ascenso + */ + public function setIdEstatus(\AppBundle\Entity\Estatus $idEstatus) + { + $this->idEstatus = $idEstatus; + + return $this; + } + + /** + * Get idEstatus + * + * @return \AppBundle\Entity\Estatus + */ + public function getIdEstatus() + { + return $this->idEstatus; + } + + + + +} diff --git a/src/AppBundle/Form/AscensoType.php b/src/AppBundle/Form/AscensoType.php new file mode 100644 index 0000000..e903018 --- /dev/null +++ b/src/AppBundle/Form/AscensoType.php @@ -0,0 +1,175 @@ +add('trabajo', FileType::class, array( + 'label' => 'Digital Constancia Trabajo Actualizada', + 'constraints' => array( + new NotBlank(), + new File(array( + 'maxSize' => '1024K', + 'mimeTypes' => [ + 'application/pdf', + 'application/x-pdf', + 'image/png', + 'image/jpg', + 'image/jpeg' + ], + 'mimeTypesMessage' => 'Sólo se permiten extensiones png, jpeg y pdf' + )) + ) + )) + ->add('expediente', FileType::class, array( + 'label' => 'Digital Actualización de Expediente', + 'constraints' => array( + new NotBlank(), + new File(array( + 'maxSize' => '1024K', + 'mimeTypes' => [ + 'application/pdf', + 'application/x-pdf', + 'image/png', + 'image/jpg', + 'image/jpeg' + ], + 'mimeTypesMessage' => 'Sólo se permiten extensiones png, jpeg y pdf' + )) + ) + )) + + ->add('pida', FileType::class, array( + 'label' => 'Digital Socialización del PIDA', + 'required' => true, + 'constraints' => array( + new File(array( + 'maxSize' => '1024K', + 'mimeTypes' => [ + 'application/pdf', + 'application/x-pdf', + 'image/png', + 'image/jpg', + 'image/jpeg' + ], + 'mimeTypesMessage' => 'Sólo se permiten extensiones png, jpeg y pdf' + )) + ) + )) + + ->add('nai', FileType::class, array( + 'label' => 'Digital Aval del NAI', + 'required' => true, + 'constraints' => array( + new File(array( + 'maxSize' => '1024K', + 'mimeTypes' => [ + 'application/pdf', + 'application/x-pdf', + 'image/png', + 'image/jpg', + 'image/jpeg' + ], + 'mimeTypesMessage' => 'Sólo se permiten extensiones png, jpeg y pdf' + )) + ) + )) + + ->add('titulo_trabajo', TextType::class, array( + 'label' => 'Título del Trabajo de Investigación', + + 'required' => true, + + )) + + + ->add('investigacion', FileType::class, array( + 'label' => 'Digital Trabajo de investigación / Tesis', + 'required' => true, + 'constraints' => array( + new File(array( + 'maxSize' => '1024K', + 'mimeTypes' => [ + 'application/pdf', + 'application/x-pdf', + 'image/png', + 'image/jpg', + 'image/jpeg' + ], + 'mimeTypesMessage' => 'Sólo se permiten extensiones png, jpeg y pdf' + )) + ) + )) + + + ->add('tipoTrabajoInvestigacion', CheckboxType::class, array( + 'label' => 'Si su trabajo de investigación es TESIS, responda ¿Fue dentro de la UBV?', + 'required' => false, + )) + + ->add('pertinencia', FileType::class, array( + 'label' => 'Informe de Pertinencia', + 'label_attr' => array( 'class' => 'esc_oposicion'), + 'required' => false, + 'attr' => array( + 'style' => 'display:none;', + 'class' => 'esc_oposicion' + ), + 'constraints' => array( + new File(array( + 'maxSize' => '1024K', + 'mimeTypes' => [ + 'application/pdf', + 'application/x-pdf', + 'image/png', + 'image/jpg', + 'image/jpeg' + ], + 'mimeTypesMessage' => 'Sólo se permiten extensiones png, jpeg y pdf' + )) + ) + )) + + + + + ->add('send', SubmitType::class, array( + 'label' => 'Crear Solicitud de Ascenso', + 'attr' => array('class' => 'btn btn-success btn-block') + )) + + + ; + + + } + + + + +} -- 2.0.0