public function update()
 {
     if ($this->provinceId == "" || $this->majorJobId == "") {
         CommonFunctions::createAlertMessage("省份或者专业类型不能为空", "error");
         return false;
     }
     $user = Yii::$app->session->get('user');
     $majorJob = MajorJob::findOne($this->majorJobId);
     if ($this->provinceId != $majorJob['provinceId']) {
         CommonFunctions::createAlertMessage("专业类型与所处省份不一致,请重新选择", "error");
         return false;
     }
     //修改省份或专业岗位,需要清除用户的在线练习相关信息
     if ($this->provinceId != $user['provinceId'] || $this->majorJobId != $user['majorJobId']) {
         CurrentTestLibrary::deleteAll(['userId' => $user['userId']]);
         //删除当前记录
         ErrorQuestion::deleteAll(['userId' => $user['userId']]);
         //删除错题记录
         Collection::deleteAll(['userId' => $user['userId']]);
         //删除收藏
     }
     /** @var $user \common\models\Users */
     $user = Users::findOne($user['userId']);
     $user->nickname = $this->nickname;
     $user->realname = $this->realname;
     $user->provinceId = $this->provinceId;
     $user->majorJobId = $this->majorJobId;
     $user->company = $this->company;
     $user->address = $this->address;
     if (!$user->save()) {
         throw new Exception("UpdateInfoForm update Save Error");
     }
     Yii::$app->session->set('user', $user);
     return true;
 }
 public function init()
 {
     /** @var $user \common\models\Users */
     $user = Yii::$app->session->get('user');
     if ($user) {
         $info = Info::findRefusedByUserId($user['userId']);
         if ($info) {
             $this->userId = $info->userId;
             $this->IDCard = $info->IDCard;
             $this->realName = $info->realName;
             $this->cellphone = $info->cellphone;
             $this->education = $info->education;
             $this->major = $info->major;
             $this->workTime = $info->workTime;
             $this->technical = $info->technical;
             $this->signUpMajor = $info->signUpMajor;
             $this->company = $info->company;
             $this->findPasswordQuestion = $info->findPasswordQuestion;
             $this->findPasswordAnswer = $info->findPasswordAnswer;
         } else {
             $this->userId = $user['userId'];
             $this->signUpMajor = MajorJob::findNameByMajorJobId($user['majorJobId']);
             $this->realName = $user['realname'];
             $this->cellphone = $user['cellphone'];
             $this->company = $user['company'];
         }
     }
 }
 public function actionIndex()
 {
     $session = Yii::$app->session;
     $user = $session->get('user');
     $examTemplates = ExamTemplate::findByMajorJobAndProvince($user['majorJobId'], $user['provinceId']);
     $totalNumber = count($examTemplates);
     if ($totalNumber == 0) {
         $url = Url::to(['site/test-library-not-found']);
         header("Location:{$url}");
         exit;
     }
     $rand = rand(1, $totalNumber);
     $examTemplate = $examTemplates[$rand - 1];
     $session->set('examTemplate', $examTemplate);
     //存入session,在考试结束后计算分数要用到
     $examTemplateDetails = ExamTemplateDetail::findByExamTemplate($examTemplate['examTemplateId']);
     $examTemplateDetails = ExamTemplateDetail::remakeArray($examTemplateDetails);
     $testLibraries = TestLibrary::findByTemplateDetails($examTemplateDetails, $user);
     $majorJob = MajorJob::findNameByMajorJobId($user['majorJobId']);
     //将一些必要参数存入session,方便后续页面调用
     $session->set('testLibraries', $testLibraries);
     //所有同类型题目
     $session->set('totalNumber', count($testLibraries));
     //总题数
     $session->set('testTitle', "模拟考试");
     //测试标题
     $session->set('majorJob', $majorJob);
     //测试岗位
     return $this->render('index', ['testLibraries' => $testLibraries]);
 }
 /** 实名认证*/
 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]);
 }
Exemple #5
0
 /**
  * 查询所有职业岗位,返回object
  * @return \common\models\MajorJob[]
  */
 public static function findAllForObject()
 {
     $dependency = new DbDependency(['sql' => 'select count(*) from majorjob']);
     $result = MajorJob::getDb()->cache(function () {
         return MajorJob::find()->all();
     }, 3600, $dependency);
     return $result;
 }
 public function register()
 {
     if ($this->provinceId == "" || $this->majorJobId == "") {
         CommonFunctions::createAlertMessage("省份或者专业类型不能为空", "error");
         return false;
     }
     $majorJob = MajorJob::findOne($this->majorJobId);
     if ($this->provinceId != $majorJob['provinceId']) {
         CommonFunctions::createAlertMessage("专业类型与所处省份不一致,请重新选择", "error");
         return false;
     }
     $openId = Yii::$app->session->get('openId');
     $user = Users::findByWeiXin($openId);
     if (!$user) {
         //如果用户不存在,即关注的时候没有把微信的相关信息存入
         $user = new Users();
         $user->weixin = $openId;
     }
     if (!$user->registerDate || $user->registerDate == 0) {
         //如果用户注册日期不存在或为0,表明用户第一次实名认证
         $user->bitcoin = 0;
         $user->registerDate = DateFunctions::getCurrentDate();
         $user->role = Users::ROLE_A;
         $user->state = Users::STATE_NORMAL;
         do {
             //保证生成的推荐码的唯一
             $recommendCode = CommonFunctions::createCommonRecommendCode();
         } while (Users::findUserByRecommendCode($recommendCode));
         $user->recommendCode = $recommendCode;
         if ($this->tjm) {
             //推荐码绑定推荐人
             $this->recommendUser = Users::findUserByRecommendCode($this->tjm);
             if ($this->recommendUser) {
                 if ($this->recommendUser['userId'] != $user['userId']) {
                     //推荐人不是自己
                     $user->recommendUserID = $this->recommendUser['userId'];
                 }
             }
         }
     }
     $user->nickname = $this->nickname;
     $user->realname = $this->realname;
     $user->provinceId = $this->provinceId;
     $user->majorJobId = $this->majorJobId;
     $user->cellphone = $this->cellphone;
     $user->company = $this->company;
     $user->address = $this->address;
     if (!$user->save()) {
         throw new Exception("RegisterForm register Save Error");
     }
     Yii::$app->cache->delete($user->cellphone);
     //注册成功后将验证码缓存清除
     Yii::$app->session->set('user', $user);
     return true;
 }
 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 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]);
 }
 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 getMajorJob()
 {
     return $this->hasOne(MajorJob::className(), ['majorJobId' => 'majorJobId']);
 }
 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]);
 }
            <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']);
?>
" readonly="readonly" placeholder="请选择" data-toggle="modal" data-target="#majorJobSelect">
            <input type="hidden" name="UpdateInfoForm[majorJobId]" class="majorJob_hidden" value="<?php 
echo $updateInfoForm['majorJobId'];
?>
">
        </div>
        <div class="col-xs-9 col-xs-offset-3"><div class="help-block"></div></div>
    </div>
    <?php 
echo $form->field($updateInfoForm, 'company');
?>
    <?php 
echo $form->field($updateInfoForm, 'address');
?>
 /**
  * 单项训练
  * @param $type
  * @return string
  */
 public function actionSingle($type)
 {
     $session = Yii::$app->session;
     $user = $session->get('user');
     $testTypeId = 0;
     $testTitle = "单项练习-";
     switch ($type) {
         case 'danxuan':
             $testTypeId = 1;
             $testTitle .= "单选题";
             break;
         case 'duoxuan':
             $testTypeId = 2;
             $testTitle .= "多选题";
             break;
         case 'panduan':
             $testTypeId = 3;
             $testTitle .= "判断题";
             break;
         case 'anli':
             $testTypeId = 4;
             $testTitle .= "案例计算题";
             break;
         default:
             break;
     }
     $currentNumber = TestLibrary::findCurrentNumber($user, $testTypeId);
     $testLibraries = TestLibrary::findAllByUserAndTestType($user, $testTypeId);
     if ($currentNumber >= count($testLibraries)) {
         //当前题号达到最大题号,重新从头开始
         $currentNumber = 0;
     }
     //测试图片
     //$testLibraries = TestLibrary::find()->where('pictureBig is not null')->orWhere('pictureSmall is not null')->all();
     $countNumber = count($testLibraries);
     if ($countNumber == 0) {
         //避免没有题目生成出题页面出错
         $url = Url::to(['site/test-library-not-found']);
         header("Location:{$url}");
         exit;
     }
     $majorJob = MajorJob::findNameByMajorJobId($user['majorJobId']);
     //将一些必要参数存入session,方便后续页面调用
     $session->set('testLibraries', $testLibraries);
     //所有题目
     $session->set('totalNumber', $countNumber);
     //总题数
     $session->set('testTypeId', $testTypeId);
     //测试类型id
     $session->set('testTitle', $testTitle);
     //测试标题
     $session->set('majorJob', $majorJob);
     //测试岗位
     //取出特定的题目量,$testLibraries为引用
     $startNumber = TestLibrary::takeOutSpecialNumber($currentNumber, $testLibraries);
     return $this->render('test', ['testLibraries' => $testLibraries, 'startNumber' => $startNumber, 'currentNumber' => $currentNumber]);
 }
Exemple #14
0
            <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']);
?>
" readonly="readonly" placeholder="请选择" data-toggle="modal" data-target="#majorJobSelect">
            <input type="hidden" name="RegisterForm[majorJobId]" class="majorJob_hidden" value="<?php 
echo $registerForm['majorJobId'];
?>
">
        </div>
        <div class="col-xs-9 col-xs-offset-3"><div class="help-block"></div></div>
    </div>
    <?php 
echo $form->field($registerForm, 'cellphone')->textInput(['class' => 'form-control mobile', 'type' => 'number']);
?>
    <?php 
echo $form->field($registerForm, 'yzm', ['template' => "{label}<div class='col-xs-4 no-padding-left'>{input}</div><div class='col-xs-5 no-padding-left'>\n                    <span class='btn btn-primary get_yzm'>获取验证码</span></div><div class='col-xs-9 col-xs-offset-3'>{error}</div>"]);
?>