public function view_incidents()
 {
     if (Auth::check()) {
         $data["inside_url"] = Config::get('app.inside_url');
         $data["user"] = Session::get('user');
         $data["actions"] = Session::get('actions');
         if (in_array('side_ver_anotaciones', $data["actions"])) {
             $current_ay = AcademicYear::getCurrentAcademicYear();
             if (!$current_ay) {
                 return View::make('control_notebook_incidents/academic_year_error', $data);
             }
             $data["levels"] = Level::lists('name', 'id');
             $data["levels"]["0"] = 'Seleccione un nivel';
             $old_level_id = Input::old('level_id');
             $level_id = Input::get('level_id');
             $level = null;
             if ($old_level_id) {
                 $level = $old_level_id;
             } elseif ($level_id) {
                 $level = $level_id;
             } else {
                 $level = Input::get('level');
             }
             $data["level"] = $level ? $level : '0';
             if ($data["level"]) {
                 $data["students"] = Student::getStudentsEnrolledInLevel($data["level"])->lists('FullName', 'id');
                 //$data["students"] = Student::orderBy('lastname')->get()->lists('FullName','id');
                 $data["students"]["0"] = 'Seleccione un alumno';
             } else {
                 $data["students"] = ['0' => 'Seleccione un nivel'];
             }
             $old_student_id = Input::old('student_id');
             $student = Input::get('student');
             if ($old_student_id) {
                 $data["student"] = $old_student_id;
             } elseif ($student) {
                 $data["student"] = $student;
             } else {
                 $data["student"] = '0';
             }
             $data["level_info"] = Level::find($data["level"]);
             $data["incidents_data"] = null;
             if ($data["level"] && $data["student"]) {
                 // se eligio nivel y alumno, ahora mostrar los incidentes de la libreta de control del alumno
                 $data["student_info"] = Student::find($data["student"]);
                 $enrollment = $data["student_info"]->getCurrentEnrollment();
                 $data["incidents_data"] = ControlNotebookIncident::where('enrollment_id', '=', $enrollment->id)->orderBy('created_at', 'DESC')->paginate(10);
             }
             return View::make('control_notebook_incidents/view_incidents', $data);
         } else {
             // Llamo a la función para registrar el log de auditoria
             $log_description = "Se intentó acceder a la ruta '" . Request::path() . "' por el método '" . Request::method() . "'";
             Helpers::registerLog(10, $log_description);
             Session::flash('error', 'Usted no tiene permisos para realizar dicha acción.');
             return Redirect::to('/dashboard');
         }
     } else {
         return View::make('error/error');
     }
 }
Ejemplo n.º 2
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $level = Level::find($id);
     if (!$level) {
         Session::flash('errorMessage', 'This level dose not exits');
         return $this->index();
     }
     return View::make('games.show')->with('level', $level);
 }
Ejemplo n.º 3
0
 public function getGame()
 {
     if (Input::get('level')) {
         $level = Level::find(Input::get('level'));
         if (!$level) {
             return Redirect::to('/game');
         }
         $game = Auth::user()->createGame($level);
         return Redirect::to("/game/" . $game->id);
     }
     return View::make('game.game');
 }
Ejemplo n.º 4
0
 public function getLevelToEnroll()
 {
     if ($this->enrollments()->get()->isEmpty()) {
         return $this->level;
     } else {
         // obtener la matricula del año pasado o la ultima matriculada registrada
         $level_id = $this->enrollments()->orderBy('date', 'DESC')->first()->level->id;
         // se debe matricular al siguiente nivel
         if ($level_id < 9) {
             return Level::find($level_id + 1);
         } else {
             return Level::find(9);
         }
     }
 }
Ejemplo n.º 5
0
 public static function verifyHourIntersection($level_id, $initial_hour, $final_hour)
 {
     $v = Level::find($level_id)->schedules()->where(function ($query) use($initial_hour, $final_hour) {
         $query->where(function ($q1) use($initial_hour) {
             $q1->where('initial_hour', '<=', $initial_hour)->where('final_hour', '>', $initial_hour);
         })->orWhere(function ($q2) use($final_hour) {
             $q2->where('initial_hour', '<', $final_hour)->where('final_hour', '>=', $final_hour);
         })->orWhere(function ($q3) use($initial_hour, $final_hour) {
             $q3->where('initial_hour', '>', $initial_hour)->where('final_hour', '<', $final_hour);
         });
     })->get();
     if ($v->isEmpty()) {
         return true;
     } else {
         return false;
     }
 }
