show with canevas some statistics
This commit is contained in:
parent
70bbc42b93
commit
fe4f202bed
|
@ -22,7 +22,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if not (app.user.products |length) %}
|
{% if not (app.user.products |length) %}
|
||||||
<div class="alert alert-info">
|
<div class="alert alert-info" ng-if="!productsFromDB.length && initLoadDone">
|
||||||
|
|
||||||
<i class="fa fa-info"></i>
|
<i class="fa fa-info"></i>
|
||||||
Créez facilement vos catégories de produits et vos produits juste en écrivant un nom par ligne dans
|
Créez facilement vos catégories de produits et vos produits juste en écrivant un nom par ligne dans
|
||||||
|
|
|
@ -7,6 +7,10 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<h1>Historique</h1>
|
<h1>Historique</h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="chartContainer" style="display: inline-block; height: 300px; width: 49%;"></div>
|
||||||
|
<div id="chartContainerChiffreAffaire" style="display: inline-block; height: 300px; width: 49%;"></div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-6">
|
<div class="col-xs-6">
|
||||||
<div class="sells">
|
<div class="sells">
|
||||||
|
@ -83,4 +87,48 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
|
||||||
|
<script>
|
||||||
|
|
||||||
|
var dataPoints = [
|
||||||
|
{% for pair in statisticsSoldProducts %}
|
||||||
|
{ label: "{{ pair.name }}", y: {{ pair.count }} },
|
||||||
|
{% endfor %}
|
||||||
|
];
|
||||||
|
var dataPointsChiffreAffaire = [
|
||||||
|
{% for pair in statisticsSoldProducts %}
|
||||||
|
{ label: "{{ pair.name }}", y: {{ pair.value }} },
|
||||||
|
{% endfor %}
|
||||||
|
];
|
||||||
|
var chart = new CanvasJS.Chart("chartContainer", {
|
||||||
|
title:{
|
||||||
|
text: "Volume de produits vendus"
|
||||||
|
},
|
||||||
|
animationEnabled: true,
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
// Change type to "doughnut", "line", "splineArea", etc.
|
||||||
|
type: "pie",
|
||||||
|
dataPoints: dataPoints
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
chart.render();
|
||||||
|
var chartContainerChiffreAffaire = new CanvasJS.Chart("chartContainerChiffreAffaire", {
|
||||||
|
title:{
|
||||||
|
text: "Valeur en euros des produits vendus"
|
||||||
|
},
|
||||||
|
animationEnabled: true,
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
// Change type to "doughnut", "line", "splineArea", etc.
|
||||||
|
type: "pie",
|
||||||
|
dataPoints: dataPointsChiffreAffaire
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
chartContainerChiffreAffaire.render();
|
||||||
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
|
// require('../../../node_modules/canvasjs/dist/canvasjs.3');
|
||||||
|
|
||||||
|
|
||||||
var $ = require('jquery');
|
var $ = require('jquery');
|
||||||
// JS is equivalent to the normal "bootstrap" package
|
// JS is equivalent to the normal "bootstrap" package
|
||||||
// no need to set this to a variable, just require it
|
// no need to set this to a variable, just require it
|
||||||
require('bootstrap-sass');
|
require('bootstrap-sass');
|
||||||
|
|
||||||
// or you can include specific pieces
|
// or you can include specific pieces
|
||||||
// require('bootstrap-sass/javascripts/bootstrap/tooltip');
|
// require('bootstrap-sass/javascripts/bootstrap/tooltip');
|
||||||
// require('bootstrap-sass/javascripts/bootstrap/popover');
|
// require('bootstrap-sass/javascripts/bootstrap/popover');
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"angular": "1.5",
|
"angular": "1.5",
|
||||||
"bootstrap": "^4.0.0",
|
"bootstrap": "^4.0.0",
|
||||||
|
"canvasjs": "^1.8.1",
|
||||||
"font-awesome": "^4.7.0",
|
"font-awesome": "^4.7.0",
|
||||||
"jquery": "1.12.2"
|
"jquery": "1.12.2"
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,18 +14,21 @@ use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
|
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
|
||||||
|
|
||||||
class DefaultController extends Controller {
|
class DefaultController extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
private $tokenManager;
|
private $tokenManager;
|
||||||
|
|
||||||
public function __construct( CsrfTokenManagerInterface $tokenManager = null ) {
|
public function __construct(CsrfTokenManagerInterface $tokenManager = null)
|
||||||
|
{
|
||||||
$this->tokenManager = $tokenManager;
|
$this->tokenManager = $tokenManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route("/", name="homepage")
|
* @Route("/", name="homepage")
|
||||||
*/
|
*/
|
||||||
public function indexAction( Request $request ) {
|
public function indexAction(Request $request)
|
||||||
|
{
|
||||||
$m = $this->getDoctrine()->getManager();
|
$m = $this->getDoctrine()->getManager();
|
||||||
$userRepo = $m->getRepository('AppBundle:User');
|
$userRepo = $m->getRepository('AppBundle:User');
|
||||||
$allUsers = $userRepo->findAll();
|
$allUsers = $userRepo->findAll();
|
||||||
|
@ -41,7 +44,8 @@ class DefaultController extends Controller {
|
||||||
/**
|
/**
|
||||||
* @Route("/dashboard", name="dashboard")
|
* @Route("/dashboard", name="dashboard")
|
||||||
*/
|
*/
|
||||||
public function dashboardAction( Request $request ) {
|
public function dashboardAction(Request $request)
|
||||||
|
{
|
||||||
$m = $this->getDoctrine()->getManager();
|
$m = $this->getDoctrine()->getManager();
|
||||||
$currentUser = $this->getUser();
|
$currentUser = $this->getUser();
|
||||||
|
|
||||||
|
@ -77,7 +81,8 @@ class DefaultController extends Controller {
|
||||||
/**
|
/**
|
||||||
* envoyer un email
|
* envoyer un email
|
||||||
*/
|
*/
|
||||||
public function emailAction() {
|
public function emailAction()
|
||||||
|
{
|
||||||
$name = "noble barbare";
|
$name = "noble barbare";
|
||||||
$message = \Swift_Message::newInstance()
|
$message = \Swift_Message::newInstance()
|
||||||
->setSubject('Hello Email')
|
->setSubject('Hello Email')
|
||||||
|
@ -99,7 +104,8 @@ class DefaultController extends Controller {
|
||||||
* get user products
|
* get user products
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
*/
|
*/
|
||||||
public function getMyProductsAction() {
|
public function getMyProductsAction()
|
||||||
|
{
|
||||||
$m = $this->getDoctrine()->getManager();
|
$m = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
|
|
||||||
|
@ -194,7 +200,8 @@ class DefaultController extends Controller {
|
||||||
*
|
*
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
*/
|
*/
|
||||||
public function addSellingAction( Request $request ) {
|
public function addSellingAction(Request $request)
|
||||||
|
{
|
||||||
|
|
||||||
$json = json_decode($request->getContent(), true);
|
$json = json_decode($request->getContent(), true);
|
||||||
$currentUser = $this->getUser();
|
$currentUser = $this->getUser();
|
||||||
|
@ -275,20 +282,51 @@ class DefaultController extends Controller {
|
||||||
* get the history of user's sellings
|
* get the history of user's sellings
|
||||||
* @Route("/history", name="history")
|
* @Route("/history", name="history")
|
||||||
*/
|
*/
|
||||||
public function historyAction() {
|
public function historyAction()
|
||||||
|
{
|
||||||
$currentUser = $this->getUser();
|
$currentUser = $this->getUser();
|
||||||
$m = $this->getDoctrine()->getManager();
|
$m = $this->getDoctrine()->getManager();
|
||||||
$sellingRepo = $m->getRepository('AppBundle:SellRecord');
|
$sellingRepo = $m->getRepository('AppBundle:SellRecord');
|
||||||
$mySellings = $sellingRepo->findByUser($currentUser->getId());
|
$mySellings = $sellingRepo->findByUser($currentUser->getId());
|
||||||
$chiffreAffaires = 0;
|
$chiffreAffaires = 0;
|
||||||
|
|
||||||
|
|
||||||
|
$productsSoldOfUser = $currentUser->getProductsSold();
|
||||||
|
$statisticsSoldProducts = [
|
||||||
|
// ['name' => 'bidule', 'count' => 0, 'value' => 0],
|
||||||
|
];
|
||||||
|
|
||||||
|
$statsForFestival = [
|
||||||
|
['name' => 'festoche bidule', 'clients_count' => 125, 'chiffre_affaire' => 236],
|
||||||
|
];
|
||||||
foreach ($mySellings as $client) {
|
foreach ($mySellings as $client) {
|
||||||
foreach ($client->getProductsSold() as $product) {
|
foreach ($client->getProductsSold() as $product) {
|
||||||
$chiffreAffaires += $product->getPrice();
|
$chiffreAffaires += $product->getPrice();
|
||||||
|
|
||||||
|
if (!isset($statisticsSoldProducts[$product->getName()])) {
|
||||||
|
$statisticsSoldProducts[$product->getName()] =
|
||||||
|
[
|
||||||
|
'name' => $product->getName(),
|
||||||
|
'count' => 0,
|
||||||
|
'value' => 0
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// echo '<pre>';
|
||||||
|
// var_dump(intval($product->getPrice()));
|
||||||
|
// echo '</pre>';
|
||||||
|
$statisticsSoldProducts[$product->getName()]['count']++;
|
||||||
|
$statisticsSoldProducts[$product->getName()]['value'] = $statisticsSoldProducts[$product->getName()]['value'] + intval($product->getPrice());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// echo '<pre>';
|
||||||
|
// var_dump($statisticsSoldProducts);
|
||||||
|
// echo '</pre>';
|
||||||
|
|
||||||
return $this->render('logged/history.html.twig',
|
return $this->render('logged/history.html.twig',
|
||||||
[
|
[
|
||||||
|
'statisticsSoldProducts' => $statisticsSoldProducts,
|
||||||
'chiffreAffaires' => $chiffreAffaires,
|
'chiffreAffaires' => $chiffreAffaires,
|
||||||
'recentSells' => $mySellings,
|
'recentSells' => $mySellings,
|
||||||
'base_dir' => realpath($this->getParameter('kernel.project_dir')) . DIRECTORY_SEPARATOR,
|
'base_dir' => realpath($this->getParameter('kernel.project_dir')) . DIRECTORY_SEPARATOR,
|
||||||
|
@ -299,7 +337,8 @@ class DefaultController extends Controller {
|
||||||
* export all clients
|
* export all clients
|
||||||
* @Route("/export-all", name="export_all")
|
* @Route("/export-all", name="export_all")
|
||||||
*/
|
*/
|
||||||
public function exportAllAction() {
|
public function exportAllAction()
|
||||||
|
{
|
||||||
// TODO
|
// TODO
|
||||||
$currentUser = $this->getUser();
|
$currentUser = $this->getUser();
|
||||||
$m = $this->getDoctrine()->getManager();
|
$m = $this->getDoctrine()->getManager();
|
||||||
|
@ -397,7 +436,8 @@ class DefaultController extends Controller {
|
||||||
/**
|
/**
|
||||||
* @Route("/set-active-festival/{id}", name="set_active_festival")
|
* @Route("/set-active-festival/{id}", name="set_active_festival")
|
||||||
*/
|
*/
|
||||||
public function setActiveFestivalAction( $id ) {
|
public function setActiveFestivalAction($id)
|
||||||
|
{
|
||||||
$currentUser = $this->getUser();
|
$currentUser = $this->getUser();
|
||||||
$m = $this->getDoctrine()->getManager();
|
$m = $this->getDoctrine()->getManager();
|
||||||
$repo = $m->getRepository('AppBundle:Festival');
|
$repo = $m->getRepository('AppBundle:Festival');
|
||||||
|
@ -413,7 +453,8 @@ class DefaultController extends Controller {
|
||||||
/**
|
/**
|
||||||
* @Route("/import", name="import")
|
* @Route("/import", name="import")
|
||||||
*/
|
*/
|
||||||
public function importAction() {
|
public function importAction()
|
||||||
|
{
|
||||||
$currentUser = $this->getUser();
|
$currentUser = $this->getUser();
|
||||||
$m = $this->getDoctrine()->getManager();
|
$m = $this->getDoctrine()->getManager();
|
||||||
$sellingRepo = $m->getRepository('AppBundle:SellRecord');
|
$sellingRepo = $m->getRepository('AppBundle:SellRecord');
|
||||||
|
@ -427,7 +468,8 @@ class DefaultController extends Controller {
|
||||||
/**
|
/**
|
||||||
* @Route("/mass-create", name="mass_create")
|
* @Route("/mass-create", name="mass_create")
|
||||||
*/
|
*/
|
||||||
public function massCreateAction( Request $request ) {
|
public function massCreateAction(Request $request)
|
||||||
|
{
|
||||||
$currentUser = $this->getUser();
|
$currentUser = $this->getUser();
|
||||||
$m = $this->getDoctrine()->getManager();
|
$m = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
|
|
|
@ -1078,6 +1078,10 @@ caniuse-lite@^1.0.30000792:
|
||||||
version "1.0.30000819"
|
version "1.0.30000819"
|
||||||
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000819.tgz#aabee5fd15a080febab6ae5d30c9ea15f4c6d4e2"
|
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000819.tgz#aabee5fd15a080febab6ae5d30c9ea15f4c6d4e2"
|
||||||
|
|
||||||
|
canvasjs@^1.8.1:
|
||||||
|
version "1.8.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/canvasjs/-/canvasjs-1.8.1.tgz#698a4e002e336ce83ef2f9101a6bd276ba7657a3"
|
||||||
|
|
||||||
caseless@~0.11.0:
|
caseless@~0.11.0:
|
||||||
version "0.11.0"
|
version "0.11.0"
|
||||||
resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.11.0.tgz#715b96ea9841593cc33067923f5ec60ebda4f7d7"
|
resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.11.0.tgz#715b96ea9841593cc33067923f5ec60ebda4f7d7"
|
||||||
|
|
Loading…
Reference in New Issue