/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Comwarranty::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'active', $this->active]); return $dataProvider; }
public static function itemsAlias($key) { $items = ['eqmType' => ArrayHelper::map(Comequipmenttype::find()->all(), 'id', 'name'), 'comBrand' => ArrayHelper::map(Combrand::find()->all(), 'id', 'name'), 'warranty' => ArrayHelper::map(Comwarranty::find()->all(), 'id', 'name'), 'dealer' => ArrayHelper::map(Comdealer::find()->all(), 'id', 'dealerName'), 'location' => ArrayHelper::map(Section::find()->all(), 'id', 'name'), 'status' => [1 => 'กำลังใช้งาน', 2 => 'พร้อมใช้งาน', 3 => 'อยู่ระหว่างซ่อม', 4 => 'ส่งซ่อม', 5 => 'ชำรุด/ซ่อมไม่ได้', 6 => 'จำหน่ายออก']]; return ArrayHelper::getValue($items, $key, []); //return array_key_exists($key, $items) ? $items[$key] : []; }
echo $form->field($model, 'price', ['inputOptions' => ['class' => 'form-control', 'placeholder' => 'ราคา', 'autocomplete' => 'off']])->textInput(['maxlength' => 20]); ?> </div> <div class="col-md-4"> <?php echo $form->field($model, 'amount', ['inputOptions' => ['class' => 'form-control', 'placeholder' => 'จำนวนที่รับเข้าระบบ', 'autocomplete' => 'off']])->textInput(['maxlength' => 10]); ?> </div> <div class="col-md-4"> <?php echo $form->field($model, 'serial', ['inputOptions' => ['class' => 'form-control', 'placeholder' => 'SN:0123456789', 'autocomplete' => 'off']])->textInput(['maxlength' => 45]); ?> </div> <div class="col-md-4"> <?php echo $form->field($model, 'warranty')->widget(Select2::classname(), ['data' => ArrayHelper::map(Comwarranty::find()->all(), 'id', 'name'), 'options' => ['placeholder' => 'การรับประกัน...'], 'pluginOptions' => ['allowClear' => true]]); ?> </div> <div class="col-md-4"> <?php echo $form->field($model, 'addToSystem')->widget(DatePicker::classname(), ['options' => ['placeholder' => 'เลือกวันที่ ...'], 'language' => 'th', 'pluginOptions' => ['autoclose' => true, 'format' => 'yyyy-mm-dd', 'todayHighlight' => true]]); ?> </div> <div class="col-md-4"> <?php echo $form->field($model, 'dealer')->widget(Select2::classname(), ['data' => ArrayHelper::map(Comdealer::find()->all(), 'id', 'dealerName'), 'options' => ['placeholder' => 'ร้านค้า/ผู้จำหน่าย...'], 'pluginOptions' => ['allowClear' => true]]); ?> </div> <div class="col-md-3"> <?php echo $form->field($model, 'location')->widget(Select2::classname(), ['data' => ArrayHelper::map(Section::find()->all(), 'id', 'name'), 'options' => ['placeholder' => 'หน่วยงาน/ฝ่าย/แผนก...'], 'pluginOptions' => ['allowClear' => true]]);
/** * @return \yii\db\ActiveQuery */ public function getWarranty_role() { return $this->hasOne(Comwarranty::className(), ['id' => 'warranty']); }
/** * Finds the Comwarranty model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Comwarranty the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Comwarranty::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }