Example #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Dep::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', 'dep', $this->dep]);
     return $dataProvider;
 }
Example #2
0
    <?php 
echo $form->field($model, 'lname')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'addr')->textarea(['rows' => 6]);
?>
 

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

    <?php 
echo $form->field($model, 'dep_id')->dropDownList(ArrayHelper::map(Dep::find()->all(), 'id', 'dep'));
?>

    <?php 
echo $form->field($model, 'person_img')->fileInput();
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'เพิ่ม' : 'แก้ไข', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>
Example #3
0
?>
<div class="box box-success box-solid">
    <div class="box-header">
        <h3 class="box-title"><i class="fa fa-user"></i><?php 
echo Html::encode($this->title);
?>
</h3>
    </div>

    <div class="box-body">
        <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

        <p>
            <?php 
echo Html::a(' เพิ่มบุคลากร', ['create'], ['class' => 'btn btn-success']);
?>
        </p>

        <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'photo', 'format' => 'html', 'value' => function ($model) {
    return Html::img('uploads/person/' . $model->photo, ['class' => 'thumbnail', 'width' => 100]);
}], 'user.username', 'user.email', 'fname', 'lname', 'tel', ['attribute' => 'dep_id', 'value' => function ($model) {
    return $model->dep->dep;
}, 'filter' => Html::activeDropDownList($searchModel, 'dep_id', ArrayHelper::map(Dep::find()->all(), 'id', 'dep'), ['class' => 'form-control'])], ['class' => 'yii\\grid\\ActionColumn']]]);
?>

    </div>
</div>
Example #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getDep()
 {
     return $this->hasOne(Dep::className(), ['id' => 'dep_id']);
 }
Example #5
0
 /**
  * Finds the Dep model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Dep the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Dep::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }