コード例 #1
0
 /**
  * Index de mercado laboral
  * 
  * @Route("/", name="mercado_laboral")
  * @Template("vocationetBundle:MercadoLaboral:index.html.twig")
  * @param Request $request Request enviado con alternativas de estudio seleccionadas
  * @Method({"GET", "POST"})
  * @return Response
  */
 public function indexAction(Request $request)
 {
     $security = $this->get('security');
     if (!$security->authentication()) {
         return $this->redirect($this->generateUrl('login'));
     }
     if (!$security->authorization($this->getRequest()->get('_route'))) {
         throw $this->createNotFoundException($this->get('translator')->trans("Acceso denegado"));
     }
     $usuarioId = $security->getSessionValue('id');
     // Verificar pago
     $pago = $this->verificarPago($usuarioId);
     if (!$pago) {
         $this->get('session')->getFlashBag()->add('alerts', array("type" => "error", "title" => $this->get('translator')->trans("no.existe.pago"), "text" => $this->get('translator')->trans("antes.de.continuar.debes.realizar.el.pago")));
         return $this->redirect($this->generateUrl('planes'));
     }
     $em = $this->getDoctrine()->getManager();
     $productoPago = $this->get('pagos')->verificarPagoProducto($this->get('pagos')->getProductoId('programa_orientacion'), $usuarioId);
     if ($productoPago) {
         $return = $this->get('perfil')->validarPosicionActual($usuarioId, 'mercadolaboral');
         if (!$return['status']) {
             $this->get('session')->getFlashBag()->add('alerts', array("type" => "error", "title" => $this->get('translator')->trans("Acceso denegado"), "text" => $this->get('translator')->trans($return['message'])));
             return $this->redirect($this->generateUrl($return['redirect']));
         }
     }
     $form_id = $this->get('formularios')->getFormId('mercado_laboral');
     $participacion = $em->getRepository("vocationetBundle:Participaciones")->findOneBy(array("formulario" => $form_id, "usuarioParticipa" => $usuarioId));
     if ($participacion) {
         return $this->forward("vocationetBundle:Alerts:alertScreen", array("title" => $this->get('translator')->trans("cuestionario.ya.ha.sido.enviado"), "message" => $this->get('translator')->trans("gracias.por.participar.mercado.laboral"), "file" => true, "path" => $participacion->getArchivoReporte()));
     }
     $formulario = $this->get('formularios')->getInfoFormulario($form_id);
     // En el caso de que NO tenga alternativas de estudio registradas se enlistan carreras para seleccionarlas
     $carreras = $em->getRepository('vocationetBundle:Carreras')->findAll();
     if ($request->getMethod() == "POST") {
         $errorCantidad = false;
         $errorAlternativa = false;
         $alternativas = $request->request->get('carrerasSeleccionadas');
         if (count($alternativas) > 0 && count($alternativas) <= 3) {
             $usuario = $em->getRepository('vocationetBundle:Usuarios')->findOneById($usuarioId);
             $auxAlternativas = '<br>';
             foreach ($alternativas as $alt) {
                 $carrera = $em->getRepository('vocationetBundle:Carreras')->findOneById($alt);
                 if ($carrera) {
                     $newAE = new AlternativasEstudios();
                     $newAE->setCarrera($carrera);
                     $newAE->setUsuario($usuario);
                     $em->persist($newAE);
                     $auxAlternativas .= '<br> - ' . $carrera->getNombre();
                 } else {
                     $errorAlternativa = true;
                 }
             }
             //Registro de que el usuario participo en el mercado laboral
             $participacion = new Participaciones();
             $participacion->setFormulario($form_id);
             $participacion->setFecha(new \DateTime());
             $participacion->setUsuarioParticipa($usuarioId);
             $participacion->setUsuarioEvaluado($usuarioId);
             $participacion->setEstado(1);
             $em->persist($participacion);
             $em->flush();
             $this->get('perfil')->actualizarpuntos('mercadolaboral', $usuarioId, array('cantidad' => count($alternativas)));
             $seleccionarMentor = $this->get('perfil')->confirmarMentorOrientacionVocacional($usuarioId);
             if ($seleccionarMentor) {
                 //Notificacion para mentor de que el estudiante  ha seleccionado alternativas de estudio
                 $name = $security->getSessionValue('usuarioNombre') . ' ' . $security->getSessionValue('usuarioApellido');
                 $dias = $security->getParameter('dias_habiles_informe_mercado_laboral');
                 $asunto = $this->get('translator')->trans('%name%.mail.mentor.estudiante.selecciona.alternativas', array('%name%' => $name), 'mail');
                 $message = $this->get('translator')->trans('%name%.ha.seleccionado%dias%.%alternativas%', array('%name%' => $name, '%alternativas%' => $auxAlternativas, '%dias%' => $dias), 'mail');
                 $this->get('mensajes')->enviarMensaje($usuarioId, array($seleccionarMentor['id']), $asunto, $message);
                 // Notificacion a estudiante de que el mentor tendra X tiempo para responder
                 $asunto = $this->get('translator')->trans('asunto.mail.mentor.informa.tiempo.espera', array(), 'mail');
                 $message = $this->get('translator')->trans('mentor.tiene.%dias%.dias.para.informe.de.alternativas.seleccionadas', array('%dias%' => $dias), 'mail');
                 $this->get('mensajes')->enviarMensaje($seleccionarMentor['id'], array($usuarioId), $asunto, $message);
             }
         } else {
             $errorCantidad = true;
         }
         if ($errorCantidad) {
             $this->get('session')->getFlashBag()->add('alerts', array("type" => "error", "title" => $this->get('translator')->trans("datos.invalidos"), "text" => $this->get('translator')->trans("verifique.los datos.suministrados")));
         }
         if ($errorAlternativa) {
             $this->get('session')->getFlashBag()->add('alerts', array("type" => "warning", "title" => $this->get('translator')->trans("datos.invalidos"), "text" => $this->get('translator')->trans("ocurrio.error.al.registrar.alternativa.de.estudio")));
         }
         return $this->redirect($this->generateUrl('mercado_laboral'));
     }
     return array('formulario_info' => $formulario, 'carreras' => $carreras);
 }
