public function actionDialoge()
 {
     $model = new Semester();
     $model->dptid = $this->_department->dptid;
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Semester'])) {
         $model->attributes = $_POST['Semester'];
         if ($model->save()) {
             $this->redirect(array('university/sylform', 'id' => $model->semid));
         }
     }
     $this->renderPartial('create', array('model' => $model));
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Semester();
     if (!isset($_SESSION['course_id'])) {
         $_SESSION['course_id'] = 1;
     }
     if (isset($_GET['ID'])) {
         $_SESSION['course_id'] = $_GET['ID'];
     }
     $course = Course::model()->find('ID=:ID', array("ID" => $_SESSION['course_id']));
     $model->ID_Course = $course->Name;
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Semester'])) {
         $model->attributes = $_POST['Semester'];
         $model->ID_Course = $_SESSION['course_id'];
         if ($model->save()) {
             $this->redirect(array('index', 'id' => $model->ID));
         }
     }
     $this->render('create', array('model' => $model));
 }
 public function prepareData()
 {
     $semester = new Semester();
     $semester['name'] = 'Semester';
     $semester->save();
     foreach (array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday') as $name) {
         $weekday = new Weekday();
         $weekday['name'] = $name;
         $weekday->save();
     }
     for ($i = 0; $i < 3; $i++) {
         $course = new Course();
         $course['name'] = 'Course ' . $i;
         $course['Semester'] = $semester;
         $course->save();
         for ($w = 3; $w < 6; $w++) {
             $cw = new CourseWeekday();
             $cw['Course'] = $course;
             $cw['weekday_id'] = $w;
             $cw->save();
         }
     }
 }