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