/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Comentarios::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, 'model_id' => $this->model_id, 'created_by' => $this->created_by, 'created_at' => $this->created_at, 'updated_by' => $this->updated_by, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'comentario', $this->comentario])->andFilterWhere(['like', 'model', $this->model]); return $dataProvider; }
<h3><?php echo Html::encode($this->title); ?> </h3> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <?php $lbl2 = ''; $pdfHeader = ['L' => ['content' => \Yii::$app->params['lblName']], 'C' => ['content' => $this->title . $lbl2, 'font-style' => 'B'], 'R' => ['content' => '']]; $pdfFooter = ['L' => ['content' => \Yii::$app->params['lblName2']], 'C' => ['content' => 'página {PAGENO} de {nb}'], 'R' => ['content' => 'Fecha:{DATE d/m/Y}']]; $columns = ['id', 'desc_tipo_doc', 'desc_tipo_doc_abr', ['attribute' => 'persona_fisica', 'value' => function ($model) { return Tiposdoc::getSiNo($model->persona_fisica); }, 'filter' => Tiposdoc::getSiNo()], ['class' => 'kartik\\grid\\ActionColumn', 'header' => Html::a('<span class="glyphicon glyphicon-plus-sign"></span>', ['create'], ['class' => 'btn-sm btn-primary', 'title' => Yii::t('app', 'Nuevo')]), 'template' => '{view} {comentario}', 'buttons' => ['comentario' => function ($url, $model) { $c = Comentarios::getComentariosByModelId($model->className(), $model->id); $text = '<span class="glyphicon glyphicon-copyright-mark"'; if (!empty($c)) { $text .= ' style="color:#FF8000"></span>'; $titl = 'Ingresar nuevo/Ver comentarios'; } else { $text .= '></span>'; $titl = 'Ingresar nuevo comentario'; } return Html::a($text, $url, ['title' => $titl, 'onclick' => '$.ajax({ type :"POST", cache : false, url : $(this).attr("href"), success : function(response) { $("#divcomentarionuevo").html(response); $("#modalcomentarionuevo").modal("show");
/** * Finds the Comentarios model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Comentarios the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Comentarios::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
<?php echo $form->field($model, 'comentario')->textArea(['maxlength' => true]); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php ActiveForm::end(); ?> <?php $models = Comentarios::find()->where(['model' => $modelNameOrigen, 'model_id' => $modelIDOrigen])->orderBy(['created_at' => SORT_DESC])->all(); $primeraVez = true; foreach ($models as $m) { if ($primeraVez) { echo '<hr/>'; echo '<p>Cantidad de comentarios ' . kartik\helpers\Html::badge(count($models)) . '</p>'; $primeraVez = false; } echo DetailView::widget(['model' => $m, 'options' => ['class' => 'table table-striped table-bordered table-condensed detail-view'], 'attributes' => ['comentario', 'userCreatedBy.username', 'created_at:datetime']]); echo '<hr/>'; } ?> </div>
$searchModel->fechasta = \Yii::$app->session->get('accesosFecHastaF'); } else { $lbl = 'Filtrar por rango de fechas'; } echo Collapse::widget(['encodeLabels' => false, 'items' => [['label' => $lbl, 'content' => $this->render('_searchfec', ['model' => $searchModel])]]]); if (\Yii::$app->session->get('accesosFecDesdeF')) { $lbl2 = ' (' . Yii::$app->formatter->asDate(\Yii::$app->session->get('accesosFecDesdeF')) . '-' . Yii::$app->formatter->asDate(\Yii::$app->session->get('accesosFecHastaF')) . ')'; } else { $lbl2 = ''; } $pdfHeader = ['L' => ['content' => \Yii::$app->params['lblName']], 'C' => ['content' => $this->title . $lbl2, 'font-style' => 'B'], 'R' => ['content' => '']]; $pdfFooter = ['L' => ['content' => \Yii::$app->params['lblName2']], 'C' => ['content' => 'página {PAGENO} de {nb}'], 'R' => ['content' => 'Fecha:{DATE d/m/Y}']]; // las columnas se definen fuera del gridview para poder extraer las etiquetas para el // popover que define las columnas a exportar $columns = [['class' => 'kartik\\grid\\ActionColumn', 'header' => 'Acciones', 'headerOptions' => ['style' => 'text-align:center;width:70px'], 'options' => ['style' => 'width:70px'], 'template' => '{comentario} {mensajeP} {mensajeV}', 'buttons' => ['comentario' => function ($url, $model) { $c = Comentarios::getComentariosByModelId('frontend\\models\\Accesos', $model->id_acceso); $text = '<span class="glyphicon glyphicon-copyright-mark"'; if (!empty($c)) { $text .= ' style="color:#FF8000"></span>'; $titl = 'Ingresar nuevo/Ver comentarios'; } else { $text .= '></span>'; $titl = 'Ingresar nuevo comentario'; } return Html::a($text, $url, ['title' => $titl, 'onclick' => '$.ajax({ type :"POST", cache : false, url : $(this).attr("href"), success : function(response) { $("#divcomentarionuevo").html(response); $("#modalcomentarionuevo").modal("show");
<?php echo DetailView::widget(['model' => $model, 'options' => ['class' => 'table table-striped table-bordered table-condensed detail-view'], 'attributes' => ['id', 'ing_fecha:date', 'ing_hora:time', ['attribute' => 'id_persona', 'format' => 'raw', 'value' => Html::a($model->id_persona, Yii::$app->urlManager->createUrl(['personas/view', 'id' => $model->id_persona]), ['title' => 'Ver detalle de persona', 'target' => '_blank', 'data-pjax' => '0'])], 'persona.apellido', 'persona.nombre', 'persona.nombre2', 'persona.tipoDoc.desc_tipo_doc_abr', 'persona.nro_doc', ['attribute' => 'ing_id_vehiculo', 'format' => 'raw', 'value' => Html::a($model->ing_id_vehiculo, Yii::$app->urlManager->createUrl(['vehiculos/view', 'id' => $model->ing_id_vehiculo]), ['title' => 'Ver detalle del vehiculo', 'target' => '_blank', 'data-pjax' => '0'])], 'ingVehiculo.patente', 'ingVehiculo.marca', 'ingVehiculo.modelo', 'ingVehiculo.color', 'ing_id_porton', 'userIngreso.username', 'accesosConcepto.concepto', 'motivo', 'egr_fecha:date', 'egr_hora:time', ['attribute' => 'egr_id_vehiculo', 'format' => 'raw', 'value' => Html::a($model->egr_id_vehiculo, Yii::$app->urlManager->createUrl(['vehiculos/view', 'id' => $model->egr_id_vehiculo]), ['title' => 'Ver detalle del vehiculo', 'target' => '_blank', 'data-pjax' => '0'])], 'egrVehiculo.patente', 'egrVehiculo.marca', 'egrVehiculo.modelo', 'egrVehiculo.color', 'egr_id_porton', 'userEgreso.username', 'control', 'userCreatedBy.username', 'created_at:datetime', 'userUpdatedBy.username', 'updated_at:datetime', ['label' => 'Estado', 'value' => Accesos::getEstados($model->estado)], 'motivo_baja']]); ?> <?php $aut = AccesosAutorizantes::findAll(['id_acceso' => $model->id]); $primeraVez = true; foreach ($aut as $a) { if ($primeraVez) { //echo '<hr/>'; echo '<p>Cantidad de autorizantes/unidades ' . kartik\helpers\Html::badge(count($aut)) . '</p>'; $primeraVez = false; } echo DetailView::widget(['model' => $a, 'options' => ['class' => 'table table-striped table-bordered table-condensed detail-view'], 'attributes' => [['attribute' => 'id_persona', 'format' => 'raw', 'value' => Html::a($a->id_persona, Yii::$app->urlManager->createUrl(['personas/view', 'id' => $a->id_persona]), ['title' => 'Ver detalle de persona', 'target' => '_blank', 'data-pjax' => '0'])], 'persona.apellido', 'persona.nombre', 'persona.nombre2', 'id_uf']]); } ?> <?php $models = Comentarios::find()->where(['model' => 'frontend\\models\\Accesos', 'model_id' => $model->id])->orderBy(['created_at' => SORT_DESC])->all(); $primeraVez = true; foreach ($models as $m) { if ($primeraVez) { //echo '<hr/>'; echo '<p>Cantidad de comentarios ' . kartik\helpers\Html::badge(count($models)) . '</p>'; $primeraVez = false; } echo DetailView::widget(['model' => $m, 'options' => ['class' => 'table table-striped table-bordered table-condensed detail-view'], 'attributes' => ['comentario', 'userCreatedBy.username', 'created_at:datetime']]); echo '<hr/>'; } ?> </div>