Beispiel #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = AcAcEspec::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, 'id_ac_centr' => $this->id_ac_centr]);
     $query->andFilterWhere(['like', 'cod_ac_espe', $this->cod_ac_espe])->andFilterWhere(['like', 'nombre', $this->nombre]);
     return $dataProvider;
 }
 /**
  * obtener las acciones especificas
  * @param int $accion
  * @return array
  */
 public function BuscarACC($accion)
 {
     $ace = AcAcEspec::find()->select(["accion_centralizada_accion_especifica.id", "CONCAT(accion_centralizada_accion_especifica.cod_ac_espe,' - ',accion_centralizada_accion_especifica.nombre) AS name"])->innerjoin('accion_centralizada', 'accion_centralizada.id=accion_centralizada_accion_especifica.id_ac_centr')->where(['accion_centralizada.id' => $accion, 'accion_centralizada_accion_especifica.estatus' => 1])->asArray()->all();
     return $ace;
 }
 /**
  * Updates an existing AccionCentralizadaVariables model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $precarga = "";
     $precarga1 = "";
     $model = $this->findModel($id);
     $accion_centralizada = AccionCentralizada::find(['estatus' => 1])->all();
     $accion_especifica = AcAcEspec::find()->where(['id' => $model->acc_accion_especifica, 'estatus' => 1])->all();
     $ue = UnidadEjecutora::find(['estatus' => 1])->select(["unidad_ejecutora.id as id", "unidad_ejecutora.nombre as name"])->where(['id' => $model->unidad_ejecutora])->asArray()->all();
     $verificar = UserAccounts::find()->select(["user_accounts.id as id", "user_accounts.username as username"])->innerjoin('accion_centralizada_variables_usuarios', 'user_accounts.id=accion_centralizada_variables_usuarios.id_usuario')->where(['accion_centralizada_variables_usuarios.id_variable' => $model->id])->andWhere(['accion_centralizada_variables_usuarios.estatus' => 1])->asArray()->all();
     $i = 0;
     foreach ($verificar as $key) {
         $precarga[$i] = $key['id'];
         $precarga1[$i] = $key['username'];
         $i++;
     }
     $acciones_especificas = [$model->accAccionEspecifica->id => $model->accAccionEspecifica->cod_ac_espe . " - " . $model->accAccionEspecifica->nombre];
     $connection = \Yii::$app->db;
     $transaction = $connection->beginTransaction();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         $usuarios = Yii::$app->request->post('id_usuario');
         $salvar = $model->uejecutoras($usuarios);
         $transaction->commit();
         return $this->redirect(['accion-centralizada-variables/view', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model, 'precarga' => $precarga, 'precarga1' => $precarga1, 'accion_centralizada' => $accion_centralizada, 'accion_especifica' => $accion_especifica, 'ue' => $ue]);
     }
 }