/**
  * Deletes an existing InfoCategory model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     $infoModel = Info::find()->andWhere(['category_id' => $id])->one();
     if (null === $infoModel) {
         $this->findModel($id)->delete();
     } else {
         Yii::$app->session->setFlash('alert', ['body' => \Yii::t('backend', 'Can not delete category #' . $id . '. It used in other table. Change category for info #' . $infoModel->id . ' before delete.'), 'options' => ['class' => 'alert-error']]);
     }
     return $this->redirect(['index']);
 }
 public function actionOver()
 {
     $user = Yii::$app->session->get('user');
     $info = Info::findByUserId($user['userId']);
     if ($info->state == Info::STATE_RECORD) {
         CommonFunctions::createAlertMessage("您的报名信息已经记录,请耐心等待工作人员帮您填报信息,填报完成可以在线进行查看", "info");
     } elseif ($info->state == Info::STATE_PASS) {
         CommonFunctions::createAlertMessage("您好!您提交的在线报名申请,云豆已经为您办理完成了,您可以登录网站进行在线查看。\n            <br>您的登录账号为: 身份证号,初始密码为:" . $info->password, "success");
     } elseif ($info->state == Info::STATE_REFUSE) {
         CommonFunctions::createAlertMessage("工作人员帮您填写报名信息失败,原因是:" . $info->replyContent, "error");
     } else {
         CommonFunctions::createAlertMessage("您的报名信息状态异常,请联系管理员", "warning");
     }
     return $this->render('over', ['info' => $info]);
 }
示例#3
0
 /**
  * Creates data provider instance with search query applied
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Info::find();
     if (!\Yii::$app->user->can('administrator')) {
         $query->forDomain();
     }
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!empty($params['mid'])) {
         $query->andFilterWhere(['model_id' => intval($params['mid'])]);
     }
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['{{info}}.id' => $this->id, '{{info}}.slug' => $this->slug, '{{info}}.author_id' => $this->author_id, '{{info}}.category_id' => $this->category_id, '{{info}}.model_id' => $this->model_id, '{{info}}.updater_id' => $this->updater_id, '{{info}}.status' => $this->status, '{{info}}.published_at' => $this->published_at, '{{info}}.created_at' => $this->created_at, '{{info}}.updated_at' => $this->updated_at, '{{info}}.domain_id' => $this->domain_id]);
     $query->andFilterWhere(['like', '{{info}}.slug', $this->slug])->andFilterWhere(['like', '{{info}}.title', $this->title])->andFilterWhere(['like', '{{info}}.description', $this->description])->andFilterWhere(['like', '{{info}}.weight', $this->weight])->andFilterWhere(['like', '{{info}}.body', $this->body])->andFilterWhere(['like', '{{info}}.before_body', $this->before_body])->andFilterWhere(['like', '{{info}}.after_body', $this->after_body])->andFilterWhere(['like', '{{info}}.on_scenario', $this->on_scenario]);
     if (!empty($params['InfoSearch']['cid'])) {
         $query->onlyModelCategory($params['InfoSearch']['cid']);
     }
     return $dataProvider;
 }
示例#4
0
 /**
  * Creates data provider instance with search query applied
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Info::find();
     if (!\Yii::$app->user->can('administrator')) {
         $query->forDomain();
     }
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!empty($params['mid'])) {
         $query->andFilterWhere(['model_id' => intval($params['mid'])]);
     }
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['info.id' => $this->id, 'info.author_id' => $this->author_id, 'info.category_id' => $this->category_id, 'info.model_id' => $this->model_id, 'info.updater_id' => $this->updater_id, 'info.status' => $this->status, 'info.domain_id' => $this->domain_id]);
     if ($this->search_date_published != '') {
         $this->data_begin_published = strtotime($this->search_date_published);
         $this->data_end_published = strtotime($this->search_date_published) + 24 * 60 * 60;
     }
     $query->andFilterWhere(['like', 'info.slug', $this->slug])->andFilterWhere(['like', 'info.title', $this->title])->andFilterWhere(['like', 'info.description', $this->description])->andFilterWhere(['like', 'info.weight', $this->weight])->andFilterWhere(['like', 'info.body', $this->body])->andFilterWhere(['like', 'info.before_body', $this->before_body])->andFilterWhere(['like', 'info.after_body', $this->after_body])->andFilterWhere(['between', 'info.published_at', $this->data_begin_published, $this->data_end_published])->andFilterWhere(['like', 'info.on_scenario', $this->on_scenario]);
     if (!empty($params['InfoSearch']['cid'])) {
         $query->onlyModelCategory($params['InfoSearch']['cid']);
     }
     return $dataProvider;
 }
示例#5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getFirstInfo()
 {
     return Info::find()->firstInfo($this->id, $this->domain_id);
     //return $this->hasOne(ModelCategory::className(), ['id' => 'category_id']);
 }
示例#6
0
 /**
  * Finds the Info model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Info the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Info::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
示例#7
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getInfos()
 {
     return $this->hasMany(Info::className(), ['category_id' => 'id']);
 }
示例#8
0
 /**
  * Deletes an existing Model model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     //$this->findModel($id)->delete();
     $infoModel = Info::find()->andWhere(['model_id' => $id])->one();
     if (null === $infoModel) {
         $this->findModel($id)->delete();
     } else {
         Yii::$app->session->setFlash('alert', ['body' => \Yii::t('backend', 'Can not delete model #' . $id . '. It used in other table. Delete info page #' . $infoModel->id . ' first.'), 'options' => ['class' => 'alert-error']]);
     }
     return $this->redirect(['index']);
 }
示例#9
0
 public function actionInfo($id)
 {
     $data = \common\models\Info::findOne($id);
     return $this->renderAjax('info', ['data' => $data]);
 }
 /** 修改状态 */
 public function actionChangeState()
 {
     $request = Yii::$app->request;
     if ($request->isPost) {
         $infoId = $request->post('infoId');
         $state = $request->post('state');
         if ($state == 'ok') {
             if ($result = Info::changeState($infoId, Info::STATE_PASS)) {
                 return $result;
             }
         } elseif ($state == 'error') {
             $replyContent = $request->post('replyContent');
             if ($result = Info::changeState($infoId, Info::STATE_REFUSE, $replyContent)) {
                 return $result;
             }
         } else {
             return "状态未定义";
         }
         return 'ok';
     } else {
         throw new Exception("非正常请求");
     }
 }
