Ejemplo n.º 1
0
 public function store()
 {
     $issues = Input::get('issues');
     $presences = Input::get('presences');
     $descs = Input::get('descs');
     if ($this->teached(Input::get('course_id'), Input::get('subject_id'), Input::get('course_date'), Input::get('hour_id'))) {
         $teach = Teach::where('course_id', '=', Input::get('course_id'))->where('course_date', '=', Input::get('course_date'))->where('hour_id', '=', Input::get('hour_id'))->first();
     } else {
         $teach = new Teach();
         $teach->project_id = Auth::user()->curr_project_id;
         $teach->location_id = Auth::user()->location_id;
         $teach->course_id = Input::get('course_id');
         $teach->employee_id = Input::get('employee_id');
         $teach->hour_id = Input::get('hour_id');
         $teach->course_date = Input::get('course_date');
         $teach->title = Input::get('title');
         $teach->comments = Input::get('comments');
         $teach->save();
     }
     for ($i = 0; $i < count($issues); $i++) {
         if (!$this->existed($teach->id, $issues[$i])) {
             $presence = new Presence();
             $presence->project_id = Auth::user()->curr_project_id;
             $presence->location_id = Auth::user()->location_id;
             $presence->teach_id = $teach->id;
             $presence->issue_id = $issues[$i];
             $presence->presence = $presences[$i];
             $presence->description = $descs[$i];
             $presence->save();
         }
     }
     Session::flash('message', 'Sukses menambahkan pertemuan dan presensi baru');
 }
Ejemplo n.º 2
0
 /**
  * Assign which course will the teacher will teach
  * @before _secure, _school
  */
 public function assign($user_id)
 {
     $usr = \User::first(array("id = ?" => $user_id), array("id"));
     if (!$usr) {
         self::redirect("/school");
     }
     $this->setSEO(array("title" => "Assign Teachers for different subjects"));
     $view = $this->getActionView();
     $grades = \Grade::all(array("organization_id = ?" => $this->organization->id), array("id", "title"));
     $view->set("grades", $grades);
     if (RequestMethods::post("action") == "assignTeacher") {
         $teaches = $this->reArray($_POST);
         foreach ($teaches as $t) {
             if (!empty($t["section"]) || !empty($t["course"])) {
                 continue;
             }
             $teach = new \Teach(array("grade_id" => $t["grade"], "classroom_id" => $t["section"], "course_id" => $t["course"], "user_id" => $usr->id, "organization_id" => $this->organization->id));
             if ($teach->validate()) {
                 $teach->save();
             }
         }
         $view->set("success", "Subjects assigned!!");
     }
     $teaches = Teach::all(array("user_id = ?" => $usr->id, "live = ?" => true));
     $view->set("teaches", $teaches);
 }