public function actionStatus() { $can_text = ""; $hideButton = true; $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 = "合格"; $hideButton = true; } else { $can_text = "受講できません"; $hideButton = false; } $this->render('status', array('studentPassed' => $can_text, 'hideButton' => $hideButton, 'student_id' => $infoStudent->id)); }
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)); }
public function actionImportData() { // if $_REQUEST info is set, process it and insert into database // then exit if (isset($_POST['action'])) { $data = $_POST['info']; $success = 0; $fail = 0; foreach ($data as $line => $record) { $line = (int) $line + 2; $criteria = new CDbCriteria(); foreach ($record as $key => $value) { $criteria->addCondition($key . "='" . $value . "'"); } $count = RsStudentPassed::model()->count($criteria); if ($count == 0) { $student_pass = new RsStudentPassed(); $student_pass->student_code = $record['student_code']; $student_pass->school_reg_code = $record['school_reg_code']; $student_pass->staff_code = $record['staff_code']; if ($student_pass->save()) { $success++; } else { $fail++; } } else { $fail++; } } echo "合格者情報の取り込みは完了しました。<br>成功: " . $success . "件<br>失敗: " . $fail . "件"; exit; } // else render the page instead $this->render('importData'); }