| @@ 188-212 (lines=25) @@ | ||
| 185 | * @Route("/importar", name="alumno_importar",methods={"GET", "POST"}) |
|
| 186 | * @Security("has_role('ROLE_DIRECTIVO')") |
|
| 187 | */ |
|
| 188 | public function importarAction(Request $request) |
|
| 189 | { |
|
| 190 | $datos = new Importar(); |
|
| 191 | $form = $this->createForm(new ImportarType(), $datos); |
|
| 192 | $form->handleRequest($request); |
|
| 193 | ||
| 194 | if ($form->isSubmitted() && $form->isValid()) { |
|
| 195 | ||
| 196 | if ($this->importarAlumnadoDesdeCsv($datos->getFichero()->getPathname())) { |
|
| 197 | $this->addFlash('success', 'Los datos se han importado correctamente'); |
|
| 198 | } |
|
| 199 | else { |
|
| 200 | $this->addFlash('error', 'Ha ocurrido un error en la importación'); |
|
| 201 | } |
|
| 202 | ||
| 203 | return new RedirectResponse( |
|
| 204 | $this->generateUrl('alumno_listar_todo') |
|
| 205 | ); |
|
| 206 | } |
|
| 207 | ||
| 208 | return $this->render('AppBundle:Alumno:importar.html.twig', |
|
| 209 | array( |
|
| 210 | 'formulario' => $form->createView() |
|
| 211 | )); |
|
| 212 | } |
|
| 213 | } |
|
| 214 | ||
| @@ 41-66 (lines=26) @@ | ||
| 38 | * @Route("/modificar/{curso}", name="curso_modificar",methods={"GET", "POST"}) |
|
| 39 | * @Security("has_role('ROLE_ADMIN')") |
|
| 40 | */ |
|
| 41 | public function modificarAction(Curso $curso, Request $peticion) |
|
| 42 | { |
|
| 43 | $formulario = $this->createForm(new CursoType(), $curso); |
|
| 44 | ||
| 45 | $formulario->handleRequest($peticion); |
|
| 46 | ||
| 47 | if ($formulario->isSubmitted() && $formulario->isValid()) { |
|
| 48 | ||
| 49 | // Guardar el usuario en la base de datos |
|
| 50 | $em = $this->getDoctrine()->getManager(); |
|
| 51 | ||
| 52 | $em->flush(); |
|
| 53 | ||
| 54 | $this->addFlash('success', 'Datos guardados correctamente'); |
|
| 55 | ||
| 56 | return new RedirectResponse( |
|
| 57 | $this->generateUrl('grupo_listar') |
|
| 58 | ); |
|
| 59 | } |
|
| 60 | ||
| 61 | return $this->render('AppBundle:Curso:modificar.html.twig', |
|
| 62 | array( |
|
| 63 | 'formulario' => $formulario->createView(), |
|
| 64 | 'curso' => $curso |
|
| 65 | )); |
|
| 66 | } |
|
| 67 | ||
| 68 | /** |
|
| 69 | * @Route("/nuevo", name="curso_nuevo",methods={"GET", "POST"}) |
|
| @@ 70-95 (lines=26) @@ | ||
| 67 | * @Route("/modificar/{grupo}", name="grupo_modificar",methods={"GET", "POST"}) |
|
| 68 | * @Security("has_role('ROLE_ADMIN')") |
|
| 69 | */ |
|
| 70 | public function modificarAction(Grupo $grupo, Request $peticion) |
|
| 71 | { |
|
| 72 | $formulario = $this->createForm(new GrupoType(), $grupo); |
|
| 73 | ||
| 74 | $formulario->handleRequest($peticion); |
|
| 75 | ||
| 76 | if ($formulario->isSubmitted() && $formulario->isValid()) { |
|
| 77 | ||
| 78 | // Guardar el usuario en la base de datos |
|
| 79 | $em = $this->getDoctrine()->getManager(); |
|
| 80 | ||
| 81 | $em->flush(); |
|
| 82 | ||
| 83 | $this->addFlash('success', 'Datos guardados correctamente'); |
|
| 84 | ||
| 85 | return new RedirectResponse( |
|
| 86 | $this->generateUrl('grupo_listar') |
|
| 87 | ); |
|
| 88 | } |
|
| 89 | ||
| 90 | return $this->render('AppBundle:Grupo:modificar.html.twig', |
|
| 91 | array( |
|
| 92 | 'formulario' => $formulario->createView(), |
|
| 93 | 'grupo' => $grupo |
|
| 94 | )); |
|
| 95 | } |
|
| 96 | ||
| 97 | ||
| 98 | /** |
|
| @@ 216-240 (lines=25) @@ | ||
| 213 | * @Route("/importar", name="usuario_importar",methods={"GET", "POST"}) |
|
| 214 | * @Security("has_role('ROLE_DIRECTIVO')") |
|
| 215 | */ |
|
| 216 | public function importarAction(Request $request) |
|
| 217 | { |
|
| 218 | $datos = new Importar(); |
|
| 219 | $form = $this->createForm(new ImportarType(), $datos); |
|
| 220 | $form->handleRequest($request); |
|
| 221 | ||
| 222 | if ($form->isSubmitted() && $form->isValid()) { |
|
| 223 | ||
| 224 | if ($this->importarUsuariosDesdeCsv($datos->getFichero()->getPathname())) { |
|
| 225 | $this->addFlash('success', 'Los datos se han importado correctamente'); |
|
| 226 | } |
|
| 227 | else { |
|
| 228 | $this->addFlash('error', 'Ha ocurrido un error en la importación'); |
|
| 229 | } |
|
| 230 | ||
| 231 | return new RedirectResponse( |
|
| 232 | $this->generateUrl('usuario_listar') |
|
| 233 | ); |
|
| 234 | } |
|
| 235 | ||
| 236 | return $this->render('AppBundle:Usuario:importar.html.twig', |
|
| 237 | array( |
|
| 238 | 'formulario' => $form->createView() |
|
| 239 | )); |
|
| 240 | } |
|
| 241 | } |
|
| 242 | ||