= Html::encode($this->title) ?>
= Html::a('Ajouter', ['create'], ['class' => 'btn btn-primary']) ?>
= Html::a('
Liste des emails', ['mail', 'id_point_vente' => $id_point_vente_active], ['class' => 'btn btn-default btn-liste-emails']) ?>
= GridView::widget([
'dataProvider' => $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('d/m/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['user_id']]) ;
$count_commandes = Commande::find()
->joinWith('production')
->where([
'id_user' => $model['user_id'],
'production.id_etablissement' => Yii::$app->user->identity->id_etablissement])
->andWhere('date_delete IS NULL')
->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) {
if(!isset($model['credit'])) $model['credit'] = 0 ;
$user = User::findOne($model['user_id']) ;
$html = '
'.Html::a(
' Crédit',
Yii::$app->urlManager->createUrl(['user/credit','id' => $model['user_id']]),
[
'title' => 'Crédit',
'class' => 'btn btn-default'
]
).'
' ;
return $html ;
}
],
[
'class' => 'yii\grid\ActionColumn',
'template' => '{update} {delete}',
'headerOptions' => ['class' => 'actions'],
'buttons' => [
'update' => function ($url, $model) {
$url = Yii::$app->urlManager->createUrl(['user/update','id' => $model['user_id']]) ;
$user = User::find()->with('userEtablissement')->where(['id' => $model['user_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' ;
}
},
'delete' => function($url, $model) {
if($model['actif']) {
return Html::a('
Supprimer', Yii::$app->urlManager->createUrl(array_merge(['user/delete','id' => $model['user_id']], Yii::$app->getRequest()->getQueryParams())), [
'title' => Yii::t('app', 'Supprimer'), 'class' => 'btn btn-default'
]);
}
}
],
],
],
]); ?>