Browse Source

Améliorations / adaptations stats

refactoring
Guillaume Bourgeois 6 years ago
parent
commit
2c5f3982fb
6 changed files with 76 additions and 31 deletions
  1. +12
    -3
      backend/controllers/StatsController.php
  2. +19
    -7
      backend/views/layouts/main.php
  3. +38
    -20
      backend/views/stats/products.php
  4. BIN
      backend/web/.sass-cache/2a0ffb00578c9d5a537db16d14c734a22b18f35c/screen.scssc
  5. +2
    -1
      backend/web/sass/screen.scss
  6. +5
    -0
      backend/web/sass/stats/_products.scss

+ 12
- 3
backend/controllers/StatsController.php View File

@@ -135,7 +135,7 @@ class StatsController extends BackendController
* @param integer $year
* @return mixed
*/
public function actionProducts($year = 0)
public function actionProducts($year = 0, $section = 1)
{
if(!$year) $year = date('Y') ;
@@ -149,8 +149,14 @@ class StatsController extends BackendController
$dataProducts[self::TOTALS]['orders'][$product['name']] = 0 ;
}
if(!in_array($section, [1, 2, 3, 4])) {
$section = 1 ;
}
$iStart = (3 * ($section - 1)) + 1 ;
$iEnd = 3 * $section ;
$empty = true ;
for($i = 1; $i <= 12; $i++) {
for($i = $iStart; $i <= $iEnd; $i++) {
// Maximums
$resMaximums = Yii::$app->db->createCommand("SELECT product.name, SUM(IF(product_distribution.active, product_distribution.quantity_max,0)) AS total
FROM distribution, product_distribution, product
@@ -212,7 +218,10 @@ class StatsController extends BackendController
'monthArray' => $monthArray,
'productsArray' => $productsArray,
'dataProducts' => $dataProducts,
'empty' => $empty
'empty' => $empty,
'section' => $section,
'iStart' => $iStart,
'iEnd' => $iEnd,
]);
}


+ 19
- 7
backend/views/layouts/main.php View File

