@@ -104,17 +104,19 @@ class SiteController extends BackendController | |||
->limit(5) | |||
->all(); | |||
$clients_credit_pain_negatif = User::findBy(['id_etablissement' => Yii::$app->user->identity->id_etablissement]) | |||
->andWhere('user_etablissement.credit < 0') | |||
->all(); | |||
// paramètres | |||
$etablissement = Etablissement::findOne(Yii::$app->user->identity->id_etablissement) ; | |||
return $this->render('index',[ | |||
'productions' => $productions, | |||
'commandes' => $commandes, | |||
'clients' => $clients, | |||
'nb_clients' => $nb_clients, | |||
'clients_credit_pain_negatif' => $clients_credit_pain_negatif, | |||
'etablissement' => $etablissement, | |||
]); | |||
} |
@@ -90,6 +90,42 @@ $this->title = 'Tableau de bord'; | |||
</div> | |||
</div> | |||
</div> | |||
<!-- Clients crédit pain négatif --> | |||
<div class=""> | |||
<div class="panel panel-default"> | |||
<div class="panel-heading"> | |||
<h3 class="panel-title"> | |||
Clients au crédit pain négatif | |||
</h3> | |||
</div> | |||
<div class="panel-body"> | |||
<?php if(count($clients_credit_pain_negatif)): ?> | |||
<p>Dernières inscriptions :</p> | |||
<table class="table table-bordered table-condensed"> | |||
<thead> | |||
<tr> | |||
<th>Prénom, nom</th> | |||
<th>Crédit pain</th> | |||
</tr> | |||
</thead> | |||
<tbody> | |||
<?php foreach($clients_credit_pain_negatif as $c): ?> | |||
<tr> | |||
<td><?= Html::encode($c['prenom'].' '.$c['nom']) ?></td> | |||
<td><?= number_format($c['credit'],2) ?></td> | |||
<td><?= Html::a('<span class="glyphicon glyphicon-euro"></span>', ['user/credit','id' => $c['user_id']], ['class' => 'btn btn-default btn-xs']) ; ?></td> | |||
</tr> | |||
<?php endforeach; ?> | |||
</tbody> | |||
</table> | |||
<?php else: ?> | |||
<div class="alert alert-warning">Aucun client.</div> | |||
<?php endif; ?> | |||
</div> | |||
</div> | |||
</div> | |||
<!-- Paramètres --> | |||
<div class=""> |
@@ -181,7 +181,7 @@ class User extends ActiveRecord implements IdentityInterface | |||
$params['id_etablissement'] = Yii::$app->user->identity->id_etablissement ; | |||
$query = (new \yii\db\Query()) | |||
->select(['user.id AS user_id', 'user.prenom','user.nom','user.telephone','user.email','user.created_at','user.date_derniere_connexion']) | |||
->select(['user.id AS user_id', 'user.prenom','user.nom','user.telephone','user.email','user.created_at','user.date_derniere_connexion','user_etablissement.*']) | |||
->from('user, user_etablissement') | |||
->where('user.id = user_etablissement.id_user') | |||
->andWhere('user_etablissement.actif = 1') |