1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Application\Bundle\DefaultBundle\Controller; |
4
|
|
|
|
5
|
|
|
use Stfalcon\Bundle\EventBundle\Entity\Event; |
6
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
7
|
|
|
use Symfony\Component\HttpFoundation\Response; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Class AnalyticsController |
11
|
|
|
*/ |
12
|
|
|
class AnalyticsController extends Controller |
13
|
|
|
{ |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Shows the dynamics of daily ticket sales |
17
|
|
|
* |
18
|
|
|
* @param Event $event |
19
|
|
|
* |
20
|
|
|
* @throws \Exception |
21
|
|
|
* |
22
|
|
|
* @return Response |
23
|
|
|
*/ |
24
|
|
|
public function showDailyDynamicsAction(Event $event) |
25
|
|
|
{ |
26
|
|
|
$analyticsService = $this->get('app.analytics.service'); |
27
|
|
|
|
28
|
|
|
// daily statistics |
29
|
|
|
$dailyData = $analyticsService->getDailyTicketsSoldData($event); |
30
|
|
|
array_unshift($dailyData, [ |
31
|
|
|
['label' => 'Date', 'type' => 'date'], |
32
|
|
|
['label' => 'Tickets sold number', 'type' => 'number'], |
33
|
|
|
]); |
34
|
|
|
|
35
|
|
|
$chart = $this->container->get('app.chart.service')->calendarChart($dailyData); |
36
|
|
|
|
37
|
|
|
// summary statistics |
38
|
|
|
$summary = $analyticsService |
39
|
|
|
->getSummaryTicketsSoldData($event); |
40
|
|
|
|
41
|
|
|
return $this->render('ApplicationDefaultBundle:Analytics:daily_dynamics.html.twig', [ |
42
|
|
|
'event' => $event, 'chart' => $chart, 'summary' => $summary, |
43
|
|
|
]); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Sales dynamics compared to past conferences (in weeks) |
48
|
|
|
* |
49
|
|
|
* @param Event $event |
50
|
|
|
* |
51
|
|
|
* @throws \Exception |
52
|
|
|
* |
53
|
|
|
* @return Response |
54
|
|
|
*/ |
55
|
|
|
public function showComparisonWithPreviousEventsAction(Event $event) |
56
|
|
|
{ |
57
|
|
|
$analyticsService = $this->get('app.analytics.service'); |
58
|
|
|
$data = $analyticsService->getDataForCompareTicketSales($event); |
59
|
|
|
|
60
|
|
|
return $this->render('ApplicationDefaultBundle:Analytics:comparison_with_previous_events.html.twig', [ |
61
|
|
|
'event' => $event, 'data' => $data, |
62
|
|
|
]); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
} |
66
|
|
|
|