keun пре 7 година
родитељ
комит
e8757c6cc4
3 измењених фајлова са 21 додато и 18 уклоњено
  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 Прегледај датотеку

@@ -42,7 +42,6 @@ class StatsController extends BackendController {
$date_end = date('Y-m-d');
$data_pain = [] ;
$data_vrac = [] ;
// labels
$data_labels = [] ;
@@ -57,7 +56,6 @@ class StatsController extends BackendController {
$mois = date('m/Y',$date->getTimestamp()) ;
$data_labels[] = $mois ;
$data_pain[$mois] = 0 ;
$data_vrac[$mois] = 0 ;
}
// commandes
@@ -73,14 +71,19 @@ class StatsController extends BackendController {
if(isset($data_pain[$mois]))
{
$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', [
'data_labels' => $data_labels,
'data_pain' => $data_pain,
'data_vrac' => $data_vrac,
'data_pain' => $data_pain_noindex,
]);
}

+ 5
- 1
backend/views/layouts/main.php Прегледај датотеку

@@ -36,7 +36,6 @@ AppAsset::register($this);
'innerContainerOptions' => ['class'=>'container-fluid'],
'options' => [
'class' => 'navbar-inverse navbar-fixed-top nav-header',
],
]);
@@ -97,6 +96,11 @@ AppAsset::register($this);
'label' => '<span class="glyphicon glyphicon-euro"></span> Facturation',
'url' => ['/etablissement/facturation'],
'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 Прегледај датотеку

@@ -4,12 +4,14 @@ $this->title = 'Statistiques' ;

use dosamigos\chartjs\ChartJs;

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

?>

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

<?= ChartJs::widget([
'type' => 'Line',
'type' => 'line',
'options' => [
'height' => 400,
'width' => 1100
@@ -18,16 +20,10 @@ use dosamigos\chartjs\ChartJs;
'labels' => $data_labels,
'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",
'data' => $data_pain
]

Loading…
Откажи
Сачувај