Browse Source

Page statistiques

master
keun 7 years ago
parent
commit
e8757c6cc4
3 changed files with 21 additions and 18 deletions
  1. +8
    -5
      backend/controllers/StatsController.php
  2. +5
    -1
      backend/views/layouts/main.php
  3. +8
    -12
      backend/views/stats/index.php

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

$date_end = date('Y-m-d'); $date_end = date('Y-m-d');
$data_pain = [] ; $data_pain = [] ;
$data_vrac = [] ;
// labels // labels
$data_labels = [] ; $data_labels = [] ;
$mois = date('m/Y',$date->getTimestamp()) ; $mois = date('m/Y',$date->getTimestamp()) ;
$data_labels[] = $mois ; $data_labels[] = $mois ;
$data_pain[$mois] = 0 ; $data_pain[$mois] = 0 ;
$data_vrac[$mois] = 0 ;
} }
// commandes // commandes
if(isset($data_pain[$mois])) if(isset($data_pain[$mois]))
{ {
$data_pain[$mois] += $c->montant_pain ; $data_pain[$mois] += $c->montant_pain ;
$data_vrac[$mois] += $c->montant_vrac ;
} }
} }
// création d'un tableau sans index car chart.js n'accepte pas les index
$data_pain_noindex = [] ;
foreach($data_pain as $key => $val)
{
$data_pain_noindex[] = $val ;
}
return $this->render('index', [ return $this->render('index', [
'data_labels' => $data_labels, 'data_labels' => $data_labels,
'data_pain' => $data_pain,
'data_vrac' => $data_vrac,
'data_pain' => $data_pain_noindex,
]); ]);
} }

+ 5
- 1
backend/views/layouts/main.php View File

'innerContainerOptions' => ['class'=>'container-fluid'], 'innerContainerOptions' => ['class'=>'container-fluid'],
'options' => [ 'options' => [
'class' => 'navbar-inverse navbar-fixed-top nav-header', 'class' => 'navbar-inverse navbar-fixed-top nav-header',
], ],
]); ]);
'label' => '<span class="glyphicon glyphicon-euro"></span> Facturation', 'label' => '<span class="glyphicon glyphicon-euro"></span> Facturation',
'url' => ['/etablissement/facturation'], 'url' => ['/etablissement/facturation'],
'visible'=> !Yii::$app->user->isGuest, 'visible'=> !Yii::$app->user->isGuest,
],
[
'label' => '<span class="glyphicon glyphicon-stats"></span> Statistiques',
'url' => ['/stats/index'],
'visible'=> !Yii::$app->user->isGuest,
] ]
], ],
] ]

+ 8
- 12
backend/views/stats/index.php View File



use dosamigos\chartjs\ChartJs; use dosamigos\chartjs\ChartJs;


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

?> ?>


<h2>Recettes des commandes (pain / vrac)</h2>
<h1>Statistiques</h1>


<?= ChartJs::widget([ <?= ChartJs::widget([
'type' => 'Line',
'type' => 'line',
'options' => [ 'options' => [
'height' => 400, 'height' => 400,
'width' => 1100 'width' => 1100
'labels' => $data_labels, 'labels' => $data_labels,
'datasets' => [ 'datasets' => [
[ [
'fillColor' => "rgba(220,220,220,0.5)",
'strokeColor' => "rgba(220,220,220,1)",
'pointColor' => "rgba(220,220,220,1)",
'pointStrokeColor' => "#fff",
'data' => $data_vrac
],
[
'fillColor' => "rgba(253,212,75,0.5)",
'strokeColor' => "rgba(253,212,75,1)",
'pointColor' => "rgba(253,212,75,1)",
'label' => 'Recettes commandes',
'backgroundColor' => "rgb(187,135,87,0.5)",
'borderColor' => "rgb(187,135,87,1)",
'pointBackgroundColor' => "rgb(187,135,87,1)",
'pointStrokeColor' => "#fff", 'pointStrokeColor' => "#fff",
'data' => $data_pain 'data' => $data_pain
] ]

Loading…
Cancel
Save