text changes to registration mail content
[namibia] / module / Dispute / src / Dispute / DataBin / Dispute.php
1 <?php
2 namespace Dispute\DataBin;
3
4
5
6 /**
7  * Manage Dispute data.
8  * @author andre.fourie
9  */
10 class Dispute extends \Workspace\Service\DataBin
11 {
12
13         /**
14          * @var array
15          */
16         protected $meta = array(
17             'Base'        => 'Dispute',
18             'DatasetName' => 'valuations',
19             'Entity'      => '\Dispute\Entity\Dispute',
20             'References'  => array(
21                 'auction'        => '\Auction\Entity\Auction',
22                 'createdBy'      => '\User\Entity\Profile',
23                 'fromCompany'    => '\Company\Entity\Company',
24                 'againstCompany' => '\Company\Entity\Company'
25             ),
26             'Dependants'  => array()
27         );
28         /**
29          * @var array
30         */
31         protected $metaAdminGrid = array(
32             'Type'          => 'Grid',
33                 'Export'        => true,
34                 'Builder'       => '\Dispute\Report\DisputeGrid',
35                 'Writer'        => '\Utility\Export\ExcelReport',
36                 'Output'        => 'Download',
37             'Contract'      => 'Recurring',
38                 'Options'       => array(
39                                 'Boolean' => array(
40                                                 'ExportToExcel' => false
41                                 )
42                 ),
43             'RequiredInput' => array(),
44             'OptionalInput' => array(
45                 'Grid'  => array(
46                     'NumberOfRecords' => 'Integer',
47                     'Page'            => 'Integer',
48                     'Filter'          => 'Array',
49                     'OrderBy'         => 'Array'
50                 )
51             ),
52             'Base'            => 'dispute',
53             'NumberOfRecords' => 10,
54         'Query'           => 'SELECT [SELECTION]
55                                               FROM \Dispute\Entity\Dispute dispute
56                                                           JOIN dispute.fromCompany fromCompany
57                                                           JOIN dispute.againstCompany againstCompany
58                                                           JOIN dispute.auction auction
59                                                           JOIN auction.stock stock
60                                                           JOIN stock.vehicleYear vehicleYear
61                                                           JOIN stock.type type
62                                                           JOIN type.model model
63                                                           JOIN model.make make
64                                               [WHERE] [ORDER]',
65             'Selection'       => 'dispute, fromCompany, againstCompany, auction, stock, vehicleYear, make, model, type',
66             'Filter'          => array(),
67             'OrderBy'         => array('dispute.created' => 'DESC'),
68             'Fields'          => array(
69                                                 'id',
70                                                 'created' => 'DateTime',
71                                                 'jobState',
72                                                 'fromCompany' => array(
73                                                     'name'
74                                                 ),
75                                                 'againstCompany' => array(
76                                                     'name'
77                                                 ),
78                                                 'auction' => array(
79                                                         'id',
80                                                         'currentBidPrice',
81                                                         'endDate' => 'DateTime',
82                                                         'stock' => array(
83                                                             'created' => 'DateTime',
84                                                             'type' => array(
85                                                                 'name',
86                                                                 'model' => array(
87                                                                     'name',
88                                                                     'make' => array(
89                                                                           'name'
90                                                                     )
91                                                                 ),
92                                                             ),
93                                                             'vehicleYear' => array(
94                                                                 'name'
95                                                             ),
96                                                             'km',
97                                                             'tradePrice',
98                                                             'retailPrice',
99                                         'listPrice'
100                                                         )
101                                                 )
102                                             )
103         );
104         /**
105          * @var array
106         */
107         protected $metaGrid = array(
108             'Type'          => 'Grid',
109                 'Export'        => true,
110                 'Builder'       => '\Dispute\Report\DisputeGrid',
111                 'Writer'        => '\Utility\Export\ExcelReport',
112                 'Output'        => 'Download',
113             'Contract'      => 'Recurring',
114                 'Options'       => array(
115                                 'Boolean' => array(
116                                                 'ExportToExcel' => false
117                                 )
118                 ),
119             'RequiredInput' => array(),
120             'OptionalInput' => array(
121                 'Grid'  => array(
122                     'NumberOfRecords' => 'Integer',
123                     'Page'            => 'Integer',
124                     'Filter'          => 'Array',
125                     'OrderBy'         => 'Array'
126                 )
127             ),
128             'Base'            => 'dispute',
129             'NumberOfRecords' => 10,
130         'Query'           => 'SELECT [SELECTION]
131                                               FROM \Dispute\Entity\Dispute dispute
132                                                           JOIN dispute.fromCompany fromCompany
133                                                           JOIN dispute.againstCompany againstCompany
134                                                           JOIN dispute.auction auction
135                                                           JOIN auction.stock stock
136                                                           JOIN stock.vehicleYear vehicleYear
137                                                           JOIN stock.type type
138                                                           JOIN type.model model
139                                                           JOIN model.make make
140                                               [WHERE] [ORDER]',
141             'Selection'       => 'dispute, fromCompany, againstCompany, auction, stock, vehicleYear, make, model, type',
142             'Filter'          => array(),
143             'OrderBy'         => array('dispute.created' => 'DESC'),
144             'Fields'          => array(
145                                                 'id',
146                                                 'created' => 'DateTime',
147                                                 'jobState',
148                                                 'fromCompany' => array(
149                                                     'name'
150                                                 ),
151                                                 'againstCompany' => array(
152                                                     'name'
153                                                 ),
154                                                 'auction' => array(
155                                                         'id',
156                                                         'currentBidPrice',
157                                                         'endDate' => 'DateTime',
158                                                         'stock' => array(
159                                                             'created' => 'DateTime',
160                                                             'type' => array(
161                                                                 'name',
162                                                                 'model' => array(
163                                                                     'name',
164                                                                     'make' => array(
165                                                                           'name'
166                                                                     )
167                                                                 ),
168                                                             ),
169                                                             'vehicleYear' => array(
170                                                                 'name'
171                                                             ),
172                                                             'km',
173                                                             'tradePrice',
174                                                             'retailPrice',
175                                         'listPrice'
176                                                         )
177                                                 )
178                                             )
179         );
180   
181   /**
182          * @var array
183         */
184         protected $metaGridDef = array(
185             'Type'          => 'Grid',
186                 'Export'        => true,
187                 'Builder'       => '\Dispute\Report\DisputeGrid',
188                 'Writer'        => '\Utility\Export\ExcelReport',
189                 'Output'        => 'Download',
190             'Contract'      => 'Recurring',
191                 'Options'       => array(
192                                 'Boolean' => array(
193                                                 'ExportToExcel' => false
194                                 )
195                 ),
196             'RequiredInput' => array(),
197             'OptionalInput' => array(
198                 'Grid'  => array(
199                     'NumberOfRecords' => 'Integer',
200                     'Page'            => 'Integer',
201                     'Filter'          => 'Array',
202                     'OrderBy'         => 'Array'
203                 )
204             ),
205             'Base'            => 'dispute',
206             'NumberOfRecords' => 10,
207         'Query'           => 'SELECT [SELECTION]
208                                               FROM \Dispute\Entity\Dispute dispute
209                                                           JOIN dispute.fromCompany fromCompany
210                                                           JOIN dispute.againstCompany againstCompany
211                                                           JOIN dispute.auction auction
212                                                           JOIN auction.stock stock
213                                                           JOIN stock.vehicleYear vehicleYear
214                                                           JOIN stock.type type
215                                                           JOIN type.model model
216                                                           JOIN model.make make
217                                               [WHERE] [ORDER]',
218             'Selection'       => 'dispute, fromCompany, againstCompany, auction, stock, vehicleYear, make, model, type',
219             'Filter'          => array(),
220             'OrderBy'         => array('dispute.created' => 'DESC'),
221             'Fields'          => array(
222                                                 'id',
223                                                 'created' => 'DateTime',
224                                                 'jobState',
225                                                 'fromCompany' => array(
226                                                     'name'
227                                                 ),
228                                                 'againstCompany' => array(
229                                                     'name'
230                                                 ),
231                                                 'auction' => array(
232                                                         'id',
233                                                         'currentBidPrice',
234                                                         'endDate' => 'DateTime',
235                                                         'stock' => array(
236                                                             'created' => 'DateTime',
237                                                             'type' => array(
238                                                                 'name',
239                                                                 'model' => array(
240                                                                     'name',
241                                                                     'make' => array(
242                                                                           'name'
243                                                                     )
244                                                                 ),
245                                                             ),
246                                                             'vehicleYear' => array(
247                                                                 'name'
248                                                             ),
249                                                             'km',
250                                                             'tradePrice',
251                                                             'retailPrice',
252                                         'listPrice'
253                                                         )
254                                                 )
255                                             )
256         );
257         /**
258          * @var array
259          */
260         protected $metaView = array(
261             'Type'        => 'Update',
262             'Contract'    => 'Recurring',
263             'Expand'      => array(
264                                         'createdBy',
265                                         'fromCompany',
266                                         'againstCompany',
267                                         'contact',
268                                                 'group',
269                                                 'groupDivision',
270                                                 'auction',
271                                                 'stock',
272                                                 'make',
273                                                 'model',
274                                                 'type',
275                                         'vehicleYear',
276                                         'km'
277             ),
278             'RequiredInput' => array(),
279             'OptionalInput' => array()
280         );
281         /**
282          * @var array
283         */
284         protected $metaCreate = array(
285                         'Type'                  => 'Create',
286                         'Contract'              => 'Recurring',
287                         'ExecuteAfter'  => array(
288                                         'sendDisputeNotification'
289                         ),
290                         'RequiredInput' => array(
291                                         'Dispute' => array(
292                                                         'againstCompany'        => 'Id',
293                                                         'auction'               => 'Id',
294                                                         'complaint'             => 'String500'
295                                         )
296                         ),
297                         'OptionalInput' => array()
298         );
299         /**
300          * @var array
301         */
302         protected $metaUpdate = array(
303                         'Type'                  => 'Update',
304                         'Contract'              => 'UseOnce',
305                         'RequiredInput' => array(
306                                         'Dispute' => array(
307                                                         'complaint'             => 'String500'
308                                         )
309                         ),
310                         'OptionalInput' => array(
311                                         'Dispute' => array(
312                                                         'resolution'            => 'String500'
313                                         )
314                         )
315         );
316
317
318
319         /**
320          * Add some dynamic filtering to our grids.
321          */
322         public function __construct()
323         {
324                 $authData = \Utility\Registry::getAuthData();
325                 switch (\Utility\Registry::getUserType())
326                 {
327                         case 'B4C User':
328                                 $groupFilter = \Utility\Registry::getSudo('Group', false);
329                                 $divisionFilter = \Utility\Registry::getSudo('Division', false);
330                                 $companyFilter = \Utility\Registry::getSudo('Company', false);
331                                 if ($groupFilter && $divisionFilter && $companyFilter)
332                                 {
333                                         $this->metaGrid['Filter']['IDENTITY(dispute.againstCompany)'] = $companyFilter;
334                                 }
335                                 break;
336                         case 'Group User':
337                                 $divisionFilter = \Utility\Registry::getSudo('Division', false);
338                                 $companyFilter = \Utility\Registry::getSudo('Company', false);
339                                 if ($divisionFilter && $companyFilter)
340                                 {
341                                         $this->metaGrid['Filter']['IDENTITY(dispute.againstCompany)'] = $companyFilter;
342                                 }
343                                 break;
344                         case 'Dealer Principle':
345                                 $companyFilter = \Utility\Registry::getSudo('Company', false);
346                                 if ($companyFilter)
347                                 {
348                                         $this->metaGrid['Filter']['IDENTITY(dispute.againstCompany)'] = $companyFilter;
349                                 }
350                                 break;
351                         default:
352         $this->metaGridDef['Filter']['IDENTITY(dispute.againstCompany)'] = $authData['company']['id'];
353                                 $this->metaGrid['Filter']['IDENTITY(dispute.fromCompany)'] = $authData['company']['id'];
354                                 break;
355                         }
356         }
357
358
359 }