Example #1
0
 public function authenticate()
 {
     if ($this->userType == 'Admin') {
         // check if login details exists in database
         $record = RsAdmin::model()->findByAttributes(array('username' => $this->username));
         if ($record === null) {
             $this->errorCode = self::ERROR_USERNAME_INVALID;
         } else {
             if (md5($this->password) !== $record->password) {
                 $this->errorCode = self::ERROR_PASSWORD_INVALID;
             } else {
                 /* $this->setState('userId',$record->userId);
                 			$this->setState('name', $record->firstName.' '.$record->lastName);*/
                 $this->setState('loginType', 'admin');
                 $this->errorCode = self::ERROR_NONE;
             }
         }
         return !$this->errorCode;
     }
     if ($this->userType == 'Front') {
         // check if login details exists in database
         $record = RsStudent::model()->findByAttributes(array('reg_code' => $this->username));
         if ($record === null) {
             $this->errorCode = self::ERROR_USERNAME_INVALID;
         } else {
             if (md5($this->password) !== $record->password) {
                 $this->errorCode = self::ERROR_PASSWORD_INVALID;
             } else {
                 $this->setState('loginType', 'front');
                 $this->errorCode = self::ERROR_NONE;
             }
         }
         return !$this->errorCode;
     }
 }
Example #2
0
 public function actionEditFinishedSeminarList()
 {
     if (!isset($_POST['s_id'])) {
         echo "There's no such Seminar";
         return;
     }
     $data = array();
     $response = array();
     $s_id = $_POST['s_id'];
     $criteria = new CDbCriteria();
     $criteria->together = true;
     $criteria->with = array('studentSeminars' => array('select' => 'studentSeminars.seminar_id, studentSeminars.apply_code,studentSeminars.attended', 'together' => true));
     $criteria->params = array();
     $criteria->addCondition('seminar_id = :s_id');
     $criteria->addCondition('attended = 1');
     $criteria->params[':s_id'] = $s_id;
     $count = RsStudent::model()->count($criteria);
     $pages = new CPagination($count);
     // results per page
     if (isset($_POST['page']) && (int) $_POST['page'] >= 0) {
         $pages->currentPage = (int) $_POST['page'] - 1;
     }
     $pages->pageSize = 10;
     $pages->applyLimit($criteria);
     $criteria->order = "reg_code ASC";
     $students = RsStudent::model()->findAll($criteria);
     $data['s_id'] = $s_id;
     $data['pages'] = $pages;
     $data['students'] = $students;
     // print_r($pages); return;
     $response['title'] = $seminar_name = RsSeminar::model()->findByPk($s_id)->name;
     $response['content'] = $this->renderPartial('_editFinishedSeminarList', $data, true);
     //set true to return html string instead of rendering it out.
     echo json_encode($response);
 }
Example #3
0
 public function actionHistory()
 {
     $data = array();
     $user_id = Yii::app()->user->id;
     $infoStudent = RsStudent::model()->findByAttributes(array('reg_code' => $user_id));
     //var_dump($infoStudent);exit;
     if ($infoStudent === null) {
         $this->redirect($this->createUrl('/login'));
     } else {
         $criteria = new CDbCriteria();
         $criteria->order = 'date DESC';
         $criteria->addCondition('student_id = ' . $infoStudent->id . '');
         $count = RsTestResult::model()->count($criteria);
         $pages = new CPagination($count);
         if (isset($_POST['page']) && (int) $_POST['page'] >= 0) {
             $pages->currentPage = (int) $_POST['page'] - 1;
         }
         // results per page
         $pages->pageSize = 10;
         $pages->applyLimit($criteria);
         $history = RsTestResult::model()->findAll($criteria);
         $data['pages'] = $pages;
         $data['testHistory'] = $history;
         echo $this->renderPartial('history', $data, true);
     }
 }
