setTitle('Utilisateurs') ;
$this->addBreadcrumb($this->getTitle()) ;
$this->addButton(['label' => '+', 'url' => 'user/create', 'class' => 'btn btn-primary']) ;
?>
= Html::a('
Liste des emails', ['mail', 'idPointSale' => $idPointSaleActive], ['class' => 'btn btn-default btn-liste-emails']) ?>
= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
[
'attribute' => 'username',
'label' => 'Nom',
'value' => function($model) {
return $model['lastname'].' '.$model['name'] ;
}
],
[
'attribute' => 'contacts',
'header' => 'Contacts',
'format' => 'raw',
'value' => function($model) {
$html = '' ;
if(strlen($model['phone'])) {
$html .= $model['phone'] ;
}
if(strlen($model['phone']) && strlen($model['email'])) {
$html .= '
' ;
}
if(strlen($model['email'])) {
$html .= $model['email'] ;
}
return $html ;
}
],
[
'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']);
}
],
[
'class' => 'yii\grid\ActionColumn',
'header' => 'Commandes',
'template' => '{orders}',
'headerOptions' => ['class' => 'actions'],
'buttons' => [
'orders' => function ($url, $model) {
$url = Yii::$app->urlManager->createUrl(['user/orders','id' => $model['id']]) ;
$countOrders = Order::searchCount([
'id_user' => $model['id']
], ['conditions' => 'date_delete IS NULL']) ;
$html = '' ;
if($countOrders) {
$html .= Html::a('
'.$countOrders, $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) {
$user = User::findOne($model->id) ;
$html = '
'.Html::a(
'',
Yii::$app->urlManager->createUrl(['user/credit','id' => $model->id]),
[
'title' => 'Crédit',
'class' => 'btn btn-default'
]
).'
' ;
return $html ;
}
],
[
'class' => 'yii\grid\ActionColumn',
'template' => '{update} {delete}',
'headerOptions' => ['class' => 'column-actions'],
'contentOptions' => ['class' => 'column-actions'],
'buttons' => [
'update' => function ($url, $model) {
$url = Yii::$app->urlManager->createUrl(['user/update','id' => $model->id]) ;
$user = User::find()->with('userProducer')->where(['id' => $model->id])->one() ;
if(count($user->userProducer) <= 1)
{
return Html::a('
', $url, [
'title' => Yii::t('app', 'Modifier'), 'class' => 'btn btn-default'
]);
}
else {
return '
Non modifiable' ;
}
},
'delete' => function($url, $model) {
return Html::a('
', Yii::$app->urlManager->createUrl(array_merge(['user/delete','id' => $model->id], Yii::$app->getRequest()->getQueryParams())), [
'title' => Yii::t('app', 'Supprimer'), 'class' => 'btn btn-default'
]);
}
],
],
],
]); ?>