@@ -53,13 +53,8 @@ if (Yii::$app->controller->action->id === 'login') {
);
} else {

if (class_exists('backend\assets\AppAsset')) {
backend\assets\AppAsset::register($this);
} else {
app\assets\AppAsset::register($this);
}

dmstr\web\AdminLteAsset::register($this);
\dmstr\web\AdminLteAsset::register($this);
\backend\assets\AppAsset::register($this);

$directoryAsset = Yii::$app->assetManager->getPublishedUrl('@vendor/almasaeed2010/adminlte/dist');
?>
@@ -99,6 +94,23 @@ if (Yii::$app->controller->action->id === 'login') {
</div>

<?php $this->endBody() ?>
<!-- analytics -->
<script>
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date();
a = s.createElement(o),
m = s.getElementsByTagName(o)[0];
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m)
})(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');

ga('create', 'UA-86917043-1', 'auto');
ga('send', 'pageview');
</script>
</body>
</html>
<?php $this->endPage() ?>

+ 38
- 20
backend/views/stats/products.php View File

@@ -37,30 +37,40 @@ termes.
*/

use \backend\controllers\StatsController ;
use yii\helpers\Html;

$this->setTitle('Statistiques <small>Produits '.$year.'</small>', 'Statistiques produits '.$year) ;
$this->addBreadcrumb('Statistiques produits '.$year) ;
$this->addButton(['label' => '&lt; '.($year - 1), 'url' => ['stats/products','year' => $year - 1], 'class' => 'btn btn-default']) ;
$this->addButton(['label' => ($year + 1).' &gt;', 'url' => ['stats/products','year' => $year + 1], 'class' => 'btn btn-default']) ;

$theMonth = 1 ;

?>
<div class="stats-products">
<?php if($empty): ?>
<div class="alert alert-warning">Aucune statistique disponible pour cette période</div>
<?php else: ?>
<table id="table-stats-products" class="table table-bordered table-hover header-fixed">
<thead>
<tr class="mois">
<th></th>
<?php foreach($monthArray as $month): ?>
<th colspan="2"><?= $month; ?></th>
<?php endforeach; ?>
<?php foreach($monthArray as $key => $month):
if(($key + 1) >= $iStart && ($key + 1) <= $iEnd):
?>
<th colspan="2">
<?php if($section != 1 && $key + 1 == $iStart): echo Html::a('&lt;', ['stats/products', 'year' => $year, 'section' => $section - 1], ['class' => 'btn btn-default']) ; ?><?php endif; ?>
<?= $month; ?>
<?php if($key + 1 == $iEnd && $section != 4): echo Html::a('&gt;', ['stats/products', 'year' => $year, 'section' => $section + 1], ['class' => 'btn btn-default']) ; ?><?php endif; ?>
</th>
<?php
endif;
endforeach;
?>
<th colspan="2">Totaux</th>
</tr>
<tr class="sub-head">
<th></th>
<?php for($i=1; $i<=13; $i++): ?>
<?php for($i=$iStart; $i<=$iEnd + 1; $i++): ?>
<th>Maximum</th>
<th>Commandés</th>
<?php endfor; ?>
@@ -71,6 +81,7 @@ $this->addButton(['label' => ($year + 1).' &gt;', 'url' => ['stats/products','ye
<tr>
<td class="name"><?= Html::encode($currentProduct['name']) ?></td>
<?php foreach($dataProducts as $month => $productsMonthArray):
$findMax = false ;
$findOrders = false ;
?>
@@ -78,14 +89,14 @@ $this->addButton(['label' => ($year + 1).' &gt;', 'url' => ['stats/products','ye
<!-- max -->
<?php
$tooltip = 'data-toggle="tooltip" data-placement="top" data-original-title="'.Html::encode($currentProduct['name']).' / '.$monthArray[$month - 1] .' '. $year.' / Maximum"' ;
$tooltip = 'data-toggle="tooltip" data-placement="top" title="'.Html::encode($currentProduct['name']).' / '.$monthArray[$month - 1] .' '. $year.' / Maximum"' ;
foreach($productsMonthArray['max'] as $product):
?>
<?php if($product['name'] == $currentProduct['name']):
$findMax = true ;
?>
<td class="align-center">
<div <?= $tooltip; ?>><?= $product['total'] ?></div>
<div <?= $tooltip; ?>><?= (int) $product['total'] ?></div>
</td>
<?php endif; ?>
<?php endforeach; ?>
@@ -93,14 +104,14 @@ $this->addButton(['label' => ($year + 1).' &gt;', 'url' => ['stats/products','ye

<!-- commandes -->
<?php
$tooltip = 'data-toggle="tooltip" data-placement="top" data-original-title="'.Html::encode($currentProduct['name']).' / '. $monthArray[$month - 1] . ' '. $year .' / Commandés"' ;
$tooltip = 'data-toggle="tooltip" data-placement="top" title="'.Html::encode($currentProduct['name']).' / '. $monthArray[$month - 1] . ' '. $year .' / Commandés"' ;
foreach($productsMonthArray['orders'] as $product):
?>
<?php if($product['name'] == $currentProduct['name']):
$findOrders = true ;
?>
<td class="align-center">
<div <?= $tooltip ?> ><?= $product['total'] ?></div>
<div <?= $tooltip ?> ><?= (int) $product['total'] ?></div>
</td>
<?php endif; ?>
<?php endforeach; ?>
@@ -110,35 +121,42 @@ $this->addButton(['label' => ($year + 1).' &gt;', 'url' => ['stats/products','ye
<?php else: ?>
<!-- totaux max -->
<?php
$tooltip = 'data-toggle="tooltip" data-placement="top" data-original-title="'.Html::encode($currentProduct['name']).' / Total '. $year .' / Maximums"' ;
$tooltip = 'data-toggle="tooltip" data-placement="top" title="'.Html::encode($currentProduct['name']).' / Total '. $year .' / Maximums"' ;
foreach($dataProducts[StatsController::TOTALS]['max'] as $productName => $totalMax):
?>
<?php if($productName == $currentProduct['name']): ?>
<?php
if($productName == $currentProduct['name']):
$findMax = true ;
?>
<td class="align-center">
<div <?= $tooltip ?> ><?= $totalMax ?></div>
<div <?= $tooltip ?> ><?= (int) $totalMax ?></div>
</td>
<?php endif; ?>
<?php endforeach; ?>

<?php if(!$findMax): ?><td class="align-center"><div <?= $tooltip; ?>>0</div></td><?php endif; ?>
<!-- totaux commandés -->
<?php
$tooltip = 'data-toggle="tooltip" data-placement="top" data-original-title="'.Html::encode($currentProduct['name']).' / Total '. $year .' / Commandés"' ;
$tooltip = 'data-toggle="tooltip" data-placement="top" title="'.Html::encode($currentProduct['name']).' / Total '. $year .' / Commandés"' ;
foreach($dataProducts[StatsController::TOTALS]['orders'] as $productName => $totalOrders):
?>
<?php if($productName == $currentProduct['name']): ?>
<?php if($productName == $currentProduct['name']):
$findOrders = true ;
?>
<td class="align-center">
<div <?= $tooltip ?> ><?= $totalOrders ?></div>
<div <?= $tooltip ?> ><?= (int) $totalOrders ?></div>
</td>
<?php endif; ?>
<?php endforeach; ?>
<?php if(!$findOrders): ?><td class="align-center"><div <?= $tooltip ?> >0</div></td><?php endif; ?>
<?php endif; ?>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>

</div>

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


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

@@ -1346,4 +1346,5 @@ a {
@import "_adminlte.scss" ;
@import "site/_index.scss" ;
@import "subscription/_index.scss" ;
@import "product/_index.scss" ;
@import "product/_index.scss" ;
@import "stats/_products.scss" ;

+ 5
- 0
backend/web/sass/stats/_products.scss View File

@@ -0,0 +1,5 @@

.stats-products {
//width: 100% ;
//overflow-x: scroll ;
}

Loading…
Cancel
Save