text changes to registration mail content
[namibia] / module / Stock / src / Stock / DataBin / Tuhpi.php
1 <?php
2 namespace Stock\DataBin;
3
4
5
6 /**
7  * Manage Trans Union HPI data.
8  * @author andre.fourie
9  */
10 class Tuhpi extends \Workspace\Service\DataBin
11 {
12
13         /**
14          * @var array
15          */
16         protected $meta = array(
17                         'Base'        => 'Stock',
18                         'DatasetName' => 'stock',
19                         'Entity'      => '\Stock\Entity\Tuhpi',
20                         'References'  => array(
21
22                                         'company'               => '\Company\Entity\Company',
23                                         'valuation'             => '\Valuation\Entity\Valuation',
24                                         'priceGuide'                    => '\PriceGuide\Entity\PriceGuide',
25                                         'auction'                       => '\Auction\Entity\Auction',
26
27                         ),
28                         'Dependants'  => array(
29                                         'stock'                         => '\Stock\Entity\Stock'
30                         )
31         );
32         /**
33          * @var array
34         */
35         protected $metaList = array(
36                         'Type'          => 'List',
37                         'Contract'      => 'Recurring',
38                         'RequiredInput' => array(),
39                         'OptionalInput' => array(
40                                         'Filter' => array(
41                                                         'created'               => 'Date',
42                                                         'updated'               => 'Date',
43                                                         'jobState'              => 'String25',
44                                                         'stock'                                 => 'Id',
45                                                         'company'                               => 'Id'
46                                         )
47                         ),
48                         'Filter' => array(),
49                         'OrderBy' => array('created' => 'DESC'),
50                         'Fields' => array(
51                                         'id',
52                                         'created',
53                     'hpi_type'
54                         ),
55                         'Expand' => array()
56         );
57         /**
58          * @var array
59         */
60         protected $metaGrid = array(
61                         'Type'          => 'Grid',
62                         'Export'        => true,
63
64
65                         'Contract'      => 'Recurring',
66                         'Options'       => array(),
67                         'RequiredInput' => array(),
68                         'OptionalInput' => array(
69                                         'Grid' => array(
70                                                         'NumberOfRecords' => 'Integer',
71                                                         'Page'            => 'Integer',
72                                                         'Filter'          => 'Array',
73                                                         'OrderBy'         => 'Array',
74                                         )
75                         ),
76                         'Base'            => 'tuhpi',
77                         'NumberOfRecords' => 20,
78                         'Query'           => 'SELECT [SELECTION]
79                                                                 FROM \Stock\Entity\Tuhpi tuhpi
80                                                                 JOIN tuhpi.stock stock
81                                                                 JOIN tuhpi.company company
82                                                                 JOIN stock.vehicleYear vehicleYear
83                                                                 JOIN stock.type type
84                                                                 JOIN type.model model
85                                                                 JOIN model.make make
86                                                                 LEFT JOIN tuhpi.auction auction
87                                                                 LEFT JOIN tuhpi.priceGuide priceGuide
88                                                                 LEFT JOIN company.group companyGroup
89                                                                 LEFT JOIN company.groupDivision groupDivision
90                                                                 LEFT JOIN stock.exteriorColour exteriorColour
91                                                                 [WHERE] [ORDER]',
92                         'Selection'       => 'tuhpi, stock, company, companyGroup, groupDivision, auction, priceGuide, exteriorColour, vehicleYear, make, model, type',
93                         'Filter'          => array(
94                                                                         'tuhpi.archived' => false
95                                                                 ),
96                         'OrderBy'         => array('tuhpi.created' => 'DESC'),
97                         'Fields'          => array(
98                                                                         'id',
99                                                                         'referenceNumber',
100                                                                         'created' => 'DateTime',
101                                                                         'registrationNumber',
102                                                                         'vinNumber',
103                                                                         'type' => array(
104                                                                                 'name',
105                                                                                 'mmCode',
106                                                                                 'model' => array(
107                                                                                         'name',
108                                                                                         'make' => array(
109                                                                                                 'name'
110                                                                                         )
111                                                                                 ),
112                                                                         ),
113                                                                         'vehicleYear' => array(
114                                                                                 'name'
115                                                                         ),
116                                                                         'exteriorColour' => array(
117                                                                                 'name'
118                                                                         ),
119                                                                         'priceGuide' => array(
120                                                                                 'id'
121                                                                         ),
122                                                                         'km',
123                                                                         'tradePrice',
124                                                                         'retailPrice',
125                                                                         'retailAmountRequired',
126                                                                         'jobState'
127                                                                 )
128         );
129
130         /**
131          * @var array
132          */
133         protected $metaView = array(
134                         'Type'      => 'View',
135                         'Expand'    => array(
136                                         'group',
137                                         'groupDivision',
138                                         'model',
139                                         'make',
140                                         'type'
141                         ),
142                         'Intersect' => array()
143         );
144         /**
145          * @var array
146         */
147         protected $metaCreate = array(
148                         'Type'     => 'Create',
149                         'Contract' => 'Recurring',
150                         'ExecuteBefore' => array(),
151                         'ExecuteAfter' => array(),
152                         'RequiredInput' => array(
153                                         'tuhpi' => array(
154                                                         'company'                       => 'Id',
155                                                         'createdBy'             => 'Id',
156                                                         'stock'                                 => 'Id'
157                                         )
158                         ),
159                         'OptionalInput' => array(
160                                         'tuhpi' => array()
161                         )
162         );
163
164         /**
165          * @var array
166          */
167         protected $metaPrint = array(
168                         'Type'          => 'Pdf',
169                         'Builder'       => '\Stock\Pdf\Tuhpi',
170                         'Writer'        => '\Utility\Export\PdfTemplate',
171                         'Output'        => 'Download',
172                         'FilePath'        => '\test.pdf',
173                         'RequiredInput' => array(),
174                         'OptionalInput' => array(
175                                         'PdfTemplate' => array(
176                                                         'email' => 'Email',
177                             'recordId' => 'Id'
178                                         )
179                         )
180         );
181
182     /**
183      * @var array
184      */
185     protected $metaPrintAccident = array(
186         'Type'          => 'Pdf',
187         'Builder'       => '\Stock\Pdf\TuhpiAccident',
188         'Writer'        => '\Utility\Export\PdfTemplate',
189         'Output'        => 'Download',
190         'FilePath'        => '\testAccident.pdf',
191         'RequiredInput' => array(),
192         'OptionalInput' => array(
193             'PdfTemplate' => array(
194                 'email' => 'Email',
195                 'recordId' => 'Id'
196             )
197         )
198     );
199
200
201         /**
202          * Add some dynamic filtering to our grids.
203          */
204         public function __construct()
205         {
206                 $authData = \Utility\Registry::getAuthData();
207                 $logedInCompanyId = $authData['company']['id'];
208                 switch (\Utility\Registry::getUserType())
209                 {
210                         case 'B4C User':
211                                 $groupFilter = \Utility\Registry::getSudo('Group', false);
212                                 $groupFilter
213                                         && $this->metaGrid['Filter']['IDENTITY(company.group)'] = $groupFilter;
214                                 $divisionFilter = \Utility\Registry::getSudo('Division', false);
215                                 $divisionFilter
216                                         && $this->metaGrid['Filter']['IDENTITY(company.groupDivision)'] = $divisionFilter;
217                                 $companyFilter = \Utility\Registry::getSudo('Company', false);
218                                 $companyFilter
219                                         && $this->metaGrid['Filter']['company.id'] = $companyFilter;
220                                 $companyFilter
221                                         && $this->metaTradeCenterGrid['Filter']['IDENTITY(company.tradeCenter)'] = $companyFilter;
222                                 break;
223                         case 'Group User':
224                                 $this->metaGrid['Filter']['IDENTITY(company.group)'] = $authData['company']['group']['id'];
225                                 $divisionFilter = \Utility\Registry::getSudo('Division', false);
226                                 $divisionFilter
227                                         && $this->metaGrid['Filter']['IDENTITY(company.groupDivision)'] = $divisionFilter;
228                                 $companyFilter = \Utility\Registry::getSudo('Company', false);
229                                 $companyFilter
230                                         && $this->metaGrid['Filter']['company.id'] = $companyFilter;
231                                 $companyFilter
232                                         && $this->metaTradeCenterGrid['Filter']['IDENTITY(company.tradeCenter)'] = $companyFilter;
233                                 break;
234                         case 'Dealer Principle':
235                                 $this->metaGrid['Filter']['IDENTITY(company.groupDivision)'] = $authData['company']['groupDivision']['id'];
236                                 $companyFilter = \Utility\Registry::getSudo('Company', false);
237                                 $companyFilter
238                                         && $this->metaGrid['Filter']['company.id'] = $companyFilter;
239                                 $companyFilter
240                                         && $this->metaTradeCenterGrid['Filter']['IDENTITY(company.tradeCenter)'] = $companyFilter;
241                                 break;
242                         default:
243
244                                 //$this->metaList['OptionalInput']['Filter']['company'] = $authData['company']['id'];
245                                 $this->metaGrid['Filter']['company.id'] = $authData['company']['id'];
246                                 $this->metaTradeCenterGrid['Filter']['IDENTITY(company.tradeCenter)'] = $authData['company']['id'];
247                                 break;
248                 }
249         }
250
251 }