소스 검색

Affichage des statistiques produits (maximum, commandes) par année dans un tableau

dev
keun 6 년 전
부모
커밋
6eefe918ae
6개의 변경된 파일241개의 추가작업 그리고 0개의 파일을 삭제
  1. +47
    -0
      backend/controllers/StatsController.php
  2. +5
    -0
      backend/views/layouts/main.php
  3. +69
    -0
      backend/views/stats/produits.php
  4. BIN
      backend/web/.sass-cache/2a0ffb00578c9d5a537db16d14c734a22b18f35c/screen.scssc
  5. +58
    -0
      backend/web/css/screen.css
  6. +62
    -0
      backend/web/sass/screen.scss

+ 47
- 0
backend/controllers/StatsController.php 파일 보기

@@ -84,6 +84,53 @@ class StatsController extends BackendController {
'data_pain' => $data_pain_noindex,
]);
}
public function actionProduits($year = 0) {
if(!$year) $year = date('Y') ;
$arr_produits = [] ;
for($i = 1; $i <= 12; $i++) {
// Maximums
$res_maximums = Yii::$app->db->createCommand("SELECT produit.nom, SUM(IF(production_produit.actif,production_produit.quantite_max,0)) AS total
FROM production, production_produit, produit
WHERE production.id_etablissement = ".Yii::$app->user->identity->id_etablissement."
AND production.date >= :date_begin
AND production.date <= :date_end
AND production.id = production_produit.id_production
AND production_produit.id_produit = produit.id
GROUP BY produit.id
ORDER BY produit.nom")
->bindValue(':date_begin', date($year.'-'.str_pad($i, 2, 0, STR_PAD_LEFT).'-01'))
->bindValue(':date_end', date($year.'-'.str_pad($i, 2, 0, STR_PAD_LEFT).'-31'))
->queryAll();
$arr_produits[$i]['max'] = $res_maximums ;
// Commandés
$res_commandes = Yii::$app->db->createCommand("SELECT produit.nom, SUM(commande_produit.quantite) AS total
FROM production, commande, commande_produit, produit
WHERE production.id_etablissement = ".Yii::$app->user->identity->id_etablissement."
AND production.date >= :date_begin
AND production.date <= :date_end
AND production.id = commande.id_production
AND commande.id = commande_produit.id_commande
AND commande_produit.id_produit = produit.id
GROUP BY produit.id
ORDER BY produit.nom")
->bindValue(':date_begin', date($year.'-'.str_pad($i, 2, 0, STR_PAD_LEFT).'-01'))
->bindValue(':date_end', date($year.'-'.str_pad($i, 2, 0, STR_PAD_LEFT).'-31'))
->queryAll();
$arr_produits[$i]['commandes'] = $res_commandes ;
}
return $this->render('produits', [
'year' => $year,
'arr_produits' => $arr_produits
]);
}

}


+ 5
- 0
backend/views/layouts/main.php 파일 보기

@@ -110,6 +110,11 @@ if(!Yii::$app->user->isGuest)
'url' => ['/stats/index'],
'visible' => !Yii::$app->user->isGuest,
],
[
'label' => '<span class="glyphicon glyphicon-stats"></span> Statistiques produits',
'url' => ['/stats/produits'],
'visible' => !Yii::$app->user->isGuest,
],
[
'label' => '<span class="glyphicon glyphicon-wrench"></span> Développement',
'url' => ['/developpement/index'],

+ 69
- 0
backend/views/stats/produits.php 파일 보기

@@ -0,0 +1,69 @@
<?php

$this->title = 'Statistiques produits' ;
$this->params['breadcrumbs'][] = 'Statistiques produits';

?>
<div class="stats-produits">
<h1>Statistiques produits <?= $year ?></h1>

<table class="table table-bordered table-hover header-fixed">
<thead>
<tr class="mois">
<th></th>
<th colspan="2">Janvier</th>
<th colspan="2">Février</th>
<th colspan="2">Mars</th>
<th colspan="2">Avril</th>
<th colspan="2">Mai</th>
<th colspan="2">Juin</th>
<th colspan="2">Juillet</th>
<th colspan="2">Août</th>
<th colspan="2">Septembre</th>
<th colspan="2">Octobre</th>
<th colspan="2">Novembre</th>
<th colspan="2">Décembre</th>
</tr>
<tr class="sub-head">
<th></th>
<?php for($i=1; $i<=12; $i++): ?>
<th>Maximum</th>
<th>Commandés</th>
<?php endfor; ?>
</tr>
</thead>
<tbody>
<?php foreach($arr_produits[1]['max'] as $produit_current): ?>
<tr>
<td class="nom"><?= $produit_current['nom'] ?></td>
<?php foreach($arr_produits as $arr_produit_mois):
$find_max = false ;
$find_commandes = false ;
?>
<!-- max -->
<?php foreach($arr_produit_mois['max'] as $produit): ?>
<?php if($produit['nom'] == $produit_current['nom']):
$find_max = true ;
?>
<td class="align-center"><?= $produit['total'] ?></td>
<?php endif; ?>
<?php endforeach; ?>
<?php if(!$find_max): ?><td class="align-center">0</td><?php endif; ?>
<!-- commandes -->
<?php foreach($arr_produit_mois['commandes'] as $produit): ?>
<?php if($produit['nom'] == $produit_current['nom']):
$find_commandes = true ;
?>
<td class="align-center"><?= $produit['total'] ?></td>
<?php endif; ?>
<?php endforeach; ?>
<?php if(!$find_commandes): ?><td class="align-center">0</td><?php endif; ?>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
</tbody>
</table>

</div>

BIN
backend/web/.sass-cache/2a0ffb00578c9d5a537db16d14c734a22b18f35c/screen.scssc 파일 보기


+ 58
- 0
backend/web/css/screen.css 파일 보기

@@ -1322,3 +1322,61 @@ a:hover, a:focus, a:active {
margin-bottom: 2px;
padding: 5px 8px;
}

/* stats */
/* line 1347, ../sass/screen.scss */
.stats-produits {
/*.header-fixed {
width: 100%
}

.header-fixed > thead,
.header-fixed > tbody,
.header-fixed > thead > tr,
.header-fixed > tbody > tr,
.header-fixed > thead > tr > th,
.header-fixed > tbody > tr > td {
display: block;
}

.header-fixed > tbody > tr:after,
.header-fixed > thead > tr:after {
content: ' ';
display: block;
visibility: hidden;
clear: both;
}

.header-fixed > tbody {
overflow-y: auto;
height: 150px;
}

.header-fixed > tbody > tr > td,
.header-fixed > thead > tr.sub-head > th {
width: 4.16%;
float: left;
}
.header-fixed > thead > tr.mois > th {
width: 7.69%;
float: left;
}*/
}
/* line 1349, ../sass/screen.scss */
.stats-produits tr.mois th {
text-align: center;
}
/* line 1354, ../sass/screen.scss */
.stats-produits tr.sub-head th {
font-weight: normal;
font-size: 12px;
}
/* line 1360, ../sass/screen.scss */
.stats-produits td.nom {
text-transform: uppercase;
}
/* line 1364, ../sass/screen.scss */
.stats-produits td.align-center {
text-align: center;
}

+ 62
- 0
backend/web/sass/screen.scss 파일 보기

@@ -1340,4 +1340,66 @@ a {
padding: 5px 8px ;
}
}
}

/* stats */

.stats-produits {
tr.mois {
th {
text-align: center ;
}
}
tr.sub-head {
th {
font-weight: normal ;
font-size: 12px ;
}
}
td.nom {
text-transform: uppercase ;
}
td.align-center {
text-align: center ;
}
/*.header-fixed {
width: 100%
}

.header-fixed > thead,
.header-fixed > tbody,
.header-fixed > thead > tr,
.header-fixed > tbody > tr,
.header-fixed > thead > tr > th,
.header-fixed > tbody > tr > td {
display: block;
}

.header-fixed > tbody > tr:after,
.header-fixed > thead > tr:after {
content: ' ';
display: block;
visibility: hidden;
clear: both;
}

.header-fixed > tbody {
overflow-y: auto;
height: 150px;
}

.header-fixed > tbody > tr > td,
.header-fixed > thead > tr.sub-head > th {
width: 4.16%;
float: left;
}
.header-fixed > thead > tr.mois > th {
width: 7.69%;
float: left;
}*/
}

Loading…
취소
저장