public static function getRooms($cid) { $c = Day_period::where('classallocation', $cid); $data = []; if ($c->count() > 0) { $cc = $c->get(); foreach ($cc as $rooms) { $room = self::find($rooms->classroom); $data[] = $room->legacycode; } } return implode(' / ', $data); }
public function getSchedRoom($room, $system) { $classes = Classallocation::where('academicterm', $system->phaseterm)->get(); foreach ($classes as $class) { if ($this->ctr > count($this->color) - 1) { $this->ctr = 0; } $dayperiods = Day_period::where('classallocation', $class->id)->where('classroom', $room)->get(); $this->getSched($dayperiods, $class); $this->ctr++; } return $this->returnCollection(); }
public static function getShortDay($cid) { $c = Day_period::where('classallocation', $cid); $data = []; if ($c->count() > 0) { $cc = $c->get(); foreach ($cc as $dp) { $day = self::find($dp->day); $data[] = $day->shortname; } } return implode(' / ', $data); }
public static function getPeriod($cid) { $c = Day_period::where('classallocation', $cid); $data = []; if ($c->count() > 0) { $cc = $c->get(); foreach ($cc as $per) { $from = self::find($per->from_time); $to = self::find($per->to_time); $data[] = $from->time . '-' . $to->time; } } return implode(' / ', $data); }
public static function checkInstructor($instructor, $time, $day) { $instructor_sched = Day_period::getInstructorsSched($instructor); $subject_time = explode(' / ', $time); $subject_day = explode(' / ', $day); foreach ($instructor_sched as $sched) { if (!in_array('TBA', $subject_day)) { $inst_day = Day::find($sched->day); if (!in_array($inst_day, $subject_day)) { $from = Time::find($sched->from_time); $to = Time::find($sched->to_time); foreach ($subject_time as $key) { $keys = explode('-', $key); $isConflict = intersectCheck($from->time, $keys[0], $to->time, $keys[1]); if ($isConflict) { return true; } } } } } return false; }
function assign($request) { $day = $request->day; $cid = $request->class_id; $days = array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'); foreach ($day as $key => $value) { $start_time = $request->input('start_time' . $value); $end_time = $request->input('end_time' . $value); // check if the user select the noon break time period if ($start_time != 11 and $end_time != 13) { //end time period must be greater than the start time period if ($end_time > $start_time) { // check if schedule overlaps if ($start_time >= 1 and $end_time <= 11 or $start_time >= 13 and $end_time <= 28) { // delete first the days and period before inserting Day_period::where('classallocation', $cid)->delete(); $day_period = new Day_period(); $day_period->classallocation = $cid; $day_period->day = $value; $day_period->from_time = $start_time; $day_period->to_time = $end_time; $day_period->save(); } else { $this->error = htmlAlert('Overlaps Noon Break in <strong>' . $days[$value - 1] . '</strong>'); return false; } } else { $this->error = htmlAlert('End Time Period must be greater than Start Time in <strong>' . $days[$value - 1] . '</strong>'); return false; } } else { if ($start_time == 11 and $end_time == 13) { $this->error = htmlAlert('Time Period must not in 12:00 pm - 1:00 pm in <strong>' . $days[$value - 1] . '</strong>'); } elseif ($start_time == 11) { $this->error = htmlAlert('Start Time must not 12:00 pm in <strong>' . $days[$value - 1] . '</strong>'); } elseif ($end_time == 13) { $this->error = htmlAlert('End Time must not 1:00 pm in <strong>' . $days[$value - 1] . '</strong>'); } return false; } } Session::flashdata('message', htmlAlert('Successfully added', 'success')); return true; }