/** * Displays a particular model. * @param integer $id the ID of the model to be displayed */ public function actionView() { //$model = $this->loadModel($id); $phone = Yii::app()->request->getParam('phone'); $date = Yii::app()->request->getParam('date'); if ($phone && $date) { $date = date("Y-m-d", strtotime($date)); $data = GameEventUserLogModel::model()->getLogByPhone($date, $phone); $this->render('view', array('data' => $data)); } else { throw new CHttpException(404, 'The requested page does not exist.'); } }
/** * 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 the ID of the model to be loaded */ public function loadModel($id) { $model = GameEventUserLogModel::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function actionAnswer() { if (Yii::app()->request->isPostRequest) { $userPhone = yii::app()->user->getState('msisdn'); $ansId = $_POST['answer']; if (empty($ansId)) { //khong chon cau tra loi $redirect = Yii::app()->createUrl('/event/play', array('notrep' => 1, 'askid' => $_POST['askid'])); $this->redirect($redirect); Yii::app()->end(); } $resAnswer = GameEventAnswerModel::model()->findByPk($ansId); if ($resAnswer->is_true) { $point = GameEventQuestionModel::model()->findByPk($_POST['askid'])->point; } else { $point = 0; } $completedTime = date('Y-m-d H:i:s'); $gameEventLog = new GameEventUserLogModel(); $gameEventLog->setAttribute('user_phone', $userPhone); $gameEventLog->setAttribute('ask_id', $_POST['askid']); $gameEventLog->setAttribute('answer_id', $ansId); $gameEventLog->setAttribute('thread_id', $_SESSION['thread']); $gameEventLog->setAttribute('point', $point); $gameEventLog->setAttribute('started_datetime', $_SESSION['startTime']); $gameEventLog->setAttribute('completed_datetime', $completedTime); $gameEventLog->save(); $this->_removeQuestion($_POST['askid']); $_SESSION['count'] += 1; } $this->redirect('/event/play'); }