All pastes #964548 Raw Edit

Someone

public php v1 · immutable
#964548 ·published 2008-03-31 09:54 UTC
rendered paste body
	//	// Returns the lowest available rate of a group for a day, the number of rooms that are available for that day at that rate.	//	function packages($values, $charset = "UTF-8") {		$this->start = $this->microtime();		$this->lastcall = "CwiListPackages";				$result = $this->client->CwiListPackages($values)->CwiListPackagesResult;		$parsed = $this->parse($result, $charset);				if(!isset($parsed[0]) || !isset($parsed[0]['PackageInfo'])){			$parsed = "";			$parsed['error']['title'] = "Error";			$parsed['error']['message'] = "An error has occured, possibly an empty result.";					}				$this->lastresult = $parsed;		$this->end = $this->microtime();				if($this->debug !== false){			$this->debug();		}						return $parsed;	}if(isset($_GET['package']) && trim($_GET['package'])){	$result = $database->executeGetArray("SELECT DISTINCT(packageCode) FROM package WHERE packageNameCustom = '".@base64_decode($_GET['package'])."' AND packageProperty = '".$_ENG['property']."' AND packageHide = '0'");		if(is_array($result)){		foreach($result AS $id => $value){			$possibleRatetypes[] = trim($value['packageCode']);		}	} else {		$possibleRatetypes = array("");	}} else {	$result = $database->executeGetArray("SELECT DISTINCT(ratetypeCode) FROM ratetype WHERE ratetypeNameCustom = '".@base64_decode($_GET['ratetype'])."' AND ratetypeProperty = '".$_ENG['property']."' AND ratetypeHide = '0'");		if(is_array($result)){		foreach($result AS $id => $value){			$possibleRatetypes[] = trim($value['ratetypeCode']);		}	} else {		$possibleRatetypes = array("");	}}function convertArray($array){	$cleaned = "";		if(is_array($array)){		if(isset($array[0])){			$cleaned = $array;		} else {			$cleaned[0] = $array;		}	}		return $cleaned;}$soap = new SOAP(false);$values['PropertyCode'] = $_ENG['property'];$values['NumberOfRooms'] = $_GET['rooms'];$values['Adults'] = $_GET['adults'];$values['Children'] = $_GET['kids'];$values['Infants'] = $_GET['infants'];$values['ReturnUnavailable'] = "true";$values['ArrivalDate'] = $_GET['arr_date'];$values['DepartDate'] = $_GET['dep_date'];$result = $soap->showAvailability($values);$alternatives = 0;if(isset($result['error'])){	$alternatives = 1;} else {	if(!isset($result[0]['AvailableRatePlans']['RatePlanAvail'] )){		$alternatives = 1;	} else {		$result[0]['AvailableRatePlans']['RatePlanAvail'] = convertArray($result[0]['AvailableRatePlans']['RatePlanAvail']);				foreach($result[0]['AvailableRatePlans']['RatePlanAvail'] AS $id => $value){					if(isset($_GET['package']) && trim($_GET['package'])){				if($value['IsPackage'] == "1") {					if ( in_array($value['RatePlan'], $possibleRatetypes)) {						$value['RoomTypes']['RoomTypeAvail'] = convertArray($value['RoomTypes']['RoomTypeAvail']);												foreach($value['RoomTypes']['RoomTypeAvail'] AS $idd => $valuee){							$valuee['RatePlan'] = $value['RatePlan'];							$resultTypes[] = $valuee;						}					} 					}			} else {				if ( in_array($value['RatePlan'], $possibleRatetypes)) {					$value['RoomTypes']['RoomTypeAvail'] = convertArray($value['RoomTypes']['RoomTypeAvail']);										foreach($value['RoomTypes']['RoomTypeAvail'] AS $idd => $valuee){						$valuee['RatePlan'] = $value['RatePlan'];						$resultTypes[] = $valuee;					}				} 			}		}	}}function cmp($a, $b){	if($a['RoomType'] > $b['RoomType']){		return 1;	} else {		return -1;	}}if(isset($resultTypes) && is_array($resultTypes)){	usort($resultTypes, "cmp");		foreach($resultTypes AS $id => $value){		$lowest[$value['RoomType']] = 99999999999;		$rooms[$value['RoomType']][] = $value;	}		foreach($rooms AS $id => $value){		foreach($value AS $idd => $valuee){			if($valuee['TotalRate'] < $lowest[$id] && $valuee['Available'] == "1"){				$possible = $database->executeGetOneArray(					"SELECT roomtypeHide FROM roomtype WHERE roomtypeCode = '".$valuee['RoomType']."'");				if(is_array($possible) && $possible['roomtypeHide'] == 0){					$lowest[$id] = $valuee['TotalRate'];					$lowarray[$id] = $valuee;				}			}		}	}}