/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = TrainTeachers::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, 'train_id' => $this->train_id, 'teachers_id' => $this->teachers_id, 'create_time' => $this->create_time, 'update_time' => $this->update_time]);
     $query->andFilterWhere(['like', 'create_user', $this->create_user])->andFilterWhere(['like', 'update_user', $this->update_user]);
     return $dataProvider;
 }
Example #2
0
 public static function getTeachersCountGroupByArea()
 {
     $result = Yii::$app->db->createCommand('SELECT count(t.id) as count,train.district FROM  ' . self::tableName() . ' t LEFT JOIN ' . TrainTeachers::tableName() . ' tt ON t.id = tt.teachers_id LEFT JOIN ' . Train::tableName() . ' train ON tt.train_id = train.id WHERE train.district is not null group by train.district')->queryAll();
     return $result;
 }
 /**
  * Finds the TrainTeachers model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return TrainTeachers the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = TrainTeachers::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #4
0
        <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 
    }
    ?>
</option>
            <?php 
}
?>
        </select>

        <div class="help-block"></div>
    </div>

    <div class="form-group">
        <?php 
 public function actionView()
 {
     $trainId = Yii::$app->request->get('id');
     $trainModel = Train::findOne(['id' => $trainId]);
     $trainTeachersModel = TrainTeachers::getAllTeachersByTrainId($trainModel['id']);
     $trainUsers = [];
     if ($trainModel['recruit_count'] > 0) {
         for ($i = 1; $i <= $trainModel['recruit_count']; $i++) {
             $trainUsersInfo = TrainUsers::findOne(['train_id' => $trainModel['id'], 'orders' => $i]);
             if (empty($trainUsersInfo)) {
                 $trainUsers[$i]['status'] = '未报名';
                 $trainUsers[$i]['class'] = 'red';
                 $trainUsers[$i]['userId'] = '';
             } else {
                 $trainUsers[$i]['status'] = TrainUsers::$statusList[$trainUsersInfo['status']];
                 $trainUsers[$i]['userId'] = $trainUsersInfo['user_id'];
                 if ($trainUsersInfo['status'] == TrainUsers::NO_APPROVED) {
                     $trainUsers[$i]['class'] = 'blue';
                 } else {
                     $trainUsers[$i]['class'] = '';
                 }
             }
         }
     }
     $data = ['trainModel' => $trainModel, 'trainTeachersModel' => $trainTeachersModel, 'trainUsers' => $trainUsers];
     return $this->render('/train/view', ['data' => $data]);
 }
 public function actionTrainView()
 {
     $trainUsersId = \Yii::$app->request->get('trainUsersId');
     if (empty($trainUsersId)) {
         throw new ServerErrorHttpException('查看课程信息失败,原因:参数错误!');
     }
     $levelName = Level::getOneLevelNameById(\Yii::$app->user->identity->level_id);
     $photo = UsersInfo::getPhotoByUserId(\Yii::$app->user->id);
     $messageCount = MessagesUsers::getCountByUserIdAndType(\Yii::$app->user->id);
     $currentTrain = TrainUsers::getTrainByUserId(\Yii::$app->user->id);
     //培训信息
     $trainModel = TrainUsers::getTrainInfoById($trainUsersId);
     if (empty($trainModel)) {
         throw new ServerErrorHttpException('查看课程信息失败,原因:不存在的培训课程!');
     }
     //考勤信息
     $attendanceModel = Attendance::getAllByTrainIdAndUserId($trainModel['train_id'], $trainModel['user_id']);
     //迟到数量
     $laterCount = Attendance::getCount($trainModel['train_id'], $trainModel['user_id'], Attendance::LATER);
     $arlyCount = Attendance::getCount($trainModel['train_id'], $trainModel['user_id'], Attendance::EARLY);
     $absencesCount = Attendance::getCount($trainModel['train_id'], $trainModel['user_id'], Attendance::ABSENCES);
     $leaveCount = Attendance::getCount($trainModel['train_id'], $trainModel['user_id'], Attendance::LEAVE);
     $trainTeachersModel = TrainTeachers::getAllTeachersByTrainId($trainModel['id']);
     $usersModel = TrainUsers::getAllUsersByTrainId($trainModel['id']);
     if (!empty($usersModel)) {
         foreach ($usersModel as $key => $val) {
             $usersModel[$key]['img'] = '';
             for ($i = 1; $i <= $val['score_appraise'] / 20; $i++) {
                 $usersModel[$key]['img'] .= '<img src="/images/user/xx1.jpg" />';
             }
             if ($val['score_appraise'] % 20 > 0) {
                 $usersModel[$key]['img'] .= '<img src="/images/user/xx2.jpg" />';
             }
         }
     }
     $data = ['levelName' => $levelName, 'currentTrain' => $currentTrain, 'trainModel' => $trainModel, 'attendanceModel' => $attendanceModel, 'laterCount' => $laterCount, 'arlyCount' => $arlyCount, 'absencesCount' => $absencesCount, 'leaveCount' => $leaveCount, 'attendanceAppraise' => $trainModel['attendance_appraise'], 'trainTeachersModel' => $trainTeachersModel, 'usersModel' => $usersModel, 'photo' => $photo, 'messageCount' => $messageCount];
     return $this->render('train-view', ['data' => $data]);
 }