public function actionEndLectureText() { $course_lecture_id = $_POST['course_lecture_id']; $idtraininglog = $_POST['idtraininglog']; $totalText = $_POST['totalText']; $totalViewText = $_POST['totalViewText']; $viewListText = $_POST['viewListText']; $user_id = Yii::app()->user->id; $timeOK = $totalViewText / $totalText * 100; $viewText = $totalViewText . ' / ' . $totalText; $check = 'NOK'; if ($timeOK >= 90) { $check = 'OK'; } //$des = ' View : ('. number_format($timeOK,2,',','.') .'% View pages '.$viewText.')'; $des = ' Hoàn thành : (' . number_format($timeOK, 2, ',', '.') . '% Xem ' . $viewText . ')'; $desNotifi = 'Học viên hoàn thành : (' . number_format($timeOK, 2, ',', '.') . '% Xem ' . $viewText . ')'; $modelTrainingLog = WTrainingLog::model()->findByPk($idtraininglog); $modelTrainingLog->user_id = $user_id; $modelTrainingLog->description = $des; $modelTrainingLog->result = $check; $modelTrainingLog->data = $viewListText; if ($modelTrainingLog->save()) { if ($modelTrainingLog->result == 'OK') { $userinfo = WUser::getFullNameUser(Yii::app()->user->id); $couseDetails = WCourseLecture::getInfoCourse($course_lecture_id); $trainer = WUser::getFullNameUser($couseDetails["created_by"]); $title = "Học viên " . $userinfo . " hoàn thành bài giảng:" . $couseDetails["course_name"]; $content = "Dear <strong>" . $trainer . "</strong>"; $content .= "<br/>Học viên <strong>" . $userinfo . '</strong> hoàn thành Bài giảng: <a href="' . Yii::app()->createUrl("wCourse/view", array("id" => $couseDetails["id"])) . '"><strong>' . $couseDetails["course_name"] . " (" . date('H:i d/m/Y') . ")</strong></a>"; //$content .="<br/>==> <a href='".Yii::app()->createUrl("wCourse/view",array("id" => $couseDetails["id"]))."'>".$couseDetails["course_name"]."</a>"; //$content .="<br />Congratulations, you have completed the lesson. "; //$content .="<br />Xin chúc mừng, Bạn đã hoàn thành bài học. "; $content .= "<br />" . $modelTrainingLog->description; WMessage::SendMessage($title, $content, "notifi", WUser::getIDMinUser(), $couseDetails["created_by"]); $mess = 'Xin chúc mừng, Bạn đã hoàn thành bài học. <br />' . $modelTrainingLog->description; // Chúc mừng bạn đã hoàn thành bài học } else { //$mess = 'You need to learn the lesson. <br />'.$modelTrainingLog->description;//Bạn cần phải học lại bài học. $mess = 'Bạn chưa hoàn thành bài học. <br />' . $modelTrainingLog->description; //Bạn cần phải học lại bài học. } echo json_encode(array('status' => 'true', 'result' => $modelTrainingLog->result, 'mess' => $mess)); } else { echo json_encode(array('status' => 'false')); } }