/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Cuentas::find(); // En el caso de que sea Vendedor se muestran solo sus contactos if (\common\models\User::isUserVendedor(Yii::$app->user->identity->id)) { $query->where('user_id = ' . Yii::$app->user->identity->id); } $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['cuenta' => SORT_ASC, 'subcuenta' => SORT_ASC]]]); $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(['cuentasid' => $this->cuentasid, 'tipocuenta_id' => $this->tipocuenta_id, 'user_id' => $this->user_id, 'sector_id' => $this->sector_id, 'estado_id' => $this->estado_id, 'categoria_id' => $this->categoria_id, 'freunion' => $this->freunion, 'monto_propuesta' => $this->monto_propuesta, 'fcampana' => $this->fcampana]); $query->andFilterWhere(['like', 'cuenta', $this->cuenta])->andFilterWhere(['like', 'subcuenta', $this->subcuenta])->andFilterWhere(['like', 'productos', $this->productos])->andFilterWhere(['like', 'comentario', $this->comentario])->andFilterWhere(['like', 'siglas', $this->siglas])->andFilterWhere(['like', 'cab_sector', $this->cab_sector])->andFilterWhere(['like', 'docto_propuesta', $this->docto_propuesta]); return $dataProvider; }
} 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]; }], ['width' => '80px', 'attribute' => 'cuenta.i2010', 'value' => function ($model, $key, $index, $widget) { return $model->cuenta->i2010;
<div class="row"> <div class="col-xs-3"> <?php // Estado $lista = ArrayHelper::map(\backend\models\Estado::find()->asArray()->all(), 'estadoid', 'estado'); echo $form->field($model, 'estado_id')->dropDownList($lista)->label('Estatus'); ?> </div> </div> <div class="row"> <div class="col-xs-3"> <?php // Cuenta $data = \backend\models\Cuentas::find()->select(['cuenta'])->distinct()->asArray()->createCommand()->queryColumn(); //echo $form->field($model, 'cuenta')->widget(\yii\jui\AutoComplete::className(), ['clientOptions' => ['source' => $data],]); echo $form->field($model, 'cuenta')->widget(\yii\jui\AutoComplete::className(), ['options' => ['class' => 'form-control'], 'clientOptions' => ['source' => $data]])->label('Dependencia / Entidad'); ?> </div> </div> <div class="row"> <div class="col-xs-3"> <?php // Siglas echo $form->field($model, 'siglas')->textInput(['maxlength' => true])->textInput(); ?> </div> </div>
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']], ['width' => '120px', 'attribute' => 'cuenta.categoria_id', 'value' => function ($model, $key, $index, $widget) { return $model->cuenta->categoria->categoria; }], ['attribute' => 'cuenta_id', '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' => '120px', 'attribute' => 'cuenta.subcuenta', 'value' => function ($model, $key, $index, $widget) { return $model->cuenta->subcuenta; }, 'group' => true, 'subGroupOf' => 6], ['label' => 'Manager', 'value' => function ($model, $key, $index, $widget) { $valores = null; $managers = $model->cuentasManagers; if ($managers !== null) { if (!empty($managers)) { foreach ($managers as $manager) { if ($manager->cuenta->subcuenta !== null && trim($manager->cuenta->subcuenta) !== '') { $valores .= $manager->cuenta->subcuenta . ', '; } else { $valores .= $manager->cuenta->cuenta . ', '; } } } }
<div class="row"> <div class="col-xs-3"> <?php //Prellenando los datos de las cuentas; $cuentas = $model->cuentasManagers; $valores = array(); if ($cuentas !== null) { if (!empty($cuentas)) { foreach ($cuentas as $cuenta) { $valores[] = $cuenta->cuenta_id; } } } $model->cuentasmanager = $valores; $lista = ArrayHelper::map(\backend\models\Cuentas::find()->where(['user_id' => Yii::$app->user->identity->id])->orderBy('cuenta')->all(), 'cuentasid', 'cuentaLarga'); echo $form->field($model, 'cuentasmanager')->widget(Select2::classname(), ['data' => $lista, 'name' => 'invitado', 'options' => ['placeholder' => 'Selecciona ...', 'multiple' => true, 'options' => []], 'pluginOptions' => ['allowClear' => true, 'tags' => true, 'tokenSeparators' => [',', ' ']]]); ?> </div> </div> </div> <div class="row"> <div class="col-xs-3"> <?php echo $form->field($model, 'puesto')->textInput(); ?> </div> <div class="col-xs-3"> <?php
/* @var $this yii\web\View */ /* @var $model backend\models\Contactos */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="contactos-form"> <?php $form = ActiveForm::begin(); ?> <div class="row"> <div class="col-xs-4"> <?php echo $form->field($model, 'cuenta_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(\backend\models\Cuentas::find()->orderBy('cuenta')->all(), 'cuentasid', 'cuentalarga'), 'options' => ['placeholder' => 'Selecciona la cuenta'], 'pluginOptions' => ['allowClear' => true]]); ?> </div> <div class="col-xs-4"> <?php echo $form->field($model, 'sectorcontacto_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(\backend\models\Sector::find()->orderBy('sector')->all(), 'sectorid', 'sector'), 'options' => ['placeholder' => 'Selecciona el sector'], 'pluginOptions' => ['allowClear' => true]]); ?> </div> </div> <div class="row"> <div class="col-xs-3"> <?php