/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Sensor::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, 'catchmentid' => $this->catchmentid, 'latitude' => $this->latitude, 'longitude' => $this->longitude, 'height' => $this->height, 'width' => $this->width, 'angle' => $this->angle]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'sensortype', $this->sensortype])->andFilterWhere(['like', 'units', $this->units])->andFilterWhere(['like', 'property', $this->property])->andFilterWhere(['like', 'admin_email', $this->admin_email]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getSensor() { return $this->hasOne(\app\models\Sensor::className(), ['id' => 'sensorid']); }
/** * Finds the Sensor model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Sensor the loaded model * @throws HttpException if the model cannot be found */ protected function findModel($id) { if (($model = Sensor::findOne($id)) !== null) { return $model; } else { throw new HttpException(404, 'The requested page does not exist.'); } }
public function actionTracing($sensorid = null) { if (isset($sensorid)) { $sensor = Sensor::find()->where(['id' => $sensorid])->one(); return $this->render('sensor_tracing', array('sensor' => $sensor)); } else { return $this->render('sensor_tracing', array('sensor' => null)); } }
/** * @return \yii\db\ActiveQuery */ public function getSensors() { return $this->hasMany(\app\models\Sensor::className(), ['catchmentid' => 'id']); }
<?php echo Html::activeDropDownList($model, 'catchmentid', ArrayHelper::map(Catchment::find()->all(), 'id', 'name')); ?> </div> <div class="col-sm-12"> <hr> </div> <div class="col-sm-4"> <?php echo \Yii::t('app', 'SENSORS'); ?> </div> <div class="col-sm-4"> <?php echo Html::activeDropDownList($model, 'sensorid', ArrayHelper::map(Sensor::find()->all(), 'id', 'name')); ?> </div> <div class="col-sm-4"> <button type="button" class="btn"><?php echo \Yii::t('app', 'Choose on map'); ?> </button> </div> <div class="col-sm-12"> <hr> </div> <div class="col-sm-4"> <?php