Ejemplo n.º 6
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     if (Auth::check()) {
         $level = Level::find($id);
         $previous = Level::where('next_level', '=', $level->id)->first();
         $previous->next_level = $level->next_level;
         $previous->save();
         $calls = Call::where('level_id', '=', $id)->get();
         foreach ($calls as $call) {
             $call->delete();
         }
         $level = Level::find($id);
         $level->delete();
         return $this->index();
     }
     return 'you are not authorized to do this';
 }
Ejemplo n.º 7
0
<?php

require __DIR__ . '/../../vendor/autoload.php';
require '../../config.php';
require_once '../../helpers/session.php';
require '../../helpers/boot.php';
require '../../helpers/functions.php';
require_once '../../helpers/User.php';
require_once '../../helpers/Level.php';
$session = new Session();
if (!$session->getLoggedin()) {
    header("Location: ../login.php");
}
$user = User::find($session->getUsername());
$level = Level::find($user->id);
if ($level) {
    header("Location: ./articles/index.php");
} else {
    header("Location: ./form.php");
}
Ejemplo n.º 8
0
 function eliminar($id)
 {
     $a = Level::find($id);
     $a->delete();
     $this->session->set_flashdata('msg', '<div class="success">El Nivel fué eliminado correctamente.</div>');
     redirect('niveles');
 }
 public function new_homework()
 {
     if (Auth::check()) {
         $data["inside_url"] = Config::get('app.inside_url');
         $data["user"] = Session::get('user');
         $data["actions"] = Session::get('actions');
         if (in_array('side_nueva_tarea', $data["actions"])) {
             $current_ay = AcademicYear::getCurrentAcademicYear();
             if (!$current_ay) {
                 return View::make('homeworks/academic_year_error', $data);
             }
             $data["levels"] = Level::lists('name', 'id');
             $data["levels"]["0"] = 'Seleccione un nivel';
             $level_id = Input::old('level_id');
             $level = null;
             if ($level_id) {
                 $level = $level_id;
             } else {
                 $level = Input::get('level');
             }
             $data["level"] = $level ? $level : '0';
             $data["is_tutor"] = $data["user"]->profiles()->where('name', '=', 'Tutor')->first() ? true : false;
             $data["is_teacher"] = $data["user"]->profiles()->where('name', '=', 'Profesor')->first() ? true : false;
             if ($data["level"]) {
                 if ($data["is_tutor"]) {
                     // si es tutor y se elige su nivel, mostrar todos los cursos de su nivel
                     if ($data["user"]->teacher->level->id == $data["level"]) {
                         $data["courses"] = Level::find($data["level"])->courses->lists('name', 'id');
                     } else {
                         $data["courses"] = Level::find($data["level"])->courses()->where('teacher_id', '=', $data["user"]->teacher->id)->lists('name', 'id');
                     }
                 } elseif ($data["is_teacher"]) {
                     // si es un profesor, mostrar solo los cursos que dicta
                     $data["courses"] = Level::find($data["level"])->courses()->where('teacher_id', '=', $data["user"]->teacher->id)->lists('name', 'id');
                 } else {
                     // si no es un profesor (entonces es director o webmaster), mostrar todos los cursos
                     $data["courses"] = Level::find($data["level"])->courses->lists('name', 'id');
                 }
                 $data["courses"]["0"] = 'Seleccione un curso';
             } else {
                 $data["courses"] = ['0' => 'Seleccione un nivel'];
             }
             $course_id = Input::old('course_id');
             if ($course_id) {
                 $data["course_id"] = $course_id;
             } else {
                 $data["course_id"] = '0';
             }
             return View::make('homeworks/new_homework', $data);
         } else {
             // Llamo a la función para registrar el log de auditoria
             $log_description = "Se intentó acceder a la ruta '" . Request::path() . "' por el método '" . Request::method() . "'";
             Helpers::registerLog(10, $log_description);
             Session::flash('error', 'Usted no tiene permisos para realizar dicha acción.');
             return Redirect::to('/dashboard');
         }
     } else {
         return View::make('error/error');
     }
 }
