<?php

	/** 
	* class.cyber_hackney.php
	*
	* Cyber Hackney / Rapid Mail Class
	* This class is used to interact with the new Rapid Mail 2.0 (v2014, Cyber Hackney)
	*
	*
	**********************************************************************************************/
	class CyberHackney
	{

		public function __construct()
		{
			#if(!defined('_VALID_RBS')) define('_VALID_RBS', 1);


			#require_once('/var/www/web3/classes/class.rest.php');
			
			#include("/var/www/web3/classes/config.inc.php");
			#require_once("/var/www/web3/classes/class.nameserver_objects.php");
			
			#$this->sSQLServer	= $sSQLServer;
			#$this->sSQLUser		= $sSQLUser;
			#$this->sSQLPass 	= $sSQLPass;
			#$this->sSQLDatabase	= $sSQLDatabase;

			#$this->CPulled		= new Pulled($this->ns_database);
			#$this->CNameMaster = new NameMaster($this->ns_database);
			#$this->CUploadData = new UploadData($this->ns_database);
		}


		
		/**
		* Get pull output by work order
		*/
		public function GetPullOutputByWo($Workorder)
		{
			if(!$Workorder) return;

			$ch = curl_init();
			curl_setopt($ch, CURLOPT_URL, "http://cyberhackney.ammscore.com/PullOutput?workorder={$Workorder}&user_id=1");
			curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
			curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
			curl_setopt($ch, CURLOPT_TIMEOUT, 1200); # 20 minutes
			$result = curl_exec ($ch);
			curl_close ($ch);

			try { $response = json_decode($result, true); } catch(Exception $e){ }

			if(! is_array($response) || $response['status']!="success" || !$response['results'][0]) 
			{
				return false;
			}

			return $response['results'];
		}

		/**
		* Get pull output by customer/mailer
		*/
		public function GetPullOutputByCustomerMailer($CustomerId, $MailerId=0)
		{
			if(!$CustomerId) return;

			$ch = curl_init();
			curl_setopt($ch, CURLOPT_URL, "http://cyberhackney.ammscore.com/PullOutput?customer_id={$CustomerId}&mailer_id={$MailerId}&user_id=1");
			curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
			curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
			curl_setopt($ch, CURLOPT_TIMEOUT, 1200); # 20 minutes
			$result = curl_exec ($ch);
			curl_close ($ch);

			try { $response = json_decode($result, true); } catch(Exception $e){ }

			if(! is_array($response) || $response['status']!="success" || !$response['results'][0]) 
			{
				return false;
			}

			return $response['results'];
		}

		private function ReplaceCsvHeader($in)
		{
			$out = $in;
			$map = $this->GetUploadHeaderMap();

			foreach($map as $from => $to)
			{
				$out = str_replace($from, $to, $out);
			}

			return $out;
		}

		/**
		* Get pull master detail
		*/
		public function GetPullMasterDetail($PullMasterId)
		{
			if(!$PullMasterId) return;

			$ch = curl_init();
			curl_setopt($ch, CURLOPT_URL, "http://cyberhackney.ammscore.com/Pulls?pull_master_id={$PullMasterId}");
			curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
			curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
			curl_setopt($ch, CURLOPT_TIMEOUT, 1200); # 20 minutes
			$result = curl_exec ($ch);
			curl_close ($ch);

			try { $response = json_decode($result, true); } catch(Exception $e){ }

			if(! is_array($response) || $response['status']!="success" || !$response['results'][0]) 
			{
				return false;
			}

			return $response['results'][0];
		}

		/**
		* Get upload master detail
		*/
		public function GetUploadMasterDetail($UploadMasterId)
		{
			if(!$UploadMasterId) return;

			$ch = curl_init();
			curl_setopt($ch, CURLOPT_URL, "http://cyberhackney.ammscore.com/Uploads?upload_master_id={$UploadMasterId}");
			curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
			curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
			curl_setopt($ch, CURLOPT_TIMEOUT, 1200); # 20 minutes
			$result = curl_exec ($ch);
			curl_close ($ch);

			try { $response = json_decode($result, true); } catch(Exception $e){ }

			if(! is_array($response)) 
			{
				return false;
			}

			return $response;
		}

		/**
		* Get pulled records
		*/
		public function GetPulledRecords($ClientId, $CustomerId, $PullId)
		{
			/**
			* Call webservice to get pull data
			*/
			$ch = curl_init();
			curl_setopt($ch, CURLOPT_URL, "http://cyberhackney.ammscore.com/PullData?user_id=1&customer_id={$ClientId}&mailer_id={$CustomerId}&pull_id={$PullId}");
			curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
			curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
			curl_setopt($ch, CURLOPT_TIMEOUT, 1200); # 20 minutes
			$result = curl_exec ($ch);
			curl_close ($ch);

			try { $response = json_decode($result, true); } catch(Exception $e){ }

			if(! is_array($response) || $response['status']!="success" || !$response['data']) 
			{
				return array();
			}

			return $response['data'];
		}

		/**
		* Get upload data records
		*/
		public function GetUploadDataRecords($ClientId, $CustomerId, $UploadId=0, $UploadMasterId=0)
		{
			/**
			* Call webservice to get upload data
			*/
			$ch = curl_init();
			curl_setopt($ch, CURLOPT_URL, "http://cyberhackney.ammscore.com/UploadData?user_id=1&customer_id={$ClientId}&mailer_id={$CustomerId}&upload_id={$UploadId}&upload_master_id={$UploadMasterId}");
			curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
			curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
			curl_setopt($ch, CURLOPT_TIMEOUT, 1200); # 20 minutes
			$result = curl_exec ($ch);
			curl_close ($ch);

			try { $response = json_decode($result, true); } catch(Exception $e){ }

			if(! is_array($response) || $response['status']!="success" || !$response['data']) 
			{
				return array();
			}

			return $response['data'];
		}

		/**
		* Update value-added options
		*/
		public function UpdateValueAddedOption($ClientId, $CustomerId, $UploadId, $UploadValueAddId, $attrs=array())
		{
			$data = array(
				'user_id' 				=> 1,
				'mailer_id'				=> $CustomerId,
				'customer_id'			=> $ClientId,
				'upload_id'				=> $UploadId,
				'upload_value_add_id'	=> $UploadValueAddId,
				'service_attributes'	=> $attrs['service_attributes']
			);
			$data = array_merge($data, $attrs);


			/**
			* Call webservice to update value-added option
			*/
			$ch = curl_init();
			curl_setopt($ch, CURLOPT_URL, "http://cyberhackney.ammscore.com/UploadValueAdd");
			curl_setopt($ch, CURLOPT_CUSTOMREQUEST , "PUT");
			curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
			curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data, '', '&')); 
			curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
			curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
			curl_setopt($ch, CURLOPT_TIMEOUT, 1200); # 20 minutes
			$result = curl_exec ($ch);
			curl_close ($ch);

			try { $response = json_decode($result, true); } catch(Exception $e){ }

			if(! is_array($response)) 
			{
				return false;
			}

			return $response;
		}

		/**
		* Add value-added options
		*/
		public function AddValueAddedOption($ClientId, $CustomerId, $UploadId, $Service='')
		{
			$data = array(
				'user_id' 		=> 1,
				'upload_id'		=> $UploadId,
				'mailer_id'		=> $CustomerId,
				'customer_id'	=> $ClientId,
				'service'		=> $Service
			);

			/**
			* Call webservice to add value-added option
			*/
			$ch = curl_init();
			curl_setopt($ch, CURLOPT_URL, "http://cyberhackney.ammscore.com/UploadValueAdd");
			curl_setopt($ch, CURLOPT_POST, true);
			curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
			curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
			curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
			curl_setopt($ch, CURLOPT_TIMEOUT, 1200); # 20 minutes
			$result = curl_exec ($ch);
			curl_close ($ch);

			try { $response = json_decode($result, true); } catch(Exception $e){ }

			if(! is_array($response)) 
			{
				return false;
			}

			return $response;
		}


		/**
		* Create cyber hackney pull
		*/
		public function CreatePull($ClientId, $CustomerId, $Name, $WorkOrderNum, $Status='PENDING', $Mode='NEW', $Limit=0)
		{
			$data = array(
				'user_id'			=> 1,
				'mailer_id'			=> $CustomerId,
				'customer_id'		=> $ClientId,
				'pull_name'			=> $Name,
				'work_order_drop'	=> $WorkOrderNum,
				'status'			=> $Status,
				'mode'				=> $Mode,
				'active_yn'			=> 'Y',
				'limit_count'		=> $Limit
			);

			/**
			* Call webservice to create cyber hackney pull
			*/
			$ch = curl_init();
			curl_setopt($ch, CURLOPT_URL, 'http://cyberhackney.ammscore.com/Pulls');
			curl_setopt($ch, CURLOPT_POST, 9);
			curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
			curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
			curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
			curl_setopt($ch, CURLOPT_TIMEOUT, 1200); # 20 minutes
			$result = curl_exec ($ch);
			curl_close ($ch);


			try { $response = json_decode($result, true); } catch(Exception $e){ }

			if(! is_array($response) || $response['status']!="success" || !$response['pull_info']['pull_master_id'] || !$response['pull_info']['pull_id']) 
			{
				return 0;
			}

			# Return the pull master id
			return array(
				'pull_master_id'	=> $response['pull_info']['pull_master_id'],
				'pull_id'			=> $response['pull_info']['pull_id']
			);
		}

		/**
		* Create pull unit
		*/
		public function CreatePullUnit($ClientId, $CustomerId, $PullId, $Action='INCLUDE', $Source='UPLOAD', $SourceId=0, $Limit=0)
		{
			$data = array(
				'user_id'			=> 1,
				'pull_id'			=> $PullId,
				'mailer_id'			=> $CustomerId,
				'customer_id'		=> $ClientId,
				'action'			=> $Action,
				'source'			=> $Source,
				'source_id'			=> $SourceId,
				'limit_count'		=> $Limit
			);

			/**
			* Call webservice to create cyber hackney pull unit
			*/
			$ch = curl_init();
			curl_setopt($ch, CURLOPT_URL, 'http://cyberhackney.ammscore.com/PullUnits');
			curl_setopt($ch, CURLOPT_POST, 8);
			curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
			curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
			curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
			curl_setopt($ch, CURLOPT_TIMEOUT, 1200); # 20 minutes
			$result = curl_exec ($ch);
			curl_close ($ch);

			try { $response = json_decode($result, true); } catch(Exception $e){ }

			if(! is_array($response) || $response['status']!="success") 
			{
				return false;
			}

			return true;
		}


		/**
		* Get upload header map
		****************************************************************************/
		private function GetUploadHeaderMap()
		{
			return array(
				'iUploadRecordIndex'	=> 'iUploadRecordIndex',
				'iUploadIndex'			=> 'iUploadIndex',
				'iNameMasterIndex'		=> 'iNameMasterIndex',
				'iAddressMasterIndex'	=> 'iAddressMasterIndex',
				'sPrefix'				=> 'PREFIX',
				'sFirst'				=> 'FIRST',
				'sMiddle'				=> 'MIDDLE',
				'sLast'					=> 'LAST',
				'sGender'				=> 'GENDER',
				'sSuffix'				=> 'SUFFIX',
				'sAddress'				=> 'ADDRESS',
				'sSuite'				=> 'ADDRESS2',
				'sCity'					=> 'CITY',
				'sState'				=> 'STATE',
				'sZip'					=> 'ZIP',
				'sZip4'					=> 'ZIP4',
				'sMake'					=> 'MAKE',
				'sYear'					=> 'YEAR',
				'sModel'				=> 'MODEL',
				'sMsg'					=> 'VIN',
				'sPhoneWork'			=> 'WORKPHONE',
				'sPhoneHome'			=> 'PHONE',
				'sEmail1'				=> 'EMAIL',
				'sPhoneCell'			=> 'CELLPHONE',
				'dtDate'				=> 'RODATE',
				'dtPurchaseDate'		=> 'DEALDATE',
				'sJ2' 		 			=> 'J2',
				'sJ3'					=> 'J3',
				'sJ4'					=> 'J4',
				'sJ5'					=> 'J5',
				'sJ6'					=> 'J6',
				'sLoc1'					=> 'LOC1',
				'sLoc2'					=> 'LOC2',
				'sLoc3'					=> 'LOC3',
				'sLoc4'					=> 'LOC4',
				'sLoc5'					=> 'LOC5',
				'sLoc6'					=> 'LOC6',
				'sLoc7'					=> 'LOC7',
				'sLoc8'					=> 'LOC8',
				'sLoc9'					=> 'LOC9',
				'sLoc10'				=> 'LOC10',
				'sLoc11'				=> 'LOC11',
				'sLoc12'				=> 'LOC12',
				'sLoc13'				=> 'LOC13',
				'sLoc14'				=> 'LOC14',
				'sLoc15'				=> 'LOC15',
				'sLoc16'				=> 'LOC16',
				'sLoc17'				=> 'LOC17',
				'sLoc18'				=> 'LOC18',
				'sLoc19'				=> 'LOC19',
				'sLoc20'				=> 'LOC20',
				'sLoc21'				=> 'LOC21',
				'sLoc22'				=> 'LOC22',
				'sLoc23'				=> 'LOC23',
				'sLoc24'				=> 'LOC24',
				'sLoc25'				=> 'LOC25',
				'sLoc26'				=> 'LOC26',
				'sLoc27'				=> 'LOC27',
				'sLoc28'				=> 'LOC28',
				'sLoc29'				=> 'LOC29',
				'sLoc30'				=> 'LOC30',
				'sLoc31'				=> 'LOC31',
				'sLoc32'				=> 'LOC32',
				'sLoc33'				=> 'LOC33',
				'sLoc34'				=> 'LOC34',
				'sLoc35'				=> 'LOC35',
				'sLoc36'				=> 'LOC36',
				'sLoc37'				=> 'LOC37',
				'sLoc38'				=> 'LOC38',
				'sLoc39'				=> 'LOC39',
				'sLoc40'				=> 'LOC40',
			);

		}

		public function GetAmmsAuthUserId($sfGuardUserId=0, $RapidmailUserId=0)
		{
			# Default user just in case we can't find a proper mapped user in the system
			$UserId = 1;

			$ch = curl_init();
			curl_setopt($ch, CURLOPT_URL, "http://cyberhackney.ammscore.com/Users?action=GetUserByKnownId&sf_guard_user_id=$sfGuardUserId&rapidmail_user_id=$RapidmailUserId");
			curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
			curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
			curl_setopt($ch, CURLOPT_TIMEOUT, 1200); # 20 minutes
			$result = curl_exec ($ch);
			curl_close ($ch);

			try { $response = json_decode($result, true); } catch(Exception $e){ }

			if(! is_array($response) || $response['status']!="success" || ! count($response['results']) ) 
			{
				return 1;
			}

			$UserId = $response['results'][0]['ammsauth_user_id'];
			$UserId = $UserId > 0 ? $UserId : 1;

			return $UserId;
		}

		/**
		* Export data to cyber hackney as an upload
		****************************************************************************/
		public function ExportToCyberHackney($FileId, $ClientId, $CustomerId, $ExportName, $header, $data, $sfGuardUserId=0)
		{
			# TEMPORARY HACK
			#if($ClientId==579 && $CustomerId==9411)
			#{
			#	$ClientId = 2;
			#	$CustomerId = 8937;
			#}

			# Generate a random file name so we can temporary save the data to disk
			if(!$FileId) $FileId = $CustomerId .'_'. md5(microtime(true)) .'_'. mt_rand(9,999999999);

			# Replace header with known mapping
			$header 	= $this->ReplaceCsvHeader($header);

			# Make sure we add the newline character to the header
			if(substr($header, -1) != "\n")
				$header .= "\n";


			$folder 	= '/var/www/web3/data/temp/';
			$filename 	= "{$FileId}.csv";
			$fullpath 	= $folder . $filename;

			$fp = fopen($fullpath, 'w');
			fwrite($fp, "{$header}{$data}");
			fclose($fp);

			/**
			* Call API to create a cyber hackney upload
			*/
			$data = array(
			    'file' 					=> '@'."$fullpath",
				'user_id'				=> $this->GetAmmsAuthUserId($sfGuardUserId),
				'mailer_id'				=> $CustomerId,
				'customer_id'			=> $ClientId,
				'upload_format_id'		=> '1',
				'upload_type' 			=> 'LIST',
				'file_name'				=> $filename,
				'upload_name'			=> $ExportName,
				'mail_ncoa_yn'			=> 'Y',
				'match_last_name_yn'	=> 'Y'
			);

			$ch = curl_init();
			curl_setopt($ch, CURLOPT_URL, 'http://cyberhackney.ammscore.com/Uploads');
			curl_setopt($ch, CURLOPT_POST, 10);
			curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
			curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
			curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
			curl_setopt($ch, CURLOPT_TIMEOUT, 1200); # 20 minutes
			$result = curl_exec ($ch);
			curl_close ($ch);

			/** 
			* Make sure we remove the temporary file
			*/
			unlink($fullpath);



			try { $response = json_decode($result, true); } catch(Exception $e){ }




			if(! is_array($response) || $response['status']!="success" || !$response['results']['upload_id']) 
			{
				return 0;
			}

			# Return the upload id
			return array(
				'upload_id'			=> $response['results']['upload_id'],
				'upload_master_id'	=> $response['results']['upload_master_id']
			);

			/*
			"status": "success"
			"upload_info": {
			    "upload_id": "4",
			    "records": 16,
			    "format": "CSV"
			  },
			*/
		}

		/**
		* Get data from a list of values
		*````````````````````````````````````````````````````````````````````*/
		private function GetData($v1='', $v2='', $v3='', $v4='', $v5='', $v6='', $v7='', $v8='', $v9='', $v10='')
		{
			if($v1)		return $v1;
			if($v2)		return $v2;
			if($v3)		return $v3;
			if($v4)		return $v4;
			if($v5)		return $v5;
			if($v6)		return $v6;
			if($v7)		return $v7;
			if($v8)		return $v8;
			if($v9)		return $v9;
			if($v10)	return $v10;
		}

		/**
		* Return data in old format if possible to reduce issues with existing products
		*````````````````````````````````````````````````````````````````````*/
		public function GetMappedData($data)
		{
			$return = $data;

			/**
			* Use first value that is populated from the data array
			*/
			$return['sFirst'] 			= $this->GetData( $data['FIRST_NAME'], 		$data['FIRST'], 		$data['sFirst'] 	);
			$return['sLast'] 			= $this->GetData( $data['LAST_NAME'], 		$data['LAST'], 			$data['sLast'] 		);
			$return['sMiddle'] 			= $this->GetData( $data['MIDDLE_NAME'], 	$data['MIDDLE'], 		$data['sMiddle'] 	);

			$return['purl_name'] 		= $this->GetData( $data['SYS_PURL_NAME'], 	$data['purl_name'] 							);
			$return['purl_code']		= $this->GetData( $data['SYS_PURL_CODE'], 	$data['purl_code'] 							);
			$return['sAddress']			= $this->GetData( $data['POSTAL_ADDRESS'], 	$data['sAddress'] 							);
			$return['sSuite'] 			= $this->GetData( $data['POSTAL_ADDRESS2'], $data['sSuite'] 							);
			$return['sCity'] 			= $this->GetData( $data['POSTAL_CITY'], 	$data['sCity'] 								);
			$return['sState'] 			= $this->GetData( $data['POSTAL_STATE'], 	$data['sState'] 							);
			$return['sZip'] 			= $this->GetData( $data['POSTAL_ZIP'], 		$data['sZip'] 								);
			$return['sJ3'] 				= $this->GetData( $data['VEHICLE_MILEAGE'], $data['MILEAGE'], 		$data['sJ3'] 		);
			$return['sMake'] 			= $this->GetData( $data['VEHICLE_MAKE'], 	$data['MAKE'], 			$data['sMake'] 		);
			$return['sYear'] 			= $this->GetData( $data['VEHICLE_YEAR'], 	$data['YEAR'], 			$data['sYear'] 		);
			$return['sModel'] 			= $this->GetData( $data['VEHICLE_MODEL'], 	$data['MODEL'], 		$data['sModel'] 	);
			$return['sMsg'] 			= $this->GetData( $data['VEHICLE_VIN'], 	$data['VIN'], 			$data['sMsg'] 		);

			$return['sEmail1'] 			= $this->GetData( $data['EMAIL'], 			$data['EMAIL_ADDRESS'], $data['sEmail1'] 	);
			$return['sEmail2'] 			= $this->GetData( $data['EMAIL2'], 			$data['EMAIL_ADDRESS2'], $data['sEmail2'] 	);
			$return['sFullBarcode'] 	= $this->GetData( $data['SYS_BARCODE'],		$data['barcode'] 							);

			$return['sCRRT'] 			= $this->GetData( $data['POSTAL_CRRT'], 	$data['sCRRT'] 								);
			$return['sDPC'] 			= $this->GetData( $data['POSTAL_DPC'], 		$data['sDPC'] 								);
			$return['sZipBarcode'] 		= $this->GetData( $data['POSTAL_BARCODE'], 	$data['sZipBarcode'] 						);
			$return['cPostalType'] 		= $this->GetData( $data['POSTAL_TYPE'], 	$data['cPostalType'] 						);


			$return['sJ2'] 				= $this->GetData( $data['J2'], 				$data['sJ2'] 								);
			$return['sJ3'] 				= $this->GetData( $data['J3'], 				$data['sJ3'] 								);
			$return['sJ6'] 				= $this->GetData( $data['J6'], 				$data['sJ6'] 								);

			$return['sPhoneHome'] 		= $this->GetData( $data['PHONEHOME'], 		$data['sPhoneHome'] 						);
			$return['qrtrak_link'] 		= $this->GetData( $data['SYS_QRTRAK_LINK'], $data['qrtrak_link'] 						);
			$return['image_code_path'] 	= $this->GetData( $data['SYS_IMAGE_CODE_PATH'], 	$data['image_code_path'] 			);

			$return['sLoc1'] 			= $this->GetData( $data['LOC1'], 			$data['sLoc1'] 								);
			$return['sLoc2'] 			= $this->GetData( $data['LOC2'], 			$data['sLoc2'] 								);
			$return['sLoc3'] 			= $this->GetData( $data['LOC3'], 			$data['sLoc3'] 								);
			$return['sLoc4'] 			= $this->GetData( $data['LOC4'], 			$data['sLoc4'] 								);
			$return['sLoc5'] 			= $this->GetData( $data['LOC5'], 			$data['sLoc5'] 								);
			$return['sLoc6'] 			= $this->GetData( $data['LOC6'], 			$data['sLoc6'] 								);
			$return['sLoc7'] 			= $this->GetData( $data['LOC7'], 			$data['sLoc7'] 								);
			$return['sLoc8'] 			= $this->GetData( $data['LOC8'], 			$data['sLoc8'] 								);
			$return['sLoc9'] 			= $this->GetData( $data['LOC9'], 			$data['sLoc9'] 								);
			$return['sLoc10'] 			= $this->GetData( $data['LOC10'], 			$data['sLoc10'] 							);
			$return['sLoc11'] 			= $this->GetData( $data['LOC11'], 			$data['sLoc11'] 							);
			$return['sLoc12'] 			= $this->GetData( $data['LOC12'], 			$data['sLoc12'] 							);
			$return['sLoc13'] 			= $this->GetData( $data['LOC13'], 			$data['sLoc13'] 							);
			$return['sLoc14'] 			= $this->GetData( $data['LOC14'], 			$data['sLoc14'] 							);
			$return['sLoc15'] 			= $this->GetData( $data['LOC15'], 			$data['sLoc15'] 							);
			
			$return['sLoc21'] 			= $this->GetData( $data['LOC21'], 			$data['sLoc21'] 							);
			$return['sLoc22'] 			= $this->GetData( $data['LOC22'], 			$data['sLoc22'] 							);
			$return['sLoc23'] 			= $this->GetData( $data['LOC23'], 			$data['sLoc23'] 							);
			$return['sLoc25'] 			= $this->GetData( $data['LOC25'], 			$data['sLoc25'] 							);
			$return['sLoc28'] 			= $this->GetData( $data['LOC28'], 			$data['sLoc28'] 							);
			$return['sLoc29'] 			= $this->GetData( $data['LOC29'], 			$data['sLoc29'] 							);
			$return['sLoc31'] 			= $this->GetData( $data['LOC31'], 			$data['sLoc31'] 							);
			$return['sLoc32'] 			= $this->GetData( $data['LOC32'], 			$data['sLoc32'] 							);
			$return['sLoc33'] 			= $this->GetData( $data['LOC33'], 			$data['sLoc33'] 							);
			$return['sLoc36'] 			= $this->GetData( $data['LOC36'], 			$data['sLoc36'] 							);

			$return['blackbook_tradein_avg'] 	= $this->GetData( $data['SYS_BLACKBOOK_TRADEIN_AVG'], 	$data['blackbook_tradein_avg'] 		);
			$return['blackbook_msrp'] 			= $this->GetData( $data['SYS_BLACKBOOK_MSRP'], 			$data['blackbook_msrp'] 			);

			$return['dtDate'] 					= $this->GetData( $data['DTDATE'], 						$data['dtDate'] 					);
			$return['iNameMasterIndex'] 		= $this->GetData( $data['INAMEMASTERINDEX'],			$data['iNameMasterIndex'] 			);



			return $return;
		}







	}




?>