protected function findModel($id) { if (($model = Jobs::find()->where(['and', 'id=' . $id, 'status=' . Status::STATUS_ACTIVE])->One()) !== null) { return $model; } else { throw new NotFoundHttpException('你所查找的网页不存在'); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Jobs::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'company_id' => $this->company_id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'status' => $this->status]); $query->andFilterWhere(['like', 'zhiweiming', $this->zhiweiming])->andFilterWhere(['like', 'gongzuodiqu', $this->gongzuodiqu])->andFilterWhere(['like', 'zhiweixinzi', $this->zhiweixinzi])->andFilterWhere(['like', 'xueliyaoqiu', $this->xueliyaoqiu])->andFilterWhere(['like', 'zhaopinrenshu', $this->zhaopinrenshu])->andFilterWhere(['like', 'gongzuoxingzhi', $this->gongzuoxingzhi])->andFilterWhere(['like', 'xingbieyaoqiu', $this->xingbieyaoqiu])->andFilterWhere(['like', 'gongzuojingyan', $this->gongzuojingyan])->andFilterWhere(['like', 'jingzhengyoushi', $this->jingzhengyoushi])->andFilterWhere(['like', 'zhiweimiaoshu', $this->zhiweimiaoshu]); return $dataProvider; }
public function actionCreateid() { $session = new Session(); $session->open(); if (\yii::$app->request->isAjax) { $pk = \yii::$app->request->post('pk'); $module = \yii::$app->request->post('module'); $deparment = \yii::$app->request->post('department'); $session['recid'] = $pk; $session['module'] = $module; $session['department'] = $deparment; $reccount = 0; $reccount = Jobs::find()->where(['recid' => $pk, 'jobstatus' => 2])->count(); if ($reccount > 0) { $session->setFlash('msgstatus', 'ใบสั่งงานนี้ได้อนุมัติไปเรียบร้อยแล้ว'); } else { //$session->setFlash('msgstatus','ใบสั่งงานนี้ได้อนุมัติไปเรียบร้อยแล้ว'); } } }