/** * Displays a single Users model. * @param integer $id * @return mixed */ public function actionView($id) { $modelInfo = UsersInfo::findOne(['user_id' => $id]); $modelEducation = UsersEducation::findAll(['user_id' => $id]); $modelTrain = UsersTrain::findAll(['user_id' => $id]); $modelVocational = UsersVocational::findAll(['user_id' => $id]); $modelPlayers = UsersPlayers::findAll(['user_id' => $id]); return $this->render('view', ['model' => $this->findModel($id), 'modelInfo' => $modelInfo, 'modelEducation' => $modelEducation, 'modelTrain' => $modelTrain, 'modelVocational' => $modelVocational, 'modelPlayers' => $modelPlayers]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = UsersEducation::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, 'user_id' => $this->user_id, 'begin_time' => $this->begin_time, 'end_time' => $this->end_time, 'educational_background' => $this->educational_background, 'create_time' => $this->create_time, 'update_time' => $this->update_time]); $query->andFilterWhere(['like', 'school', $this->school])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'witness', $this->witness])->andFilterWhere(['like', 'witness_phone', $this->witness_phone])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'update_user', $this->update_user]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getUsersEducations() { return $this->hasMany(UsersEducation::className(), ['user_id' => 'id']); }
public function actionLogin() { if (!\Yii::$app->user->isGuest) { return $this->redirect(['/user-center/index']); } $postInfo = Yii::$app->request->post(); if (!empty($postInfo)) { if (is_numeric($postInfo['username'])) { $loginInfo = ['_csrf' => $postInfo['_csrf'], 'LoginForm' => ['mobile_phone' => $postInfo['username'], 'password' => $postInfo['password'], 'rememberMe' => $postInfo['rememberMe']]]; } else { $loginInfo = ['_csrf' => $postInfo['_csrf'], 'LoginForm' => ['email' => $postInfo['username'], 'password' => $postInfo['password'], 'rememberMe' => $postInfo['rememberMe']]]; } $model = new LoginForm(); if ($model->load($loginInfo) && $model->login()) { $usersInfo = UsersInfo::findOne(['user_id' => Yii::$app->user->id]); if (empty($usersInfo)) { $usersLevelInfo = UsersLevel::findOne(['user_id' => Yii::$app->user->id]); return $this->redirect(['/user/register-info', 'train_id' => $usersLevelInfo['train_id']]); } $usersEducation = UsersEducation::findAll(['user_id' => Yii::$app->user->id]); if (empty($usersEducation)) { $usersLevelInfo = UsersLevel::findOne(['user_id' => Yii::$app->user->id]); return $this->redirect(['/user/register-education', 'train_id' => $usersLevelInfo['train_id']]); } return $this->redirect(['/user-center/index']); } else { throw new ServerErrorHttpException('系统错误,原因:' . json_encode($model->errors, JSON_UNESCAPED_UNICODE)); } } else { return $this->render('login'); } }
public function actionUserEducation() { if (Yii::$app->request->isPost) { $infoParams = Yii::$app->request->post(); $infoParams['UsersEducation']['user_id'] = Yii::$app->user->id; if (empty($infoParams['UsersEducation']['end_time'])) { $infoParams['UsersEducation']['end_time'] = date('Y-m-d H:i:s', time()); } $infoInfo = $infoParams; $model = new UsersEducation(); if ($model->load($infoInfo) && $model->save()) { return $this->redirect('/user-center/user-info'); } else { throw new ServerErrorHttpException('系统错误,原因:' . json_encode($model->errors, JSON_UNESCAPED_UNICODE)); } } else { if (Yii::$app->request->get('id')) { UsersEducation::findOne(Yii::$app->request->get('id'))->delete(); return $this->redirect('/user-center/user-info'); } else { $model = UsersEducation::findAll(['user_id' => Yii::$app->user->id]); $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); $data = ['levelName' => $levelName, 'currentTrain' => $currentTrain, 'photo' => $photo, 'messageCount' => $messageCount]; return $this->render('user-education', ['data' => $data, 'model' => $model]); } } }
$('#ddd8').html('免冠照片必须上传'); $('#dd8').focus(); return false; } if($('#dd9').val()=='' && $('#dd11').val()==''){ $('#ddd9').html('身份证信息必须上传'); $('#dd9').focus(); return false; } } </script> </li> <li> <h1><span>教育经历</span>已完善(<?php echo \app\models\UsersEducation::getCountByUserId(Yii::$app->user->id); ?> 条)</h1> <div style="display:none;" class="form_input"> <div class="divp_pt"> <table cellpadding="0" cellspacing="0" class="wans_content"> <tr> <th>序</th> <th>学校名称</th> <th>时间</th> <th>学历/学位</th> <th>操作</th> </tr> <?php if (!empty($userEducation)) {
/** * Finds the UsersEducation model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return UsersEducation the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = UsersEducation::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }