コード例 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = UePartidaEntidad::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_ue' => $this->id_ue, 'id_tipo_entidad' => $this->id_tipo_entidad]);
     $query->select(['ANY_VALUE(id) as id', 'cuenta', 'partida'])->andFilterWhere(['like', 'cuenta', $this->cuenta])->andFilterWhere(['like', 'partida', $this->partida])->groupBy('partida, cuenta');
     return $dataProvider;
 }
コード例 #2
0
ファイル: UePartidaEntidad.php プロジェクト: minpppst/rsc
 public function obtener_uej_relacionadas($entidad, $cuenta, $partida)
 {
     $ue = "";
     $uej = UePartidaEntidad::find()->select(['unidad_ejecutora.nombre as name'])->innerjoin('unidad_ejecutora', 'ue_partida_entidad.id_ue=unidad_ejecutora.id')->where(['ue_partida_entidad.cuenta' => $cuenta])->andWhere(['ue_partida_entidad.partida' => $partida])->andwhere(['ue_partida_entidad.id_tipo_entidad' => $entidad])->asArray()->all();
     foreach ($uej as $key => $value) {
         $ue .= $value['name'] . ", ";
     }
     $ue = substr($ue, 0, -2);
     return $ue;
 }
コード例 #3
0
ファイル: TipoEntidad.php プロジェクト: minpppst/rsc
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getUePartidaEntidads()
 {
     return $this->hasMany(UePartidaEntidad::className(), ['id_tipo_entidad' => 'id']);
 }
コード例 #4
0
 /**
  * Updates an existing AccionCentralizadaPedido 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);
     //autocomplete
     //$materiales = MaterialesServicios::find()
     //      ->select(['nombre', 'id', 'precio'])
     //    ->all();
     $materiales = UePartidaEntidad::find()->andWhere(['id_tipo_entidad' => 2])->andWhere(['id_ue' => $model->asignado0->accion_especifica_ue0->id_ue])->All();
     foreach ($materiales as $key => $value) {
         foreach ($value->materialesPartidaEntidad as $key => $value) {
             if (isset($value)) {
                 $materiales1[] = $value;
             }
         }
     }
     if ($request->isAjax) {
         /*
          *   Process for ajax request
          */
         Yii::$app->response->format = Response::FORMAT_JSON;
         //verificando que la unidad ejecutora no este aprobada
         $usuario = UserAccounts::findOne(\Yii::$app->user->id);
         $accion = AccionCentralizadaAsignar::find()->where(['usuario' => $usuario->id])->One();
         if ($accion->accion_centralizada_ac_especifica_uej->aprobado == 1) {
             return ['title' => "Requerimientos", 'content' => '<span class="text-danger">Esta Unidad Ejecutora Ya no Puede Realizar Pedidos </span>', 'footer' => Html::button('Cerrar', ['class' => 'btn btn-default pull-left', 'data-dismiss' => "modal"])];
         }
         if ($request->isGet) {
             return ['title' => "Pedido", 'content' => $this->renderAjax('update', ['model' => $this->findModel($id), 'materiales' => $materiales1]), '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' => 'true', 'title' => "Pedido", 'content' => $this->renderAjax('view', ['model' => $this->findModel($id), 'materiales' => $materiales1]), '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' => "Pedido", 'content' => $this->renderAjax('update', ['model' => $this->findModel($id), 'materiales' => $materiales1]), '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, 'materiales' => $materiales]);
         }
     }
 }
コード例 #5
0
 /**
  * Finds the UePartidaEntidad model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return UePartidaEntidad the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = UePartidaEntidad::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }