/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Incident::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'date' => $this->date, 'equipment_id' => $this->equipment_id, 'room_id' => $this->room_id, 'solved' => $this->solved, 'date_solved' => $this->date_solved, 'client_id' => $this->client_id, 'user_id' => $this->user_id]); $query->andFilterWhere(['like', 'description', $this->description]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Incident::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(['id' => $this->id, 'raptor_id' => $this->raptor_id, 'nearest_city_id' => $this->nearest_city_id, 'hy' => $this->hy, 'a' => $this->a, 'orphan' => $this->orphan, 'oiled' => $this->oiled, 'leg_hold_trap' => $this->leg_hold_trap, 'methane_burner' => $this->methane_burner, 'wind_turbine' => $this->wind_turbine, 'gunshot' => $this->gunshot, 'hvt' => $this->hvt, 'window_strike' => $this->window_strike, 'hbc' => $this->hbc, 'cbc' => $this->cbc, 'head_spinal_trama' => $this->head_spinal_trama, 'wnv' => $this->wnv, 'emaciated' => $this->emaciated, 'disposition_date' => $this->disposition_date, 'end_of_stay' => $this->end_of_stay, 'released' => $this->released, 'died' => $this->died, 'died_48' => $this->died_48, 'died_96' => $this->died_96, 'euthanized' => $this->euthanized, 'euthanized_48' => $this->euthanized_48, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'city', $this->city])->andFilterWhere(['like', 'state', $this->state])->andFilterWhere(['like', 'zip', $this->zip])->andFilterWhere(['like', 'county', $this->county])->andFilterWhere(['like', 'lat', $this->lat])->andFilterWhere(['like', 'lon', $this->lon])->andFilterWhere(['like', 'lead_value', $this->lead_value])->andFilterWhere(['like', 'fx', $this->fx])->andFilterWhere(['like', 'suspected_injury', $this->suspected_injury])->andFilterWhere(['like', 'disposition', $this->disposition]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Incident::find(); $query->joinWith(['equipment', 'room', 'client', 'user']); $dataProvider = new ActiveDataProvider(['query' => $query]); $dataProvider->sort->attributes['equipment'] = ['asc' => ['equipment.inventory' => SORT_ASC], 'desc' => ['equipment.inventory' => SORT_DESC]]; $dataProvider->sort->attributes['room'] = ['asc' => ['room.name' => SORT_ASC], 'desc' => ['room.name' => SORT_DESC]]; $dataProvider->sort->attributes['client'] = ['asc' => ['client.client_id' => SORT_ASC], 'desc' => ['client.client_id' => SORT_DESC]]; $dataProvider->sort->attributes['user'] = ['asc' => ['user.user_name' => SORT_ASC], 'desc' => ['user.user_name' => SORT_DESC]]; $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(['id' => $this->id, 'solved' => $this->solved, 'date_solved' => $this->date_solved]); $query->andFilterWhere(['like', 'incident.description', $this->description])->andFilterWhere(['like', 'date', $this->date])->andFilterWhere(['like', 'equipment.inventory', $this->equipment])->andFilterWhere(['like', 'room.name', $this->room])->andFilterWhere(['like', 'client.client_id', $this->client])->andFilterWhere(['like', 'user.user_name', $this->user]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getIncidents() { return $this->hasMany(Incident::className(), ['user_id' => 'id']); }
/** * @return \yii\db\ActiveQuery */ public function getIncidents() { return $this->hasMany(Incident::className(), ['nearest_city_id' => 'id']); }
/** * Finds the Incident model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return Incident the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Incident::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getRaptor() { return $this->hasOne(Incident::className(), ['id' => 'raptor_id']); }
?> <div class="incident-index"> <h1><?php echo Html::encode($this->title); ?> </h1> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <p> <?php echo ButtonDropdown::widget(['label' => 'Create Incident', 'options' => ['class' => 'btn btn-success'], 'containerOptions' => ['class' => 'margin-bottom_20'], 'dropdown' => ['items' => array_map(function ($data) { return ['label' => $data->species_long, 'url' => ['incident/create', 'raptor_id' => $data->id]]; }, Incident::raptors())]]); ?> </p> <?php Pjax::begin(['timeout' => Yii::$app->constants->pjaxTimeout]); ?> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => ActionColumn::className(), 'template' => '{update}{view}', 'headerOptions' => ['style' => 'width: 100px;'], 'buttonOptions' => ['style' => 'padding: 5px;'], 'contentOptions' => ['style' => 'text-align: center;']], 'raptor_id', 'address', 'city', 'state']]); ?> <?php Pjax::end(); ?> </div>
/** * @return \yii\db\ActiveQuery */ public function getIncident() { return $this->hasOne(Incident::className(), ['id' => 'incident_id']); }