public function search($params) { $query = UomModel::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id_uom' => $this->id_uom, 'create_by' => $this->create_by, 'update_by' => $this->update_by]); $query->andFilterWhere(['like', 'cd_uom', $this->cd_uom])->andFilterWhere(['like', 'nm_uom', $this->nm_uom])->andFilterWhere(['like', 'create_at', $this->create_at])->andFilterWhere(['like', 'update_at', $this->update_at]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getIdUom() { return $this->hasOne(Uom::className(), ['id_uom' => 'id_uom']); }
?> <div class=" product-uom-form col-lg-6" style="padding-left: 0px;"> <?php $form = ActiveForm::begin(); ?> <div class="panel panel-primary"> <div class="panel-heading">Product Uoms</div> <div class="panel-body"> <?php echo $form->field($model, 'nmProduct')->widget('yii\\jui\\AutoComplete', ['id' => 'product', 'options' => ['class' => 'form-control'], 'clientOptions' => ['source' => new JsExpression('yii.global.sourceProduct'), 'delay' => 100]]); ?> <?php echo $form->field($model, 'id_uom')->dropDownList(ArrayHelper::map(Uom::find()->all(), 'id_uom', 'nm_uom'), ['style' => 'width:200px;']); ?> <?php echo $form->field($model, 'isi')->textInput(); ?> </div> </div> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php
/** * Finds the Uom model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Uom the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Uom::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
<?php use yii\helpers\Html; use yii\grid\GridView; use biz\master\models\Uom; use yii\data\ActiveDataProvider; use yii\helpers\Url; /* @var $this yii\web\View */ /* @var $model biz\master\models\Product */ $uoms = \yii\helpers\ArrayHelper::map(Uom::find()->all(), 'id_uom', 'nm_uom'); echo GridView::widget(['dataProvider' => new ActiveDataProvider(['query' => $model->getProductUoms(), 'sort' => false]), 'tableOptions' => ['class' => 'table table-striped'], 'layout' => '{items}', 'showFooter' => true, 'columns' => [['class' => 'yii\\grid\\SerialColumn', 'footer' => Html::label('New', '#new-uom')], ['attribute' => 'idUom.nm_uom', 'footer' => Html::dropDownList('id_uom', '', $uoms, ['style' => 'width:200px;', 'id' => 'new-uom'])], 'idUom.cd_uom', ['attribute' => 'isi', 'footer' => Html::textInput('isi_uom', '', ['style' => 'width:50px;'])], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{delete}', 'urlCreator' => function ($action, $uom) use($model) { return Url::toRoute(['delete-uom', 'id_product' => $model->id_product, 'id_uom' => $uom->id_uom]); }]]]); ?> <?php $js = <<<JS yii.global.isChangeOrEnter(\$(document),'#input-form [name="id_uom"]',function () { \$('#input-form [name="isi_uom"]').focus().select(); }); yii.global.isChangeOrEnter(\$(document),'#input-form [name="isi_uom"]',function () { \$('#input-form [name="action"]').val('uom'); if (\$('#id-uom').val() != '') { \$('#input-form').submit(); } }); JS; $this->registerJs($js);