示例#1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Department::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', 'department', $this->department]);
     return $dataProvider;
 }
示例#2
0
use backend\modules\setting\models\Department;
/* @var $this yii\web\View */
/* @var $searchModel backend\modules\personal\models\PersonalSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'บุคลากร';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="personal-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?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'], 'user.username', ['format' => 'html', 'attribute' => 'department_id', 'value' => function ($model) {
    return $model->department->department;
}, 'filter' => Html::activeDropDownList($searchModel, 'department_id', ArrayHelper::map(Department::find()->all(), 'id', 'department'), ['class' => 'form-control', 'prompt' => 'เลือกสังกัด'])], 'firstname', 'lastname', ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>
示例#3
0
?>
    
    <?php 
echo $form->field($user, 'username');
?>
    
    <?php 
echo $form->field($user, 'password_hash');
?>
    
    <?php 
echo $form->field($user, 'email');
?>

    <?php 
echo $form->field($model, 'department_id')->dropDownList(ArrayHelper::map(Department::find()->all(), 'id', 'department'));
?>

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

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

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

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