Example #4
0
 public function actionSeminarIndex()
 {
     /****issue 8220****/
     if (isset($_POST['schedule_date'])) {
         $response = array();
         $schedule_date = $_POST['schedule_date'];
         $user_id = Yii::app()->user->id;
         $infoStudent = RsStudent::model()->findByAttributes(array('reg_code' => $user_id));
         if ($infoStudent->updateAll(array('schedule_date' => $schedule_date), 'reg_code = :user_id', array('user_id' => $user_id))) {
             $response['save'] = "ok";
             echo json_encode($response);
         } else {
             $response['save'] = "fail";
             echo json_encode($response);
         }
         return;
     }
     $can_text = "";
     $user_id = Yii::app()->user->id;
     $infoStudent = RsStudent::model()->findByAttributes(array('reg_code' => $user_id));
     $studentPassedModel = new RsStudentPassed();
     $get_student = $studentPassedModel->studentCanTest($infoStudent->id, $infoStudent->student_code);
     $allData = Yii::app()->db->createCommand($get_student);
     $studentPassed = $allData->queryAll();
     if (count($studentPassed) > 0) {
         $can_text = "合格";
     } else {
         $can_text = "受講できません";
     }
     $user_id = Yii::app()->user->id;
     $infoStudent = RsStudent::model()->findByAttributes(array('reg_code' => $user_id));
     $student_id = $infoStudent->id;
     /*************申し込み中セミナー一覧**********/
     //#8665	141126
     $sSQL = "SELECT\n\t\t\t\t\t*\n\t\t\t\tFROM\n\t\t\t\t\trs_seminar,\n\t\t\t\t\trs_student_seminar\n\t\t\t\tWHERE\n\t\t\t\t\trs_seminar.id = seminar_id\n\t\t\t\t\tAND student_id = {$infoStudent->id}\n\t\t\t\t\tAND attended = 0\n\t\t\t\t\tAND to_char(CURRENT_TIMESTAMP,'yyyy-mm-dd') >= to_char(apply_from_date, 'yyyy-mm-dd' ) \n\t\t\t\t\tAND to_char(CURRENT_TIMESTAMP,'yyyy-mm-dd hh24:i:ss') <= ( to_char(start_date, 'yyyy-mm-dd') || ' ' || to_time || ':00') \n\t\t\t\tORDER BY start_date DESC, from_time ASC, to_time ASC\n\t\t\t\t";
     $listRegisted = Yii::app()->db->createCommand($sSQL)->queryAll();
     /*************受講済みセミナー一覧**********/
     $sSQL = "SELECT\n\t\t\t\t\t*\n\t\t\t\tFROM\n\t\t\t\t\trs_seminar,\n\t\t\t\t\trs_student_seminar\n\t\t\t\tWHERE\n\t\t\t\t\trs_seminar.id = seminar_id\n\t\t\t\t\tAND student_id = {$infoStudent->id}\n\t\t\t\t\tAND attended = 1\n\t\t\t\t";
     $listAttended = Yii::app()->db->createCommand($sSQL)->queryAll();
     $this->render('seminarIndex', array("student_id" => $student_id, "schedule_date" => $infoStudent->schedule_date, 'studentPassed' => $can_text, 'listAttended' => $listAttended, 'listRegisted' => $listRegisted));
 }
Example #5
0
 public function studentCodeExits($attribute, $params)
 {
     if (RsStudent::model()->findByAttributes(array('student_code' => $this->student_code))) {
         $this->addError($attribute, Yii::t("front", "student.exists"));
     }
 }
Example #6
0
 public function actionExportAttendedStudent()
 {
     Yii::import('ext.ECSVExport');
     $model = new RsStudent();
     $sql_status = $model->sql_status();
     $sql = $sql_status['sql'];
     $list_student = $model->data_query($sql);
     $data_csv = array();
     foreach ($list_student as $values) {
         $faculty = Yii::app()->params['faculty_values'][$values["faculty"]];
         $status = Yii::app()->params['status'][$values["status"]];
         $item_csv = array("名大ID" => $values["student_code"], "名前" => $values["first_name"] . ' ' . $values["last_name"], "フリガナ" => $values["first_kana"] . ' ' . $values["last_kana"], "所属" => $faculty, "学籍・教員番号" => $values["professor_code"], "状況" => $status);
         array_push($data_csv, $item_csv);
     }
     $csv = new ECSVExport($data_csv);
     //$output = $csv->toCSV();
     //$output = mb_convert_encoding($csv->toCSV(),"SJIS", "UTF-8");
     $output = mb_convert_encoding($csv->toCSV(), "SJIS-win", "UTF-8");
     $filename = "認定者一覧.csv";
     Yii::app()->getRequest()->sendFile($filename, $output, "text/csv", false);
 }