public function my_schedule()
 {
     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_mi_horario', $data["actions"])) {
             $current_ay = AcademicYear::getCurrentAcademicYear();
             if (!$current_ay) {
                 return View::make('schedule/academic_year_error', $data);
             }
             $student = $data["user"]->student;
             $data["enrollment_info"] = $student->getCurrentEnrollment();
             $data["level"] = $data["enrollment_info"]->level;
             $data["schedules_data"] = $data["level"]->schedules()->orderBy('initial_hour')->get();
             return View::make('schedule/my_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');
     }
 }
Ejemplo n.º 2
0
 public function getCurrentYearHomeworks()
 {
     $current_ay = AcademicYear::getCurrentAcademicYear();
     if (!$current_ay) {
         return null;
     }
     return $this->homeworks()->where('academic_year_id', '=', $current_ay->id)->orderBy('created_at', 'DESC');
 }
Ejemplo n.º 3
0
 public static function search($search_text, $search_state, $search_level)
 {
     $current_ay = AcademicYear::getCurrentAcademicYear();
     if (!$current_ay) {
         return null;
     }
     if ($search_level) {
         return Enrollment::join('students', 'students.id', '=', 'enrollments.student_id')->where(function ($query) use($search_text) {
             $query->where('names', 'LIKE', "%{$search_text}%")->orWhere('lastname', 'LIKE', "%{$search_text}%");
         })->where('enrollments.academic_year_id', '=', $current_ay->id)->where('enrollments.level_id', '=', $search_level)->where('enrollments.state', '=', $search_state)->orderBy('enrollments.date')->select('enrollments.*');
     } else {
         return Enrollment::join('students', 'students.id', '=', 'enrollments.student_id')->where(function ($query) use($search_text) {
             $query->where('names', 'LIKE', "%{$search_text}%")->orWhere('lastname', 'LIKE', "%{$search_text}%");
         })->where('enrollments.academic_year_id', '=', $current_ay->id)->where('enrollments.state', '=', $search_state)->orderBy('enrollments.date')->select('enrollments.*');
     }
 }
Ejemplo n.º 4
0
 public static function getStudentsEnrolledInLevel($level_id)
 {
     $current_ay = AcademicYear::getCurrentAcademicYear();
     if (!$current_ay) {
         return null;
     }
     $enrolled_students = Student::whereHas('enrollments', function ($q) use($current_ay, $level_id) {
         $q->where('academic_year_id', '=', $current_ay->id)->where('state', '=', 'A')->where('level_id', '=', $level_id);
     });
     return $enrolled_students->orderBy('lastname')->get();
 }
 public function answer_incident()
 {
     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_mis_anotaciones', $data["actions"])) {
             $current_ay = AcademicYear::getCurrentAcademicYear();
             if (!$current_ay) {
                 return View::make('control_notebook_incidents/academic_year_error', $data);
             }
             $incident_id = Input::get('incident_id');
             // Validate the info, create rules for the inputs
             $attributes = array('parent_comment' => 'Respuesta o comentario');
             $messages = array();
             $rules = array('parent_comment' => 'required|max:300');
             // Run the validation rules on the inputs from the form
             $validator = Validator::make(Input::all(), $rules, $messages, $attributes);
             // If the validator fails, redirect back to the form
             if ($validator->fails()) {
                 return Redirect::to('control_notebook_incidents/show_my_incident/' . $incident_id)->withErrors($validator)->withInput(Input::all());
             } else {
                 $incident = ControlNotebookIncident::find($incident_id);
                 $incident->parent_comment = Input::get('parent_comment');
                 $incident->save();
                 Session::flash('message', 'Se registró correctamente la respuesta.');
                 // Llamo a la función para registrar el log de auditoria
                 $log_description = "Se respondió a la Anotación con id: {{$incident->id}}";
                 Helpers::registerLog(4, $log_description);
                 return Redirect::to('control_notebook_incidents/show_my_incident/' . $incident_id)->withInput(Input::all());
             }
         } 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');
     }
 }
 public function show_homework($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_mis_tareas', $data["actions"])) {
             $current_ay = AcademicYear::getCurrentAcademicYear();
             if (!$current_ay) {
                 return View::make('homeworks/academic_year_error', $data);
             }
             $data["homework_info"] = Homework::find($id);
             if (!$data["homework_info"]) {
                 Session::flash('error', 'No se encontró la Tarea solicitada.');
                 return Redirect::to('homeworks/my_homeworks');
             }
             $data["course_info"] = $data["homework_info"]->course;
             $data["level_info"] = $data["course_info"]->level;
             return View::make('homeworks/show_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');
     }
 }
 public function submit_offline_enrollments()
 {
     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_matricula_offline', $data["actions"])) {
             $current_ay = AcademicYear::getCurrentAcademicYear();
             if (!$current_ay) {
                 return View::make('enrollments/academic_year_error', $data);
             }
             $students = Input::get('students');
             if (!$students) {
                 Session::flash('error', 'No seleccionó ningún alumno.');
                 return Redirect::to('enrollments/offline_enrollment');
             }
             foreach ($students as $student_id) {
                 $enrollment = new Enrollment();
                 $enrollment->date = date('Y-m-d');
                 $enrollment->state = 'A';
                 $enrollment->student_id = $student_id;
                 $enrollment->academic_year_id = $current_ay->id;
                 $enrollment->level_id = Student::find($student_id)->getLevelToEnroll()->id;
                 $enrollment->doc_name = null;
                 $enrollment->save();
                 // Llamo a la función para registrar el log de auditoria
                 $log_description = "Se creó la Matrícula con id: {{$enrollment->id}}";
                 Helpers::registerLog(3, $log_description);
             }
             Session::flash('message', 'Los alumnos fueron matriculados exitosamente.');
             return Redirect::to('enrollments/offline_enrollment');
         } 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.º 8
0
 public function show_notice($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_ver_comunicados', $data["actions"])) {
             $current_ay = AcademicYear::getCurrentAcademicYear();
             if (!$current_ay) {
                 return View::make('notices/academic_year_error', $data);
             }
             $data["notice_info"] = Notice::find($id);
             if (!$data["notice_info"]) {
                 Session::flash('error', 'No se encontró el Comunicado solicitado.');
                 return Redirect::to('notices/view_notices');
             }
             if ($data["user"]->profiles()->where('name', '=', 'Alumno')->first()) {
                 $data["can_delete"] = false;
             } elseif ($data["user"]->profiles()->where('name', '=', 'Director')->first()) {
                 $data["can_delete"] = true;
             } elseif ($data["user"]->profiles()->where('name', '=', 'Profesor')->first()) {
                 if ($data["user"]->teacher->id == $data["notice_info"]->teacher_id) {
                     $data["can_delete"] = true;
                 } else {
                     $data["can_delete"] = false;
                 }
             } elseif ($data["user"]->profiles()->where('name', '=', 'Personal Administrativo')->first()) {
                 if (AdministrativeStaff::where('user_id', '=', $data["user"]->id)->first()->id == $data["notice_info"]->administrative_staff_id) {
                     $data["can_delete"] = true;
                 } else {
                     $data["can_delete"] = false;
                 }
             } else {
                 $data["can_delete"] = true;
             }
             return View::make('notices/show_notice', $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');
     }
 }