Esempio n. 1
0
 /**
  * Get the time element from datetime parameter, then get kode_waktu from fetched time, based on Noreg and Kode Seksi
  * @param $date
  * @return mixed|null
  */
 public static function getKodeWaktuByDate($date, $kode_seksi, $noreg)
 {
     $instance = DB::select('SELECT time(tanggal) as time FROM presences WHERE date(tanggal)=? and kode_seksi=? and Noreg=? order by time desc', [$date, $kode_seksi, $noreg]);
     if (count($instance) == 0) {
         return null;
     }
     $time = $instance[0]->time;
     //next query timeslot, guaranteed to be not null by condition
     $timeslot = WaktuKuliah::getKodeWaktuByTime($time);
     return $timeslot;
 }
Esempio n. 2
0
 public function editMatkul($id_course)
 {
     $course = Course::where('seksi', $id_course)->first();
     //get all prodi information
     $prodis = Prodi::all();
     //transform prodi to associative array
     $prodi_arr = array();
     foreach ($prodis as $prodi) {
         $prodi_arr[$prodi->id] = $prodi->prodi;
     }
     $kode_dosen = $course->Kode_Dosen;
     //need to pass filled data to this view (extra parameter)
     $room = Room::room_name();
     $room_arr = Helpers::toAssociativeArrays($room);
     $waktu_kuliah = WaktuKuliah::waktuMap();
     $waktu_opts = Helpers::toAssociativeArrays($waktu_kuliah);
     return view('lecturers.editcourse')->with('prodi_options', $prodi_arr)->with('Kode_Dosen', $kode_dosen)->with('room_options', $room_arr)->with('course', $course)->with('waktu_options', $waktu_opts);
 }
Esempio n. 3
0
 /**
  * @param $day string of course day
  * @param $time_start string of course start time
  * @param $time_end string of course end time
  */
 public static function isAbsentFillable($day, $time_start, $time_end, $kode_seksi, $noreg)
 {
     //get current time in Indonesia
     $current_day = trans('messages.' . date('l'));
     //get current time
     $current_time = date('H:i');
     //first condition current time must be in interval course time
     $stat = (bool) DB::select('select ? between ? and ? as result', [$current_time, $time_start, $time_end])[0]->result;
     //second condition current day must be within course day
     $stat2 = strcmp($current_day, $day) == 0;
     //third condition, check in presences table whether current slot already exist
     $current_slot = WaktuKuliah::getKodeWaktuByTime($current_time);
     if (is_null($current_slot)) {
         return 0;
     }
     $current_date = date('Y-m-d');
     $recorded_slot = Presence::getKodeWaktuByDate($current_date, $kode_seksi, $noreg);
     //if(is_null($recorded_slot))
     //    return 0;
     //insertable if current slot different from recorded slot
     $stat3 = strcmp($current_slot, $recorded_slot) != 0;
     $final_stat = $stat && $stat2 && $stat3;
     return $final_stat;
 }