/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = PosisiMotor::find(); $query->joinWith(['motor0', 'jenisMotor0']); // $query->where('status="belum terjual"'); $dataProvider = new ActiveDataProvider(['query' => $query]); $dataProvider->sort->attributes['no_totok'] = ['asc' => ['Motor.no_totok' => SORT_ASC], 'desc' => ['Motor.no_totok' => SORT_DESC]]; $dataProvider->sort->attributes['no_rangka'] = ['asc' => ['Motor.no_rangka' => SORT_ASC], 'desc' => ['Motor.no_rangka' => SORT_DESC]]; $dataProvider->sort->attributes['no_mesin'] = ['asc' => ['Motor.no_mesin' => SORT_ASC], 'desc' => ['Motor.no_mesin' => SORT_DESC]]; $dataProvider->sort->attributes['jenisMotor0.nama'] = ['asc' => ['motor.id_jenis' => SORT_ASC], 'desc' => ['motor.id_jenis' => 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_motor' => $this->id_motor, 'no_totok' => $this->no_totok, 'no_rangka' => $this->no_rangka, 'no_mesin' => $this->no_mesin, 'nama' => $this->nama]); $query->andFilterWhere(['like', 'posisi', $this->posisi])->andFilterWhere(['like', 'keterangan', $this->keterangan]); return $dataProvider; }
<li><a href="chart-pabrik">Pabrik</a></li>--> </ul> </div> </div> </td> </tr> </table><br/> <!--Html::a('Download Data Motor', ['export'], ['class' => 'btn btn-info'])--> <?php $form = \yii\bootstrap\ActiveForm::begin(); /* parameterized initialization */ $form = \yii\bootstrap\ActiveForm::begin(['id' => 'form_id', 'options' => ['class' => 'form_class', 'enctype' => 'multipart/form-data']]); //render form elements here \yii\bootstrap\ActiveForm::end(); ?> </div> <div class="table-responsive"> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'id', 'value' => 'id', 'filter' => false, 'contentOptions' => ['style' => 'width: 75px;']], ['attribute' => 'nama', 'value' => 'jenisMotor0.nama', 'filter' => Html::activeDropDownList($searchModel, 'nama', \yii\helpers\ArrayHelper::map(\app\models\JenisMotor::find()->select('nama')->distinct()->all(), 'nama', 'nama'), ['class' => 'form-control', 'prompt' => 'Semua'])], ['attribute' => 'warna', 'value' => 'warna', 'contentOptions' => ['style' => 'width: 125px;']], ['attribute' => 'no_totok', 'value' => 'no_totok', 'contentOptions' => ['style' => 'width: 75px;']], 'no_rangka', 'no_mesin', ['attribute' => 'posisi', 'value' => 'posisiMotor0.posisi', 'filter' => Html::activeDropDownList($searchModel, 'posisi', \yii\helpers\ArrayHelper::map(\app\models\PosisiMotor::find()->select('posisi')->distinct()->all(), 'posisi', 'posisi'), ['class' => 'form-control', 'prompt' => 'Semua'])], ['attribute' => 'status', 'format' => 'raw', 'filter' => Html::activeDropDownList($searchModel, 'status', \yii\helpers\ArrayHelper::map(\app\models\Motor::find()->select('status')->distinct()->all(), 'status', 'status'), ['class' => 'form-control', 'prompt' => 'Semua']), 'value' => function ($row) { $values = ['laku' => 'success', 'belum terjual' => 'info']; return Html::tag('span', $row->status, ['class' => 'label label-' . $values[$row->status] . ''], ['style' => 'text-size:14px']); }], ['class' => \yii\grid\ActionColumn::className(), 'template' => '{delete} {update}']]]); ?> </div> </div>