/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Estado::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, 'estado_valor' => $this->estado_valor]); $query->andFilterWhere(['like', 'estado_nombre', $this->estado_nombre]); return $dataProvider; }
<div class="row"> <div class="col-xs-2"> <?php $lista = ArrayHelper::map(User::find()->asArray()->all(), 'id', 'username'); if (!$model->user_id) { $model->user_id = Yii::$app->user->identity->id; } // Para preseleccionar el dato echo $form->field($model, 'user_id')->dropDownList($lista); ?> </div> <div class="col-xs-2"> <?php $lista = ArrayHelper::map(\backend\models\Estado::find()->asArray()->all(), 'estadoid', 'estado'); echo $form->field($model, 'estado_id')->dropDownList($lista)->label('Status'); ?> </div> <div class="col-xs-4"> <?php echo $form->field($model, 'cuenta')->textInput(['maxlength' => true])->label('Dependencia'); ?> </div> <div class="col-xs-4"> <?php echo $form->field($model, 'siglas')->textInput(['maxlength' => true]); ?> </div>
/** * Devuelve un arreglo con todos los posibles Estados ex. 1 Activo * @return array */ public static function getEstadoLista() { $dropciones = Estado::find()->asArray()->all(); return ArrayHelper::map($dropciones, 'id', 'estado_nombre'); }
<?php $gridColumns = [['class' => 'kartik\\grid\\SerialColumn', 'width' => '25px'], ['class' => 'kartik\\grid\\ActionColumn', 'template' => '{view} {update} {delete}', 'width' => '25px'], ['class' => 'kartik\\grid\\ExpandRowColumn', 'value' => function ($modelo, $key, $index, $column) { return GridView::ROW_COLLAPSED; }, 'expandOneOnly' => true, 'detail' => function ($modelo, $key, $index, $column) { $searchModel = new \backend\models\search\ContactosSearch(); $searchModel->cuenta_id = $modelo->cuentasid; $dataProvider = $searchModel->search(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' => 'Status'], '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' => 'cuenta', 'label' => 'Dependencia / Entidad', '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' => 'siglas', 'width' => '140px', 'group' => true, 'editableOptions' => function ($model, $key, $index, $widget) { return ['formOptions' => ['action' => Url::to(['cuentas/change', 'id' => $model->cuentasid])], 'header' => 'Siglas de la Cuenta', 'size' => 'md']; }], ['class' => 'kartik\\grid\\EditableColumn', 'label' => 'Cabeza de Sector', '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' => ['decimal'], 'editableOptions' => function ($model, $key, $index, $widget) { return ['inputType' => \kartik\editable\Editable::INPUT_TEXT, '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' => ['decimal'], 'width' => '80px', 'editableOptions' => function ($model, $key, $index, $widget) { return ['inputType' => \kartik\editable\Editable::INPUT_TEXT, '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' => ['decimal'], 'width' => '80px', 'editableOptions' => function ($model, $key, $index, $widget) { return ['inputType' => \kartik\editable\Editable::INPUT_TEXT, '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' => ['decimal'], 'width' => '80px', 'editableOptions' => function ($model, $key, $index, $widget) {
} }); } else { alert("No ha seleccionado nada para eliminar!"); return false; } });', \yii\web\View::POS_READY); ?> <?php $gridColumns = [['width' => '25px', 'class' => 'kartik\\grid\\SerialColumn'], ['class' => '\\kartik\\grid\\CheckboxColumn', 'rowSelectedClass' => GridView::TYPE_DANGER], ['class' => 'kartik\\grid\\ActionColumn', 'template' => '{update} {delete}', 'width' => '25px'], ['width' => '80px', 'attribute' => 'cuenta.user_id', 'value' => function ($model, $key, $index, $widget) { return $model->cuenta->user->username; }, 'filterType' => GridView::FILTER_SELECT2, 'filter' => \yii\helpers\ArrayHelper::map(\common\models\User::find()->asArray()->all(), 'id', 'nombre'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => 'Gerente']], ['width' => '100px', 'label' => 'Estatus', 'attribute' => 'cuenta.estado_id', 'value' => function ($model, $key, $index, $widget) { return $model->cuenta->estado->estado; }, 'filterType' => GridView::FILTER_SELECT2, 'filter' => \yii\helpers\ArrayHelper::map(\backend\models\Estado::find()->asArray()->all(), 'estadoid', 'estado'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => 'Estatus']], ['attribute' => 'cuenta_id', 'label' => 'Empresa', 'width' => '140px', 'value' => function ($model, $key, $index, $widget) { return $model->cuenta->cuenta; }, 'filterType' => GridView::FILTER_SELECT2, 'filter' => \yii\helpers\ArrayHelper::map(\backend\models\Cuentas::find()->asArray()->orderBy('cuenta')->groupBy('cuenta')->where('tipocuenta_id = ' . $tipo_empresa)->all(), 'cuentasid', 'cuenta'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => 'Cuenta'], 'group' => true], ['width' => '180px', 'class' => 'kartik\\grid\\EditableColumn', 'attribute' => 'nombre', 'pageSummary' => true, 'editableOptions' => function ($model, $key, $index, $widget) { return ['asPopover' => false, 'inputType' => \kartik\editable\Editable::INPUT_TEXT, 'formOptions' => ['action' => Url::to(['contactos/change', 'id' => $model->contactosid])], 'header' => 'Nombre del Contacto', 'size' => 'md']; }], ['width' => '180px', 'class' => 'kartik\\grid\\EditableColumn', 'attribute' => 'apellido', 'pageSummary' => true, 'editableOptions' => function ($model, $key, $index, $widget) { return ['asPopover' => false, 'inputType' => \kartik\editable\Editable::INPUT_TEXT, 'formOptions' => ['action' => Url::to(['contactos/change', 'id' => $model->contactosid])], 'header' => 'Apellido del Contacto', 'size' => 'md']; }], ['width' => '140px', 'class' => 'kartik\\grid\\EditableColumn', 'attribute' => 'puesto', 'label' => 'Cargo', 'editableOptions' => function ($model, $key, $index, $widget) { return ['asPopover' => false, 'inputType' => \kartik\editable\Editable::INPUT_TEXT, 'formOptions' => ['action' => Url::to(['contactos/change', 'id' => $model->contactosid])], 'header' => 'Nombre del Puesto', 'size' => 'md']; }], ['width' => '100px', 'label' => 'Teléfono', 'class' => 'kartik\\grid\\EditableColumn', 'attribute' => 'telefono', 'editableOptions' => function ($model, $key, $index, $widget) { return ['asPopover' => false, 'inputType' => \kartik\editable\Editable::INPUT_TEXT, 'formOptions' => ['action' => Url::to(['contactos/change', 'id' => $model->contactosid])], 'header' => 'Telefono', 'size' => 'md']; }], ['class' => 'kartik\\grid\\EditableColumn', 'attribute' => 'correo', 'label' => 'Dirección Electrónica', 'width' => '140px', 'editableOptions' => function ($model, $key, $index, $widget) { return ['asPopover' => false, 'inputType' => \kartik\editable\Editable::INPUT_TEXT, 'formOptions' => ['action' => Url::to(['contactos/change', 'id' => $model->contactosid])], 'header' => 'Correo', 'size' => 'md']; }], ['class' => 'kartik\\grid\\EditableColumn', 'attribute' => 'direccion', 'label' => 'Dirección Oficina', 'width' => '140px', 'editableOptions' => function ($model, $key, $index, $widget) { return ['asPopover' => false, 'inputType' => \kartik\editable\Editable::INPUT_TEXTAREA, 'formOptions' => ['action' => Url::to(['contactos/change', 'id' => $model->contactosid])], 'header' => 'Dirección', 'size' => 'md', 'inputType' => \kartik\editable\Editable::INPUT_TEXTAREA]; }], ['class' => 'kartik\\grid\\EditableColumn', 'attribute' => 'asistente', 'label' => 'Asistente', 'width' => '140px', 'editableOptions' => function ($model, $key, $index, $widget) { return ['asPopover' => false, 'inputType' => \kartik\editable\Editable::INPUT_TEXTAREA, 'formOptions' => ['action' => Url::to(['contactos/change', 'id' => $model->contactosid])], 'header' => 'Asistente', 'size' => 'md', 'inputType' => \kartik\editable\Editable::INPUT_TEXTAREA];
/** * @return \yii\db\ActiveQuery */ public function getEstado() { return $this->hasOne(Estado::className(), ['estadoid' => 'estado_id']); }
public static function getEstadoId($estado_nombre) { $estado = Estado::find('id')->where(['estado_nombre' => $estado_nombre])->one(); return isset($estado->id) ? $estado->id : false; }
/** * Finds the Estado model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Estado the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Estado::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }