/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = MonitoringKacamata::find(); // add conditions that should always apply here $query->joinWith(['nikkes0']); $dataProvider = new ActiveDataProvider(['query' => $query]); $dataProvider->sort->attributes['nikkes0'] = ['asc' => ['peserta.nama' => SORT_ASC], 'desc' => ['peserta.nama' => 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; } $query->andFilterWhere(['id' => $this->id, 'hak_kacamata_id' => $this->hak_kacamata_id, 'tgl_ambil' => $this->tgl_ambil, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'created_by' => $this->created_by]); $query->andFilterWhere(['like', 'monitoring_kacamata.nikkes', $this->nikkes])->andFilterWhere(['like', 'peserta.nama', $this->nikkes0]); return $dataProvider; }
use kartik\helpers\Html; use kartik\grid\GridView; use kartik\icons\Icon; use yii\helpers\Url; use frontend\models\MonitoringKacamata; use yii\helpers\ArrayHelper; /* @var $this yii\web\View */ /* @var $searchModel frontend\models\search\MonitoringKacamataSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = 'Monitoring Kacamata'; $this->params['breadcrumbs'][] = $this->title; Icon::Map($this, Icon::FA); ?> <div class="monitoring-kacamata-index"> <h1><?php echo Html::encode($this->title); ?> </h1> <?php //echo $this->render('_search', ['model' => $searchModel]); $gridColumns = [['class' => 'kartik\\grid\\SerialColumn', 'contentOptions' => ['class' => 'kartik-sheet-style'], 'header' => '#', 'width' => '36px', 'headerOptions' => ['class' => 'kartik-sheet-style']], ['attribute' => 'nikkes', 'width' => '15%'], ['attribute' => 'nikkes0', 'value' => 'nikkes0.nama'], ['attribute' => 'hak_kacamata_id', 'value' => function ($model, $key, $index, $widget) { return '<code>' . $model->hakKacamata->hak_kacamata . '</code>'; }, 'filterType' => GridView::FILTER_SELECT2, 'filter' => MonitoringKacamata::getHakKacamataList(), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => 'Hak Kacamata'], 'vAlign' => 'middle', 'format' => 'raw', 'width' => '10%'], ['attribute' => 'tgl_ambil', 'filterType' => GridView::FILTER_DATE, 'filterWidgetOptions' => ['options' => ['placeholder' => 'Enter date ...'], 'type' => \kartik\widgets\DatePicker::TYPE_COMPONENT_APPEND, 'removeButton' => false, 'pluginOptions' => ['autoclose' => true, 'format' => 'yyyy-mm-dd']], 'width' => '20%', 'format' => 'date'], ['class' => 'kartik\\grid\\ActionColumn', 'hidden' => true]]; ?> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => $gridColumns, 'headerRowOptions' => ['class' => 'active'], 'filterRowOptions' => ['class' => 'active'], 'pjax' => true, 'panel' => ['heading' => '<h3 class="panel-title"><i class="glyphicon glyphicon-th-large"></i> Monitoring Kacamata</h3>', 'type' => GridView::TYPE_PRIMARY], 'toolbar' => [['content' => Html::button(Icon::show('plus'), ['type' => 'button', 'title' => 'Add Monitoring Kacamata', 'class' => 'btn btn-success', 'onClick' => 'location.href=window.location.href + "/create"']) . '' . Html::a(Icon::show('repeat'), ['/monitoringkacamata'], ['data-pjax' => 0, 'class' => 'btn btn-default', 'title' => 'Reset'])]], 'hover' => true, 'condensed' => true, 'striped' => false, 'responsive' => true]); ?> </div>
/** * Finds the MonitoringKacamata model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return MonitoringKacamata the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = MonitoringKacamata::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getMonitoringKacamatas() { return $this->hasMany(MonitoringKacamata::className(), ['hak_kacamata_id' => 'id']); }