示例#11
0
 public function record()
 {
     $user = Yii::$app->session->get('user');
     $info = Info::findRefusedByUserId($user['userId']);
     if (!$info) {
         $info = new Info();
         $info->password = CommonFunctions::createRandPassword();
     }
     $info->userId = $this->userId;
     $info->IDCard = $this->IDCard;
     $info->realName = $this->realName;
     $info->cellphone = $this->cellphone;
     $info->education = $this->education;
     $info->major = $this->major;
     $info->workTime = $this->workTime;
     $info->technical = $this->technical;
     $info->signUpMajor = $this->signUpMajor;
     $info->company = $this->company;
     $info->findPasswordQuestion = $this->findPasswordQuestion;
     $info->findPasswordAnswer = $this->findPasswordAnswer;
     $info->headImg = $this->headImg;
     $info->educationImg = $this->educationImg;
     $info->createDate = DateFunctions::getCurrentDate();
     $info->state = Info::STATE_RECORD;
     if (!$info->save()) {
         throw new Exception("Sign Up Info save error");
     }
 }
示例#12
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getInfo()
 {
     return $this->hasOne(Info::className(), ['id' => 'info_id']);
 }
示例#13
0
文件: Info.php 项目: allhaze/renault
 public function afterDelete()
 {
     $model = Info::find()->andWhere(['locale_group_id' => $this->locale_group_id, 'domain_id' => Yii::$app->user->identity->domain_id])->one();
     if ($model) {
         $model->delete();
     }
     return parent::afterDelete();
 }
示例#14
0
 /**
  * 修改状态,有错误会返回错误
  * @param $infoId
  * @param $state
  * @return bool|string
  */
 public static function changeState($infoId, $state, $replyContent = null)
 {
     $info = Info::findOne($infoId);
     if ($info) {
         $info->state = $state;
         $user = Yii::$app->session->get('user');
         $info->replyUserId = $user['userId'];
         $info->replyDate = DateFunctions::getCurrentDate();
         $info->replyContent = $replyContent;
         $info->save();
         return false;
     } else {
         return "不存在该信息";
     }
 }