コード例 #2
0
 /**
  * Seleccion del mentores expertos - POST
  *
  * @author Camilo Quijano <*****@*****.**>
  * @version 1
  * @Route("/select_mentor_experto", name="seleccionar_mentor_experto")
  * @Method("POST")
  * @param Request $request Request enviado con ID de mentor seleccionado
  * @return Redirect
  */
 public function seleccionarMentorExpertoAction(Request $request)
 {
     $security = $this->get('security');
     if (!$security->authentication()) {
         return $this->redirect($this->generateUrl('login'));
     }
     if (!$security->authorization($this->getRequest()->get('_route'))) {
         throw $this->createNotFoundException($this->get('translator')->trans("Acceso denegado"));
     }
     $pr = $this->get('perfil');
     if ($request->getMethod() == 'POST') {
         $usuarioId = $security->getSessionValue('id');
         $mentorEId = $request->request->get('mentorE');
         $em = $this->getDoctrine()->getManager();
         $usuarioMentor = $em->getRepository('vocationetBundle:Usuarios')->findOneById($mentorEId);
         if ($usuarioMentor) {
             if ($usuarioMentor->getRol()->getId() == 2) {
                 // Relacion creada entre usuario y mentor
                 $user = $em->getRepository('vocationetBundle:Usuarios')->findOneBy(array('id' => $usuarioId));
                 $newR = new Relaciones();
                 $newR->setUsuario($usuarioMentor);
                 $newR->setUsuario2($user);
                 $newR->setTipo(3);
                 $newR->setCreated(new \DateTime());
                 $newR->setEstado(1);
                 $em->persist($newR);
                 //Registro de que el usuario participo en red de mentores
                 $form_id = $this->get('formularios')->getFormId('red_mentores');
                 $auxPart = $em->getRepository('vocationetBundle:Participaciones')->findOneBy(array('formulario' => $form_id, 'usuarioParticipa' => $usuarioId));
                 if (!$auxPart) {
                     $participacion = new Participaciones();
                     $participacion->setFormulario($form_id);
                     $participacion->setFecha(new \DateTime());
                     $participacion->setUsuarioParticipa($usuarioId);
                     $participacion->setUsuarioEvaluado($usuarioId);
                     $participacion->setEstado(1);
                     $em->persist($participacion);
                 }
                 $em->flush();
                 $this->get('session')->getFlashBag()->add('alerts', array("type" => "success", "title" => $this->get('translator')->trans("elegir.mentor"), "text" => $this->get('translator')->trans("ha.seleccionado.mentor.contactese.con.el")));
                 //return $this->redirect($this->generateUrl('agenda_estudiante'));
             } else {
                 // El usuario seleccionado no es Orientador Vocacional o no ha sido aprobado
                 $this->get('session')->getFlashBag()->add('alerts', array("type" => "error", "title" => $this->get('translator')->trans("error.elegir.mentor"), "text" => $this->get('translator')->trans("error.en.seleccion.de.mentor")));
             }
         } else {
             //El mentor seleccionado no existe
             $this->get('session')->getFlashBag()->add('alerts', array("type" => "error", "title" => $this->get('translator')->trans("error.elegir.mentor"), "text" => $this->get('translator')->trans("error.en.seleccion.de.mentor")));
         }
     }
     return $this->redirect($this->generateUrl('red_mentores'));
 }