text changes to registration mail content
[namibia] / module / Statistical / src / Statistical / Service / Statistical.php
1 <?php
2 namespace Statistical\Service;
3
4
5
6 /**
7  * Manage Statistical data.
8  * @author andre.fourie
9  */
10 class Statistical extends \Workspace\Service\DataBin
11 {
12
13         /**
14          * @var array
15          */
16         protected $meta = array(
17                         'Base'          => 'Statistical',
18                         'DatasetName'   => 'statistical',
19                         'Entity'        => '\Statistical\Entity\Statistical',
20                         'References'    => array(),
21                         
22         );
23         /**
24          * @var array
25         */
26         protected $metaList = array(
27                         'Contract'              => 'Recurring',
28                         'RequiredInput'         => array(),
29                         'OptionalInput'         => array(
30                                         'Filter'        => array(
31                                                         'stock'                 => 'Id',
32                                                         'dealdone'              => 'Boolean',
33                                                         'dealnotdone'       => 'Boolean',
34                                                         'tradecentre'       => 'Boolean',
35                                                         'fromProfile'       => 'Id',
36                                                         'created'               => 'Date',
37                                         )
38                         ),
39                         'Filter' => array(),
40                         'Fields' => array(
41                                 'stock',
42                                 'dealdone',
43                                 'dealnotdone',
44                                 'tradecentre',
45                                 'fromProfile',
46                                 'created'
47                         ),
48                         'Expand' => array()
49         );
50         
51         /**
52          * @var array
53         */
54         protected $metaCreate = array(
55                         'Contract'              => 'Recurring',
56                         'RequiredInput' => array(
57                                                         'stock'                         => 'Id',
58                                                         'created'               => 'Date'
59                         ),
60                         'OptionalInput' => array(
61                                                         'dealdone'              => 'Boolean',
62                                                         'dealnotdone'       => 'Boolean',
63                                                         'tradecentre'       => 'Boolean',
64                                                         'fromProfile'       => 'Id'
65                                         
66                         )
67         );
68
69
70         public function clickReport()
71         {
72                 $counts = $this->em->createQuery(
73                                 'SELECT c.bannerId, COUNT(c.id) AS total '
74                                 . 'FROM \\Statistical\\Entity\\Click c '
75                                 . 'WHERE c.created >= :minDate '
76                                 . 'GROUP BY c.bannerId'
77                         )
78                         ->setParameter('minDate', date('Y-m-') . '01 00:00:00')
79                         ->getScalarResult();
80                 $data = array();
81                 $data[] = '<h4>Click report for ' . date('Y-m') . '</h4>';
82                 $data[] = '<br/>';
83                 foreach ($counts as $count)
84                 {
85                         $data[] = $count['bannerId'] . ': ' . $count['total'] . '<br/>';
86                 }
87                 $data[] = '<br/>';
88                 $data[] = '<br/>';
89
90                 $oNotify = new \Utility\Comms\Notification();
91                 $oNotify->sendBasicEmail(
92                         'info@bid4cars.com.na',
93                         'Click report for ' . date('Y-m'),
94                         implode('', $data)
95                 );
96         }
97         
98         
99
100 }