

namibia
bb2698c383a0585633180c7996aba816667c9e6d
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
<?php namespace Valuation\Report; /** * Stock Contyrol Report. * @author andre.fourie */ class ValuationGrid extends \Utility\Service\Report { /** * @var string */ protected $_title = 'Valuation Data Export'; /** * @var string */ protected $_subject = 'Valuations'; /** * @var string */ protected $_description = 'Export of valuations.'; /** * @var array */ protected $_notes = array( 'Confidential information, generated using Bid 4 Cars, for more information visit bid4cars.com.na' ); /** * @var array */ protected $_headers = array( 'Dealer', 'Group', 'Division', 'Reference Number', 'Registration Number', 'VIN Number', 'Make', 'Model', 'Type', 'MM Code', 'Year', 'Main Exterior Colour', 'KM', 'Trade Price', 'Recon costs', 'Price Offered to Sales', '% of Trade', 'Date loaded on price guide', 'Number of price guide offers', 'Highest price guide offer', 'Highest price Dealer Name(s)', 'Status', 'Sales Person', 'Manager' ); /** * @var array */ protected $_fields = array( 'company_name', 'companyGroup_name', 'groupDivision_name', 'stock_referenceNumber', 'stock_registrationNumber', 'stock_vinNumber', 'make_name', 'model_name', 'type_name', 'type_mmCode', 'vehicleYear_name', 'exteriorColour_name', 'stock_km', 'stock_tradePrice', 'stock_damageTotal', 'valuation_amountOffered', 'valuation_updated', 'stock_loadedOnPriceGuide', 'stock_numberOfOffers', 'stock_highestOffer', 'higestoffernames', 'valuation_jobState', 'salesProfile_fullName', 'managerProfile_fullName' ); /** * @var array */ protected $_totals = array( 'stock_tradePrice', 'stock_listPrice', 'stock_damageTotal', 'stock_retailPrice', 'stock_highestOffer' ); /** * @var array */ protected $_currencyFields = array( 'stock_tradePrice', 'stock_listPrice', 'stock_damageTotal', 'stock_retailPrice', 'stock_highestOffer', 'valuation_amountOffered' ); /** * Build the dataset. */ public function build() { #-> Data passed by DataBin Grid functionality. $this->em->clear(); ini_set('memory_limit','512M'); foreach ($this->_data as $rowId => $rowData) { $this->_data[$rowId]['salesProfile_fullName'] = isset($rowData['salesProfile_firstName']) && !empty($rowData['salesProfile_firstName']) ? $rowData['salesProfile_firstName'] . ' ' . $rowData['salesProfile_familyName'] : ''; $this->_data[$rowId]['managerProfile_fullName'] = isset($rowData['managerProfile_firstName']) && !empty($rowData['managerProfile_firstName']) ? $rowData['managerProfile_firstName'] . ' ' . $rowData['managerProfile_familyName'] : ''; if (is_null($rowData['priceGuide_id'])) { $this->_data[$rowId]['higestoffernames'] = ''; continue; } $query = 'SELECT priceGuideOffer, company ' . 'FROM \PriceGuide\Entity\Offer priceGuideOffer ' . 'JOIN priceGuideOffer.company company ' . 'WHERE IDENTITY(priceGuideOffer.priceGuideStock) = :priceGuideId' . ' AND priceGuideOffer.amount = :highestOffer'; $query = $this->em->createQuery($query); $query->setParameter('priceGuideId', $rowData['priceGuide_id']); $query->setParameter('highestOffer', $rowData['stock_highestOffer']); $resultx = $query->getArrayResult(); $this->em->clear(); if (empty($resultx)) { $this->_data[$rowId]['higestoffernames'] = ''; continue; } $dealers = array(); foreach($resultx as $itemx) { $dealers[] = $itemx['company']['name']; } $this->_data[$rowId]['higestoffernames'] = implode(', ', $dealers); } foreach ($this->_data as $rowId => $rowData) { if ($this->_data[$rowId]['stock_tradePrice'] == 0) { $this->_data[$rowId]['valuation_updated'] = '0 %'; } else { $this->_data[$rowId]['valuation_updated'] = round(($this->_data[$rowId]['valuation_amountOffered'] * 100) / $this->_data[$rowId]['stock_tradePrice']) . ' %' ; } } } } |
Commits for namibiamodule/Valuation/src/Valuation/Report/ValuationGrid.php
Revision | Author | Commited | Message |
---|---|---|---|
bb2698 ...
![]() |
Mark | Mon 24 Oct, 2016 08:44:08 +0000 | latest update |
df0489 ... | Mark | Fri 14 Oct, 2016 10:01:00 +0000 | initial commit |