Esempio n. 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Offices::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, 'department_id' => $this->department_id]);
     $query->andFilterWhere(['like', 'name_th', $this->name_th])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'position', $this->position])->andFilterWhere(['like', 'status', $this->status])->andFilterWhere(['like', 'tel', $this->tel])->andFilterWhere(['like', 'fax', $this->fax])->andFilterWhere(['like', 'logo', $this->logo]);
     return $dataProvider;
 }
 /**
  * Finds the Offices model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Offices the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Offices::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Esempio n. 3
0
/* @var $model app\models\Groups */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="groups-form">

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

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

    <?php 
echo $form->field($model, 'office_id')->dropDownList(ArrayHelper::map(Offices::find()->where('status="1"')->all(), 'id', 'name_th'), ['prompt' => '--เลือกสังกัด--']);
?>

    <?php 
echo $form->field($model, 'status')->dropDownList(['0' => 'ไม่ใช้งาน', '1' => 'ใช้งาน'], ['prompt' => '--เลือกสถานะ--']);
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

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