public function actionGetSessionOptions()
 {
     $_SESSION['idSubject'] = $_POST['id'];
     $result = '';
     if ($_SESSION['idSubject'] != 0) {
         $sql_hour = "SELECT \n                        ssj.Hour\n                        FROM tbl_classmanager AS cm \n                        INNER JOIN tbl_class_subject AS csj ON csj.ID_CLass = cm.ID \n                        INNER JOIN tbl_subject AS sj ON sj.ID = csj.ID_Subject \n                        INNER JOIN tbl_semester_subject AS ssj ON ssj.ID_Subject = sj.ID \n                        INNER JOIN tbl_hour AS h ON h.ID = csj.ID_Hour \n                        WHERE ssj.ID_Subject = :idSubject AND csj.ID_Class = :idClass AND csj.ID_Facuty = :idFacuty";
         $sql_type = "SELECT \n                        h.Type\n                        FROM tbl_classmanager AS cm \n                        INNER JOIN tbl_class_subject AS csj ON csj.ID_CLass = cm.ID \n                        INNER JOIN tbl_subject AS sj ON sj.ID = csj.ID_Subject \n                        INNER JOIN tbl_semester_subject AS ssj ON ssj.ID_Subject = sj.ID \n                        INNER JOIN tbl_hour AS h ON h.ID = csj.ID_Hour \n                        WHERE ssj.ID_Subject = :idSubject AND csj.ID_Class = :idClass AND csj.ID_Facuty = :idFacuty";
         $total_hour = SemesterSubject::model()->findBySql($sql_hour, array('idSubject' => $_SESSION['idSubject'], 'idClass' => $_SESSION['idClass'], 'idFacuty' => Yii::app()->user->getState('idUser')));
         $hour_type = Hour::model()->findBySql($sql_type, array('idSubject' => $_SESSION['idSubject'], 'idClass' => $_SESSION['idClass'], 'idFacuty' => Yii::app()->user->getState('idUser')));
         $sessions = $this->getAttendanceSession(Yii::app()->user->getState('idUser'), $this->getIdClassSubject($_SESSION['idClass'], $_SESSION['idSubject'], Yii::app()->user->getState('idUser')));
         if (strtoupper($hour_type->Type) == 'E') {
             $session = $total_hour->Hour / 3;
         } else {
             $session = $total_hour->Hour / 2;
         }
         if ($session == 0) {
             $result .= '<option value="0">Không Session</option>';
         } else {
             $result .= '<option value="0">Chọn session</option>';
             for ($i = 0; $i < $session; $i++) {
                 $disabled = '';
                 foreach ($sessions as $sess) {
                     if ($sess->Session == $i + 1) {
                         $disabled = ' class="disabled" ';
                     }
                 }
                 $result .= '<option value="' . ($i + 1) . '" ' . $disabled . '> Session ' . ($i + 1) . '</option>';
             }
         }
         echo $result;
     } else {
         echo '<option value="0">Chưa chọn lớp học</option>';
     }
 }
 /**
  * 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 SemesterSubject the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = SemesterSubject::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }