Exemple #1
0
 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);
 }
Exemple #2
0
 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();
 }
Exemple #3
0
 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);
 }
Exemple #4
0
 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);
 }
Exemple #5
0
 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;
 }