/**
  * Displays a single LocalizacionAccVariable model.
  * @param integer $id
  * @return mixed
  */
 public function actionView($id)
 {
     $model = $this->findModel($id);
     $model1 = AccionCentralizadaVariableProgramacion::find()->where(['id_localizacion' => $model->id])->One();
     $model2 = AccionCentralizadaVariables::find($model->id_variable)->One();
     $request = Yii::$app->request;
     if ($request->isAjax) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         return ['title' => "Variable #" . $id, 'content' => $this->renderAjax('view', ['model' => $model, 'model1' => $model1]), 'footer' => Html::button('Cerrar', ['class' => 'btn btn-default pull-left', 'data-dismiss' => "modal"]) . Html::a('Editar', ['update', 'id' => $id, 'variable' => $model->id_variable, 'localizacion' => $model2->localizacion], ['class' => 'btn btn-primary', 'role' => 'modal-remote'])];
     } else {
         return $this->render('view', ['model' => $model, 'model1' => $model1]);
     }
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = AccionCentralizadaVariables::find();
     $query->joinWith(['unidadMedida']);
     // add conditions that should always apply here
     $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(['id' => $this->id, 'responsable' => $this->responsable, 'meta_programada_variable' => $this->meta_programada_variable, 'unidad_ejecutora' => $this->unidad_ejecutora, 'acc_accion_especifica' => $this->acc_accion_especifica]);
     $query->andFilterWhere(['like', 'nombre_variable', $this->nombre_variable])->andFilterWhere(['like', 'definicion', $this->definicion])->andFilterWhere(['like', 'base_calculo', $this->base_calculo])->andFilterWhere(['like', 'unidad_medida.unidad_medida', $this->unidad_medida])->andFilterWhere(['like', 'fuente_informacion', $this->fuente_informacion]);
     return $dataProvider;
 }
 public function VariablesAsignadas()
 {
     $ace = AccionCentralizadaVariables::find()->select(["accion_centralizada_variables.nombre_variable as nombre", "accion_centralizada_variables.id", "accion_centralizada_variables.localizacion as localizacion", "localizacion_acc_variable.id id_localizacion"])->innerjoin('accion_centralizada_variables_usuarios', 'accion_centralizada_variables_usuarios.id_variable=accion_centralizada_variables.id')->innerjoin('localizacion_acc_variable', 'localizacion_acc_variable.id_variable=accion_centralizada_variables.id')->where(['accion_centralizada_variables_usuarios.id_usuario' => Yii::$app->user->getId()])->asArray()->all();
     $provider = new ArrayDataProvider(['allModels' => $ace, 'sort' => ['attributes' => ['nombre']], 'pagination' => ['pageSize' => 10]]);
     return $provider;
 }
Example #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getIdVariable()
 {
     return $this->hasOne(AccionCentralizadaVariables::className(), ['id' => 'id_variable']);
 }
 /**
  * Finds the AccionCentralizadaVariables model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return AccionCentralizadaVariables the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = AccionCentralizadaVariables::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }