Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* Author: Mahbubur Rahman Sumon*/
- /* Copy right: Metafour (uk) Ltd.*/
- /* e2 client library*/
- /* it is independant of client website */
- /* but it is dependent on e2 xml service */
- // 080710 Sunny: Changed to work on PHP5 only (before: PHP4 only)
- require_once ("xml2array.php");
- class Session extends BasicE2XML {
- /* Deal with e2 xml service sessions
- */
- var $sessionID;
- var $embSystem;
- var $user;
- var $password;
- var $transaction; // e2 transaction handler
- function setSystem($newSystem) {
- $this->embSystem = $newSystem;
- }
- function setUser($newUser) {
- $this->user = $newUser;
- }
- function setPassword($newPassword) {
- $this->password = $newPassword;
- }
- function setSessionId($newSessId) {
- $this->sessionID = $newSessId;
- }
- function getSessionID() {
- return $this->sessionID;
- }
- function Session($newSys, $newUser, $newPass) {
- $this->embSystem = $newSys;
- $this->user = $newUser;
- $this->password = $newPass;
- }
- function createSession($url, $params) {
- $xmldoc = $this->buildRequestXMLDoc($params);
- $xpost = new XMLPosting();
- $xpost->setUrl($url);
- $xpost->setReqXML($xmldoc->saveXML());
- //echo htmlentities($xmldoc->saveXML());
- $resXml = $xpost->postXmlMessage();
- $this->parseResponse($resXml);
- }
- /* build request xml to start session*/
- function buildRequestXMLDoc($params) {
- $xmldoc = $this->buildE2XMLHeader("SystemService", "StartSession", "");
- $xmldoc = $this->setXNodeValue($xmldoc, "//StartSession", "System", $this->embSystem);
- $xmldoc = $this->setXNodeValue($xmldoc, "//StartSession", "User", $this->user);
- $xmldoc = $this->setXNodeValue($xmldoc, "//StartSession", "Password", $this->password);
- for ($i = 0; $i < count($params); $i ++) {
- if ($i == 0) {
- $xmldoc = $this->setXNodeValue($xmldoc, "//StartSession", "Params", "");
- }
- $xmldoc = $this->setXNodeValue($xmldoc, "//StartSession/Params", "Param", "");
- $xmldoc = $this->setXNodeValue($xmldoc, "//StartSession/Params/Param", "Action", $params[$i]->getAction());
- $xmldoc = $this->setXNodeValue($xmldoc, "//StartSession/Params/Param", "Name", $params[$i]->getName());
- $xmldoc = $this->setXNodeValue($xmldoc, "//StartSession/Params/Param", "Value", $params[$i]->getValue());
- }
- return $xmldoc;
- }
- function parseResponse($rs) {
- $doc = new DOMDocument('1.0', 'ISO-8859-1');
- if (!$doc->loadXML($rs)) {
- // it is done here to isolate e2 client library independant
- // of client website.
- $this->setErrorCode("Website-C0201");
- $this->setErrorType("fatal");
- $this->setErrorDesc("Error while parsing response xml document");
- return;
- }
- $root = $doc->firstChild;
- //$root->name = 'SystemService';
- $this->parseNode($root);
- //$dom->free();
- }
- function parseNode($root) {
- $this->parseNodeFault($root);
- if (strlen($this->getErrorCode()) > 0) {
- return;
- }
- $this->transaction = $this->parseNodeTransaction($root);
- $this->sessionID = $this->transaction->getSessionID();
- }
- // parse transaction node
- function parseNodeTransaction($node) {
- $transaction = new Transaction();
- $ok = 0;
- if ($node->hasChildNodes()) {
- foreach ($node->childNodes as $n) {
- // Transaction information here
- if ($n->nodeName == 'Transaction') {
- foreach ($n->childNodes as $tr) {
- if ($tr->nodeName == 'SessionID')
- $transaction->setSessionID($tr->nodeValue);
- if ($tr->nodeName == 'Version')
- $transaction->setVersion($tr->nodeValue);
- if ($tr->nodeName == 'Service')
- $transaction->setService($tr->nodeValue);
- }
- return $transaction;
- }
- }
- }
- }
- }
- class SessionParams extends BasicE2XML {
- /* Deal with e2 xml service session params
- */
- var $params;
- var $responseArray;
- function setParams($newParams) {
- $this->params = $newParams;
- }
- function getResponseArray() {
- return $this->responseArray;
- }
- function getParams() {
- return $this->params;
- }
- function SessionParams($newParams) {
- $this->params = $newParams;
- }
- function setGet($url, $sessId) {
- $xmldoc = $this->buildRequestXMLDoc($sessId);
- $xpost = new XMLPosting();
- $xpost->setUrl($url);
- $xpost->setReqXML($xmldoc->saveXML());
- //echo htmlentities($xmldoc->saveXML());
- $resXml = $xpost->postXmlMessage();
- $this->parseResponse($resXml);
- //echo htmlentities($resXml);
- }
- /* build request xml to start session*/
- function buildRequestXMLDoc($sessId) {
- $service_name = "SessionParams";
- $xmldoc = $this->buildE2XMLHeader("SystemService", $service_name, $sessId);
- $xpath = "//".$service_name;
- for ($i = 0; $i < count($this->params); $i ++) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Param", "");
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Param", "Action", $this->params[$i]->getAction());
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Param", "Name", $this->params[$i]->getName());
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Param", "Value", $this->params[$i]->getValue());
- }
- return $xmldoc;
- }
- }
- class Transaction {
- /* class dealing with e2 transaction
- Author: Mahbubur Rahman Sumon
- */
- var $sessionID;
- var $version;
- var $service;
- function setSessionID($newSessionID) {
- $this->sessionID = $newSessionID;
- }
- function setVersion($newVersion) {
- $this->version = $newVersion;
- }
- function setService($newService) {
- $this->service = $newService;
- }
- function getSessionID() {
- return $this->sessionID;
- }
- function getVersion() {
- return $this->version;
- }
- function getService() {
- return $this->service;
- }
- }
- // E2 fault class
- class Fault {
- var $errorCode;
- var $errorDesc;
- var $errorType;
- function setErrorCode($newErrorCode) {
- $this->errorCode = $newErrorCode;
- }
- function setErrorDesc($newErrorDesc) {
- $this->errorDesc = $newErrorDesc;
- }
- function setErrorType($newErrorType) {
- $this->errorType = $newErrorType;
- }
- function getErrorCode() {
- return $this->errorCode;
- }
- function getErrorDesc() {
- return $this->errorDesc;
- }
- function getErrorType() {
- return $this->errorType;
- }
- function Fault($code = "", $type = "", $desc = "") {
- $this->errorCode = $code;
- $this->errorType = $type;
- $this->errorDesc = $desc;
- }
- function showErrorMessage() {
- echo "<table border=\"1\">
- <tr>
- <td colspan=\"2\" align=\"center\" bgcolor=\"#f00000\">Error</td>
- </tr>";
- if (isset ($this->errorCode)) {
- echo "<tr>
- <td >Code:</td>
- <td>{$this->errorCode}</td>
- </tr>";
- }
- if (isset ($this->errorDesc)) {
- echo "<tr>
- <td>Description:</td>
- <td>{$this->errorDesc}</td>
- </tr>";
- }
- if (isset ($this->errorType)) {
- echo "<tr>
- <td>Severity:</td>
- <td>{$this->errorType}</td>
- </tr>";
- }
- echo "</table>";
- }
- /* save e2 client error message for log*/
- function saveErrorMessage() {
- $processId = getmypid();
- $logFile = "/tmp/e2client".$processId.".log";
- $fp = fopen($logFile, "a+");
- if (!$fp) {
- return;
- }
- fwrite($fp, $this->errorType.",".$this->errorCode.",".$this->errorDesc."\n");
- fclose($fp);
- }
- }
- class Param extends BasicE2XML {
- /* deal with e2 session param*/
- var $action;
- var $name;
- var $value;
- function setAction($new_action) {
- $this->action = $new_action;
- }
- function setName($new_name) {
- $this->name = $new_name;
- }
- function setValue($new_value) {
- $this->value = $new_value;
- }
- function getAction() {
- return $this->action;
- }
- function getName() {
- return $this->name;
- }
- function getValue() {
- return $this->value;
- }
- function buildReqXml($xmldoc, $xpath) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Param", "");
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Param", "Action", $this->action);
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Param", "Name", $this->name);
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Param", "Value", $this->value);
- return $xmldoc;
- }
- function parse_param($xmldoc, $xpath) {
- $xpath = $xpath."/Param";
- $this->action = $this->getXpathNodeValue($xmldoc, $xpath."/Action");
- $this->name = $this->getXpathNodeValue($xmldoc, $xpath."/Name");
- $this->value = $this->getXpathNodeValue($xmldoc, $xpath."/Value");
- }
- }
- class XMLPosting {
- var $reqXML;
- var $resXML;
- var $url;
- function setUrl($newUrl) {
- $this->url = $newUrl;
- }
- function setReqXML($newReqXML) {
- $this->reqXML = $newReqXML;
- }
- function getReqXML() {
- return $this->reqXML;
- }
- function getResXML() {
- return $this->resXML;
- }
- function postXmlMessage() {
- $ch = curl_init($this->url);
- curl_setopt($ch, CURLOPT_HEADER, false);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable
- curl_setopt($ch, CURLOPT_POSTFIELDS, $this->reqXML); // add POST fields
- // grab URL and pass it to the browser
- $this->resXML = curl_exec($ch);
- // close CURL resource, and free up system resources
- curl_close($ch);
- return $this->resXML;
- }
- }
- class E2Interface extends BasicE2XML {
- /* deal with e2 xml communication, */
- var $reqXML;
- var $resXML;
- var $url;
- function setUrl($newUrl) {
- $this->url = $newUrl;
- }
- function setReqXML($newReqXML) {
- $this->reqXML = $newReqXML;
- }
- function getReqXML() {
- return $this->reqXML;
- }
- function getResXML() {
- return $this->resXML;
- }
- function postXmlMessage() {
- if (!isset ($this->url) || strlen($this->url) <= 0) {
- $this->setErrorCode("Website-C0001");
- $this->setErrorType("error");
- $this->setErrorDesc("Invalid or no URL");
- return;
- }
- $ch = curl_init($this->url);
- if (!$ch) {
- $this->setErrorCode("Website-C0001");
- $this->setErrorType("error");
- $this->setErrorDesc("Invalid or no URL");
- return;
- }
- curl_setopt($ch, CURLOPT_HEADER, false);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable
- curl_setopt($ch, CURLOPT_POSTFIELDS, $this->reqXML); // add POST fields
- // grab URL and pass it to the browser
- $this->resXML = curl_exec($ch);
- // close CURL resource, and free up system resources
- curl_close($ch);
- return $this->resXML;
- }
- }
- class BasicE2XML extends Fault {
- /* deal with basic e2 xml funcitons*/
- // service name
- var $service;
- // action name
- var $action;
- // session id
- var $sessionId;
- // response array
- var $responseArray;
- // set service
- function setService($newService) {
- $this->service = $newService;
- }
- // set action
- function setAction($newAction) {
- $this->action = $newAction;
- }
- // get session Id
- function getSessionId() {
- return $this->sessionId;
- }
- // set session Id
- function setSessionId($newSessId) {
- $this->sessionId = $newSessId;
- }
- // get response array
- function getResponseArray() {
- return ($this->responseArray);
- }
- // add node and set value under a parent
- function setXNodeValue($xd, $parent_xpath, $child, $childValue) {
- $calcX = new DOMXPath($xd);
- $xNodes = $calcX->query("$parent_xpath");
- $ch = $xd->createElement("$child");
- if ($childValue) {
- $ch->nodeValue = utf8_encode($childValue);
- }
- // point to the last node in the xpath
- $count = $xNodes->length;
- /*foreach ($i = 0; $i < $count; $i ++) {
- if (!$xNodes->item($i))
- break;
- }
- // parent node not found so return
- if ($i == 0)
- return;*/
- if ($xNodes->item($count -1)) {
- $xNodes->item($count -1)->appendChild($ch);
- }
- return $xd;
- }
- // Add attribute to a node
- // Added by Yayun Sun
- function setXNodeAttribute($xd, $node_xpath, $attrName, $attrValue) {
- $calcX = DOMXPath($xd);
- $xNodes = $calcX->query("$node_xpath");
- if ($attrValue) {
- $attrValue = utf8_encode($attrValue);
- }
- // point to the last node in the xpath
- $count = $xNodes->length;
- /*for ($i = 0; $i < sizeof($xNodes->nodeset); $i ++) {
- if (!$xNodes->nodeset[$i])
- break;
- }
- // parent node not found so return
- if ($i == 0)
- return;*/
- if ($xNodes->item($count -1)) {
- $xNodes->item($count -1)->setAttribute($attrName, $attrValue);
- }
- return $xd;
- }
- //Return node value of xpath
- function getXNodeValue($xd, $parent_xpath) {
- $calcX = DOMXPath($xd);
- $xNodes = $calcX->query("$parent_xpath");
- $ch = $xd->createElement("$child");
- if ($xNodes->item(0)) {
- return $xNodes->item[0]->nodeValue;
- }
- return "";
- }
- //build header of e2 service
- function buildE2XMLHeader($newService = "", $newAction = "", $newSessId = "") {
- if (!isset ($this->service)) {
- $this->service = $newService;
- }
- if (!isset ($this->action)) {
- $this->action = $newAction;
- }
- if (!isset ($this->sessionId)) {
- $this->sessionId = $newSessId;
- }
- $doc = new DOMDocument('1.0', 'ISO-8859-1');
- $doc->formatOutput = true;
- $root = $doc->createElement($this->service);
- $root = $doc->appendChild($root);
- $tRoot = $doc->createElement("Transaction");
- $tRoot = $root->appendChild($tRoot);
- $tRoot = $doc->createElement($this->action);
- $tRoot = $root->appendChild($tRoot);
- $doc = $this->setXNodeValue($doc, "//Transaction", "SessionID", $this->sessionId);
- $doc = $this->setXNodeValue($doc, "//Transaction", "Version", "1.0");
- $doc = $this->setXNodeValue($doc, "//Transaction", "Service", $this->action);
- return $doc;
- }
- function parseNodeFault($node) {
- if ($node->hasChildNodes()) {
- foreach ($node->childNodes as $n) {
- //error message here
- if ($n->nodeName == 'Fault') {
- foreach ($n->childNodes as $flt) {
- if ($flt->nodeName == 'Code')
- $this->setErrorCode($flt->nodeValue);
- if ($flt->nodeName == 'Description')
- $this->setErrorDesc($flt->nodeValue);
- if ($flt->nodeName == 'Severity')
- $this->setErrorType($flt->nodeValue);
- }
- return;
- }
- }
- }
- return;
- }
- // parse xml response
- function parseResponse($rx) {
- $doc = new DOMDocument('1.0', 'ISO-8859-1');
- if (!$doc->loadXML($rx)) {
- // it is done here to isolate e2 client library independant
- // of client website.
- $this->setErrorCode("Website-C0201");
- $this->setErrorType("fatal");
- $this->setErrorDesc("Error while parsing response xml document");
- return;
- }
- $root = $doc->firstChild;
- $this->parseNodeFault($root);
- if (strlen($this->getErrorCode()) > 0) {
- //$dom->free();
- return;
- }
- $xml2a = new xml2array($rx);
- $xa = $xml2a->getResult();
- if (is_array($xa[$this->service][$this->action])) {
- $this->responseArray = $xa[$this->service][$this->action];
- }
- //$dom->free();
- return $this->responseArray;
- }
- }
- class FindAvailability extends E2Interface {
- /* Deal with e2 availability*/
- var $programme;
- var $productType;
- var $property;
- var $product;
- var $destination;
- var $resort;
- var $depart;
- var $arrive;
- var $adult;
- var $duration;
- var $startDate;
- var $endDate;
- var $leaves;
- var $type;
- var $roomTypeList;
- var $availableProducts;
- function setProgramme($newProgramme) {
- $this->programme = $newProgramme;
- }
- function setProductType($newProductType) {
- $this->productType = $newProductType;
- }
- function setProperty($newProperty) {
- $this->property = $newProperty;
- }
- function setProduct($newProduct) {
- $this->product = $newProduct;
- }
- function setDestination($newDestination) {
- $this->destination = $newDestination;
- }
- function setResort($newResort) {
- $this->resort = $newResort;
- }
- function setAdult($newAdult) {
- $this->adult = $newAdult;
- }
- function setDuration($newDura) {
- $this->duration = $newDura;
- }
- function setDepart($newDepart) {
- $this->depart = $newDepart;
- }
- function setArrive($newArrive) {
- $this->arrive = $newArrive;
- }
- function setStartDate($newStartDate) {
- $this->startDate = $newStartDate;
- }
- function setEndDate($newEndDate) {
- $this->endDate = $newEndDate;
- }
- function setLeaves($newLeaves) {
- $this->leaves = $newLeaves;
- }
- function setType($newType) {
- $this->type = $newType;
- }
- function setRoomTypeList($newList) {
- $this->roomTypeList = $newList;
- }
- function setAvailableProducts($newAvailableProducts) {
- $this->availableProducts = $newAvailableProducts;
- }
- function getProgramme() {
- return $this->programme;
- }
- function getProductType() {
- return $this->productType;
- }
- function getProperty() {
- return $this->property;
- }
- function getProduct() {
- return $this->product;
- }
- function getDestination() {
- return $this->destination;
- }
- function getResort() {
- return $this->resort;
- }
- function getAdult() {
- return $this->adult;
- }
- function getDuration() {
- return $this->duration;
- }
- function getStartDate() {
- return $this->startDate;
- }
- function getEndDate() {
- return $this->endDate;
- }
- function getLeaves() {
- return $this->leaves;
- }
- function getAvailableProducts() {
- return $this->responseArray;
- }
- // find availability constructor
- function FindAvailability($newProductType = "", $newStartDate = "", $newAdult = "0", $newLeaves = "") {
- $this->service = "ReservationService";
- $this->action = "FindAvailability";
- $this->productType = $newProductType;
- $this->startDate = $newStartDate;
- $this->adult = $newAdult;
- $this->leaves = $newLeaves;
- }
- function getAvailability($url, $sessId, $details, $newResType = "array") {
- /* core member function for availability*/
- $xmldoc = $this->buildRequestXMLDoc($sessId, $details);
- $this->setUrl($url);
- $this->setReqXML($xmldoc->saveXML());
- //echo htmlentities($xmldoc->saveXML());
- $resXml = $this->postXmlMessage();
- //echo htmlentities($this->resXML);
- if ($newResType == 'array'){
- return $this->parseResponse($this->resXML);
- }else{
- return $resXml;
- }
- }
- function buildRequestXMLDoc($sessId, $details) {
- /* build request xml for e2 availability*/
- $xmldoc = $this->buildE2XMLHeader("ReservationService", "FindAvailability", $sessId);
- if (isset ($this->programme)) {
- $xmldoc = $this->setXNodeValue($xmldoc, "//FindAvailability", "Programme", $this->programme);
- }
- if (isset ($this->productType)) {
- $xmldoc = $this->setXNodeValue($xmldoc, "//FindAvailability", "ProductType", $this->productType);
- }
- if (isset ($this->property)) {
- $xmldoc = $this->setXNodeValue($xmldoc, "//FindAvailability", "Property", $this->property);
- }
- if (isset ($this->product)) {
- $xmldoc = $this->setXNodeValue($xmldoc, "//FindAvailability", "Product", $this->product);
- }
- if (isset ($this->destination)) {
- $xmldoc = $this->setXNodeValue($xmldoc, "//FindAvailability", "Destination", $this->destination);
- }
- if (isset ($this->resort)) {
- $xmldoc = $this->setXNodeValue($xmldoc, "//FindAvailability", "Resort", $this->resort);
- }
- if (isset ($this->startDate)) {
- $xmldoc = $this->setXNodeValue($xmldoc, "//FindAvailability", "StartDate", $this->startDate);
- }
- if (isset ($this->endDate)) {
- $xmldoc = $this->setXNodeValue($xmldoc, "//FindAvailability", "EndDate", $this->endDate);
- }
- if (isset ($this->duration)) {
- $xmldoc = $this->setXNodeValue($xmldoc, "//FindAvailability", "Duration", $this->duration);
- }
- if (isset ($this->leaves)) {
- $xmldoc = $this->setXNodeValue($xmldoc, "//FindAvailability", "Leaves", $this->leaves);
- }
- if (isset ($this->type)) {
- $xmldoc = $this->setXNodeValue($xmldoc, "//FindAvailability", "Type", $this->type);
- }
- if (isset ($this->roomTypeList)) {
- $xmldoc = $this->setXNodeValue($xmldoc, "//FindAvailability", "RoomTypeList", $this->roomTypeList);
- }
- if (isset ($this->adult)) {
- $xmldoc = $this->setXNodeValue($xmldoc, "//FindAvailability", "Adult", $this->adult);
- }
- if (isset ($this->depart)) {
- $xmldoc = $this->setXNodeValue($xmldoc, "//FindAvailability", "Depart", $this->depart);
- }
- if (isset ($this->arrive)) {
- $xmldoc = $this->setXNodeValue($xmldoc, "//FindAvailability", "Arrive", $this->arrive);
- }
- /* for availability detail information*/
- for ($index = 0; $index < sizeof($details) and isset ($details[$index]); $index ++) {
- $detailFlag = $details[$index];
- if ($index == 0) {
- $xmldoc = $this->setXNodeValue($xmldoc, "//FindAvailability", "Detail", "");
- }
- $xmldoc = $detailFlag->buildRequestXMLDoc($xmldoc, "//FindAvailability/Detail");
- }
- return $xmldoc;
- }
- }
- class AvailDetails extends BasicE2XML {
- /* deal with e2 availability details flag*/
- var $flag;
- var $value;
- function setFlag($newFalg) {
- $this->flag = $newFlag;
- }
- function setValue($newValue) {
- $this->value = $newValue;
- }
- function getFlag() {
- return $this->flag;
- }
- function getValue() {
- return $this->value;
- }
- function AvailDetails($newFlag, $newValue) {
- /* constructor*/
- $this->flag = $newFlag;
- $this->value = $newValue;
- }
- function buildRequestXMLDoc($xmldoc, $xpath) {
- if (strlen($this->flag)){
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, $this->flag, $this->value);
- }
- return $xmldoc;
- }
- }
- class StartEnquiry extends E2Interface {
- /* Deal with e2 StartEnquiry*/
- var $source; // Booking source
- var $adult; // Booking source
- var $bookingNumber; // human readable booking number
- var $email; // Email address, for auto notification to be sent in addition to the email address of the E2 user
- var $noStartEmail;
- function setSource($newSource) {
- $this->source = $newSource;
- }
- function setAdult($newA) {
- $this->adult = $newA;
- }
- function setBookingNumber($newBooking) {
- $this->bookingNumber = $newBooking;
- }
- function setEmail($newE) {
- $this->email = $newE;
- }
- function setNoStartEmail($newN) {
- $this->noStartEmail = $newN;
- }
- function getSource() {
- return ($this->source);
- }
- function getBookingNumber() {
- $this->bookingNumber = $this->responseArray["Success"];
- return ($this->bookingNumber);
- }
- function StartEnquiry($newSource = "") {
- /* constructor */
- $this->service = "ReservationService";
- $this->action = "StartEnquiry";
- $this->source = $newSource;
- }
- function Book($url, $sessId) {
- $xmldoc = $this->buildRequestXMLDoc($sessId);
- //$xpost = new XMLPosting();
- $this->setUrl($url);
- $this->setReqXML($xmldoc->saveXML());
- //echo htmlentities($xmldoc->saveXML());
- $resXml = $this->postXmlMessage();
- //echo htmlentities($resXml);
- $this->parseResponse($this->resXML);
- }
- function buildRequestXMLDoc($sessId) {
- /* build request xml for e2 StartEnquiry*/
- $service = $this->action;
- $xmldoc = $this->buildE2XMLHeader($this->service, $service, $sessId);
- if (isset ($this->source)) {
- $xmldoc = $this->setXNodeValue($xmldoc, "//".$service, "Source", $this->source);
- }
- if (isset ($this->adult)) {
- $xmldoc = $this->setXNodeValue($xmldoc, "//".$service, "Adult", $this->adult);
- }
- if (isset($this->email)) {
- $xmldoc = $this->setXNodeValue($xmldoc, "//".$service, "Email", $this->email);
- }
- if (isset($this->noStartEmail) && $this->noStartEmail) {
- $xmldoc = $this->setXNodeValue($xmldoc, "//".$service, "NoStartEmail", "");
- }
- return $xmldoc;
- }
- }
- class PrepareDetails extends E2Interface {
- /* Deal with e2 PrepareDetails*/
- /* it is compatible with single product*/
- var $type;
- var $product;
- var $suppCode;
- var $suppDepDate;
- var $suppDur;
- var $details;
- function setType($newType) {
- $this->type = $newType;
- }
- function setProduct($newProduct) {
- $this->product = $newProduct;
- }
- function setSupplementCode($newSuppCode) {
- $this->suppCode = $newSuppCode;
- }
- function setSupplementDeparture($newSuppDep) {
- $this->suppDepDate = $newSuppDep;
- }
- function setSupplementDuration($newSuppDur) {
- $this->suppDur = $newSuppDur;
- }
- function setDetails($newDetails) {
- $this->lineStyleArray = $newDetails;
- }
- function getType() {
- return ($this->type);
- }
- function getProduct() {
- return ($this->product);
- }
- function getDetails() {
- return ($this->responseArray);
- }
- function PrepareDetails($newType = "", $newProduct = "") {
- /* constructor */
- $this->service = "ReservationService";
- $this->action = "PrepareDetails";
- $this->type = $newType;
- $this->product = $newProduct;
- }
- function prepare($url, $sessId) {
- $xmldoc = $this->buildRequestXMLDoc($sessId);
- //$xpost = new XMLPosting();
- $this->setUrl($url);
- $this->setReqXML($xmldoc->saveXML());
- //echo htmlentities($xmldoc->saveXML());
- $resXml = $this->postXmlMessage();
- //echo htmlentities($resXml);
- $this->parseResponse($this->resXML);
- }
- function buildRequestXMLDoc($sessId) {
- /* build request xml for e2 StartEnquiry*/
- $service = $this->action;
- $xmldoc = $this->buildE2XMLHeader($this->service, $service, $sessId);
- $xmldoc = $this->setXNodeValue($xmldoc, "//".$service, "Product", "");
- if (isset ($this->type)) {
- $xmldoc = $this->setXNodeValue($xmldoc, "//".$service."/Product", "ProductType", $this->type);
- }
- if (isset ($this->product)) {
- $xmldoc = $this->setXNodeValue($xmldoc, "//".$service."/Product", "ProductCode", $this->product);
- }
- if (isset ($this->suppCode)) {
- $xmldoc = $this->setXNodeValue($xmldoc, "//".$service."/Product", "SupplementCode", $this->suppCode);
- }
- if (isset ($this->suppDepDate)) {
- $xmldoc = $this->setXNodeValue($xmldoc, "//".$service."/Product", "SupplementDepartDate", $this->suppDepDate);
- }
- if (isset ($this->suppDur)) {
- $xmldoc = $this->setXNodeValue($xmldoc, "//".$service."/Product", "SupplementDuration", $this->suppDur);
- }
- return $xmldoc;
- }
- }
- class BookProduct extends E2Interface {
- /* Deal with e2 BookProduct*/
- /* it is dealt with single product*/
- var $products;
- var $transactionDetails; // have array of bookproduct response
- function setType($newType) {
- $this->type = $newType;
- }
- function setProducts($newProducts) {
- $this->products = $newProducts;
- }
- function setTransactionDetails($newTrans) {
- $this->transactionDetails = $newTrans;
- }
- function getType() {
- return ($this->type);
- }
- function getProducts() {
- return ($this->products);
- }
- function getTransactionDetails() {
- return ($this->responseArray);
- }
- function BookProduct($newURL, $sessId, $newProducts = "") {
- /* constructor */
- $this->service = "ReservationService";
- $this->action = "BookProduct";
- $this->sessionId = $sessId;
- $this->url = $newURL;
- $this->products = $newProducts;
- }
- function AddTransaction() {
- $xmldoc = $this->buildRequestXMLDoc();
- $this->setReqXML($xmldoc->saveXML());
- //echo htmlentities($xmldoc->saveXML());
- $resXml = $this->postXmlMessage();
- //echo htmlentities($resXml);
- $this->parseResponse($this->resXML);
- }
- function buildRequestXMLDoc() {
- /* build request xml for e2 BookProduct*/
- $xmldoc = $this->buildE2XMLHeader($this->service, $this->action, $sessId);
- $xpath = "//".$this->action;
- if (isset ($this->products) && is_array($this->products)) {
- foreach ($this->products as $p) {
- $xmldoc = $p->buildRequestXMLDoc($xmldoc, $xpath);
- }
- }
- return $xmldoc;
- }
- }
- class Product extends E2Interface {
- /* Deal with e2 BookProduct*/
- /* it is dealt with single product*/
- var $type;
- var $product;
- var $currency;
- var $packageDate;
- var $transactionNumber;
- var $lineStyle;
- var $lineStyleValue;
- var $sellPriceOverride;
- var $costPriceOverride;
- function setType($newType) {
- $this->type = $newType;
- }
- function setProduct($newProduct) {
- $this->product = $newProduct;
- }
- function setPackageDate ($newpd) {
- $this->packageDate = $newpd;
- }
- function setTransactionNumber($newTransNo){
- $this->transactionNumber = $newTransNo;
- }
- function getTransactionNumber(){
- $this->transactionNumber;
- }
- function setCurrency ($newcur) {
- $this->currency = $newcur;
- }
- function setLineStyle($newLS) {
- $this->lineStyle = $newLS;
- }
- function setLineStyleValue($newLSValue) {
- $this->lineStyleValue = $newLSValue;
- }
- function setSellPriceOverride($priceOverride){
- $this->sellPriceOverride = $priceOverride;
- }
- function setCostPriceOverride($priceOverride){
- $this->costPriceOverride = $priceOverride;
- }
- function getType() {
- return ($this->type);
- }
- function getProduct() {
- return ($this->product);
- }
- function Product($newType = "", $newProduct = "", $ls = "", $lsValue = "") {
- /* constructor */
- $this->service = "ReservationService";
- $this->action = "BookProduct";
- $this->type = $newType;
- $this->product = $newProduct;
- $this->lineStyle = $ls;
- $this->lineStyleValue = $lsValue;
- }
- function buildRequestXMLDoc($xmldoc, $xpath) {
- /* build request xml for e2 Product*/
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Product", "");
- $xpath = $xpath."/Product";
- // when supplement booking
- if ($this->type == "SUP"){
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "TransactionNumber", $this->transactionNumber);
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Supplements", "");
- $xpath = $xpath."/Supplements";
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Supplement", "");
- $xpath = $xpath."/Supplement";
- }
- if (isset ($this->type)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "ProductType", $this->type);
- }
- if (isset ($this->product)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "ProductCode", $this->product);
- }
- if (isset ($this->packageDate)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "PackageDate", $this->packageDate);
- }
- if (isset ($this->currency)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Currency", $this->currency);
- }
- if (isset($this->sellPriceOverride)){
- $xmldoc = $this->sellPriceOverride->buildReqXML($xmldoc, $xpath);
- }
- if (isset($this->costPriceOverride)){
- $xmldoc = $this->costPriceOverride->buildReqXML($xmldoc, $xpath);
- }
- /* add lines style value*/
- if (is_array($this->lineStyle)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "LineStyleDetails", "");
- $xpath = $xpath."/LineStyleDetails";
- foreach ($this->lineStyle as $line) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "LineStyle", "");
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/LineStyle", "Field", $line["Field"]);
- $lsValue = "";
- if (isset ($this->lineStyleValue[strtoupper($line["Field"])])) {
- $lsValue = $this->lineStyleValue[strtoupper($line["Field"])];
- }
- if (strlen($lsValue) == 0){
- $lsValue = $line["Value"];
- }
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/LineStyle", "Value", $lsValue);
- }
- }
- return $xmldoc;
- }
- }
- class BookingInfo extends BasicE2XML {
- /* Deal with e2 BookingInfo*/
- /* Now this class is deprecated to use*/
- /* you suggested to use BookingDetails which is */
- /* more organised*/
- var $bookingNumber; // human readable booking number
- var $bookingSummary; // flag for booking summary details
- var $transactions; // flag for transaction details
- var $pax; // flag for passenger details
- var $notes; // flag for booking notes details
- var $autoNotes; // flag for auto booking notes details
- var $docs; // flag for booking docs details
- var $toggleOrder; // flag for toggle itinerary order
- var $showCanx; // flag for showing cancelled lines
- var $info; // info array
- function setBookingNumber($newB = "") {
- $this->bookingNumber = $newB;
- }
- function setBookingSummary($newBS = "") {
- $this->bookingSummary = $newBS;
- }
- function setTransactions($newT = "") {
- $this->transaction = $newT;
- }
- function setPax($newP = "") {
- $this->pax = $newP;
- }
- function setNotes($newN = "") {
- $this->notes = $newN;
- }
- function setAutoNotes($newA = "") {
- $this->autoNotes = $newA;
- }
- function setDocs($newD = "") {
- $this->docs = $newD;
- }
- function setToggleOrder($newTG = "") {
- $this->toggleOrder = $newTG;
- }
- function setShowCanx($newSC = "") {
- $this->showCanx = $newSC;
- }
- function setInfo($newI) {
- $this->info = $newI;
- }
- function getBookingNumber() {
- return $this->bookingNumber;
- }
- function getBookingSummary() {
- return $this->bookingSummary;
- }
- function getTransactions() {
- return $this->transaction;
- }
- function getPax() {
- return $this->pax;
- }
- function getNotes() {
- return $this->notes;
- }
- function getDocs() {
- return $this->docs;
- }
- function getToggleOrder() {
- return $this->toggleOrder;
- }
- function getShowCanx() {
- return $this->showCanx;
- }
- function getInfo() {
- return $this->info;
- }
- function BookingInfo($newBookingNumber = "") {
- /* constructor */
- $this->bookingNumber = $newBookingNumber;
- }
- function findInfo($url, $sessId) {
- $xmldoc = $this->buildRequestXMLDoc($sessId);
- $xpost = new XMLPosting();
- $xpost->setUrl($url);
- $xpost->setReqXML($xmldoc->saveXML());
- //echo htmlentities($xmldoc->saveXML());
- $resXml = $xpost->postXmlMessage();
- //echo htmlentities($resXml);
- $this->parseResponse($resXml);
- }
- function buildRequestXMLDoc($sessId) {
- /* build request xml for e2 BookingInfo*/
- $service_name = "BookingInfo";
- $xmldoc = $this->buildE2XMLHeader("ReservationService", $service_name, $sessId);
- $xpath = "//".$service_name;
- if (isset ($this->bookingNumber)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "BookingNumber", $this->bookingNumber);
- }
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "DetailLevel", "");
- $xpath = $xpath."/DetailLevel";
- if (isset ($this->bookingSummary)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "BookingSummary", "");
- }
- if (isset ($this->transaction)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Transactions", "");
- }
- if (isset ($this->pax)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Pax", "");
- }
- if (isset ($this->notes)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Notes", "");
- }
- if (isset ($this->autoNotes)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "AutoNotes", "");
- }
- if (isset ($this->docs)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Docs", "");
- }
- if (isset ($this->toggleOrder)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "ToggleOrder", "");
- }
- if (isset ($this->showCanx)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "ShowCanx", "");
- }
- return $xmldoc;
- }
- function parseResponse($rx) {
- $doc = new DOMDocument('1.0', 'ISO-8859-1');
- if (!$doc->loadXML($rx)) {
- // it is done here to isolate e2 client library independant
- // of client website.
- $this->setErrorCode("Website-C0201");
- $this->setErrorType("fatal");
- $this->setErrorDesc("Error while parsing response xml document");
- return;
- }
- $root = $doc->firstChild;
- $this->parseNodeFault($root);
- if (strlen($this->getErrorCode()) > 0) {
- //$dom->free();
- return;
- }
- $xml2a = new xml2array($rx);
- $xa = $xml2a->getResult();
- if (is_array($xa['ReservationService']["$service_name"])) {
- $this->info = $xa['ReservationService']["$service_name"];
- }
- //$dom->free();
- }
- }
- class CancelTransaction extends E2Interface {
- /* Deal with e2 CancelTransaction*/
- /* it is dealt with multiple transaction*/
- var $transArray; // store array xsaction number
- function setTransArray($newTA) {
- $this->transArray = $newTA;
- }
- function getTransArray() {
- return $this->transArray;
- }
- function CancelTransaction($newTA = "") {
- /* constructor */
- $this->service = "ReservationService";
- $this->action = "CancelTransaction";
- $this->transArray = $newTA;
- }
- function cancel($url, $sessId) {
- $xmldoc = $this->buildRequestXMLDoc($sessId);
- $this->setUrl($url);
- $this->setReqXML($xmldoc->saveXML());
- //echo htmlentities($xmldoc->saveXML());
- $resXml = $this->postXmlMessage();
- //echo htmlentities($resXml);
- $this->parseResponse($this->resXML);
- }
- function buildRequestXMLDoc($sessId) {
- /* build request xml for e2 CancelTransaction */
- $service_name = $this->action;
- $xmldoc = $this->buildE2XMLHeader($this->service, $service_name, $sessId);
- $xpath = "//".$service_name;
- /* add cancel lines */
- if (is_array($this->transArray)) {
- foreach ($this->transArray as $cl) {
- $trans_no = $cl;
- if (strpos($cl, ":") >= 0){
- list($trans_no, $supp_no) = split("\+", $cl);
- }
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "BookingTransaction", "");
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/BookingTransaction", "TransactionNumber", $trans_no);
- if (strlen($supp_no)){
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/BookingTransaction", "SupplementNumber", $supp_no);
- }
- }
- }
- return $xmldoc;
- }
- }
- class AddPassenger extends E2Interface {
- /* Obsolate to use this class, Please use PassengerService*/
- /* Deal with e2 AddPassenger*/
- /* it is dealt with multiple pax*/
- var $paxArray; // store array pax
- var $paxStyleArray; // store pax style value
- function setPaxArray($newPA) {
- $this->paxArray = $newPA;
- }
- function setPaxStyleArray($newPX) {
- $this->paxStyleArray = $newPX;
- }
- function getPaxArray() {
- return $this->paxArray;
- }
- function AddPassenger($newPA = "", $newPX = "") {
- /* constructor */
- $this->service = "ReservationService";
- $this->action = "AddPassenger";
- $this->paxArray = $newPA;
- $this->paxStyleArray = $newPX;
- }
- function add($url, $sessId) {
- $xmldoc = $this->buildRequestXMLDoc($sessId);
- $this->setUrl($url);
- $this->setReqXML($xmldoc->saveXML());
- //echo htmlentities($xmldoc->saveXML());
- $resXml = $this->postXmlMessage();
- //echo htmlentities($resXml);
- $this->parseResponse($this->resXML);
- }
- function buildRequestXMLDoc($sessId) {
- /* build request xml for e2 CancelTransaction */
- $service_name = $this->action;
- $xmldoc = $this->buildE2XMLHeader($this->service, $service_name, $sessId);
- $xpath = "//".$service_name;
- /* add paxs */
- if (is_array($this->paxArray)) {
- foreach ($this->paxArray as $px) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Passenger", "");
- if (isset ($px["Title"])) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "Title", $px["Title"]);
- }
- if (isset ($px["Firstname"])) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "Firstname", $px["Firstname"]);
- }
- if (isset ($px["Lastname"])) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "Lastname", $px["Lastname"]);
- }
- if (isset ($px["Gender"])) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "Gender", $px["Gender"]);
- }
- if (isset ($px["BirthDate"])) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "BirthDate", $px["BirthDate"]);
- }
- if (isset ($px["Age"])) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "Age", $px["Age"]);
- }
- if (isset ($px["InfantAge"])) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "InfantAge", $px["InfantAge"]);
- }
- if (isset ($px["Smoker"])) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "Smoker", $px["Smoker"]);
- }
- /* add paxs style value */
- if (is_array($this->paxStyleArray)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "PaxStyleDetails", "");
- $pxs_path = "/Passenger/PaxStyleDetails";
- foreach ($this->paxStyleArray as $pxs) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath.$pxs_path, "PaxStyle", "");
- //print ($this->paxStyleValueArray[$pxs["Field"]]);
- if (isset ($px[$pxs["Field"]])) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath.$pxs_path."/PaxStyle", "Field", $pxs["Field"]);
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath.$pxs_path."/PaxStyle", "Value", $px[$pxs["Field"]]);
- }
- }
- }
- }
- }
- return $xmldoc;
- }
- }
- class UpdatePassenger extends E2Interface {
- /* Deal with e2 UpdatePassenger*/
- /* it is dealt with multiple pax*/
- /* Added by Yayun Sun*/
- var $paxArray; // store array pax
- var $paxStyleArray; // store pax style value
- function setPaxArray($newPA) {
- $this->paxArray = $newPA;
- }
- function setPaxStyleArray($newPX) {
- $this->paxStyleArray = $newPX;
- }
- function getPaxArray() {
- return $this->paxArray;
- }
- function UpdatePassenger($newPA = "", $newPX = "") {
- /* constructor */
- $this->service = "ReservationService";
- $this->action = "UpdatePassenger";
- $this->paxArray = $newPA;
- $this->paxStyleArray = $newPX;
- }
- function update($url, $sessId) {
- $xmldoc = $this->buildRequestXMLDoc($sessId);
- $this->setUrl($url);
- $this->setReqXML($xmldoc->saveXML());
- //echo htmlentities($xmldoc->saveXML());
- $resXml = $this->postXmlMessage();
- //echo htmlentities($resXml);
- $this->parseResponse($this->resXML);
- }
- function buildRequestXMLDoc($sessId) {
- /* build request xml for e2 UpdatePassenger */
- $service_name = $this->action;
- $xmldoc = $this->buildE2XMLHeader($this->service, $service_name, $sessId);
- $xpath = "//".$service_name;
- /* add paxs */
- if (is_array($this->paxArray)) {
- foreach ($this->paxArray as $px) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Passenger", "");
- if (isset ($px["PaxCode"])) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "PaxCode", $px["PaxCode"]);
- }
- if (isset ($px["Title"])) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "Title", $px["Title"]);
- }
- if (isset ($px["Firstname"])) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "Firstname", $px["Firstname"]);
- }
- if (isset ($px["Lastname"])) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "Lastname", $px["Lastname"]);
- }
- if (isset ($px["Gender"])) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "Gender", $px["Gender"]);
- }
- if (isset ($px["BirthDate"])) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "BirthDate", $px["BirthDate"]);
- }
- if (isset ($px["Age"])) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "Age", $px["Age"]);
- }
- if (isset ($px["AgeCategory"])) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "AgeCategory", $px["AgeCategory"]);
- }
- if (isset ($px["InfantAge"])) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "InfantAge", $px["InfantAge"]);
- }
- if (isset ($px["Smoker"])) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "Smoker", $px["Smoker"]);
- }
- /* add paxs style value */
- if (is_array($this->paxStyleArray)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "PaxStyleDetails", "");
- $pxs_path = "/Passenger/PaxStyleDetails";
- foreach ($this->paxStyleArray as $pxs) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath.$pxs_path, "PaxStyle", "");
- if (isset ($px[$pxs["Field"]])) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath.$pxs_path."/PaxStyle", "Field", $pxs["Field"]);
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath.$pxs_path."/PaxStyle", "Value", $px[$pxs["Field"]]);
- }
- }
- }
- }
- }
- return $xmldoc;
- }
- }
- class PreparePassenger extends E2Interface {
- /* Obsolate to use this class, Please use PassengerService*/
- /* Deal with e2 PreparePassenger*/
- function PreparePassenger() {
- $this->service = "ReservationService";
- $this->action = "PreparePassenger";
- /* constructor */
- }
- function prepare($url, $sessId) {
- $xmldoc = $this->buildRequestXMLDoc($sessId);
- $this->setUrl($url);
- $this->setReqXML($xmldoc->saveXML());
- //echo htmlentities($xmldoc->saveXML());
- $resXml = $this->postXmlMessage();
- //echo htmlentities($resXml);
- $this->parseResponse($this->resXML);
- }
- function buildRequestXMLDoc($sessId) {
- /* build request xml for e2 CancelTransaction */
- $service_name = $this->action;
- $xmldoc = $this->buildE2XMLHeader($this->service, $service_name, $sessId);
- return $xmldoc;
- }
- }
- class PassengerService extends E2Interface {
- /* Deal with e2 AddPassenger, prepare passenger, update passenger*/
- /* it is dealt with multiple pax*/
- var $paxArray; // store array pax
- var $paxStyleArray; // store pax style value
- var $skipNumberCheck; // whether to skip number check on names
- function setPaxArray($newPA) {
- $this->paxArray = $newPA;
- }
- function setPaxStyleArray($newPX) {
- $this->paxStyleArray = $newPX;
- }
- function setSkipNumberCheck($newS) {
- $this->setSkipNumberCheck = $newS;
- }
- function getPaxArray() {
- return $this->paxArray;
- }
- function PassengerService($newAction, $url, $sessId) {
- /* constructor */
- $this->service = "ReservationService";
- $this->action = $newAction;
- $this->url = $url;
- $this->sessionId = $sessId;
- }
- function perform() {
- $xmldoc = $this->buildRequestXMLDoc();
- $this->setReqXML($xmldoc->saveXML());
- //echo htmlentities($xmldoc->saveXML());
- $resXml = $this->postXmlMessage();
- //echo htmlentities($resXml);
- $this->responseArray = $this->parseResponse($resXml);
- return $this->responseArray;
- }
- function buildRequestXMLDoc() {
- /* build request xml for e2 CancelTransaction */
- $service_name = $this->action;
- $xmldoc = $this->buildE2XMLHeader($this->service, $service_name, $this->sessionId);
- $xpath = "//".$service_name;
- /* add paxs */
- if (is_array($this->paxArray) && $this->action != 'PreparePassenger') {
- foreach ($this->paxArray as $px) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Passenger", "");
- if (isset ($px["PaxCode"])) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "PaxCode", $px["PaxCode"]);
- }
- if (isset ($px["Title"])) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "Title", $px["Title"]);
- }
- if (isset ($px["Firstname"])) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "Firstname", $px["Firstname"]);
- }
- if (isset ($px["Lastname"])) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "Lastname", $px["Lastname"]);
- }
- if (isset ($px["Gender"])) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "Gender", $px["Gender"]);
- }
- if (isset ($px["BirthDate"])) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "BirthDate", $px["BirthDate"]);
- }
- if (isset ($px["InfantAge"])) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "InfantAge", $px["InfantAge"]);
- }
- if (isset ($px["Smoker"])) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "Smoker", $px["Smoker"]);
- }
- /* add paxs style value */
- if (is_array($this->paxStyleArray)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "PaxStyleDetails", "");
- $pxs_path = "/Passenger/PaxStyleDetails";
- foreach ($this->paxStyleArray as $pxs) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath.$pxs_path, "PaxStyle", "");
- //print ($this->paxStyleValueArray[$pxs["Field"]]);
- if (isset ($px[$pxs["Field"]])) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath.$pxs_path."/PaxStyle", "Field", $pxs["Field"]);
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath.$pxs_path."/PaxStyle", "Value", $px[$pxs["Field"]]);
- }
- }
- }
- }
- }
- if ($this->setSkipNumberCheck) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "SkipNumberCheck", "");
- }
- return $xmldoc;
- }
- }
- class FindAcceptedCards extends E2Interface {
- var $cardType;
- function setCardType($newCT) {
- $this->cardType = $newCT;
- }
- function FindAcceptedCards($url, $sessId, $newCT="") {
- $this->service = "PaymentService";
- $this->action = "FindAcceptedCards";
- $this->url = $url;
- $this->sessionId = $sessId;
- $this->cardType = $newCT;
- }
- function find() {
- $xmldoc = $this->buildRequestXMLDoc();
- $this->setReqXML($xmldoc->saveXML());
- //echo htmlentities($xmldoc->saveXML());
- $resXml = $this->postXmlMessage();
- //echo htmlentities($resXml);
- $this->parseResponse($this->resXML);
- }
- function buildRequestXMLDoc() {
- /* build request xml for e2 CancelTransaction */
- $xmldoc = $this->buildE2XMLHeader();
- $xpath = "//".$this->action;
- if (isset ($this->paymentType)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "CardType", $this->cardType);
- }
- return $xmldoc;
- }
- }
- class PreviousCards extends E2Interface {
- var $clientCode;
- function setClientCode($newCL) {
- $this->clientCode = $newCL;
- }
- function PreviousCards($url, $sessId, $newCL="") {
- $this->service = "PaymentService";
- $this->action = "PreviousCards";
- $this->url = $url;
- $this->sessionId = $sessId;
- $this->clientCode = $newCL;
- }
- function find() {
- $xmldoc = $this->buildRequestXMLDoc();
- $this->setReqXML($xmldoc->saveXML());
- //echo htmlentities($xmldoc->saveXML());
- $resXml = $this->postXmlMessage();
- //echo htmlentities($resXml);
- $this->parseResponse($this->resXML);
- return $this->responseArray;
- }
- function buildRequestXMLDoc() {
- /* build request xml for e2 CancelTransaction */
- $xmldoc = $this->buildE2XMLHeader();
- $xpath = "//".$this->action;
- if (isset ($this->clientCode)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "ClientCode", $this->clientCode);
- }
- return $xmldoc;
- }
- }
- class AcceptPayment extends E2Interface {
- /* Deal with e2 AcceptPayment */
- var $paymentType;
- var $amount;
- var $paymentDate;
- var $note;
- /*var $chequeNo; // cheque payment is not necessary yet
- var $authCode;*/
- function setPaymentType($newPT) {
- $this->paymentType = $newPT;
- }
- function setAmount($newA) {
- $this->amount = $newA;
- }
- function setPaymentDate($newPD) {
- $this->paymentDate = $newPD;
- }
- function setNote($newN) {
- $this->note = $newN;
- }
- /*function setChequeNo ($newCN) {
- $this->chequeNo =$newCN;
- }
- function setAuthCode ($newAC) {
- $this->authCode = $newAC;
- }*/
- function AcceptPayment($pType = "", $amnt = 0) {
- $this->paymentType = $pType;
- $htis->amount = $amnt;
- }
- }
- class CCPayment extends AcceptPayment {
- var $collectInFuture;
- var $cardType;
- var $cardNo;
- var $expires;
- var $startDate;
- var $issueNo;
- var $securityCode;
- var $charge;
- var $authOption;
- var $authCode;
- var $previousCardRef;
- var $cardHolder; // will hold CardHolder object
- var $threeDSecureStep; // ThreeDSecure step verify or finalise
- var $paResFile;
- var $datacashReference;
- function setCollectionInFuture($newCIF) {
- $this->collectInFuture = $newCIF;
- }
- function setCardType($newCT) {
- $this->cardType = $newCT;
- }
- function setCardNo($newCN) {
- $this->cardNo = $newCN;
- }
- function setStartDate($newSD) {
- $this->startDate = $newSD;
- }
- function setExpires($newE) {
- $this->expires = $newE;
- }
- function setIssueNo($newIN) {
- $this->issueNo = $newIN;
- }
- function setSecurityCode($newSC) {
- $this->securityCode = $newSC;
- }
- function setCharge($newC) {
- $this->charge = $newC;
- }
- function setAuthOption($newAO) {
- $this->authOption = $newAO;
- }
- function setAuthCode($newAC) {
- $this->authCode = $newAC;
- }
- function setPreviousCardRef($newRef){
- $this->previousCardRef = $newRef;
- }
- function setCardHolder($newCH) {
- $this->cardHolder = $newCH;
- }
- function setThreeDSecureStep($step){
- $this->threeDSecureStep = $step;
- }
- function setPaResFile($file){
- $this->paResFile = $file;
- }
- function setDatacashReference($ref){
- $this->datacashReference = $ref;
- }
- function getCollectionInFuture() {
- return $this->collectInFuture;
- }
- function getCardType() {
- return $this->cardType;
- }
- function getCardNo() {
- return $this->setCardNo;
- }
- function getStartDate() {
- return $this->startDate;
- }
- function getExpires() {
- return $this->expires;
- }
- function getIssueNo() {
- return $this->issueNo;
- }
- function getSecurityCode() {
- return $this->securityCode;
- }
- function getCharge() {
- return $this->charge;
- }
- function getAuthOption() {
- return $this->authOption;
- }
- function getAuthCode() {
- return $this->authCode;
- }
- function getPreviousCardRef(){
- return $this->previousCardRef;
- }
- function getCardHolder() {
- return $this->cardHolder;
- }
- function CCPayment($pType = "", $amnt = 0, $newCType = "", $newCNo = "", $newExpires = "", $newAOption = "") {
- $this->service = "PaymentService";
- $this->action = "AcceptPayment";
- $this->paymentType = $pType;
- $this->amount = $amnt;
- $this->cardType = $newCType;
- $this->cardNo = $newCNo;
- $this->expires = $newExpires;
- $this->authOption = $newAOption;
- }
- function accept($url, $sessId) {
- $xmldoc = $this->buildRequestXMLDoc($sessId);
- $this->setUrl($url);
- $this->setReqXML($xmldoc->saveXML());
- //echo htmlentities($xmldoc->saveXML());
- $resXml = $this->postXmlMessage();
- //echo htmlentities($resXml);
- $this->parseResponse($this->resXML);
- }
- function buildRequestXMLDoc($sessId) {
- /* build request xml for e2 CancelTransaction */
- $service_name = $this->action;
- $xmldoc = $this->buildE2XMLHeader($this->service, $service_name, $sessId);
- $xpath = "//".$service_name;
- if (isset ($this->paymentType)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "PaymentType", $this->paymentType);
- }
- if (isset ($this->paymentDate)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "PaymentDate", $this->paymentDate);
- }
- if (isset ($this->collectInFuture)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "CollectInFuture", $this->collectInFuture);
- }
- if (isset ($this->amount)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Amount", $this->amount);
- }
- if (isset ($this->previousCardRef)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "PreviousCardRef", $this->previousCardRef);
- }
- if (isset ($this->cardType)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "CardType", $this->cardType);
- }
- if (isset ($this->cardNo)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "CardNo", $this->cardNo);
- }
- if (isset ($this->expires)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Expires", $this->expires);
- }
- if (isset($this->securityCode)){
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "SecurityCode", $this->securityCode);
- }
- if (isset ($this->charge)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Charge", $this->charge);
- }
- if (isset ($this->authOption)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "AuthOption", $this->authOption);
- }
- if (isset ($this->startDate)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "StartDate", $this->startDate);
- }
- if (isset ($this->issueNo)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "IssueNo", $this->issueNo);
- }
- if (isset ($this->threeDSecureStep)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "ThreeDSecureStep", $this->threeDSecureStep);
- }
- if (isset ($this->paResFile)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "PaResFile", $this->paResFile);
- }
- if (isset ($this->datacashReference)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "DatacashReference", $this->datacashReference);
- }
- /* Card holder information */
- if (isset ($this->cardHolder)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "CardHolder", "");
- $xpath = $xpath."/CardHolder";
- if (strlen($this->cardHolder->getTitle()) > 0) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Title", $this->cardHolder->getTitle());
- }
- if (strlen($this->cardHolder->getFirstname()) > 0) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Firstname", $this->cardHolder->getFirstname());
- }
- if (strlen($this->cardHolder->getLastname()) > 0) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Lastname", $this->cardHolder->getLastname());
- }
- if (strlen($this->cardHolder->getPostcode()) > 0) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Postcode", $this->cardHolder->getPostcode());
- }
- if (strlen($this->cardHolder->getAddressLine1()) > 0) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "AddressLine1", $this->cardHolder->getAddressLine1());
- }
- if (strlen($this->cardHolder->getAddressLine2()) > 0) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "AddressLine2", $this->cardHolder->getAddressLine2());
- }
- if (strlen($this->cardHolder->getArea()) > 0) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Area", $this->cardHolder->getArea());
- }
- if (strlen($this->cardHolder->getTown()) > 0) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Town", $this->cardHolder->getTown());
- }
- if (strlen($this->cardHolder->getCounty()) > 0) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "County", $this->cardHolder->getCounty());
- }
- if (strlen($this->cardHolder->getCountry()) > 0) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Country", $this->cardHolder->getCountry());
- }
- }
- return $xmldoc;
- }
- }
- class PPPayment extends AcceptPayment {
- /* Deal with e2 AcceptPayment for PayPal payment */
- var $email;
- var $server;
- var $authOption;
- var $payPalStep;
- var $merchantReference;
- var $datacashReference;
- function setEmail($newE) {
- $this->email = $newE;
- }
- function setServer($newS) {
- $this->server = $newS;
- }
- function setAuthOption($newA) {
- $this->authOption = $newA;
- }
- function setPayPalStep($newP) {
- $this->payPalStep = $newP;
- }
- function setMerchantReference($newM){
- $this->merchantReference = $newM;
- }
- function setDatacashReference($ref){
- $this->datacashReference = $ref;
- }
- function PPPayment($pType = "", $amnt = 0) {
- $this->service = "PaymentService";
- $this->action = "AcceptPayment";
- $this->paymentType = $pType;
- $this->amount = $amnt;
- }
- function accept($url, $sessId, $emulated = false) {
- $xmldoc = $this->buildRequestXMLDoc($sessId);
- $this->setUrl($url);
- $this->setReqXML($xmldoc->saveXML());
- //echo htmlentities($xmldoc->saveXML());
- if(!$emulated)
- {
- $resXml = $this->postXmlMessage();
- //echo htmlentities($resXml);
- $this->parseResponse($this->resXML);
- }
- }
- function buildRequestXMLDoc($sessId) {
- $service_name = $this->action;
- $xmldoc = $this->buildE2XMLHeader($this->service, $service_name, $sessId);
- $xpath = "//".$service_name;
- if (isset ($this->paymentType)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "PaymentType", $this->paymentType);
- }
- if (isset ($this->amount)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Amount", $this->amount);
- }
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "PayPal", "");
- $xpath = "//".$service_name."/PayPal";
- if (isset ($this->email)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Email", $this->email);
- }
- if (isset ($this->server)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Server", $this->server);
- }
- if (isset ($this->payPalStep)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "PayPalStep", $this->payPalStep);
- }
- if (isset ($this->authOption)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "AuthOption", $this->authOption);
- }
- if (isset($this->merchantReference)){
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "MerchantReference", $this->merchantReference);
- }
- if (isset ($this->datacashReference)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "DatacashReference", $this->datacashReference);
- }
- return $xmldoc;
- }
- }
- class CardHolder extends BasicE2XML {
- /* deal with e2 credit card info*/
- var $title;
- var $firstname;
- var $lastname;
- var $addressLine1;
- var $addressLine2;
- var $area;
- var $town;
- var $county;
- var $country;
- var $postcode;
- function setTitle($newT) {
- $this->title = $newT;
- }
- function setFirstname($newFN) {
- $this->firstname = $newFN;
- }
- function setLastname($newLN) {
- $this->lastName = $newLN;
- }
- function setAddressLine1($newA1) {
- $this->addressLine1 = $newA1;
- }
- function setAddressLine2($newA2) {
- $this->addressLine2 = $newA2;
- }
- function setArea($newA) {
- $this->area = $newA;
- }
- function setTown($newT) {
- $this->town = $newT;
- }
- function setCounty($newC) {
- $this->county = $newC;
- }
- function setCountry($newC) {
- $this->country = $newC;
- }
- function setPostcode($newP) {
- $this->postcode = $newP;
- }
- function getTitle() {
- return $this->title;
- }
- function getFirstname() {
- return $this->firstname;
- }
- function getLastname() {
- return $this->lastname;
- }
- function getAddressLine1() {
- return $this->addressLine1;
- }
- function getAddressLine2() {
- return $this->addressLine2;
- }
- function getArea() {
- return $this->area;
- }
- function getTown() {
- return $this->town;
- }
- function getCounty() {
- return $this->county;
- }
- function getCountry() {
- return $this->country;
- }
- function getPostcode() {
- return $this->postcode;
- }
- function CardHolder($newTitle = "", $newFirstname = "", $newLastname = "") {
- $this->title = $newTitle;
- $this->firstname = $newFirstname;
- $this->lastname = $newLastname;
- }
- }
- class RegisterClient extends BasicE2XML {
- /* Deal with e2 RegisterClient service*/
- /* Now this class is deprecated to use*/
- /* you suggested to use ClientService which is */
- /* more organised*/
- var $postcode;
- var $lastname;
- var $email;
- var $firstname;
- var $building;
- var $street;
- var $area;
- var $city;
- var $countryName;
- var $workPhone;
- var $responseArray;
- function setPostcode($newP) {
- $this->postcode = $newP;
- }
- function setLastname($newL) {
- $this->lastname = $newL;
- }
- function setEmail($newE) {
- $this->email = $newE;
- }
- function setFirstname($newF) {
- $this->firstname = $newF;
- }
- function setTitle($newT) {
- $this->title = $newT;
- }
- function setBuilding($newB) {
- $this->building = $newB;
- }
- function setStreet($newS) {
- $this->street = $newS;
- }
- function setArea($newA) {
- $this->area = $newA;
- }
- function setCity($newC) {
- $this->city = $newC;
- }
- function setCountryName($newC) {
- $this->countryName = $newC;
- }
- function setWorkPhone($newW) {
- $this->workPhone = $newW;
- }
- function getPostcode() {
- return $this->postcode;
- }
- function getLastname() {
- return $this->lastname;
- }
- function getEmail() {
- return $this->email;
- }
- function getFirstname() {
- return $this->firstname;
- }
- function getTitle() {
- return $this->title;
- }
- function getBuilding() {
- return $this->building;
- }
- function getStreet() {
- return $this->street;
- }
- function getArea() {
- return $this->area;
- }
- function getCity() {
- return $this->city;
- }
- function getCountryName() {
- return $this->countryName;
- }
- function getWorkPhone() {
- return $this->workPhone;
- }
- function getResponseArray() {
- return ($this->responseArray);
- }
- function RegisterClient($newPOCD = "", $newLNAM = "", $newEMAD = "") {
- /* constructor */
- $this->postcode = $newPOCD;
- $this->lastname = $newLNAM;
- $this->email = $newEMAD;
- }
- function register($url, $sessId) {
- $xmldoc = $this->buildRequestXMLDoc($sessId);
- $xpost = new XMLPosting();
- $xpost->setUrl($url);
- $xpost->setReqXML($xmldoc->saveXML());
- //echo htmlentities($xmldoc->saveXML());
- $resXml = $xpost->postXmlMessage();
- //echo htmlentities($resXml);
- $this->parseResponse($resXml);
- }
- function buildRequestXMLDoc($sessId) {
- /* build request xml for e2 CancelTransaction */
- $service_name = "RegisterClient";
- $xmldoc = $this->buildE2XMLHeader("ClientService", $service_name, $sessId);
- $xpath = "//".$service_name;
- /* add paxs */
- if (isset ($this->postcode)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Postcode", $this->postcode);
- }
- if (isset ($this->lastname)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Lastname", $this->lastname);
- }
- if (isset ($this->email)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Email", $this->email);
- }
- if (isset ($this->firstname)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Firstname", $this->firstname);
- }
- if (isset ($this->building)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Building", $this->building);
- }
- if (isset ($this->street)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Street", $this->street);
- }
- if (isset ($this->area)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Area", $this->area);
- }
- if (isset ($this->city)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "City", $this->city);
- }
- if (isset ($this->countryName)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "CountryName", $this->countryName);
- }
- if (isset ($this->workPhone)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "WorkPhone", $this->workPhone);
- }
- return $xmldoc;
- }
- function parseResponse($rx) {
- $doc = new DOMDocument('1.0', 'ISO-8859-1');
- if (!$doc->loadXML($rx)) {
- // it is done here to isolate e2 client library independant
- // of client website.
- $this->setErrorCode("Website-C0201");
- $this->setErrorType("fatal");
- $this->setErrorDesc("Error while parsing response xml document");
- return;
- }
- $root = $doc->firstChild;
- $this->parseNodeFault($root);
- if (strlen($this->getErrorCode()) > 0) {
- //$dom->free();
- return;
- }
- $xml2a = new xml2array($rx);
- $xa = $xml2a->getResult();
- if (is_array($xa['ClientService']["$service_name"])) {
- $this->responseArray = $xa['ClientService']["$service_name"];
- }
- //$dom->free();
- }
- }
- class AssignClient extends E2Interface {
- /* Deal with e2 AssignClient service*/
- var $clientCode;
- function setClientCode($newCD) {
- $this->clientCode = $newCD;
- }
- function getClientCode() {
- return $this->clientCode;
- }
- function AssignClient($newCD = "") {
- /* constructor */
- $this->service = "ReservationService";
- $this->action = "AssignClient";
- $this->clientCode = $newCD;
- }
- function assign($url, $sessId) {
- $xmldoc = $this->buildRequestXMLDoc($sessId);
- $this->setUrl($url);
- $this->setReqXML($xmldoc->saveXML());
- //echo htmlentities($xmldoc->saveXML());
- $resXml = $this->postXmlMessage();
- //echo htmlentities($resXml);
- $this->parseResponse($this->resXML);
- }
- function buildRequestXMLDoc($sessId) {
- /* build request xml for e2 CancelTransaction */
- $service_name = $this->action;
- $xmldoc = $this->buildE2XMLHeader($this->service, $service_name, $sessId);
- $xpath = "//".$service_name;
- /* assign client */
- if (isset ($this->clientCode)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "ClientCode", $this->clientCode);
- }
- return $xmldoc;
- }
- }
- class UpdateStatus extends E2Interface {
- /* Deal with e2 UpdateStatus service */
- var $newStatus;
- var $checkOnly; // flag for checking
- var $optionTaken; // option taken
- var $optionUntil; // option until
- var $optionUntilTime; // option until time
- function setNewStatus($newS) {
- $this->newStatus = $newS;
- }
- function setCheckOnly($newC) {
- $this->checkOnly = $newC;
- }
- function setOptionTaken($newOT){
- $this->optionTaken = $newOT;
- }
- function setOptionUntil ($newOU) {
- $this->optionUntil = $newOU;
- }
- function setOptionUntilTime($newTime){
- $this->optionUntilTime = $newTime;
- }
- function getNewStatus() {
- return $this->newStatus;
- }
- function getCheckOnly() {
- return $this->checkOnly;
- }
- function UpdateStatus($newS = "", $newCK = "") {
- /* constructor */
- $this->service = "ReservationService";
- $this->action = "UpdateStatus";
- $this->newStatus = $newS;
- $this->checkOnly = $newCK;
- }
- function update($url, $sessId) {
- $xmldoc = $this->buildRequestXMLDoc($sessId);
- $this->setUrl($url);
- $this->setReqXML($xmldoc->saveXML());
- //echo htmlentities($xmldoc->saveXML());
- $resXml = $this->postXmlMessage();
- //echo htmlentities($resXml);
- $this->parseResponse($this->resXML);
- }
- function buildRequestXMLDoc($sessId) {
- /* build request xml for e2 CancelTransaction */
- $service_name = $this->action;
- $xmldoc = $this->buildE2XMLHeader($this->service, $service_name, $sessId);
- $xpath = "//".$service_name;
- if (isset ($this->newStatus)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "NewStatus", $this->newStatus);
- }
- if (isset ($this->optionTaken) && strlen($this->optionTaken) > 0) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "OptionTaken", $this->optionTaken);
- }
- if (isset ($this->optionUntil) && strlen($this->optionUntil) > 0) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "OptionUntil", $this->optionUntil);
- }
- if (isset($this->optionUntilTime) && strlen($this->optionUntilTime) > 0){
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "OptionUntilTime", $this->optionUntilTime);
- }
- if (isset ($this->checkOnly) && strlen($this->checkOnly) > 0) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "CheckOnly", "");
- }
- return $xmldoc;
- }
- }
- class RecalcBooking extends E2Interface {
- /* Deal with e2 RecalcBooking service */
- var $BookingNumber;
- function setBookingNUmber($newBN) {
- $this->bookingNumber = $newBN;
- }
- function RecalcBooking($url, $sessId, $newBN = "") {
- /* constructor */
- $this->service = "ReservationService";
- $this->action = "RecalcBooking";
- $this->url = $url;
- $this->sessionId = $sessId;
- $this->bookingNumber = $newBN;
- }
- function recalc() {
- $xmldoc = $this->buildRequestXMLDoc();
- $this->setReqXML($xmldoc->saveXML());
- //echo htmlentities($xmldoc->saveXML());
- $resXml = $this->postXmlMessage();
- //echo htmlentities($resXml);
- $this->parseResponse($resXml);
- return $this->responseArray;
- }
- function buildRequestXMLDoc() {
- $xmldoc = $this->buildE2XMLHeader();
- $xpath = "//".$this->action;
- // postcode to find address
- if (isset ($this->bookingNumber)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "BookingNumber", $this->BookingNumber);
- }
- return $xmldoc;
- }
- }
- class AddNote extends E2Interface {
- /* Deal with e2 AddNote*/
- /* it is dealt with multiple pax*/
- var $noteArray; // store array notes
- function setNoteArray($newPA) {
- $this->noteArray = $newPA;
- }
- function getNoteArray() {
- return $this->noteArray;
- }
- function AddNote($newNA = "") {
- /* constructor */
- $this->service = "ReservationService";
- $this->action = "AddNote";
- $this->noteArray = $newNA;
- }
- function add($url, $sessId) {
- $xmldoc = $this->buildRequestXMLDoc($sessId);
- $this->setUrl($url);
- $this->setReqXML($xmldoc->saveXML());
- //echo htmlentities($xmldoc->saveXML());
- $resXml = $this->postXmlMessage();
- //echo htmlentities($resXml);
- $this->parseResponse($this->resXML);
- }
- function buildRequestXMLDoc($sessId) {
- /* build request xml for e2 CancelTransaction */
- $service_name = $this->action;
- $xmldoc = $this->buildE2XMLHeader($this->service, $service_name, $sessId);
- $xpath = "//".$service_name;
- /* add paxs */
- if (is_array($this->noteArray)) {
- foreach ($this->noteArray as $note) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Notes", "");
- if (isset ($note["Type"])) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Notes", "Type", $note["Type"]);
- }
- if (isset ($note["TransactionNumber"])) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Notes", "TransactionNumber", $note["TransactionNumber"]);
- }
- if (isset ($note["SupplementNumber"])) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Notes", "SupplementNumber", $note["SupplementNumber"]);
- }
- if (isset ($note["Note"])) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Notes", "Note", $note["Note"]);
- }
- if (isset ($note["Auto"])) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Notes", "Auto", $note["Auto"]);
- }
- if (isset ($note["PrecodedNote"])) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Notes", "PrecodedNote", $note["PrecodedNote"]);
- }
- if (isset ($note["TellClient"])) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Notes", "TellClient", "Y");
- }
- if (isset ($note["TellSupplier"])) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Notes", "TellSupplier", "Y");
- }
- }
- }
- return $xmldoc;
- }
- }
- class RequestInvoice extends E2Interface {
- /* Deal with e2 RequestInvoice*/
- var $queue; // invoice queue
- var $bookingCode; // booking code (human readable)
- var $email; // email address to send invoice to
- function setQueue($newQ) {
- $this->queue = $newQ;
- }
- function setBookingCode($newBCODE) {
- $this->bookingCode = $newBCODE;
- }
- function setEmail($newEmail) {
- $this->email = $newEmail;
- }
- function getNoteArray() {
- return $this->invoiceType;
- }
- function RequestInvoice($newQ = "") {
- /* constructor */
- $this->service = "PaymentService";
- $this->action = "RequestInvoice";
- $this->queue = $newQ;
- }
- function invoice($url, $sessId) {
- $xmldoc = $this->buildRequestXMLDoc($sessId);
- $this->setUrl($url);
- $this->setReqXML($xmldoc->saveXML());
- //echo htmlentities($xmldoc->saveXML());
- $resXml = $this->postXmlMessage();
- //echo htmlentities($resXml);
- $this->parseResponse($this->resXML);
- }
- function buildRequestXMLDoc($sessId) {
- /* build request xml for e2 CancelTransaction */
- $service_name = $this->action;
- $xmldoc = $this->buildE2XMLHeader($this->service, $service_name, $sessId);
- $xpath = "//".$service_name;
- if (isset ($this->queue)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Queue", $this->queue);
- }
- if (isset ($this->bookingCode)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "BookingCode", $this->bookingCode);
- }
- if (isset ($this->email)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Email", $this->email);
- }
- return $xmldoc;
- }
- }
- class RequestDummyInvoice extends E2Interface {
- /* Deal with e2 RequestInvoice*/
- var $bookingCode; // booking code (human readable)
- function setBookingCode($newBCODE) {
- $this->bookingCode = $newBCODE;
- }
- function RequestDummyInvoice() {
- /* constructor */
- $this->service = "PaymentService";
- $this->action = "RequestDummyInvoice";
- }
- function invoice($url, $sessId) {
- $xmldoc = $this->buildRequestXMLDoc($sessId);
- $this->setUrl($url);
- $this->setReqXML($xmldoc->saveXML());
- //echo htmlentities($xmldoc->saveXML());
- $resXml = $this->postXmlMessage();
- //echo htmlentities($resXml);
- $this->parseResponse($this->resXML);
- }
- function buildRequestXMLDoc($sessId) {
- /* build request xml for e2 CancelTransaction */
- $service_name = $this->action;
- $xmldoc = $this->buildE2XMLHeader($this->service, $service_name, $sessId);
- $xpath = "//".$service_name;
- if (isset ($this->bookingCode)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "BookingCode", $this->bookingCode);
- }
- return $xmldoc;
- }
- }
- class DataService extends E2Interface {
- /* Deal with e2 Data service*/
- // product type, TOR, VIS, ACC etc.
- var $productType;
- // Transport code
- var $transportCode;
- // accommmodation code
- var $accommodationCode;
- // component code
- var $componentCode;
- // 270208 added by Sunny: Package code for GetPackages
- var $packageCode;
- // 271108 added by Sunny: Property code for GetProperties
- var $propertyCode;
- // code from
- var $codeFrom;
- // code to
- var $codeTo;
- // Live flag
- var $liveOnly;
- // Item detail flag
- var $item;
- // detail detail flag
- var $detail;
- // trans detail flag for Transport
- var $trans;
- // response array of the service
- var $responseArray;
- // detail level array
- var $detailLevel;
- // 120508 added by Sarah: Misc Fields
- var $miscFields;
- // 120508 added by Sarah: Code
- var $code;
- /* constructor */
- function DataService($newAction, $newProductType, $url, $sessId) {
- $this->service = "DataService";
- $this->action = $newAction;
- $this->productType = $newProductType;
- $this->url = $url;
- $this->sessionId = $sessId;
- }
- // set product type
- function setProductType($newProductType) {
- $this->productType = $newProductType;
- }
- // set transaction code
- function setTransportCode($newTransCode) {
- $this->transportCode = $newTransCode;
- }
- // set component code
- function setComponentCode($newComponentCode) {
- $this->componentCode = $newComponentCode;
- }
- // 270208 added by Sunny: set package code for GetPackages
- function setPackageCode($newPackageCode) {
- $this->packageCode = $newPackageCode;
- }
- // 271108 added by Sunny: set property code for GetProperties
- function setPropertyCode($newPropertyCode) {
- $this->propertyCode = $newPropertyCode;
- }
- // set accommodation code
- function setAccommodationCode($newAccCode){
- $this->accommodationCode = $newAccCode;
- }
- //set code from for find
- function setCodeFrom($newCode) {
- $this->codeFrom = $newCode;
- }
- // set code to for find
- function setCodeTo($newCode) {
- $this->codeTo = $newCode;
- }
- // set live only flag
- function setLiveOnly($newFlag) {
- $this->liveOnly = $newFlag;
- }
- // set item detail flag
- function setItem($newFlag) {
- $this->item = $newFlag;
- }
- // set Detail of detail flag
- function setDetail($newFlag) {
- $this->detail = $newFlag;
- }
- // set Detail of detail flag
- function setDetailLevel($newDtl) {
- $this->detailLevel = $newDtl;
- }
- // set Trans of detail flag
- function setTrans($newFlag) {
- $this->trans = $newFlag;
- }
- // 120508 added by Sarah: set Misc fields
- function setMiscFields($newMiscFields) {
- $this->miscFields = $newMiscFields;
- }
- // 120508 added by Sarah: set Code
- function setCode($newCode) {
- $this->code = $newCode;
- }
- function setResponseArray($newRA) {
- $this->responseArray = $newRA;
- }
- function getResponseArray() {
- return $this->responseArray;
- }
- // return data
- function getData($newResType="array") {
- $xmldoc = $this->buildRequestXMLDoc();
- $this->setReqXML($xmldoc->saveXML());
- //echo htmlentities($xmldoc->saveXML());
- $resXml = $this->postXmlMessage();
- //echo htmlentities($resXml);
- if (strlen($this->getErrorCode()) > 0) {
- return;
- }
- if ($newResType == 'array'){
- $this->responseArray = $this->parseResponse($resXml);
- return $this->responseArray;
- }else{
- return $resXml;
- }
- }
- function buildRequestXMLDoc() {
- /* build request xml for e2 CancelTransaction */
- $xmldoc = $this->buildE2XMLHeader();
- $xpath = "//".$this->action;
- // add product type node
- if (isset ($this->productType)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Type", $this->productType);
- }
- // add ComponentCode node in request
- if (isset ($this->componentCode)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "ComponentCode", $this->componentCode);
- }
- // 270208 added by Sunny: add PackageCode node in request
- if (isset ($this->packageCode)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "PackageCode", $this->packageCode);
- }
- // 280208 added by Sunny: add PropertyCode node in request
- if (isset ($this->propertyCode)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "PropertyCode", $this->propertyCode);
- }
- // add accommodation code
- if (isset($this->accommodationCode)){
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "AccommodationCode", $this->accommodationCode);
- }
- // add TransportCode node
- if (isset ($this->transportCode)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "TransportCode", $this->transportCode);
- }
- // 120508 added by Sarah: add Misc Fields node
- if (isset ($this->miscFields)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "MiscFields", $this->miscFields);
- }
- // 120508 added by Sarah: add Room Type Code node
- if (isset ($this->code)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Code", $this->code);
- }
- // find
- if (isset($this->codeFrom) || isset($this->codeTo)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Find", "");
- if (isset($this->codeFrom)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Find", "CodeFrom", $this->codeFrom);
- }
- if (isset($this->codeTo)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Find", "CodeTo", $this->codeTo);
- }
- }
- // add detail level node
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "DetailLevel", "");
- // add LiveOnly flag
- if (isset ($this->liveOnly)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "LiveOnly", (!$this->liveOnly) ? "false" :
- "true");
- }
- // add Itemdetail flag
- if (isset ($this->item)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/DetailLevel", "Item", "");
- }
- // add Detail flag
- if (isset ($this->detail)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/DetailLevel", "Detail", "");
- }
- // add trans flag for transport
- if (isset ($this->trans)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/DetailLevel", "Trans", "");
- }
- /* for detail information*/
- for ($index = 0; $index < sizeof($this->detailLevel) && isset ($this->detailLevel[$index]); $index ++) {
- $detailFlag = $this->detailLevel[$index];
- $xmldoc = $detailFlag->buildRequestXMLDoc($xmldoc, $xpath."/DetailLevel");
- }
- return $xmldoc;
- }
- }
- class ClientService extends E2Interface {
- /* Deal with e2 Client service*/
- /* obsolate to use RegisterClient from RegsiterClient Class*/
- var $code;
- var $postcode;
- var $title;
- var $lastname;
- var $email;
- var $firstname;
- var $building;
- var $street;
- var $area;
- var $city;
- var $countryName;
- var $countryCode;
- var $workPhone;
- var $homePhone;
- var $mobilePhone;
- // agent code
- var $agentCode;
- // agent Internet password (CL.IPWD)
- var $password;
- // private client password (CL.IPWD)
- var $internetPassword;
- // exlcude bulk email
- var $excludeBulkEmail;
- // exlcude mail
- var $excludeMail;
- // 220108 added by Sunny: user defined fields
- var $userDef;
- // comment 1
- var $comments1;
- // date of birth
- var $birthDate;
- // flag to remember credit card info for further use
- var $rememberCard;
- // private client validation booking number
- var $bookingNumber;
- // private client validation booking departure date
- var $departureDate;
- // flag to get client's password in email
- var $getPassword;
- // template to be used for forget password email
- var $template;
- // 221008 added by Sunny: Flag to regenerate password
- var $regenPass;
- //client source
- var $source;
- // whether the passsword validation should be case sensitive
- var $isPassCaseSensitive;
- // whether the client details can be cleared when updating
- var $isAgentOnly;
- var $isPrivateOnly;
- var $isInternetOnly;
- var $responseArray;
- function setPostcode($newP) {
- $this->postcode = $newP;
- }
- function setCode($newC) {
- $this->code = $newC;
- }
- function setLastname($newL) {
- $this->lastname = $newL;
- }
- function setEmail($newE) {
- $this->email = $newE;
- }
- function setFirstname($newF) {
- $this->firstname = $newF;
- }
- function setTitle($newT) {
- $this->title = $newT;
- }
- function setBuilding($newB) {
- $this->building = $newB;
- }
- function setStreet($newS) {
- $this->street = $newS;
- }
- function setArea($newA) {
- $this->area = $newA;
- }
- function setCity($newC) {
- $this->city = $newC;
- }
- function setCountryName($newC) {
- $this->countryName = $newC;
- }
- function setCountryCode($newC) {
- $this->countryCode = $newC;
- }
- function setWorkPhone($newW) {
- $this->workPhone = $newW;
- }
- function setHomePhone($newHP){
- $this->homePhone = $newHP;
- }
- function setMobilePhone($newMP){
- $this->mobilePhone = $newMP;
- }
- function setAgentCode($newAGCD) {
- $this->agentCode = $newAGCD;
- }
- function setPassword($newPassword) {
- $this->password = $newPassword;
- }
- function setInternetPassword($newPassword) {
- $this->internetPassword = $newPassword;
- }
- function setExcludeMail($newExcludeMail){
- $this->excludeMail = $newExcludeMail;
- }
- function setExcludeBulkEmail($newEM) {
- $this->excludeBulkEmail = $newEM;
- }
- function setComments1($newC1) {
- $this->comments1 = $newC1;
- }
- function setBirthDate($new_date){
- $this->birthDate = $new_date;
- }
- function setRememberCard($newFlag = 'false'){
- $this->rememberCard = $newFlag;
- }
- function setBookingNumber($newBcod) {
- $this->bookingNumber = $newBcod;
- }
- function setDepartureDate($newDdep) {
- $this->departureDate = $newDdep;
- }
- function setSendMePass($newFlag="false") {
- $this->sendMePass = $newFlag;
- }
- // 221008 added by Sunny: Flag to regenerate password
- function setRegenPass($newFlag="false") {
- $this->regenPass = $newFlag;
- }
- // 050208 added by Sunny: The flag to match one and only client record
- function setUniqueMatchOnly($newFlag="false") {
- $this->uniqueMatchOnly = $newFlag;
- }
- function setSource($newVal) {
- $this->source = $newVal;
- }
- function setTemplate($newTmpl){
- $this->template = $newTmpl;
- }
- // 220108 added by Sunny: Set the user defined fields
- function setUserDef($keyValuePairs) {
- $this->userDef = $keyValuePairs;
- }
- // 070808 added by Sunny: Whether the client details can be cleared when updating
- function setCanClear($newCanClear) {
- $this->canClear = $newCanClear;
- }
- function setIsPassCaseSensitive($newP) {
- $this->isPassCaseSensitive = $newP;
- }
- function setIsAgentOnly($newA) {
- $this->isAgentOnly = $newA;
- }
- function setIsPrivateOnly($newP) {
- $this->isPrivateOnly = $newP;
- }
- function setIsInternetOnly($newI) {
- $this->isInternetOnly = $newI;
- }
- function getPostcode() {
- return $this->postcode;
- }
- function getLastname() {
- return $this->lastname;
- }
- function getEmail() {
- return $this->email;
- }
- function getFirstname() {
- return $this->firstname;
- }
- function getTitle() {
- return $this->title;
- }
- function getBuilding() {
- return $this->building;
- }
- function getStreet() {
- return $this->street;
- }
- function getArea() {
- return $this->area;
- }
- function getCity() {
- return $this->city;
- }
- function getCountryName() {
- return $this->countryName;
- }
- function getWorkPhone() {
- return $this->workPhone;
- }
- function getBirthDate(){
- return $this->birthDate;
- }
- function getRememberCard(){
- return $this->rememberCard;
- }
- function getResponseArray() {
- return ($this->responseArray);
- }
- function ClientService($newAction, $newURL, $newSessId) {
- /* constructor */
- $this->service = "ClientService";
- $this->action = $newAction;
- $this->url = $newURL;
- $this->sessionId = $newSessId;
- }
- function getClientInfo() {
- $xmldoc = $this->buildRequestXMLDoc();
- $this->setReqXML($xmldoc->saveXML());
- //echo htmlentities($xmldoc->saveXML());
- $resXml = $this->postXmlMessage();
- //echo htmlentities($resXml);
- if (strlen($this->getErrorCode()) > 0) {
- return;
- }
- $this->responseArray = $this->parseResponse($resXml);
- return $this->responseArray;
- }
- function buildRequestXMLDoc() {
- /* build request xml for e2 CancelTransaction */
- $xmldoc = $this->buildE2XMLHeader();
- $xpath = "//".$this->action;
- /* add paxs */
- if (isset ($this->postcode)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Postcode", $this->postcode);
- }
- if (isset ($this->code)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Code", $this->code);
- }
- if (isset ($this->title)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Title", $this->title);
- }
- if (isset ($this->lastname)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Lastname", $this->lastname);
- }
- if (isset ($this->email)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Email", $this->email);
- }
- if (isset ($this->firstname)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Firstname", $this->firstname);
- }
- if (isset ($this->building)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Building", $this->building);
- if ($this->building == "" && isset ($this->canClear) && $this->canClear) {
- $xmldoc = $this->setXNodeAttribute($xmldoc, $xpath."/Building", "Null", "true");
- }
- }
- if (isset ($this->street)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Street", $this->street);
- if ($this->street == "" && isset ($this->canClear) && $this->canClear) {
- $xmldoc = $this->setXNodeAttribute($xmldoc, $xpath."/Street", "Null", "true");
- }
- }
- if (isset ($this->area)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Area", $this->area);
- if ($this->area == "" && isset ($this->canClear) && $this->canClear) {
- $xmldoc = $this->setXNodeAttribute($xmldoc, $xpath."/Area", "Null", "true");
- }
- }
- if (isset ($this->city)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "City", $this->city);
- if ($this->city == "" && isset ($this->canClear) && $this->canClear) {
- $xmldoc = $this->setXNodeAttribute($xmldoc, $xpath."/City", "Null", "true");
- }
- }
- if (isset ($this->countryName)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "CountryName", $this->countryName);
- }
- if (isset ($this->countryCode)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "CountryCode", $this->countryCode);
- }
- if (isset ($this->workPhone)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "WorkPhone", $this->workPhone);
- }
- if (isset($this->homePhone)){
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "HomePhone", $this->homePhone);
- }
- if (isset($this->mobilePhone)){
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Phone3", $this->mobilePhone);
- }
- // set agent code
- if (isset ($this->agentCode)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "AgentCode", $this->agentCode);
- }
- // set password in the request
- if (isset ($this->password)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Password", $this->password);
- }
- // set Internet password(for private client) in the request
- if (isset ($this->internetPassword)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "InternetPassword", $this->internetPassword);
- }
- // set excludeEmail in the request
- if (isset ($this->excludeMail)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "ExcludeMail", $this->excludeMail);
- }
- // set excludeEmail in the request
- if (isset ($this->excludeBulkEmail)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "ExcludeBulkEmail", $this->excludeBulkEmail);
- }
- // set comments1 in the request
- if (isset ($this->comments1)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Comments1", $this->comments1);
- }
- if (isset ($this->birthDate)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "BirthDate", $this->birthDate);
- }
- if (isset ($this->rememberCard)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "RememberCard", $this->rememberCard);
- }
- // set Booking number for client validation
- if (isset ($this->bookingNumber)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "BookingNumber", $this->bookingNumber);
- }
- // set Booking departure for client validation
- if (isset ($this->departureDate)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "DepartureDate", $this->departureDate);
- }
- // set flag to get client's password
- if (isset ($this->sendMePass)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "SendMePass", $this->sendMePass);
- }
- // 221008 added by Sunny: Set flag to regenerate password
- if (isset ($this->regenPass)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "RegeneratePassword", $this->regenPass);
- }
- // 050208 added by Sunny: Set flag to match one and only client record
- if (isset ($this->uniqueMatchOnly)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "UniqueMatchOnly", $this->uniqueMatchOnly);
- }
- //template to be used for the password recovery email
- if (isset ($this->template)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Template", $this->template);
- }
- // set client source
- if (isset ($this->source)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Source", $this->source);
- }
- // 220108 added by Sunny: set the user defined fields
- if (isset($this->userDef)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "UDF", "");
- $userDefKeys = array_keys($this->userDef);
- for ($i = 0; $i < count($userDefKeys); $i++) {
- $key = $userDefKeys[$i];
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/UDF", "Index", $key);
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/UDF", "Value", $this->userDef[$key]);
- }
- }
- if (isset ($this->isPassCaseSensitive)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "IsPassCaseSensitive", ($this->isPassCaseSensitive ? "true" : "false"));
- }
- if (isset ($this->isAgentOnly)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "AgentOnly", ($this->isAgentOnly ? "true" : "false"));
- }
- if (isset ($this->isPrivateOnly)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "PrivateOnly", ($this->isPrivateOnly ? "true" : "false"));
- }
- if (isset ($this->isInternetOnly)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "InternetOnly", ($this->isInternetOnly ? "true" : "false"));
- }
- return $xmldoc;
- }
- }
- class SupplierService extends E2Interface {
- /* Deal with e2 Supplier service*/
- /* 140208 Added by Sunny */
- var $code;
- var $responseArray;
- function setCode($newC) {
- $this->code = $newC;
- }
- function getResponseArray() {
- return ($this->responseArray);
- }
- function SupplierService($newAction, $newURL, $newSessId) {
- /* constructor */
- $this->service = "SupplierService";
- $this->action = $newAction;
- $this->url = $newURL;
- $this->sessionId = $newSessId;
- }
- function getSupplierInfo() {
- $xmldoc = $this->buildRequestXMLDoc();
- $this->setReqXML($xmldoc->saveXML());
- //echo htmlentities($xmldoc->saveXML());
- $resXml = $this->postXmlMessage();
- //echo htmlentities($resXml);
- if (strlen($this->getErrorCode()) > 0) {
- return;
- }
- $this->responseArray = $this->parseResponse($resXml);
- return $this->responseArray;
- }
- function buildRequestXMLDoc() {
- /* build request xml for e2 FindSupplier */
- $xmldoc = $this->buildE2XMLHeader();
- $xpath = "//".$this->action;
- if (isset ($this->code)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Code", $this->code);
- }
- return $xmldoc;
- }
- }
- class BookingDetail extends e2Interface {
- /* Deal with e2 BookingDetail*/
- /* Booking info is obsolate to use*/
- var $bookingNumber; // human readable booking number
- var $leadname; // Booking lead name
- var $departureDate; // departure date
- var $departFrom; // departure date from
- var $departTo; // departure date to
- var $customerCode; // customer code
- var $agentNumber; // agent number
- var $bookingStatList; // allowed booking status for find booking
- var $bookingSummary; // flag for booking summary details
- var $transactions; // flag for transaction details
- var $pax; // flag for passenger details
- var $notes; // flag for booking notes details
- var $docs; // flag for booking docs details
- var $toggleOrder; // flag for toggle itinerary order
- var $showCanx; // flag for showing cancelled lines
- var $lines; // flag for line detail of a line
- var $ShortDesc; // flag for shortdesc only in line header of a line
- var $finance; // flag for finance information
- var $lastInvoice; // flag for last invoice only
- var $info; // info array
- var $responseArray; // responseArray
- var $params;
- var $userOnly; // flag for user only notification email
- var $detailLevel = array(); // for detail level flag
- var $error; // error code for user only notification email
- // booking notify
- var $emailTemplate;
- var $emailSender;
- var $emailTo;
- var $emailCc;
- var $emailBcc;
- var $emailSubject;
- var $emailMsg;
- var $emailNoMerge;
- var $emailUserRef;
- function addAllDetailLevel($dtl_array){
- if (!is_array($dtl_array)) {return;}
- foreach ($dtl_array as $dtl_item){
- array_push($this->detailLevel, $dtl_item);
- }
- }
- function addDetailLevel($flag, $value){
- if (strlen($flag)){
- $dtlLevel = new AvailDetails($flag, $value);
- array_push($this->detailLevel, $dtlLevel);
- }
- }
- function setUserOnly($newUO) {
- $this->userOnly = $newUO;
- }
- function setError($newE) {
- $this->error = $newE;
- }
- function setParams($newParams) {
- $this->params = $newParams;
- }
- function setBookingNumber($newB) {
- $this->bookingNumber = $newB;
- }
- // set lead name
- function setLeadname($newLeadname) {
- $this->leadname = $newLeadname;
- }
- function setDepartureDate($newDEPDT) {
- $this->departureDate = $newDEPDT;
- }
- function setDepartureFrom($newDEPFR) {
- $this->departureFrom = $newDEPFR;
- }
- function setDepartureTo($newDEPTO) {
- $this->departureTo = $newDEPTO;
- }
- function setAgentNumber($newAGTCD) {
- $this->agentNumber = $newAGTCD;
- }
- function setCustomerCode($newCLCD) {
- $this->customerCode = $newCLCD;
- }
- function setBookingStatusList($newStatLs) {
- $this->bookingStatusList = $newStatLs;
- }
- function setBookingSummary($newBS = "") {
- $this->addDetailLevel("BookingSummary", $newBS);
- }
- function setTransactions($newT = "") {
- $this->addDetailLevel("Transactions", $newT);
- }
- function setPax($newP = "") {
- $this->addDetailLevel("Pax", $newP);
- }
- function setNotes($newN = "") {
- $this->addDetailLevel("Notes", $newN);
- }
- function setDocs($newD = "") {
- $this->addDetailLevel("Docs", $newD);
- }
- function setLatestDocs($newD = "") {
- $this->addDetailLevel("LatestDocs", $newD);
- }
- function setToggleOrder($newTG = "") {
- $this->addDetailLevel("ToggleOrder", $newTG);
- }
- function setShowCanx($newSC = "") {
- $this->addDetailLevel("ShowCanx", $newSC);
- }
- function setLines($newP = "Y") {
- $this->addDetailLevel("Lines", $newP);
- }
- function setShortDesc($newSD = "Y") {
- $this->addDetailLevel("ShortDesc", $newSD);
- }
- function setFinance($newSD = "Y") {
- $this->addDetailLevel("Finance", $newSD);
- }
- function setLastInvoice($newSD = "Y") {
- $this->addDetailLevel("LastInvoice", $newSD);
- }
- function setInfo($newI) {
- $this->addDetailLevel("Info", $newI);
- }
- function setEmailSender($sndr){
- $this->emailSender = $sndr;
- }
- function setEmailTo($to){
- $this->emailTo = $to;
- }
- function setEmailCc($cc){
- $this->emailCc = $cc;
- }
- function setEmailBcc($bcc){
- $this->emailBcc = $bcc;
- }
- function setEmailSubject($subject){
- $this->emailSubject = $subject;
- }
- function setEmailTemplate($template){
- $this->emailTemplate = $template;
- }
- function setEmailMsg($msg){
- $this->emailMsg = $msg;
- }
- function setEmailNoMerge($no_merge){
- $this->emailNoMerge = $no_merge;
- }
- function setEmailUserRef($userRef) {
- $this->emailUserRef = $userRef;
- }
- function getBookingNumber() {
- return $this->bookingNumber;
- }
- function getBookingSummary() {
- return $this->bookingSummary;
- }
- function getTransactions() {
- return $this->transaction;
- }
- function getPax() {
- return $this->pax;
- }
- function getNotes() {
- return $this->notes;
- }
- function getDocs() {
- return $this->docs;
- }
- function getToggleOrder() {
- return $this->toggleOrder;
- }
- function getShowCanx() {
- return $this->showCanx;
- }
- function getInfo() {
- return $this->info;
- }
- function getResponseArray() {
- return ($this->responseArray);
- }
- function BookingDetail($newAction, $newURL, $newSessId, $newBookingNumber = "") {
- /* constructor */
- $this->service = "ReservationService";
- $this->action = $newAction;
- $this->url = $newURL;
- $this->sessionId = $newSessId;
- $this->bookingNumber = $newBookingNumber;
- }
- function findInfo() {
- $xmldoc = $this->buildRequestXMLDoc();
- $this->setReqXML($xmldoc->saveXML());
- //echo htmlentities($xmldoc->saveXML());
- $resXml = $this->postXmlMessage();
- //echo htmlentities($resXml);
- if (strlen($this->getErrorCode()) > 0) {
- return;
- }
- $this->responseArray = $this->parseResponse($resXml);
- return $this->responseArray;
- }
- function buildRequestXMLDoc() {
- /* build request xml for e2 BookingDetails*/
- $xmldoc = $this->buildE2XMLHeader();
- $xpath = "//".$this->action;
- if (isset ($this->bookingNumber)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "BookingNumber", $this->bookingNumber);
- }
- if (isset ($this->leadname)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Leadname", $this->leadname);
- }
- if (isset ($this->departureDate)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "DepartureDate", $this->departureDate);
- }
- if (isset ($this->departureFrom)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "DepartFrom", $this->departureFrom);
- }
- if (isset ($this->departureTo)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "DepartTo", $this->departureTo);
- }
- if (isset ($this->customerCode)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "CustomerCode", $this->customerCode);
- }
- if (isset ($this->agentNumber)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "AgentNumber", $this->agentNumber);
- }
- if (isset ($this->bookingStatusList)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "BookingStatusList", $this->bookingStatusList);
- }
- // detail level only for BookingInfo action
- if ($this->action == "BookingInfo") {
- /* for detail information*/
- for ($index = 0; $index < sizeof($this->detailLevel) && isset ($this->detailLevel[$index]); $index ++) {
- $detailFlag = $this->detailLevel[$index];
- if ($index == 0) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "DetailLevel", "");
- }
- $xmldoc = $detailFlag->buildRequestXMLDoc($xmldoc, $xpath."/DetailLevel");
- }
- }
- if ($this->action == "BookingNotify") {
- if (isset ($this->error) && strlen($this->error)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Error", $this->error);
- }
- if (isset($this->emailSender)){
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Sender", $this->emailSender);
- }
- if (isset($this->emailBcc)){
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Bcc", $this->emailBcc);
- }
- if (isset($this->emailCc)){
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Cc", $this->emailCc);
- }
- if (isset($this->emailTo)){
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "To", $this->emailTo);
- }
- if (isset($this->emailTemplate)){
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Template", $this->emailTemplate);
- }
- if (isset($this->emailSubject)){
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Subject", $this->emailSubject);
- }
- if (isset($this->emailMsg)){
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Message", $this->emailMsg);
- }
- if (isset($this->emailNoMerge) && $this->emailNoMerge){
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "NoMerge", '');
- }
- if (isset($this->emailUserRef) && $this->emailUserRef){
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "UserReference", $this->emailUserRef);
- }
- }
- // detail level only for BookingInfo action
- if ($this->action == "BookingParams") {
- for ($i = 0; $i < count($this->params); $i ++) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Param", "");
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Param", "Action", $this->params[$i]->getAction());
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Param", "Name", $this->params[$i]->getName());
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Param", "Value", $this->params[$i]->getValue());
- }
- }
- return $xmldoc;
- }
- }
- class BasicDataService extends E2Interface {
- /* Deal with e2 Data service*/
- /* Modified by Yayun Sun to have a desciption field and to set LiveOnly properly */
- // postcode to find address
- var $postcode;
- // type to find code
- var $type;
- // code to find code
- var $code;
- // miscelinious Fields to find code
- var $miscFields;
- // description field to find code
- var $desc;
- // Live flag
- var $liveOnly;
- //Available on the Internet flag
- var $internetOnly;
- // response array of the service
- var $responseArray;
- // set postcode
- function setPostcode($newPOCD) {
- $this->postcode = $newPOCD;
- }
- // set type
- function setType($newT) {
- $this->type = $newT;
- }
- // set code
- function setCode($newC) {
- $this->code = $newC;
- }
- // set description
- function setDesc($newD) {
- $this->setDesc = $newD;
- }
- // set misc fields for DC
- function setMiscFields($newM) {
- $this->miscFields = $newM;
- }
- //set live only flag
- function setLiveOnly($newFlag) {
- $this->liveOnly = $newFlag;
- }
- // Set available on the Internet
- function setInternetOnly($newFlag){
- $this->internetOnly = $newFlag;
- }
- function setResponseArray($newRA) {
- $this->responseArray = $newRA;
- }
- function getResponseArray() {
- return $this->responseArray;
- }
- function BasicDataService($newAction, $url, $sessId) {
- $this->service = "DataService";
- $this->action = $newAction;
- $this->url = $url;
- $this->sessionId = $sessId;
- }
- // return data
- function getData() {
- $xmldoc = $this->buildRequestXMLDoc();
- $this->setReqXML($xmldoc->saveXML());
- //echo htmlentities($xmldoc->saveXML());
- $resXml = $this->postXmlMessage();
- //echo htmlentities($resXml);
- $this->responseArray = $this->parseResponse($resXml);
- return $this->responseArray;
- }
- function buildRequestXMLDoc() {
- /* build request xml for e2 CancelTransaction */
- $xmldoc = $this->buildE2XMLHeader();
- $xpath = "//".$this->action;
- // postcode to find address
- if (isset ($this->postcode)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Postcode", $this->postcode);
- }
- // type to find code from dc
- if (isset ($this->type)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Type", $this->type);
- }
- // code to find code from dc
- if (isset ($this->code)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Code", $this->code);
- }
- // description to find code from dc
- if (isset ($this->desc)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Description", $this->desc);
- }
- // misc fields to find code from dc
- if (isset ($this->miscFields)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "MiscFields", $this->miscFields);
- }
- // add LiveOnly flag
- if (isset ($this->liveOnly)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "LiveOnly", (!$this->liveOnly) ? "false" : "true");
- }
- // add available on the Internet flag
- if (isset ($this->internetOnly)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "InternetOnly", (!$this->internetOnly) ? "false" : "true");
- }
- return $xmldoc;
- }
- }
- class PassengerInfo extends e2Interface {
- /* Deal with e2 PassengerInfo*/
- /* Added by Yayun Sun */
- var $bookingNumber; // Human readable booking number
- var $paxCode; // The passenger code
- var $responseArray; // Response array
- function setBookingNumber($newB) {
- $this->bookingNumber = $newB;
- }
- function setPaxCode($newP) {
- $this->paxCode = $newP;
- }
- function getBookingNumber() {
- return $this->bookingNumber;
- }
- function getPaxCode() {
- return $this->paxCode;
- }
- function getResponseArray() {
- return $this->responseArray;
- }
- function PassengerInfo($newAction, $newURL, $newSessId, $newBookingNumber = "", $newPaxCode = "") {
- /* constructor */
- $this->service = "ReservationService";
- $this->action = $newAction;
- $this->url = $newURL;
- $this->sessionId = $newSessId;
- $this->bookingNumber = $newBookingNumber;
- $this->paxCode = $newPaxCode;
- }
- function findInfo() {
- $xmldoc = $this->buildRequestXMLDoc();
- $this->setReqXML($xmldoc->saveXML());
- $resXml = $this->postXmlMessage();
- if (strlen($this->getErrorCode()) > 0) {
- return;
- }
- //$this->responseArray = $this->parseResponse($resXml);
- //return $this->responseArray;
- return $resXml;
- }
- function buildRequestXMLDoc() {
- /* build request xml for e2 PassengerInfo*/
- $xmldoc = $this->buildE2XMLHeader();
- $xpath = "//".$this->action;
- if (isset ($this->bookingNumber)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "BookingNumber", $this->bookingNumber);
- }
- if (isset ($this->paxCode)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "PaxCode", $this->paxCode);
- }
- return $xmldoc;
- }
- }
- class AssignPassenger extends e2Interface {
- /* Deal with e2 AssignPassenger*/
- /* Added by Yayun Sun */
- var $transactionNumber; // The transaction number
- var $paxList; // The list of passenger codes
- var $toReplace; // Whether the passenger list should replace the existing one or simply appending
- var $canClear; // Whether the passenger list can be cleared by replacing
- function setTransactionNumber($newT) {
- $this->transactionNumber = $newT;
- }
- function setPaxList($newP) {
- $this->paxList = $newP;
- }
- function setToReplace($newR) {
- $this->toReplace = $newR;
- }
- function setCanClear($newC) {
- $this->canClear = $newC;
- }
- function getTransactionNumber() {
- return $this->TransactionNumber;
- }
- function getPaxList() {
- return $this->paxList;
- }
- function getToReplace() {
- return $this->toReplace;
- }
- function getCanClear() {
- return $this->canClear;
- }
- function AssignPassenger($newURL, $newSessId, $newTransactionNumber = "", $newPaxList = "", $newToReplace = false, $newCanClear = false) {
- /* constructor */
- $this->service = "ReservationService";
- $this->action = "AssignPassenger";
- $this->url = $newURL;
- $this->sessionId = $newSessId;
- $this->transactionNumber = $newTransactionNumber;
- $this->paxList = $newPaxList;
- $this->toReplace = $newToReplace;
- $this->canClear = $newCanClear;
- }
- function assign() {
- $xmldoc = $this->buildRequestXMLDoc();
- $this->setReqXML($xmldoc->saveXML());
- $resXml = $this->postXmlMessage();
- if (strlen($this->getErrorCode()) > 0) {
- return;
- }
- $this->responseArray = $this->parseResponse($resXml);
- return $this->responseArray;
- }
- function buildRequestXMLDoc() {
- /* build request xml for e2 AssignPassenger */
- $xmldoc = $this->buildE2XMLHeader();
- $xpath = "//".$this->action;
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "BookingTransaction", "");
- if (isset ($this->transactionNumber)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/BookingTransaction", "TransactionNumber", $this->transactionNumber);
- }
- if (isset ($this->paxList)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/BookingTransaction", "PassengerList", $this->paxList);
- }
- if (isset ($this->toReplace) && $this->toReplace) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/BookingTransaction", "Replace", "");
- if (isset ($this->canClear) && $this->canClear) {
- $xmldoc = $this->setXNodeAttribute($xmldoc, $xpath."/BookingTransaction/Replace", "Null", "true");
- }
- }
- return $xmldoc;
- }
- }
- class PrepareUpdateTransaction extends e2Interface {
- /* Deal with e2 PrepareUpdateTransaction */
- /* Added by Yayun Sun */
- var $tranNumber; // Booking transaction number
- var $suppNumber; // Booking supplemenet number
- var $responseArray; // Response array
- var $resType; // Response type: array or xml
- function setTranNumber($newT) {
- $this->tranNumber = $newT;
- }
- function setSuppNumber($newS) {
- $this->suppNumber = $newS;
- }
- function setResType($newType) {
- $this->resType = $newType;
- }
- function getTranNumber() {
- return $this->tranNumber;
- }
- function getSuppNumber() {
- return $this->suppNumber;
- }
- function getResponseArray() {
- return $this->responseArray;
- }
- function PrepareUpdateTransaction($newAction, $newURL, $newSessId, $newTranNumber = "", $newSuppNumber = "", $newType = "array") {
- /* constructor */
- $this->service = "ReservationService";
- $this->action = $newAction;
- $this->url = $newURL;
- $this->sessionId = $newSessId;
- $this->tranNumber = $newTranNumber;
- $this->suppNumber = $newSuppNumber;
- $this->resType = $newType;
- }
- function findTranInfo() {
- $xmldoc = $this->buildRequestXMLDoc();
- $this->setReqXML($xmldoc->saveXML());
- //echo htmlentities($xmldoc->saveXML());
- $resXml = $this->postXmlMessage();
- //echo htmlentities($resXml);
- if ($this->resType == "array") {
- $this->responseArray = $this->parseResponse($resXml);
- return $this->responseArray;
- } else if ($this->resType == "xml") {
- return $resXml;
- }
- }
- function buildRequestXMLDoc() {
- /* build request xml for e2 UpdateTransactionInfo*/
- $xmldoc = $this->buildE2XMLHeader();
- $xpath = "//".$this->action;
- if (isset ($this->tranNumber)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "TransactionNumber", $this->tranNumber);
- }
- if (isset ($this->suppNumber)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "SupplementNumber", $this->suppNumber);
- }
- return $xmldoc;
- }
- }
- class UpdateTransaction extends e2Interface {
- /* Deal with e2 UpdateTransaction */
- /* Added by Yayun Sun */
- var $tranNumber; // Booking transaction number
- var $suppNumber; // Booking supplemenet number
- var $lineStyleArray; // Store line style fields
- function setTranNumber($newT) {
- $this->tranNumber = $newT;
- }
- function setSuppNumber($newS) {
- $this->suppNumber = $newS;
- }
- function setLineStyleArray($newLX) {
- $this->lineStyleArray = $newLX;
- }
- function getTranNumber() {
- return $this->tranNumber;
- }
- function getSuppNumber() {
- return $this->suppNumber;
- }
- function UpdateTransaction($newAction, $newURL, $newSessId, $newTranNumber = "", $newSuppNumber = "", $newLX = "") {
- /* constructor */
- $this->service = "ReservationService";
- $this->action = $newAction;
- $this->url = $newURL;
- $this->sessionId = $newSessId;
- $this->tranNumber = $newTranNumber;
- $this->suppNumber = $newSuppNumber;
- $this->lineStyleArray = $newLX;
- }
- function update($sessId) {
- $xmldoc = $this->buildRequestXMLDoc($sessId);
- $this->setReqXML($xmldoc->saveXML());
- //echo htmlentities($xmldoc->saveXML());
- $resXml = $this->postXmlMessage();
- //echo htmlentities($resXml);
- $this->parseResponse($this->resXML);
- }
- function buildRequestXMLDoc($sessId) {
- /* build request xml for e2 UpdateTransaction */
- $service_name = $this->action;
- $xmldoc = $this->buildE2XMLHeader($this->service, $service_name, $sessId);
- $xpath = "//".$service_name;
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "TransactionNumber", $this->tranNumber);
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "SupplementNumber", $this->suppNumber);
- if (is_array($this->lineStyleArray)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "LineStyleDetails", "");
- foreach ($this->lineStyleArray as $lxs) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/LineStyleDetails", "LineStyle", "");
- if (isset ($lxs["Field"])) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/LineStyleDetails/LineStyle", "Field", $lxs["Field"]);
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/LineStyleDetails/LineStyle", "Value", $lxs["Value"]);
- }
- }
- }
- return $xmldoc;
- }
- }
- class FindBookings extends e2Interface {
- /* Deal with e2 FindBookings */
- /* Added by Yayun Sun */
- var $clientCode;
- var $bookingNumber;
- var $departFrom;
- var $departTo;
- function setClientCode($newC) {
- $this->clientCode = $newC;
- }
- function getClientCode($newC) {
- return $this->clientCode;
- }
- function setBookingNumber($newB) {
- $this->bookingNumber = $newB;
- }
- function getBookingNumber($newB) {
- return $this->bookingNumber;
- }
- function setDepartFrom($newD) {
- $this->departFrom = $newD;
- }
- function setDepartTo($newD) {
- $this->departTo = $newD;
- }
- function FindBookings($newAction, $newURL, $newSessId, $newClientCode = "") {
- /* constructor */
- $this->service = "ReservationService";
- $this->action = $newAction;
- $this->url = $newURL;
- $this->sessionId = $newSessId;
- $this->clientCode = $newClientCode;
- }
- function findBookingList() {
- $xmldoc = $this->buildRequestXMLDoc();
- $this->setReqXML($xmldoc->saveXML());
- //echo htmlentities($xmldoc->saveXML());
- $resXml = $this->postXmlMessage();
- //echo htmlentities($resXml);
- if (strlen($this->getErrorCode()) > 0) {
- return;
- }
- $this->responseArray = $this->parseResponse($resXml);
- return $this->responseArray;
- }
- function buildRequestXMLDoc() {
- /* build request xml for e2 FindBookings*/
- $xmldoc = $this->buildE2XMLHeader();
- $xpath = "//".$this->action;
- if (isset ($this->clientCode)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "CustomerCode", $this->clientCode);
- }
- if (isset ($this->bookingNumber)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "BookingNumber", $this->bookingNumber);
- }
- if (isset ($this->departFrom)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "DepartFrom", $this->departFrom);
- }
- if (isset ($this->departTo)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "DepartTo", $this->departTo);
- }
- return $xmldoc;
- }
- }
- class PriceOverride extends E2Interface{
- /* Deal with price override*/
- var $adult, $conc1, $conc2, $conc3, $infant, $unit;
- function setAdult($price){
- $this->adult = $price;
- }
- function setConc1($price){
- $this->conc1 = $price;
- }
- function setConc2($price){
- $this->conc2 = $price;
- }
- function setConc3($price){
- $this->conc3 = $price;
- }
- function setInfant($price){
- $this->infant = $price;
- }
- function setUnit($price){
- $this->unit = $price;
- }
- function buildOverrideXML($xmldoc, $xpath){
- if (isset($this->adult)){
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Adult", $this->adult);
- }
- if (isset($this->conc1)){
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Conc1", $this->conc1);
- }
- if (isset($this->conc2)){
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Conc2", $this->conc2);
- }
- if (isset($this->conc3)){
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Conc3", $this->conc3);
- }
- if (isset($this->infant)){
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Infant", $this->infant);
- }
- if (isset($this->unit)){
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Unit", $this->unit);
- }
- return $xmldoc;
- }
- }
- class SellPriceOverride extends PriceOverride{
- function SellPriceOverride(){
- }
- function buildReqXML($xmldoc, $xpath){
- $override_tag_name = "SellPriceOverride";
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, $override_tag_name, "");
- $xmldoc = $this->buildOverrideXML($xmldoc, $xpath ."/".$override_tag_name);
- return $xmldoc;
- }
- }
- class CostPriceOverride extends PriceOverride{
- function SellPriceOverride($adult_prc){
- $this->adult = $adult_prc;
- }
- function buildReqXML($xmldoc, $xpath){
- $override_tag_name = "CostPriceOverride";
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, $override_tag_name, "");
- $xmldoc = $this->buildOverrideXML($xmldoc, $xpath ."/".$override_tag_name);
- return $xmldoc;
- }
- }
- class FindDBData extends E2Interface {
- /* Deal with e2 Maintenance Service - Find*/
- /* Added by Yayun Sun*/
- var $table; // the table name in Embarque
- var $tableKey; // the key name of the table used for the search
- var $matchFrom; // the starting search point for the key
- var $matchTo; // the end search point for the key
- var $select; // the filter criteria
- // 120208 added by Sunny: The fields to return in response
- var $showFields;// the fields to return
- var $liveOnly; // the live flag
- var $resType; // Response type: array or xml
- function setTable($newTable) {
- $this->table = $newTable;
- }
- function setTableKey($newTableKey) {
- $this->tableKey = $newTableKey;
- }
- function setMatchFrom($keyValuePairs) {
- $this->matchFrom = $keyValuePairs;
- }
- function setMatchTo($keyValuePairs) {
- $this->matchTo = $keyValuePairs;
- }
- function setSelect($keyValuePairs) {
- $this->select = $keyValuePairs;
- }
- function setShowFields($fields) {
- $this->showFields = $fields;
- }
- function setLiveOnly($newLiveOnly) {
- $this->liveOnly = $newLiveOnly;
- }
- function setResType($newType) {
- $this->resType = $newType;
- }
- function getResponseArray() {
- return $this->responseArray;
- }
- function FindDBData($newTable = "", $newTableKey = "", $newLiveOnly = true, $newType = "array") {
- /* constructor */
- $this->service = "MaintenanceService";
- $this->action = "Find";
- $this->table = $newTable;
- $this->tableKey = $newTableKey;
- $this->liveOnly = $newLiveOnly;
- $this->resType = $newType;
- }
- function find($url, $sessId) {
- $xmldoc = $this->buildRequestXMLDoc($sessId);
- $this->setUrl($url);
- $this->setReqXML($xmldoc->saveXML());
- //echo htmlentities($xmldoc->saveXML());
- $resXml = $this->postXmlMessage();
- //echo htmlentities($resXml);
- if ($this->resType == "array") {
- $this->responseArray = $this->parseResponse($this->resXML);
- return $this->responseArray;
- } else if ($this->resType == "xml") {
- return $resXml;
- }
- }
- function buildRequestXMLDoc($sessId) {
- /* build request xml for e2 MaintenanceService - Find */
- $service_name = $this->action;
- $xmldoc = $this->buildE2XMLHeader($this->service, $service_name, $sessId);
- $xpath = "//".$service_name;
- /* add search criteria */
- if (isset($this->table)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Table", $this->table);
- }
- if (isset($this->tableKey)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Key", $this->tableKey);
- }
- if (isset($this->matchFrom)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "MatchFrom", "");
- $matchFromKeys = array_keys($this->matchFrom);
- for ($i = 0; $i < count($matchFromKeys); $i++) {
- $key = $matchFromKeys[$i];
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/MatchFrom", $key, $this->matchFrom[$key]);
- }
- }
- if (isset($this->matchTo)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "MatchTo", "");
- $matchToKeys = array_keys($this->matchTo);
- for ($i = 0; $i < count($matchToKeys); $i++) {
- $key = $matchToKeys[$i];
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/MatchTo", $key, $this->matchTo[$key]);
- }
- }
- if (isset($this->select)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Select", "");
- $selectKeys = array_keys($this->select);
- for ($i = 0; $i < count($selectKeys); $i++) {
- $key = $selectKeys[$i];
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Select", $key, $this->select[$key]);
- }
- }
- if (isset($this->showFields)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "ShowFields", $this->showFields);
- }
- if (isset($this->liveOnly)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "LiveOnly", (!$this->liveOnly) ? "false" : "true");
- }
- return $xmldoc;
- }
- }
- class UpdateDBData extends E2Interface {
- /* Deal with e2 Maintenance Service - Update*/
- /* Added by Yayun Sun*/
- var $table; // the table name in Embarque
- var $tableKey; // the key name of the table used for the search
- var $bookmark; // the bookmark of the record to be updated
- var $updates; // the updates
- function setTable($newTable) {
- $this->table = $newTable;
- }
- function setTableKey($newTableKey) {
- $this->tableKey = $newTableKey;
- }
- function setBookmark($bookmark) {
- $this->bookmark = $bookmark;
- }
- function setUpdates($keyValuePairs) {
- $this->updates = $keyValuePairs;
- }
- function getResponseArray() {
- return $this->responseArray;
- }
- function UpdateDBData($newTable = "", $newTableKey = "", $bookmark = "") {
- /* constructor */
- $this->service = "MaintenanceService";
- $this->action = "Update";
- $this->table = $newTable;
- $this->tableKey = $newTableKey;
- $this->bookmark = $bookmark;
- }
- function update($url, $sessId) {
- $xmldoc = $this->buildRequestXMLDoc($sessId);
- $this->setUrl($url);
- $this->setReqXML($xmldoc->saveXML());
- //echo htmlentities($xmldoc->saveXML());
- $resXml = $this->postXmlMessage();
- //echo htmlentities($resXml);
- $this->responseArray = $this->parseResponse($this->resXML);
- return $this->responseArray;
- }
- function buildRequestXMLDoc($sessId) {
- /* build request xml for e2 MaintenanceService - Update */
- $service_name = $this->action;
- $xmldoc = $this->buildE2XMLHeader($this->service, $service_name, $sessId);
- $xpath = "//".$service_name;
- /* add search criteria */
- if (isset($this->table)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Table", $this->table);
- }
- if (isset($this->tableKey)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Key", $this->tableKey);
- }
- if (isset($this->bookmark)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Record", "");
- $xmldoc = $this->setXNodeAttribute($xmldoc, $xpath."/Record", "Bookmark", $this->bookmark);
- }
- if (isset($this->updates)) {
- $updatesKeys = array_keys($this->updates);
- for ($i = 0; $i < count($updatesKeys); $i++) {
- $key = $updatesKeys[$i];
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Record", $key, $this->updates[$key]);
- }
- }
- return $xmldoc;
- }
- }
- class GetProperties extends E2Interface {
- /* Deal with e2 Data Service (Ext 1) - GetProperties*/
- /* Added by Yayun Sun*/
- var $propertyCode; // the property code
- var $liveOnly; // the live flag
- function setPropertyCode($newCode) {
- $this->propertyCode = $newCode;
- }
- function setLiveOnly($newLiveOnly) {
- $this->liveOnly = $newLiveOnly;
- }
- function getResponseArray() {
- return $this->responseArray;
- }
- function GetProperties($newCode = "", $newLiveOnly = true) {
- /* constructor */
- $this->service = "DataService";
- $this->action = "GetProperties";
- $this->propertyCode = $newCode;
- $this->liveOnly = $newLiveOnly;
- }
- function findProperty($url, $sessId) {
- $xmldoc = $this->buildRequestXMLDoc($sessId);
- $this->setUrl($url);
- $this->setReqXML($xmldoc->saveXML());
- //echo htmlentities($xmldoc->saveXML());
- $resXml = $this->postXmlMessage();
- //echo htmlentities($resXml);
- $this->responseArray = $this->parseResponse($this->resXML);
- return $this->responseArray;
- }
- function buildRequestXMLDoc($sessId) {
- /* build request xml for e2 Data Service (Ext 1) - GetProperties */
- $service_name = $this->action;
- $xmldoc = $this->buildE2XMLHeader($this->service, $service_name, $sessId);
- $xpath = "//".$service_name;
- /* add search criteria */
- if (isset($this->propertyCode)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "PropertyCode", $this->propertyCode);
- }
- if (isset($this->liveOnly)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "LiveOnly", (!$this->liveOnly) ? "N" : "Y");
- }
- return $xmldoc;
- }
- }
- class GetAccommodations extends E2Interface {
- /* Deal with e2 Data Service (Ext 1) - GetAccommodations*/
- /* Added by NR*/
- var $accommodationCode; // the room/accommodation code
- // 150508 added by Sunny: Code from/to
- var $codeFrom;
- var $codeTo;
- var $features; // the room feature code(s)
- var $liveOnly; // the live flag
- // 210508 added by Sunny: Detail level
- var $detailLevel; // the details level array
- function setAccommodationCode($newCode) {
- $this->accommodationCode = $newCode;
- }
- function setCodeFrom($newCodeFrom) {
- $this->codeFrom = $newCodeFrom;
- }
- function setCodeTo($newCodeTo) {
- $this->codeTo = $newCodeTo;
- }
- function setLiveOnly($newLiveOnly) {
- $this->liveOnly = $newLiveOnly;
- }
- function setFeatures($newFeatures) {
- $this->features = $newFeatures;
- }
- function setDetailLevel($newDetailLevel) {
- $this->detailLevel = $newDetailLevel;
- }
- function getResponseArray() {
- return $this->responseArray;
- }
- function GetAccommodations($newCode = "", $newLiveOnly = true, $detailLevel = array()) {
- /* constructor */
- $this->service = "DataService";
- $this->action = "GetAccommodations";
- $this->accommodationCode = $newCode;
- $this->liveOnly = $newLiveOnly;
- $this->detailLevel = $detailLevel;
- }
- function findAccommodation($url, $sessId) {
- $xmldoc = $this->buildRequestXMLDoc($sessId);
- $this->setUrl($url);
- $this->setReqXML($xmldoc->saveXML());
- //echo htmlentities($xmldoc->saveXML());
- $resXml = $this->postXmlMessage();
- //echo htmlentities($resXml);
- $this->responseArray = $this->parseResponse($this->resXML);
- return $this->responseArray;
- }
- function buildRequestXMLDoc($sessId) {
- /* build request xml for e2 Data Service (Ext 1) - GetAccommodations */
- $service_name = $this->action;
- $xmldoc = $this->buildE2XMLHeader($this->service, $service_name, $sessId);
- $xpath = "//".$service_name;
- /* add search criteria */
- if (isset($this->accommodationCode)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "AccommodationCode", $this->accommodationCode);
- }
- if (isset($this->codeFrom)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "CodeFrom", $this->codeFrom);
- }
- if (isset($this->codeTo)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "CodeTo", $this->codeTo);
- }
- if (isset($this->features)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Features", $this->features);
- }
- if (isset($this->liveOnly)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "LiveOnly", (!$this->liveOnly) ? "N" : "Y");
- }
- /* for detail information */
- for ($index = 0; $index < sizeof($this->detailLevel) and isset ($this->detailLevel[$index]); $index ++) {
- $detailFlag = $this->detailLevel[$index];
- if ($index == 0) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "DetailLevel", "");
- }
- $xmldoc = $detailFlag->buildRequestXMLDoc($xmldoc, $xpath."/DetailLevel");
- }
- return $xmldoc;
- }
- }
- class Util {
- // return node array whether there are single node or multiple
- //
- public static function getNodeArray($node, $child)
- {
- $node_array = array();
- if(is_array($node)){
- if (is_array($node[$child])){
- if (isset($node[$child][0])){
- $node_array = $node[$child];
- }else{
- $node_array[] = $node[$child];
- }
- }else if (isset($node[$child])){
- $node_array[] = $node[$child];
- }
- }
- return ($node_array);
- }
- // Is e2 error?
- function isE2Err($e2Obj){
- if ( $e2Obj && strlen($e2Obj->getErrorCode())>0) {
- return true;
- }
- return false;
- }
- // Create an e2 session
- function createE2Session($e2db, $e2user, $e2pass, $e2sessUrl, $params=array()){
- $sessionId = '';
- $session = new Session($e2db, $e2user, $e2pass);
- $session->createSession($e2sessUrl, $params);
- if (!$this->isE2Err($session)) {
- $sessionId = $session->getSessionID();
- }
- return $sessionId;
- }
- }
- class MarketingService extends E2Interface {
- /* Deal with e2 Marketing service*/
- var $brochure;
- var $client;
- var $quantity;
- var $source;
- var $letter;
- var $dispatchMethod;
- var $responseArray;
- function setBrochure($newBrochure){
- $this->brochure = $newBrochure;
- }
- function setClient($newCl){
- $this->client = $newCl;
- }
- function setQuantity($newQnty){
- $this->quantity = $newQnty;
- }
- function setSource($newSrc){
- $this->source = $newSrc;
- }
- function setLetter($newLetter){
- $this->letter = $newLetter;
- }
- function setDispatchMethod($newDM){
- $this->dispatchMethod = $newDM;
- }
- function getBrochure(){
- return $this->brochure;
- }
- function getClient(){
- return $this->client;
- }
- function getQuantity(){
- return $this->quantity;
- }
- function getSource(){
- return $this->source;
- }
- function getLetter(){
- return $this->letter;
- }
- function getDispatchMethod(){
- return $this->dispatchMethod;
- }
- function getResponseArray() {
- return ($this->responseArray);
- }
- function MarketingService($newAction, $newURL, $newSessId) {
- /* constructor */
- $this->service = "MarketingService";
- $this->action = $newAction;
- $this->url = $newURL;
- $this->sessionId = $newSessId;
- }
- function getMarketingInfo() {
- $xmldoc = $this->buildRequestXMLDoc();
- $this->setReqXML($xmldoc->saveXML());
- //echo htmlentities($xmldoc->saveXML());
- $resXml = $this->postXmlMessage();
- //echo htmlentities($resXml);
- if (strlen($this->getErrorCode()) > 0) {
- return;
- }
- $this->responseArray = $this->parseResponse($resXml);
- return $this->responseArray;
- }
- function buildRequestXMLDoc() {
- /* build request xml for e2 CancelTransaction */
- $xmldoc = $this->buildE2XMLHeader();
- $xpath = "//".$this->action;
- /* add paxs */
- if (isset ($this->brochure)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Brochure", $this->brochure);
- }
- if (isset ($this->client)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Client", $this->client);
- }
- if (isset ($this->letter)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Letter", $this->letter);
- }
- if (isset ($this->dispatchMethod)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "DispatchMethod", $this->dispatchMethod);
- }
- if (isset ($this->quantity)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Quantity", $this->quantity);
- }
- // set source
- if (isset ($this->source)) {
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Source", $this->source);
- }
- return $xmldoc;
- }
- }
- class E2UtilityService extends E2Interface {
- /* Deal with e2 Utility service*/
- // booking notify
- var $emailMsgFile;
- var $emailSender;
- var $emailTo;
- var $emailCc;
- var $emailBcc;
- var $emailSubject;
- var $emailMsg;
- var $responseArray;
- function setEmailSender($sndr){
- $this->emailSender = $sndr;
- }
- function setEmailTo($to){
- $this->emailTo = $to;
- }
- function setEmailCc($cc){
- $this->emailCc = $cc;
- }
- function setEmailBcc($bcc){
- $this->emailBcc = $bcc;
- }
- function setEmailSubject($subject){
- $this->emailSubject = $subject;
- }
- function setEmailMsgFile($messageFile){
- $this->emailMsgFile = $messageFile;
- }
- function setEmailMsg($msg){
- $this->emailMsg = $msg;
- }
- function getResponseArray() {
- return ($this->responseArray);
- }
- function E2UtilityService($newAction, $newURL, $newSessId) {
- /* constructor */
- $this->service = "UtilityService";
- $this->action = $newAction;
- $this->url = $newURL;
- $this->sessionId = $newSessId;
- }
- function getUtilityInfo() {
- $xmldoc = $this->buildRequestXMLDoc();
- $this->setReqXML($xmldoc->saveXML());
- //echo htmlentities($xmldoc->saveXML());
- $resXml = $this->postXmlMessage();
- //echo htmlentities($resXml);
- if (strlen($this->getErrorCode()) > 0) {
- return;
- }
- $this->responseArray = $this->parseResponse($resXml);
- return $this->responseArray;
- }
- function buildRequestXMLDoc() {
- /* build request xml for e2 CancelTransaction */
- $xmldoc = $this->buildE2XMLHeader();
- $xpath = "//".$this->action;
- if ($this->action == "EmailNotify") {
- if (isset($this->emailSender)){
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Sender", $this->emailSender);
- }
- if (isset($this->emailBcc)){
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Bcc", $this->emailBcc);
- }
- if (isset($this->emailCc)){
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Cc", $this->emailCc);
- }
- if (isset($this->emailTo)){
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "To", $this->emailTo);
- }
- if (isset($this->emailMsgFile)){
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "MessageFile", $this->emailMsgFile);
- }
- if (isset($this->emailSubject)){
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Subject", $this->emailSubject);
- }
- if (isset($this->emailMsg)){
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Message", $this->emailMsg);
- }
- }
- return $xmldoc;
- }
- }
- class DocumentService extends E2Interface {
- /* Deal with e2 Document service*/
- var $bookingNumber;
- var $unpaidTolerance;
- var $email;
- function setBookingNumber($bookingNumber) {
- $this->bookingNumber = $bookingNumber;
- }
- function setUnpaidTolerance($unpaidTolerance) {
- $this->unpaidTolerance = $unpaidTolerance;
- }
- function setEmail($email) {
- $this->email = $email;
- }
- function DocumentService($newAction, $newURL, $newSessId) {
- /* constructor */
- $this->service = "DocumentService";
- $this->action = $newAction;
- $this->url = $newURL;
- $this->sessionId = $newSessId;
- }
- function run() {
- $xmldoc = $this->buildRequestXMLDoc();
- $this->setReqXML($xmldoc->saveXML());
- //echo htmlentities($xmldoc->saveXML());
- $resXml = $this->postXmlMessage();
- //echo htmlentities($resXml);
- if (strlen($this->getErrorCode()) > 0) {
- return;
- }
- $this->responseArray = $this->parseResponse($resXml);
- return $this->responseArray;
- }
- function buildRequestXMLDoc() {
- /* build request xml for e2 Document service */
- $xmldoc = $this->buildE2XMLHeader();
- $xpath = "//".$this->action;
- if ($this->action == "RunPicklist") {
- if (isset($this->bookingNumber)){
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "BookingNumber", $this->bookingNumber);
- }
- if (isset($this->unpaidTolerance)){
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "UnpaidTolerance", $this->unpaidTolerance);
- }
- if (isset($this->email)){
- $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Email", $this->email);
- }
- }
- return $xmldoc;
- }
- }
- class EndSession extends E2Interface {
- /*
- Deal with the e2 xml service: EndSession
- Added by Yayun Sun (Sunny)
- */
- function EndSession($newAction, $newURL, $newSessId) {
- /* constructor */
- $this->service = "SystemService";
- $this->action = $newAction;
- $this->url = $newURL;
- $this->sessionId = $newSessId;
- }
- function removeSession() {
- $xmldoc = $this->buildRequestXMLDoc();
- $this->setReqXML($xmldoc->saveXML());
- //echo htmlentities($xmldoc->saveXML());
- $resXml = $this->postXmlMessage();
- //echo htmlentities($resXml);
- if (strlen($this->getErrorCode()) > 0) {
- return;
- }
- $this->responseArray = $this->parseResponse($resXml);
- return $this->responseArray;
- }
- function buildRequestXMLDoc() {
- /* build request xml for e2 EndSession*/
- $xmldoc = $this->buildE2XMLHeader();
- return $xmldoc;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement