setTitle('Utilisateurs');
$this->addBreadcrumb($this->getTitle());
$this->addButton(['label' => 'Nouvel utilisateur ', '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) {
return User::getUsernameFromArray($model);
}
],
[
'attribute' => 'type',
'label' => 'Type',
'value' => function ($model) {
$typeArray = User::getTypeChoicesArray();
if(isset($typeArray[$model['type']])) {
return $typeArray[$model['type']];
}
return '';
}
],
[
'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 .= '
';
}
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(' ' . $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 = '