6 class Complete extends \Utility\Service\PdfTemplate
14 protected $_title = 'Stock Information';
16 * @var \Stock\Entity\Stock
22 protected $showTradeDataOnly = true;
26 protected $showCustomerDetails = false;
30 protected $showValuationDetails = false;
34 protected $showMainImage = true;
38 protected $showPricingDetails = true;
42 protected $showVehicleDetails = true;
46 protected $showVehicleNotes = true;
50 protected $showDamageDetails = true;
54 protected $showAccessoryDetails = true;
58 protected $showSignatureLines = false;
62 protected $showTermsAndConditions = false;
66 protected $showOffersReceived = false;
70 protected $showOfferMade = false;
74 * Utility for easy parameter retrieval.
75 * @param string $param
76 * @param unknown $default
79 protected function getStockParam($param, $default)
81 return !is_null($this->jobRecord->$param)
82 ? $this->jobRecord->$param
87 * Utility for easy parameter retrieval.
88 * @param string $param
89 * @param unknown $default
92 protected function getStockSubParam($ref, $param, $default)
94 $ref = !is_null($this->jobRecord->$ref)
95 ? $this->jobRecord->$ref
97 return is_object($ref)
103 * Utility for easy parameter retrieval.
104 * @param string $param
105 * @param unknown $default
108 protected function getValuationParam($param, $default)
110 return !is_null($this->jobRecord->valuation)
111 && !is_null($this->jobRecord->valuation->$param)
112 ? $this->jobRecord->valuation->$param
120 public function build()
122 #-> Set data item to work with.
123 $this->auctionRecord = $this->_input['jobRecord'];
124 $this->jobRecord = $this->_input['jobRecord']->stock;
125 $dateTimeFormat = \Utility\Definitions\Locale::getDateTimeFormat();
126 $currencyPrefix = \Utility\Definitions\Locale::getCurrencyPrefix();
127 $authData = \Utility\Registry::getAuthData();
128 $dateOfPrint = 'Date of print: <span style="color:#333;">' . date('Y-m-d H:i:s') . '</span>';
129 $printedBy = 'Printed by: <span style="color:#333;">' . $authData['firstName']
130 . ' ' . $authData['familyName'] . '</span>';
131 $referenceNo = 'Reference no.: <span style="color:#333;">' . $this->jobRecord->referenceNumber . '</span>';
134 /* --------------------------------- CUSTOMER, VALUATION, PRICING --------------------------------- */
135 $type = $this->jobRecord->type;
137 '<br /><div style="font-size:16px;font-weight:bold;">'
138 . $type->model->make->name . ' '
139 . $type->model->name . ' '
141 . $type->introYear->name . ' - '
142 . (!is_null($type->discYear) ? $type->discYear->name : 'Current') . ')'
143 . '</div><hr /><br />'
147 /* --------------------------------- CUSTOMER, VALUATION, PRICING --------------------------------- */
149 $customerDetail = ' ';
150 if ($this->showCustomerDetails)
152 $table = $this->newTable(
154 'padding:0;margin:0;font-size:10px;',
156 'padding:2px 3px 2px 0;margin:0;'
158 $department = $this->getValuationParam('department', null);
159 $department = !is_null($department)
163 ->addTitle('Customer', 'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1)
164 ->addKeyValueDataSet(array(
165 'Customer name:' => $this->getValuationParam('firstName', ''),
166 'Customer surname:' => $this->getValuationParam('familyName', ''),
167 'ID:' => $this->getValuationParam('idNumber', ''),
168 'Mobile:' => $this->getValuationParam('mobile', ''),
169 'Email:' => $this->getValuationParam('email', ''),
170 'Department:' => $department,
171 'Address:' => ' ',
172 '<span style="color:#FFF;font-size:20px;">a1</span>' => ' ',
173 '<span style="color:#FFF;font-size:10px;">1</span><span style="color:#000;font-size:10px;">______________________________________</span>' => ' ',
174 '<span style="color:#FFF;font-size:20px;">a</span>' => ' ',
175 '<span style="color:#FFF;font-size:10px;">2</span><span style="color:#000;font-size:10px;">______________________________________</span>' => ' ',
176 '<span style="color:#FFF;font-size:20px;">b</span>' => ' ',
177 '<span style="color:#FFF;font-size:10px;">3</span><span style="color:#000;font-size:10px;">______________________________________</span>' => ' '
178 ), 0, 'font-weight:bold;', 'color:#666;');
179 $customerDetail = $table->publish();
181 #-> Customer alternated with dealership details for traders.
182 if ($this->showTradeDataOnly)
184 $table = $this->newTable(
186 'padding:0;margin:0;font-size:10px;',
188 'padding:2px 3px 2px 0;margin:0;'
190 $department = $this->getValuationParam('department', null);
191 $department = !is_null($department)
194 $contact = $this->getStockSubParam('company', 'contact', null);
196 ->addTitle('Dealership', 'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1)
197 ->addKeyValueDataSet(array(
198 'Dealership name:' => $this->getStockSubParam('company', 'name', ''),
199 'Contact:' => !is_null($contact) ? $contact->firstName . ' ' . $contact->familyName : '',
200 'Mobile:' => !is_null($contact) ? $contact->mobile : '',
201 'Email:' => !is_null($contact) ? $contact->email : ''
202 ), 0, 'font-weight:bold;', 'color:#666;');
203 $customerDetail = $table->publish();
207 $valuationDetail = ' ';
208 if ($this->showValuationDetails)
210 $table = $this->newTable(
212 'padding:0;margin:0;font-size:10px;',
214 'padding:2px 3px 2px 0;margin:0;'
217 ->getRepository('\Auction\Entity\Auction')
218 ->findOneBy(array('stock' => $this->jobRecord));
219 $pgLoaded = !is_null($pgItem)
220 ? $pgItem->created->format($dateTimeFormat)
222 $valCreated = $this->getValuationParam('created', null);
223 $valCreated = !is_null($valCreated)
224 ? $valCreated->format($dateTimeFormat)
227 ->addTitle('Valuation details', 'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1)
228 ->addKeyValueDataSet($this->showTradeDataOnly
230 'Date created:' => $valCreated,
231 'Date loaded on price guide:' => $pgLoaded
234 'Date created:' => $valCreated,
235 'Valuation no.:' => $this->getValuationParam('valuationNumber', ''),
236 'Reference no.:' => $this->getStockParam('referenceNumber', ''),
237 'Date loaded on price guide:' => $pgLoaded
238 ), 0, 'font-weight:bold;', 'color:#F00;');
239 $valuationDetail = $table->publish();
241 $mainImage = ' ';
242 if ($this->showMainImage)
244 $pic = $this->getStockParam('mainImage', '');
247 $mainImage = '<img src="' . __DIR__ . '/../../../../../public/img/bin/'. $pic->filename . '" style="padding:0;margin:0;width:100%;" />';
252 $pricingDetail = ' ';
253 $total = $this->getValuationParam('overAllowance', '0.00') + $this->getValuationParam('amountOffered', '0.00');
254 $total = number_format($total, 2, '.', '');
255 if ($this->showPricingDetails)
257 $table = $this->newTable(
259 'padding:0;margin:0;font-size:10px;',
261 'padding:2px 3px 2px 0;margin:0;'
264 ->addTitle('Pricing details', 'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1)
265 ->addKeyValueDataSet($this->showTradeDataOnly
267 'Trade:' => $currencyPrefix . $this->getStockParam('tradePrice', '0.00'),
268 'Retail:' => $currencyPrefix . $this->getStockParam('retailPrice', '0.00'),
269 'List:' => $currencyPrefix . $this->getStockParam('listPrice', '0.00'),
270 'Reserve price:' => $currencyPrefix . $this->auctionRecord->reservePrice,
271 'Amount offered:' => $currencyPrefix . $this->getValuationParam('amountOffered', '0.00'),
272 'O.A.:' => $currencyPrefix . $this->getValuationParam('overAllowance', '0.00'),
273 'Total offer:' => $currencyPrefix . $total, // total offer = amount offered + O.A
276 'Trade:' => $currencyPrefix . $this->getStockParam('tradePrice', '0.00'),
277 'Retail:' => $currencyPrefix . $this->getStockParam('retailPrice', '0.00'),
278 'List:' => $currencyPrefix . $this->getStockParam('listPrice', '0.00'),
279 'Amount offered:' => $currencyPrefix . $this->getValuationParam('amountOffered', '0.00'),
280 'O.A.:' => $currencyPrefix . $this->getValuationParam('overAllowance', '0.00'),
281 'Total offer:' => $currencyPrefix . $total, // total offer = amount offered + O.A
282 'Projected retail:' => $currencyPrefix,
283 'Planned margin:' => $currencyPrefix,
284 'Price guide highest offer:' => $currencyPrefix . $this->getStockParam('highestOffer', '0.00')
285 ), 0, 'font-weight:bold;', 'color:#F00;');
286 $pricingDetail = $table->publish();
289 #-> First row of data-blocks.
290 if ($this->showCustomerDetails
291 || $this->showValuationDetails
292 || $this->showMainImage
293 || $this->showPricingDetails)
297 array(30, 5, 30, 5, 30),
298 'margin:0;font-size:10px;vertical-align:top;',
300 'padding:10px 0 0 0;'
302 ->setCellValue(0, 0, $customerDetail)
303 ->setCellValue(0, 2, $pricingDetail)
304 ->setCellValue(0, 4, $valuationDetail . $mainImage);
305 $this->append($container->publish() . '<br />');
309 /* --------------------------------- VEHICLE, DAMAGES, ACCESSORIES --------------------------------- */
312 $vehicleDetail = ' ';
313 if ($this->showVehicleDetails)
315 $keys = $this->getStockParam('spareKeys', null);
326 $table = $this->newTable(
328 'padding:0;margin:0;font-size:10px;',
330 'padding:2px 3px 2px 0;margin:0;'
333 ->addTitle('Vehicle specifications', 'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1)
334 ->addKeyValueDataSet(array(
335 'Year:' => $this->getStockSubParam('vehicleYear', 'name', ''),
336 'Category:' => $type->category->name,
337 'Make:' => $type->model->make->name,
338 'Model:' => $type->model->name,
339 'Type:' => $type->name,
340 'Registration no.:' => $this->getStockParam('registrationNumber', ''),
341 'Fuel type:' => $this->getStockSubParam('fuelType', 'name', ''),
342 'Transmission type:' => $this->getStockSubParam('transmissionType', 'name', ''),
343 'VIN no.:' => $this->getStockParam('vinNumber', ''),
344 'Engine no.:' => $this->getStockParam('engineNumber', ''),
345 'MM code:' => $type->mmCode,
346 'Kms:' => $this->getStockParam('km', ''),
347 'Condition:' => $this->getStockSubParam('condition', 'name', ''),
348 'Main exterior colour:' => $this->getStockSubParam('exteriorColour', 'name', ''),
349 'Main interior colour:' => $this->getStockSubParam('interiorColour', 'name', ''),
350 'Upholstery:' => $this->getStockSubParam('upholstery', 'name', ''),
351 'Papers:' => $this->getStockSubParam('papers', 'name', ''),
352 'Papers comments:' => $this->getStockParam('papersNotes', ''),
353 'Natis:' => $this->getStockSubParam('natis', 'name', ''),
354 'Spare keys:' => $keys,
355 'FSH:' => $this->getStockSubParam('fullServiceHistory', 'name', ''),
356 'FSH comments:' => $this->getStockParam('fshNotes', ''),
357 'Stock number:' => $this->getStockParam('stockNumber', '')
358 ), 0, '', 'color:#666;');
359 $vehicleDetail = $table->publish();
363 $damagesDetail = ' ';
364 if ($this->showDamageDetails)
366 $damageData = array();
367 $damages = $this->jobRecord->damagesToArray();
368 foreach ($damages as $damage)
370 $damageData[$damage['damage']['name'] . ':'] = $currencyPrefix . $damage['amount'];
372 $damageData['Total estimated repair cost:'] =
373 '<span style="color:#F00;">' . $currencyPrefix . $this->getStockParam('damageTotal', '') . '</span>';
374 $damageData['Damages comments:'] = $this->getStockParam('damageNotes', '');
375 $damageData['Previous repairs noted:'] = $this->getStockParam('previousRepairsNoted', false)
378 $damageData['Previous repairs comments:'] = $this->getStockParam('previousRepairsNotes', '');
379 $table = $this->newTable(
381 'padding:0;margin:0;font-size:10px;',
383 'padding:2px 3px 2px 0;margin:0;'
385 $type = $this->jobRecord->type;
387 ->addTitle('Damages', 'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1)
388 ->addKeyValueDataSet($damageData, 0, '', 'color:#666;');
389 $damagesDetail = $table->publish();
393 $accessoriesDetail = ' ';
394 if ($this->showAccessoryDetails)
398 $accessories = $this->jobRecord->accessoriesToArray();
399 foreach ($accessories as $accessory)
401 $accs[] = $accessory['accessory']['name'];
405 for ($i = 0; $i <= count($accs); $i += 2)
407 if (isset($accs[$i]))
409 $accData[$accs[$i]] = isset($accs[$i + 1])
415 $accData['<span style="color:#000;font-size:10px;">Comments:</span>'] =
416 '<span style="color:#666;font-size:10px;">' . $this->getStockParam('accessoryNotes', '') . '</span>';
417 $table = $this->newTable(
419 'padding:0;margin:0;font-size:9px;',
421 'padding:2px 3px 2px 0;margin:0;'
423 $type = $this->jobRecord->type;
425 ->addTitle('Accessories', 'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1)
426 ->addKeyValueDataSet($accData, 0, 'color:#666;', 'color:#666;');
427 $accessoriesDetail = $table->publish();
430 #-> Second row of data-blocks.
431 if ($this->showVehicleDetails
432 || $this->showDamageDetails
433 || $this->showAccessoryDetails)
437 array(30, 5, 30, 5, 30),
438 'margin:0;font-size:10px;vertical-align:top;',
440 'padding:10px 0 0 0;'
442 ->setCellValue(0, 0, $vehicleDetail)
443 ->setCellValue(0, 2, $damagesDetail)
444 ->setCellValue(0, 4, $accessoriesDetail);
445 $this->append($container->publish() . '<br />');
448 /* --------------------------------- VEHICLE NOTES --------------------------------- */
450 $VehicleNotes = ' ';
451 if ($this->showVehicleNotes)
453 $table = $this->newTable(
455 'padding:0;margin:0;font-size:10px;',
457 'padding:15px 15px 15px 0;margin:0;'
461 '1______________________________________________________________________________________________________________________________________' => ' ',
462 '2______________________________________________________________________________________________________________________________________' => ' ',
463 '3______________________________________________________________________________________________________________________________________' => ' '
467 ->addTitle('Notes:', 'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1)
468 ->addKeyValueDataSet($dSet, 0, '', 'color:#666;');
469 $VehicleNotes = $table->publish();
471 #-> Third row of data-blocks.
472 if ($this->showVehicleNotes)
476 array(30, 5, 30, 5, 30),
477 'margin:0;font-size:10px;vertical-align:top;',
479 'padding:10px 0 0 0;'
481 ->setCellValue(0, 0, $VehicleNotes);
482 $this->append($container->publish() . '<br />');
489 /* --------------------------------- SIGNATURES --------------------------------- */
491 if ($this->showSignatureLines)
494 $this->newSignatureLine()
495 ->addSignatureLine('Customer (name)', 'Signature', 'Date')
496 ->addSignatureLine('Manager (name)', 'Signature', 'Date')
502 '<div style="position:absolute;bottom:0;left:0;padding:0;margin:0;width:100%;">'
503 . '<table cellpadding="0px" cellspacing="0px" style="border:0px;width:100%;">'
505 . '<td style="width:30%;border-bottom: solid 1px #333;font-size:10px;font-weight:bold;color:#666;"><i>'
506 . $dateOfPrint . '</i></td>'
507 . '<td style="width:5%"> </td>'
508 . '<td style="width:30%;border-bottom: solid 1px #333;font-size:10px;font-weight:bold;color:#666;"><i>'
509 . $printedBy . '</i></td>'
510 . '<td style="width:5%"> </td>'
511 . '<td style="width:30%;border-bottom: solid 1px #333;font-size:10px;font-weight:bold;color:#666;"><i>'
512 . $referenceNo . '</i></td>'
521 /* --------------------------------- TERMS AND CONDITIONS --------------------------------- */
522 #-> Terms and Conditions.
523 if ($this->showTermsAndConditions)
526 $this->append('<br/>');
528 $table = $this->newTable(
530 'padding:0;margin:0;font-size:9px;',
532 'padding:2px 3px 2px 0;margin:0;'
534 $type = $this->jobRecord->type;
536 ->addTitle('Terms and Conditions', 'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1)
537 ->addKeyValueDataSet(array(
538 'I acknowledge, confirm and agree that:' => '',
539 '1. Ownership' => '',
540 '1.1. I am the owner of my trade-in vehicle and I am legally allowed to sell my trade-in vehicle.' => 'Yes / No',
541 '1.2. I am a South African resident.' => 'Yes / No',
542 '1.3. My trade-in vehicle is not subject to a claim of any nature whatsoever by any other person or entity and I '
543 . 'indemnify the Dealer against any claims of any ' => 'Yes / No',
544 '1.4. If my trade-in vehicle is subject to any claim by any other person or entity, the Dealer will not be bound '
545 . 'to this valuation.' => 'Yes / No',
546 '2. VAT Registration' => '',
547 'This transaction is subject to the payment of VAT.' => 'Yes / No',
548 '3. Status of the Vehicle' => '',
549 '3.1. My trade-in vehicle was new when I purchased it.' => 'Yes / No',
550 '3.2. My trade-in vehicle has been used for self-drive hire or taxi work.' => 'Yes / No',
551 '3.3. My trade-in vehicle has a full service history.' => 'Yes / No',
552 '3.4. My trade in vehicle has not been involved in any accident.' => 'Yes / No',
553 '3.5. If my trade-in vehicle has been involved in an accident, there was a total loss claim made (Stolen & Recovered).' => 'Yes / No',
554 '3.6. A current registration paper has been handed over by me.' => 'Yes / No',
555 '3.7. I have supplied the owners and service manuals to the Dealer.' => 'Yes / No',
556 '3.8. My trade-in vehicle is subject to a service and/or maintenance plan and/or warranty.' => 'Yes / No',
557 '4. Status of the Vehicle' => '',
558 'The Dealer will only be bound by its appraised trade-in value of my trade-in vehicle as far as the trade-in has '
559 . 'been approved and accepted in writing by either the dealer principle, designated sales manager or used car manager'
560 . ' and the parties have entered into the Dealer\'s standard Offer to Purchase in respect of my trade-in vehicle.' => '',
561 '5. Outstanding Finance' => '',
562 '5.1. The Dealer, in its absolute and sole discretion, may agree to settle the existing finance in lieu of payment '
563 . '(or part payment) of the trade-in vehicle to me.' => '',
564 '5.2. If the agreed trade-in allowance of the trade-in vehicle is lower than the settlement figure in clause 5.1 above, '
565 . 'I must pay the Registered Credit Provider the difference between the settlement figure and the trade-in allowance with '
566 . 'proof of such payment (made to the registered Credit Provider) submitted to the Dealer prior to the signing of the Offer to Purchase.' => '',
567 '5.3. I will remain liable to the registered Credit Provider in respect of the related finance at all times until the '
568 . 'credit Agreement has been legally terminated.' => '',
569 '5.4. For purposes of clarity, the Dealer does not accept any liability with respect to the related finance set out in '
570 . 'clause 5.4 above at any time or for any reason.' => '',
571 '5.5. The Dealer will use its best endeavors to pay the trade-in allowance to the registered Credit Provider as soon as '
572 . 'is reasonably possible. However the Dealer accepts no liability for any costs or liability incurred by me as a result '
573 . 'of any delay in the payment by the Dealer.' => '',
574 '6. No Financial Advice' => '',
575 'This trade-in valuation does not constitute financial advice to me as contemplated in the Financial Advisory and '
576 . 'Intermediary Services Act 37 of 2002 but is subject to the Consumer Protection Act 68 of 2008.' => '',
578 '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 '
579 . '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.' => '',
580 '8. The Dealer\'s right to withdraw from the offer' => '',
581 'The Dealer is bound by this offer only in so far as:' => '',
582 '8.1. I have signed an Offer to Purchase with the same Dealer in respect of this valuation; and' => '',
583 '8.2. Fewer than 7 (seven) days have passed since the issuing of this valuation; and' => '',
584 '8.3. My trade-in vehicle is in the same condition as the date of inspection; and' => '',
585 '8.4. This trade-in valuation was signed by the Valuator and the Manager of the Dealer.' => '',
586 ' <br /> ' => '',
587 'I HAVE READ THE ABOVE TERMS AND CONDITIONS AND CONFIRM MY UNDERSTANDING AND AGREE TO BE BOUND THERETO.' => '',
588 ' <br /> ' => '',
590 'By signing this form, I agree to the [Dealership Name] valuation terms and conditions above.' => '',
591 ' <br /> <br /> <br /> <br /> <br />' => '',
592 '<b>Signature:</b>' => '',
594 'Date: ' . date('Y-m-d') => ''
595 ), 0, 'color:#333;', 'color:#000;');
596 $this->append($table->publish() . '<br />');
599 '<div style="position:absolute;bottom:0;left:0;padding:0;margin:0;width:100%;">'
600 . '<table cellpadding="0px" cellspacing="0px" style="border:0px;width:100%;">'
602 . '<td style="width:30%;border-bottom: solid 1px #333;font-size:10px;font-weight:bold;color:#666;"><i>'
603 . $dateOfPrint . '</i></td>'
604 . '<td style="width:5%"> </td>'
605 . '<td style="width:30%;border-bottom: solid 1px #333;font-size:10px;font-weight:bold;color:#666;"><i>'
606 . $printedBy . '</i></td>'
607 . '<td style="width:5%"> </td>'
608 . '<td style="width:30%;border-bottom: solid 1px #333;font-size:10px;font-weight:bold;color:#666;"><i>'
609 . $referenceNo . '</i></td>'