/** * Displays a particular model. * @param integer $id the ID of the model to be displayed */ public function actionTraineeViewCourse($id) { if (empty(Yii::app()->user->id)) { $this->redirect(Yii::app()->createUrl('')); } $dataCourseLecture = array(); $listTrainee = array(); $db = Yii::app()->db; if (!empty($id)) { $data = WCourseLecture::model()->findAll('course_id=' . $id . ' ORDER BY start_date ASC'); $data = CJSON::decode(CJSON::encode($data)); $course_data = WCourse::getDetailCourse($id); if (!empty($data)) { foreach ($data as $key => $item) { if (!empty($item["lecture_id"])) { $lectureDetails = WLecture::model()->find('id=' . $item['lecture_id']); if (!empty($lectureDetails)) { $category = $lectureDetails->category; $lectureDetails = CJSON::decode(CJSON::encode($lectureDetails)); $dataCourseLecture[$item['id']] = $item; $dataCourseLecture[$item['id']]['details'] = $lectureDetails; $dataCourseLecture[$item['id']]['cat_name'] = $category->cat_name; $dataCourseLecture[$item['id']]['PreTest'] = FALSE; if (strtotime($course_data["end_date"]) < strtotime($item["end_date"])) { $dataCourseLecture[$item['id']]['end_date'] = $course_data["end_date"]; } if (!empty($item['pre_test_id'])) { $comm = $db->createCommand()->select('t.*')->from('pls_user_test t')->where('course_id=' . $item['course_id'] . ' AND success = 2 AND lecture_id=' . $item['lecture_id'] . ' AND test_id=' . $item['pre_test_id'] . ' AND user_id=' . Yii::app()->user->id); $preTest = $comm->queryRow(); $comm->reset(); if (!empty($preTest)) { $dataCourseLecture[$item['id']]['PreTest'] = TRUE; } } $dataCourseLecture[$item['id']]['Test'] = FALSE; if (!empty($item['test_id'])) { $comm = $db->createCommand()->select('t.*')->from('pls_user_test t')->where('course_id=' . $item['course_id'] . ' AND success=2 AND lecture_id=' . $item['lecture_id'] . ' AND test_id=' . $item['test_id'] . ' AND user_id=' . Yii::app()->user->id); $Test = $comm->queryRow(); $comm->reset(); if (!empty($Test)) { $dataCourseLecture[$item['id']]['Test'] = TRUE; } } } } // Info Pre-Test } } $dataTrainee = WCourseTrainee::model()->findAll('course_id=' . $id); $dataTrainee = CJSON::decode(CJSON::encode($dataTrainee)); if (!empty($dataTrainee)) { foreach ($dataTrainee as $item) { $traineeDetails = WUser::model()->find('id=' . $item['trainee_id']); if (!empty($traineeDetails)) { $traineeDetails = CJSON::decode(CJSON::encode($traineeDetails)); $listTrainee[$traineeDetails['id']]['id'] = $traineeDetails['id']; $listTrainee[$traineeDetails['id']]['course_id'] = $id; $listTrainee[$traineeDetails['id']]['fullname'] = $traineeDetails['fullname']; $listTrainee[$traineeDetails['id']]['username'] = $traineeDetails['username']; } } } } $this->render('trainee/view', array('model' => $this->loadModel($id), 'dataCourseLecture' => $dataCourseLecture, 'listTrainee' => $listTrainee)); }
public function actionSendComment() { $dataType = $_REQUEST["dataType"]; $dataId = $_REQUEST["dataId"]; $action_url = $_REQUEST["action_url"]; $contentComment = $_REQUEST["contentComment"]; $parent_id = $_REQUEST["parent_id"]; $_db = Yii::app()->db; $comm = $_db->createCommand(); $result = $comm->insert('pls_comment', array('parent_id' => $parent_id, 'user_id' => Yii::app()->user->id, 'content' => $contentComment, 'data_id' => $dataId, 'data_type' => $dataType, 'status' => 1, 'created_date' => date('Y-m-d H:i:s'), 'action_url' => strtolower($action_url))); if ($result) { $idnewrecord = Yii::app()->db->getLastInsertID($result); if ($dataType == "course") { $courseDetails = WCourse::model()->find("id=" . $dataId); if (Yii::app()->user->id != $courseDetails->created_by) { $title = "Bình Luận Khóa học: " . $courseDetails->course_name; $content = ""; $user = WUser::getUserById(Yii::app()->user->id); if (Yii::app()->session["group_id"] == 1) { $content .= "Có giáo viên <strong>" . $user->username . "</strong> bình luận tại Khóa học: <a href='" . Yii::app()->createUrl('wCourse/view', array("id" => $dataId, "row" => "comment_row_" . $idnewrecord)) . "'>\"" . $courseDetails->course_name . "\"</a>"; } else { if (Yii::app()->session["group_id"] == 2) { $content .= "Có học viên <strong>" . $user->username . "</strong> bình luận tại Khóa học: <a href='" . Yii::app()->createUrl('wCourse/view', array("id" => $dataId, "row" => "comment_row_" . $idnewrecord)) . "'>\"" . $courseDetails->course_name . "\"</a>"; } else { if (Yii::app()->session["group_id"] == 3) { $content .= "Có Quản trị viên <strong>" . $user->username . "</strong> bình luận tại Khóa học: <a href='" . Yii::app()->createUrl('wCourse/view', array("id" => $dataId, "row" => "comment_row_" . $idnewrecord)) . "'>\"" . $courseDetails->course_name . "\"</a>"; } } } $content .= '<br/>Click xem chi tiết: <a href="' . Yii::app()->createUrl('wCourse/view', array("id" => $dataId, "row" => "comment_row_" . $idnewrecord)) . '">' . $courseDetails->course_name . '</a>'; WMessage::SendMessage($title, $content, "notifi", WUser::getIDMinUser(), $courseDetails->created_by); } } elseif ($dataType == "courselecture") { $courseLecture = WLecture::model()->find("id=" . $dataId); if (Yii::app()->user->id != $courseLecture->created_by) { $title = "Bình Luận Bài Giảng: " . $courseLecture->lecture_name; $content = ""; $user = WUser::getUserById(Yii::app()->user->id); if (Yii::app()->session["group_id"] == 1) { $content .= "Có giáo viên <strong>" . $user->username . "</strong> bình luận tại Bài Giảng: <a href='" . Yii::app()->createUrl('wLecture/View', array("id" => $dataId, "row" => "comment_row_" . $idnewrecord)) . "'>\"" . $courseLecture->lecture_name . "\"</a>"; } else { if (Yii::app()->session["group_id"] == 2) { $content .= "Có học viên <strong>" . $user->username . "</strong> bình luận tại Bài Giảng: <a href='" . Yii::app()->createUrl('wLecture/View', array("id" => $dataId, "row" => "comment_row_" . $idnewrecord)) . "'>\"" . $courseLecture->lecture_name . "\"</a>"; } else { if (Yii::app()->session["group_id"] == 3) { $content .= "Có Quản trị viên <strong>" . $user->username . "</strong> bình luận tại Bài Giảng: <a href='" . Yii::app()->createUrl('wLecture/View', array("id" => $dataId, "row" => "comment_row_" . $idnewrecord)) . "'>\"" . $courseLecture->lecture_name . "\"</a>"; } } } $content .= '<br/>Click xem chi tiết: <a href="' . Yii::app()->createUrl('wLecture/View', array("id" => $dataId, "row" => "comment_row_" . $idnewrecord)) . '">' . $courseLecture->lecture_name . '</a>'; WMessage::SendMessage($title, $content, "notifi", WUser::getIDMinUser(), $courseLecture->created_by); } } echo json_encode(array("result" => "true")); } else { echo json_encode(array("result" => "false")); } }
public function loadModel($id) { $model = WLecture::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
/** * Displays a particular model. * @param integer $id the ID of the model to be displayed */ public function actionViewCourse($id) { if (empty(Yii::app()->user->id)) { $this->redirect(Yii::app()->createUrl('')); } $dataCourseLecture = array(); $listTrainee = array(); if (!empty($id)) { $data = WCourseLecture::model()->findAll('course_id=' . $id); $data = CJSON::decode(CJSON::encode($data)); if (!empty($data)) { foreach ($data as $key => $item) { $lectureDetails = WLecture::model()->find('id=' . $item['lecture_id']); if (!empty($lectureDetails)) { $category = $lectureDetails->category; $lectureDetails = CJSON::decode(CJSON::encode($lectureDetails)); $dataCourseLecture[$item['id']] = $item; $dataCourseLecture[$item['id']]['details'] = $lectureDetails; $dataCourseLecture[$item['id']]['cat_name'] = $category->cat_name; } } } $dataTrainee = WCourseTrainee::model()->findAll('course_id=' . $id); $dataTrainee = CJSON::decode(CJSON::encode($dataTrainee)); if (!empty($dataTrainee)) { foreach ($dataTrainee as $item) { $traineeDetails = WUser::model()->find('id=' . $item['trainee_id']); if (!empty($traineeDetails)) { $traineeDetails = CJSON::decode(CJSON::encode($traineeDetails)); $listTrainee[$traineeDetails['id']]['id'] = $traineeDetails['id']; $listTrainee[$traineeDetails['id']]['course_id'] = $id; $listTrainee[$traineeDetails['id']]['fullname'] = $traineeDetails['fullname']; $listTrainee[$traineeDetails['id']]['username'] = $traineeDetails['username']; } } } } $this->render('supervisor/view', array('model' => $this->loadModel($id), 'dataCourseLecture' => $dataCourseLecture, 'listTrainee' => $listTrainee)); }
<!--:</span><span class="col2">--><?php //echo WCourse::getTotalCourseOfTrainer('started'); ?> <!--</span></p>--> <p><span class="col1"><?php echo Yii::t('web/home', 'Closed courses'); ?> :</span><span class="col2"><?php echo WCourse::getTotalCourseOfTrainer('closed'); ?> </span></p> <p><span class="col1"><?php echo Yii::t('web/home', 'Total lectures'); ?> :</span><span class="col2 color_cb0303"><?php echo WLecture::getTotalLectureOfTrainer(); ?> </span></p> <p><span class="col1"><?php echo Yii::t('web/home', 'Pendding trainees'); ?> :</span> <span class="col2 color_40b80c"> <?php echo WCourseTrainee::getTotalTraineeRegister(); ?> <a style="font-weight: normal;font-size: 11px;" href="<?php echo Yii::app()->createUrl('wCourseTrainee/Listtraineeall'); ?> ">View list</a> </span>
/** * This is the default 'index' action that is invoked * when an action is not explicitly requested by users. */ public function actionIndex() { $view = 'index'; if (Yii::app()->user->isGuest) { $this->redirect(array('login')); } else { if (Yii::app()->session['group_id'] == 2) { $this->layout = '//layouts/main'; $view = 'trainee/index'; $this->render($view); } elseif (Yii::app()->session['group_id'] == 1) { $this->layout = '//layouts/main'; $view = 'trainer/index'; $this->render($view); } elseif (Yii::app()->session['group_id'] == 4) { $this->layout = '//layouts/main'; $view = 'teamleader/index'; $this->render($view); } elseif (Yii::app()->session['group_id'] == 3) { $view = 'supervisor/index'; // $view = 'index'; $this->layout = '//layouts/main'; $data = array(); // biểu đồ liên quan $infoCourse = array(); $criteria = new CDbCriteria(); $criteria->condition = 'status = 1'; $criteria->order = 'id desc'; $criteria->limit = 6; $count = WUser::model()->count($criteria); $pages = new CPagination($count); // results per page $pages->pageSize = Params::$rowsPerPage; $pages->applyLimit($criteria); $infosupper = WUser::model()->findAll($criteria); // course_lecture /* $courseLecture = array(); $db = Yii::app()->db; $comm = $db->createCommand() ->select('COUNT(*)') ->from('pls_course_lecture t') ->leftJoin('pls_course t1','t1.id = t.course_id') ->leftJoin('pls_lecture t2','t2.id = t.lecture_id') ->leftJoin('pls_test t3','t3.id = t.pre_test_id') ->leftJoin('pls_test t4','t4.id = t.test_id') ->leftJoin('pls_user t5','t5.id = t.trainer_id') ->order('t.id DESC'); $total = $comm->queryScalar(); $comm->reset(); $comm = $db->createCommand() ->select(' t.*, t1.course_name, t2.lecture_name, t3.test_name, t4.test_name, t5.fullname ') ->from('pls_course_lecture t') ->leftJoin('pls_course t1','t1.id = t.course_id') ->leftJoin('pls_lecture t2','t2.id = t.lecture_id') ->leftJoin('pls_test t3','t3.id = t.pre_test_id') ->leftJoin('pls_test t4','t4.id = t.test_id') ->leftJoin('pls_user t5','t5.id = t.trainer_id') ->order('t.id ASC'); $limit = 6; $page = (isset($_GET['page']) AND !empty($_GET['page'])) ? $_GET['page'] : 1; $offset = $limit * ($page-1); $comm->limit = $limit; $comm->offset = $offset; $courseLecture = $comm->queryAll(); $pages = new CPagination($total); $pages->pageSize = $limit; */ $courseLecture = array(); $courseLecture = WCourseLecture::model()->findAll(); $Lectures = array(); $Lectures = WLecture::model()->findAll(); // course trainne /* $courseTrainee = array(); $db = Yii::app()->db; $comm = $db->createCommand() ->select('COUNT(*)') ->from('pls_course_trainee t') ->leftJoin('pls_course t1','t1.id = t.course_id') ->leftJoin('pls_user t2','t2.id = t.trainee_id') ->order('t.id DESC'); $total = $comm->queryScalar(); $comm->reset(); $comm = $db->createCommand() ->select(' t.*, t1.course_name, t2.fullname ') ->from('pls_course_trainee t') ->leftJoin('pls_course t1','t1.id = t.course_id') ->leftJoin('pls_user t2','t2.id = t.trainee_id') ->order('t.id ASC'); $limit = 10; $page = (isset($_GET['page']) AND !empty($_GET['page'])) ? $_GET['page'] : 1; $offset = $limit * ($page-1); $comm->limit = $limit; $comm->offset = $offset; $courseTrainee = $comm->queryAll(); $pages = new CPagination($total); $pages->pageSize = $limit;*/ // course_trainee $db = Yii::app()->db; $comm = $db->createCommand()->select('count(*)')->from('pls_user t')->where('t.user_group_id=2'); $total = $comm->queryScalar(); $comm->reset(); $comm = $db->createCommand()->select('*')->from('pls_user t')->where('t.user_group_id=2'); $limit = 5; $page = (isset($_GET['page']) and !empty($_GET['page'])) ? $_GET['page'] : 1; $offset = $limit * ($page - 1); $comm->limit = $limit; $comm->offset = $offset; $data = $comm->queryAll(); $result = array(); if (!empty($data)) { foreach ($data as $item) { $result[$item['id']] = $item; $comm->reset(); $comm = $db->createCommand()->select('t2.course_name')->from('pls_course_trainee t')->leftJoin('pls_course t2', 't.course_id= t2.id')->where('t.trainee_id=' . $item['id'] . ' AND t.status = 1'); $Trainee = $comm->queryAll(); $result[$item['id']]['course_list'] = $Trainee; } } $pages = new CPagination($total); $pages->pageSize = $limit; $TraineeUser = array(); $TraineeUser = WUser::model()->findAll('status=1 and user_group_id=2'); // var_dump(count($TraineeUser)); $TrainerUser = array(); $TrainerUser = WUser::model()->findAll('status =1 and user_group_id=1'); // var_dump(count($TrainerUser)); $sum = array(); $sum = array_merge($TraineeUser, $TrainerUser); // var_dump(count($sum));die; // var_dump(count($sumUser));die; // course_trainer $db = Yii::app()->db; $comm = $db->createCommand()->select('count(*)')->from('pls_user t')->where('t.user_group_id=1'); $total = $comm->queryScalar(); $comm->reset(); $comm = $db->createCommand()->select('*')->from('pls_user t')->where('t.user_group_id=1'); $limit = 6; $page = (isset($_GET['page']) and !empty($_GET['page'])) ? $_GET['page'] : 1; $offset = $limit * ($page - 1); $comm->limit = $limit; $comm->offset = $offset; $data = $comm->queryAll(); $resultTrainer = array(); if (!empty($data)) { foreach ($data as $item) { $result[$item['id']] = $item; $comm->reset(); $comm = $db->createCommand()->select('t2.course_name')->from('pls_course_trainee t')->leftJoin('pls_course t2', 't.course_id= t2.id')->where('t.trainee_id=' . $item['id'] . ' AND t.status = 1'); $courseTrainee = $comm->queryAll(); $resultTrainer[$item['id']]['course_list'] = $courseTrainee; } } $pages = new CPagination($total); $pages->pageSize = $limit; // var_dump(count($resultTrainer));die; // course_result_test $courseTest = array(); $db = Yii::app()->db; $comm = $db->createCommand()->select('COUNT(*)')->from('pls_user_test t')->leftJoin('pls_course t1', 't1.id = t.course_id')->leftJoin('pls_user t2', 't2.id = t.user_id')->leftJoin('pls_test t3', 't3.id = t.test_id')->order('t.course_id DESC'); $total = $comm->queryScalar(); $comm->reset(); $comm = $db->createCommand()->select(' t.*, t1.course_name, t2.fullname, t3.total_point ')->from('pls_user_test t')->leftJoin('pls_course t1', 't1.id = t.course_id')->leftJoin('pls_user t2', 't2.id = t.user_id')->leftJoin('pls_test t3', 't3.id = t.test_id')->order('t.course_id ASC'); $limit = 6; $page = (isset($_GET['page']) and !empty($_GET['page'])) ? $_GET['page'] : 1; $offset = $limit * ($page - 1); $comm->limit = $limit; $comm->offset = $offset; $courseTest = $comm->queryAll(); $pages = new CPagination($total); $pages->pageSize = $limit; // lecture_schedule $lectureSchedule = array(); $db = Yii::app()->db; $comm = $db->createCommand()->select('COUNT(*)')->from('pls_course_lecture t')->leftJoin('pls_course t1', 't1.id = t.course_id')->leftJoin('pls_lecture t2', 't2.id = t.lecture_id')->leftJoin('pls_user t5', 't5.id = t.trainer_id')->order('t.trainer_id DESC'); $total = $comm->queryScalar(); $comm->reset(); $comm = $db->createCommand()->select(' t.*, t1.course_name, t2.lecture_name, t5.fullname ')->from('pls_course_lecture t')->leftJoin('pls_course t1', 't1.id = t.course_id')->leftJoin('pls_lecture t2', 't2.id = t.lecture_id')->leftJoin('pls_user t5', 't5.id = t.trainer_id')->order('t.trainer_id DESC'); $limit = 6; $page = (isset($_GET['page']) and !empty($_GET['page'])) ? $_GET['page'] : 1; $offset = $limit * ($page - 1); $comm->limit = $limit; $comm->offset = $offset; $lectureSchedule = $comm->queryAll(); $pages = new CPagination($total); $pages->pageSize = $limit; // running course $db = Yii::app()->db; $comm = $db->createCommand()->select('COUNT(*)')->from('pls_course t')->leftJoin('pls_course_cat t1', 't1.id = t.course_cat_id')->where('t.status = 2 and t.end_date > NOW()')->order('t.start_date ASC'); $total = $comm->queryScalar(); $comm->reset(); $comm = $db->createCommand()->select(' t.*, t1.course_cat, t1.avatar ')->from('pls_course t')->leftJoin('pls_course_cat t1', 't1.id = t.course_cat_id')->where('t.status = 2 and t.end_date > NOW()')->order('t.start_date ASC'); $limit = 6; $page = (isset($_GET['page']) and !empty($_GET['page'])) ? $_GET['page'] : 1; $offset = $limit * ($page - 1); $comm->limit = $limit; $comm->offset = $offset; $runningCourse = $comm->queryAll(); $pages = new CPagination($total); $pages->pageSize = $limit; $totalCourse = array(); $coursependding = array(); $courseactive = array(); $coursestart = array(); $coursecomplete = array(); $totalCourse = WCourse::model()->findAll(); $coursependding = WCourse::model()->findAll('status=0'); $courseactive = WCourse::model()->findAll('status=1'); $coursestart = WCourse::model()->findAll('status=2'); $coursecomplete = WCourse::model()->findAll('status=5'); $imgoverview = '<img width="680px" height="360px" src="' . Yii::app()->theme->baseUrl . '/img/overview.png" />'; // training proccessing $dashCourse = array(); $db = Yii::app()->db; $comm = $db->createCommand()->select('COUNT(*)')->from('pls_course t')->leftJoin('pls_user t2', 't2.id = t.trainer_id')->order('t.status ASC'); $total = $comm->queryScalar(); $comm->reset(); $comm = $db->createCommand()->select(' t.*, t2.fullname ')->from('pls_course t')->leftJoin('pls_user t2', 't2.id = t.trainer_id')->order('t.status ASC'); $dashCourse = $comm->queryAll(); $total_pages = ceil(count($dashCourse) / Params::$coursePerPage); $test = $db->createCommand(' SELECT course_id, user_id, AVG(point_percent), YEAR(end_date) ,Y.course_name FROM( SELECT A.course_id, A.lecture_id, A.test_id, A.pass_score_point, A.user_id, C.total_point, ROUND(IFNULL(A.pass_score_point, 0)*100 / C.total_point, 0) point_percent FROM pls_user_test A INNER JOIN pls_test C ON A.test_id = C.id WHERE A. status = 1 AND A.success = 2 GROUP BY A.course_id, A.test_id, A.user_id, A.lecture_id ) X INNER JOIN pls_course Y ON X.course_id = Y.id WHERE Y.end_date < NOW() GROUP BY course_id, end_date ,course_name , YEAR(end_date) ORDER BY YEAR(end_date) ASC '); $test = $test->queryAll(); // MyHelper::dump($test);die; $this->render($view, array('total_pages' => $total_pages, 'test' => $test, 'totalCourse' => $totalCourse, 'coursependding' => $coursependding, 'courseactive' => $courseactive, 'coursestart' => $coursestart, 'coursecomplete' => $coursecomplete, 'Lectures' => $Lectures, 'TraineeUser' => $TraineeUser, 'TrainerUser' => $TrainerUser, 'sum' => $sum, 'imgoverview' => $imgoverview, 'runningCourse' => $runningCourse, 'courseTrainer' => $resultTrainer, 'courseTrainee' => $result, 'courseLecture' => $courseLecture, 'courseTest' => $courseTest, 'lectureSchedule' => $lectureSchedule)); // $this->render($view,array('courseTrainee'=>$courseTrainee, 'courseLecture'=>$courseLecture, 'courseTest'=>$courseTest,'lectureSchedule'=>$lectureSchedule)); } } }