Pouvoir filtrer les utilisateurs par nom, prenom, telephone, email dans la section "Utilisateurs".prodstable
@@ -63,14 +63,27 @@ class UserController extends BackendController | |||
*/ | |||
public function actionIndex() | |||
{ | |||
$dataProvider = new ActiveDataProvider([ | |||
'query' => | |||
(new \yii\db\Query()) | |||
$params = Yii::$app->request->queryParams; | |||
$query = (new \yii\db\Query()) | |||
->select('*') | |||
->from('user, user_etablissement') | |||
->where('user.id = user_etablissement.id_user') | |||
->andWhere('user_etablissement.actif = 1') | |||
->andWhere('user_etablissement.id_etablissement = '.Yii::$app->user->identity->id_etablissement) | |||
->andWhere('user_etablissement.id_etablissement = '.Yii::$app->user->identity->id_etablissement) ; | |||
if(isset($params['nom'])) | |||
$query->andFilterWhere(['like', 'nom', $params['nom']]); | |||
if(isset($params['prenom'])) | |||
$query->andFilterWhere(['like', 'prenom', $params['prenom']]) ; | |||
if(isset($params['email'])) | |||
$query->andFilterWhere(['like', 'email', $params['email']]) ; | |||
if(isset($params['telephone'])) | |||
$query->andFilterWhere(['like', 'telephone', $params['telephone']]) ; | |||
$dataProvider = new ActiveDataProvider([ | |||
'query' => $query | |||
]); | |||
$etablissement = Etablissement::find() |
@@ -20,11 +20,44 @@ $this->params['breadcrumbs'][] = $this->title; | |||
<?= GridView::widget([ | |||
'dataProvider' => $dataProvider, | |||
'filterModel' => true, | |||
'columns' => [ | |||
'nom', | |||
'prenom', | |||
'telephone', | |||
'email', | |||
[ | |||
'attribute' => 'nom', | |||
'filter' => Html::input( | |||
'string', | |||
'nom', | |||
isset(Yii::$app->request->queryParams['nom']) ? Html::encode(Yii::$app->request->queryParams['nom']) : '', | |||
[ 'class' => 'form-control'] | |||
) | |||
], | |||
[ | |||
'attribute' => 'prenom', | |||
'filter' => Html::input( | |||
'string', | |||
'prenom', | |||
isset(Yii::$app->request->queryParams['prenom']) ? Html::encode(Yii::$app->request->queryParams['prenom']) : '', | |||
['class' => 'form-control'] | |||
) | |||
], | |||
[ | |||
'attribute' => 'telephone', | |||
'filter' => Html::input( | |||
'string', | |||
'telephone', | |||
isset(Yii::$app->request->queryParams['telephone']) ? Html::encode(Yii::$app->request->queryParams['telephone']) : '', | |||
['class' => 'form-control'] | |||
) | |||
], | |||
[ | |||
'attribute' => 'email', | |||
'filter' => Html::input( | |||
'string', | |||
'email', | |||
isset(Yii::$app->request->queryParams['email']) ? Html::encode(Yii::$app->request->queryParams['email']) : '', | |||
['class' => 'form-control'] | |||
) | |||
], | |||
[ | |||
'attribute' => 'credit', | |||
'format' => 'raw', |