/**
  * @return void
  * @throws ApiException
  */
 private function initialize()
 {
     $lessons = LessonModel::getAllByGroupNameOrGroupId($this->group['group_id']);
     $this->weeks[1] = new WeekModel(1);
     $this->weeks[2] = new WeekModel(2);
     foreach ($lessons as $lesson) {
         $this->weeks[$lesson['lesson_week']]->days[$lesson['day_number']]->lessons[] = $lesson;
     }
 }
 public function groups_lessonsRelationAction($data)
 {
     $groupName = $data["groups"];
     $groupName = urldecode($groupName);
     $cond = "";
     if (isset($_GET["week"])) {
         $week = abs(intval($_GET["week"]));
         if ($week > 2) {
             throw new Exception("404 - Not Found");
         }
         $cond .= " AND lesson_week = {$week}";
     }
     if (isset($_GET["day"])) {
         $day = abs(intval($_GET["day"]));
         if ($day > 7) {
             throw new Exception("404 - Not Found");
         }
         $cond .= " AND day_number = {$day}";
     }
     $this->data = LessonModel::getAllByGroupNameOrGroupId($groupName, $cond);
     return $this->send(200);
 }
Ejemplo n.º 3
0
 /**
  * @api
  * @param $data
  * @return string
  * @throws ApiException
  */
 public function groups_lessonsRelationAction($data)
 {
     $filter = $this->_fc->getFilter();
     $condition = "";
     if ($filter != null) {
         $allowFilters = ['day_number' => true, 'day_name' => true, 'lesson_number' => true, 'lesson_week' => true, 'lesson_type' => true, 'rate' => true];
         $filterContext = $this->_fc->getArrayDepth($filter) == 1 ? new FilterContext(new AndFilterStrategy()) : new FilterContext(new OrFilterStrategy());
         $condition = $filterContext->buildCondition($filter, $allowFilters);
     }
     $data["groups"] = urldecode($data["groups"]);
     $response = LessonModel::getAllByGroupNameOrGroupId($data['groups'], $condition);
     $this->debugInfo = "duplicateTeachersFilter is enable";
     $this->data = $response;
     return $this->send(200);
 }