|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- <?php
-
-
-
- use yii\helpers\Html;
- use yii\grid\GridView;
- use common\models\User;
- use common\models\Order;
-
- $this->setTitle('Utilisateurs');
- $this->addBreadcrumb($this->getTitle());
- $this->addButton(['label' => 'Nouvel utilisateur <span class="glyphicon glyphicon-plus"></span>', 'url' => 'user/create', 'class' => 'btn btn-primary']);
-
- ?>
-
- <?=
-
- $this->render('_menu', [
- 'idPointSaleActive' => $idPointSaleActive,
- 'sectionInactiveUsers' => $sectionInactiveUsers,
- 'sectionSubscribers' => $sectionSubscribers,
- 'pointsSaleArray' => $pointsSaleArray,
- 'section' => 'index'
- ]);
-
- ?>
-
- <?= GridView::widget([
- 'dataProvider' => $dataProvider,
- 'filterModel' => $searchModel,
- 'columns' => [
- [
- 'attribute' => 'username',
- 'label' => 'Nom',
- 'value' => function ($model) {
- if (isset($model['name_legal_person']) && strlen($model['name_legal_person'])) {
- return $model['name_legal_person'];
- } else {
- 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 .= '<br />';
- }
- if (strlen($model['email'])) {
- $html .= $model['email'];
- }
- return $html;
- }
- ],
- [
- '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('<span class="glyphicon glyphicon-eye-open"></span> ' . $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) {
-
- $userProducer = UserProducer::searchOne([
- 'id_user' => $model->id
- ]);
- $credit = $userProducer ? $userProducer->credit : 0;
- $classBtnCredit = $userProducer->credit_active ? 'btn-success' : 'btn-default';
-
- $html = '<div class="input-group">
- <input type="text" class="form-control input-credit" readonly="readonly" value="' . number_format($credit, 2) . ' €" placeholder="">
- <span class="input-group-btn">
- ' . Html::a(
- '<span class="glyphicon glyphicon-euro"></span>',
- Yii::$app->urlManager->createUrl(['user/credit', 'id' => $model->id]),
- [
- 'title' => 'Crédit',
- 'class' => 'btn ' . $classBtnCredit
- ]
- ) . '
- </span>
- </div>';
- 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();
- return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, [
- 'title' => Yii::t('app', 'Modifier'), 'class' => 'btn btn-default'
- ]);
- },
- 'delete' => function ($url, $model) {
- return Html::a('<span class="glyphicon glyphicon-trash"></span>', Yii::$app->urlManager->createUrl(array_merge(['user/delete', 'id' => $model->id], Yii::$app->getRequest()->getQueryParams())), [
- 'title' => Yii::t('app', 'Supprimer'), 'class' => 'btn btn-default btn-confirm-delete'
- ]);
- }
- ],
- ],
- ],
- ]); ?>
|