public function indexAction()
 {
     $user = new User();
     $rol = new RolSistema();
     $opciones = new ArrayCollection();
     //new OpcionSistema();
     $user = $this->get('security.context')->getToken()->getUser();
     if ($user != 'anon.' && $user->getAuditDeleted() == false) {
         $roles = $user->getRols();
         if (isset($roles)) {
             foreach ($roles as $rol) {
                 //$opciones = $rol->getOpcionesSistema();
                 $opciones = new ArrayCollection(array_merge_maintain_keys($opciones->toArray(), $rol->getOpcionesSistema()->toArray()));
             }
             $peticion = $this->getRequest();
             $sesion = $peticion->getSession();
             $sesion->set('opciones', $opciones);
             return $this->render('MinSalSCABundle:Default:index.html.twig', array('opciones' => $opciones));
         }
     } else {
         if ($user != 'anon.' && $user->getAuditDeleted() == true) {
             $this->get('session')->setFlash('notice', 'El usuario "' . $user->getUsername() . '" se encuentra inactivo');
             $this->getRequest()->getSession()->set('notice', 'El usuario "' . $user->getUsername() . '" se encuentra inactivo');
             return new RedirectResponse($this->generateUrl('fos_user_security_logout'));
             //return $this->redirect($this->generateUrl('fos_user_security_logout'));
         }
         return $this->render('MinSalSCABundle:Default:index.html.twig');
     }
 }
 public function manttRolEdicionAction()
 {
     $request = $this->getRequest();
     $nombreRol = $request->get('nombreRol');
     $funciones = $request->get('funcionesRol');
     $rolImportador = $request->get('rolImportador');
     $rolProductor = $request->get('rolProductor');
     $rolComprador = $request->get('rolComprador');
     $rolCompVend = $request->get('rolCompVend');
     $rolInterno = $request->get('rolInterno');
     $rolTipo = $request->get('rolTipo');
     $rolInternoTipo = $request->get('rolInternoTipo');
     $id = $request->get('id');
     $operacion = $request->get('oper');
     $rolDao = new RolDao($this->getDoctrine());
     if ($operacion == 'edit') {
         $rolSistema = new RolSistema();
         $rolDao = new RolDao($this->getDoctrine());
         $rolSistema = $rolDao->repositorio->find($id);
         if (!$rolSistema) {
             //throw $this->createNotFoundException('No se encontro rol con ese id '.$id);
             return new Response('{"status":false,"msg":"No se encontro rol con este id->' . $id . '"}');
         }
         $rolSistema->setNombreRol($nombreRol);
         $rolSistema->setFuncionesRol($funciones);
         $rolSistema->setRolImportador($rolImportador);
         $rolSistema->setRolProductor($rolProductor);
         $rolSistema->setRolComprador($rolComprador);
         $rolSistema->setRolCompVend($rolCompVend);
         $rolSistema->setRolInterno($rolInterno);
         $rolSistema->setRolTipo($rolTipo);
         $rolSistema->setRolInternoTipo($rolInternoTipo);
         $rolDao->editRol($rolSistema);
     } else {
         if ($operacion == 'del') {
             $rolDao->delRol($id);
         } else {
             if ($operacion == 'add') {
                 $rolSistema = new RolSistema();
                 $rolSistema->setNombreRol($nombreRol);
                 $rolSistema->setFuncionesRol($funciones);
                 $rolSistema->setRolImportador($rolImportador);
                 $rolSistema->setRolProductor($rolProductor);
                 $rolSistema->setRolComprador($rolComprador);
                 $rolSistema->setRolCompVend($rolCompVend);
                 $rolSistema->setRolInterno($rolInterno);
                 $rolSistema->setRolTipo($rolTipo);
                 $rolSistema->setRolInternoTipo($rolInternoTipo);
                 $rolDao->addRol($rolSistema);
             }
         }
     }
     return new Response('{"status":true,"msg":""}');
 }