Example #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = PartidaSubEspecifica::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, 'especifica' => $this->especifica, 'sub_especifica' => $this->sub_especifica, 'estatus' => $this->estatus]);
     $query->andFilterWhere(['like', 'nombre', $this->nombre]);
     return $dataProvider;
 }
 /**
  * Finds the PartidaSubEspecifica model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param char(1) $cuenta
  * @param char(2) $partida
  * @param char(2) $generica
  * @param char(2) $especifica
  * @param char(2) $subespecifica
  * @return el modelo
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($cuenta, $partida, $generica, $especifica, $subespecifica)
 {
     if (($model = PartidaSubEspecifica::findOne(['cuenta' => $cuenta, 'partida' => $partida, 'generica' => $generica, 'especifica' => $especifica, 'subespecifica' => $subespecifica])) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #3
0
 public function cabeceras()
 {
     //cabeceras
     $model = $this;
     $columnas = PartidaSubEspecifica::find()->select([new \yii\db\Expression('concat(cuenta,partida) as partida')])->where('cuenta in (4)')->groupBy(new \yii\db\Expression('concat(cuenta,partida)'))->asArray()->all();
     $data[] = ['class' => 'kartik\\grid\\SerialColumn', 'width' => '30px'];
     $data[] = ['class' => 'kartik\\grid\\DataColumn', 'width' => '30px', 'attribute' => 'nombre_accion', 'value' => function ($model, $index, $dataColumn) {
         return $model['nombre'];
     }];
     foreach ($columnas as $key => $value) {
         $data[] = ['class' => '\\kartik\\grid\\DataColumn', 'attribute' => $value['partida'], 'value' => function ($model, $index, $dataColumn, $dataProvider) {
             if (array_key_exists($dataProvider->attribute, $model)) {
                 return $model[$dataProvider->attribute];
             }
         }];
     }
     return $data;
 }
 /**
  * Updates an existing MaterialesServicios 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);
     //Desplegables
     $unidad_medida = UnidadMedida::find()->all();
     $presentacion = Presentacion::find()->all();
     //autocompletar
     $sub_especfica = PartidaSubEspecifica::find()->select(['nombre as value', 'id as id'])->asArray()->all();
     if ($request->isAjax) {
         /*
          *   Process for ajax request
          */
         Yii::$app->response->format = Response::FORMAT_JSON;
         if ($request->isGet) {
             return ['title' => "Modificar Materiales/Servicios #" . $id, 'content' => $this->renderAjax('update', ['model' => $model, 'unidad_medida' => $unidad_medida, 'presentacion' => $presentacion, 'sub_especfica' => $sub_especfica]), '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' => '#crud-datatable-pjax', 'title' => "MaterialesServicios #" . $id, 'content' => $this->renderAjax('view', ['model' => $model, 'unidad_medida' => $unidad_medida, 'presentacion' => $presentacion, 'sub_especfica' => $sub_especfica]), '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' => "Modificar Materiales/Servicios #" . $id, 'content' => $this->renderAjax('update', ['model' => $model, 'unidad_medida' => $unidad_medida, 'presentacion' => $presentacion, 'sub_especfica' => $sub_especfica]), '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, 'unidad_medida' => $unidad_medida, 'presentacion' => $presentacion, 'sub_especfica' => $sub_especfica]);
         }
     }
 }
Example #5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPartidaSubEspecificas()
 {
     return $this->hasMany(PartidaSubEspecifica::className(), ['cuenta' => 'cuenta', 'partida' => 'partida', 'generica' => 'generica', 'especifica' => 'especifica']);
 }
Example #6
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCuenta0()
 {
     return $this->hasOne(PartidaSubEspecifica::className(), ['cuenta' => 'cuenta', 'partida' => 'partida', 'generica' => 'generica', 'especifica' => 'especifica', 'subespecifica' => 'subespecifica']);
 }