public function actionSensorpopup($locationid = null) { $locations = Catchment::find()->all(); if (isset($locationid)) { $location = Catchment::find()->where(['id' => $locationid])->one(); } else { $location = $locations[0]; } return $this->renderPartial('sensorpopup', array('locations' => $locations, 'location' => $location)); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Catchment::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]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'name_es', $this->name_es])->andFilterWhere(['like', 'name_ne', $this->name_ne])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'description_es', $this->description_es])->andFilterWhere(['like', 'description_ne', $this->description_ne]); return $dataProvider; }
public function actionSensors($locationid) { $location = Catchment::find()->where(['id' => $locationid])->One(); return $this->renderPartial('sensors', array('location' => $location)); }
/** * @return \yii\db\ActiveQuery */ public function getCatchment() { return $this->hasOne(\app\models\Catchment::className(), ['id' => 'catchmentid']); }
<hr> </div> <div class="col-lg-4"> <?php echo \Yii::t('app', 'LOCATION'); ?> </div> <div class="col-lg-8"> <?php /*= $form->field($model, 'catchmentid', ['template' => '{input}{error}{hint}'])->dropDownList(\yii\helpers\ArrayHelper::map(app\models\Catchment::find()->all(), 'id', 'name'), ['prompt' => Yii::t('app', 'Select')] ); */ ?> <?php echo Html::activeDropDownList($model, 'catchmentid', ArrayHelper::map(Catchment::find()->all(), 'id', 'name')); ?> </div> <div class="col-lg-12"> <hr> </div> <div class="col-lg-4"> <?php echo \Yii::t('app', 'TYPE OF SENSOR'); ?> </div> <div class="col-lg-8">
/** * Finds the Catchment model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Catchment the loaded model * @throws HttpException if the model cannot be found */ protected function findModel($id) { if (($model = Catchment::findOne($id)) !== null) { return $model; } else { throw new HttpException(404, 'The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getCatchments() { return $this->hasMany(\app\models\Catchment::className(), ['userid' => 'id']); }