public function actionCourses1() { $criteria = new CDbCriteria(); // $criteria->condition ='user_group_id=1'; $criteria->order = 'id desc'; $criteria->limit = 10; $count = WCourse::model()->count($criteria); $pages = new CPagination($count); $pages->pageSize = Params::$rowsPerPage; $pages->applyLimit($criteria); $courselist = WCourse::model()->findAll($criteria); $data = array(); $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 = 0 OR t.status = 1')->order('t.id DESC'); $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 = 0 OR t.status = 1')->order('t.id DESC'); $result = $comm->queryAll(); $limit = 10; $page = (isset($_GET['page']) and !empty($_GET['page'])) ? $_GET['page'] : 1; $offset = $limit * ($page - 1); $comm->limit = $limit; $comm->offset = $offset; $data = $comm->queryAll(); if (!empty($data)) { $data = CJSON::decode(CJSON::encode($data)); } $count = WCourse::model()->count($criteria); $pages = new CPagination($count); $pages->pageSize = Params::$rowsPerPage; $pages->applyLimit($criteria); // var_dump($data);die; $this->render('listcourse', array('data' => $data, 'courselist' => $courselist, 'pages' => $pages)); }
public function actionCopyCourse() { $idcourse = $_REQUEST["idcourse"]; $dataCourse = WCourse::model()->find("id=" . $idcourse); $check = 0; if (!empty($dataCourse)) { $modelCourse = new WCourse(); $modelCourse->approve = $dataCourse->approve; $modelCourse->avatar = $dataCourse->avatar; $modelCourse->course_cat_id = $dataCourse->course_cat_id; $space = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; $newCode = ""; $index = 0; for ($i = 0; $i < strlen($space); $i++) { $checkData = WCourse::model()->findAll("course_code='" . $dataCourse->course_code . $space[$i] . "'"); if (empty($checkData)) { $newCode = $dataCourse->course_code . $space[$i]; break; } else { $index++; } } $name = "Copy "; if ($index != 0) { $name .= $index . ' '; } $modelCourse->course_code = $newCode; $modelCourse->course_name = $name . $dataCourse->course_name; $modelCourse->created_by = $dataCourse->created_by; $modelCourse->created_date = date('Y-m-d H:i:s'); $modelCourse->description = $dataCourse->description; $modelCourse->start_date = NULL; $modelCourse->end_date = NULL; $modelCourse->hot_course = 0; $modelCourse->intruduce = $dataCourse->intruduce; $modelCourse->lecture_count = $dataCourse->lecture_count; $modelCourse->status = $dataCourse->status; $modelCourse->trainee_count = 0; $modelCourse->trainer_id = $dataCourse->trainer_id; if ($modelCourse->save()) { $idcoursenew = $modelCourse->id; $dataCourseLecture = WCourseLecture::model()->findAll('course_id=' . $idcourse . ' ORDER BY start_date ASC'); if (!empty($dataCourseLecture)) { foreach ($dataCourseLecture as $courselecture) { $modelCourseLecture = new WCourseLecture(); $modelCourseLecture->course_id = $idcoursenew; $modelCourseLecture->end_date = NULL; $modelCourseLecture->start_date = NULL; $modelCourseLecture->status = $courselecture->status; $modelCourseLecture->trainer_id = $courselecture->trainer_id; $modelCourseLecture->lecture_id = $courselecture->lecture_id; if ($modelCourseLecture->save()) { } else { $check = 2; } } } } else { $check = 1; } } $mess = ""; $status = "true"; if ($check == 0) { $mess = "Copy thành công"; $status = "true"; } elseif ($check == 1) { $status = "false"; $mess = "Không thêm mới được Course. Lỗi thao tác, mời bạn thử lại."; } else { $status = "false"; $mess = "Lỗi thao tác, mời bạn thử lại."; } echo json_encode(array("result" => $status, 'message' => $mess)); }
public function actionTraineeCalendarLecture($id) { if (empty(Yii::app()->user->id)) { $this->redirect(Yii::app()->createUrl('')); } $course = WCourse::model()->find('id=' . $id); $db = Yii::app()->db; $comm = $db->createCommand()->select('t.*,t3.lecture_name,t3.lecture_type,t2.lecture_id,t2.start_date,t2.end_date,t2.id as idcourselecture,t4.fullname,t4.username')->from('pls_course_trainee t')->leftJoin('pls_course_lecture t2', 't.course_id=t2.course_id')->leftJoin('pls_lecture t3', 't3.id=t2.lecture_id')->leftJoin('pls_user t4', 't4.id=t2.trainer_id')->where('t2.course_id=' . $id . ' AND t.trainee_id=' . Yii::app()->user->id)->order('t2.start_date ASC'); $data = $comm->queryAll(); $this->render('trainee/calendar_lecture', array('course' => $course, 'data' => $data)); }
public static function getTestByCourse() { $criteria = new CDbCriteria(); $criteria->alias = 'c'; $criteria->distinct = true; //$criteria->select = 'cl.*, c.*'; //$criteria->join = 'LEFT JOIN {{user_test}} AS ut ON c.id = ut.course_id'; //$criteria->join = 'LEFT JOIN {{course_lecture}} AS cl ON cl.course_id = c.id'; $criteria->condition = 'c.created_by=:created_by and c.status>=:status'; $criteria->params = array(':created_by' => Yii::app()->user->id, ':status' => 1); $criteria->order = ''; $rs = WCourse::model()->findAll($criteria); //$sql = "Select "; //var_dump($rs);exit(); if ($rs) { return $rs; } else { return null; } }
<?php $form = $this->beginWidget('CActiveForm', array('id' => 'wcourse-trainee-form', 'focus' => '#LoginForm_username', 'enableAjaxValidation' => false)); ?> <p class="note">Fields with <span class="required">*</span> are required.</p> <?php echo $form->errorSummary($model); ?> <div class="row"> <?php echo $form->labelEx($model, 'course_id'); ?> <?php echo $form->dropDownList($model, 'course_id', CHtml::listData(WCourse::model()->findAll(), 'id', 'course_name'), array('prompt' => 'Chọn khóa học :')); ?> <?php echo $form->error($model, 'course_id'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'trainee_id'); ?> <?php echo $form->dropDownList($model, 'trainee_id', CHtml::listData(WUser::model()->findAll("group_id=2"), 'id', 'fullname'), array('class' => 'chosen-select', 'multiple' => 'multiple', 'data-placeholder' => "Chọn học viên vào lớp")); ?> <?php
/** * Luu ket qua test vao db **/ public function actionResult() { $this->layout = '//layouts/main_trainer'; $cs = Yii::app()->getClientScript(); $cs->registerCssFile(Yii::app()->theme->baseUrl . '/css/jquery-ui.css?ver=' . time()); $cs->registerCssFile(Yii::app()->theme->baseUrl . '/css/dialog.css?ver=' . time()); //$cs->registerCssFile(Yii::app()->theme->baseUrl.'/css/jquery.countdown.css?ver='.time()); $cs->registerScriptFile(Yii::app()->theme->baseUrl . '/js/jquery.simplemodal-1.4.4.js', CClientScript::POS_END); $cs->registerScriptFile(Yii::app()->theme->baseUrl . '/js/jquery-ui.js'); $cs->registerScriptFile(Yii::app()->theme->baseUrl . '/js/jquery.slimscroll.min.js'); $courseid = isset($_REQUEST['course_id']) ? $_REQUEST['course_id'] : ''; $lecture_id = isset($_REQUEST['lecture_id']) ? $_REQUEST['lecture_id'] : ''; $test_id = isset($_REQUEST['test_id']) ? $_REQUEST['test_id'] : ''; $total = isset($_REQUEST['total']) ? $_REQUEST['total'] : ''; $kind = isset($_REQUEST['kind']) ? $_REQUEST['kind'] : ''; //Thong tin bai test $testDetails = WTestParent::model()->find("id=" . $test_id); //Get tong so cau hoi $db = Yii::app()->db; $comm = $db->createCommand()->select('t.*')->from('pls_test_user t')->where('t.id_test_parent=' . $test_id . ' AND t.user_id=' . Yii::app()->user->id . ' AND kind=' . $kind . ' AND t.course_id=' . $courseid . ' AND t.lecture_id=' . $lecture_id); $dataTestUser = $comm->queryRow(); if (empty($dataTestUser)) { $this->redirect(Yii::app()->createUrl("/")); } $totalquestion = 0; $totalTrue = 0; $totalQuestionText = 0; $totalfails = 0; $totalnotdoing = 0; $totalnoanswer = 0; if (!empty($dataTestUser) and !empty($dataTestUser["dataquestion"])) { if (!empty($dataTestUser["dataquestion"])) { $dataquestion = json_decode($dataTestUser["dataquestion"], true); $totalquestion = count($dataquestion); } //lay so cau hoi dung if (!empty($dataTestUser["datafinish"])) { $datafinish = json_decode($dataTestUser["datafinish"], true); foreach ($datafinish as $itemdatafinish) { if ($itemdatafinish["question_type"] != 2 and isset($itemdatafinish["check"]) and $itemdatafinish["check"] == "OK") { ++$totalTrue; } elseif ($itemdatafinish["question_type"] != 2 and isset($itemdatafinish["check"]) and $itemdatafinish["check"] == "NOK" and isset($itemdatafinish["doing"]) and $itemdatafinish["doing"] == 1) { $totalfails++; } elseif ($itemdatafinish["question_type"] != 2 and isset($itemdatafinish["check"]) and $itemdatafinish["check"] == "NOK" and isset($itemdatafinish["doing"]) and $itemdatafinish["doing"] == 0) { $totalnotdoing++; } elseif ($itemdatafinish["question_type"] == 2) { ++$totalQuestionText; } elseif (!isset($itemdatafinish["check"])) { ++$totalnoanswer; } } } } // Tong diem $comm->reset(); $comm = $db->createCommand()->select('t.*')->from('pls_user_test t')->where('t.test_id=' . $test_id . ' AND test_kind=' . $kind . ' AND t.course_id=' . $courseid . ' AND t.lecture_id=' . $lecture_id . ' AND user_id=' . Yii::app()->user->id); $dataUserTest = $comm->queryRow(); $courseDetails = WCourse::model()->find("id=" . $courseid); $username = WUser::getFullNameUser(Yii::app()->user->id); $trainer = WUser::getFullNameUser($courseDetails->created_by); $title = "Học viên " . $username . " Làm xong bài Test :" . $testDetails->test_name; $content = "Dear <strong>" . $trainer . "</strong>"; $content .= "<br/>Có học viên <strong>" . $username . "</strong> làm xong bài test : " . $testDetails->test_name . " (" . date('H:i d/m/Y') . ")"; $content .= "<br/><a href='" . Yii::app()->createUrl("wUserTest/viewdetails", array("id" => $dataUserTest["id"])) . "'>Click để xem chi tiết</a>"; WMessage::SendMessage($title, $content, "notifi", WUser::getIDMinUser(), $courseDetails->created_by); $modeltest = WTest::model()->find('id=:id', array(':id' => $test_id)); $this->render('/wTest/trainee/_result', array('testDetails' => $testDetails, 'totalquestion' => $totalquestion, 'totalQuestionText' => $totalQuestionText, 'totalTrue' => $totalTrue, 'totalfails' => $totalfails, 'totalnotdoing' => $totalnotdoing, 'totalnoanswer' => $totalnoanswer, 'dataUserTest' => $dataUserTest, 'dataTestUser' => $dataTestUser)); }
" class="btn btn-info" style="float: right; margin-right: 10px; margin-top: 20px;">Category Test</a> <a class="btn btn-warning" style="float: right; margin-right: 10px; margin-top: 20px;" href="<?php echo Yii::app()->createUrl('wTest/QuestionLib'); ?> "><span class="btn_right">Ngân hàng câu hỏi</span></a> <div class="clear"></div> </div> </div> <div class="primary_container"> <div class="primary_container_test" style="box-shadow: 0px 0px 0px; border: 0px; "> <div class="container_test"> <div class="col-md-12" style="padding-bottom:15px;"> <b style="float:left;margin:5px 0;">Filter</b> <div class="col-md-3"> <?php echo CHtml::dropDownList("course_list_id", 'course_list_id', CHtml::listData(WCourse::model()->findAll("status=1"), 'id', 'course_name'), array("onchange" => "return LoadTestResult();", 'prompt' => '--' . Yii::t('web/home', 'Select Course') . '--', 'class' => 'form-control chosen-select')); ?> </div> <div class="col-md-3"> <select id="test_kind" name="course" onchange="return LoadTestResult();" class="form-control"> <option value="">Select Type</option> <option value="1">Pre Test</option> <option value="0">Post Test</option> </select> </div> <div class="col-md-3"> <select id="test_success" onchange="return LoadTestResult();" class="form-control"> <option value="" selected="selected">Select Success</option> <option value="1">Chưa hoàn thành(Chờ chấm điểm)</option> <option value="2">Hoàn Thành</option>
/** * 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 WCourse the loaded model * @throws CHttpException */ public function loadModel($id) { $model = WCourse::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
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")); } }
/** * 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)); } } }
public function actionIndex() { $countCourses = WCourse::model()->findAll(); $total_pages = ceil(count($countCourses) / params::$coursePerPage); $this->render('index', array('total_pages' => $total_pages)); }
// $newValue = Yii::app()->createUrl('aaa'); // echo CHtml::dropDownList('filter_season', $newValue, $listname); // } ?> <!-- <?php echo CHtml::form(array('extra/save'), 'post'); echo CHtml::hiddenField('model', 'wcoursetrainee'); ?> <div class='menuaction' > <?php echo CHtml::ajaxSubmitButton(Yii::t('app', 'Save'), array('/extra/save'), array('type' => 'POST', 'success' => 'function(data, textStatus, XMLHttpRequest) { $("#wcoursetrainee-grid").yiiGridView.update("wcoursetrainee-grid"); }', array('')), array('')); ?> </div> <?php $this->widget('zii.widgets.grid.CGridView', array('id' => 'wcoursetrainee-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array(array('name' => 'course_id', 'value' => 'WCourse::model()->findByPk($data->course_id) == null ? "" : WCourse::model()->findByPk($data->course_id)->course_name', 'filter' => CHtml::listData(WCourse::model()->findAll('status=1 and trainee_count >0'), 'id', 'course_name')), array('name' => 'avatar', 'value' => 'WUser::model()->findByPk($data->trainee_id) == null ? "" : CHtml::image(Yii::app()->params["url_base"]."/uploads/avatars/user/".WUser::model()->findByPk($data->trainee_id)->avatar)', 'type' => 'image'), array('name' => 'Trainee', 'value' => 'WUser::model()->findByPk($data->trainee_id) == null ? "" : WUser::model()->findByPk($data->trainee_id)->fullname'), array('name' => 'email', 'value' => 'WUser::model()->findByPk($data->trainee_id) == null ? "" : WUser::model()->findByPk($data->trainee_id)->email'), array('name' => 'phone', 'value' => 'WUser::model()->findByPk($data->trainee_id) == null ? "" : WUser::model()->findByPk($data->trainee_id)->phone'), array('name' => 'address', 'value' => 'WUser::model()->findByPk($data->trainee_id) == null ? "" : WUser::model()->findByPk($data->trainee_id)->address'), array('name' => 'birthday', 'value' => 'WUser::model()->findByPk($data->trainee_id) == null ? "" : WUser::model()->findByPk($data->trainee_id)->date_birth'), array('name' => 'status', 'header' => 'status', 'value' => '($data->status=="1")?("Pendding"):("Activated")')))); ?> <?php echo CHtml::endForm(); ?> --> </div> <table class="table table-hover"> <thead class="first_thead"> <tr> <th>Avatar</th> <th>User Account</th> <th>Full name</th> <th>Company</th> <th>Email</th>
public function actionActiveCourse() { // active course group_id=3 $courseId = $_POST['course_id']; $status = $_POST['status']; $model = WCourse::model()->findByPk($courseId); // var_dump($model);die; if ($status == 1) { $model->status = 0; } else { $model->status = 1; } if ($model->save()) { $userFrom = Yii::app()->user->id; $userTo = $model->created_by; $username = WUser::getFullNameUser($userTo); $title = "Khoá học :" . $model->course_name . ' của bạn đã được kích hoạt'; $content = "Dear <strong>" . $username . "</strong>"; $content .= "<br/>Khóa học của bạn đã được kích hoạt hoàn toàn"; $content .= "<br/>Ngay bây giờ bạn có thể cho học viên của bạn học những bài giảng của khóa học này."; $content .= "<br/>Click đi đến bài viết <a href='" . Yii::app()->createUrl('wCourse/view', array("id" => $courseId)) . "'>" . $model->course_name . "</a> "; $content .= "<br/>Chúc bạn một ngày làm việc tốt"; WMessage::SendMessage($title, $content, "notifi", $userFrom, $userTo); $status = json_encode(array('status' => 'true', 'result' => $model->status)); } else { $status = json_encode(array('status' => 'false')); } echo $status; }
/** * Lists all models. */ public function actionIndex() { if (empty(Yii::app()->user->id) || Yii::app()->session['group_id'] == 2 || empty($_REQUEST['course_id'])) { $this->redirect(Yii::app()->createUrl('')); } $courseId = $_REQUEST['course_id']; $model = WCourse::model()->find('id=' . $courseId); $offset = 0; $limit = 6; $where = ''; if (!empty($_REQUEST['course_id'])) { $where .= ' AND t2.id=' . $_REQUEST['course_id']; } if (Yii::app()->session["group_id"] == 3) { } elseif (Yii::app()->session["group_id"] == 2) { $where .= " AND t2.trainer_id=" . Yii::app()->user->id; } $db = Yii::app()->db; $comm = $db->createCommand()->select('COUNT(*)')->from('pls_course_trainee t1')->leftJoin('pls_course t2', 't2.id= t1.course_id')->leftJoin('pls_user t3', 't1.trainee_id = t3.id')->where('t3.user_group_id=2 ' . $where); $total = $comm->queryScalar(); $comm->reset(); $comm = $db->createCommand()->select('t2.course_name,t2.id as course_id,t2.course_code,t1.status,t1.id as idcoursetrainee,t3.username,t3.fullname,t3.email,t3.phone,t3.company,t3.id')->from('pls_course_trainee t1')->leftJoin('pls_course t2', 't2.id= t1.course_id')->leftJoin('pls_user t3', 't1.trainee_id = t3.id')->where('t3.user_group_id=2 ' . $where)->order('t1.status ASC,t1.register_date ASC'); $comm->limit = $limit; $comm->offset = $offset; $data = $comm->queryAll(); $comm = $db->createCommand()->select('COUNT(*)')->from('pls_course_trainee t1')->leftJoin('pls_course t2', 't2.id= t1.course_id')->leftJoin('pls_user t3', 't1.trainee_id = t3.id')->where('t3.user_group_id=2 ' . $where); $countTrainee = $comm->queryScalar(); $total_pages = ceil($countTrainee / 6); $this->render('index', array('total_pages' => $total_pages, 'model' => $model, 'data' => $data)); }