text changes to registration mail content
[namibia] / module / Auction / src / Auction / Pdf / Portal.php
1 <?php
2
3 namespace Auction\Pdf;
4
5 class Portal extends \Utility\Service\PdfTemplate
6 {
7
8     /**
9      * PDF title.
10      * @var string
11      */
12     protected $_title = 'Stock Information';
13
14     /**
15      * @var \Stock\Entity\Stock
16      */
17     protected $jobRecord;
18
19     /**
20      * @var boolean
21      */
22     protected $showTradeDataOnly = true;
23
24     /**
25      * @var boolean
26      */
27     protected $showCustomerDetails = false;
28
29     /**
30      * @var boolean
31      */
32     protected $showValuationDetails = false;
33
34     /**
35      * @var boolean
36      */
37     protected $showMainImage = true;
38
39     /**
40      * @var boolean
41      */
42     protected $showPricingDetails = true;
43
44     /**
45      * @var boolean
46      */
47     protected $showVehicleDetails = true;
48
49     /**
50      * @var boolean
51      */
52     protected $showVehicleNotes = true;
53
54     /**
55      * @var boolean
56      */
57     protected $showDamageDetails = true;
58
59     /**
60      * @var boolean
61      */
62     protected $showAccessoryDetails = true;
63
64     /**
65      * @var boolean
66      */
67     protected $showSignatureLines = true;
68
69     /**
70      * @var boolean
71      */
72     protected $showTermsAndConditions = false;
73
74     /**
75      * @var boolean
76      */
77     protected $showOffersReceived = true;
78
79     /**
80      * @var boolean
81      */
82     protected $showOfferMade = true;
83
84     /**
85      * Utility for easy parameter retrieval.
86      * @param string $param
87      * @param unknown $default
88      * @return unknown
89      */
90     protected function getStockParam($param, $default)
91     {
92         return !is_null($this->jobRecord->$param) ? $this->jobRecord->$param : $default;
93     }
94
95     /**
96      * Utility for easy parameter retrieval.
97      * @param string $param
98      * @param unknown $default
99      * @return unknown
100      */
101     protected function getStockSubParam($ref, $param, $default)
102     {
103         $ref = !is_null($this->jobRecord->$ref) ? $this->jobRecord->$ref : null;
104         return is_object($ref) ? $ref->$param : $default;
105     }
106
107     /**
108      * Utility for easy parameter retrieval.
109      * @param string $param
110      * @param unknown $default
111      * @return unknown
112      */
113     protected function getValuationParam($param, $default)
114     {
115         return !is_null($this->jobRecord->valuation) && !is_null($this->jobRecord->valuation->$param) ? $this->jobRecord->valuation->$param : $default;
116     }
117
118     /**
119      * Build the content.
120      */
121     public function build()
122     {
123         #-> Set data item to work with.
124         $this->auctionRecord = $this->_input['jobRecord'];
125         $this->jobRecord = $this->_input['jobRecord']->stock;
126         $dateTimeFormat = \Utility\Definitions\Locale::getDateTimeFormat();
127         $currencyPrefix = \Utility\Definitions\Locale::getCurrencyPrefix();
128         $authData = \Utility\Registry::getAuthData();
129         $dateOfPrint = 'Date of print: <span style="color:#333;">' . date('Y-m-d H:i:s') . '</span>';
130         $printedBy = 'Printed by: <span style="color:#333;">' . $authData['firstName']
131             . ' ' . $authData['familyName'] . '</span>';
132         $referenceNo = 'Reference no.: <span style="color:#333;">' . $this->jobRecord->referenceNumber . '</span>';
133
134
135         /* --------------------------------- CUSTOMER, VALUATION, PRICING --------------------------------- */
136         $type = $this->jobRecord->type;
137         $this->append(
138             '<br /><div style="font-size:16px;font-weight:bold;">'
139             . $type->model->make->name . ' '
140             . $type->model->name . ' '
141             . $type->name . ' ('
142             . $type->introYear->name . ' - '
143             . (!is_null($type->discYear) ? $type->discYear->name : 'Current') . ')'
144             . '</div><hr /><br />'
145         );
146
147
148         /* --------------------------------- CUSTOMER, VALUATION, PRICING --------------------------------- */
149         #-> Customer
150         $customerDetail = '&nbsp;';
151         if ($this->showCustomerDetails)
152         {
153             $table = $this->newTable(
154                 array(60, 40), 'padding:0;margin:0;font-size:10px;', '',
155                 'padding:2px 3px 2px 0;margin:0;'
156             );
157             $department = $this->getValuationParam('department', null);
158             $department = !is_null($department) ? $department : '&nbsp;';
159             $table
160                 ->addTitle('Customer',
161                     'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1)
162                 ->addKeyValueDataSet(array(
163                     'Customer name:' => $this->getValuationParam('firstName', ''),
164                     'Customer surname:' => $this->getValuationParam('familyName', ''),
165                     'ID:' => $this->getValuationParam('idNumber', ''),
166                     'Mobile:' => $this->getValuationParam('mobile', ''),
167                     'Email:' => $this->getValuationParam('email', ''),
168                     'Department:' => $department,
169                     'Address:' => '&nbsp;',
170                     '<span style="color:#FFF;font-size:20px;">a1</span>' => '&nbsp;',
171                     '<span style="color:#FFF;font-size:10px;">1</span><span style="color:#000;font-size:10px;">______________________________________</span>' => '&nbsp;',
172                     '<span style="color:#FFF;font-size:20px;">a</span>' => '&nbsp;',
173                     '<span style="color:#FFF;font-size:10px;">2</span><span style="color:#000;font-size:10px;">______________________________________</span>' => '&nbsp;',
174                     '<span style="color:#FFF;font-size:20px;">b</span>' => '&nbsp;',
175                     '<span style="color:#FFF;font-size:10px;">3</span><span style="color:#000;font-size:10px;">______________________________________</span>' => '&nbsp;'
176                 ), 0, 'font-weight:bold;', 'color:#666;');
177             $customerDetail = $table->publish();
178         }
179         #-> Customer alternated with dealership details for traders.
180         if ($this->showTradeDataOnly)
181         {
182             $table = $this->newTable(
183                 array(60, 40), 'padding:0;margin:0;font-size:10px;', '',
184                 'padding:2px 3px 2px 0;margin:0;'
185             );
186             $department = $this->getValuationParam('department', null);
187             $department = !is_null($department) ? $department : '&nbsp;';
188             $contact = $this->getStockSubParam('company', 'contact', null);
189             $table
190                 ->addTitle('Dealership',
191                     'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1)
192                 ->addKeyValueDataSet(array(
193                     'Dealership name:' => $this->getStockSubParam('company', 'name', ''),
194                     'Contact:' => !is_null($contact) ? $contact->firstName . ' ' . $contact->familyName : '',
195                     'Mobile:' => !is_null($contact) ? $contact->mobile : '',
196                     'Email:' => !is_null($contact) ? $contact->email : ''
197                 ), 0, 'font-weight:bold;', 'color:#666;');
198             $customerDetail = $table->publish();
199         }
200
201         #-> Valuation
202         $valuationDetail = '&nbsp;';
203         if ($this->showValuationDetails)
204         {
205             $table = $this->newTable(
206                 array(55, 45), 'padding:0;margin:0;font-size:10px;', '',
207                 'padding:2px 3px 2px 0;margin:0;'
208             );
209             $pgItem = $this->em
210                 ->getRepository('\Auction\Entity\Auction')
211                 ->findOneBy(array('stock' => $this->jobRecord));
212             $pgLoaded = !is_null($pgItem) ? $pgItem->created->format($dateTimeFormat) : '&nbsp;';
213             $valCreated = $this->getValuationParam('created', null);
214             $valCreated = !is_null($valCreated) ? $valCreated->format($dateTimeFormat) : '&nbsp;';
215             $table
216                 ->addTitle('Valuation details',
217                     'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1)
218                 ->addKeyValueDataSet($this->showTradeDataOnly ? array(
219                     'Date created:' => $valCreated,
220                     'Date loaded on price guide:' => $pgLoaded
221                 ) : array(
222                     'Date created:' => $valCreated,
223                     'Valuation no.:' => $this->getValuationParam('valuationNumber', ''),
224                     'Reference no.:' => $this->getStockParam('referenceNumber', ''),
225                     'Date loaded on price guide:' => $pgLoaded
226                 ), 0, 'font-weight:bold;', 'color:#F00;');
227             $valuationDetail = $table->publish();
228         }
229         $mainImage = '&nbsp;';
230         if ($this->showMainImage)
231         {
232             $pic = $this->getStockParam('mainImage', '');
233             if (is_object($pic))
234             {
235                 $mainImage = '<img src="' . __DIR__ . '/../../../../../public/img/bin/' . $pic->filename . '" style="padding:0;margin:0;width:100%;" />';
236             }
237         }
238
239         #-> Pricing details
240         $pricingDetail = '&nbsp;';
241         $total = $this->getValuationParam('overAllowance', '0.00') + $this->getValuationParam('amountOffered',
242                 '0.00');
243         $total = number_format($total, 2, '.', '');
244         if ($this->showPricingDetails)
245         {
246             $table = $this->newTable(
247                 array(60, 40), 'padding:0;margin:0;font-size:10px;', '',
248                 'padding:2px 3px 2px 0;margin:0;'
249             );
250             $table
251                 ->addTitle('Pricing details',
252                     'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1)
253                 ->addKeyValueDataSet($this->showTradeDataOnly ? array(
254                     'Trade:' => $currencyPrefix . $this->getStockParam('tradePrice',
255                             '0.00'),
256                     'Retail:' => $currencyPrefix . $this->getStockParam('retailPrice',
257                             '0.00'),
258                     'List:' => $currencyPrefix . $this->getStockParam('listPrice',
259                             '0.00'),
260                     'Reserve price:' => $currencyPrefix . $this->auctionRecord->reservePrice,
261                     'Highest bid:' => $currencyPrefix . $this->getStockParam('highestBid',
262                             '0.00')
263
264
265
266                     /* 'Amount offered:'            => $currencyPrefix . $this->getValuationParam('amountOffered', '0.00'), */
267                     /* 'O.A.:'                      => $currencyPrefix . $this->getValuationParam('overAllowance', '0.00'), */
268                     /* 'Total offer:'                    => $currencyPrefix . $total, // total offer =  amount offered + O.A */
269                 ) : array(
270                     'Trade:' => $currencyPrefix . $this->getStockParam('tradePrice',
271                             '0.00'),
272                     'Retail:' => $currencyPrefix . $this->getStockParam('retailPrice',
273                             '0.00'),
274                     'List:' => $currencyPrefix . $this->getStockParam('listPrice',
275                             '0.00'),
276                     'Amount offered:' => $currencyPrefix . $this->getValuationParam('amountOffered',
277                             '0.00'),
278                     'O.A.:' => $currencyPrefix . $this->getValuationParam('overAllowance',
279                             '0.00'),
280                     'Total offer:' => $currencyPrefix . $total, // total offer =  amount offered + O.A
281                     'Projected retail:' => $currencyPrefix,
282                     'Planned margin:' => $currencyPrefix,
283                     'Price guide highest offer:' => $currencyPrefix . $this->getStockParam('highestOffer',
284                             '0.00')
285                 ), 0, 'font-weight:bold;', 'color:#F00;');
286             $pricingDetail = $table->publish();
287         }
288
289         #-> First row of data-blocks.
290         if ($this->showCustomerDetails || $this->showValuationDetails || $this->showMainImage || $this->showPricingDetails)
291         {
292             $container = $this
293                 ->newTable(
294                     array(30, 5, 30, 5, 30),
295                     'margin:0;font-size:10px;vertical-align:top;', '',
296                     'padding:10px 0 0 0;'
297                 )
298                 ->setCellValue(0, 0, $customerDetail)
299                 ->setCellValue(0, 2, $pricingDetail)
300                 ->setCellValue(0, 4, $valuationDetail . $mainImage);
301             $this->append($container->publish() . '<br />');
302         }
303
304         /* --------------------------------- Buyer Details --------------------------------- */
305         if (true)
306         {
307             $table = $this->newTable(
308                 array(30, 30), 'padding:0;margin:0;font-size:10px;', '',
309                 'padding:2px 3px 2px 0;margin:0;'
310             );
311
312             $table
313                 ->addTitle('Buyers Details',
314                     'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1)
315                 ->addKeyValueDataSet(array(
316                     'Dealership name:' => $this->auctionRecord->soldToCompany->name,
317                     'Contact:' => !is_null($this->auctionRecord->soldToProfile) ? $this->auctionRecord->soldToProfile->firstName . ' ' . $this->auctionRecord->soldToProfile->familyName : '',
318                     'Mobile:' => !is_null($this->auctionRecord->soldToProfile) ? $this->auctionRecord->soldToProfile->mobile : '',
319                     'Email:' => !is_null($this->auctionRecord->soldToProfile) ? $this->auctionRecord->soldToProfile->email : ''
320                 ), 0, 'font-weight:bold;', 'color:#666;');
321             $buyerDetails = $table->publish();
322
323             $this->append($buyerDetails . '<br />');
324         }
325
326
327         /* --------------------------------- VEHICLE, DAMAGES, ACCESSORIES --------------------------------- */
328
329         #-> Vehicle details
330         $vehicleDetail = '&nbsp;';
331         if ($this->showVehicleDetails)
332         {
333             $keys = $this->getStockParam('spareKeys', null);
334             if (is_null($keys))
335             {
336                 $keys = '';
337             }
338             else
339             {
340                 $keys = $keys ? 'Yes' : 'No';
341             }
342             $table = $this->newTable(
343                 array(55, 45), 'padding:0;margin:0;font-size:10px;', '',
344                 'padding:2px 3px 2px 0;margin:0;'
345             );
346             $table
347                 ->addTitle('Vehicle specifications',
348                     'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1)
349                 ->addKeyValueDataSet(array(
350                     'Year:' => $this->getStockSubParam('vehicleYear', 'name', ''),
351                     'Category:' => $type->category->name,
352                     'Make:' => $type->model->make->name,
353                     'Model:' => $type->model->name,
354                     'Type:' => $type->name,
355                     'Registration no.:' => $this->getStockParam('registrationNumber', ''),
356                     'Fuel type:' => $this->getStockSubParam('fuelType', 'name', ''),
357                     'Transmission type:' => $this->getStockSubParam('transmissionType',
358                         'name', ''),
359                     'VIN no.:' => $this->getStockParam('vinNumber', ''),
360                     'Engine no.:' => $this->getStockParam('engineNumber', ''),
361                     'MM code:' => $type->mmCode,
362                     'Kms:' => $this->getStockParam('km', ''),
363                     'Condition:' => $this->getStockSubParam('condition', 'name', ''),
364                     'Main exterior colour:' => $this->getStockSubParam('exteriorColour',
365                         'name', ''),
366                     'Main interior colour:' => $this->getStockSubParam('interiorColour',
367                         'name', ''),
368                     'Upholstery:' => $this->getStockSubParam('upholstery', 'name', ''),
369                     'Papers:' => $this->getStockSubParam('papers', 'name', ''),
370                     'Papers comments:' => $this->getStockParam('papersNotes', ''),
371                     'Natis:' => $this->getStockSubParam('natis', 'name', ''),
372                     'Spare keys:' => $keys,
373                     'FSH:' => $this->getStockSubParam('fullServiceHistory', 'name', ''),
374                     'FSH comments:' => $this->getStockParam('fshNotes', ''),
375                     'Stock number:' => $this->getStockParam('stockNumber', '')
376                 ), 0, '', 'color:#666;');
377             $vehicleDetail = $table->publish();
378         }
379
380         #-> Damages
381         $damagesDetail = '&nbsp;';
382         if ($this->showDamageDetails)
383         {
384             $damageData = array();
385             $damages = $this->jobRecord->damagesToArray();
386             foreach ($damages as $damage)
387             {
388                 $damageData[$damage['damage']['name'] . ':'] = $currencyPrefix . $damage['amount'];
389             }
390             $damageData['Total estimated repair cost:'] = '<span style="color:#F00;">' . $currencyPrefix . $this->getStockParam('damageTotal',
391                     '') . '</span>';
392             $damageData['Damages comments:'] = $this->getStockParam('damageNotes', '');
393             $damageData['Previous repairs noted:'] = $this->getStockParam('previousRepairsNoted',
394                 false) ? 'Yes' : 'No';
395             $damageData['Previous repairs comments:'] = $this->getStockParam('previousRepairsNotes',
396                 '');
397             $table = $this->newTable(
398                 array(50, 50), 'padding:0;margin:0;font-size:10px;', '',
399                 'padding:2px 3px 2px 0;margin:0;'
400             );
401             $type = $this->jobRecord->type;
402             $table
403                 ->addTitle('Damages',
404                     'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1)
405                 ->addKeyValueDataSet($damageData, 0, '', 'color:#666;');
406             $damagesDetail = $table->publish();
407         }
408
409         #-> Accessories
410         $accessoriesDetail = '&nbsp;';
411         if ($this->showAccessoryDetails)
412         {
413             $accs = array();
414             $accData = array();
415             $accessories = $this->jobRecord->accessoriesToArray();
416             foreach ($accessories as $accessory)
417             {
418                 $accs[] = $accessory['accessory']['name'];
419             }
420             if (!empty($accs))
421             {
422                 for ($i = 0; $i <= count($accs); $i += 2)
423                 {
424                     if (isset($accs[$i]))
425                     {
426                         $accData[$accs[$i]] = isset($accs[$i + 1]) ? $accs[$i + 1] : '';
427                     }
428                 }
429             }
430             $accData['<span style="color:#000;font-size:10px;">Comments:</span>'] = '<span style="color:#666;font-size:10px;">' . $this->getStockParam('accessoryNotes',
431                     '') . '</span>';
432             $table = $this->newTable(
433                 array(50, 50), 'padding:0;margin:0;font-size:9px;', '',
434                 'padding:2px 3px 2px 0;margin:0;'
435             );
436             $type = $this->jobRecord->type;
437             $table
438                 ->addTitle('Accessories',
439                     'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1)
440                 ->addKeyValueDataSet($accData, 0, 'color:#666;', 'color:#666;');
441             $accessoriesDetail = $table->publish();
442         }
443
444         #-> Second row of data-blocks.
445         if ($this->showVehicleDetails || $this->showDamageDetails || $this->showAccessoryDetails)
446         {
447             $container = $this
448                 ->newTable(
449                     array(30, 5, 30, 5, 30),
450                     'margin:0;font-size:10px;vertical-align:top;', '',
451                     'padding:10px 0 0 0;'
452                 )
453                 ->setCellValue(0, 0, $vehicleDetail)
454                 ->setCellValue(0, 2, $damagesDetail)
455                 ->setCellValue(0, 4, $accessoriesDetail);
456             $this->append($container->publish() . '<br />');
457         }
458
459         /* --------------------------------- VEHICLE NOTES --------------------------------- */
460         #-> Vehicle Notes
461         $VehicleNotes = '&nbsp;';
462         if ($this->showVehicleNotes)
463         {
464             $table = $this->newTable(
465                 array(55, 45), 'padding:0;margin:0;font-size:10px;', '',
466                 'padding:15px 15px 15px 0;margin:0;'
467             );
468
469             $dSet = array(
470                 '1______________________________________________________________________________________________________________________________________' => '&nbsp;',
471                 '2______________________________________________________________________________________________________________________________________' => '&nbsp;',
472                 '3______________________________________________________________________________________________________________________________________' => '&nbsp;'
473             );
474
475             $table
476                 ->addTitle('Notes:',
477                     'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1)
478                 ->addKeyValueDataSet($dSet, 0, '', 'color:#666;');
479             $VehicleNotes = $table->publish();
480         }
481         #-> Third row of data-blocks.
482         if ($this->showVehicleNotes)
483         {
484             $container = $this
485                 ->newTable(
486                     array(30, 5, 30, 5, 30),
487                     'margin:0;font-size:10px;vertical-align:top;', '',
488                     'padding:10px 0 0 0;'
489                 )
490                 ->setCellValue(0, 0, $VehicleNotes);
491             $this->append($container->publish() . '<br />');
492         }
493
494
495
496
497
498         /* --------------------------------- SIGNATURES --------------------------------- */
499         #-> Signatures.
500         if ($this->showSignatureLines)
501         {
502             $this->append(
503                 $this->newSignatureLine()
504                     ->addSignatureLine('Customer (name)', 'Signature', 'Date')
505                     ->addSignatureLine('Manager (name)', 'Signature', 'Date')
506                     ->publish()
507             );
508         }
509
510         $this->append(
511             '<div style="position:absolute;bottom:0;left:0;padding:0;margin:0;width:100%;">'
512             . '<table cellpadding="0px" cellspacing="0px" style="border:0px;width:100%;">'
513             . '<tr>'
514             . '<td style="width:30%;border-bottom: solid 1px #333;font-size:10px;font-weight:bold;color:#666;"><i>'
515             . $dateOfPrint . '</i></td>'
516             . '<td style="width:5%">&nbsp;</td>'
517             . '<td style="width:30%;border-bottom: solid 1px #333;font-size:10px;font-weight:bold;color:#666;"><i>'
518             . $printedBy . '</i></td>'
519             . '<td style="width:5%">&nbsp;</td>'
520             . '<td style="width:30%;border-bottom: solid 1px #333;font-size:10px;font-weight:bold;color:#666;"><i>'
521             . $referenceNo . '</i></td>'
522             . '</tr>'
523             . '</table>'
524             . '</div>'
525         );
526
527
528
529
530         /* --------------------------------- TERMS AND CONDITIONS --------------------------------- */
531         #-> Terms and Conditions.
532         if ($this->showTermsAndConditions)
533         {
534             $this->nextPage();
535             $this->append('<br/>');
536
537             $table = $this->newTable(
538                 array(90, 10), 'padding:0;margin:0;font-size:9px;', '',
539                 'padding:2px 3px 2px 0;margin:0;'
540             );
541             $type = $this->jobRecord->type;
542             $table
543                 ->addTitle('Terms and Conditions',
544                     'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1)
545                 ->addKeyValueDataSet(array(
546                     'I acknowledge, confirm and agree that:' => '',
547                     '1. Ownership' => '',
548                     '1.1. I am the owner of my trade-in vehicle and I am legally allowed to sell my trade-in vehicle.' => 'Yes / No',
549                     '1.2. I am a South African resident.' => 'Yes / No',
550                     '1.3. My trade-in vehicle is not subject to a claim of any nature whatsoever by any other person or entity and I '
551                     . 'indemnify the Dealer against any claims of any ' => 'Yes / No',
552                     '1.4. If my trade-in vehicle is subject to any claim by any other person or entity, the Dealer will not be bound '
553                     . 'to this valuation.' => 'Yes / No',
554                     '2. VAT Registration' => '',
555                     'This transaction is subject to the payment of VAT.' => 'Yes / No',
556                     '3. Status of the Vehicle' => '',
557                     '3.1. My trade-in vehicle was new when I purchased it.' => 'Yes / No',
558                     '3.2. My trade-in vehicle has been used for self-drive hire or taxi work.' => 'Yes / No',
559                     '3.3. My trade-in vehicle has a full service history.' => 'Yes / No',
560                     '3.4. My trade in vehicle has not been involved in any accident.' => 'Yes / No',
561                     '3.5. If my trade-in vehicle has been involved in an accident, there was a total loss claim made (Stolen & Recovered).' => 'Yes / No',
562                     '3.6. A current registration paper has been handed over by me.' => 'Yes / No',
563                     '3.7. I have supplied the owners and service manuals to the Dealer.' => 'Yes / No',
564                     '3.8. My trade-in vehicle is subject to a service and/or maintenance plan and/or warranty.' => 'Yes / No',
565                     '4. Status of the Vehicle' => '',
566                     'The Dealer will only be bound by its appraised trade-in value of my trade-in vehicle as far as the trade-in has '
567                     . 'been approved and accepted in writing by either the dealer principle, designated sales manager or used car manager'
568                     . ' and the parties have entered into the Dealer\'s standard Offer to Purchase in respect of my trade-in vehicle.' => '',
569                     '5. Outstanding Finance' => '',
570                     '5.1. The Dealer, in its absolute and sole discretion, may agree to settle the existing finance in lieu of payment '
571                     . '(or part payment) of the trade-in vehicle to me.' => '',
572                     '5.2. If the agreed trade-in allowance of the trade-in vehicle is lower than the settlement figure in clause 5.1 above, '
573                     . 'I must pay the Registered Credit Provider the difference between the settlement figure and the trade-in allowance with '
574                     . 'proof of such payment (made to the registered Credit Provider) submitted to the Dealer prior to the signing of the Offer to Purchase.' => '',
575                     '5.3. I will remain liable to the registered Credit Provider in respect of the related finance at all times until the '
576                     . 'credit Agreement has been legally terminated.' => '',
577                     '5.4. For purposes of clarity, the Dealer does not accept any liability with respect to the related finance set out in '
578                     . 'clause 5.4 above at any time or for any reason.' => '',
579                     '5.5. The Dealer will use its best endeavors to pay the trade-in allowance to the registered Credit Provider as soon as '
580                     . 'is reasonably possible. However the Dealer accepts no liability for any costs or liability incurred by me as a result '
581                     . 'of any delay in the payment by the Dealer.' => '',
582                     '6. No Financial Advice' => '',
583                     'This trade-in valuation does not constitute financial advice to me as contemplated in the Financial Advisory and '
584                     . 'Intermediary Services Act 37 of 2002 but is subject to the Consumer Protection Act 68 of 2008.' => '',
585                     '7. Risk' => '',
586                     'The risk of damage or loss in and to the trade-in vehicle will pass from me to the Dealer only once the Dealer has '
587                     . 'taken possession of my trade-in vehicle and has received the proper documentation from me to enable it to re-register my trade-in vehicle.' => '',
588                     '8. The Dealer\'s right to withdraw from the offer' => '',
589                     'The Dealer is bound by this offer only in so far as:' => '',
590                     '8.1. I have signed an Offer to Purchase with the same Dealer in respect of this valuation; and' => '',
591                     '8.2. Fewer than 7 (seven) days have passed since the issuing of this valuation; and' => '',
592                     '8.3. My trade-in vehicle is in the same condition as the date of inspection; and' => '',
593                     '8.4. This trade-in valuation was signed by the Valuator and the Manager of the Dealer.' => '',
594                     '&nbsp;<br />&nbsp;' => '',
595                     'I HAVE READ THE ABOVE TERMS AND CONDITIONS AND CONFIRM MY UNDERSTANDING AND AGREE TO BE BOUND THERETO.' => '',
596                     '&nbsp;<br />&nbsp;' => '',
597                     'Acceptance' => '',
598                     'By signing this form, I agree to the [Dealership Name] valuation terms and conditions above.' => '',
599                     '&nbsp;<br />&nbsp;<br />&nbsp;<br />&nbsp;<br />&nbsp;<br />' => '',
600                     '<b>Signature:</b>' => '',
601                     '&nbsp;' => '',
602                     'Date: ' . date('Y-m-d') => ''
603                 ), 0, 'color:#333;', 'color:#000;');
604             $this->append($table->publish() . '<br />');
605
606             $this->append(
607                 '<div style="position:absolute;bottom:0;left:0;padding:0;margin:0;width:100%;">'
608                 . '<table cellpadding="0px" cellspacing="0px" style="border:0px;width:100%;">'
609                 . '<tr>'
610                 . '<td style="width:30%;border-bottom: solid 1px #333;font-size:10px;font-weight:bold;color:#666;"><i>'
611                 . $dateOfPrint . '</i></td>'
612                 . '<td style="width:5%">&nbsp;</td>'
613                 . '<td style="width:30%;border-bottom: solid 1px #333;font-size:10px;font-weight:bold;color:#666;"><i>'
614                 . $printedBy . '</i></td>'
615                 . '<td style="width:5%">&nbsp;</td>'
616                 . '<td style="width:30%;border-bottom: solid 1px #333;font-size:10px;font-weight:bold;color:#666;"><i>'
617                 . $referenceNo . '</i></td>'
618                 . '</tr>'
619                 . '</table>'
620                 . '</div>'
621             );
622         }
623
624
625         /* --------------------------------- OFFERS RECEIVED/MADE --------------------------------- */
626         #-> Offers received.
627         if ($this->showOffersReceived || $this->showOfferMade)
628         {
629
630
631             if ($this->showOffersReceived)
632             {
633                 $offers = array();
634                 $pgItems = $this->em
635                     ->getRepository('\PriceGuide\Entity\PriceGuide')
636                     ->findBy(array('stock' => $this->jobRecord));
637                 if (!empty($pgItems))
638                 {
639                     foreach ($pgItems as $pgItem)
640                     {
641                         $iterator = $pgItem->offers->getIterator();
642                         foreach ($iterator as $offer)
643                         {
644                             $status = $offer->status;
645                             $offers[] = array(
646                                 $offer->company->name,
647                                 $offer->created->format($dateTimeFormat),
648                                 $currencyPrefix . $offer->amount,
649                                 $offer->profile->mobile,
650                                 $offer->profile->email,
651                                 $status
652                             );
653                         }
654                     }
655
656                     $this->nextPage();
657                     $this->append('<br/>');
658                     $table = $this->newTable(
659                         array(20, 15, 15, 10, 30, 10),
660                         'padding:0;margin:0;font-size:10px;',
661                         '',
662                         'padding:2px 5px 2px 2px;margin:0;'
663                     );
664                     $table
665                         ->addTitle('Offers received', 'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1)
666                         ->setColumnHeaders(array(
667                             'Buyer', 'Date', 'Offer', 'Mobile', 'Email', 'Status'
668                         ), array(20, 15, 15, 10, 30, 10),
669                             'padding:2px 2px 2px 5px;background-color:#F00;color:#FFF;font-weight:bold;font-size:10px;')
670                         ->setDataSet($offers);
671                     $this->append($table->publish() . '<br />');
672
673                     $this->append(
674                         '<div style="position:absolute;bottom:0;left:0;padding:0;margin:0;width:100%;">'
675                         . '<table cellpadding="0px" cellspacing="0px" style="border:0px;width:100%;">'
676                         . '<tr>'
677                         . '<td style="width:30%;border-bottom: solid 1px #333;font-size:10px;font-weight:bold;color:#666;"><i>'
678                         . $dateOfPrint . '</i></td>'
679                         . '<td style="width:5%">&nbsp;</td>'
680                         . '<td style="width:30%;border-bottom: solid 1px #333;font-size:10px;font-weight:bold;color:#666;"><i>'
681                         . $printedBy . '</i></td>'
682                         . '<td style="width:5%">&nbsp;</td>'
683                         . '<td style="width:30%;border-bottom: solid 1px #333;font-size:10px;font-weight:bold;color:#666;"><i>'
684                         . $referenceNo . '</i></td>'
685                         . '</tr>'
686                         . '</table>'
687                         . '</div>'
688                     );
689                 }
690
691             }
692
693             #-> Offer made.
694             if ($this->showOfferMade)
695             {
696                 $offers = array();
697                 $pgItem = $this->em
698                     ->getRepository('\PriceGuide\Entity\PriceGuide')
699                     ->findOneBy(array('stock' => $this->jobRecord));
700                 if (!is_null($pgItem))
701                 {
702                     $companyId = \Utility\Registry::resolveCompanyContext();
703                     $iterator = $pgItem->offers->getIterator();
704                     foreach ($iterator as $offer)
705                     {
706                         $status = $offer->status;
707                         $offers[] = array(
708                             $offer->company->name,
709                             $offer->created->format($dateTimeFormat),
710                             $currencyPrefix . $offer->amount,
711                             $offer->profile->mobile,
712                             $offer->profile->email,
713                             $status
714                         );
715                     }
716
717                     $table = $this->newTable(
718                         array(20, 15, 15, 10, 30, 10),
719                         'padding:0;margin:0;font-size:10px;',
720                         '',
721                         'padding:2px 5px 2px 2px;margin:0;'
722                     );
723
724                     $this->nextPage();
725                     $this->append('<br/>');
726                     $table
727                         ->addTitle('Offers made', 'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1)
728                         ->setColumnHeaders(array(
729                             'Buyer', 'Date', 'Offer', 'Mobile', 'Email', 'Status'
730                         ), array(20, 15, 15, 10, 30, 10),
731                             'padding:2px 2px 2px 5px;background-color:#F00;color:#FFF;font-weight:bold;font-size:10px;')
732                         ->setDataSet($offers);
733                     $this->append($table->publish() . '<br />');
734
735                     $this->append(
736                         '<div style="position:absolute;bottom:0;left:0;padding:0;margin:0;width:100%;">'
737                         . '<table cellpadding="0px" cellspacing="0px" style="border:0px;width:100%;">'
738                         . '<tr>'
739                         . '<td style="width:30%;border-bottom: solid 1px #333;font-size:10px;font-weight:bold;color:#666;"><i>'
740                         . $dateOfPrint . '</i></td>'
741                         . '<td style="width:5%">&nbsp;</td>'
742                         . '<td style="width:30%;border-bottom: solid 1px #333;font-size:10px;font-weight:bold;color:#666;"><i>'
743                         . $printedBy . '</i></td>'
744                         . '<td style="width:5%">&nbsp;</td>'
745                         . '<td style="width:30%;border-bottom: solid 1px #333;font-size:10px;font-weight:bold;color:#666;"><i>'
746                         . $referenceNo . '</i></td>'
747                         . '</tr>'
748                         . '</table>'
749                         . '</div>'
750                     );
751                 }
752
753             }
754
755
756         }
757
758
759 //        /* --------------------------------- BID HISTORY --------------------------------- */
760 //        $this->nextPage();
761 //        $table = $this->newTable(
762 //            array(20, 15, 10, 10, 20, 15, 10), 'padding:0;margin:0;font-size:10px;',
763 //            '', 'padding:2px 3px 2px 0;margin:0;'
764 //        );
765 //
766 //        $table
767 //            ->addTitle('Bid History',
768 //                'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1);
769 //
770 //        $table->setColumnHeaders(array(
771 //            'Dealership',
772 //            'User',
773 //            'Bid Amount',
774 //            'Mobile',
775 //            'Email',
776 //            'Created',
777 //            'Status'
778 //        ), array(20, 15, 10, 10, 20, 15, 10), 'font-weight: bold; color: #ffffff; background-color: #D42E30;');
779 //
780 //        $data = array();
781 //        foreach ($this->auctionRecord->bids as $bid)
782 //        {
783 //            $data[] = array (
784 //                $bid->company->name,
785 //                $bid->profile->firstName . ' ' . $bid->profile->familyName,
786 //                $bid->amount,
787 //                $bid->profile->mobile,
788 //                $bid->profile->email,
789 //                $bid->created->format('Y-m-d H:i:s'),
790 //                $bid->status,
791 //            );
792 //        }
793 //
794 //        $table->setDataSet($data);
795 //
796 //
797 //        $bidHistory = $table->publish();
798 //
799 //        $this->append($bidHistory . '<br />');
800
801         return;
802     }
803
804 }