setTitle('Utilisateurs'); $this->addBreadcrumb($this->getTitle()); $this->addButton(['label' => 'Nouvel utilisateur ', 'url' => 'user/create', 'class' => 'btn btn-primary']); ?> render('_menu_filter', [ 'idPointSaleActive' => $idPointSaleActive, 'idDistributionActive' => 0, 'sectionInactiveUsers' => $sectionInactiveUsers, 'sectionSubscribers' => $sectionSubscribers, 'pointsSaleArray' => $pointsSaleArray, 'section' => 'index' ]); ?> $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}
', 'headerOptions' => ['class' => 'column-actions'], 'contentOptions' => ['class' => 'column-actions'], 'buttons' => [ 'view' => function ($url, $user) { return Html::a('', Yii::$app->urlManager->createUrl(['user/view', 'id' => $user->id]), [ 'title' => 'Voir', 'class' => 'btn btn-default' ]); }, 'update' => function ($url, $user) { return Html::a('', Yii::$app->urlManager->createUrl(['user/update', 'id' => $user->id]), [ 'title' => 'Modifier', 'class' => 'btn btn-default' ]); }, 'delete' => function ($url, $model) { return Html::a(' Enlever', Yii::$app->urlManager->createUrl(array_merge(['user/delete', 'id' => $model->id], Yii::$app->getRequest()->getQueryParams())), [ 'title' => 'Enlever', 'class' => 'btn-confirm-delete' ]); }, 'switch' => function($url, $model) use ($userModule, $userCurrent) { if($userModule->getAuthorizationChecker()->isGrantedAsAdministrator($userCurrent)) { return Html::a(' Prendre la main', Yii::$app->urlManager->createUrl(['user/switch-identity', 'id' => $model->id]), [ 'title' => 'Prendre la main', 'class' => '' ]); } } ], ], ], ]); ?>