6 class CompleteNew 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 'Highest bid:' => $currencyPrefix . $this->getStockParam('highestBid', '0.00')
275 /* 'Amount offered:' => $currencyPrefix . $this->getValuationParam('amountOffered', '0.00'), */
276 /* 'O.A.:' => $currencyPrefix . $this->getValuationParam('overAllowance', '0.00'), */
277 /* 'Total offer:' => $currencyPrefix . $total, // total offer = amount offered + O.A */
280 'Trade:' => $currencyPrefix . $this->getStockParam('tradePrice', '0.00'),
281 'Retail:' => $currencyPrefix . $this->getStockParam('retailPrice', '0.00'),
282 'List:' => $currencyPrefix . $this->getStockParam('listPrice', '0.00'),
283 'Amount offered:' => $currencyPrefix . $this->getValuationParam('amountOffered', '0.00'),
284 'O.A.:' => $currencyPrefix . $this->getValuationParam('overAllowance', '0.00'),
285 'Total offer:' => $currencyPrefix . $total, // total offer = amount offered + O.A
286 'Projected retail:' => $currencyPrefix,
287 'Planned margin:' => $currencyPrefix,
288 'Price guide highest offer:' => $currencyPrefix . $this->getStockParam('highestOffer', '0.00')
289 ), 0, 'font-weight:bold;', 'color:#F00;');
290 $pricingDetail = $table->publish();
293 #-> First row of data-blocks.
294 if ($this->showCustomerDetails
295 || $this->showValuationDetails
296 || $this->showMainImage
297 || $this->showPricingDetails)
301 array(30, 5, 30, 5, 30),
302 'margin:0;font-size:10px;vertical-align:top;',
304 'padding:10px 0 0 0;'
306 ->setCellValue(0, 0, $customerDetail)
307 ->setCellValue(0, 2, $pricingDetail)
308 ->setCellValue(0, 4, $valuationDetail . $mainImage);
309 $this->append($container->publish() . '<br />');
313 /* --------------------------------- VEHICLE, DAMAGES, ACCESSORIES --------------------------------- */
316 $vehicleDetail = ' ';
317 if ($this->showVehicleDetails)
319 $keys = $this->getStockParam('spareKeys', null);
330 $table = $this->newTable(
332 'padding:0;margin:0;font-size:10px;',
334 'padding:2px 3px 2px 0;margin:0;'
337 ->addTitle('Vehicle specifications', 'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1)
338 ->addKeyValueDataSet(array(
339 'Year:' => $this->getStockSubParam('vehicleYear', 'name', ''),
340 'Category:' => $type->category->name,
341 'Make:' => $type->model->make->name,
342 'Model:' => $type->model->name,
343 'Type:' => $type->name,
344 'Registration no.:' => $this->getStockParam('registrationNumber', ''),
345 'Fuel type:' => $this->getStockSubParam('fuelType', 'name', ''),
346 'Transmission type:' => $this->getStockSubParam('transmissionType', 'name', ''),
347 'VIN no.:' => $this->getStockParam('vinNumber', ''),
348 'Engine no.:' => $this->getStockParam('engineNumber', ''),
349 'MM code:' => $type->mmCode,
350 'Kms:' => $this->getStockParam('km', ''),
351 'Condition:' => $this->getStockSubParam('condition', 'name', ''),
352 'Main exterior colour:' => $this->getStockSubParam('exteriorColour', 'name', ''),
353 'Main interior colour:' => $this->getStockSubParam('interiorColour', 'name', ''),
354 'Upholstery:' => $this->getStockSubParam('upholstery', 'name', ''),
355 'Papers:' => $this->getStockSubParam('papers', 'name', ''),
356 'Papers comments:' => $this->getStockParam('papersNotes', ''),
357 'Natis:' => $this->getStockSubParam('natis', 'name', ''),
358 'Spare keys:' => $keys,
359 'FSH:' => $this->getStockSubParam('fullServiceHistory', 'name', ''),
360 'FSH comments:' => $this->getStockParam('fshNotes', ''),
361 'Stock number:' => $this->getStockParam('stockNumber', '')
362 ), 0, '', 'color:#666;');
363 $vehicleDetail = $table->publish();
367 $damagesDetail = ' ';
368 if ($this->showDamageDetails)
370 $damageData = array();
371 $damages = $this->jobRecord->damagesToArray();
372 foreach ($damages as $damage)
374 $damageData[$damage['damage']['name'] . ':'] = $currencyPrefix . $damage['amount'];
376 $damageData['Total estimated repair cost:'] =
377 '<span style="color:#F00;">' . $currencyPrefix . $this->getStockParam('damageTotal', '') . '</span>';
378 $damageData['Damages comments:'] = $this->getStockParam('damageNotes', '');
379 $damageData['Previous repairs noted:'] = $this->getStockParam('previousRepairsNoted', false)
382 $damageData['Previous repairs comments:'] = $this->getStockParam('previousRepairsNotes', '');
383 $table = $this->newTable(
385 'padding:0;margin:0;font-size:10px;',
387 'padding:2px 3px 2px 0;margin:0;'
389 $type = $this->jobRecord->type;
391 ->addTitle('Damages', 'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1)
392 ->addKeyValueDataSet($damageData, 0, '', 'color:#666;');
393 $damagesDetail = $table->publish();
397 $accessoriesDetail = ' ';
398 if ($this->showAccessoryDetails)
402 $accessories = $this->jobRecord->accessoriesToArray();
403 foreach ($accessories as $accessory)
405 $accs[] = $accessory['accessory']['name'];
409 for ($i = 0; $i <= count($accs); $i += 2)
411 if (isset($accs[$i]))
413 $accData[$accs[$i]] = isset($accs[$i + 1])
419 $accData['<span style="color:#000;font-size:10px;">Comments:</span>'] =
420 '<span style="color:#666;font-size:10px;">' . $this->getStockParam('accessoryNotes', '') . '</span>';
421 $table = $this->newTable(
423 'padding:0;margin:0;font-size:9px;',
425 'padding:2px 3px 2px 0;margin:0;'
427 $type = $this->jobRecord->type;
429 ->addTitle('Accessories', 'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1)
430 ->addKeyValueDataSet($accData, 0, 'color:#666;', 'color:#666;');
431 $accessoriesDetail = $table->publish();
434 #-> Second row of data-blocks.
435 if ($this->showVehicleDetails
436 || $this->showDamageDetails
437 || $this->showAccessoryDetails)
441 array(30, 5, 30, 5, 30),
442 'margin:0;font-size:10px;vertical-align:top;',
444 'padding:10px 0 0 0;'
446 ->setCellValue(0, 0, $vehicleDetail)
447 ->setCellValue(0, 2, $damagesDetail)
448 ->setCellValue(0, 4, $accessoriesDetail);
449 $this->append($container->publish() . '<br />');
452 /* --------------------------------- VEHICLE NOTES --------------------------------- */
454 $VehicleNotes = ' ';
455 if ($this->showVehicleNotes)
457 $table = $this->newTable(
459 'padding:0;margin:0;font-size:10px;',
461 'padding:15px 15px 15px 0;margin:0;'
465 '1______________________________________________________________________________________________________________________________________' => ' ',
466 '2______________________________________________________________________________________________________________________________________' => ' ',
467 '3______________________________________________________________________________________________________________________________________' => ' '
471 ->addTitle('Notes:', 'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1)
472 ->addKeyValueDataSet($dSet, 0, '', 'color:#666;');
473 $VehicleNotes = $table->publish();
475 #-> Third row of data-blocks.
476 if ($this->showVehicleNotes)
480 array(30, 5, 30, 5, 30),
481 'margin:0;font-size:10px;vertical-align:top;',
483 'padding:10px 0 0 0;'
485 ->setCellValue(0, 0, $VehicleNotes);
486 $this->append($container->publish() . '<br />');
493 /* --------------------------------- SIGNATURES --------------------------------- */
495 if ($this->showSignatureLines)
498 $this->newSignatureLine()
499 ->addSignatureLine('Customer (name)', 'Signature', 'Date')
500 ->addSignatureLine('Manager (name)', 'Signature', 'Date')
506 '<div style="position:absolute;bottom:0;left:0;padding:0;margin:0;width:100%;">'
507 . '<table cellpadding="0px" cellspacing="0px" style="border:0px;width:100%;">'
509 . '<td style="width:30%;border-bottom: solid 1px #333;font-size:10px;font-weight:bold;color:#666;"><i>'
510 . $dateOfPrint . '</i></td>'
511 . '<td style="width:5%"> </td>'
512 . '<td style="width:30%;border-bottom: solid 1px #333;font-size:10px;font-weight:bold;color:#666;"><i>'
513 . $printedBy . '</i></td>'
514 . '<td style="width:5%"> </td>'
515 . '<td style="width:30%;border-bottom: solid 1px #333;font-size:10px;font-weight:bold;color:#666;"><i>'
516 . $referenceNo . '</i></td>'
525 /* --------------------------------- TERMS AND CONDITIONS --------------------------------- */
526 #-> Terms and Conditions.
527 if ($this->showTermsAndConditions)
530 $this->append('<br/>');
532 $table = $this->newTable(
534 'padding:0;margin:0;font-size:9px;',
536 'padding:2px 3px 2px 0;margin:0;'
538 $type = $this->jobRecord->type;
540 ->addTitle('Terms and Conditions', 'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1)
541 ->addKeyValueDataSet(array(
542 'I acknowledge, confirm and agree that:' => '',
543 '1. Ownership' => '',
544 '1.1. I am the owner of my trade-in vehicle and I am legally allowed to sell my trade-in vehicle.' => 'Yes / No',
545 '1.2. I am a South African resident.' => 'Yes / No',
546 '1.3. My trade-in vehicle is not subject to a claim of any nature whatsoever by any other person or entity and I '
547 . 'indemnify the Dealer against any claims of any ' => 'Yes / No',
548 '1.4. If my trade-in vehicle is subject to any claim by any other person or entity, the Dealer will not be bound '
549 . 'to this valuation.' => 'Yes / No',
550 '2. VAT Registration' => '',
551 'This transaction is subject to the payment of VAT.' => 'Yes / No',
552 '3. Status of the Vehicle' => '',
553 '3.1. My trade-in vehicle was new when I purchased it.' => 'Yes / No',
554 '3.2. My trade-in vehicle has been used for self-drive hire or taxi work.' => 'Yes / No',
555 '3.3. My trade-in vehicle has a full service history.' => 'Yes / No',
556 '3.4. My trade in vehicle has not been involved in any accident.' => 'Yes / No',
557 '3.5. If my trade-in vehicle has been involved in an accident, there was a total loss claim made (Stolen & Recovered).' => 'Yes / No',
558 '3.6. A current registration paper has been handed over by me.' => 'Yes / No',
559 '3.7. I have supplied the owners and service manuals to the Dealer.' => 'Yes / No',
560 '3.8. My trade-in vehicle is subject to a service and/or maintenance plan and/or warranty.' => 'Yes / No',
561 '4. Status of the Vehicle' => '',
562 'The Dealer will only be bound by its appraised trade-in value of my trade-in vehicle as far as the trade-in has '
563 . 'been approved and accepted in writing by either the dealer principle, designated sales manager or used car manager'
564 . ' and the parties have entered into the Dealer\'s standard Offer to Purchase in respect of my trade-in vehicle.' => '',
565 '5. Outstanding Finance' => '',
566 '5.1. The Dealer, in its absolute and sole discretion, may agree to settle the existing finance in lieu of payment '
567 . '(or part payment) of the trade-in vehicle to me.' => '',
568 '5.2. If the agreed trade-in allowance of the trade-in vehicle is lower than the settlement figure in clause 5.1 above, '
569 . 'I must pay the Registered Credit Provider the difference between the settlement figure and the trade-in allowance with '
570 . 'proof of such payment (made to the registered Credit Provider) submitted to the Dealer prior to the signing of the Offer to Purchase.' => '',
571 '5.3. I will remain liable to the registered Credit Provider in respect of the related finance at all times until the '
572 . 'credit Agreement has been legally terminated.' => '',
573 '5.4. For purposes of clarity, the Dealer does not accept any liability with respect to the related finance set out in '
574 . 'clause 5.4 above at any time or for any reason.' => '',
575 '5.5. The Dealer will use its best endeavors to pay the trade-in allowance to the registered Credit Provider as soon as '
576 . 'is reasonably possible. However the Dealer accepts no liability for any costs or liability incurred by me as a result '
577 . 'of any delay in the payment by the Dealer.' => '',
578 '6. No Financial Advice' => '',
579 'This trade-in valuation does not constitute financial advice to me as contemplated in the Financial Advisory and '
580 . 'Intermediary Services Act 37 of 2002 but is subject to the Consumer Protection Act 68 of 2008.' => '',
582 '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 '
583 . '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.' => '',
584 '8. The Dealer\'s right to withdraw from the offer' => '',
585 'The Dealer is bound by this offer only in so far as:' => '',
586 '8.1. I have signed an Offer to Purchase with the same Dealer in respect of this valuation; and' => '',
587 '8.2. Fewer than 7 (seven) days have passed since the issuing of this valuation; and' => '',
588 '8.3. My trade-in vehicle is in the same condition as the date of inspection; and' => '',
589 '8.4. This trade-in valuation was signed by the Valuator and the Manager of the Dealer.' => '',
590 ' <br /> ' => '',
591 'I HAVE READ THE ABOVE TERMS AND CONDITIONS AND CONFIRM MY UNDERSTANDING AND AGREE TO BE BOUND THERETO.' => '',
592 ' <br /> ' => '',
594 'By signing this form, I agree to the [Dealership Name] valuation terms and conditions above.' => '',
595 ' <br /> <br /> <br /> <br /> <br />' => '',
596 '<b>Signature:</b>' => '',
598 'Date: ' . date('Y-m-d') => ''
599 ), 0, 'color:#333;', 'color:#000;');
600 $this->append($table->publish() . '<br />');
603 '<div style="position:absolute;bottom:0;left:0;padding:0;margin:0;width:100%;">'
604 . '<table cellpadding="0px" cellspacing="0px" style="border:0px;width:100%;">'
606 . '<td style="width:30%;border-bottom: solid 1px #333;font-size:10px;font-weight:bold;color:#666;"><i>'
607 . $dateOfPrint . '</i></td>'
608 . '<td style="width:5%"> </td>'
609 . '<td style="width:30%;border-bottom: solid 1px #333;font-size:10px;font-weight:bold;color:#666;"><i>'
610 . $printedBy . '</i></td>'
611 . '<td style="width:5%"> </td>'
612 . '<td style="width:30%;border-bottom: solid 1px #333;font-size:10px;font-weight:bold;color:#666;"><i>'
613 . $referenceNo . '</i></td>'