private function fillEntity($entity, $data)
 {
     $camposObligatorios = array('nombre', 'nombreI', 'codigo', 'caracter', 'creditos', 'curso', 'coordinador');
     if (Herramientas::allFields($camposObligatorios, $data)) {
         $em = $this->getDoctrine()->getManager();
         $coordinador = $em->getRepository('EtsiAppGuiasBundle:Profesor')->find($data['coordinador']);
         $entity->setNombre($data['nombre']);
         $entity->setNombreI($data['nombreI']);
         $entity->setCodigo($data['codigo']);
         $entity->setCaracter($data['caracter']);
         $entity->setCreditos($data['creditos']);
         $entity->setCurso($data['curso']);
         $entity->setCuatrimestre($data['cuatrimestre']);
         $entity->setCoordinador($coordinador);
         $entity->clearGrados();
         if (isset($data['grados']) && !empty($data['grados'])) {
             foreach ($data['grados'] as $value) {
                 $grado = $em->getRepository('EtsiAppGuiasBundle:Grado')->find($value);
                 $entity->addGrado($grado);
             }
         }
         $entity->clearAreas();
         if (isset($data['areas']) && !empty($data['areas'])) {
             foreach ($data['areas'] as $value) {
                 $area = $em->getRepository('EtsiAppGuiasBundle:Area')->find($value);
                 $entity->addArea($area);
             }
         }
         $em->persist($entity);
         $em->flush();
         return true;
     }
     return false;
 }
Example #2
0
 private function fillEntity($entity, $data)
 {
     $camposObligatorios = array('nombre', 'email', 'password', 'tlf');
     if (Herramientas::allFields($camposObligatorios, $data)) {
         $em = $this->getDoctrine()->getManager();
         $entity->setNombre($data['nombre']);
         $entity->setEmail($data['email']);
         $entity->setTlf($data['tlf']);
         if ($data['password'] != $entity->getPassword()) {
             $entity->setSalt(md5(time()));
             $encoder = new \Symfony\Component\Security\Core\Encoder\MessageDigestPasswordEncoder('sha512', true, 10);
             $password = $encoder->encodePassword($data['password'], $entity->getSalt());
             $entity->setPassword($password);
         }
         $entity->clearRoles();
         if (isset($data['roles']) && !empty($data['roles'])) {
             foreach ($data['roles'] as $value) {
                 $rol = $em->getRepository('EtsiAppGuiasBundle:Rol')->find($value);
                 $entity->addRole($rol);
             }
         }
         $em->persist($entity);
         $em->flush();
         return true;
     }
     return false;
 }
Example #3
0
 private function fillEntity($entity, $data)
 {
     $camposObligatorios = array('nombre', 'departamento');
     if (Herramientas::allFields($camposObligatorios, $data)) {
         $em = $this->getDoctrine()->getManager();
         $entity->setNombre($data['nombre']);
         $entity->setDepartamento($data['departamento']);
         $em->persist($entity);
         $em->flush();
         return true;
     }
     return false;
 }
Example #4
0
 private function fillEntity($entity, $data)
 {
     $camposObligatorios = array('nombre');
     if (Herramientas::allFields($camposObligatorios, $data)) {
         $em = $this->getDoctrine()->getManager();
         $entity->setNombre($data['nombre']);
         $padre = $em->getRepository('EtsiAppGuiasBundle:Grado')->find($data['gradoPadre']);
         $entity->setGradoPadre($padre);
         $em->persist($entity);
         $em->flush();
         return true;
     }
     return false;
 }
Example #5
0
 private function fillEntity($entity, $data)
 {
     $camposObligatorios = array('numeroSemana', 'horasGruposGrandes', 'horasGruposReducidosAula', 'horasGruposReducidosInformatica', 'horasGruposReducidosLaboratorio', 'horasGruposReducidosCampo', 'examen', 'observaciones');
     if (Herramientas::allFields($camposObligatorios, $data)) {
         $entity->setNumeroSemana($data['numeroSemana']);
         $entity->setHorasGruposGrandes($data['horasGruposGrandes']);
         $entity->setHorasGruposReducidosAula($data['horasGruposReducidosAula']);
         $entity->setHorasGruposReducidosInformatica($data['horasGruposReducidosInformatica']);
         $entity->setHorasGruposReducidosLaboratorio($data['horasGruposReducidosLaboratorio']);
         $entity->setHorasGruposReducidosCampo($data['horasGruposReducidosCampo']);
         $entity->setExamen($data['examen']);
         $entity->setObservaciones($data['observaciones']);
         $em = $this->getDoctrine()->getManager();
         $em->persist($entity);
         $em->flush();
         return true;
     }
     return false;
 }
Example #6
0
 public function getPdfAction($id)
 {
     $em = $this->getDoctrine()->getManager();
     $guia = $em->getRepository('EtsiAppGuiasBundle:Guia')->find($id);
     if ($guia) {
         $facade = $this->get('ps_pdf.facade');
         $response = new Response();
         $this->render('EtsiAppGuiasBundle:PDF:guia.pdf.twig', array('guia' => $guia), $response);
         $documentXml = $response->getContent();
         $this->render('EtsiAppGuiasBundle:PDF:guia.style.twig', array(), $response);
         $stylesheetXml = $response->getContent();
         $content = $facade->render($documentXml, $stylesheetXml);
         $asignatura = $guia->getAsignatura();
         $curso = $asignatura->getCurso();
         $nombre = Herramientas::slugify($asignatura->getNombre());
         $header = array('content-type' => 'application/pdf', 'Content-Disposition' => 'attachment; filename="' . $asignatura->getId() . '.pdf"');
         return new Response($content, 200, $header);
     }
     return $this->indexAction(array('error' => array('No se ha podido cargar la guía')));
 }