/** * Lists all Menu models. * @return mixed */ public function actionIndex() { $model = new Search(); if ($model->load(Yii::$app->request->post()) && $model->validate()) { $list = Page::find()->filterWhere(['like', 'text', $model['search']])->all(); if (count($list) == 0) { $errors = 'По Вашему запросу ничего не найдено. Попробуйте задать другой запрос.'; return $this->render('index', ['search' => $model['search'], 'errors' => $errors]); } else { return $this->render('index', ['search' => $model['search'], 'list' => $list]); } } }
/** * Finds the Search model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Search the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Search::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function actionSearch() { $model = new Search(); if ($model->load(Yii::$app->request->post()) && $model->validate()) { $result = $model->getBySearch($model); if (!$result) { Yii::$app->session->setFlash('error', 'Nothing was found.'); } //User::d($result); /*$countQuery = clone $result; $pages = new Pagination(['totalCount' => $countQuery->count(),'defaultPageSize'=>20]); $models = $result->offset($pages->offset) ->limit($pages->limit) ->all(); if(!isset($sort)){ $sort = 1; }*/ return $this->render('search', ['models' => $result, 'lang' => $this->lang]); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Search::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; } // grid filtering conditions $query->andFilterWhere(['med_id' => $this->med_id, 'npi' => $this->npi, 'ind_pac_id' => $this->ind_pac_id, 'ind_enrl_id' => $this->ind_enrl_id, 'grad_yr' => $this->grad_yr, 'grp_prac_pac_id' => $this->grp_prac_pac_id, 'num_grp_prac_mem' => $this->num_grp_prac_mem, 'hosp_aff_ccn_1' => $this->hosp_aff_ccn_1, 'hosp_aff_ccn_2' => $this->hosp_aff_ccn_2, 'hosp_aff_ccn_3' => $this->hosp_aff_ccn_3, 'hosp_aff_ccn_4' => $this->hosp_aff_ccn_4, 'hosp_aff_ccn_5' => $this->hosp_aff_ccn_5]); $query->andFilterWhere(['like', 'last_name', $this->last_name])->andFilterWhere(['like', 'first_name', $this->first_name])->andFilterWhere(['like', 'mid_name', $this->mid_name])->andFilterWhere(['like', 'suffix', $this->suffix])->andFilterWhere(['like', 'gender', $this->gender])->andFilterWhere(['like', 'credential', $this->credential])->andFilterWhere(['like', 'med_school', $this->med_school])->andFilterWhere(['like', 'pri_spec', $this->pri_spec])->andFilterWhere(['like', 'sec_spec1', $this->sec_spec1])->andFilterWhere(['like', 'sec_spec2', $this->sec_spec2])->andFilterWhere(['like', 'sec_spec3', $this->sec_spec3])->andFilterWhere(['like', 'sec_spec4', $this->sec_spec4])->andFilterWhere(['like', 'sec_spec_all', $this->sec_spec_all])->andFilterWhere(['like', 'org_legal_name', $this->org_legal_name])->andFilterWhere(['like', 'org_dba_name', $this->org_dba_name])->andFilterWhere(['like', 'address_1', $this->address_1])->andFilterWhere(['like', 'address_2', $this->address_2])->andFilterWhere(['like', 'marker_add_2', $this->marker_add_2])->andFilterWhere(['like', 'city', $this->city])->andFilterWhere(['like', 'state', $this->state])->andFilterWhere(['like', 'zip', $this->zip])->andFilterWhere(['like', 'hosp_aff_lbn_1', $this->hosp_aff_lbn_1])->andFilterWhere(['like', 'hosp_aff_lbn_2', $this->hosp_aff_lbn_2])->andFilterWhere(['like', 'hosp_aff_lbn_3', $this->hosp_aff_lbn_3])->andFilterWhere(['like', 'hosp_aff_lbn_4', $this->hosp_aff_lbn_4])->andFilterWhere(['like', 'hosp_aff_lbn_5', $this->hosp_aff_lbn_5])->andFilterWhere(['like', 'medicare', $this->medicare])->andFilterWhere(['like', 'erx', $this->erx])->andFilterWhere(['like', 'pqrs', $this->pqrs])->andFilterWhere(['like', 'ehr', $this->ehr])->andFilterWhere(['like', 'pqrs_cert', $this->pqrs_cert])->andFilterWhere(['like', 'mil_hearts', $this->mil_hearts]); return $dataProvider; }
/** * @inheritdoc */ public function actionIndex($q) { $model = new Search(); $model->search($q); return $this->render('index', ['model' => $model]); }
$this->params['breadcrumbs'][] = $this->title; ?> <div class="relatives-index"> <?php if (isset($_POST['search'])) { $searchString = $_POST['search']; } else { $searchString = $_REQUEST['search']; } $searchString = trim($searchString); // $searchString = Html::encode($searchString); // $searchString = Html::decode($searchString); echo Html::tag('p', 'Поисковая строка: ' . $searchString); echo Html::beginTag('div', ['class' => 'panel panel-info']); $content = Html::tag('h3', '<i class="glyphicon glyphicon-calendar"></i> Результаты поиска', ['class' => "panel-title"]); echo Html::tag('div', $content, ['class' => "panel-heading"]); echo Html::endTag('div'); $result = Search::getComplitMatch($searchString, "full"); if (count($result)) { echo Html::beginTag('table', ['class' => 'table table-striped table-bordered detail-view']); foreach ($result as $record) { echo Relatives::renderRow($record->id); } echo Html::endTag('table'); } else { echo 'нет данных'; } ?> </div>