/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($uf, $params) { $query = UfTitularidad::find()->where(['id_uf' => $uf]); $pageSize = isset($_GET['per-page']) ? $_GET['per-page'] : \Yii::$app->params['uftitularidad.defaultPageSize']; $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => $pageSize], 'sort' => ['defaultOrder' => ['id' => SORT_DESC], 'enableMultiSort' => true]]); // Agregado a mano, para que incluya el ordenamiento por tipo de documento $dataProvider->sort->attributes['tipoMovim'] = ['asc' => ['movim_uf.desc_movim_uf' => SORT_ASC], 'desc' => ['movim_uf.desc_movim_uf' => SORT_DESC]]; $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; } // grid filtering conditions $query->andFilterWhere(['id' => $this->id, 'id_uf' => $this->id_uf, 'tipo_movim' => $this->tipoMovim, 'fec_desde' => $this->fec_desde, 'fec_hasta' => $this->fec_hasta, 'created_by' => $this->created_by, 'created_at' => $this->created_at, 'updated_by' => $this->updated_by, 'updated_at' => $this->updated_at, 'estado' => $this->estado, 'ultima' => $this->ultima]); $query->andFilterWhere(['like', 'exp_telefono', $this->exp_telefono])->andFilterWhere(['like', 'exp_direccion', $this->exp_direccion])->andFilterWhere(['like', 'exp_localidad', $this->exp_localidad])->andFilterWhere(['like', 'exp_email', $this->exp_email])->andFilterWhere(['like', 'motivo_baja', $this->motivo_baja]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getUfTitularidad() { return $this->hasOne(UfTitularidad::className(), ['id' => 'uf_titularidad_id']); }
/** * Finds the UfTitularidad model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return UfTitularidad the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = UfTitularidad::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
.table-condensed > thead > tr > td, .table-condensed > tbody > tr > td, .table-condensed > tfoot > tr > td { padding: 1px; } '); ?> <div class="uf-titularidad-form"> <?php $UfModel = Uf::findOne($model->id_uf); if (!empty($UfModel->ultUfTitularidad->id)) { $puedeCambiarTipoMovim = true; $query = UfTitularidadPersonas::find()->joinWith('persona')->where(['uf_titularidad_id' => $UfModel->ultUfTitularidad->id]); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['tipo' => SORT_DESC], 'enableMultiSort' => true]]); $xDefecto = UfTitularidad::findOne($UfModel->ultUfTitularidad->id); $model->exp_telefono = $xDefecto->exp_telefono; $model->exp_direccion = $xDefecto->exp_direccion; $model->exp_localidad = $xDefecto->exp_localidad; $model->exp_email = $xDefecto->exp_email; echo GridView::widget(['dataProvider' => $dataProvider, 'condensed' => true, 'layout' => '{items}', 'panel' => ['type' => GridView::TYPE_INFO, 'heading' => 'Titularidad actual sobre U.F.' . $model->id_uf, 'footer' => false, 'before' => false, 'after' => false], 'panelHeadingTemplate' => '{heading}', 'resizableColumns' => false, 'columns' => [['attribute' => 'tipo', 'value' => function ($model) { return UfTitularidadPersonas::getTipos($model->tipo); }], 'id_persona', 'persona.apellido', 'persona.nombre', 'persona.nombre2', 'persona.tipoDoc.desc_tipo_doc_abr', 'persona.nro_doc', 'observaciones']]); } else { $puedeCambiarTipoMovim = false; } ?> <?php $form = ActiveForm::begin(); ?>
public function getUltUfTitularidad() { return $this->hasOne(UfTitularidad::className(), ['id_uf' => 'id'])->where(['ultima' => 1]); }
/** * @return \yii\db\ActiveQuery */ public function getUfTitularidad() { return $this->hasMany(UfTitularidad::className(), ['tipo_movim' => 'id']); }