public function actionIndex()
 {
     $request = Yii::$app->request;
     try {
         $query = $request->get('search-string', '');
         $query = HtmlPurifier::process($query);
         Yii::$app->view->title = 'Kết quả tìm kiếm cho ' . $query;
         Yii::$app->view->registerMetaTag(['name' => 'description', 'content' => 'Bluebee-UET.com - Kết quả tìm kiếm cho ' . $query]);
         Yii::$app->view->registerMetaTag(['property' => 'og:title', 'content' => 'Bluebee-UET.com - Kết quả tìm kiếm cho ' . $query]);
         Yii::$app->view->registerMetaTag(['property' => 'og:description', 'content' => 'Bluebee-UET.com - Kết quả tìm kiếm cho ' . $query]);
         Yii::$app->view->registerMetaTag(['property' => 'og:image', 'content' => 'http://bluebee-uet.com/img/logo.jpg']);
         $attr = $request->get('attr', '');
         switch ($attr) {
             case 'teacher':
                 $data = Teachers::searchTeachers(strtolower($query));
                 break;
             case 'document':
                 $data = Documents::searchDocuments(strtolower($query));
                 break;
             case 'subject':
                 $data = Subjects::searchSubjects(strtolower($query));
                 break;
             default:
                 $this->redirect('http://bluebee-uet.com');
                 break;
         }
         $data['attr'] = $attr;
         $data['query'] = $query;
         return $this->render('index', $data);
     } catch (Exception $ex) {
     }
 }
 public function actionView()
 {
     $id = Yii::$app->request->get('id');
     $model = Teachers::findOne(['id' => $id]);
     $trainWind = News::getImgRecommendNewsByCategory(11, 12);
     return $this->render('view', ['data' => $model, 'trainWind' => $trainWind]);
 }
 public function actionDelete()
 {
     Yii::$app->response->format = Response::FORMAT_JSON;
     $request = \Yii::$app->request;
     $data = $request->post();
     $id = $data['id'];
     try {
         Teachers::findOne(['id' => $id])->delete();
         return ['status' => 1, 'message' => 'Thành công'];
     } catch (Exception $ex) {
         return ['status' => 0, 'message' => 'Có lỗi xảy ra'];
     }
 }
 public function actionTrain()
 {
     $levelId = Yii::$app->request->get('level_id');
     $imgNews = News::getImgRecommendNewsByCategory(3, 5);
     $teachersCount = Teachers::getTeachersCount();
     $trainCount = Train::getTrainCount();
     $trainTeachers = Teachers::getAllTeachersForNewsTrain();
     $trainWind = News::getTrainWindByLevelId($levelId, 8);
     $trainLand = TrainLand::getAllDataByCount(4);
     $data = ['imgNews' => $imgNews, 'teachersCount' => $teachersCount, 'trainTeachers' => $trainTeachers, 'levelId' => $levelId, 'trainWind' => $trainWind, 'trainCount' => $trainCount, 'trainLand' => $trainLand];
     return $this->render('train', ['data' => $data]);
     //        return $this->render('build', ['data' => $data]);
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Teachers::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'sex' => $this->sex, 'age' => $this->age, 'status' => $this->status, 'level' => $this->level, 'lesson' => $this->lesson, 'create_time' => $this->create_time, 'update_time' => $this->update_time]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'create_user', $this->create_user])->andFilterWhere(['like', 'update_user', $this->update_user]);
     return $dataProvider;
 }
 public function actionRateTeacher()
 {
     $request = Yii::$app->request;
     try {
         $teacher = $request->post('teacher', '');
         $check_teacher = Teachers::find()->where(['id' => $teacher])->count();
         if ($check_teacher == 0) {
             return json_encode(Util::arrayError('Giáo viên không tồn tại', ''));
         }
         $stars = $request->post('stars', '');
         if ($stars < 1 || $stars > 5) {
             return json_encode(Util::arrayError('Điểm không hợp lệ', ''));
         }
         $result = Teachers::rateTeacher($teacher, $stars);
         return json_encode(Util::arraySuccess('Success', $result));
     } catch (Exception $ex) {
     }
 }
Exemple #7
0
 public static function getTeachersByDepartment($department)
 {
     $query = Teachers::find()->where(['department' => $department])->orderBy('id desc');
     $countQuery = clone $query;
     $pages = new Pagination(['totalCount' => $countQuery->count()]);
     $pages->defaultPageSize = 27;
     $models = $query->offset($pages->offset)->limit($pages->limit)->all();
     if (!Yii::$app->cache->exists('departments')) {
         $departments = Departments::find()->orderBy('name', 'desc')->all();
         Yii::$app->cache->add('departments', $departments, 3600);
     } else {
         $departments = Yii::$app->cache->get('departments');
     }
     return ['models' => $models, 'pages' => $pages, 'departments' => $departments];
 }
 /**
  * @param $trainId
  */
 public static function getAllTeachersByTrainId($trainId)
 {
     $result = Yii::$app->db->createCommand('SELECT tu.train_id,t.name,t.photo,t.age,t.sex,t.level,tu.teachers_id FROM  ' . self::tableName() . ' tu LEFT JOIN ' . Teachers::tableName() . ' t ON tu.teachers_id = t.id WHERE tu.train_id=:train_id', [':train_id' => $trainId])->queryAll();
     return $result;
 }
 /**
  * Updates an existing UsersLevel model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     if (Yii::$app->request->isPost) {
         $infoParams = Yii::$app->request->post();
         if ($infoParams['UsersLevel']['status'] == UsersLevel::SEND_CARD) {
             $infoParams['UsersLevel']['end_date'] = date('Y-m-d', time() + 3600 * 24 * 365);
         }
         $userLevelInfo = $infoParams;
         if ($model->load($userLevelInfo) && $model->save()) {
             //如果状态更新为已经注册
             if ($model->status == UsersLevel::SEND_CARD) {
                 if ($model->level_id == 1) {
                     //如果是注册学员升级市级教练
                     UsersLevel::updateAll(['status' => UsersLevel::LEVEL_UP], ['user_id' => $model->user_id, 'level_id' => $model->level_id]);
                     $userInfo = UsersInfo::findOne(['user_id' => $model->user_id]);
                     //新增一条用户和级别对应的信息
                     $userLevelModel = new UsersLevel();
                     $userLevelModel->user_id = $model->user_id;
                     $userLevelModel->level_id = $model->level_id + 1;
                     $userLevelModel->credentials_number = $userInfo['credentials_number'];
                     $userLevelModel->district = $userInfo['account_location'];
                     $userLevelModel->receive_address = $userInfo['contact_address'];
                     $userLevelModel->postcode = $userInfo['contact_postcode'];
                     $userLevelModel->status = UsersLevel::NO_TRAIN;
                     if (!$userLevelModel->save()) {
                         throw new ServerErrorHttpException(json_encode($userLevelModel->errors, JSON_UNESCAPED_UNICODE) . '!');
                     } else {
                         Users::updateAll(['level_id' => $model->level_id + 1, 'level_order' => $model->level_id + 1], ['id' => $model->user_id]);
                     }
                 }
                 $usersTrainInfo = UsersLevel::getUserTrainInfo($model->id);
                 $teacherInfo = Teachers::findOne($usersTrainInfo['teachers_id']);
                 $usersTrainModel = new UsersTrain();
                 $usersTrain['UsersTrain']['user_id'] = $usersTrainInfo['user_id'];
                 $usersTrain['UsersTrain']['credentials_number'] = $usersTrainInfo['certificate_number'];
                 $usersTrain['UsersTrain']['begin_time'] = $usersTrainInfo['begin_time'];
                 $usersTrain['UsersTrain']['end_time'] = $usersTrainInfo['end_time'];
                 $usersTrain['UsersTrain']['level'] = Level::getOneLevelNameById($usersTrainInfo['level_id']);
                 $usersTrain['UsersTrain']['address'] = $usersTrainInfo['address'];
                 $usersTrain['UsersTrain']['witness'] = $teacherInfo['name'];
                 $usersTrain['UsersTrain']['witness_phone'] = $teacherInfo['phone'];
                 $usersTrain['UsersTrain']['description'] = '通过培训课程' . $usersTrainInfo['content'];
                 if ($usersTrainModel->load($usersTrain) && $usersTrainModel->save()) {
                     $content = "很高兴的通知您,您已完成" . Level::getOneLevelNameById($model->level_id) . "级教练员的注册,注册时效为1年,您现在可以正式开展教练员工作。【教练系统】";
                     $userInfo = Users::findOne($model->user_id);
                     $result = $this->sendMessage($content, Messages::REGISTER_SUCCESS, $model->user_id, $userInfo['mobile_phone'], '1');
                     if ($result != '0') {
                         throw new ServerErrorHttpException($result);
                     } else {
                         return $this->redirect(['view', 'id' => $model->id]);
                     }
                 } else {
                     throw new ServerErrorHttpException(json_encode($usersTrainModel->errors, JSON_UNESCAPED_UNICODE));
                 }
             }
         }
     } else {
         $photo = UsersInfo::getPhotoByUserId($model->user_id);
         return $this->render('update', ['model' => $model, 'photo' => $photo]);
     }
 }
 /**
  * Displays a single TrainTeachers model.
  * @param integer $id
  * @return mixed
  */
 public function actionView($id)
 {
     $model = $this->findModel($id);
     $model->teacherName = \app\models\Teachers::getOneTeacherNameById($model->teachers_id);
     return $this->render('view', ['model' => $model]);
 }
 /**
  * Finds the Teachers model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Teachers the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Teachers::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemple #12
0
" target="_blank" style="width:300px"><?php 
echo $model->trainName;
?>
</a>
        <div class="help-block"></div>
    </div>

    <?php 
echo $form->field($model, 'train_id')->hiddenInput(['value' => $model->trainId])->label(false);
?>

    <div class="form-group field-trainteachers-teachers_id has-success">
        <label for="trainteachers-teachers_id" class="control-label">讲师</label>
        <select style="width:200px" name="TrainTeachers[teachers_id]" class="form-control" id="trainteachers-teachers_id">
            <?php 
foreach (\app\models\Teachers::getAll() as $key => $val) {
    ?>
            <option value="<?php 
    echo $val['id'];
    ?>
" <?php 
    if ($model->teachers_id == $val['id']) {
        ?>
 selected <?php 
    }
    ?>
><?php 
    echo $val['name'];
    if (\app\models\TrainTeachers::findOne(['train_id' => $model->trainId, 'teachers_id' => $val['id']])) {
        ?>
———已选<?php 
Exemple #13
0
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model app\models\TrainTeachers */
$this->title = '查看';
$this->params['breadcrumbs'][] = ['label' => '讲师管理', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="train-teachers-view">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <p>
        <?php 
echo Html::a('更新', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']);
?>
        <?php 
echo Html::a('删除', ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => '确认删除吗?', 'method' => 'post']]);
?>
    </p>

    <?php 
echo DetailView::widget(['model' => $model, 'attributes' => [['attribute' => 'train_id', 'format' => 'html', 'value' => '<a href="/Admin/train/index?TrainSearch[id]=' . $model->train_id . '" target="_blank" style="width:300px">' . \app\models\Train::getOneTrainNameById($model->train_id) . '</a>'], ['attribute' => 'teachers_id', 'format' => 'html', 'value' => '<a href="/Admin/teachers/index?TeachersSearch[id]=' . $model->teachers_id . '" target="_blank" style="width:300px">' . \app\models\Teachers::getOneTeacherNameById($model->teachers_id) . '</a>'], 'create_time', 'create_user', 'update_time', 'update_user']]);
?>

</div>