public function submit_disable_convocatoria()
 {
     if (Auth::check()) {
         $data["inside_url"] = Config::get('app.inside_url');
         $data["user"] = Session::get('user');
         $data["permisos"] = Session::get('permisos');
         if (in_array('side_nuevo_usuario', $data["permisos"])) {
             $idperiodo = Input::get('idperiodo');
             $exist_evento = Evento::where('idperiodos', '=', $idperiodo)->get();
             $exist_postulante = PostulantesPeriodo::where('idperiodos', '=', $idperiodo)->get();
             $exist_user = UsersPeriodo::where('idperiodos', '=', $idperiodo)->get();
             $url = "convocatorias/edit_convocatoria/" . $idperiodo;
             if ($exist_evento->isEmpty() && $exist_postulante->isEmpty() && $exist_user->isEmpty()) {
                 $periodo = Periodo::find($idperiodo);
                 $periodo->delete();
                 // Llamo a la función para registrar el log de auditoria
                 $descripcion_log = "Se inhabilitó el periodo con id {{$periodo->idperiodos}}";
                 Helpers::registrarLog(5, $descripcion_log);
                 Session::flash('message', 'Se inhabilitó correctamente la convocatoria.');
             } else {
                 Session::flash('error', 'Existe al menos un evento, postulante o usuario asociado a esta convocatoria. No es posible inhabilitar.');
             }
             return Redirect::to($url);
         } else {
             // Llamo a la función para registrar el log de auditoria
             $descripcion_log = "Se intentó acceder a la ruta '" . Request::path() . "' por el método '" . Request::method() . "'";
             Helpers::registrarLog(10, $descripcion_log);
             Session::flash('error', 'Usted no tiene permisos para realizar dicha acción.');
             return Redirect::to('/dashboard');
         }
     } else {
         return View::make('error/error');
     }
 }
 public function submit_asistencia_excel()
 {
     if (Auth::check()) {
         $data["inside_url"] = Config::get('app.inside_url');
         $data["user"] = Session::get('user');
         $data["permisos"] = Session::get('permisos');
         if (in_array('side_reporte_asistencia', $data["permisos"])) {
             $data["search_periodo"] = Input::get('search_periodo_excel');
             $data["search_usuario"] = Input::get('search_usuario_excel');
             $data["periodos"] = Periodo::lists('nombre', 'idperiodos');
             $periodo = Periodo::find($data["search_periodo"]);
             $eventos_asistencia = Asistencia::getEventosAsistencia()->get();
             $voluntarios_data = UsersPerfil::searchVoluntariosReporteInfo($data["search_periodo"], $data["search_usuario"]);
             $str_table = "<table><tr><td></td><td></td><td></td><td><strong>Reporte de Asistencia</strong></td></tr></table>";
             if ($periodo == null) {
                 $str_table .= "<table><tr><td><strong>Periodo</strong></td><td>Todos</td></tr><tr></tr></table>";
             } else {
                 $str_table .= "<table><tr><td><strong>Periodo:</strong></td><td>" . $periodo->nombre . "</td></tr><tr></tr></table>";
             }
             $str_table .= "<table border=1><tr><th>Periodo</th><th>Doc. de Identidad</th><th>Nombre</th><th>Eventos Programados</th><th>Eventos que Asistio</th><th>% Asistencia</th><th>Promedio Calificacion</th></tr>";
             if ($voluntarios_data != null) {
                 foreach ($voluntarios_data as $voluntario_data) {
                     $eventos_total = 0;
                     $eventos_asistidos = 0;
                     $str_table .= "<tr><td>" . htmlentities($voluntario_data->nombre_periodo) . "</td><td>" . htmlentities($voluntario_data->num_documento) . "</td><td>" . htmlentities($voluntario_data->apellido_pat . ' ' . $voluntario_data->apellido_mat . ', ' . $voluntario_data->nombre_persona) . "</td><td>";
                     foreach ($eventos_asistencia as $asistencia) {
                         if ($asistencia->idusers == $voluntario_data->id) {
                             $str_table .= "-" . htmlentities($asistencia->nombre) . "<br>";
                             $eventos_total++;
                         }
                     }
                     $str_table .= "</td><td>";
                     foreach ($eventos_asistencia as $asistencia) {
                         if ($asistencia->idusers == $voluntario_data->id) {
                             if ($asistencia->asistio == 1) {
                                 $str_table .= "-" . htmlentities($asistencia->nombre) . "<br>";
                                 $eventos_asistidos++;
                             }
                         }
                     }
                     $str_table .= "</td><td>" . htmlentities(round($eventos_asistidos / $eventos_total * 100, 2)) . "%</td><td>" . htmlentities(round($voluntario_data->prom_calificaciones), 2) . "</td></tr>";
                 }
             }
             $str_table .= "</table>";
             $filename = "reporte_asistencia" . date('Y-m-d') . ".xls";
             // Show the download dialog
             header("Content-type: application/vnd.ms-excel; charset=utf-8");
             // Let's indicate to the browser we are giving it the file
             header("Content-Disposition: attachment; filename=\"{$filename}\"");
             // Avoid the browser to save the file into it's cache
             header("Pragma: no-cache");
             header("Expires: 0");
             // Render the table
             echo $str_table;
         } else {
             return View::make('error/error');
         }
     } else {
         return View::make('error/error');
     }
 }