/**
  * Updates an existing ProyectoAccionEspecifica model.
  * For ajax request will return json object
  * and for non-ajax request if update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $request = Yii::$app->request;
     $model = $this->findModel($id);
     //lista desplegable
     $unidadEjecutora = UnidadEjecutora::find()->all();
     $unidadMedida = UnidadMedida::find()->all();
     if ($request->isAjax) {
         /*
          *   Process for ajax request
          */
         Yii::$app->response->format = Response::FORMAT_JSON;
         if ($request->isGet) {
             return ['title' => "Editar Acción Específica #" . $id, 'content' => $this->renderAjax('update', ['model' => $model, 'unidadEjecutora' => $unidadEjecutora, 'unidadMedida' => $unidadMedida]), 'footer' => Html::button('Cerrar', ['class' => 'btn btn-default pull-left', 'data-dismiss' => "modal"]) . Html::button('Guardar', ['class' => 'btn btn-primary', 'type' => "submit"])];
         } else {
             if ($model->load($request->post()) && $model->save()) {
                 return ['forceReload' => '#especifica-pjax', 'title' => "Editar Acción Específica #" . $id, 'content' => $this->renderAjax('view', ['model' => $model, 'unidadEjecutora' => $unidadEjecutora, 'unidadMedida' => $unidadMedida]), 'footer' => Html::button('Cerrar', ['class' => 'btn btn-default pull-left', 'data-dismiss' => "modal"]) . Html::a('Editar', ['update', 'id' => $id], ['class' => 'btn btn-primary', 'role' => 'modal-remote'])];
             } else {
                 return ['title' => "Update ProyectoAccionEspecifica #" . $id, 'content' => $this->renderAjax('update', ['model' => $model, 'unidadEjecutora' => $unidadEjecutora, 'unidadMedida' => $unidadMedida]), 'footer' => Html::button('Cerrar', ['class' => 'btn btn-default pull-left', 'data-dismiss' => "modal"]) . Html::button('Guardar', ['class' => 'btn btn-primary', 'type' => "submit"])];
             }
         }
     } else {
         /*
          *   Process for non-ajax request
          */
         if ($model->load($request->post()) && $model->save()) {
             return $this->redirect(['view', 'id' => $model->id]);
         } else {
             return $this->render('update', ['model' => $model, 'unidadEjecutora' => $unidadEjecutora, 'unidadMedida' => $unidadMedida]);
         }
     }
 }
Esempio n. 2
0
 /**
  * Pedidos
  * @param integer $ue unidad ejecutora
  * @return mixed
  */
 public function actionPedido($proyectoEspecifica)
 {
     //Datos para el gridview
     $searchModel = new ProyectoPedidoSearch(['proyectoEspecifica' => $proyectoEspecifica]);
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     //Otros datos
     $pe = ProyectoAccionEspecifica::find()->where(['id' => $proyectoEspecifica])->one();
     $ue = UnidadEjecutora::find()->where(['id' => $pe->id_unidad_ejecutora])->one();
     return $this->render('pedido', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'ue' => $ue, 'pe' => $pe, 'proyectoEspecifica' => $proyectoEspecifica]);
 }
 /**
  * Pedidos
  * @param integer $ue unidad ejecutora
  * @return mixed
  */
 public function actionPedido($ue, $acc)
 {
     //Datos para el gridview
     $searchModel = new AccionCentralizadaPedidoSearch(['idUnidadEjecutora' => $ue, 'idAcc' => $acc]);
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     $model = AcEspUej::find()->where(['id_ue' => $ue])->andWhere(['id_ac_esp' => $acc])->One();
     //Otros datos
     $ue = UnidadEjecutora::findOne($ue);
     return $this->render('pedido', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'ue' => $ue, 'model' => $model]);
 }
Esempio n. 4
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = UnidadEjecutora::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]);
     $query->andFilterWhere(['like', 'codigo_ue', $this->codigo_ue])->andFilterWhere(['like', 'nombre', $this->nombre]);
     return $dataProvider;
 }
 /**
  * Funcion de respuesta para el AJAX de
  * unidades ejecutoras
  * @return array JSON 
  */
 public function actionAce()
 {
     $request = Yii::$app->request;
     if ($request->isAjax) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         if ($request->isPost) {
             //Acciones Especificas
             $ace = UnidadEjecutora::find()->select(["unidad_ejecutora.id", "CONCAT(unidad_ejecutora.codigo_ue,' - ',unidad_ejecutora.nombre) AS name"])->innerjoin('accion_centralizada_ac_especifica_uej', 'accion_centralizada_ac_especifica_uej.id_ue=unidad_ejecutora.id')->where(['accion_centralizada_ac_especifica_uej.id_ac_esp' => $request->post('depdrop_parents')])->asArray()->all();
             if ($ace != NULL) {
                 return ['output' => $ace];
             }
         }
     }
 }
Esempio n. 6
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getIdUe()
 {
     return $this->hasOne(UnidadEjecutora::className(), ['id' => 'id_ue']);
 }
Esempio n. 7
0
 /**
  * Finds the UnidadEjecutora model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return UnidadEjecutora the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = UnidadEjecutora::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Esempio n. 8
0
    <?php 
    echo Html::dropDownList('accion_centralizada', 'accion_centralizada', ArrayHelper::map($accion_centralizada, 'id', 'nombre_accion'), ['prompt' => 'Seleccione', 'class' => 'form-control', 'id' => 'accion_centralizada']);
    ?>
    
    <?php 
}
// fin del else
?>
    
    
    <?php 
echo $form->field($model, 'acc_accion_especifica')->dropDownList(ArrayHelper::map($accion_especifica, 'id', 'nombre'), ['prompt' => 'Seleccione']);
?>
    
    <!--<?php 
echo $form->field($model, 'unidad_ejecutora')->dropDownList(ArrayHelper::map(UnidadEjecutora::find()->all(), 'id', 'nombre'), ['prompt' => 'Selecciones Unidad Ejecutora']);
?>
-->
    
    <?php 
echo $form->field($model, 'unidad_ejecutora')->dropDownList(ArrayHelper::map($ue, 'id', 'name'), ['prompt' => 'Seleccione']);
?>

    <?php 
if (empty($acciones_especificas)) {
    $acciones_especificas = [];
}
?>
  
    <!--<?php 
echo $form->field($model, 'acc_accion_especifica')->dropDownList($acciones_especificas, ['prompt' => 'Seleccione']);
 /**
  * obtener las unidades ejecutoras asociadas a una acc
  * @param int $acc_uej
  * @return array
  */
 public function ObtenerUnidadesEJ($acc_uej)
 {
     $unidad = UnidadEjecutora::find()->select(["unidad_ejecutora.id as id", "CONCAT(unidad_ejecutora.codigo_ue, ' - ',unidad_ejecutora.nombre) as name"])->innerjoin('accion_centralizada_ac_especifica_uej', 'accion_centralizada_ac_especifica_uej.id_ue=unidad_ejecutora.id')->where(['accion_centralizada_ac_especifica_uej.id_ac_esp' => $acc_uej])->asArray()->all();
     return $unidad;
 }
 /**
  * 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]);
     }
 }
Esempio n. 11
0
 /**
  * Accion para importar acciones especificas.
  * @param integer $accion_centralizada es el id de una accion central
  * @return mixed
  */
 public function actionImportar($accion_central)
 {
     $request = Yii::$app->request;
     $modelo = new UploadForm();
     if ($request->isPost) {
         $archivo = file($_FILES['UploadForm']['tmp_name']['importFile']);
         $bandera = 0;
         $contador = 0;
         $mensaje = "";
         $id_accion_especifica = "";
         $connection = \Yii::$app->db;
         $transaction = $connection->beginTransaction();
         try {
             foreach ($archivo as $llave => $valor) {
                 $exploded = explode(';', str_replace('"', '', $valor));
                 if ($bandera == 0) {
                     $ac = AcAcEspec::find()->where(['cod_ac_espe' => $exploded[0], 'id_ac_centr' => $accion_central])->one();
                     if ($ac == null) {
                         $ac = new AcAcEspec();
                         $ac->id_ac_centr = $accion_central;
                         $ac->cod_ac_espe = str_replace("'", "", $exploded[0]);
                         $ac->nombre = $exploded[1];
                         $ac->estatus = 0;
                         $ac->isNewRecord = true;
                         $ac->id = null;
                         $ac->save(false);
                         //guardando unidad ejecutora de esa accion especifica
                         //si existe unidades ejecutoras
                         $exploded[2] = str_replace("'", "", $exploded[2]);
                         if (isset($exploded[2]) && $exploded[2] > 0) {
                             $bandera = 1;
                             $contador = $exploded[2];
                             $id_accion_especifica = $ac->id;
                         }
                     } else {
                         $mensaje = "Codigo De Accion Ya Existe";
                     }
                 } else {
                     //print_r($exploded); exit();
                     $exploded[0] = str_replace("'", "", $exploded[0]);
                     $exploded[0] = str_replace("\r\n", "", $exploded[0]);
                     $ej = UnidadEjecutora::find()->where(['codigo_ue' => $exploded[0]])->one();
                     if ($ej != null) {
                         $ac_ej = new AcEspUej();
                     } else {
                         $mensaje = "No Existe El Codigo De Unidad Ejecutora " . $exploded[0];
                     }
                     $ac_ej->id_ue = $ej['id'];
                     $ac_ej->id_ac_esp = $id_accion_especifica;
                     $ac_ej->save(false);
                     $contador = $contador - 1;
                     if ($contador == 0) {
                         $bandera = 0;
                     }
                 }
             }
             $transaction->commit();
             Yii::$app->session->setFlash('importado', '<div class="alert alert-success">Registros importados exitosamente.</div>');
             return $this->refresh();
         } catch (\Exception $e) {
             $transaction->rollBack();
             Yii::$app->session->setFlash('importado', '<div class="alert alert-danger">' . $mensaje . '</div>');
         }
     }
     return $this->render('importar', ['modelo' => $modelo, 'accion_central' => $accion_central]);
 }
Esempio n. 12
0
 /**
  * Updates an existing UePartidaEntidad model.
  * For ajax request will return json object
  * and for non-ajax request if update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $request = Yii::$app->request;
     $model = $this->findModel($id);
     $cuenta = $model->cuenta;
     $partida = $model->partida;
     $ue = ArrayHelper::map(UnidadEjecutora::find()->asArray()->all(), 'id', 'nombre');
     $tipo_entidad = arrayHelper::map(TipoEntidad::find()->asArray()->all(), 'id', 'nombre');
     $verificar = ArrayHelper::map(UePartidaEntidad::find()->where('cuenta= :id', ['id' => $model->cuenta])->andwhere(['partida' => $model->partida])->andwhere(['id_tipo_entidad' => 1])->all(), 'id', 'id_ue');
     $verificar_acc = ArrayHelper::map(UePartidaEntidad::find()->where('cuenta= :id', ['id' => $model->cuenta])->andwhere(['partida' => $model->partida])->andwhere(['id_tipo_entidad' => 2])->all(), 'id', 'id_ue');
     /*
      *   Process for post resquest
      */
     if ($request->post()) {
         //
         $connection = \Yii::$app->db;
         $transaction = $connection->beginTransaction();
         try {
             //verificando los cambios en los tipos de entidad proyecto y acc
             $proyecto = $request->post('ue_proyecto');
             $acc = $request->post('ue_acc');
             if (empty($proyecto) && empty($acc)) {
                 Yii::$app->getSession()->setFlash('danger', 'Error, no puede dejar las partida sin unidad ejecutora');
                 return $this->render('update', ['model' => $model, 'ue' => $ue, 'tipo_entidad' => $tipo_entidad, 'precarga_proyecto' => $verificar, 'precarga_acc' => $verificar_acc]);
             }
             $model->UejEntidad($proyecto, 1);
             $model->UejEntidad($acc, 2);
             $transaction->commit();
         } catch (Exception $e) {
             $transaction->rollback();
             Yii::$app->getSession()->setFlash('danger', 'Error al actualizar unidades.');
             return $this->render('update', ['model' => $model, 'ue' => $ue, 'tipo_entidad' => $tipo_entidad, 'precarga_proyecto' => $verificar, 'precarga_acc' => $verificar_acc]);
         }
         return $this->redirect(['view', 'partida' => $partida, 'cuenta' => $cuenta]);
     } else {
         return $this->render('update', ['model' => $model, 'ue' => $ue, 'tipo_entidad' => $tipo_entidad, 'precarga_proyecto' => $verificar, 'precarga_acc' => $verificar_acc]);
     }
 }