/** * 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 AttendanceDetail the loaded model * @throws CHttpException */ public function loadModel($id) { $model = AttendanceDetail::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function actionGetStudentAttendance() { $_SESSION['idSession'] = $_POST['id']; if ($_SESSION['idSession'] != 0) { $attendance_status = Domain::getAttendanceStatus(); $students = Student::model()->findAll('ID_Class=:idClass', array('idClass' => $_SESSION['idClass'])); $idClassSubject = $this->getIdClassSubject($_SESSION['idClass'], $_SESSION['idSubject'], Yii::app()->user->getState('idUser')); if ($this->checkAttendanceSession($_SESSION['idSession'], $this->getAttendanceSession(Yii::app()->user->getState('idUser'), $idClassSubject))) { echo $this->createTableAddtendance($attendance_status, $students); } else { $attendance = $this->getAttendance($_SESSION['idSession'], Yii::app()->user->getState('idUser'), $idClassSubject); $attendance_details = AttendanceDetail::model()->findAll('ID_Attendance=:idAttend', array('idAttend' => $attendance[0]->ID)); $attend = array(); foreach ($students as $student) { foreach ($attendance_details as $detail) { if ($student->ID == $detail->ID_Student) { $attend['Status_' . $student->Code] = $detail->Status; break; } } } echo $this->createTableAddtendance($attendance_status, $students, $attend, true); } } else { echo 'false'; } }