/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Tooltypes::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]); $query->andFilterWhere(['like', 'type_name', $this->type_name]); return $dataProvider; }
<div class="tools-index4"> <div class="panel panel-info"> <div class="panel-heading"><h3><i class="glyphicon glyphicon-list-alt"></i> <?php echo Html::encode($this->title); ?> </h3></div> <div class="panel-body"> <p> <?php echo Html::a('<i class="glyphicon glyphicon-plus"></i> เพิ่มข้อมูล', ['create'], ['class' => 'btn btn-success']); ?> </p> <div class="pull-right"> <?php $data = ArrayHelper::map(\app\models\Tooltypes::find()->all(), 'type_name', 'type_name'); ?> <?php echo Html::dropDownList('tooltypes', null, $data, ['prompt' => '- เลือกประเภท -', 'onchange' => ' $.pjax.reload({ url: "' . Url::to(['index4']) . '&ToolsSearch[tooltype_id]="+$(this).val(), container: "#pjax-gridview", timeout: 1000, }); ', 'class' => 'form-control']); ?> </div><br> <?php Pjax::begin(['id' => 'pjax-gridview']);
/** * Finds the Tooltypes model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Tooltypes the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Tooltypes::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function getTooltypetool() { // ความสัมพันธ์จาก tools ไปหา tooltypes return $this->hasOne(Tooltypes::className(), ['id' => 'tooltype_id']); }
</div> <div class="col-xs-3 col-sm-3 col-md-3"> <?php echo $form->field($model, 'fnumber')->textInput(['readonly' => true, 'maxlength' => true]); ?> </div> <div class="col-xs-3 col-sm-3 col-md-3"> <?php echo $form->field($model, 'lnumber')->widget(\yii\widgets\MaskedInput::classname(), ['mask' => '9999']); ?> </div> </div> <div class="row"> <div class="col-xs-6 col-sm-6 col-md-6"> <?php echo $form->field($model, 'tooltype_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(Tooltypes::find()->all(), 'id', 'type_name'), 'language' => 'th', 'options' => ['placeholder' => 'เลือกประเภท ...'], 'pluginOptions' => ['allowClear' => true]]); ?> </div> <div class="col-xs-2 col-sm-2 col-md-2"> <?php echo $form->field($model, 'buydate')->widget(DatePicker::className(), ['language' => 'th', 'dateFormat' => 'yyyy-MM-dd', 'clientOptions' => ['changeMonth' => true, 'changeYear' => true], 'options' => ['class' => 'form-control']]); ?> </div> <div class="col-xs-2 col-sm-2 col-md-2"> <?php echo $form->field($model, 'okdate')->widget(DatePicker::className(), ['language' => 'th', 'dateFormat' => 'yyyy-MM-dd', 'clientOptions' => ['changeMonth' => true, 'changeYear' => true], 'options' => ['class' => 'form-control']]); ?> </div> <div class="col-xs-2 col-sm-2 col-md-2">