@@ -101,7 +103,26 @@
{% for pair in statisticsSoldProducts %}
{ label: "{{ pair.name }}", y: {{ pair.value }} },
{% endfor %}
+ ];var dataPointsFestivals = [
+ {% for pair in statisticsFestivals %}
+ { label: "{{ pair.name }}", y: {{ pair.chiffreAffaire }} , countClients : {{ pair.clients_count }}, date: "{{ pair.date |date('Y-m-d')}}" },
+ {% endfor %}
];
+ console.log(dataPointsFestivals);
+ var chartFestival = new CanvasJS.Chart("chartContainer", {
+ title:{
+ text: "Chiffre d'affaire par festival"
+ },
+ animationEnabled: true,
+ data: [
+ {
+ // Change type to "doughnut", "line", "splineArea", etc.
+ type: "bar",
+ dataPoints: dataPointsFestivals
+ }
+ ]
+ });
+ chartFestival.render();
var chart = new CanvasJS.Chart("chartContainer", {
title:{
text: "Volume de produits vendus"
diff --git a/src/AppBundle/Controller/DefaultController.php b/src/AppBundle/Controller/DefaultController.php
index 3e33123c..d8936d39 100755
--- a/src/AppBundle/Controller/DefaultController.php
+++ b/src/AppBundle/Controller/DefaultController.php
@@ -290,8 +290,19 @@ class DefaultController extends Controller
$mySellings = $sellingRepo->findByUser($currentUser->getId());
$chiffreAffaires = 0;
+ $myFestivals = $currentUser->getFestivals();
- $productsSoldOfUser = $currentUser->getProductsSold();
+ $statisticsFestivals = [
+ ];
+
+ foreach ($myFestivals as $festival) {
+ $statisticsFestivals[]=[
+ 'date'=>$festival->getDateCreation(),
+ 'name'=>$festival->getName(),
+ 'clients_count' => count($festival->getSellRecords()),
+ 'chiffreAffaire'=>$festival->getChiffreAffaire(),
+ ];
+ }
$statisticsSoldProducts = [
// ['name' => 'bidule', 'count' => 0, 'value' => 0],
];
@@ -312,20 +323,15 @@ class DefaultController extends Controller
];
}
-// echo '
';
-// var_dump(intval($product->getPrice()));
-// echo '
';
$statisticsSoldProducts[$product->getName()]['count']++;
$statisticsSoldProducts[$product->getName()]['value'] = $statisticsSoldProducts[$product->getName()]['value'] + intval($product->getPrice());
}
}
-// echo '
';
-// var_dump($statisticsSoldProducts);
-// echo '
';
return $this->render('logged/history.html.twig',
[
+ 'statisticsFestivals' => $statisticsFestivals,
'statisticsSoldProducts' => $statisticsSoldProducts,
'chiffreAffaires' => $chiffreAffaires,
'recentSells' => $mySellings,