/** 实名认证*/ public function actionRegister() { $majorJobs = MajorJob::findAllForObject(); $provinces = Province::findAllForObject(); $user = Yii::$app->session->get('user'); //已经进行过实名认证的用户 if ($user['majorJobId'] != 0 && $user['registerDate'] != null && $user['registerDate'] > 0) { CommonFunctions::createAlertMessage("您已经进行过实名认证,可以选择修改部分信息。<br>\n 注意:修改考试区域、专业类型信息后,您以前做的相关在线练习、错题、重点题信息等都会重置,请慎重。", "info"); $updateInfoForm = new UpdateInfoForm(); if ($updateInfoForm->load(Yii::$app->request->post()) && $updateInfoForm->validate()) { if ($updateInfoForm->update()) { CommonFunctions::createAlertMessage("恭喜您,修改成功", "success"); } } return $this->render('update-info', ['updateInfoForm' => $updateInfoForm, 'majorJobs' => $majorJobs, 'provinces' => $provinces]); } //未进行过实名认证的用户 $registerForm = new RegisterForm(); CommonFunctions::createAlertMessage("实名认证主要用于系统内部正确配置相关的题库与模拟试题模型,请如实、认证填写", "info"); if ($registerForm->load(Yii::$app->request->post()) && $registerForm->validate()) { if ($registerForm->register()) { CommonFunctions::createAlertMessage("恭喜您,注册成功", "success"); $url = Url::previous("register"); //获取前面记住的url if ($url) { return $this->redirect($url); } } } return $this->render('register', ['registerForm' => $registerForm, 'majorJobs' => $majorJobs, 'provinces' => $provinces]); }
/** * 查询所有省份,返回object,缓存1小时、依赖省份数量 * @return \common\models\Province[] */ public static function findAllForObject() { $dependency = new DbDependency(['sql' => 'select count(*) from province']); $result = Province::getDb()->cache(function () { return Province::find()->all(); }, 3600, $dependency); return $result; }
/** * 获得省份名称 * @return string */ public static function getProvinceNameById($id) { $provinceLists = \Yii::$app->cache->get('cache_province'); if (!$provinceLists) { $province = Province::find()->where('1=1')->orderBy('id asc')->all(); foreach ($province as $onePr) { $provinceLists[$onePr->provinceID] = $onePr->province; } \Yii::$app->cache->set('cache_province', $provinceLists); } return $provinceLists[$id]; }
public function actionSearch() { Url::remember(); //记录当前页,为更新数据后还是跳转到当前页做记录 $request = Yii::$app->request; $query = Yii::$app->session->getFlash('query'); if ($request->isPost) { $type = $request->post('type'); $content = $request->post('content'); } else { $type = $request->get('type'); $content = trim($request->get('content')); } if ($type || !$query) { switch ($type) { case 'testLibraryId': $query = TestLibrary::find()->where(['testLibraryId' => $content]); break; case 'testType': $table_a = TestLibrary::tableName(); $table_b = TestType::tableName(); $query = TestLibrary::find()->leftJoin($table_b, "{$table_a}.testTypeId={$table_b}.testTypeId")->where(['like', "{$table_b}.name", $content]); break; case 'province': $table_a = TestLibrary::tableName(); $table_b = Province::tableName(); $query = TestLibrary::find()->leftJoin($table_b, "{$table_a}.provinceId={$table_b}.provinceId")->where(['like', "{$table_b}.name", $content]); break; case 'majorJob': $table_a = TestLibrary::tableName(); $table_b = MajorJob::tableName(); $query = TestLibrary::find()->leftJoin($table_b, "{$table_a}.majorJobId={$table_b}.majorJobId")->where(['like', $table_b . ".name", $content]); break; case 'testChapter': $table_a = TestLibrary::tableName(); $table_b = TestChapter::tableName(); $query = TestLibrary::find()->leftJoin($table_b, "{$table_a}.testChapterId={$table_b}.testChapterId")->where(['like', $table_b . ".name", $content]); break; case 'question': case 'problem': case 'options': $query = TestLibrary::find()->where(['like', $type, $content]); break; default: $query = TestLibrary::find(); break; } } Yii::$app->session->setFlash('query', $query); $pagination = new Pagination(['defaultPageSize' => Yii::$app->params['pageSize'], 'totalCount' => $query->count()]); $model = $query->offset($pagination->offset)->limit($pagination->limit)->all(); return $this->render('index', ['models' => $model, 'pages' => $pagination]); }
/** * 初始化与系统地址有关的文件缓冲 */ public static function initSysaddress() { $sysaddress = array(); //配置ID与地区匹配缓冲 $province = Province::find()->where('1=1')->orderBy('id asc')->all(); $city = City::find()->where('1=1')->orderBy('father asc,id asc')->all(); $area = Area::find()->where('1=1')->orderBy('father asc,id asc')->all(); foreach ($province as $value) { $sysaddress['province'][$value->provinceID] = $value->province; } foreach ($city as $value) { $sysaddress['city'][$value->cityID] = $value->city; } foreach ($area as $value) { $sysaddress['area'][$value->areaID] = $value->area; } //配置多级联动操作相关缓冲 $sysaddress['province_option'] = ''; foreach ($province as $value) { $sysaddress['province_option'] .= '<option value="' . $value->provinceID . '">' . $value->province . '</option>'; } $sysaddress['province_option'] = '<select name="province" class="qys_common_provice contactField requiredField">' . $sysaddress['province_option'] . '</select>'; #获得所有城市列表并按照省份排序 #先从缓冲获得数据 $i = 0; $city_list_fit = ''; foreach ($city as $value) { if ($value->father !== $i) { $city_list_fit .= '</select><select name="city" class="qys_common_city_' . $value->father . ' contactField requiredField">'; $i = $value->father; } $city_list_fit .= '<option value="' . $value->cityID . '">' . $value->city . '</option>'; } $city_list_fit .= '</select>'; $city_list_fit = substr($city_list_fit, 9); $sysaddress['city_option'] = $city_list_fit; #获得所有城市列表并按照省份排序 #先从缓冲获得数据 $i = 0; $area_list_fit = ''; foreach ($area as $value) { if ($value->father !== $i) { $area_list_fit .= '</select><select name="area" class="qys_common_area_' . $value->father . ' contactField requiredField">'; $i = $value->father; } $area_list_fit .= '<option value="' . $value->areaID . '">' . $value->area . '</option>'; } $area_list_fit .= '</select>'; $area_list_fit = substr($area_list_fit, 9); $sysaddress['area_option'] = $area_list_fit; \Yii::$app->cache->set('sys_address', $sysaddress); }
public function actionMajor() { $request = Yii::$app->request; if ($request->isPost) { $id = $request->post('id'); $name = $request->post('name'); if ($id) { $major = MajorJob::findOne($id); CommonFunctions::createAlertMessage("修改成功", "success"); } else { $major = new Province(); CommonFunctions::createAlertMessage("添加成功", "success"); } $major->name = $name; if (!$major->save()) { throw new Exception("Basic Date area save error"); } return $this->redirect(['basic-data/major']); } $models = MajorJob::findAllForObject(); return $this->render('major', ['models' => $models]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Province::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(['province_id' => $this->province_id, 'region_id' => $this->region_id]); $query->andFilterWhere(['like', 'province_name', $this->province_name]); return $dataProvider; }
public function actionSearch() { $request = Yii::$app->request; $query = Yii::$app->session->getFlash('query'); if ($request->isPost) { $type = $request->post('type'); $content = trim($request->post('content')); } else { $type = $request->get('type'); $content = trim($request->get('content')); } if ($type || !$query) { switch ($type) { case 'province': $table_a = Users::tableName(); $table_b = Province::tableName(); $query = Users::find()->leftJoin($table_b, "{$table_a}.provinceId={$table_b}.provinceId")->where(['like', "{$table_b}.name", $content]); break; case 'majorJob': $table_a = Users::tableName(); $table_b = MajorJob::tableName(); $query = Users::find()->leftJoin($table_b, "{$table_a}.majorJobId={$table_b}.majorJobId")->where(['like', $table_b . ".name", $content]); break; case 'nickname': case 'cellphone': $query = Users::find()->where(['like', $type, $content]); break; default: $query = Users::find(); break; } $query = $query->andWhere('weixin is not null'); //添加微信用户条件,位置不可改 } Yii::$app->session->setFlash('query', $query); $pagination = new Pagination(['defaultPageSize' => Yii::$app->params['pageSize'], 'totalCount' => $query->count()]); $user = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(['registerDate' => SORT_DESC])->all(); return $this->render('index', ['users' => $user, 'pages' => $pagination]); }
public function getProvince() { return $this->hasOne(Province::className(), ['provinceId' => 'provinceId']); }
public function actionSearch() { $request = Yii::$app->request; $query = Yii::$app->session->getFlash('query'); if ($request->isPost) { $type = $request->post('type'); $content = trim($request->post('content')); } else { $type = $request->get('type'); $content = trim($request->get('content')); } if ($type || !$query) { switch ($type) { case 'province': $table_a = ExamTemplate::tableName(); $table_b = Province::tableName(); $query = ExamTemplate::find()->leftJoin($table_b, "{$table_a}.provinceId={$table_b}.provinceId")->where(['like', "{$table_b}.name", $content]); break; case 'majorJob': $table_a = ExamTemplate::tableName(); $table_b = MajorJob::tableName(); $query = ExamTemplate::find()->leftJoin($table_b, "{$table_a}.majorJobId={$table_b}.majorJobId")->where(['like', "{$table_b}.name", $content]); break; case 'name': case 'state': $query = ExamTemplate::find()->where(['like', $type, $content]); break; default: $query = ExamTemplate::find(); break; } } Yii::$app->session->setFlash('query', $query); $pagination = new Pagination(['defaultPageSize' => Yii::$app->params['pageSize'], 'totalCount' => $query->count()]); $examTemplates = $query->offset($pagination->offset)->limit($pagination->limit)->all(); return $this->render('index', ['examTemplates' => $examTemplates, 'pages' => $pagination]); }
?> <div class="container-fluid"> <?php $form = ActiveForm::begin(['id' => 'account-register', 'options' => ['class' => 'form-horizontal'], 'fieldConfig' => ['options' => ['class' => 'form-group no-margin-bottom'], 'template' => "{label}<div class='col-xs-9 no-padding-left'>{input}</div><div class='col-xs-9 col-xs-offset-3'>{error}</div>", 'labelOptions' => ['class' => 'col-xs-3 control-label']]]); ?> <?php echo $form->field($updateInfoForm, 'nickname'); ?> <?php echo $form->field($updateInfoForm, 'realname'); ?> <div class="form-group no-margin-bottom field-updateinfoform-provinceid required"> <label class="col-xs-3 control-label" for="updateinfoform-provinceid">考试区域</label> <div class="col-xs-9 no-padding-left"> <input type="text" id="updateinfoform-provinceid" class="form-control can_select province_input" value="<?php echo Province::findNameByProvinceId($updateInfoForm['provinceId']); ?> " readonly="readonly" placeholder="请选择" data-toggle="modal" data-target="#provinceSelect"> <input type="hidden" name="UpdateInfoForm[provinceId]" class="province_hidden" value="<?php echo $updateInfoForm['provinceId']; ?> "> </div> <div class="col-xs-9 col-xs-offset-3"><div class="help-block"></div></div> </div> <div class="form-group no-margin-bottom field-updateinfoform-majorjobid required"> <label class="col-xs-3 control-label" for="updateinfoform-majorjobid">专业类型</label> <div class="col-xs-9 no-padding-left"> <input type="text" id="updateinfoform-provinceid" class="form-control can_select majorJob_input" value="<?php echo MajorJob::findNameByMajorJobId($updateInfoForm['majorJobId']); ?>
/** * Finds the Province model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Province the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Province::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getProvinces() { return $this->hasMany(Province::className(), ['region_id' => 'region_id']); }
/* @var $form yii\widgets\ActiveForm */ ?> <div class="municipal-city-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'municipality_name')->textInput(['maxlength' => true]); ?> <?php $province = Province::find()->all(); $listData = ArrayHelper::map($province, 'province_id', 'province_name'); echo $form->field($model, 'province_id')->dropDownList($listData, ['prompt' => 'Select your Province']); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php ActiveForm::end(); ?> </div>
?> <div class="container-fluid"> <?php $form = ActiveForm::begin(['id' => 'account-register', 'options' => ['class' => 'form-horizontal'], 'fieldConfig' => ['options' => ['class' => 'form-group no-margin-bottom'], 'template' => "{label}<div class='col-xs-9 no-padding-left'>{input}</div><div class='col-xs-9 col-xs-offset-3'>{error}</div>", 'labelOptions' => ['class' => 'col-xs-3 control-label']]]); ?> <?php echo $form->field($registerForm, 'nickname'); ?> <?php echo $form->field($registerForm, 'realname'); ?> <div class="form-group no-margin-bottom field-registerform-provinceid required"> <label class="col-xs-3 control-label" for="registerform-provinceid">考试区域</label> <div class="col-xs-9 no-padding-left"> <input type="text" id="registerform-provinceid" class="form-control can_select province_input" value="<?php echo Province::findNameByProvinceId($registerForm['provinceId']); ?> " readonly="readonly" placeholder="请选择" data-toggle="modal" data-target="#provinceSelect"> <input type="hidden" name="RegisterForm[provinceId]" class="province_hidden" value="<?php echo $registerForm['provinceId']; ?> "> </div> <div class="col-xs-9 col-xs-offset-3"><div class="help-block"></div></div> </div> <div class="form-group no-margin-bottom field-registerform-majorjobid required"> <label class="col-xs-3 control-label" for="registerform-majorjobid">专业类型</label> <div class="col-xs-9 no-padding-left"> <input type="text" id="registerform-provinceid" class="form-control can_select majorJob_input" value="<?php echo MajorJob::findNameByMajorJobId($registerForm['majorJobId']); ?>
public function getProvince() { return $this->hasOne(Province::className(), ['PROVINCE_ID' => 'dept_prov_id']); }