コード例 #1
0
ファイル: SeSearch.php プロジェクト: minpppst/rsc
 /**
  * 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;
 }
コード例 #2
0
ファイル: AccionCentralizada.php プロジェクト: minpppst/rsc
 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;
 }
コード例 #3
0
 /**
  * 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]);
         }
     }
 }