/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Comequipmenttype::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;
 }
Exemple #2
0
 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] : [];
 }
Exemple #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getEquipment()
 {
     return $this->hasOne(Comequipmenttype::className(), ['id' => 'equipment_id']);
 }
 /**
  * Finds the Comequipmenttype model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Comequipmenttype the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Comequipmenttype::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemple #5
0
<div class="comstocklist-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'active')->inline(true)->radiolist(['Y' => 'ใช้งาน', 'N' => 'ไม่มีการใช้งาน']);
?>

    <?php 
echo $form->field($model, 'category')->widget(Select2::classname(), ['data' => ArrayHelper::map(Comequipmenttype::find()->all(), 'id', 'name'), 'options' => ['placeholder' => 'เลือกอุปกรณ์...'], 'pluginOptions' => ['allowClear' => true]]);
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'บันทึกข้อมูล' : 'แก้ไขข้อมูล', ['class' => $model->isNewRecord ? 'btn btn-success btn-block btn-sm' : 'btn btn-primary btn-block btn-sm']);
?>
    </div>

    <?php 
ActiveForm::end();
?>

</div>