->limit(5) | ->limit(5) | ||||
->all(); | ->all(); | ||||
$clients_credit_pain_negatif = User::findBy(['id_etablissement' => Yii::$app->user->identity->id_etablissement]) | |||||
->andWhere('user_etablissement.credit < 0') | |||||
->all(); | |||||
// paramètres | // paramètres | ||||
$etablissement = Etablissement::findOne(Yii::$app->user->identity->id_etablissement) ; | $etablissement = Etablissement::findOne(Yii::$app->user->identity->id_etablissement) ; | ||||
return $this->render('index',[ | return $this->render('index',[ | ||||
'productions' => $productions, | 'productions' => $productions, | ||||
'commandes' => $commandes, | 'commandes' => $commandes, | ||||
'clients' => $clients, | 'clients' => $clients, | ||||
'nb_clients' => $nb_clients, | 'nb_clients' => $nb_clients, | ||||
'clients_credit_pain_negatif' => $clients_credit_pain_negatif, | |||||
'etablissement' => $etablissement, | 'etablissement' => $etablissement, | ||||
]); | ]); | ||||
} | } |
</div> | </div> | ||||
</div> | </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 --> | <!-- Paramètres --> | ||||
<div class=""> | <div class=""> |
$params['id_etablissement'] = Yii::$app->user->identity->id_etablissement ; | $params['id_etablissement'] = Yii::$app->user->identity->id_etablissement ; | ||||
$query = (new \yii\db\Query()) | $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') | ->from('user, user_etablissement') | ||||
->where('user.id = user_etablissement.id_user') | ->where('user.id = user_etablissement.id_user') | ||||
->andWhere('user_etablissement.actif = 1') | ->andWhere('user_etablissement.actif = 1') |