public function actionIndex() { Yii::app()->getModule('aud'); Yii::app()->getModule('group'); Yii::app()->getModule('lesson'); Yii::app()->getModule('sch'); Yii::app()->getModule('spec'); Yii::app()->getModule('teacher'); $schs = Sch::model()->findAll(array('order' => 'modified_time DESC', 'limit' => 100)); $auds = Aud::model()->findAll(array('order' => 'updated_time DESC', 'limit' => 100)); $specs = Spec::model()->findAll(array('order' => 'updated_time DESC', 'limit' => 100)); $groups = Group::model()->findAll(array('order' => 'updated_time DESC', 'limit' => 100)); $lessons = Lesson::model()->findAll(array('order' => 'updated_time DESC', 'limit' => 100)); $teachers = Teacher::model()->findAll(array('order' => 'updated_time DESC', 'limit' => 100)); $entries = $this->addEntries(array($auds, $specs, $groups, $lessons, $teachers)); foreach ($schs as $value) { $entries[] = array('id' => $value->group_id, 'module' => strtolower(get_class($value)), 'time' => $value->modified_time . rand(100000, 999999), 'time' => $value->modified_time, 'user' => $value->modified_by, 'action' => 'update'); } $entriesNew = array(); foreach ($entries as $value) { $entriesNew[$value['time'] . rand(10000, 99999)] = $value; } krsort($entriesNew); $this->render('index', array('entries' => $entriesNew)); }
public function schData() { Yii::app()->getModule('aud'); Yii::app()->getModule('spec'); Yii::app()->getModule('lesson'); Yii::app()->getModule('teacher'); $data = array(); $data['auds'] = Aud::model()->getAll(); $data['lessons'] = Lesson::model()->getAll(); $data['teachers'] = Teacher::model()->getAll(); return $data; }
public function name($module = null, $id = null) { Yii::app()->getModule('aud'); Yii::app()->getModule('group'); Yii::app()->getModule('lesson'); Yii::app()->getModule('sch'); Yii::app()->getModule('spec'); Yii::app()->getModule('teacher'); $item = ''; switch ($module) { case 'aud': if ($aud = Aud::model()->findByPk($id)) { $item = $aud->name . ' (' . Yii::app()->params['aud_types'][$aud->type] . ')'; } break; case 'group': if ($group = Group::model()->findByPk($id)) { $item = $group->group_spec->code . '-' . $group->year . '-0' . $group->number . ' (' . $group->group_spec->name . ', ' . Yii::app()->sch->course($group->year) . ' курс)'; } break; case 'lesson': if ($lesson = Lesson::model()->findByPk($id)) { $item = isset($lesson->fullname) ? $lesson->fullname : $lesson->name; } break; case 'sch': if ($sch = Sch::model()->findByPk($id)) { $item = $sch->group->groupName() . ' (' . $sch->group->group_spec->name . ', ' . Yii::app()->sch->course($sch->group->year) . ' курс)'; } break; case 'spec': if ($spec = Spec::model()->findByPk($id)) { $item = $spec->name; } break; case 'teacher': if ($teacher = Teacher::model()->findByPk($id)) { $item = $teacher->surname . ' ' . $teacher->initials; } break; default: $item = ''; break; } return $item; }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return Aud the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Aud::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function audName($id = null) { Yii::app()->getModule('aud'); return $id != null ? Aud::model()->findByPk($id)->name : false; }