setTitle('Utilisateurs'); $this->addBreadcrumb($this->getTitle()); $this->addButton(['label' => 'Nouvel utilisateur ', 'url' => 'user/create', 'class' => 'btn btn-primary']); ?> render('_menu', [ 'idPointSaleActive' => $idPointSaleActive, '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' => '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'], 'filter' => [ 0 => 'Non', 1 => 'Oui' ], 'value' => function ($user) use ($userModule) { if($userModule->isUserSubscribedNewsletter($user)) { return 'Oui'; } return 'Non'; } ], [ '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'], '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' => 'Commandes', 'class' => 'btn btn-default ' ]);; } else { $html .= 'Aucune commande'; } return $html; }, ], ], [ 'attribute' => 'credit', 'format' => 'raw', '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 = '
' . Html::a( '', Yii::$app->urlManager->createUrl(['user/credit', 'id' => $model->id]), [ 'title' => 'Crédit', 'class' => 'btn ' . $classBtnCredit ] ) . '
'; return $html; } ], [ 'class' => 'yii\grid\ActionColumn', 'template' => '{update} {delete} {switch}', 'headerOptions' => ['class' => 'column-actions'], 'contentOptions' => ['class' => 'column-actions'], 'buttons' => [ '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('', Yii::$app->urlManager->createUrl(array_merge(['user/delete', 'id' => $model->id], Yii::$app->getRequest()->getQueryParams())), [ 'title' => 'Supprimer', 'class' => 'btn btn-default btn-confirm-delete' ]); }, 'switch' => function($url, $model) use ($userModule, $userCurrent) { if($userModule->getAuthorizationChecker()->isGrantedAsAdministrator($userCurrent)) { return Html::a('', Yii::$app->urlManager->createUrl(['user/switch-identity', 'id' => $model->id]), [ 'title' => 'Prendre la main', 'class' => 'btn btn-default' ]); } } ], ], ], ]); ?>