Просмотр исходного кода

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

refactoring
Guillaume Bourgeois 5 лет назад
Родитель
Сommit
bc9654b050
11 измененных файлов: 161 добавлений и 223 удалений
  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. Двоичные данные
      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 Просмотреть файл

@@ -43,6 +43,7 @@ use common\models\ProductOrder ;
use common\models\Product ;
use common\models\User ;
use common\models\ProductDistribution ;
use common\models\Distribution ;

class OrderController extends BackendController
{
@@ -252,7 +253,7 @@ class OrderController extends BackendController
*/
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]);
}


+ 8
- 3
backend/controllers/SiteController.php Просмотреть файл

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

// dernières commandes
@@ -150,13 +150,18 @@ class SiteController extends BackendController
// paramètres
$producer = Producer::get();

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


+ 4
- 0
backend/controllers/SubscriptionController.php Просмотреть файл

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

+ 2
- 0
backend/views/layouts/main.php Просмотреть файл

@@ -69,6 +69,8 @@ if (Yii::$app->controller->action->id === 'login') {
<head>
<meta charset="<?= Yii::$app->charset ?>"/>
<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() ?>
<title><?= Html::encode($this->title) ?></title>
<link rel="icon" type="image/png" href="<?php echo Yii::$app->urlManagerBackend->getBaseUrl(); ?>/img/favicon3.png" />

+ 66
- 207
backend/views/site/index.php Просмотреть файл

@@ -42,224 +42,86 @@ $this->title = 'Tableau de bord';

?>
<div class="site-index">
<?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; ?>
<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>
<?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>
<?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>

<!-- 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>
<?php endforeach; ?>
<?php endif; ?>
</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">
<thead>
<tr>
@@ -294,11 +156,8 @@ $this->title = 'Tableau de bord';
<?php endforeach; ?>
</tbody>
</table>
<?php else: ?>
<div class="alert alert-warning">Aucune commande</div>
<?php endif; ?>
</div>
</div>
</div>
</div>
<?php endif; ?>
</div>

Двоичные данные
backend/web/.sass-cache/2a0ffb00578c9d5a537db16d14c734a22b18f35c/screen.scssc Просмотреть файл


+ 34
- 8
backend/web/css/screen.css Просмотреть файл

@@ -1499,41 +1499,67 @@ body.skin-black .content-wrapper .btn-primary, body.skin-black .content-wrapper
color: white;
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 {
color: #BB8757;
}

/* line 125, ../sass/_adminlte.scss */
/* line 131, ../sass/_adminlte.scss */
body.login-page {
background: none;
background-color: #F8F1DD;
}
/* line 129, ../sass/_adminlte.scss */
/* line 135, ../sass/_adminlte.scss */
body.login-page .login-box .login-logo {
text-align: center;
font-family: "comfortaalight";
}
/* line 132, ../sass/_adminlte.scss */
/* line 138, ../sass/_adminlte.scss */
body.login-page .login-box .login-logo img {
width: 50px;
}
/* line 137, ../sass/_adminlte.scss */
/* line 143, ../sass/_adminlte.scss */
body.login-page .login-box .login-box-body .btn-primary {
background-color: #BB8757;
border-color: #BB8757;
padding: 5px 10px;
}
/* line 142, ../sass/_adminlte.scss */
/* line 148, ../sass/_adminlte.scss */
body.login-page .login-box .login-box-body .btn-primary:active {
background-color: #c29469;
border-color: #BB8757;
}
/* line 148, ../sass/_adminlte.scss */
/* line 154, ../sass/_adminlte.scss */
body.login-page .login-box .login-box-body a {
color: #BB8757;
}
/* line 150, ../sass/_adminlte.scss */
/* line 156, ../sass/_adminlte.scss */
body.login-page .login-box .login-box-body a:hover {
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 Просмотреть файл

@@ -113,6 +113,12 @@ body.skin-black {
color: white ;
border-color: $color1 ;
}
.alert {
a {
color: white ;
}
}
}
.main-footer {

+ 2
- 1
backend/web/sass/screen.scss Просмотреть файл

@@ -1368,4 +1368,5 @@ a {
}
}

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

+ 34
- 0
backend/web/sass/site/_index.scss Просмотреть файл

@@ -0,0 +1,34 @@

.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 Просмотреть файл

@@ -152,9 +152,9 @@ class Distribution extends ActiveRecordCommon
{
$distribution = null ;
if ($date != '') {
$distribution = Distribution::find()
->where(['date' => $date])
->one() ;
$distribution = Distribution::searchOne([
'date' => $date
]) ;
if (!$distribution) {
$distribution = new Distribution;

Загрузка…
Отмена
Сохранить