/**
  * Expire login
  * User need change password to insite
  * @return boolean whether login
  */
 public static function expire()
 {
     $user = WUser::model()->find('LOWER(username)=?', array(strtolower(Yii::app()->user->name)));
     $time_changepass = strtotime($user['time_changepass']);
     $now = time();
     $datediff = $now - $time_changepass;
     $number_date = floor($datediff / (60 * 60 * 24));
     if (isset($time_changepass) && $time_changepass != '' || $number_date <= Yii::app()->params->number_date_expire) {
         return false;
     } else {
         return true;
     }
 }
 /**
  * Authenticates a user.
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     $user = WUser::model()->find('LOWER(username)=?', array(strtolower($this->username)));
     //var_dump($user); exit();
     //echo CFunction::encrypt($this->password,Yii::app()->params->hashkey);exit();
     //echo $user->validatePassword($this->password,Yii::app()->params->hashkey);exit();
     if ($user === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if (!$user->validatePassword($this->password, Yii::app()->params->hashkey)) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             $this->_id = $user->id;
             //$this->_group_id = $user->group;
             $this->username = $user->username;
             $this->errorCode = self::ERROR_NONE;
             //update login
         }
     }
     return $this->errorCode == self::ERROR_NONE;
 }
Exemple #3
0
    }
    ?>
">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="inputCompany" class="col-sm-4 control-label">Company</label>
                                <div class="col-sm-8">
                                    <input type="text" id="inputCompany" class="form-control" style="margin-bottom: 10px;" name="company" value="<?php 
    if ($data['company']) {
        echo $data['company'];
    }
    ?>
">
                                    <?php 
    echo CHtml::dropDownList("compay_id", "company_id", CHtml::listData(WUser::model()->findAll(), "company", "company"), array('prompt' => '--' . Yii::t('web/home', 'Select Company') . '--', "onchange" => "return OnChangeCompany(this)", "class" => "form-control chosen-select", "style" => "margin-top:10px"));
    ?>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="inputPhone" class="col-sm-4 control-label">Phone</label>
                                <div class="col-sm-8">
                                    <input type="text" id="inputPhone" class="form-control" name="phone" value="<?php 
    if ($data['region']) {
        echo $data['phone'];
    }
    ?>
">
                                </div>
                            </div>
                            <div class="form-group">
 /**
  * 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 WUser the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = WUser::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
?>
/webRTC/js/firebase.js"></script>
<script type="text/javascript" src="<?php 
echo Yii::app()->params['url_base'];
?>
/webRTC/js/RTCMultiConnection-v2.2.4.js"></script>
<!--<script type="text/javascript" src="--><?php 
//echo Yii::app()->params['url_base'];
?>
<!--/webRTC/js/getMediaElement.css"></script>-->
<script type="text/javascript" src="<?php 
echo Yii::app()->params['url_base'];
?>
/webRTC/js/getMediaElement.js"></script>
<?php 
$dataUser = WUser::model()->find("id=" . Yii::app()->user->id);
?>

<div class="primary_boxtop">
    <div class="primary_boxtop_content">
        <h1 class="fl"><img src="<?php 
echo Yii::app()->theme->baseUrl;
?>
/img/icon-webinar.png" align="middle" alt="Course" /><?php 
echo $dataCourseLecture['lecture_name'];
?>
</h1>
        <div class="clear"></div>
    </div>
</div>
<div class="primary_container">
 /**
  * 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));
 }
Exemple #7
0
?>
		<?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 
echo $form->error($model, 'trainee_id');
?>
            <input type="hidden" id="list_trainee" name="list_trainee" />
        <?php 
$cs = Yii::app()->getClientScript();
$cs->registerCssFile(Yii::app()->theme->baseUrl . '/chosen/chosen.css');
?>
        <script type="text/javascript">
            function add_chosen(item) {
                $('#list_trainee').val($('#list_trainee').val()+item.value+",");
            };

            function delete_chosen(item) {
 public static function getUserById($id)
 {
     return WUser::model()->find('id=:id', array(':id' => $id));
 }
 /**
  * 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));
 }
Exemple #10
0
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title"><?php 
echo Yii::t('web/home', 'titleBoxAddTrainee');
?>
</h4>
            </div>
            <!--form search-->
            <div class="modal-body" >
                <label class="sr-only"><?php 
echo Yii::t('web/home', 'Search');
?>
</label>
                <input type="text" id="trainee_username" class="form-control" placeholder="Username Or Fullname Or Email" style="width: 600px;float: left;">
                <?php 
echo Chtml::dropDownList('dataListCompany', 'id', Chtml::listData(WUser::model()->findAll('company is NOT NULL GROUP BY company'), "company", "company"), array('empty' => Yii::t('web/home', 'Select a Company'), 'style' => 'width:215px;float:left;margin-left:10px', 'class' => 'form-control'));
?>
                <button type="button" onclick="return loadTraineeOption();" class="btn btn-success" style="margin-left: 10px; float: left;"><?php 
echo Yii::t('web/home', 'Search');
?>
</button>
                <div id="bodyTraineeList" style="float: left;width: 100%; margin-top: 10px;"></div>
                <div class="clear"></div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-success btn-sm" onclick="return addMutilTrainee();"><?php 
echo Yii::t('web/home', 'titleBoxAddTraineeButtonAdd');
?>
</button>
                <button type="button" class="btn btn-danger btn-sm" data-dismiss="modal" ><?php 
echo Yii::t('web/home', 'titleBoxAddTraineeButtonClose');
    /**
     * 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));
            }
        }
    }
                <?php 
echo $form->textArea($model, 'address', array('size' => 60, 'maxlength' => 255, 'class' => 'form-control'));
?>
                <?php 
echo $form->error($model, 'address');
?>
            </td>
        </tr>
        <tr>
            <td width="130"><?php 
echo $form->labelEx($model, 'supervisor_code');
?>
</td>
            <td  style="padding-bottom: 10px;">
                <?php 
echo $form->dropDownList($model, 'supervisor_code', CHtml::listData(WUser::model()->findAll('status=:status and user_group_id=:group_id', array(':status' => 1, ':group_id' => 3)), "username", "fullname"), array('class' => 'form-control'));
?>
                <?php 
echo $form->error($model, 'supervisor_code');
?>
            </td>
        </tr>
        <tr>
            <td width="130"><?php 
echo $form->labelEx($model, 'time_startwork');
?>
</td>
            <td  style="padding-bottom: 10px;">
                <?php 
echo $form->textField($model, 'time_startwork', array('size' => 50, 'maxlength' => 50, 'class' => 'form-control'));
?>
Exemple #13
0
 public static function getUserByUsername($username)
 {
     return WUser::model()->find('username=:username', array(':username' => $username));
 }
 public function actionRspass()
 {
     // thu vien mail
     Yii::import('application.extensions.phpmailer.JPhpMailer');
     $check_date = '';
     // check login
     if (!empty(Yii::app()->user->id)) {
         $this->redirect(Yii::app()->createurl(''));
     }
     $page = 0;
     if (!empty($_REQUEST['acc']) && !empty($_REQUEST['token'])) {
         $username_var = trim($_REQUEST['acc']);
         $username_var = str_replace(array(',', "'", '"', ' ', '%'), '', $username_var);
         $token_string = trim($_REQUEST['token']);
         $token_string = str_replace(array(',', "'", '"', ' ', '%'), '', $token_string);
         //check token
         $criteria = new CDbCriteria();
         $criteria->select = array('*');
         $criteria->addCondition('user_name= "' . $username_var . '" AND token_check="' . $token_string . '"');
         $check_token = WUserLosePass::model()->find($criteria);
         $check_token = CJSON::decode(CJSON::encode($check_token));
         if (empty($check_token)) {
             $check_date = 'Chuỗi kick hoạt không đúng ! bạn vui lòng sử dụng đúng URL trong Email !';
         } else {
             $date_now = date('Y-m-d');
             //get id lost
             $criteria = new CDbCriteria();
             $criteria->select = array('*');
             $criteria->addCondition('user_name= "' . $username_var . '"');
             $get_lost_id = WUserLosePass::model()->findAll($criteria);
             $get_lost_id = CJSON::decode(CJSON::encode($get_lost_id));
             $criteria = new CDbCriteria();
             $criteria->select = array('*');
             $criteria->addCondition('user_name= "' . $username_var . '" AND end_time_change >= "' . $date_now . '"');
             $data_lost = WUserLosePass::model()->findAll($criteria);
             $data_lost = CJSON::decode(CJSON::encode($data_lost));
             //check user
             $criteria = new CDbCriteria();
             $criteria->select = array('*');
             $criteria->addCondition('username= "******"');
             $data = WUser::model()->find($criteria);
             $data = CJSON::decode(CJSON::encode($data));
             if (empty($data_lost)) {
                 // var_dump($data_lost);
                 $check_date = 'Quá hạn kich hoạt email!';
             }
             if (empty($check_date) && !empty($data)) {
                 if (!empty($_REQUEST['password'])) {
                     $pass_new = CFunction::encrypt($_REQUEST['password'], Yii::app()->params->hashkey);
                     $model = WUserUpdate::model()->find('id=' . $data['id']);
                     $model->password = $pass_new;
                     if ($model->save()) {
                         if ($get_lost_id) {
                             foreach ($get_lost_id as $key => $value) {
                                 $id = $value['id'];
                                 $this->loadModel($id)->delete();
                             }
                         }
                         $this->render('success_change_pass');
                         $page = 1;
                     }
                 }
             }
         }
     }
     if ($page == 0) {
         $dataProvider = new CActiveDataProvider('WUserLosePass');
         $this->render('lostpass', array('dataProvider' => $dataProvider, 'check_date' => $check_date));
     }
 }