Browse Source

Refactoring/traduction vues backend/views/stats

dev
Guillaume Bourgeois 6 years ago
parent
commit
5703dd9f34
3 changed files with 39 additions and 40 deletions
  1. +5
    -5
      backend/controllers/StatsController.php
  2. +2
    -2
      backend/views/stats/index.php
  3. +32
    -33
      backend/views/stats/products.php

+ 5
- 5
backend/controllers/StatsController.php View File

@@ -124,7 +124,7 @@ class StatsController extends BackendController
]);
}
const TOTAUX = 13 ;
const TOTALS = 13 ;
/**
* Affiche un tableau avec les totaux (maximums, commandés) de chaque produit
@@ -143,8 +143,8 @@ class StatsController extends BackendController
$dataProducts[self::TOTAUX] = ['max' => [], 'orders' => []] ;
foreach($productsArray as $product) {
$dataProducts[self::TOTAUX]['max'][$p['name']] = 0 ;
$dataProducts[self::TOTAUX]['orders'][$p['name']] = 0 ;
$dataProducts[self::TOTALS]['max'][$p['name']] = 0 ;
$dataProducts[self::TOTALS]['orders'][$p['name']] = 0 ;
}
$empty = true ;
@@ -167,8 +167,8 @@ class StatsController extends BackendController
if(count($resMaximums)) $empty = false ;
foreach($resMaximums as $productMax) {
if(!isset($dataProducts[self::TOTAUX]['max'][$productMax['name']])) $dataProducts[self::TOTAUX]['max'][$productMax['name']] = 0 ;
$dataProducts[self::TOTAUX]['max'][$productMax['name']] += $productMax['total'] ;
if(!isset($dataProducts[self::TOTALS]['max'][$productMax['name']])) $dataProducts[self::TOTALS]['max'][$productMax['name']] = 0 ;
$dataProducts[self::TOTALS]['max'][$productMax['name']] += $productMax['total'] ;
}

// Commandés

+ 2
- 2
backend/views/stats/index.php View File

@@ -53,7 +53,7 @@ $this->params['breadcrumbs'][] = 'Statistiques';
'width' => 1100
],
'data' => [
'labels' => $data_labels,
'labels' => $dataLabels,
'datasets' => [
[
'label' => 'Recettes commandes',
@@ -61,7 +61,7 @@ $this->params['breadcrumbs'][] = 'Statistiques';
'borderColor' => "rgb(187,135,87,1)",
'pointBackgroundColor' => "rgb(187,135,87,1)",
'pointStrokeColor' => "#fff",
'data' => $data_pain
'data' => $data
]
]
]

backend/views/stats/produits.php → backend/views/stats/products.php View File

@@ -42,12 +42,12 @@ $this->title = 'Statistiques produits' ;
$this->params['breadcrumbs'][] = 'Statistiques produits';

?>
<div class="stats-produits">
<div class="stats-products">
<h1>Statistiques produits <?= $year ?>
<div id="nav-year">
<a class="btn btn-default" href="<?= Yii::$app->urlManager->createUrl(['stats/produits','year' => $year - 1]); ?>">&lt; <?= ($year - 1) ?></a>
<a class="btn btn-default" href="<?= Yii::$app->urlManager->createUrl(['stats/produits','year' => $year + 1]); ?>"><?= ($year + 1) ?> &gt;</a>
<a class="btn btn-default" href="<?= Yii::$app->urlManager->createUrl(['stats/products','year' => $year - 1]); ?>">&lt; <?= ($year - 1) ?></a>
<a class="btn btn-default" href="<?= Yii::$app->urlManager->createUrl(['stats/products','year' => $year + 1]); ?>"><?= ($year + 1) ?> &gt;</a>
</div>
</h1>
@@ -55,12 +55,12 @@ $this->params['breadcrumbs'][] = 'Statistiques produits';
<div class="alert alert-warning">Aucune statistique disponible pour cette période</div>
<?php else: ?>
<table id="table-stats-produits" class="table table-bordered table-hover header-fixed">
<table id="table-stats-products" class="table table-bordered table-hover header-fixed">
<thead>
<tr class="mois">
<th></th>
<?php foreach($arr_mois as $m): ?>
<th colspan="2"><?= $m; ?></th>
<?php foreach($monthArray as $month): ?>
<th colspan="2"><?= $month; ?></th>
<?php endforeach; ?>
</tr>
<tr class="sub-head">
@@ -72,64 +72,63 @@ $this->params['breadcrumbs'][] = 'Statistiques produits';
</tr>
</thead>
<tbody>
<?php foreach($produits as $produit_current): ?>
<?php foreach($productsArray as $currentProduct): ?>
<tr>
<td class="nom"><?= Html::encode($produit_current['nom']) ?></td>
<?php foreach($arr_produits as $mois => $arr_produit_mois):
$find_max = false ;
$find_commandes = false ;
<td class="name"><?= Html::encode($currentProduct['name']) ?></td>
<?php foreach($dataProducts as $month => $productsMonthArray):
$findMax = false ;
$findOrders = false ;
?>
<?php if($mois != StatsController::TOTAUX): ?>
<?php if($month != StatsController::TOTALS): ?>
<!-- max -->
<?php foreach($arr_produit_mois['max'] as $produit):
$tooltip = 'data-toggle="tooltip" data-placement="top" data-original-title="'.Html::encode($produit_current['nom']).' / '.$arr_mois[$mois - 1] .' '. $year.' / Maximum"' ;
<?php foreach($productsMonthArray['max'] as $product):
$tooltip = 'data-toggle="tooltip" data-placement="top" data-original-title="'.Html::encode($currentProduct['name']).' / '.$monthArray[$month - 1] .' '. $year.' / Maximum"' ;
?>
<?php if($produit['nom'] == $produit_current['nom']):
$find_max = true ;
<?php if($product['name'] == $currentProduct['name']):
$findMax = true ;
?>
<td class="align-center">
<div <?= $tooltip; ?>><?= $produit['total'] ?></div>
<div <?= $tooltip; ?>><?= $product['total'] ?></div>
</td>
<?php endif; ?>
<?php endforeach; ?>
<?php if(!$find_max): ?><td class="align-center"><div <?= $tooltip; ?>>0</div></td><?php endif; ?>
<?php if(!$findMax): ?><td class="align-center"><div <?= $tooltip; ?>>0</div></td><?php endif; ?>

<!-- commandes -->
<?php foreach($arr_produit_mois['commandes'] as $produit):
$tooltip = 'data-toggle="tooltip" data-placement="top" data-original-title="'.Html::encode($produit_current['nom']).' / '. $arr_mois[$mois - 1] . ' '. $year .' / Commandés"' ;
<?php foreach($productsMonthArray['orders'] as $product):
$tooltip = 'data-toggle="tooltip" data-placement="top" data-original-title="'.Html::encode($currentProduct['name']).' / '. $monthArray[$month - 1] . ' '. $year .' / Commandés"' ;
?>
<?php if($produit['nom'] == $produit_current['nom']):
$find_commandes = true ;
<?php if($product['name'] == $currentProduct['name']):
$findOrders = true ;
?>
<td class="align-center">
<div <?= $tooltip ?> ><?= $produit['total'] ?></div>
<div <?= $tooltip ?> ><?= $product['total'] ?></div>
</td>
<?php endif; ?>
<?php endforeach; ?>
<?php if(!$find_commandes): ?><td class="align-center"><div <?= $tooltip ?> >0</div></td><?php endif; ?>
<?php if(!$findOrders): ?><td class="align-center"><div <?= $tooltip ?> >0</div></td><?php endif; ?>

<?php else: ?>
<!-- totaux max -->
<?php foreach($arr_produits[StatsController::TOTAUX]['max'] as $nom_produit => $total_max):
$tooltip = 'data-toggle="tooltip" data-placement="top" data-original-title="'.Html::encode($produit_current['nom']).' / Total '. $year .' / Maximums"' ;
<?php foreach($productsArray[StatsController::TOTALS]['max'] as $productName => $totalMax):
$tooltip = 'data-toggle="tooltip" data-placement="top" data-original-title="'.Html::encode($currentProduct['name']).' / Total '. $year .' / Maximums"' ;
?>
<?php if($nom_produit == $produit_current['nom']): ?>
<?php if($productName == $currentProduct['name']): ?>
<td class="align-center">
<div <?= $tooltip ?> ><?= $total_max ?></div>
<div <?= $tooltip ?> ><?= $totalMax ?></div>
</td>
<?php endif; ?>
<?php endforeach; ?>

<!-- totaux commandés -->
<?php foreach($arr_produits[StatsController::TOTAUX]['commandes'] as $nom_produit => $total_commandes):
$tooltip = 'data-toggle="tooltip" data-placement="top" data-original-title="'.Html::encode($produit_current['nom']).' / Total '. $year .' / Commandés"' ;
<?php foreach($productsArray[StatsController::TOTALS]['orders'] as $productName => $totalOrders):
$tooltip = 'data-toggle="tooltip" data-placement="top" data-original-title="'.Html::encode($currentProduct['name']).' / Total '. $year .' / Commandés"' ;
?>
<?php if($nom_produit == $produit_current['nom']): ?>
<?php if($productName == $currentProduct['name']): ?>
<td class="align-center">
<div <?= $tooltip ?> ><?= $total_commandes ?></div>
<div <?= $tooltip ?> ><?= $totalOrders ?></div>
</td>
<?php endif; ?>
<?php endforeach; ?>

Loading…
Cancel
Save