title = 'Utilisateurs'; $this->params['breadcrumbs'][] = $this->title; ?>

title) ?> 'btn btn-primary']) ?> Liste des emails', ['mail'], ['class' => 'btn btn-default']) ?>

$dataProvider, 'filterModel' => true, 'columns' => [ [ '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' => 'created_at', 'label' => 'Date d\'inscription', 'value' => function($model) { if(isset($model['created_at'])) return date('m/d/Y à H:i', $model['created_at']); } ], [ 'attribute' => 'date_derniere_connexion', 'label' => 'Dernière connexion', 'value' => function($model) { if(isset($model['date_derniere_connexion'])) return date('m/d/Y à H:i', strtotime($model['date_derniere_connexion'])); else return '' ; } ], [ 'class' => 'yii\grid\ActionColumn', 'template' => '{commandes}', 'headerOptions' => ['class' => 'actions'], 'buttons' => [ 'commandes' => function ($url, $model) { $url = Yii::$app->urlManager->createUrl(['user/commandes','id' => $model['id']]) ; $count_commandes = Commande::find()->joinWith('production')->where(['id_user' => $model['id'], 'production.id_etablissement' => Yii::$app->user->identity->id_etablissement])->count() ; $html = '' ; if($count_commandes) { $s = '' ; if($count_commandes > 1) $s = 's' ; $html .= Html::a(' '.$count_commandes.' commande'.$s, $url, [ 'title' => Yii::t('app', 'Commandes'), 'class' => 'btn btn-default ' ]); ; } else { $html .= 'Aucune commande' ; } return $html ; }, ], ], [ 'attribute' => 'credit', 'format' => 'raw', 'value' => function($model) use($etablissement) { $html = '
'.Html::a( ' Crédit', Yii::$app->urlManager->createUrl(['user/credit','id' => $model['id']]), [ 'title' => 'Crédit', 'class' => 'btn btn-default' ] ).'
' ; return $html ; } ], [ 'class' => 'yii\grid\ActionColumn', 'template' => '{update}', 'headerOptions' => ['class' => 'actions'], 'buttons' => [ 'update' => function ($url, $model) { $url = Yii::$app->urlManager->createUrl(['user/update','id' => $model['id']]) ; $user = User::find()->with('userEtablissement')->where(['id' => $model['id']])->one() ; if(count($user->userEtablissement) <= 1) { return Html::a(' Modifier', $url, [ 'title' => Yii::t('app', 'Modifier'), 'class' => 'btn btn-default' ]); } else { return ' Non modifiable' ; } }, ], ], ], ]); ?>