Пример #1
0
 public function destroy($id)
 {
     $teach = Teach::with('presences')->find($id);
     if ($teach->presences->count() > 0) {
         Session::flash('message', 'Tidak dapat menghapus pertemuan!!');
     } else {
         Teach::destroy($id);
         Session::flash('message', 'Sukses mengupdate info Pertemuan');
     }
 }
Пример #2
0
 protected static function _init()
 {
     $session = Registry::get("session");
     if (!self::$_courses || !self::$_classes) {
         if (!$session->get('TeacherService:$courses') || !$session->get('TeacherService:$classes')) {
             $teaches = \Teach::all(array("user_id = ?" => self::$_teacher->user_id));
             $session->set('TeacherService:$teaches', $teaches);
             $session->set('TeacherService:$courses', self::_findCourses($teaches));
             $session->set('TeacherService:$classes', self::_findClasses($teaches));
         }
         self::$_courses = $session->get('TeacherService:$courses');
         self::$_classes = $session->get('TeacherService:$classes');
         self::$_teaches = $session->get('TeacherService:$teaches');
     }
 }
Пример #3
0
 public function show($id)
 {
     $payroll = Payroll::findOrFail($id);
     $curr_month = (int) date('m', strtotime($payroll->release_date));
     $curr_year = (int) date('Y', strtotime($payroll->release_date));
     $curr_month = $curr_month - 1;
     if ($curr_month == 0) {
         $curr_month = 12;
         $curr_year = $curr_year - 1;
     }
     $employee = Employee::find($payroll->employee_id);
     $incomes = Income::where('employee_id', '=', $employee->id)->where(DB::raw('year(release_date)'), '=', $curr_year)->where(DB::raw('month(release_date)'), '=', $curr_month)->get();
     $deductions = Deduction::where('employee_id', '=', $employee->id)->where(DB::raw('year(release_date)'), '=', $curr_year)->where(DB::raw('month(release_date)'), '=', $curr_month)->get();
     $teaches = Teach::where('employee_id', '=', $employee->id)->where(DB::raw('year(course_date)'), '=', $curr_year)->where(DB::raw('month(course_date)'), '=', $curr_month)->count();
     $menu = 'employee';
     return View::make('payrolls.show', compact('payroll', 'employee', 'incomes', 'deductions', 'teaches', 'curr_year', 'curr_month', 'menu'));
 }
Пример #4
0
 public function report($id)
 {
     $student = Issue::with('placement', 'receivable.installments', 'education', 'earnings', 'punishments', 'returnments', 'presences', 'points', 'retrievals', 'masteries')->find($id);
     $periods = Teach::with(array('presences' => function ($q) use($id) {
         $q->where('issue_id', '=', $id);
     }))->select(DB::raw('month(course_date) as months'), DB::raw('year(course_date) as years'))->groupBy(DB::raw('month(course_date)'))->get();
     $presences = array();
     foreach ($periods as $period) {
         $presences[] = array('month' => $period->months, 'year' => $period->years, 'presences' => $this->countPresences($id, $period->months, $period->years), 'presents' => $this->countPresents($id, $period->months, $period->years), 'absents' => $this->countAbsents($id, $period->months, $period->years), 'sicks' => $this->countSicks($id, $period->months, $period->years), 'permits' => $this->countPermits($id, $period->months, $period->years));
     }
     $points = array();
     foreach ($student->points as $point) {
         if ($point->pointable_type == 'Activity') {
             $points[] = array('date' => $point->pointable->agenda, 'event' => $point->pointable->name, 'point' => $point->point, 'lowest' => $this->getLowest($point->pointable_id), 'highest' => $this->getHighest($point->pointable_id));
         }
     }
     $menu = 'student';
     return View::make('students.report', compact('student', 'presences', 'points', 'menu'));
 }
Пример #5
0
 /**
  * @before _secure, _teacher
  */
 public function create($course_id, $classroom_id)
 {
     $teach = \Teach::first(array("course_id = ?" => $course_id, "user_id = ?" => $this->user->id));
     if (!$teach || $teach->classroom_id != $classroom_id) {
         self::redirect("/teacher");
     }
     $this->setSEO(array("title" => "Teacher | Create Assignments"));
     $view = $this->getActionView();
     $grade = Grade::first(array("id = ?" => $teach->grade_id), array("title", "id"));
     $classroom = Classroom::first(array("id = ?" => $classroom_id), array("section", "id"));
     $view->set("grade", $grade);
     $view->set("classroom", $classroom);
     if (RequestMethods::post("action") == "assignment") {
         $headers = getallheaders();
         $attachment = $this->_upload("attachment", "assignments");
         $assignment = new \Assignment(array("title" => RequestMethods::post("title"), "description" => RequestMethods::post("description"), "deadline" => RequestMethods::post("deadline"), "user_id" => $this->user->id, "organization_id" => $this->organization->id, "classroom_id" => $classroom_id, "course_id" => $course_id, "attachment" => $attachment));
         if (!$assignment->validate()) {
             $view->set("success", "Invalid Request");
             return;
         }
         $assignment->save();
         $view->set("success", "Assignment Created successfully!!");
     }
 }
Пример #6
0
 /**
  * @todo move to services
  * Grade the students for each week
  * @before _secure, _teacher
  */
 public function weeklyStudentsPerf($course_id, $classroom_id)
 {
     $this->setSEO(array("title" => "Grade Students Weekly Performance | Teacher"));
     $view = $this->getActionView();
     $session = Registry::get("session");
     if (!$course_id || !$classroom_id) {
         self::redirect("/404");
     }
     $teach = Teach::first(array("course_id = ?" => $course_id, "classroom_id = ?" => $classroom_id, "user_id = ?" => $this->user->id));
     if (!$teach) {
         self::redirect("/404");
     }
     $service = new Shared\Services\Classroom();
     $return = $service->weeklyPerformance($teach);
     $view->set($return);
     $classroom = TeacherService::$_classes[$teach->classroom_id];
     $course = TeacherService::$_courses[$teach->course_id];
     $enrollments = $service->enrollments($classroom, array('table' => 'performance', 'teach' => $teach));
     $scale = array();
     for ($i = 1; $i <= 10; $i++) {
         $scale[] = $i;
     }
     $view->set(array("students" => $enrollments, "class" => $classroom->grade . " - " . $classroom->section, "course" => $course->title, "scale" => $scale));
 }
Пример #7
0
 public function edit($id)
 {
     $teach = Teach::with('presences')->find($id);
     $menu = 'academic';
     return View::make('presences.edit', compact('teach', 'menu'));
 }