Browse Source

[Backend] Tableau de bord : clients au crédit pain négatif

prodstable
keun 7 years ago
parent
commit
b9aed0edca
3 changed files with 42 additions and 4 deletions
  1. +5
    -3
      backend/controllers/SiteController.php
  2. +36
    -0
      backend/views/site/index.php
  3. +1
    -1
      common/models/User.php

+ 5
- 3
backend/controllers/SiteController.php View File

@@ -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,
]);
}

+ 36
- 0
backend/views/site/index.php View File

@@ -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="">

+ 1
- 1
common/models/User.php View File

@@ -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')

Loading…
Cancel
Save