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

title) ?> 'btn btn-primary']) ?>

Liste des emails', ['mail', 'idPointSale' => $idPointSaleActive], ['class' => 'btn btn-default btn-liste-emails']) ?> $dataProvider, 'filterModel' => true, 'columns' => [ [ 'attribute' => 'lastname', 'filter' => Html::input( 'string', 'lastname', isset(Yii::$app->request->queryParams['lastname']) ? Html::encode(Yii::$app->request->queryParams['lastname']) : '', [ 'class' => 'form-control'] ) ], [ 'attribute' => 'name', 'filter' => Html::input( 'string', 'name', isset(Yii::$app->request->queryParams['name']) ? Html::encode(Yii::$app->request->queryParams['name']) : '', ['class' => 'form-control'] ) ], [ 'attribute' => 'phone', 'filter' => Html::input( 'string', 'phone', isset(Yii::$app->request->queryParams['phone']) ? Html::encode(Yii::$app->request->queryParams['phone']) : '', ['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_last_connection', 'label' => 'Dernière connexion', 'value' => function($model) { if(isset($model['date_last_connection'])) return date('d/m/Y à H:i', strtotime($model['date_last_connection'])); else return '' ; } ], [ 'class' => 'yii\grid\ActionColumn', 'template' => '{orders}', 'headerOptions' => ['class' => 'actions'], 'buttons' => [ 'orders' => function ($url, $model) { $url = Yii::$app->urlManager->createUrl(['user/orders','id' => $model['user_id']]) ; $countOrders = Order::searchCount([ 'id_user' => $model['user_id'] ], ['conditions' => 'date_delete IS NULL']) ; $html = '' ; if($countOrders) { $s = '' ; if($countOrders > 1) $s = 's' ; $html .= Html::a(' '.$countOrders.' 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($producer) { 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('userProducer')->where(['id' => $model['user_id']])->one() ; if(count($user->userProducer) <= 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['active']) { 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' ]); } } ], ], ], ]); ?>