Browse Source

Amélioration / adaptations site/index (tableau de bord)

refactoring
Guillaume Bourgeois 5 years ago
parent
commit
bc9654b050
11 changed files with 161 additions and 223 deletions
  1. +2
    -1
      backend/controllers/OrderController.php
  2. +8
    -3
      backend/controllers/SiteController.php
  3. +4
    -0
      backend/controllers/SubscriptionController.php
  4. +2
    -0
      backend/views/layouts/main.php
  5. +66
    -207
      backend/views/site/index.php
  6. BIN
      backend/web/.sass-cache/2a0ffb00578c9d5a537db16d14c734a22b18f35c/screen.scssc
  7. +34
    -8
      backend/web/css/screen.css
  8. +6
    -0
      backend/web/sass/_adminlte.scss
  9. +2
    -1
      backend/web/sass/screen.scss
  10. +34
    -0
      backend/web/sass/site/_index.scss
  11. +3
    -3
      common/models/Distribution.php

+ 2
- 1
backend/controllers/OrderController.php View File

use common\models\Product ; use common\models\Product ;
use common\models\User ; use common\models\User ;
use common\models\ProductDistribution ; use common\models\ProductDistribution ;
use common\models\Distribution ;


class OrderController extends BackendController class OrderController extends BackendController
{ {
*/ */
public function actionIndex($date = '', $returnData = false) public function actionIndex($date = '', $returnData = false)
{ {
if (!Product::count() && !PointSale::count()) {
if (!Product::searchCount() || !PointSale::searchCount()) {
$this->redirect(['site/index', 'error_products_points_sale' => 1]); $this->redirect(['site/index', 'error_products_points_sale' => 1]);
} }



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

public function actionIndex() public function actionIndex()
{ {
// commandes // commandes
$distributions = Distribution::find()
$distributionsArray = Distribution::find()
->with('order') ->with('order')
->where(['>=', 'distribution.date', date('Y-m-d')]) ->where(['>=', 'distribution.date', date('Y-m-d')])
->andWhere([ ->andWhere([
'distribution.active' => 1 'distribution.active' => 1
]) ])
->orderBy('date ASC') ->orderBy('date ASC')
->limit(5)
->limit(3)
->all(); ->all();


// dernières commandes // dernières commandes
// paramètres // paramètres
$producer = Producer::get(); $producer = Producer::get();


$productsCount = Product::searchCount() ;
$pointsSaleCount = PointSale::searchCount() ;
return $this->render('index', [ return $this->render('index', [
'distributionsArray' => $distributions,
'distributionsArray' => $distributionsArray,
'ordersArray' => $ordersArray, 'ordersArray' => $ordersArray,
'usersArray' => $usersArray, 'usersArray' => $usersArray,
'nbUsers' => $nbUsers, 'nbUsers' => $nbUsers,
'usersNegativeCredit' => $usersNegativeCredit, 'usersNegativeCredit' => $usersNegativeCredit,
'producer' => $producer, 'producer' => $producer,
'productsCount' => $productsCount,
'pointsSaleCount' => $pointsSaleCount
]); ]);
} }



+ 4
- 0
backend/controllers/SubscriptionController.php View File

*/ */
public function actionIndex() public function actionIndex()
{ {
if (!Product::searchCount() || !PointSale::searchCount()) {
$this->redirect(['site/index', 'error_products_points_sale' => 1]);
}
$dataProvider = new ActiveDataProvider([ $dataProvider = new ActiveDataProvider([
'query' => Subscription::find() 'query' => Subscription::find()
->with(['user', 'producer', 'pointSale', 'productSubscription', 'productSubscription.product']) ->with(['user', 'producer', 'pointSale', 'productSubscription', 'productSubscription.product'])

+ 2
- 0
backend/views/layouts/main.php View File

<head> <head>
<meta charset="<?= Yii::$app->charset ?>"/> <meta charset="<?= Yii::$app->charset ?>"/>
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="baseurl" content="<?= Yii::$app->urlManagerBackend->baseUrl ; ?>">
<meta name="baseurl-absolute" content="<?= Yii::$app->urlManagerBackend->getHostInfo().Yii::$app->urlManagerBackend->baseUrl; ?>">
<?= Html::csrfMetaTags() ?> <?= Html::csrfMetaTags() ?>
<title><?= Html::encode($this->title) ?></title> <title><?= Html::encode($this->title) ?></title>
<link rel="icon" type="image/png" href="<?php echo Yii::$app->urlManagerBackend->getBaseUrl(); ?>/img/favicon3.png" /> <link rel="icon" type="image/png" href="<?php echo Yii::$app->urlManagerBackend->getBaseUrl(); ?>/img/favicon3.png" />

+ 66
- 207
backend/views/site/index.php View File



?> ?>
<div class="site-index"> <div class="site-index">
<?php if(Yii::$app->request->get('error_products_points_sale')): ?> <?php if(Yii::$app->request->get('error_products_points_sale')): ?>
<div class="alert alert-danger">Vous devez saisir vos produits et vos points de vente
avant d'initialiser vos jours de production.</div>
<div class="alert alert-warning">
Vous devez ajouter <?php if(!$productsCount): ?> des produits<?php endif; ?>
<?php if(!$productsCount && !$pointsSaleCount): ?> et<?php endif; ?>
<?php if(!$pointsSaleCount): ?> un ou des points de vente <?php endif; ?>
avant d'effectuer cette action.
</div>
<?php endif; ?> <?php endif; ?>
<div class="col-md-4">
<!-- commandes -->
<div class="">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
Commandes
<?= Html::a('Voir', ['order/index'], ['class' => 'btn btn-default btn-xs']) ; ?>
</h3>
</div>
<div class="panel-body">
<?php if(count($distributionsArray)): ?>
<p>Prochaines distributions : </p>
<table class="table table-bordered table-condensed">
<thead>
<tr>
<th>Date</th>
<th>Commandes</th>
<th></th>
</tr>
</thead>
<tbody>
<?php foreach($distributionsArray as $distribution): ?>
<tr>
<td><?= date('d/m/Y',strtotime($distribution['date'])); ?></td>
<td><?= count($distribution->order); ?></td>
<td>
<?= Html::a('<span class="glyphicon glyphicon-eye-open"></span>', ['order/index','date' => $distribution['date']], ['class' => 'btn btn-default btn-xs']) ; ?>
<?php if(count($distribution->order)): ?><?= Html::a('<span class="glyphicon glyphicon-download-alt"></span>', ['order/report','date' => $distribution['date'],'global' => 1], ['class' => 'btn btn-default btn-xs']) ; ?><?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php else: ?>
<div class="alert alert-warning">Aucune production de programmée.</div>
<?php endif; ?>
</div>
<?php if(!$productsCount): ?>
<div class="info-box">
<span class="info-box-icon bg-yellow"><i class="fa fa-clone"></i></span>
<div class="info-box-content">
<span class="info-box-text"><br /><?= Html::a('Ajouter des produits', ['product/create'], ['class' => 'btn btn-default']); ?></span>
</div> </div>
</div> </div>
<?php endif; ?>
<!-- Clients -->
<div class="">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
<?= $nbUsers; ?> client<?php if($nbUsers > 1): ?>s<?php endif; ?>
<?= Html::a('Ajouter',['user/create'],['class' => 'btn btn-success btn-xs margin-left']) ; ?>
<?= Html::a('Liste', ['user/index'], ['class' => 'btn btn-default btn-xs']) ; ?>
</h3>
</div>
<div class="panel-body">
<?php if($nbUsers): ?>
<p>Dernières inscriptions :</p>
<table class="table table-bordered table-condensed">
<thead>
<tr>
<th>Prénom, nom</th>
<th>Inscription</th>
<th></th>
</tr>
</thead>
<tbody>
<?php foreach($usersArray as $user): ?>
<tr>
<td><?= Html::encode($user['lastname'].' '.$user['name']) ?></td>
<td><?= date('d/m/Y', $user['created_at']); ?></td>
<td><?= Html::a('<span class="glyphicon glyphicon-pencil"></span>', ['user/update','id' => $user['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>
<!-- Clients crédit 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($usersNegativeCredit)): ?>
<table class="table table-bordered table-condensed">
<thead>
<tr>
<th>Prénom, nom</th>
<th>Crédit pain</th>
</tr>
</thead>
<tbody>
<?php foreach($usersNegativeCredit as $user): ?>
<tr>
<td><?= Html::encode($user['lastname'].' '.$user['name']) ?></td>
<td><?= number_format($user['credit'],2) ?></td>
<td><?= Html::a('<span class="glyphicon glyphicon-euro"></span>', ['user/credit','id' => $user['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>
<?php if(!$pointsSaleCount): ?>
<div class="info-box">
<span class="info-box-icon bg-yellow"><i class="fa fa-map-marker"></i></span>
<div class="info-box-content">
<span class="info-box-text"><br /><?= Html::a('Ajouter des points de vente', ['point-sale/create'], ['class' => 'btn btn-default']); ?></span>
</div> </div>
</div> </div>
<?php endif; ?>
<!-- Paramètres -->
<div class="">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
Paramètres
<?= Html::a('Configurer',['producer/update'],['class' => 'btn btn-default btn-xs']) ; ?>
</h3>
</div>
<div class="panel-body">
<table class="table table-bordered table-condensed">
<thead>
<tr>
<th>Configuration</th>
<th>Valeur</th>
</tr>
</thead>
<tbody>
<tr>
<td>Producteur activé</td>
<td>
<?php if($producer->active): ?>
<span class="label label-success">Active</span>
<?php else: ?>
<span class="label label-danger">Hors-ligne</span>
<?php endif; ?>
</td>
</tr>
<tr>
<td>Producteur protégé par un code</td>
<td>
<?php if(strlen($producer->code)): ?>
<span class="label label-success">Oui</span><br />
<strong><?= Html::encode($producer->code) ?></strong>
<?php else: ?>
<span class="label label-danger">Non</span>
<?php endif; ?>
</td>
</tr>
<tr>
<td>Délai de commande</td>
<td><?= $producer->order_delay ?> jour<?php if($producer->order_delay > 1): ?>s<?php endif; ?></td>
</tr>
<tr>
<td>Heure limite de commande</td>
<td><?= $producer->order_deadline ?>h</td>
</tr>
<tr>
<td>Système de Crédit activé</td>
<td>
<?php if($producer->credit): ?>
<span class="label label-success">Oui</span><br />
<?php else: ?>
<span class="label label-danger">Non</span>
<?php endif; ?>
</td>
</tr>
</tbody>
</table>
</div>
<?php if($productsCount && $pointsSaleCount && !count($distributionsArray)): ?>
<div class="info-box">
<span class="info-box-icon bg-yellow"><i class="fa fa-calendar"></i></span>
<div class="info-box-content">
<span class="info-box-text"><br /><?= Html::a('Ajouter des jours de distribution', ['order/index'], ['class' => 'btn btn-default']); ?></span>
</div> </div>
</div> </div>

<!-- Mon abonnement -->
<div class="" id="billing">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
Mon abonnement
<?= Html::a('Voir',['producer/billing'],['class' => 'btn btn-default btn-xs']) ; ?>
</h3>
</div>
<div class="panel-body">
<div class="col-md-12">
<?php if(is_null($producer->free_price)): ?>
<h2>Prix libre</h2>
<p>Le modèle économique de <em>La boîte à pain</em> est basé sur un système de prix libre. <?= Html::a('En savoir plus',['producer/billing']); ?></p>
<?php else: ?>
<h2><?= $producer->getFreePrice() ?> / mois <?= Html::a('Modifier',['producer/billing'],['class' => 'btn btn-xs btn-primary']) ?></h2>
<?php endif; ?>
<?php endif; ?>
<div id="distributions">
<!-- distributions -->
<?php if(count($distributionsArray)): ?>
<?php foreach($distributionsArray as $distribution): ?>
<div class="col-md-4 col-sm-12 col-xs-12">
<div class="info-box">
<span class="info-box-icon bg-green date">
<span class="day"><?= strftime('%A', strtotime($distribution->date)) ?></span>
<span class="num"><?= date('d', strtotime($distribution->date)) ?></span>
<span class="month"><?= strftime('%B', strtotime($distribution->date)) ?></span>
</span>
<div class="info-box-content">
<span class="info-box-text">
<?php if(count($distribution->order)): ?>
<strong><?= count($distribution->order); ?></strong> COMMANDES
<?php else: ?>
AUCUNE COMMANDE
<?php endif; ?>
</span>
<span class="info-box-number"></span>
<div class="buttons">
<?= Html::a('<span class="fa fa-eye"></span>', ['order/index', 'date' => $distribution->date], ['class' => 'btn btn-default']); ?>
<?php if(count($distribution->order)): ?><?= Html::a('<span class="fa fa-download"></span>', ['order/report', 'date' => $distribution->date], ['class' => 'btn btn-default']); ?><?php endif; ?>
</div>
</div>
</div> </div>
</div> </div>
</div>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div> </div>
<div class="col-md-8">
<!-- dernières commandes -->
<div id="last-orders" class="">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
Dernières commandes clients
</h3>
</div>
<div class="panel-body">
<?php if(is_array($ordersArray) && count($ordersArray)): ?>
<div class="clr"></div>
<!-- dernières commandes -->
<?php if(is_array($ordersArray) && count($ordersArray)): ?>
<div id="last-orders" class="">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
Commandes à venir
</h3>
</div>
<div class="panel-body">
<table class="table table-condensed table-bordered"> <table class="table table-condensed table-bordered">
<thead> <thead>
<tr> <tr>
<?php endforeach; ?> <?php endforeach; ?>
</tbody> </tbody>
</table> </table>
<?php else: ?>
<div class="alert alert-warning">Aucune commande</div>
<?php endif; ?>
</div>
</div> </div>
</div> </div>
</div> </div>
<?php endif; ?>
</div> </div>

BIN
backend/web/.sass-cache/2a0ffb00578c9d5a537db16d14c734a22b18f35c/screen.scssc View File


+ 34
- 8
backend/web/css/screen.css View File

color: white; color: white;
border-color: #BB8757; border-color: #BB8757;
} }
/* line 119, ../sass/_adminlte.scss */
/* line 118, ../sass/_adminlte.scss */
body.skin-black .content-wrapper .alert a {
color: white;
}
/* line 125, ../sass/_adminlte.scss */
body.skin-black .main-footer a { body.skin-black .main-footer a {
color: #BB8757; color: #BB8757;
} }


/* line 125, ../sass/_adminlte.scss */
/* line 131, ../sass/_adminlte.scss */
body.login-page { body.login-page {
background: none; background: none;
background-color: #F8F1DD; background-color: #F8F1DD;
} }
/* line 129, ../sass/_adminlte.scss */
/* line 135, ../sass/_adminlte.scss */
body.login-page .login-box .login-logo { body.login-page .login-box .login-logo {
text-align: center; text-align: center;
font-family: "comfortaalight"; font-family: "comfortaalight";
} }
/* line 132, ../sass/_adminlte.scss */
/* line 138, ../sass/_adminlte.scss */
body.login-page .login-box .login-logo img { body.login-page .login-box .login-logo img {
width: 50px; width: 50px;
} }
/* line 137, ../sass/_adminlte.scss */
/* line 143, ../sass/_adminlte.scss */
body.login-page .login-box .login-box-body .btn-primary { body.login-page .login-box .login-box-body .btn-primary {
background-color: #BB8757; background-color: #BB8757;
border-color: #BB8757; border-color: #BB8757;
padding: 5px 10px; padding: 5px 10px;
} }
/* line 142, ../sass/_adminlte.scss */
/* line 148, ../sass/_adminlte.scss */
body.login-page .login-box .login-box-body .btn-primary:active { body.login-page .login-box .login-box-body .btn-primary:active {
background-color: #c29469; background-color: #c29469;
border-color: #BB8757; border-color: #BB8757;
} }
/* line 148, ../sass/_adminlte.scss */
/* line 154, ../sass/_adminlte.scss */
body.login-page .login-box .login-box-body a { body.login-page .login-box .login-box-body a {
color: #BB8757; color: #BB8757;
} }
/* line 150, ../sass/_adminlte.scss */
/* line 156, ../sass/_adminlte.scss */
body.login-page .login-box .login-box-body a:hover { body.login-page .login-box .login-box-body a:hover {
color: #c29469; color: #c29469;
} }

/* line 5, ../sass/site/_index.scss */
.site-index #distributions .info-box .date {
text-transform: uppercase;
font-size: 12px;
line-height: 20px;
padding-top: 10px;
}
/* line 11, ../sass/site/_index.scss */
.site-index #distributions .info-box .date span {
display: block;
}
/* line 17, ../sass/site/_index.scss */
.site-index #distributions .info-box .date .num {
font-size: 30px;
padding-top: 5px;
padding-bottom: 5px;
}
/* line 29, ../sass/site/_index.scss */
.site-index #distributions .info-box-content .buttons {
margin-top: 10px;
}

+ 6
- 0
backend/web/sass/_adminlte.scss View File

color: white ; color: white ;
border-color: $color1 ; border-color: $color1 ;
} }
.alert {
a {
color: white ;
}
}
} }
.main-footer { .main-footer {

+ 2
- 1
backend/web/sass/screen.scss View File

} }
} }


@import "_adminlte.scss" ;
@import "_adminlte.scss" ;
@import "site/_index.scss" ;

+ 34
- 0
backend/web/sass/site/_index.scss View File


.site-index {
#distributions {
.info-box {
.date {
text-transform: uppercase ;
font-size: 12px ;
line-height: 20px ;
padding-top: 10px ;
span {
display: block ;
}
.day {
}
.num {
font-size: 30px ;
padding-top: 5px ;
padding-bottom: 5px ;
}
.month {
}
}
}
.info-box-content {
.buttons {
margin-top: 10px ;
}
}
}
}

+ 3
- 3
common/models/Distribution.php View File

{ {
$distribution = null ; $distribution = null ;
if ($date != '') { if ($date != '') {
$distribution = Distribution::find()
->where(['date' => $date])
->one() ;
$distribution = Distribution::searchOne([
'date' => $date
]) ;
if (!$distribution) { if (!$distribution) {
$distribution = new Distribution; $distribution = new Distribution;

Loading…
Cancel
Save