Ejemplo n.º 10
0
 public function clear(Request $request)
 {
     foreach ($request->input('checkbox') as $key => $value) {
         $model = Level::find($value);
         $model->delete();
     }
     return redirect()->route('admin.level.index')->with('success', 'successfully deleted');
 }
 public function upload_supply_lists()
 {
     if (Auth::check()) {
         $data["inside_url"] = Config::get('app.inside_url');
         $data["user"] = Session::get('user');
         $data["actions"] = Session::get('actions');
         if (in_array('side_subir_lista_utiles', $data["actions"])) {
             $level_ids = Input::get('level_ids');
             if (!Input::hasFile('archivos')) {
                 Session::flash('error', 'Suba por lo menos la lista de útiles de un nivel.');
                 return Redirect::to('enrollments/supply_lists')->withInput(Input::all());
             }
             $rules = ['file' => 'required'];
             $path = 'files/supply_lists/';
             if (!File::exists($path)) {
                 File::makeDirectory($path);
             }
             $n = 0;
             foreach (Input::file('archivos') as $archivo) {
                 $v = Validator::make(['file' => $archivo], $rules);
                 if ($v->passes()) {
                     $level = Level::find($level_ids[$n]);
                     if ($level->document) {
                         // eliminar la anterior version
                         File::delete($level->document->path . $level->document->name);
                         // Llamo a la función para registrar el log de auditoria
                         $log_description = "Se eliminó el Documento con id: {{$level->document->id}}";
                         Helpers::registerLog(5, $log_description);
                         $level->document->delete();
                     }
                     $file_name = str_replace(' ', '_', $level->name);
                     $file_path = $path . $file_name;
                     $nombreArchivo = $file_name . '-lista_de_utiles.' . $archivo->getClientOriginalExtension();
                     $nombreArchivoEncriptado = Str::random(27) . '.' . pathinfo($nombreArchivo, PATHINFO_EXTENSION);
                     $peso = $archivo->getSize();
                     $uploadSuccess = $archivo->move($path, $nombreArchivoEncriptado);
                     $document = new Document();
                     $document->title = $nombreArchivo;
                     $document->name = $nombreArchivoEncriptado;
                     $document->size = $peso;
                     $document->path = $path;
                     $document->type = 'Lista de útiles';
                     $document->level_id = $level->id;
                     $document->save();
                     // Llamo a la función para registrar el log de auditoria
                     $log_description = "Se creó el Documento con id: {{$document->id}}";
                     Helpers::registerLog(3, $log_description);
                 }
                 $n = $n + 1;
             }
             Session::flash('message', 'Se han subido correctamente las listas de útiles.');
             return Redirect::to('enrollments/supply_lists');
         } else {
             // Llamo a la función para registrar el log de auditoria
             $log_description = "Se intentó acceder a la ruta '" . Request::path() . "' por el método '" . Request::method() . "'";
             Helpers::registerLog(10, $log_description);
             Session::flash('error', 'Usted no tiene permisos para realizar dicha acción.');
             return Redirect::to('/dashboard');
         }
     } else {
         return View::make('error/error');
     }
 }
Ejemplo n.º 12
0
 public function schedule($level_id)
 {
     if (Auth::check()) {
         $data["inside_url"] = Config::get('app.inside_url');
         $data["user"] = Session::get('user');
         $data["actions"] = Session::get('actions');
         if (in_array('side_listar_niveles', $data["actions"])) {
             $data["level"] = Level::find($level_id);
             if (!$data["level"]) {
                 Session::flash('error', 'No se encontró el Nivel solicitado.');
                 return Redirect::to('levels/list_levels');
             }
             $data["courses"] = $data["level"]->courses()->lists('name', 'id');
             $data["courses"]["0"] = '';
             $data["schedules_data_raw"] = $data["level"]->schedules()->orderBy('initial_hour');
             $data["schedules_data"] = $data["schedules_data_raw"]->get();
             //return $data["schedules_data"];
             //return $data["schedules_data_raw"]->where('initial_hour','=','08:00:00')->where('day','=','Viernes')->first();
             if ($data["user"]->profiles()->where('name', '=', 'webmaster')->first()) {
                 $data["can_update_schedule"] = true;
             } elseif ($data["user"]->profiles()->where('name', '=', 'Director')->first()) {
                 $data["can_update_schedule"] = true;
             } elseif ($data["user"]->profiles()->where('name', '=', 'Tutor')->first()) {
                 if ($data["user"]->teacher->level->id != $level_id) {
                     $data["can_update_schedule"] = false;
                 } else {
                     $data["can_update_schedule"] = true;
                 }
             } else {
                 $data["can_update_schedule"] = false;
             }
             return View::make('levels/schedule', $data);
         } else {
             // Llamo a la función para registrar el log de auditoria
             $log_description = "Se intentó acceder a la ruta '" . Request::path() . "' por el método '" . Request::method() . "'";
             Helpers::registerLog(10, $log_description);
             Session::flash('error', 'Usted no tiene permisos para realizar dicha acción.');
             return Redirect::to('/dashboard');
         }
     } else {
         return View::make('error/error');
     }
 }