|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- <?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' => '+', 'url' => 'user/create', 'class' => 'btn btn-primary']) ;
-
- ?>
-
- <?=
-
- $this->render('_menu',[
- 'idPointSaleActive' => $idPointSaleActive,
- 'sectionInactiveUsers' => $sectionInactiveUsers,
- 'pointsSaleArray' => $pointsSaleArray,
- 'section' => 'list'
- ]) ;
-
- ?>
-
- <?= 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 .= '<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) {
- $user = User::findOne($model->id) ;
- $html = '<div class="input-group">
- <input type="text" class="form-control input-credit" readonly="readonly" value="'.number_format($user->getCredit($producer->id),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 btn-default'
- ]
- ).'
- </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() ;
- if(count($user->userProducer) <= 1)
- {
- return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, [
- 'title' => Yii::t('app', 'Modifier'), 'class' => 'btn btn-default'
- ]);
- }
- else {
- return '<span data-toggle="tooltip" data-placement="top" title="Vous ne pouvez pas modifier les utilisateurs qui sont liés à plusieurs producteurs."><span class="glyphicon glyphicon-remove-sign"></span> Non modifiable</span>' ;
- }
- },
- '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'
- ]);
- }
- ],
- ],
- ],
- ]); ?>
|