setTitle('Utilisateurs');
$this->addBreadcrumb($this->getTitle());
$this->addButton(['label' => 'Nouvel utilisateur ', 'url' => 'user/create', 'class' => 'btn btn-primary']);
?>
=
$this->render('_menu_filter', [
'idPointSaleActive' => $idPointSaleActive,
'idDistributionActive' => 0,
'sectionInactiveUsers' => $sectionInactiveUsers,
'sectionSubscribers' => $sectionSubscribers,
'pointsSaleArray' => $pointsSaleArray,
'section' => 'index'
]);
?>
= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'summary' =>
'Affichage de {begin, number}-{end, number} sur {totalCount, number} {totalCount, plural, one{élément} other{éléments}}.'.
$this->getProducerModule()->getProducerPageSizer()
->getPageSizeSummary($producer, 'user', 'Utilisateurs'),
'columns' => [
[
'attribute' => 'username',
'label' => 'Nom',
'value' => function ($user) use ($userModule) {
return $userModule->getUsername($user);
}
],
[
'attribute' => 'type',
'label' => 'Type',
'headerOptions' => ['class' => 'column-hide-on-mobile'],
'filterOptions' => ['class' => 'column-hide-on-mobile'],
'contentOptions' => ['class' => 'column-hide-on-mobile'],
'filter' => $userModule->getTypeChoicesArray(),
'value' => function ($user) use ($userModule) {
return $userModule->getTypeLabel($user['type']);
}
],
[
'attribute' => 'contacts',
'header' => 'Contacts',
'format' => 'raw',
'headerOptions' => ['class' => 'column-hide-on-mobile'],
'filterOptions' => ['class' => 'column-hide-on-mobile'],
'contentOptions' => ['class' => 'column-hide-on-mobile'],
'value' => function ($user) {
$html = '';
if (strlen($user['phone'])) {
$html .= $user['phone'];
}
if (strlen($user['phone']) && strlen($user['email'])) {
$html .= '
';
}
if (strlen($user['email'])) {
$html .= $user['email'];
}
return $html;
}
],
[
'attribute' => 'credit',
'format' => 'raw',
'contentOptions' => ['class' => 'column-hide-on-mobile align-center'],
'value' => function ($model) use ($producer) {
$userProducer = UserProducer::searchOne([
'id_user' => $model->id
]);
$credit = $userProducer ? $userProducer->credit : 0;
$classBtnCredit = $userProducer->credit_active ? 'btn-success' : 'btn-default';
$html = ''.Price::format($credit).'';
return $html;
}
],
[
'class' => 'yii\grid\ActionColumn',
'header' => 'Commandes',
'template' => '{orders}',
'headerOptions' => ['class' => 'actions column-hide-on-mobile'],
'filterOptions' => ['class' => 'column-hide-on-mobile'],
'contentOptions' => ['class' => 'column-hide-on-mobile align-center'],
'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.' commande'.($countOrders > 1 ? 's' : ''), $url, [
'title' => 'Commandes', 'class' => 'btn btn-default '
]);;
} else {
$html .= 'Aucune';
}
return $html;
},
],
],
[
'attribute' => 'newsletter',
'header' => "Inscrit au bulletin
d'information",
'format' => 'raw',
'headerOptions' => ['class' => 'column-hide-on-mobile'],
'filterOptions' => ['class' => 'column-hide-on-mobile'],
'contentOptions' => ['class' => 'column-hide-on-mobile align-center'],
'filter' => [
0 => 'Non',
1 => 'Oui'
],
'value' => function ($user) use ($userModule) {
if($userModule->isUserSubscribedNewsletter($user)) {
return 'Oui';
}
return 'Non';
}
],
[
'attribute' => 'id_user_user_group',
'header' => 'Groupes',
'format' => 'raw',
'headerOptions' => ['class' => 'column-hide-on-mobile'],
'filterOptions' => ['class' => 'column-hide-on-mobile'],
'contentOptions' => ['class' => 'column-hide-on-mobile'],
'filter' => $userGroupModule->getRepository()->populateUserGroupDropdownList(false),
'value' => function ($user) {
$html = '';
foreach($user->userUserGroup as $userUserGroup) {
$html .= ''.$userUserGroup->userGroup->name.' ';
}
return $html;
}
],
[
'class' => 'yii\grid\ActionColumn',
'template' => '{view} {update}