'Auction', 'DatasetName' => 'valuations', 'Entity' => '\Auction\Entity\Auction', 'References' => array( 'stock' => '\Stock\Entity\Stock', 'createdBy' => '\User\Entity\Profile', 'company' => '\Company\Entity\Company', 'soldToProfile' => '\User\Entity\Profile', 'soldToCompany' => '\Company\Entity\Company', 'currentBid' => '\Auction\Entity\Bid' ), 'Dependants' => array() ); /** * @var array */ protected $metaAdminGrid = array( 'Type' => 'Grid', 'Export' => true, 'Builder' => '\Auction\Report\AuctionGrid', 'Writer' => '\Utility\Export\ExcelReport', 'Output' => 'Download', 'Contract' => 'Recurring', 'Options' => array( 'Boolean' => array( 'ExportToExcel' => false ) ), 'RequiredInput' => array(), 'OptionalInput' => array( 'Grid' => array( 'NumberOfRecords' => 'Integer', 'Page' => 'Integer', 'Filter' => 'Array', 'OrderBy' => 'Array' ) ), 'Base' => 'auction', 'NumberOfRecords' => 10, 'Query' => 'SELECT [SELECTION] FROM \Auction\Entity\Auction auction JOIN auction.company company JOIN company.city city JOIN city.region region JOIN auction.stock stock JOIN stock.vehicleYear vehicleYear JOIN stock.type type JOIN type.model model JOIN model.make make LEFT JOIN stock.exteriorColour exteriorColour LEFT JOIN auction.currentBid currentBid [WHERE] [ORDER]', 'Selection' => 'auction, company, city, region, stock, vehicleYear, make, model, type, exteriorColour, currentBid', 'Filter' => array(), 'OrderBy' => array('auction.created' => 'DESC'), 'Fields' => array( 'id', 'created' => 'DateTime', 'endDate' => 'DateTime', 'jobState', 'company' => array( 'id', 'name', 'city' => array( 'region' => array( 'id', 'name' ) ) ), 'currentBid' => array( 'company' => array( 'id' ), 'amount' ), 'stock' => array( 'created' => 'DateTime', 'type' => array( 'name', 'model' => array( 'name', 'make' => array( 'name' ) ), ), 'vehicleYear' => array( 'name' ), 'exteriorColour' => array( 'name' ), 'km', 'tradePrice', 'retailPrice', 'listPrice' ) ) ); /** * @var array */ protected $metaGrid = array( 'Type' => 'Grid', 'Export' => true, 'Builder' => '\Auction\Report\AuctionGrid', 'Writer' => '\Utility\Export\ExcelReport', 'Output' => 'Download', 'Contract' => 'Recurring', 'Options' => array( 'Boolean' => array( 'ExportToExcel' => false ) ), 'RequiredInput' => array(), 'OptionalInput' => array( 'Grid' => array( 'NumberOfRecords' => 'Integer', 'Page' => 'Integer', 'Filter' => 'Array', 'OrderBy' => 'Array' ) ), 'Base' => 'auction', 'NumberOfRecords' => 20, 'Query' => 'SELECT [SELECTION] FROM \Auction\Entity\Auction auction LEFT JOIN auction.baskets basket WITH (IDENTITY(basket.company) = [owncompany] OR IDENTITY(basket.profile) = [ownprofile]) [SWAP] [WHERE] [GROUP] [ORDER]', 'Selection' => 'partial auction.{id,currentBidPrice,reservePrice,created,endDate,jobState,regionId,makeId,auctionCompanyId,auctionCompanyName,makeName,modelName,typeName,yearName,referenceNumber,registrationNumber,stockKm,currentBidCompanyId,stockCompanyId,regionName,stockCreated}, basket, COUNT(DISTINCT bid.id) as numBids, COUNT(DISTINCT allbid.id) as numAllBids', 'Swap' => 'LEFT JOIN auction.bids bid WITH IDENTITY(bid.company) = [company] LEFT JOIN auction.bids allbid', 'GroupBy' => 'auction.id', 'Filter' => array( 'auction.archived' => 0 ), 'OrderBy' => array( 'auction.endDate' => 'ASC', 'auction.auctionCompanyName' => 'ASC', 'auction.makeName' => 'ASC', 'auction.modelName' => 'ASC', 'auction.typeName' => 'ASC', 'auction.yearName' => 'ASC' ), 'Fields' => array( 'id', 'numBids', 'numAllBids', 'currentBidPrice', 'reservePrice', 'created' => 'DateTime', 'endDate' => 'DateTime', 'jobState', 'regionId', 'makeId', 'auctionCompanyId', 'auctionCompanyName', 'makeName', 'modelName', 'typeName', 'yearName', 'referenceNumber', 'registrationNumber', 'stockKm', 'currentBidCompanyId', 'stockCompanyId', 'regionName', 'stockCreated', 'baskets' => array( 0 => array( 'id', 'archived' ) ) ), 'ExportMeta' => array( 'Query' => 'SELECT [SELECTION] FROM \Auction\Entity\Auction auction JOIN auction.stock stock JOIN auction.company company JOIN company.city city JOIN city.region region LEFT JOIN auction.baskets basket WITH (IDENTITY(basket.company) = [owncompany] OR IDENTITY(basket.profile) = [ownprofile]) [SWAP] [WHERE] [GROUP] [ORDER]', 'Selection' => 'partial auction.{id,stock,currentBidPrice,reservePrice,created,endDate,jobState,regionId,makeId,auctionCompanyId,auctionCompanyName,makeName,modelName,typeName,yearName,referenceNumber,registrationNumber,stockKm,currentBidCompanyId,stockCompanyId,regionName,stockCreated}, partial stock.{id,vinNumber,tradePrice,listPrice,highestBid}, partial company.{id,city}, partial city.{id,region}, partial region.{id,name}, basket, COUNT(DISTINCT bid.id) as numBids, COUNT(DISTINCT allbid.id) as numAllBids', ) ); /** * @var array */ protected $metaHistoricGrid = array( 'Type' => 'Grid', 'Export' => true, 'Builder' => '\Auction\Report\HistoricGrid', 'Writer' => '\Utility\Export\ExcelReport', 'Output' => 'Download', 'Contract' => 'Recurring', 'Options' => array( 'Boolean' => array( 'ExportToExcel' => false ) ), 'RequiredInput' => array(), 'OptionalInput' => array( 'Grid' => array( 'NumberOfRecords' => 'Integer', 'Page' => 'Integer', 'Filter' => 'Array', 'OrderBy' => 'Array' ) ), 'Base' => 'auction', 'NumberOfRecords' => 20, 'Query' => 'SELECT [SELECTION] FROM \Auction\Entity\Auction auction JOIN auction.company company JOIN company.city city JOIN city.region region JOIN auction.stock stock JOIN stock.company companyStock JOIN stock.vehicleYear vehicleYear JOIN stock.type type JOIN type.model model JOIN model.make make LEFT JOIN stock.exteriorColour exteriorColour LEFT JOIN auction.currentBid currentBid [WHERE] [GROUP] [ORDER]', 'Selection' => 'auction, company, city, region, stock,companyStock, vehicleYear, make, model, type, exteriorColour, currentBid', 'GroupBy' => 'auction.id', 'Filter' => array( 'auction.jobState' => 'Sold', 'auction.archived' => 0 ), 'OrderBy' => array( 'auction.endDate' => 'DESC', 'company.name' => 'ASC' ), 'Fields' => array( 'id', 'reservePrice', 'created' => 'DateTime', 'endDate' => 'DateTime', 'jobState', 'company' => array( 'id', 'name', 'city' => array( 'region' => array( 'id', 'name' ) ) ), 'currentBid' => array( 'company' => array( 'id' ), 'amount' ), 'stock' => array( 'company' => array( 'id' ), 'created' => 'DateTime', 'type' => array( 'mmCode', 'name', 'model' => array( 'name', 'make' => array( 'id', 'name' ) ), ), 'vehicleYear' => array( 'name' ), 'exteriorColour' => array( 'name' ), 'km', 'tradePrice', 'retailPrice', 'damageTotal', 'listPrice' ) ) ); /** * @var array */ protected $metaView = array( 'Type' => 'Update', 'Contract' => 'Recurring', 'Expand' => array( 'currentBid', 'autoBid', 'company', 'soldToCompany', 'contact', 'group', 'groupDivision', 'stock', 'city', 'region', 'damages', 'accessories', 'category', 'make', 'model', 'type', 'mainImage', 'frontImage', 'rightImage', 'leftImage', 'backImage', 'interiorImage', 'engineImage', 'natisImage', 'contact', 'fuelType', 'transmissionType', 'condition', 'fullServiceHistory', 'exteriorColour', 'interiorColour', 'upholstery', 'papers', 'natis', 'spareKeys', 'vehicleYear' ), 'RequiredInput' => array(), 'OptionalInput' => array() ); /** * Add some dynamic filtering to our grids. */ public function __construct() { $authData = \Utility\Registry::getAuthData(); $modifiedDate = new \DateTime('-180 days'); $this->metaHistoricGrid['Filter']['auction.endDate'] = "> " . $modifiedDate->format('Y-m-d'); $this->metaGrid['Query'] = str_replace('[owncompany]', $authData['company']['id'], $this->metaGrid['Query']); $this->metaGrid['Query'] = str_replace('[ownprofile]', $authData['id'], $this->metaGrid['Query']); $this->metaGrid['ExportMeta']['Query'] = str_replace('[owncompany]', $authData['company']['id'], $this->metaGrid['ExportMeta']['Query']); $this->metaGrid['ExportMeta']['Query'] = str_replace('[ownprofile]', $authData['id'], $this->metaGrid['ExportMeta']['Query']); switch (\Utility\Registry::getUserType()) { case 'B4C User': $groupFilter = \Utility\Registry::getSudo('Group', false); $divisionFilter = \Utility\Registry::getSudo('Division', false); $companyFilter = \Utility\Registry::getSudo('Company', false); if ($groupFilter && $divisionFilter && $companyFilter) { $this->metaGrid['Swap'] = str_replace('[company]', $companyFilter, $this->metaGrid['Swap']); $this->metaGrid['Query'] = str_replace('[company]', $companyFilter, $this->metaGrid['Query']); $this->metaGrid['ExportMeta']['Query'] = str_replace('[company]', $companyFilter, $this->metaGrid['ExportMeta']['Query']); } else { $this->metaGrid['Swap'] = str_replace('[company]', '0', $this->metaGrid['Swap']); $this->metaGrid['Query'] = str_replace('[company]', '0', $this->metaGrid['Query']); $this->metaGrid['ExportMeta']['Query'] = str_replace('[company]', '0', $this->metaGrid['ExportMeta']['Query']); } break; case 'Group User': $divisionFilter = \Utility\Registry::getSudo('Division', false); $companyFilter = \Utility\Registry::getSudo('Company', false); if ($divisionFilter && $companyFilter) { $this->metaGrid['Swap'] = str_replace('[company]', $companyFilter, $this->metaGrid['Swap']); $this->metaGrid['Query'] = str_replace('[company]', $companyFilter, $this->metaGrid['Query']); $this->metaGrid['ExportMeta']['Query'] = str_replace('[company]', $companyFilter, $this->metaGrid['ExportMeta']['Query']); } else { $this->metaGrid['Swap'] = str_replace('[company]', '0', $this->metaGrid['Swap']); $this->metaGrid['Query'] = str_replace('[company]', '0', $this->metaGrid['Query']); $this->metaGrid['ExportMeta']['Query'] = str_replace('[company]', '0', $this->metaGrid['ExportMeta']['Query']); } break; case 'Dealer Principle': $companyFilter = \Utility\Registry::getSudo('Company', false); if ($companyFilter) { $this->metaGrid['Swap'] = str_replace('[company]', $companyFilter, $this->metaGrid['Swap']); $this->metaGrid['Query'] = str_replace('[company]', $companyFilter, $this->metaGrid['Query']); $this->metaGrid['ExportMeta']['Query'] = str_replace('[company]', $companyFilter, $this->metaGrid['ExportMeta']['Query']); } else { $this->metaGrid['Swap'] = str_replace('[company]', '0', $this->metaGrid['Swap']); $this->metaGrid['Query'] = str_replace('[company]', '0', $this->metaGrid['Query']); $this->metaGrid['ExportMeta']['Query'] = str_replace('[company]', '0', $this->metaGrid['ExportMeta']['Query']); } break; default: if ('' != $authData['company']['id']) { $this->metaGrid['Swap'] = str_replace('[company]', $authData['company']['id'], $this->metaGrid['Swap']); $this->metaGrid['Query'] = str_replace('[company]', $authData['company']['id'], $this->metaGrid['Query']); $this->metaGrid['ExportMeta']['Query'] = str_replace('[company]', $authData['company']['id'], $this->metaGrid['ExportMeta']['Query']); } else { $this->metaGrid['Swap'] = str_replace('[company]', '0', $this->metaGrid['Swap']); $this->metaGrid['Query'] = str_replace('[company]', '0', $this->metaGrid['Query']); $this->metaGrid['ExportMeta']['Query'] = str_replace('[company]', '0', $this->metaGrid['ExportMeta']['Query']); } break; } } }