|
|
@@ -47,133 +47,118 @@ $this->addButton(['label' => '+', 'url' => 'user/create', 'class' => 'btn btn-pr |
|
|
|
|
|
|
|
?> |
|
|
|
|
|
|
|
<div class="user-index"> |
|
|
|
<ul id="tabs-points-vente" class="nav nav-tabs" role="tablist"> |
|
|
|
<li class="<?php if(!$idPointSaleActive && !$sectionInactiveUsers): ?>active<?php endif; ?>"> |
|
|
|
<a href="<?= Yii::$app->urlManager->createUrl(['user/index']); ?>">Tous</a> |
|
|
|
</li> |
|
|
|
<?php foreach($pointsSaleArray as $pointSale): ?> |
|
|
|
<li class="<?php if($idPointSaleActive == $pointSale->id): ?>active<?php endif; ?>"> |
|
|
|
<a href="<?= Yii::$app->urlManager->createUrl(['user/index','idPointSale' => $pointSale->id]); ?>"><?= Html::encode($pointSale->name) ?></a> |
|
|
|
</li> |
|
|
|
<?php endforeach; ?> |
|
|
|
<li class="<?php if($sectionInactiveUsers): ?>active<?php endif; ?>"> |
|
|
|
<a href="<?= Yii::$app->urlManager->createUrl(['user/index','sectionInactiveUsers' => 1]); ?>">Inactifs</a> |
|
|
|
</li> |
|
|
|
</ul> |
|
|
|
|
|
|
|
<?= Html::a('<span class="glyphicon glyphicon-envelope"></span> Envoyer un email', ['mail', 'idPointSale' => $idPointSaleActive], ['class' => 'btn btn-default btn-liste-emails']) ?> |
|
|
|
|
|
|
|
<?= GridView::widget([ |
|
|
|
'dataProvider' => $dataProvider, |
|
|
|
'filterModel' => $searchModel, |
|
|
|
'columns' => [ |
|
|
|
[ |
|
|
|
'attribute' => 'username', |
|
|
|
'label' => 'Nom', |
|
|
|
'value' => function($model) { |
|
|
|
return $model['lastname'].' '.$model['name'] ; |
|
|
|
<?= |
|
|
|
|
|
|
|
$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'] ; |
|
|
|
} |
|
|
|
], |
|
|
|
[ |
|
|
|
'attribute' => 'contacts', |
|
|
|
'header' => 'Contacts', |
|
|
|
'format' => 'raw', |
|
|
|
'value' => function($model) { |
|
|
|
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(strlen($model['phone'])) { |
|
|
|
$html .= $model['phone'] ; |
|
|
|
} |
|
|
|
if(strlen($model['phone']) && strlen($model['email'])) { |
|
|
|
$html .= '<br />' ; |
|
|
|
if($countOrders) { |
|
|
|
$html .= Html::a('<span class="glyphicon glyphicon-eye-open"></span> '.$countOrders, $url, [ |
|
|
|
'title' => Yii::t('app', 'Commandes'), 'class' => 'btn btn-default ' |
|
|
|
]); ; |
|
|
|
} |
|
|
|
if(strlen($model['email'])) { |
|
|
|
$html .= $model['email'] ; |
|
|
|
else { |
|
|
|
$html .= 'Aucune commande' ; |
|
|
|
} |
|
|
|
|
|
|
|
return $html ; |
|
|
|
} |
|
|
|
], |
|
|
|
[ |
|
|
|
'attribute' => 'created_at', |
|
|
|
'label' => 'Date d\'inscription', |
|
|
|
'value' => function($model) { |
|
|
|
if(isset($model['created_at'])) |
|
|
|
return date('m/d/Y à H:i', $model['created_at']); |
|
|
|
} |
|
|
|
], |
|
|
|
[ |
|
|
|
'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' |
|
|
|
]); |
|
|
|
], |
|
|
|
[ |
|
|
|
'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' |
|
|
|
]); |
|
|
|
} |
|
|
|
], |
|
|
|
], |
|
|
|
]); ?> |
|
|
|
</div> |
|
|
|
], |
|
|
|
]); ?> |