jobRecord->$param) ? $this->jobRecord->$param : $default; } /** * Utility for easy parameter retrieval. * @param string $param * @param unknown $default * @return unknown */ protected function getStockSubParam($ref, $param, $default) { $ref = !is_null($this->jobRecord->$ref) ? $this->jobRecord->$ref : null; return is_object($ref) ? $ref->$param : $default; } /** * Utility for easy parameter retrieval. * @param string $param * @param unknown $default * @return unknown */ protected function getValuationParam($param, $default) { return !is_null($this->jobRecord->valuation) && !is_null($this->jobRecord->valuation->$param) ? $this->jobRecord->valuation->$param : $default; } /** * Build the content. */ public function build() { #-> Set data item to work with. $this->auctionRecord = $this->_input['jobRecord']; $this->jobRecord = $this->_input['jobRecord']->stock; $dateTimeFormat = \Utility\Definitions\Locale::getDateTimeFormat(); $currencyPrefix = \Utility\Definitions\Locale::getCurrencyPrefix(); $authData = \Utility\Registry::getAuthData(); $dateOfPrint = 'Date of print: ' . date('Y-m-d H:i:s') . ''; $printedBy = 'Printed by: ' . $authData['firstName'] . ' ' . $authData['familyName'] . ''; $referenceNo = 'Reference no.: ' . $this->jobRecord->referenceNumber . ''; /* --------------------------------- CUSTOMER, VALUATION, PRICING --------------------------------- */ $type = $this->jobRecord->type; $this->append( '
' . $type->model->make->name . ' ' . $type->model->name . ' ' . $type->name . ' (' . $type->introYear->name . ' - ' . (!is_null($type->discYear) ? $type->discYear->name : 'Current') . ')' . '


' ); /* --------------------------------- CUSTOMER, VALUATION, PRICING --------------------------------- */ #-> Customer $customerDetail = ' '; if ($this->showCustomerDetails) { $table = $this->newTable( array(60, 40), 'padding:0;margin:0;font-size:10px;', '', 'padding:2px 3px 2px 0;margin:0;' ); $department = $this->getValuationParam('department', null); $department = !is_null($department) ? $department : ' '; $table ->addTitle('Customer', 'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1) ->addKeyValueDataSet(array( 'Customer name:' => $this->getValuationParam('firstName', ''), 'Customer surname:' => $this->getValuationParam('familyName', ''), 'ID:' => $this->getValuationParam('idNumber', ''), 'Mobile:' => $this->getValuationParam('mobile', ''), 'Email:' => $this->getValuationParam('email', ''), 'Department:' => $department, 'Address:' => ' ', 'a1' => ' ', '1______________________________________' => ' ', 'a' => ' ', '2______________________________________' => ' ', 'b' => ' ', '3______________________________________' => ' ' ), 0, 'font-weight:bold;', 'color:#666;'); $customerDetail = $table->publish(); } #-> Customer alternated with dealership details for traders. if ($this->showTradeDataOnly) { $table = $this->newTable( array(60, 40), 'padding:0;margin:0;font-size:10px;', '', 'padding:2px 3px 2px 0;margin:0;' ); $department = $this->getValuationParam('department', null); $department = !is_null($department) ? $department : ' '; $contact = $this->getStockSubParam('company', 'contact', null); $table ->addTitle('Dealership', 'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1) ->addKeyValueDataSet(array( 'Dealership name:' => $this->getStockSubParam('company', 'name', ''), 'Contact:' => !is_null($contact) ? $contact->firstName . ' ' . $contact->familyName : '', 'Mobile:' => !is_null($contact) ? $contact->mobile : '', 'Email:' => !is_null($contact) ? $contact->email : '' ), 0, 'font-weight:bold;', 'color:#666;'); $customerDetail = $table->publish(); } #-> Valuation $valuationDetail = ' '; if ($this->showValuationDetails) { $table = $this->newTable( array(55, 45), 'padding:0;margin:0;font-size:10px;', '', 'padding:2px 3px 2px 0;margin:0;' ); $pgItem = $this->em ->getRepository('\Auction\Entity\Auction') ->findOneBy(array('stock' => $this->jobRecord)); $pgLoaded = !is_null($pgItem) ? $pgItem->created->format($dateTimeFormat) : ' '; $valCreated = $this->getValuationParam('created', null); $valCreated = !is_null($valCreated) ? $valCreated->format($dateTimeFormat) : ' '; $table ->addTitle('Valuation details', 'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1) ->addKeyValueDataSet($this->showTradeDataOnly ? array( 'Date created:' => $valCreated, 'Date loaded on price guide:' => $pgLoaded ) : array( 'Date created:' => $valCreated, 'Valuation no.:' => $this->getValuationParam('valuationNumber', ''), 'Reference no.:' => $this->getStockParam('referenceNumber', ''), 'Date loaded on price guide:' => $pgLoaded ), 0, 'font-weight:bold;', 'color:#F00;'); $valuationDetail = $table->publish(); } $mainImage = ' '; if ($this->showMainImage) { $pic = $this->getStockParam('mainImage', ''); if (is_object($pic)) { $mainImage = ''; } } #-> Pricing details $pricingDetail = ' '; $total = $this->getValuationParam('overAllowance', '0.00') + $this->getValuationParam('amountOffered', '0.00'); $total = number_format($total, 2, '.', ''); if ($this->showPricingDetails) { $table = $this->newTable( array(60, 40), 'padding:0;margin:0;font-size:10px;', '', 'padding:2px 3px 2px 0;margin:0;' ); $table ->addTitle('Pricing details', 'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1) ->addKeyValueDataSet($this->showTradeDataOnly ? array( 'Trade:' => $currencyPrefix . $this->getStockParam('tradePrice', '0.00'), 'Retail:' => $currencyPrefix . $this->getStockParam('retailPrice', '0.00'), 'List:' => $currencyPrefix . $this->getStockParam('listPrice', '0.00'), 'Reserve price:' => $currencyPrefix . $this->auctionRecord->reservePrice, 'Highest bid:' => $currencyPrefix . $this->getStockParam('highestBid', '0.00') /* 'Amount offered:' => $currencyPrefix . $this->getValuationParam('amountOffered', '0.00'), */ /* 'O.A.:' => $currencyPrefix . $this->getValuationParam('overAllowance', '0.00'), */ /* 'Total offer:' => $currencyPrefix . $total, // total offer = amount offered + O.A */ ) : array( 'Trade:' => $currencyPrefix . $this->getStockParam('tradePrice', '0.00'), 'Retail:' => $currencyPrefix . $this->getStockParam('retailPrice', '0.00'), 'List:' => $currencyPrefix . $this->getStockParam('listPrice', '0.00'), 'Amount offered:' => $currencyPrefix . $this->getValuationParam('amountOffered', '0.00'), 'O.A.:' => $currencyPrefix . $this->getValuationParam('overAllowance', '0.00'), 'Total offer:' => $currencyPrefix . $total, // total offer = amount offered + O.A 'Projected retail:' => $currencyPrefix, 'Planned margin:' => $currencyPrefix, 'Price guide highest offer:' => $currencyPrefix . $this->getStockParam('highestOffer', '0.00') ), 0, 'font-weight:bold;', 'color:#F00;'); $pricingDetail = $table->publish(); } #-> First row of data-blocks. if ($this->showCustomerDetails || $this->showValuationDetails || $this->showMainImage || $this->showPricingDetails) { $container = $this ->newTable( array(30, 5, 30, 5, 30), 'margin:0;font-size:10px;vertical-align:top;', '', 'padding:10px 0 0 0;' ) ->setCellValue(0, 0, $customerDetail) ->setCellValue(0, 2, $pricingDetail) ->setCellValue(0, 4, $valuationDetail . $mainImage); $this->append($container->publish() . '
'); } /* --------------------------------- Buyer Details --------------------------------- */ if (true) { $table = $this->newTable( array(30, 30), 'padding:0;margin:0;font-size:10px;', '', 'padding:2px 3px 2px 0;margin:0;' ); $table ->addTitle('Buyers Details', 'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1) ->addKeyValueDataSet(array( 'Dealership name:' => $this->auctionRecord->soldToCompany->name, 'Contact:' => !is_null($this->auctionRecord->soldToProfile) ? $this->auctionRecord->soldToProfile->firstName . ' ' . $this->auctionRecord->soldToProfile->familyName : '', 'Mobile:' => !is_null($this->auctionRecord->soldToProfile) ? $this->auctionRecord->soldToProfile->mobile : '', 'Email:' => !is_null($this->auctionRecord->soldToProfile) ? $this->auctionRecord->soldToProfile->email : '' ), 0, 'font-weight:bold;', 'color:#666;'); $buyerDetails = $table->publish(); $this->append($buyerDetails . '
'); } /* --------------------------------- VEHICLE, DAMAGES, ACCESSORIES --------------------------------- */ #-> Vehicle details $vehicleDetail = ' '; if ($this->showVehicleDetails) { $keys = $this->getStockParam('spareKeys', null); if (is_null($keys)) { $keys = ''; } else { $keys = $keys ? 'Yes' : 'No'; } $table = $this->newTable( array(55, 45), 'padding:0;margin:0;font-size:10px;', '', 'padding:2px 3px 2px 0;margin:0;' ); $table ->addTitle('Vehicle specifications', 'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1) ->addKeyValueDataSet(array( 'Year:' => $this->getStockSubParam('vehicleYear', 'name', ''), 'Category:' => $type->category->name, 'Make:' => $type->model->make->name, 'Model:' => $type->model->name, 'Type:' => $type->name, 'Registration no.:' => $this->getStockParam('registrationNumber', ''), 'Fuel type:' => $this->getStockSubParam('fuelType', 'name', ''), 'Transmission type:' => $this->getStockSubParam('transmissionType', 'name', ''), 'VIN no.:' => $this->getStockParam('vinNumber', ''), 'Engine no.:' => $this->getStockParam('engineNumber', ''), 'MM code:' => $type->mmCode, 'Kms:' => $this->getStockParam('km', ''), 'Condition:' => $this->getStockSubParam('condition', 'name', ''), 'Main exterior colour:' => $this->getStockSubParam('exteriorColour', 'name', ''), 'Main interior colour:' => $this->getStockSubParam('interiorColour', 'name', ''), 'Upholstery:' => $this->getStockSubParam('upholstery', 'name', ''), 'Papers:' => $this->getStockSubParam('papers', 'name', ''), 'Papers comments:' => $this->getStockParam('papersNotes', ''), 'Natis:' => $this->getStockSubParam('natis', 'name', ''), 'Spare keys:' => $keys, 'FSH:' => $this->getStockSubParam('fullServiceHistory', 'name', ''), 'FSH comments:' => $this->getStockParam('fshNotes', ''), 'Stock number:' => $this->getStockParam('stockNumber', '') ), 0, '', 'color:#666;'); $vehicleDetail = $table->publish(); } #-> Damages $damagesDetail = ' '; if ($this->showDamageDetails) { $damageData = array(); $damages = $this->jobRecord->damagesToArray(); foreach ($damages as $damage) { $damageData[$damage['damage']['name'] . ':'] = $currencyPrefix . $damage['amount']; } $damageData['Total estimated repair cost:'] = '' . $currencyPrefix . $this->getStockParam('damageTotal', '') . ''; $damageData['Damages comments:'] = $this->getStockParam('damageNotes', ''); $damageData['Previous repairs noted:'] = $this->getStockParam('previousRepairsNoted', false) ? 'Yes' : 'No'; $damageData['Previous repairs comments:'] = $this->getStockParam('previousRepairsNotes', ''); $table = $this->newTable( array(50, 50), 'padding:0;margin:0;font-size:10px;', '', 'padding:2px 3px 2px 0;margin:0;' ); $type = $this->jobRecord->type; $table ->addTitle('Damages', 'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1) ->addKeyValueDataSet($damageData, 0, '', 'color:#666;'); $damagesDetail = $table->publish(); } #-> Accessories $accessoriesDetail = ' '; if ($this->showAccessoryDetails) { $accs = array(); $accData = array(); $accessories = $this->jobRecord->accessoriesToArray(); foreach ($accessories as $accessory) { $accs[] = $accessory['accessory']['name']; } if (!empty($accs)) { for ($i = 0; $i <= count($accs); $i += 2) { if (isset($accs[$i])) { $accData[$accs[$i]] = isset($accs[$i + 1]) ? $accs[$i + 1] : ''; } } } $accData['Comments:'] = '' . $this->getStockParam('accessoryNotes', '') . ''; $table = $this->newTable( array(50, 50), 'padding:0;margin:0;font-size:9px;', '', 'padding:2px 3px 2px 0;margin:0;' ); $type = $this->jobRecord->type; $table ->addTitle('Accessories', 'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1) ->addKeyValueDataSet($accData, 0, 'color:#666;', 'color:#666;'); $accessoriesDetail = $table->publish(); } #-> Second row of data-blocks. if ($this->showVehicleDetails || $this->showDamageDetails || $this->showAccessoryDetails) { $container = $this ->newTable( array(30, 5, 30, 5, 30), 'margin:0;font-size:10px;vertical-align:top;', '', 'padding:10px 0 0 0;' ) ->setCellValue(0, 0, $vehicleDetail) ->setCellValue(0, 2, $damagesDetail) ->setCellValue(0, 4, $accessoriesDetail); $this->append($container->publish() . '
'); } /* --------------------------------- VEHICLE NOTES --------------------------------- */ #-> Vehicle Notes $VehicleNotes = ' '; if ($this->showVehicleNotes) { $table = $this->newTable( array(55, 45), 'padding:0;margin:0;font-size:10px;', '', 'padding:15px 15px 15px 0;margin:0;' ); $dSet = array( '1______________________________________________________________________________________________________________________________________' => ' ', '2______________________________________________________________________________________________________________________________________' => ' ', '3______________________________________________________________________________________________________________________________________' => ' ' ); $table ->addTitle('Notes:', 'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1) ->addKeyValueDataSet($dSet, 0, '', 'color:#666;'); $VehicleNotes = $table->publish(); } #-> Third row of data-blocks. if ($this->showVehicleNotes) { $container = $this ->newTable( array(30, 5, 30, 5, 30), 'margin:0;font-size:10px;vertical-align:top;', '', 'padding:10px 0 0 0;' ) ->setCellValue(0, 0, $VehicleNotes); $this->append($container->publish() . '
'); } /* --------------------------------- SIGNATURES --------------------------------- */ #-> Signatures. if ($this->showSignatureLines) { $this->append( $this->newSignatureLine() ->addSignatureLine('Customer (name)', 'Signature', 'Date') ->addSignatureLine('Manager (name)', 'Signature', 'Date') ->publish() ); } $this->append( '
' . '' . '' . '' . '' . '' . '' . '' . '' . '
' . $dateOfPrint . ' ' . $printedBy . ' ' . $referenceNo . '
' . '
' ); /* --------------------------------- TERMS AND CONDITIONS --------------------------------- */ #-> Terms and Conditions. if ($this->showTermsAndConditions) { $this->nextPage(); $this->append('
'); $table = $this->newTable( array(90, 10), 'padding:0;margin:0;font-size:9px;', '', 'padding:2px 3px 2px 0;margin:0;' ); $type = $this->jobRecord->type; $table ->addTitle('Terms and Conditions', 'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1) ->addKeyValueDataSet(array( 'I acknowledge, confirm and agree that:' => '', '1. Ownership' => '', '1.1. I am the owner of my trade-in vehicle and I am legally allowed to sell my trade-in vehicle.' => 'Yes / No', '1.2. I am a South African resident.' => 'Yes / No', '1.3. My trade-in vehicle is not subject to a claim of any nature whatsoever by any other person or entity and I ' . 'indemnify the Dealer against any claims of any ' => 'Yes / No', '1.4. If my trade-in vehicle is subject to any claim by any other person or entity, the Dealer will not be bound ' . 'to this valuation.' => 'Yes / No', '2. VAT Registration' => '', 'This transaction is subject to the payment of VAT.' => 'Yes / No', '3. Status of the Vehicle' => '', '3.1. My trade-in vehicle was new when I purchased it.' => 'Yes / No', '3.2. My trade-in vehicle has been used for self-drive hire or taxi work.' => 'Yes / No', '3.3. My trade-in vehicle has a full service history.' => 'Yes / No', '3.4. My trade in vehicle has not been involved in any accident.' => 'Yes / No', '3.5. If my trade-in vehicle has been involved in an accident, there was a total loss claim made (Stolen & Recovered).' => 'Yes / No', '3.6. A current registration paper has been handed over by me.' => 'Yes / No', '3.7. I have supplied the owners and service manuals to the Dealer.' => 'Yes / No', '3.8. My trade-in vehicle is subject to a service and/or maintenance plan and/or warranty.' => 'Yes / No', '4. Status of the Vehicle' => '', 'The Dealer will only be bound by its appraised trade-in value of my trade-in vehicle as far as the trade-in has ' . 'been approved and accepted in writing by either the dealer principle, designated sales manager or used car manager' . ' and the parties have entered into the Dealer\'s standard Offer to Purchase in respect of my trade-in vehicle.' => '', '5. Outstanding Finance' => '', '5.1. The Dealer, in its absolute and sole discretion, may agree to settle the existing finance in lieu of payment ' . '(or part payment) of the trade-in vehicle to me.' => '', '5.2. If the agreed trade-in allowance of the trade-in vehicle is lower than the settlement figure in clause 5.1 above, ' . 'I must pay the Registered Credit Provider the difference between the settlement figure and the trade-in allowance with ' . 'proof of such payment (made to the registered Credit Provider) submitted to the Dealer prior to the signing of the Offer to Purchase.' => '', '5.3. I will remain liable to the registered Credit Provider in respect of the related finance at all times until the ' . 'credit Agreement has been legally terminated.' => '', '5.4. For purposes of clarity, the Dealer does not accept any liability with respect to the related finance set out in ' . 'clause 5.4 above at any time or for any reason.' => '', '5.5. The Dealer will use its best endeavors to pay the trade-in allowance to the registered Credit Provider as soon as ' . 'is reasonably possible. However the Dealer accepts no liability for any costs or liability incurred by me as a result ' . 'of any delay in the payment by the Dealer.' => '', '6. No Financial Advice' => '', 'This trade-in valuation does not constitute financial advice to me as contemplated in the Financial Advisory and ' . 'Intermediary Services Act 37 of 2002 but is subject to the Consumer Protection Act 68 of 2008.' => '', '7. Risk' => '', '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 ' . '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.' => '', '8. The Dealer\'s right to withdraw from the offer' => '', 'The Dealer is bound by this offer only in so far as:' => '', '8.1. I have signed an Offer to Purchase with the same Dealer in respect of this valuation; and' => '', '8.2. Fewer than 7 (seven) days have passed since the issuing of this valuation; and' => '', '8.3. My trade-in vehicle is in the same condition as the date of inspection; and' => '', '8.4. This trade-in valuation was signed by the Valuator and the Manager of the Dealer.' => '', ' 
 ' => '', 'I HAVE READ THE ABOVE TERMS AND CONDITIONS AND CONFIRM MY UNDERSTANDING AND AGREE TO BE BOUND THERETO.' => '', ' 
 ' => '', 'Acceptance' => '', 'By signing this form, I agree to the [Dealership Name] valuation terms and conditions above.' => '', ' 
 
 
 
 
' => '', 'Signature:' => '', ' ' => '', 'Date: ' . date('Y-m-d') => '' ), 0, 'color:#333;', 'color:#000;'); $this->append($table->publish() . '
'); $this->append( '
' . '' . '' . '' . '' . '' . '' . '' . '' . '
' . $dateOfPrint . ' ' . $printedBy . ' ' . $referenceNo . '
' . '
' ); } /* --------------------------------- OFFERS RECEIVED/MADE --------------------------------- */ #-> Offers received. if ($this->showOffersReceived || $this->showOfferMade) { if ($this->showOffersReceived) { $offers = array(); $pgItems = $this->em ->getRepository('\PriceGuide\Entity\PriceGuide') ->findBy(array('stock' => $this->jobRecord)); if (!empty($pgItems)) { foreach ($pgItems as $pgItem) { $iterator = $pgItem->offers->getIterator(); foreach ($iterator as $offer) { $status = $offer->status; $offers[] = array( $offer->company->name, $offer->created->format($dateTimeFormat), $currencyPrefix . $offer->amount, $offer->profile->mobile, $offer->profile->email, $status ); } } $this->nextPage(); $this->append('
'); $table = $this->newTable( array(20, 15, 15, 10, 30, 10), 'padding:0;margin:0;font-size:10px;', '', 'padding:2px 5px 2px 2px;margin:0;' ); $table ->addTitle('Offers received', 'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1) ->setColumnHeaders(array( 'Buyer', 'Date', 'Offer', 'Mobile', 'Email', 'Status' ), array(20, 15, 15, 10, 30, 10), 'padding:2px 2px 2px 5px;background-color:#F00;color:#FFF;font-weight:bold;font-size:10px;') ->setDataSet($offers); $this->append($table->publish() . '
'); $this->append( '
' . '' . '' . '' . '' . '' . '' . '' . '' . '
' . $dateOfPrint . ' ' . $printedBy . ' ' . $referenceNo . '
' . '
' ); } } #-> Offer made. if ($this->showOfferMade) { $offers = array(); $pgItem = $this->em ->getRepository('\PriceGuide\Entity\PriceGuide') ->findOneBy(array('stock' => $this->jobRecord)); if (!is_null($pgItem)) { $companyId = \Utility\Registry::resolveCompanyContext(); $iterator = $pgItem->offers->getIterator(); foreach ($iterator as $offer) { $status = $offer->status; $offers[] = array( $offer->company->name, $offer->created->format($dateTimeFormat), $currencyPrefix . $offer->amount, $offer->profile->mobile, $offer->profile->email, $status ); } $table = $this->newTable( array(20, 15, 15, 10, 30, 10), 'padding:0;margin:0;font-size:10px;', '', 'padding:2px 5px 2px 2px;margin:0;' ); $this->nextPage(); $this->append('
'); $table ->addTitle('Offers made', 'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1) ->setColumnHeaders(array( 'Buyer', 'Date', 'Offer', 'Mobile', 'Email', 'Status' ), array(20, 15, 15, 10, 30, 10), 'padding:2px 2px 2px 5px;background-color:#F00;color:#FFF;font-weight:bold;font-size:10px;') ->setDataSet($offers); $this->append($table->publish() . '
'); $this->append( '
' . '' . '' . '' . '' . '' . '' . '' . '' . '
' . $dateOfPrint . ' ' . $printedBy . ' ' . $referenceNo . '
' . '
' ); } } } // /* --------------------------------- BID HISTORY --------------------------------- */ // $this->nextPage(); // $table = $this->newTable( // array(20, 15, 10, 10, 20, 15, 10), 'padding:0;margin:0;font-size:10px;', // '', 'padding:2px 3px 2px 0;margin:0;' // ); // // $table // ->addTitle('Bid History', // 'padding:0 0 10px 0;font-weight:bold;font-size:11px;', 0, 1); // // $table->setColumnHeaders(array( // 'Dealership', // 'User', // 'Bid Amount', // 'Mobile', // 'Email', // 'Created', // 'Status' // ), array(20, 15, 10, 10, 20, 15, 10), 'font-weight: bold; color: #ffffff; background-color: #D42E30;'); // // $data = array(); // foreach ($this->auctionRecord->bids as $bid) // { // $data[] = array ( // $bid->company->name, // $bid->profile->firstName . ' ' . $bid->profile->familyName, // $bid->amount, // $bid->profile->mobile, // $bid->profile->email, // $bid->created->format('Y-m-d H:i:s'), // $bid->status, // ); // } // // $table->setDataSet($data); // // // $bidHistory = $table->publish(); // // $this->append($bidHistory . '
'); return; } }