function RPSearch($arrRP) { $arrRP = array_filter($arrRP); if (empty($arrRP)) { if (isset($arrRP['POST']['op'])) { if ($arrRP['POST']['op'] == 's') { $RP = null; } } else { $RP = str_replace("xxResponsexx", "<Error><ErrorDescription>No data found.</ErrorDescription></Error>", $RP); } return $RP; } // $tmpHo = ""; $txtCateg = ""; $RoomCatg = ""; $txtRoomType = ""; $RoomType = ""; $txtRoomSeq = ""; $RoomSeq = ""; $CntRoomSeq = 0; $NightPrice = 0; $MinAge = 0; $MaxAge = 0; $RTNetPrice = 0; $PricePerDay = ''; $Price = 0; //modify 2013-08-08 $tempRpHotels = $arrRP["Hotel"]; $arrRP["Hotel"] = ''; $i = 0; $CancelPolicyID = ""; setArrReplaceSpecial($arySearch, $aryReplace); foreach ($arrRP['POST']['response'] as $obj) { $obj->SpHotelName = replaceXMLChar($obj->SpHotelName, $arySearch, $aryReplace); $obj->RoomCatgName = replaceXMLChar($obj->RoomCatgName, $arySearch, $aryReplace); if ($tmpHo != "" and $tmpHo->SpHotelCode != $obj->SpHotelCode) { // $txtRoomType = str_replace("xxNumRoomsxx", $CntRoomSeq, $txtRoomType); $txtRoomType = str_replace("xxResponseRoomSeqxx", $txtRoomSeq, $txtRoomType); //$txtRoomType = str_replace("xxNightPricexx",$NightPrice,$txtRoomType); $txtRoomType = str_replace("xxMinAgexx", $MinAge, $txtRoomType); $txtRoomType = str_replace("xxMaxAgexx", $MaxAge, $txtRoomType); $txtRoomType = str_replace("xxRTNetPricexx", $RTNetPrice, $txtRoomType); $txtRoomType = str_replace("xxTotalPricexx", $RTNetPrice, $txtRoomType); $txtRoomType = str_replace("xxRTGrossPricexx", $RTNetPrice, $txtRoomType); $txtRoomType = str_replace("xxRTCommPricexx", 0, $txtRoomType); $txtRoomType = str_replace("xxavrNightPricexx", $RTNetPrice / $arrRP["POST"]["Night"], $txtRoomType); $txtRoomType = getNightPrice($arrRP["POST"]["Night"], $RTNetPrice, $txtRoomType); $NightPrice = 0; $MinAge = 0; $MaxAge = 0; $RTNetPrice = 0; $PricePerDay = ''; $txtCateg = str_replace("xxResponseRoomTypexx", $txtRoomType, $txtCateg); $txtCateg = str_replace("xxPricexx", $Price, $txtCateg); $txtCateg = str_replace("xxNetPricexx", $Price, $txtCateg); $txtCateg = str_replace("xxGrossPricexx", $Price, $txtCateg); $txtCateg = str_replace("xxCommPricexx", 0, $txtCateg); $txtCateg = str_replace("xxavailxx", $obj->Avail, $txtCateg); $txtCateg = str_replace("xxMessagexx", $tmpHo->Message, $txtCateg); $Price = 0; $txtHotel = $tempRpHotels; $txtHotel = str_replace("xxHotelIdxx", $tmpHo->SpHotelCode, $txtHotel); $txtHotel = str_replace("xxHotelNamexx", XMLSymbor($tmpHo->SpHotelName), $txtHotel); $txtHotel = str_replace("xxRatingxx", $tmpHo->Rating, $txtHotel); $txtHotel = str_replace("xxCurrencyxx", $tmpHo->Currency, $txtHotel); $txtHotel = str_replace("xxavailxx", $tmpHo->Avail, $txtHotel); $txtHotel = str_replace("xxCancelPolicyIDxx", XMLSymbor(substr($CancelPolicyID, 0, -3)), $txtHotel); $txtHotel = str_replace("xxCanAmendxx", $tmpHo->CanAmend, $txtHotel); $txtHotel = str_replace("xxdtCheckInxx", $arrRP["POST"]["FromDt"], $txtHotel); $txtHotel = str_replace("xxdtCheckOutxx", $arrRP["POST"]["ToDt"], $txtHotel); $txtHotel = str_replace("xxResponseRoomCategxx", $txtCateg, $txtHotel); if ($i > 0) { $arrRP["Hotel"] .= $txtHotel; } $txtCateg = ""; $CancelPolicyID = ""; $txtHotel = ""; } if ($RoomCatg != $obj->RoomCatgCode . $obj->MealTypeCode || $txtCateg == "") { $txtRoomType = str_replace("xxNumRoomsxx", $CntRoomSeq, $txtRoomType); $txtRoomType = str_replace("xxResponseRoomSeqxx", $txtRoomSeq, $txtRoomType); //$txtRoomType = str_replace("xxNightPricexx",$NightPrice,$txtRoomType); $txtRoomType = str_replace("xxMinAgexx", $MinAge, $txtRoomType); $txtRoomType = str_replace("xxMaxAgexx", $MaxAge, $txtRoomType); $txtRoomType = str_replace("xxRTNetPricexx", $RTNetPrice, $txtRoomType); $txtRoomType = str_replace("xxTotalPricexx", $RTNetPrice, $txtRoomType); $txtRoomType = str_replace("xxRTGrossPricexx", $RTNetPrice, $txtRoomType); $txtRoomType = str_replace("xxRTCommPricexx", 0, $txtRoomType); $txtRoomType = str_replace("xxavrNightPricexx", $RTNetPrice / $arrRP["POST"]["Night"], $txtRoomType); $txtRoomType = getNightPrice($arrRP["POST"]["Night"], $PricePerDay, $txtRoomType); $NightPrice = 0; $MinAge = 0; $MaxAge = 0; $RTNetPrice = 0; $PricePerDay = ''; $txtCateg = str_replace("xxResponseRoomTypexx", $txtRoomType, $txtCateg); $txtRoomType = ""; $txtCateg = str_replace("xxPricexx", $Price, $txtCateg); $txtCateg = str_replace("xxNetPricexx", $Price, $txtCateg); $txtCateg = str_replace("xxGrossPricexx", $Price, $txtCateg); $txtCateg = str_replace("xxCommPricexx", 0, $txtCateg); $txtCateg = str_replace("xxavailxx", $obj->Avail, $txtCateg); $txtCateg = str_replace("xxMessagexx", $obj->Message, $txtCateg); $Price = 0; $RoomCatg = $obj->RoomCatgCode . $obj->MealTypeCode; $txtCateg .= $arrRP["RoomCateg"]; $txtCateg = str_replace("xxCodexx", $obj->RoomCatgCode, $txtCateg); $txtCateg = str_replace("xxNamexx", $obj->RoomCatgName, $txtCateg); $txtCateg = str_replace("xxBFTypexx", $obj->MealTypeCode, $txtCateg); $txtCateg = str_replace("xxavailxx", $obj->Avail, $txtCateg); $txtCateg = str_replace("xxMessagexx", $obj->Message, $txtCateg); } if ($RoomType != $obj->RoomType || $txtRoomType == "") { $txtRoomType = str_replace("xxNumRoomsxx", $CntRoomSeq, $txtRoomType); $txtRoomType = str_replace("xxResponseRoomSeqxx", $txtRoomSeq, $txtRoomType); //$txtRoomType = str_replace("xxNightPricexx",$NightPrice,$txtRoomType); $txtRoomType = str_replace("xxMinAgexx", $MinAge, $txtRoomType); $txtRoomType = str_replace("xxMaxAgexx", $MaxAge, $txtRoomType); $txtRoomType = str_replace("xxRTNetPricexx", $RTNetPrice, $txtRoomType); $txtRoomType = str_replace("xxTotalPricexx", $RTNetPrice, $txtRoomType); $txtRoomType = str_replace("xxRTGrossPricexx", $RTNetPrice, $txtRoomType); $txtRoomType = str_replace("xxRTCommPricexx", 0, $txtRoomType); $txtRoomType = str_replace("xxavrNightPricexx", $RTNetPrice / $arrRP["POST"]["Night"], $txtRoomType); $txtRoomType = getNightPrice($arrRP["POST"]["Night"], $PricePerDay, $txtRoomType); $NightPrice = 0; $MinAge = 0; $MaxAge = 0; $RTNetPrice = 0; $PricePerDay = ''; $txtRoomSeq = ""; $CntRoomSeq = 0; $RoomType = $obj->RoomType; $txtRoomType .= $arrRP["RoomType"]; $txtRoomType = str_replace("xxTypeNamexx", $obj->RoomType, $txtRoomType); $txtRoomType = str_replace("xxResponseRatexx", $arrRP["Rate"], $txtRoomType); } if ($RoomType == $obj->RoomType || $txtRoomSeq == "") { switch (strtoupper($RoomType)) { case "SINGLE": $LoopRoom = f_cnt_room($arrRP, "Sgl"); $rt = "Sgl"; break; case "TWIN": $LoopRoom = f_cnt_room($arrRP, "Tw"); $rt = "Tw"; break; case "DOUBLE": $LoopRoom = f_cnt_room($arrRP, "Dbl"); $rt = "Dbl"; break; case "TRIPLE": $LoopRoom = f_cnt_room($arrRP, "Tpl"); $rt = "Tpl"; break; case "QUAD": $LoopRoom = f_cnt_room($arrRP, "Quad"); $rt = "Quad"; break; } $loop = 0; while ($loop < $LoopRoom[$rt . "_" . $obj->ChildAge1 . "_" . $obj->ChildAge2 . "_" . $obj->AdultNum]) { $CntRoomSeq++; $txtRoomSeq .= $arrRP["RoomSeq"]; $PriceTotal = $obj->PriceTotal / $arrRP["POST"]["Night"]; $NightPrice += $PriceTotal; $MinAge = $obj->MinAge; $MaxAge = $obj->MaxAge; $ChildOverAge = $obj->ChildOverAge == 'COA' ? 'COA' : 'N'; $RTNetPrice += $obj->PriceTotal; $PricePerDay = $obj->PricePerDay; $Price += $obj->PriceTotal; $txtRoomSeq = str_replace("xxRoomPricexx", cal_Price($PriceTotal), $txtRoomSeq); $txtRoomSeq = str_replace("xxNoxx", $CntRoomSeq, $txtRoomSeq); $txtRoomSeq = str_replace("xxAdultNumxx", $obj->AdultNum, $txtRoomSeq); $txtRoomSeq = str_replace("xxChildNumxx", $obj->ChildNum, $txtRoomSeq); $txtRoomSeq = str_replace("xxChildAge1xx", $obj->ChildAge1, $txtRoomSeq); $txtRoomSeq = str_replace("xxChildAge2xx", $obj->ChildAge2, $txtRoomSeq); $txtRoomSeq = str_replace("xxsRoomTypexx", $ChildOverAge, $txtRoomSeq); $loop++; } if (!empty($obj->CancelPolicyID)) { if (strpos($CancelPolicyID, $obj->CancelPolicyID) === false) { $CancelPolicyID .= $obj->CancelPolicyID . "#|#"; } } else { $CancelPolicyID .= "#|#"; } } if (!is_object($tmpHo) or $tmpHo->SpHotelCode != $obj->SpHotelCode) { $tmpHo = $obj; } $i++; } if ($tmpHo->SpHotelCode != "") { $txtRoomType = str_replace("xxNumRoomsxx", $CntRoomSeq, $txtRoomType); $txtRoomType = str_replace("xxResponseRoomSeqxx", $txtRoomSeq, $txtRoomType); //$txtRoomType = str_replace("xxNightPricexx",$NightPrice,$txtRoomType); $txtRoomType = str_replace("xxMinAgexx", $MinAge, $txtRoomType); $txtRoomType = str_replace("xxMaxAgexx", $MaxAge, $txtRoomType); $txtRoomType = getNightPrice($arrRP["POST"]["Night"], $PricePerDay, $txtRoomType); $txtRoomType = str_replace("xxRTNetPricexx", $RTNetPrice, $txtRoomType); $txtRoomType = str_replace("xxTotalPricexx", $RTNetPrice, $txtRoomType); $txtRoomType = str_replace("xxRTGrossPricexx", $RTNetPrice, $txtRoomType); $txtRoomType = str_replace("xxRTCommPricexx", 0, $txtRoomType); $txtRoomType = str_replace("xxavrNightPricexx", $RTNetPrice / $arrRP["POST"]["Night"], $txtRoomType); $txtCateg = str_replace("xxResponseRoomTypexx", $txtRoomType, $txtCateg); $txtCateg = str_replace("xxPricexx", $Price, $txtCateg); $txtCateg = str_replace("xxNetPricexx", $Price, $txtCateg); $txtCateg = str_replace("xxGrossPricexx", $Price, $txtCateg); $txtCateg = str_replace("xxCommPricexx", 0, $txtCateg); $txtCateg = str_replace("xxavailxx", $tmpHo->Avail, $txtCateg); $txtCateg = str_replace("xxMessagexx", $tmpHo->Message, $txtCateg); $txtHotel = $tempRpHotels; $txtHotel = str_replace("xxHotelIdxx", $tmpHo->SpHotelCode, $txtHotel); $txtHotel = str_replace("xxHotelNamexx", $tmpHo->SpHotelName, $txtHotel); $txtHotel = str_replace("xxRatingxx", $tmpHo->Rating, $txtHotel); $txtHotel = str_replace("xxCurrencyxx", $tmpHo->Currency, $txtHotel); $txtHotel = str_replace("xxavailxx", $tmpHo->Avail, $txtHotel); $txtHotel = str_replace("xxCancelPolicyIDxx", XMLSymbor(substr($CancelPolicyID, 0, -3)), $txtHotel); $txtHotel = str_replace("xxCanAmendxx", $tmpHo->CanAmend, $txtHotel); $txtHotel = str_replace("xxdtCheckInxx", $arrRP["POST"]["FromDt"], $txtHotel); $txtHotel = str_replace("xxdtCheckOutxx", $arrRP["POST"]["ToDt"], $txtHotel); $txtHotel = str_replace("xxResponseRoomCategxx", $txtCateg, $txtHotel); $arrRP["Hotel"] .= $txtHotel; } $RP = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><Service_SearchHotel><SearchHotel_Response>" . $arrRP["Hotel"] . "</SearchHotel_Response></Service_SearchHotel>"; //Bot 16384 /* * //Rate/RoomRate/RoomSeq/@RoomPrice = //Rate/@nightprice */ $o = simplexml_load_string($RP); $Rate = $o->xpath("//Rate"); foreach ($Rate as $node) { $nightPrice = doubleval($node->attributes()->NightPrice); $RoomRate = $node->xpath('.//RoomRate/RoomSeq'); $divrooms = count($RoomRate); foreach ($RoomRate as $updNode) { $updNode->attributes()->RoomPrice = doubleval($nightPrice) / $divrooms; } } return $o->asXML(); }
/** * * @param type $AvgPriceRoom * @param type $post * @return type */ private function getNightPrice($AvgPriceRoom, $post) { $arrNightPrice = array(); if ($AvgPriceRoom > 0) { $indexNight = 0; while ($indexNight < $post['Night']) { $arrNightPrice[$indexNight] = array("AccomPrice" => cal_Price($AvgPriceRoom / $post['Night']), "ChildMinAge" => 2, "ChildMaxAge" => 18, "ChildInfo" => "", "MinstayDay" => "0.00", "MinstayType" => "NONE", "MinstayRate" => "0.00", "MinstayPrice" => "0.00", "CompulsoryName" => "NONE", "CompulsoryPrice" => "0.00", "SupplementName" => "NONE", "SupplementPrice" => "0.00", "PromotionName" => "NONE", "PromotionValue" => "False", "PromotionBFPrice" => "0", "EarlyBirdType" => "NONE", "EarlyBirdRate" => "0.00", "EarlyBirdPrice" => "0.00", "CommissionType" => "NONE", "CommissionRate" => "0.00", "CommissionPrice" => "0.00"); $indexNight++; } } return $arrNightPrice; }