/** * Updates an existing Producto model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); $categoria = new Categoria(); $categoriasActivas = $categoria->getCategoriasActivas(); if ($model->load(Yii::$app->request->post())) { $subioArchivo = false; if ($model->file = UploadedFile::getInstance($model, 'file')) { $subioArchivo = true; $nombreImagen = $model->nombre; $model->imagen = 'img/' . $nombreImagen . '.' . $model->file->extension; } if ($model->validate()) { $model->save(); if ($subioArchivo) { $model->file->saveAs('img/' . $model->nombre . '.' . $model->file->extension); } Yii::$app->getSession()->setFlash('success', Yii::t('core', 'Product has been succesfully updated')); return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('update', ['model' => $model, 'categorias' => $categoriasActivas]); } } else { return $this->render('update', ['model' => $model, 'categorias' => $categoriasActivas]); } }
/** * Creates a new Categoria model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Categoria(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Categoria::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]); if (strtolower($this->esActivo) == strtolower(Yii::t('core', 'Yes'))) { $query->andFilterWhere(['esActivo' => $this->esActivo == 0]); } else { if (strtolower($this->esActivo) == strtolower(Yii::t('core', 'No'))) { $query->andFilterWhere(['esActivo' => $this->esActivo == 1]); } } $query->andFilterWhere(['like', 'nombre', $this->nombre])->andFilterWhere(['like', 'descripcion', $this->descripcion]); return $dataProvider; }
<?php $lista = ArrayHelper::map(\backend\models\Tipocuenta::find()->asArray()->all(), 'tipocuentaid', 'tipocuenta'); echo $form->field($model, 'tipocuenta_id')->dropDownList($lista)->label('Tipo de Cuenta'); ?> </div> <div class="col-xs-4"> <?php $lista = ArrayHelper::map(\backend\models\Sector::find()->asArray()->all(), 'sectorid', 'sector'); echo $form->field($model, 'sector_id')->dropDownList($lista); ?> </div> <div class="col-xs-4"> <?php $lista = ArrayHelper::map(\backend\models\Categoria::find()->asArray()->all(), 'categoriaid', 'categoria'); echo $form->field($model, 'categoria_id')->dropDownList($lista); ?> </div> </div> <div class="row"> <div class="col-xs-4"> <?php echo $form->field($model, 'freunion')->widget(\kartik\datecontrol\DateControl::classname()); ?> </div> <div class="col-xs-4"> <?php
/** * @return \yii\db\ActiveQuery */ public function getCategoria() { return $this->hasOne(Categoria::className(), ['categoriaid' => 'categoria_id']); }
/** * @return \yii\db\ActiveQuery */ public function getIdCategoria() { return $this->hasOne(Categoria::className(), ['id' => 'id_categoria']); }
$searchModel->cuenta_id = $modelo->cuentasid; //print_r(Yii::$app->request->queryParams); $dataProvider = $searchModel->searchCuentas(Yii::$app->request->queryParams); return Yii::$app->controller->renderPartial('_contactos-details', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]); }], ['class' => 'kartik\\grid\\EditableColumn', 'attribute' => 'user_id', 'width' => '140px', 'value' => function ($model, $key, $index, $widget) { return $model->user->username; }, 'filterType' => GridView::FILTER_SELECT2, 'filter' => \yii\helpers\ArrayHelper::map(\common\models\User::find()->asArray()->orderBy('username')->all(), 'id', 'username'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => 'Gerente'], 'editableOptions' => function ($model, $key, $index, $widget) { return ['formOptions' => ['action' => Url::to(['cuentas/change', 'id' => $model->cuentasid])], 'header' => 'Gerente de la Cuenta', 'size' => 'md', 'inputType' => \kartik\editable\Editable::INPUT_SELECT2, 'options' => ['data' => \yii\helpers\ArrayHelper::map(\common\models\User::find()->all(), 'id', 'username')]]; }], ['class' => 'kartik\\grid\\EditableColumn', 'attribute' => 'estado_id', 'label' => 'Estatus', 'width' => '100px', 'value' => function ($model, $key, $index, $widget) { return $model->estado->estado; }, 'filterType' => GridView::FILTER_SELECT2, 'filter' => \yii\helpers\ArrayHelper::map(\backend\models\Estado::find()->asArray()->orderBy('estado')->all(), 'estadoid', 'estado'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => 'Estatus'], 'editableOptions' => function ($model, $key, $index, $widget) { return ['formOptions' => ['action' => Url::to(['cuentas/change', 'id' => $model->cuentasid])], 'header' => 'Status', 'size' => 'md', 'inputType' => \kartik\editable\Editable::INPUT_SELECT2, 'options' => ['data' => \yii\helpers\ArrayHelper::map(\backend\models\Estado::find()->all(), 'estadoid', 'estado')]]; }], ['class' => 'kartik\\grid\\EditableColumn', 'attribute' => 'categoria_id', 'width' => '100px', 'value' => function ($model, $key, $index, $widget) { return $model->categoria->categoria; }, 'filterType' => GridView::FILTER_SELECT2, 'filter' => \yii\helpers\ArrayHelper::map(\backend\models\Categoria::find()->asArray()->orderBy('categoria')->all(), 'categoriaid', 'categoria'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => 'Categoria'], 'editableOptions' => function ($model, $key, $index, $widget) { return ['formOptions' => ['action' => Url::to(['cuentas/change', 'id' => $model->cuentasid])], 'header' => 'Categoría', 'size' => 'md', 'inputType' => \kartik\editable\Editable::INPUT_SELECT2, 'options' => ['data' => \yii\helpers\ArrayHelper::map(\backend\models\Categoria::find()->all(), 'categoriaid', 'categoria')]]; }], ['class' => 'kartik\\grid\\EditableColumn', 'attribute' => 'cuenta', 'width' => '140px', 'group' => true, 'editableOptions' => function ($model, $key, $index, $widget) { return ['formOptions' => ['action' => Url::to(['cuentas/change', 'id' => $model->cuentasid])], 'header' => 'Nombre de la Cuenta', 'size' => 'md']; }], ['class' => 'kartik\\grid\\EditableColumn', 'attribute' => 'subcuenta', 'width' => '100px', 'editableOptions' => function ($model, $key, $index, $widget) { return ['formOptions' => ['action' => Url::to(['cuentas/change', 'id' => $model->cuentasid])], 'header' => 'Nombre de la SubCuenta', 'size' => 'md']; }], ['class' => 'kartik\\grid\\EditableColumn', 'attribute' => 'sector_id', 'width' => '100px', 'value' => function ($model, $key, $index, $widget) { return $model->sector->sector; }, 'filterType' => GridView::FILTER_SELECT2, 'filter' => \yii\helpers\ArrayHelper::map(\backend\models\Sector::find()->asArray()->orderBy('sector')->all(), 'sectorid', 'sector'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => 'Sector'], 'editableOptions' => function ($model, $key, $index, $widget) { return ['formOptions' => ['action' => Url::to(['cuentas/change', 'id' => $model->cuentasid])], 'header' => 'Sector', 'size' => 'md', 'inputType' => \kartik\editable\Editable::INPUT_SELECT2, 'options' => ['data' => \yii\helpers\ArrayHelper::map(\backend\models\Sector::find()->all(), 'sectorid', 'sector')]]; }], ['class' => 'kartik\\grid\\EditableColumn', 'attribute' => 'i2010', 'width' => '80px', 'format' => ['currency'], 'editableOptions' => function ($model, $key, $index, $widget) { return ['inputType' => \kartik\editable\Editable::INPUT_MONEY, 'formOptions' => ['action' => Url::to(['cuentas/change', 'id' => $model->cuentasid])], 'header' => 'Monto de Inversión', 'size' => 'md']; }, 'pageSummary' => true], ['class' => 'kartik\\grid\\EditableColumn', 'attribute' => 'i2011', 'format' => ['currency'], 'width' => '80px', 'editableOptions' => function ($model, $key, $index, $widget) { return ['inputType' => \kartik\editable\Editable::INPUT_MONEY, 'formOptions' => ['action' => Url::to(['cuentas/change', 'id' => $model->cuentasid])], 'header' => 'Monto de Inversión', 'size' => 'md']; }, 'pageSummary' => true], ['class' => 'kartik\\grid\\EditableColumn', 'attribute' => 'i2012', 'format' => ['currency'], 'width' => '80px', 'editableOptions' => function ($model, $key, $index, $widget) { return ['inputType' => \kartik\editable\Editable::INPUT_MONEY, 'formOptions' => ['action' => Url::to(['cuentas/change', 'id' => $model->cuentasid])], 'header' => 'Monto de Inversión', 'size' => 'md']; }, 'pageSummary' => true], ['class' => 'kartik\\grid\\EditableColumn', 'attribute' => 'i2013', 'format' => ['currency'], 'width' => '80px', 'editableOptions' => function ($model, $key, $index, $widget) {