/**
  */
 public function actionPopulateclassdivisions()
 {
     ClassDivision::deleteAll();
     $classes = AClass::find()->all();
     $groups = [];
     foreach ($classes as $class) {
         $key = join('|', [$class->room_id, $class->day_id, $class->type_id, $class->frequency_id, $class->start_time]);
         //echo $key . ': ' . $class->fullName . PHP_EOL;
         if (!isset($groups[$key])) {
             $groups[$key] = [];
         }
         $groups[$key][] = $class;
     }
     foreach ($groups as $key => $group) {
         $classId = null;
         foreach ($group as $class) {
             // use the ID of the first class in the group for all of them
             if (null === $classId) {
                 $classId = $class->id;
             }
             $cd = new ClassDivision();
             $cd->class_id = $classId;
             $cd->division_id = $class->division_id;
             if (!$cd->save()) {
                 echo $key . ' failed to save' . PHP_EOL;
             }
         }
     }
 }
Пример #2
0
 public function search($params)
 {
     $query = AClass::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'day_id' => $this->day_id, 'division_id' => $this->division_id, 'room_id' => $this->room_id, 'instructor_id' => $this->instructor_id, 'start_time' => $this->start_time, 'type_id' => $this->type_id, 'frequency' => $this->frequency, 'active' => $this->active]);
     return $dataProvider;
 }
Пример #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getClasses()
 {
     return $this->hasMany(AClass::className(), ['division_id' => 'id']);
 }
Пример #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getHandAnchor()
 {
     return $this->hasOne(AClass::className(), ['id' => 'hand_anchor_id']);
 }
 /**
  * Finds the AClass model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return AClass the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = AClass::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Пример #6
0
 /**
  * @return \app\models\AClass[] available class choices
  */
 public function getWeaponAnchors()
 {
     return AClass::find()->joinWith(['school', 'day', 'frequency', 'type'])->andWhere(['location_id' => Yii::$app->user->schoolId])->andWhere(['class_type.name' => 'Weapons'])->andFilterWhere(['division_id' => $this->division_id])->orFilterWhere(['class.id' => $this->affiliation->weapon_anchor_id])->orderBy(['-`day`.`ord`' => SORT_DESC, 'start_time' => SORT_ASC])->all();
 }
Пример #7
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getClass()
 {
     return $this->hasOne(AClass::className(), ['id' => 'class_id']);
 }