text changes to registration mail content
[namibia] / module / PriceGuide / src / PriceGuide / DataBin / Club.php
1 <?php
2 namespace PriceGuide\DataBin;
3
4
5
6 /**
7  * Manage Club data.
8  * @author andre.fourie
9  */
10 class Club extends \Workspace\Service\DataBin
11 {
12
13         /**
14          * @var array
15          */
16         protected $meta = array(
17                         'Base'        => 'Club',
18                         'DatasetName' => 'models',
19                         'Entity'      => '\PriceGuide\Entity\Club',
20                         'References'  => array(
21                                         'company' => '\Company\Entity\Company'
22                         ),
23                         'Dependants'  => array()
24         );
25         /**
26          * @var array
27         */
28         protected $metaSelectList = array(
29                         'Type'          => 'SelectList',
30                         'Contract'      => 'Recurring',
31                         'RequiredInput' => array(),
32                         'OptionalInput' => array(
33                                         'Filter' => array(
34                                                         'company' => 'Id',
35                                                         'name'    => 'String50'
36                                         )
37                         ),
38                         'Filter'   => array(),
39                         'Label'    => array(
40                                 'Format' => '[name]',
41                                 'Fields' => array('name')
42                         )
43         );
44         /**
45          * @var array
46         */
47         protected $metaGrid = array(
48                         'Type'          => 'Grid',
49                         'Contract'      => 'Recurring',
50                         'RequiredInput' => array(),
51                         'OptionalInput' => array(
52                                         'Grid' => array(
53                                                         'NumberOfRecords' => 'Integer',
54                                                         'Page'            => 'Integer',
55                                                         'Filter'          => 'Array',
56                                                         'OrderBy'         => 'Array'
57                                         )
58                         ),
59                         'Base'            => 'club',
60                         'NumberOfRecords' => 10,
61                         'Query'           => 'SELECT [SELECTION]
62                                                                 FROM \PriceGuide\Entity\Club club
63                                                                 JOIN club.company company
64                                                                 [WHERE] [ORDER]',
65                         'Selection'       => 'club, company, SIZE(club.members) as numMembers',
66                         'Filter'          => array(
67                                                                         'club.archived' => false
68                                                                 ),
69                         'GroupBy'         => 'club.id',
70                         'OrderBy'         => array('club.name' => 'ASC'),
71                         'Fields'          => array(
72                                                                         'id',
73                                                                         'name',
74                                                                         'created' => 'DateTime',
75                                                                         'useAsDefault',
76                                                                         'numMembers'
77                                                                 )
78         );
79         /**
80          * @var array
81         */
82         protected $metaCreate = array(
83                         'Type'          => 'Create',
84                         'Contract'      => 'Recurring',
85                         'RequiredInput' => array(
86                                         'Club' => array(
87                                                         'name' => 'String50'
88                                         )
89                         ),
90                         'OptionalInput' => array(
91                                         'Club' => array(
92                                                         'useAsDefault' => 'Boolean'
93                                         )
94                         )
95         );
96         /**
97          * @var array
98         */
99         protected $metaUpdate = array(
100                         'Type'          => 'Update',
101                         'Contract'      => 'UseOnce',
102                         'RequiredInput' => array(
103                                         'Club' => array(
104                                                         'name' => 'String50'
105                                         )
106                         ),
107                         'OptionalInput' => array(
108                                         'Club' => array(
109                                                         'useAsDefault' => 'Boolean'
110                                         )
111                         )
112         );
113         /**
114          * @var array
115         */
116         protected $metaArchive = array(
117                         'Type'          => 'Update',
118                         'Contract'      => 'UseOnce',
119                         'ExecuteAfter'  => array(
120                                         'archiveClub'
121                         ),
122                         'RequiredInput' => array(),
123                         'OptionalInput' => array()
124         );
125
126
127         /**
128          * Dynamic filtering.
129          */
130         public function __construct()
131         {
132                 $authData = \Utility\Registry::getAuthData();
133                 switch (\Utility\Registry::getUserType())
134                 {
135                         case 'B4C User':
136                                 $groupFilter = \Utility\Registry::getSudo('Group', false);
137                                 $groupFilter
138                                         && $this->metaGrid['Filter']['IDENTITY(company.group)'] = $groupFilter;
139                                 $divisionFilter = \Utility\Registry::getSudo('Division', false);
140                                 $divisionFilter
141                                         && $this->metaGrid['Filter']['IDENTITY(company.groupDivision)'] = $divisionFilter;
142                                 $companyFilter = \Utility\Registry::getSudo('Company', false);
143                                 $companyFilter
144                                         && $this->metaGrid['Filter']['company.id'] = $companyFilter
145                                         && $this->metaSelectList['Filter']['company'] = \Utility\Registry::getEntityManager()
146                                                         ->getReference(
147                                                                 '\Company\Entity\Company', $companyFilter
148                                                                 );
149                                 break;
150                         case 'Group Manager':
151                                 $this->metaGrid['Filter']['IDENTITY(company.group)'] = $authData['company']['group']['id'];
152                                 $divisionFilter = \Utility\Registry::getSudo('Division', false);
153                                 $divisionFilter
154                                         && $this->metaGrid['Filter']['IDENTITY(company.groupDivision)'] = $divisionFilter;
155                                 $companyFilter = \Utility\Registry::getSudo('Company', false);
156                                 $companyFilter
157                                         && $this->metaGrid['Filter']['company.id'] = $companyFilter
158                                         && $this->metaSelectList['Filter']['company'] = \Utility\Registry::getEntityManager()
159                                                         ->getReference(
160                                                                 '\Company\Entity\Company', $companyFilter
161                                                                 );
162                                 break;
163                         case 'Division Manager':
164                                 $this->metaGrid['Filter']['IDENTITY(company.groupDivision)'] = $authData['company']['groupDivision']['id'];
165                                 $companyFilter = \Utility\Registry::getSudo('Company', false);
166                                 $companyFilter
167                                         && $this->metaGrid['Filter']['company.id'] = $companyFilter
168                                         && $this->metaSelectList['Filter']['company'] = \Utility\Registry::getEntityManager()
169                                                         ->getReference(
170                                                                 '\Company\Entity\Company', $companyFilter
171                                                                 );
172                                 break;
173                         default:
174                                 $this->metaGrid['Filter']['company.id'] = $authData['company']['id'];
175                                 $this->metaSelectList['Filter']['company'] = \Utility\Registry::getEntityManager()
176                                         ->getReference(
177                                                 '\Company\Entity\Company', $authData['company']['id']
178                                                 );
179                                 break;
180                 }
181         }
182
183 }