'data_pain' => $data_pain_noindex, | '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 | |||||
]); | |||||
} | |||||
} | } | ||||
'url' => ['/stats/index'], | 'url' => ['/stats/index'], | ||||
'visible' => !Yii::$app->user->isGuest, | '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', | 'label' => '<span class="glyphicon glyphicon-wrench"></span> Développement', | ||||
'url' => ['/developpement/index'], | 'url' => ['/developpement/index'], |
<?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> |
margin-bottom: 2px; | margin-bottom: 2px; | ||||
padding: 5px 8px; | 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; | |||||
} |
padding: 5px 8px ; | 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; | |||||
}*/ | |||||
} | } |