Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 156.72 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. /* Author: Mahbubur Rahman Sumon*/
  5. /* Copy right: Metafour (uk) Ltd.*/
  6. /* e2 client library*/
  7. /* it is independant of client website */
  8. /* but it is dependent on e2 xml service */
  9.  
  10. // 080710 Sunny: Changed to work on PHP5 only (before: PHP4 only)
  11.  
  12. require_once ("xml2array.php");
  13. class Session extends BasicE2XML {
  14.     /* Deal with e2 xml service sessions
  15.      */
  16.     var $sessionID;
  17.     var $embSystem;
  18.     var $user;
  19.     var $password;
  20.     var $transaction; // e2 transaction handler
  21.     function setSystem($newSystem) {
  22.         $this->embSystem = $newSystem;
  23.     }
  24.     function setUser($newUser) {
  25.         $this->user = $newUser;
  26.     }
  27.     function setPassword($newPassword) {
  28.         $this->password = $newPassword;
  29.     }
  30.     function setSessionId($newSessId) {
  31.         $this->sessionID = $newSessId;
  32.     }
  33.     function getSessionID() {
  34.         return $this->sessionID;
  35.     }
  36.     function Session($newSys, $newUser, $newPass) {
  37.         $this->embSystem = $newSys;
  38.         $this->user = $newUser;
  39.         $this->password = $newPass;
  40.     }
  41.     function createSession($url, $params) {
  42.         $xmldoc = $this->buildRequestXMLDoc($params);
  43.         $xpost = new XMLPosting();
  44.         $xpost->setUrl($url);
  45.         $xpost->setReqXML($xmldoc->saveXML());
  46.         //echo htmlentities($xmldoc->saveXML());
  47.         $resXml = $xpost->postXmlMessage();
  48.         $this->parseResponse($resXml);
  49.     }
  50.     /* build request xml to start session*/
  51.     function buildRequestXMLDoc($params) {
  52.         $xmldoc = $this->buildE2XMLHeader("SystemService", "StartSession", "");
  53.         $xmldoc = $this->setXNodeValue($xmldoc, "//StartSession", "System", $this->embSystem);
  54.         $xmldoc = $this->setXNodeValue($xmldoc, "//StartSession", "User", $this->user);
  55.         $xmldoc = $this->setXNodeValue($xmldoc, "//StartSession", "Password", $this->password);
  56.         for ($i = 0; $i < count($params); $i ++) {
  57.             if ($i == 0) {
  58.                 $xmldoc = $this->setXNodeValue($xmldoc, "//StartSession", "Params", "");
  59.             }
  60.             $xmldoc = $this->setXNodeValue($xmldoc, "//StartSession/Params", "Param", "");
  61.             $xmldoc = $this->setXNodeValue($xmldoc, "//StartSession/Params/Param", "Action", $params[$i]->getAction());
  62.             $xmldoc = $this->setXNodeValue($xmldoc, "//StartSession/Params/Param", "Name", $params[$i]->getName());
  63.             $xmldoc = $this->setXNodeValue($xmldoc, "//StartSession/Params/Param", "Value", $params[$i]->getValue());
  64.         }
  65.         return $xmldoc;
  66.     }
  67.     function parseResponse($rs) {
  68.         $doc = new DOMDocument('1.0', 'ISO-8859-1');
  69.         if (!$doc->loadXML($rs)) {
  70.             // it is done here to isolate e2 client library independant
  71.             // of client website.
  72.             $this->setErrorCode("Website-C0201");
  73.             $this->setErrorType("fatal");
  74.             $this->setErrorDesc("Error while parsing response xml document");
  75.             return;
  76.         }
  77.         $root = $doc->firstChild;
  78.         //$root->name = 'SystemService';
  79.         $this->parseNode($root);
  80.         //$dom->free();
  81.     }
  82.     function parseNode($root) {
  83.         $this->parseNodeFault($root);
  84.         if (strlen($this->getErrorCode()) > 0) {
  85.             return;
  86.         }
  87.         $this->transaction = $this->parseNodeTransaction($root);
  88.         $this->sessionID = $this->transaction->getSessionID();
  89.     }
  90.     // parse transaction node
  91.     function parseNodeTransaction($node) {
  92.         $transaction = new Transaction();
  93.         $ok = 0;
  94.         if ($node->hasChildNodes()) {
  95.             foreach ($node->childNodes as $n) {
  96.                 // Transaction information here
  97.                 if ($n->nodeName == 'Transaction') {
  98.                     foreach ($n->childNodes as $tr) {
  99.                         if ($tr->nodeName == 'SessionID')
  100.                             $transaction->setSessionID($tr->nodeValue);
  101.                         if ($tr->nodeName == 'Version')
  102.                             $transaction->setVersion($tr->nodeValue);
  103.                         if ($tr->nodeName == 'Service')
  104.                             $transaction->setService($tr->nodeValue);
  105.  
  106.                     }
  107.                     return $transaction;
  108.                 }
  109.  
  110.             }
  111.         }
  112.     }
  113.  
  114. }
  115.  
  116. class SessionParams extends BasicE2XML {
  117.     /* Deal with e2 xml service session params
  118.      */
  119.     var $params;
  120.     var $responseArray;
  121.     function setParams($newParams) {
  122.         $this->params = $newParams;
  123.     }
  124.     function getResponseArray() {
  125.         return $this->responseArray;
  126.     }
  127.     function getParams() {
  128.         return $this->params;
  129.     }
  130.     function SessionParams($newParams) {
  131.         $this->params = $newParams;
  132.     }
  133.     function setGet($url, $sessId) {
  134.         $xmldoc = $this->buildRequestXMLDoc($sessId);
  135.         $xpost = new XMLPosting();
  136.         $xpost->setUrl($url);
  137.         $xpost->setReqXML($xmldoc->saveXML());
  138.         //echo htmlentities($xmldoc->saveXML());
  139.         $resXml = $xpost->postXmlMessage();
  140.         $this->parseResponse($resXml);
  141.         //echo htmlentities($resXml);
  142.     }
  143.     /* build request xml to start session*/
  144.     function buildRequestXMLDoc($sessId) {
  145.         $service_name = "SessionParams";
  146.         $xmldoc = $this->buildE2XMLHeader("SystemService", $service_name, $sessId);
  147.         $xpath = "//".$service_name;
  148.         for ($i = 0; $i < count($this->params); $i ++) {
  149.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Param", "");
  150.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Param", "Action", $this->params[$i]->getAction());
  151.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Param", "Name", $this->params[$i]->getName());
  152.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Param", "Value", $this->params[$i]->getValue());
  153.         }
  154.         return $xmldoc;
  155.     }
  156. }
  157. class Transaction {
  158.     /* class dealing with e2 transaction
  159.        Author: Mahbubur Rahman Sumon
  160.      */
  161.     var $sessionID;
  162.     var $version;
  163.     var $service;
  164.     function setSessionID($newSessionID) {
  165.         $this->sessionID = $newSessionID;
  166.     }
  167.     function setVersion($newVersion) {
  168.         $this->version = $newVersion;
  169.     }
  170.     function setService($newService) {
  171.         $this->service = $newService;
  172.     }
  173.     function getSessionID() {
  174.         return $this->sessionID;
  175.     }
  176.     function getVersion() {
  177.         return $this->version;
  178.     }
  179.     function getService() {
  180.         return $this->service;
  181.     }
  182. }
  183. // E2 fault class
  184. class Fault {
  185.     var $errorCode;
  186.     var $errorDesc;
  187.     var $errorType;
  188.     function setErrorCode($newErrorCode) {
  189.         $this->errorCode = $newErrorCode;
  190.     }
  191.     function setErrorDesc($newErrorDesc) {
  192.         $this->errorDesc = $newErrorDesc;
  193.     }
  194.     function setErrorType($newErrorType) {
  195.         $this->errorType = $newErrorType;
  196.     }
  197.     function getErrorCode() {
  198.         return $this->errorCode;
  199.     }
  200.     function getErrorDesc() {
  201.         return $this->errorDesc;
  202.     }
  203.     function getErrorType() {
  204.         return $this->errorType;
  205.     }
  206.     function Fault($code = "", $type = "", $desc = "") {
  207.         $this->errorCode = $code;
  208.         $this->errorType = $type;
  209.         $this->errorDesc = $desc;
  210.     }
  211.     function showErrorMessage() {
  212.  
  213.       echo "<table border=\"1\">
  214.        <tr>
  215.          <td colspan=\"2\" align=\"center\" bgcolor=\"#f00000\">Error</td>
  216.        </tr>";
  217.      
  218.  
  219.  
  220.         if (isset ($this->errorCode)) {
  221.  
  222.         echo "<tr>
  223.          <td >Code:</td>
  224.          <td>{$this->errorCode}</td>
  225.        </tr>";
  226.        
  227.  
  228.  
  229.         }
  230.         if (isset ($this->errorDesc)) {
  231.  
  232.         echo "<tr>
  233.          <td>Description:</td>
  234.          <td>{$this->errorDesc}</td>
  235.        </tr>";
  236.        
  237.  
  238.  
  239.         }
  240.         if (isset ($this->errorType)) {
  241.  
  242.         echo "<tr>
  243.          <td>Severity:</td>
  244.          <td>{$this->errorType}</td>
  245.        </tr>";
  246.        
  247.  
  248.  
  249.         }
  250.  
  251.       echo "</table>";
  252.  
  253.     }
  254.     /* save e2 client error message for log*/
  255.     function saveErrorMessage() {
  256.         $processId = getmypid();
  257.         $logFile = "/tmp/e2client".$processId.".log";
  258.         $fp = fopen($logFile, "a+");
  259.         if (!$fp) {
  260.             return;
  261.         }
  262.         fwrite($fp, $this->errorType.",".$this->errorCode.",".$this->errorDesc."\n");
  263.         fclose($fp);
  264.     }
  265. }
  266. class Param extends BasicE2XML {
  267.     /* deal with e2 session param*/
  268.     var $action;
  269.     var $name;
  270.     var $value;
  271.     function setAction($new_action) {
  272.         $this->action = $new_action;
  273.     }
  274.     function setName($new_name) {
  275.         $this->name = $new_name;
  276.     }
  277.     function setValue($new_value) {
  278.         $this->value = $new_value;
  279.     }
  280.     function getAction() {
  281.         return $this->action;
  282.     }
  283.     function getName() {
  284.         return $this->name;
  285.     }
  286.     function getValue() {
  287.         return $this->value;
  288.     }
  289.     function buildReqXml($xmldoc, $xpath) {
  290.  
  291.         $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Param", "");
  292.         $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Param", "Action", $this->action);
  293.         $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Param", "Name", $this->name);
  294.         $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Param", "Value", $this->value);
  295.         return $xmldoc;
  296.     }
  297.     function parse_param($xmldoc, $xpath) {
  298.         $xpath = $xpath."/Param";
  299.         $this->action = $this->getXpathNodeValue($xmldoc, $xpath."/Action");
  300.         $this->name = $this->getXpathNodeValue($xmldoc, $xpath."/Name");
  301.         $this->value = $this->getXpathNodeValue($xmldoc, $xpath."/Value");
  302.     }
  303. }
  304. class XMLPosting {
  305.     var $reqXML;
  306.     var $resXML;
  307.     var $url;
  308.     function setUrl($newUrl) {
  309.         $this->url = $newUrl;
  310.     }
  311.     function setReqXML($newReqXML) {
  312.         $this->reqXML = $newReqXML;
  313.     }
  314.     function getReqXML() {
  315.         return $this->reqXML;
  316.     }
  317.     function getResXML() {
  318.         return $this->resXML;
  319.     }
  320.     function postXmlMessage() {
  321.         $ch = curl_init($this->url);
  322.         curl_setopt($ch, CURLOPT_HEADER, false);
  323.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable
  324.         curl_setopt($ch, CURLOPT_POSTFIELDS, $this->reqXML); // add POST fields
  325.  
  326.         // grab URL and pass it to the browser
  327.         $this->resXML = curl_exec($ch);
  328.         // close CURL resource, and free up system resources
  329.         curl_close($ch);
  330.         return $this->resXML;
  331.     }
  332. }
  333. class E2Interface extends BasicE2XML {
  334.     /* deal with e2 xml communication,  */
  335.     var $reqXML;
  336.     var $resXML;
  337.     var $url;
  338.     function setUrl($newUrl) {
  339.         $this->url = $newUrl;
  340.     }
  341.     function setReqXML($newReqXML) {
  342.         $this->reqXML = $newReqXML;
  343.     }
  344.     function getReqXML() {
  345.         return $this->reqXML;
  346.     }
  347.     function getResXML() {
  348.         return $this->resXML;
  349.     }
  350.     function postXmlMessage() {
  351.         if (!isset ($this->url) || strlen($this->url) <= 0) {
  352.             $this->setErrorCode("Website-C0001");
  353.             $this->setErrorType("error");
  354.             $this->setErrorDesc("Invalid or no URL");
  355.             return;
  356.         }
  357.         $ch = curl_init($this->url);
  358.         if (!$ch) {
  359.             $this->setErrorCode("Website-C0001");
  360.             $this->setErrorType("error");
  361.             $this->setErrorDesc("Invalid or no URL");
  362.             return;
  363.         }
  364.         curl_setopt($ch, CURLOPT_HEADER, false);
  365.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable
  366.         curl_setopt($ch, CURLOPT_POSTFIELDS, $this->reqXML); // add POST fields
  367.  
  368.         // grab URL and pass it to the browser
  369.         $this->resXML = curl_exec($ch);
  370.         // close CURL resource, and free up system resources
  371.         curl_close($ch);
  372.         return $this->resXML;
  373.     }
  374. }
  375.  
  376. class BasicE2XML extends Fault {
  377.     /* deal with basic e2 xml funcitons*/
  378.     // service name
  379.     var $service;
  380.     // action name
  381.     var $action;
  382.     // session id
  383.     var $sessionId;
  384.     // response array
  385.     var $responseArray;
  386.  
  387.     // set service
  388.     function setService($newService) {
  389.         $this->service = $newService;
  390.     }
  391.     // set action
  392.     function setAction($newAction) {
  393.         $this->action = $newAction;
  394.     }
  395.     // get session Id
  396.     function getSessionId() {
  397.         return $this->sessionId;
  398.     }
  399.     // set session Id
  400.     function setSessionId($newSessId) {
  401.         $this->sessionId = $newSessId;
  402.     }
  403.     // get response array
  404.     function getResponseArray() {
  405.         return ($this->responseArray);
  406.     }
  407.     // add node and set value under a parent
  408.     function setXNodeValue($xd, $parent_xpath, $child, $childValue) {
  409.         $calcX = new DOMXPath($xd);
  410.         $xNodes = $calcX->query("$parent_xpath");
  411.         $ch = $xd->createElement("$child");
  412.         if ($childValue) {
  413.             $ch->nodeValue = utf8_encode($childValue);
  414.         }
  415.         // point to the last node in the xpath
  416.         $count = $xNodes->length;
  417.         /*foreach ($i = 0; $i < $count; $i ++) {
  418.             if (!$xNodes->item($i))
  419.                 break;
  420.         }
  421.         // parent node not found so return
  422.         if ($i == 0)
  423.             return;*/
  424.         if ($xNodes->item($count -1)) {
  425.             $xNodes->item($count -1)->appendChild($ch);
  426.         }
  427.         return $xd;
  428.     }
  429.     // Add attribute to a node
  430.     // Added by Yayun Sun
  431.     function setXNodeAttribute($xd, $node_xpath, $attrName, $attrValue) {
  432.         $calcX = DOMXPath($xd);
  433.         $xNodes = $calcX->query("$node_xpath");
  434.         if ($attrValue) {
  435.             $attrValue = utf8_encode($attrValue);
  436.         }
  437.         // point to the last node in the xpath
  438.         $count = $xNodes->length;
  439.         /*for ($i = 0; $i < sizeof($xNodes->nodeset); $i ++) {
  440.             if (!$xNodes->nodeset[$i])
  441.                 break;
  442.         }
  443.         // parent node not found so return
  444.         if ($i == 0)
  445.             return;*/
  446.         if ($xNodes->item($count -1)) {
  447.             $xNodes->item($count -1)->setAttribute($attrName, $attrValue);
  448.         }
  449.         return $xd;
  450.     }
  451.     //Return node value of xpath
  452.     function getXNodeValue($xd, $parent_xpath) {
  453.  
  454.         $calcX = DOMXPath($xd);
  455.         $xNodes = $calcX->query("$parent_xpath");
  456.         $ch = $xd->createElement("$child");
  457.         if ($xNodes->item(0)) {
  458.             return $xNodes->item[0]->nodeValue;
  459.         }
  460.         return "";
  461.     }
  462.  
  463.     //build header of e2 service
  464.     function buildE2XMLHeader($newService = "", $newAction = "", $newSessId = "") {
  465.         if (!isset ($this->service)) {
  466.             $this->service = $newService;
  467.         }
  468.         if (!isset ($this->action)) {
  469.             $this->action = $newAction;
  470.         }
  471.         if (!isset ($this->sessionId)) {
  472.             $this->sessionId = $newSessId;
  473.         }
  474.         $doc = new DOMDocument('1.0', 'ISO-8859-1');
  475.         $doc->formatOutput = true;
  476.         $root = $doc->createElement($this->service);
  477.         $root = $doc->appendChild($root);
  478.         $tRoot = $doc->createElement("Transaction");
  479.         $tRoot = $root->appendChild($tRoot);
  480.         $tRoot = $doc->createElement($this->action);
  481.         $tRoot = $root->appendChild($tRoot);
  482.         $doc = $this->setXNodeValue($doc, "//Transaction", "SessionID", $this->sessionId);
  483.         $doc = $this->setXNodeValue($doc, "//Transaction", "Version", "1.0");
  484.         $doc = $this->setXNodeValue($doc, "//Transaction", "Service", $this->action);
  485.         return $doc;
  486.     }
  487.     function parseNodeFault($node) {
  488.         if ($node->hasChildNodes()) {
  489.             foreach ($node->childNodes as $n) {
  490.                 //error message here
  491.                 if ($n->nodeName == 'Fault') {
  492.                     foreach ($n->childNodes as $flt) {
  493.                         if ($flt->nodeName == 'Code')
  494.                             $this->setErrorCode($flt->nodeValue);
  495.                         if ($flt->nodeName == 'Description')
  496.                             $this->setErrorDesc($flt->nodeValue);
  497.                         if ($flt->nodeName == 'Severity')
  498.                             $this->setErrorType($flt->nodeValue);
  499.                     }
  500.                     return;
  501.                 }
  502.             }
  503.         }
  504.         return;
  505.     }
  506.     // parse xml response
  507.     function parseResponse($rx) {
  508.         $doc = new DOMDocument('1.0', 'ISO-8859-1');
  509.         if (!$doc->loadXML($rx)) {
  510.             // it is done here to isolate e2 client library independant
  511.             // of client website.
  512.             $this->setErrorCode("Website-C0201");
  513.             $this->setErrorType("fatal");
  514.             $this->setErrorDesc("Error while parsing response xml document");
  515.             return;
  516.         }
  517.         $root = $doc->firstChild;
  518.         $this->parseNodeFault($root);
  519.         if (strlen($this->getErrorCode()) > 0) {
  520.             //$dom->free();
  521.             return;
  522.         }
  523.         $xml2a = new xml2array($rx);
  524.         $xa = $xml2a->getResult();
  525.         if (is_array($xa[$this->service][$this->action])) {
  526.             $this->responseArray = $xa[$this->service][$this->action];
  527.         }
  528.         //$dom->free();
  529.         return $this->responseArray;
  530.     }
  531. }
  532.  
  533. class FindAvailability extends E2Interface {
  534.     /* Deal with e2 availability*/
  535.     var $programme;
  536.     var $productType;
  537.     var $property;
  538.     var $product;
  539.     var $destination;
  540.     var $resort;
  541.     var $depart;
  542.     var $arrive;
  543.     var $adult;
  544.     var $duration;
  545.     var $startDate;
  546.     var $endDate;
  547.     var $leaves;
  548.     var $type;
  549.     var $roomTypeList;
  550.     var $availableProducts;
  551.     function setProgramme($newProgramme) {
  552.         $this->programme = $newProgramme;
  553.     }
  554.     function setProductType($newProductType) {
  555.         $this->productType = $newProductType;
  556.     }
  557.     function setProperty($newProperty) {
  558.         $this->property = $newProperty;
  559.     }
  560.     function setProduct($newProduct) {
  561.         $this->product = $newProduct;
  562.     }
  563.     function setDestination($newDestination) {
  564.         $this->destination = $newDestination;
  565.     }
  566.     function setResort($newResort) {
  567.         $this->resort = $newResort;
  568.     }
  569.     function setAdult($newAdult) {
  570.         $this->adult = $newAdult;
  571.     }
  572.     function setDuration($newDura) {
  573.         $this->duration = $newDura;
  574.     }
  575.  
  576.     function setDepart($newDepart) {
  577.         $this->depart = $newDepart;
  578.     }
  579.     function setArrive($newArrive) {
  580.         $this->arrive = $newArrive;
  581.     }
  582.     function setStartDate($newStartDate) {
  583.         $this->startDate = $newStartDate;
  584.     }
  585.     function setEndDate($newEndDate) {
  586.         $this->endDate = $newEndDate;
  587.     }
  588.  
  589.     function setLeaves($newLeaves) {
  590.         $this->leaves = $newLeaves;
  591.     }
  592.     function setType($newType) {
  593.         $this->type = $newType;
  594.     }
  595.     function setRoomTypeList($newList) {
  596.         $this->roomTypeList = $newList;
  597.     }
  598.     function setAvailableProducts($newAvailableProducts) {
  599.         $this->availableProducts = $newAvailableProducts;
  600.     }
  601.     function getProgramme() {
  602.         return $this->programme;
  603.     }
  604.     function getProductType() {
  605.         return $this->productType;
  606.     }
  607.     function getProperty() {
  608.         return $this->property;
  609.     }
  610.     function getProduct() {
  611.         return $this->product;
  612.     }
  613.     function getDestination() {
  614.         return $this->destination;
  615.     }
  616.     function getResort() {
  617.         return $this->resort;
  618.     }
  619.     function getAdult() {
  620.         return $this->adult;
  621.     }
  622.     function getDuration() {
  623.         return $this->duration;
  624.     }
  625.     function getStartDate() {
  626.         return $this->startDate;
  627.     }
  628.     function getEndDate() {
  629.         return $this->endDate;
  630.     }
  631.  
  632.     function getLeaves() {
  633.         return $this->leaves;
  634.     }
  635.     function getAvailableProducts() {
  636.         return $this->responseArray;
  637.     }
  638.     // find availability constructor
  639.     function FindAvailability($newProductType = "", $newStartDate = "", $newAdult = "0", $newLeaves = "") {
  640.         $this->service = "ReservationService";
  641.         $this->action = "FindAvailability";
  642.         $this->productType = $newProductType;
  643.         $this->startDate = $newStartDate;
  644.         $this->adult = $newAdult;
  645.         $this->leaves = $newLeaves;
  646.     }
  647.     function getAvailability($url, $sessId, $details, $newResType = "array") {
  648.         /* core member function for availability*/
  649.         $xmldoc = $this->buildRequestXMLDoc($sessId, $details);
  650.         $this->setUrl($url);
  651.         $this->setReqXML($xmldoc->saveXML());
  652.         //echo htmlentities($xmldoc->saveXML());
  653.         $resXml = $this->postXmlMessage();
  654.         //echo htmlentities($this->resXML);
  655.         if ($newResType == 'array'){
  656.           return $this->parseResponse($this->resXML);
  657.         }else{
  658.           return $resXml;
  659.         }
  660.     }
  661.     function buildRequestXMLDoc($sessId, $details) {
  662.         /* build request xml for e2 availability*/
  663.         $xmldoc = $this->buildE2XMLHeader("ReservationService", "FindAvailability", $sessId);
  664.         if (isset ($this->programme)) {
  665.             $xmldoc = $this->setXNodeValue($xmldoc, "//FindAvailability", "Programme", $this->programme);
  666.         }
  667.         if (isset ($this->productType)) {
  668.             $xmldoc = $this->setXNodeValue($xmldoc, "//FindAvailability", "ProductType", $this->productType);
  669.         }
  670.         if (isset ($this->property)) {
  671.             $xmldoc = $this->setXNodeValue($xmldoc, "//FindAvailability", "Property", $this->property);
  672.         }
  673.         if (isset ($this->product)) {
  674.             $xmldoc = $this->setXNodeValue($xmldoc, "//FindAvailability", "Product", $this->product);
  675.         }
  676.         if (isset ($this->destination)) {
  677.             $xmldoc = $this->setXNodeValue($xmldoc, "//FindAvailability", "Destination", $this->destination);
  678.         }
  679.         if (isset ($this->resort)) {
  680.             $xmldoc = $this->setXNodeValue($xmldoc, "//FindAvailability", "Resort", $this->resort);
  681.         }
  682.         if (isset ($this->startDate)) {
  683.             $xmldoc = $this->setXNodeValue($xmldoc, "//FindAvailability", "StartDate", $this->startDate);
  684.         }
  685.         if (isset ($this->endDate)) {
  686.             $xmldoc = $this->setXNodeValue($xmldoc, "//FindAvailability", "EndDate", $this->endDate);
  687.         }
  688.         if (isset ($this->duration)) {
  689.             $xmldoc = $this->setXNodeValue($xmldoc, "//FindAvailability", "Duration", $this->duration);
  690.         }
  691.         if (isset ($this->leaves)) {
  692.             $xmldoc = $this->setXNodeValue($xmldoc, "//FindAvailability", "Leaves", $this->leaves);
  693.         }
  694.         if (isset ($this->type)) {
  695.             $xmldoc = $this->setXNodeValue($xmldoc, "//FindAvailability", "Type", $this->type);
  696.         }
  697.         if (isset ($this->roomTypeList)) {
  698.             $xmldoc = $this->setXNodeValue($xmldoc, "//FindAvailability", "RoomTypeList", $this->roomTypeList);
  699.         }
  700.         if (isset ($this->adult)) {
  701.             $xmldoc = $this->setXNodeValue($xmldoc, "//FindAvailability", "Adult", $this->adult);
  702.         }
  703.         if (isset ($this->depart)) {
  704.             $xmldoc = $this->setXNodeValue($xmldoc, "//FindAvailability", "Depart", $this->depart);
  705.         }
  706.         if (isset ($this->arrive)) {
  707.             $xmldoc = $this->setXNodeValue($xmldoc, "//FindAvailability", "Arrive", $this->arrive);
  708.         }
  709.         /* for availability detail information*/
  710.         for ($index = 0; $index < sizeof($details) and isset ($details[$index]); $index ++) {
  711.             $detailFlag = $details[$index];
  712.             if ($index == 0) {
  713.                 $xmldoc = $this->setXNodeValue($xmldoc, "//FindAvailability", "Detail", "");
  714.             }
  715.             $xmldoc = $detailFlag->buildRequestXMLDoc($xmldoc, "//FindAvailability/Detail");
  716.         }
  717.         return $xmldoc;
  718.     }
  719. }
  720. class AvailDetails extends BasicE2XML {
  721.     /* deal with e2 availability details flag*/
  722.     var $flag;
  723.     var $value;
  724.     function setFlag($newFalg) {
  725.         $this->flag = $newFlag;
  726.     }
  727.     function setValue($newValue) {
  728.         $this->value = $newValue;
  729.     }
  730.     function getFlag() {
  731.         return $this->flag;
  732.     }
  733.     function getValue() {
  734.         return $this->value;
  735.     }
  736.     function AvailDetails($newFlag, $newValue) {
  737.         /* constructor*/
  738.         $this->flag = $newFlag;
  739.         $this->value = $newValue;
  740.     }
  741.     function buildRequestXMLDoc($xmldoc, $xpath) {
  742.         if (strlen($this->flag)){
  743.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, $this->flag, $this->value);
  744.         }
  745.         return $xmldoc;
  746.     }
  747. }
  748. class StartEnquiry extends E2Interface {
  749.     /* Deal with e2 StartEnquiry*/
  750.     var $source; // Booking source
  751.     var $adult; // Booking source
  752.     var $bookingNumber; // human readable booking number
  753.     var $email;  // Email address, for auto notification to be sent in addition to the email address of the E2 user
  754.     var $noStartEmail;
  755.     function setSource($newSource) {
  756.         $this->source = $newSource;
  757.     }
  758.     function setAdult($newA) {
  759.         $this->adult = $newA;
  760.     }
  761.     function setBookingNumber($newBooking) {
  762.         $this->bookingNumber = $newBooking;
  763.     }
  764.     function setEmail($newE) {
  765.         $this->email = $newE;
  766.     }
  767.     function setNoStartEmail($newN) {
  768.         $this->noStartEmail = $newN;
  769.     }
  770.     function getSource() {
  771.         return ($this->source);
  772.     }
  773.     function getBookingNumber() {
  774.         $this->bookingNumber = $this->responseArray["Success"];
  775.         return ($this->bookingNumber);
  776.     }
  777.     function StartEnquiry($newSource = "") {
  778.         /* constructor */
  779.         $this->service = "ReservationService";
  780.         $this->action = "StartEnquiry";
  781.         $this->source = $newSource;
  782.     }
  783.     function Book($url, $sessId) {
  784.         $xmldoc = $this->buildRequestXMLDoc($sessId);
  785.         //$xpost = new XMLPosting();
  786.         $this->setUrl($url);
  787.         $this->setReqXML($xmldoc->saveXML());
  788.         //echo htmlentities($xmldoc->saveXML());
  789.         $resXml = $this->postXmlMessage();
  790.         //echo htmlentities($resXml);
  791.         $this->parseResponse($this->resXML);
  792.     }
  793.     function buildRequestXMLDoc($sessId) {
  794.         /* build request xml for e2 StartEnquiry*/
  795.         $service = $this->action;
  796.         $xmldoc = $this->buildE2XMLHeader($this->service, $service, $sessId);
  797.         if (isset ($this->source)) {
  798.             $xmldoc = $this->setXNodeValue($xmldoc, "//".$service, "Source", $this->source);
  799.         }
  800.         if (isset ($this->adult)) {
  801.             $xmldoc = $this->setXNodeValue($xmldoc, "//".$service, "Adult", $this->adult);
  802.         }
  803.         if (isset($this->email)) {
  804.             $xmldoc = $this->setXNodeValue($xmldoc, "//".$service, "Email", $this->email);
  805.         }
  806.         if (isset($this->noStartEmail) && $this->noStartEmail) {
  807.             $xmldoc = $this->setXNodeValue($xmldoc, "//".$service, "NoStartEmail", "");
  808.         }
  809.         return $xmldoc;
  810.     }
  811.  
  812. }
  813. class PrepareDetails extends E2Interface {
  814.     /* Deal with e2 PrepareDetails*/
  815.     /* it is compatible with single product*/
  816.     var $type;
  817.     var $product;
  818.     var $suppCode;
  819.     var $suppDepDate;
  820.     var $suppDur;
  821.     var $details;
  822.     function setType($newType) {
  823.         $this->type = $newType;
  824.     }
  825.     function setProduct($newProduct) {
  826.         $this->product = $newProduct;
  827.     }
  828.     function setSupplementCode($newSuppCode) {
  829.         $this->suppCode = $newSuppCode;
  830.     }
  831.     function setSupplementDeparture($newSuppDep) {
  832.         $this->suppDepDate = $newSuppDep;
  833.     }
  834.     function setSupplementDuration($newSuppDur) {
  835.         $this->suppDur = $newSuppDur;
  836.     }
  837.     function setDetails($newDetails) {
  838.         $this->lineStyleArray = $newDetails;
  839.     }
  840.     function getType() {
  841.         return ($this->type);
  842.     }
  843.     function getProduct() {
  844.         return ($this->product);
  845.     }
  846.     function getDetails() {
  847.         return ($this->responseArray);
  848.     }
  849.     function PrepareDetails($newType = "", $newProduct = "") {
  850.         /* constructor */
  851.         $this->service = "ReservationService";
  852.         $this->action = "PrepareDetails";
  853.         $this->type = $newType;
  854.         $this->product = $newProduct;
  855.     }
  856.     function prepare($url, $sessId) {
  857.         $xmldoc = $this->buildRequestXMLDoc($sessId);
  858.         //$xpost = new XMLPosting();
  859.         $this->setUrl($url);
  860.         $this->setReqXML($xmldoc->saveXML());
  861.         //echo htmlentities($xmldoc->saveXML());
  862.         $resXml = $this->postXmlMessage();
  863.         //echo htmlentities($resXml);
  864.         $this->parseResponse($this->resXML);
  865.     }
  866.     function buildRequestXMLDoc($sessId) {
  867.         /* build request xml for e2 StartEnquiry*/
  868.         $service = $this->action;
  869.         $xmldoc = $this->buildE2XMLHeader($this->service, $service, $sessId);
  870.         $xmldoc = $this->setXNodeValue($xmldoc, "//".$service, "Product", "");
  871.         if (isset ($this->type)) {
  872.             $xmldoc = $this->setXNodeValue($xmldoc, "//".$service."/Product", "ProductType", $this->type);
  873.         }
  874.         if (isset ($this->product)) {
  875.             $xmldoc = $this->setXNodeValue($xmldoc, "//".$service."/Product", "ProductCode", $this->product);
  876.         }
  877.         if (isset ($this->suppCode)) {
  878.             $xmldoc = $this->setXNodeValue($xmldoc, "//".$service."/Product", "SupplementCode", $this->suppCode);
  879.         }
  880.         if (isset ($this->suppDepDate)) {
  881.             $xmldoc = $this->setXNodeValue($xmldoc, "//".$service."/Product", "SupplementDepartDate", $this->suppDepDate);
  882.         }
  883.         if (isset ($this->suppDur)) {
  884.             $xmldoc = $this->setXNodeValue($xmldoc, "//".$service."/Product", "SupplementDuration", $this->suppDur);
  885.         }
  886.         return $xmldoc;
  887.     }
  888. }
  889. class BookProduct extends E2Interface {
  890.     /* Deal with e2 BookProduct*/
  891.     /* it is dealt with single product*/
  892.     var $products;
  893.     var $transactionDetails; // have array of bookproduct response
  894.     function setType($newType) {
  895.         $this->type = $newType;
  896.     }
  897.     function setProducts($newProducts) {
  898.         $this->products = $newProducts;
  899.     }
  900.     function setTransactionDetails($newTrans) {
  901.         $this->transactionDetails = $newTrans;
  902.     }
  903.     function getType() {
  904.         return ($this->type);
  905.     }
  906.     function getProducts() {
  907.         return ($this->products);
  908.     }
  909.     function getTransactionDetails() {
  910.         return ($this->responseArray);
  911.     }
  912.     function BookProduct($newURL, $sessId, $newProducts = "") {
  913.         /* constructor */
  914.         $this->service = "ReservationService";
  915.         $this->action = "BookProduct";
  916.         $this->sessionId = $sessId;
  917.         $this->url = $newURL;
  918.         $this->products = $newProducts;
  919.     }
  920.     function AddTransaction() {
  921.         $xmldoc = $this->buildRequestXMLDoc();
  922.         $this->setReqXML($xmldoc->saveXML());
  923.         //echo htmlentities($xmldoc->saveXML());
  924.         $resXml = $this->postXmlMessage();
  925.         //echo htmlentities($resXml);
  926.         $this->parseResponse($this->resXML);
  927.     }
  928.     function buildRequestXMLDoc() {
  929.         /* build request xml for e2 BookProduct*/
  930.         $xmldoc = $this->buildE2XMLHeader($this->service, $this->action, $sessId);
  931.         $xpath = "//".$this->action;
  932.         if (isset ($this->products) && is_array($this->products)) {
  933.             foreach ($this->products as $p) {
  934.                 $xmldoc = $p->buildRequestXMLDoc($xmldoc, $xpath);
  935.             }
  936.         }
  937.         return $xmldoc;
  938.     }
  939. }
  940. class Product extends E2Interface {
  941.     /* Deal with e2 BookProduct*/
  942.     /* it is dealt with single product*/
  943.     var $type;
  944.     var $product;
  945.     var $currency;
  946.     var $packageDate;
  947.     var $transactionNumber;
  948.     var $lineStyle;
  949.     var $lineStyleValue;
  950.     var $sellPriceOverride;
  951.     var $costPriceOverride;
  952.     function setType($newType) {
  953.         $this->type = $newType;
  954.     }
  955.     function setProduct($newProduct) {
  956.         $this->product = $newProduct;
  957.     }
  958.     function setPackageDate ($newpd) {
  959.         $this->packageDate = $newpd;
  960.     }
  961.     function setTransactionNumber($newTransNo){
  962.         $this->transactionNumber = $newTransNo;
  963.     }
  964.     function getTransactionNumber(){
  965.         $this->transactionNumber;
  966.     }
  967.     function setCurrency ($newcur) {
  968.        $this->currency = $newcur;
  969.     }
  970.     function setLineStyle($newLS) {
  971.         $this->lineStyle = $newLS;
  972.     }
  973.     function setLineStyleValue($newLSValue) {
  974.         $this->lineStyleValue = $newLSValue;
  975.     }
  976.     function setSellPriceOverride($priceOverride){
  977.         $this->sellPriceOverride = $priceOverride;
  978.     }
  979.     function setCostPriceOverride($priceOverride){
  980.         $this->costPriceOverride = $priceOverride;
  981.     }
  982.     function getType() {
  983.         return ($this->type);
  984.     }
  985.     function getProduct() {
  986.         return ($this->product);
  987.     }
  988.     function Product($newType = "", $newProduct = "", $ls = "", $lsValue = "") {
  989.         /* constructor */
  990.         $this->service = "ReservationService";
  991.         $this->action = "BookProduct";
  992.         $this->type = $newType;
  993.         $this->product = $newProduct;
  994.         $this->lineStyle = $ls;
  995.         $this->lineStyleValue = $lsValue;
  996.     }
  997.     function buildRequestXMLDoc($xmldoc, $xpath) {
  998.         /* build request xml for e2 Product*/
  999.         $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Product", "");
  1000.         $xpath = $xpath."/Product";
  1001.         // when supplement booking
  1002.         if ($this->type == "SUP"){
  1003.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "TransactionNumber", $this->transactionNumber);
  1004.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Supplements", "");
  1005.             $xpath = $xpath."/Supplements";
  1006.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Supplement", "");
  1007.             $xpath = $xpath."/Supplement";
  1008.         }
  1009.         if (isset ($this->type)) {
  1010.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "ProductType", $this->type);
  1011.         }
  1012.         if (isset ($this->product)) {
  1013.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "ProductCode", $this->product);
  1014.         }
  1015.         if (isset ($this->packageDate)) {
  1016.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "PackageDate", $this->packageDate);
  1017.         }
  1018.         if (isset ($this->currency)) {
  1019.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Currency", $this->currency);
  1020.         }
  1021.         if (isset($this->sellPriceOverride)){
  1022.             $xmldoc = $this->sellPriceOverride->buildReqXML($xmldoc, $xpath);
  1023.         }
  1024.         if (isset($this->costPriceOverride)){
  1025.             $xmldoc = $this->costPriceOverride->buildReqXML($xmldoc, $xpath);
  1026.         }
  1027.         /* add lines style value*/
  1028.         if (is_array($this->lineStyle)) {
  1029.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "LineStyleDetails", "");
  1030.             $xpath = $xpath."/LineStyleDetails";
  1031.             foreach ($this->lineStyle as $line) {
  1032.                 $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "LineStyle", "");
  1033.                 $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/LineStyle", "Field", $line["Field"]);
  1034.                 $lsValue = "";
  1035.                 if (isset ($this->lineStyleValue[strtoupper($line["Field"])])) {
  1036.                     $lsValue = $this->lineStyleValue[strtoupper($line["Field"])];
  1037.                 }
  1038.                 if (strlen($lsValue) == 0){
  1039.                   $lsValue = $line["Value"];
  1040.                 }
  1041.                 $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/LineStyle", "Value", $lsValue);
  1042.             }
  1043.         }
  1044.         return $xmldoc;
  1045.     }
  1046. }
  1047.  
  1048. class BookingInfo extends BasicE2XML {
  1049.     /* Deal with e2 BookingInfo*/
  1050.     /* Now this class is deprecated to use*/
  1051.     /* you suggested to use BookingDetails which is */
  1052.     /* more organised*/
  1053.     var $bookingNumber; // human readable booking number
  1054.     var $bookingSummary; // flag for booking summary details
  1055.     var $transactions; // flag for transaction details
  1056.     var $pax; // flag for passenger details
  1057.     var $notes; // flag for booking notes details
  1058.     var $autoNotes; // flag for auto booking notes details
  1059.     var $docs; // flag for booking docs details
  1060.     var $toggleOrder; // flag for toggle itinerary order
  1061.     var $showCanx; // flag for showing cancelled lines
  1062.     var $info; // info array
  1063.     function setBookingNumber($newB = "") {
  1064.         $this->bookingNumber = $newB;
  1065.     }
  1066.     function setBookingSummary($newBS = "") {
  1067.         $this->bookingSummary = $newBS;
  1068.     }
  1069.     function setTransactions($newT = "") {
  1070.         $this->transaction = $newT;
  1071.     }
  1072.     function setPax($newP = "") {
  1073.         $this->pax = $newP;
  1074.     }
  1075.     function setNotes($newN = "") {
  1076.         $this->notes = $newN;
  1077.     }
  1078.     function setAutoNotes($newA = "") {
  1079.         $this->autoNotes = $newA;
  1080.     }
  1081.     function setDocs($newD = "") {
  1082.         $this->docs = $newD;
  1083.     }
  1084.     function setToggleOrder($newTG = "") {
  1085.         $this->toggleOrder = $newTG;
  1086.     }
  1087.     function setShowCanx($newSC = "") {
  1088.         $this->showCanx = $newSC;
  1089.     }
  1090.     function setInfo($newI) {
  1091.         $this->info = $newI;
  1092.     }
  1093.     function getBookingNumber() {
  1094.         return $this->bookingNumber;
  1095.     }
  1096.     function getBookingSummary() {
  1097.         return $this->bookingSummary;
  1098.     }
  1099.     function getTransactions() {
  1100.         return $this->transaction;
  1101.     }
  1102.     function getPax() {
  1103.         return $this->pax;
  1104.     }
  1105.     function getNotes() {
  1106.         return $this->notes;
  1107.     }
  1108.     function getDocs() {
  1109.         return $this->docs;
  1110.     }
  1111.     function getToggleOrder() {
  1112.         return $this->toggleOrder;
  1113.     }
  1114.     function getShowCanx() {
  1115.         return $this->showCanx;
  1116.     }
  1117.     function getInfo() {
  1118.         return $this->info;
  1119.     }
  1120.     function BookingInfo($newBookingNumber = "") {
  1121.         /* constructor */
  1122.         $this->bookingNumber = $newBookingNumber;
  1123.     }
  1124.     function findInfo($url, $sessId) {
  1125.         $xmldoc = $this->buildRequestXMLDoc($sessId);
  1126.         $xpost = new XMLPosting();
  1127.         $xpost->setUrl($url);
  1128.         $xpost->setReqXML($xmldoc->saveXML());
  1129.         //echo htmlentities($xmldoc->saveXML());
  1130.         $resXml = $xpost->postXmlMessage();
  1131.         //echo htmlentities($resXml);
  1132.         $this->parseResponse($resXml);
  1133.     }
  1134.     function buildRequestXMLDoc($sessId) {
  1135.         /* build request xml for e2 BookingInfo*/
  1136.         $service_name = "BookingInfo";
  1137.         $xmldoc = $this->buildE2XMLHeader("ReservationService", $service_name, $sessId);
  1138.         $xpath = "//".$service_name;
  1139.         if (isset ($this->bookingNumber)) {
  1140.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "BookingNumber", $this->bookingNumber);
  1141.         }
  1142.         $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "DetailLevel", "");
  1143.         $xpath = $xpath."/DetailLevel";
  1144.         if (isset ($this->bookingSummary)) {
  1145.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "BookingSummary", "");
  1146.         }
  1147.         if (isset ($this->transaction)) {
  1148.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Transactions", "");
  1149.         }
  1150.         if (isset ($this->pax)) {
  1151.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Pax", "");
  1152.         }
  1153.         if (isset ($this->notes)) {
  1154.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Notes", "");
  1155.         }
  1156.         if (isset ($this->autoNotes)) {
  1157.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "AutoNotes", "");
  1158.         }
  1159.         if (isset ($this->docs)) {
  1160.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Docs", "");
  1161.         }
  1162.         if (isset ($this->toggleOrder)) {
  1163.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "ToggleOrder", "");
  1164.         }
  1165.         if (isset ($this->showCanx)) {
  1166.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "ShowCanx", "");
  1167.         }
  1168.         return $xmldoc;
  1169.     }
  1170.     function parseResponse($rx) {
  1171.         $doc = new DOMDocument('1.0', 'ISO-8859-1');
  1172.         if (!$doc->loadXML($rx)) {
  1173.             // it is done here to isolate e2 client library independant
  1174.             // of client website.
  1175.             $this->setErrorCode("Website-C0201");
  1176.             $this->setErrorType("fatal");
  1177.             $this->setErrorDesc("Error while parsing response xml document");
  1178.             return;
  1179.         }
  1180.         $root = $doc->firstChild;
  1181.         $this->parseNodeFault($root);
  1182.         if (strlen($this->getErrorCode()) > 0) {
  1183.             //$dom->free();
  1184.             return;
  1185.         }
  1186.         $xml2a = new xml2array($rx);
  1187.         $xa = $xml2a->getResult();
  1188.         if (is_array($xa['ReservationService']["$service_name"])) {
  1189.             $this->info = $xa['ReservationService']["$service_name"];
  1190.         }
  1191.         //$dom->free();
  1192.     }
  1193. }
  1194. class CancelTransaction extends E2Interface {
  1195.     /* Deal with e2 CancelTransaction*/
  1196.     /* it is dealt with multiple transaction*/
  1197.     var $transArray; // store array xsaction number
  1198.     function setTransArray($newTA) {
  1199.         $this->transArray = $newTA;
  1200.     }
  1201.     function getTransArray() {
  1202.         return $this->transArray;
  1203.     }
  1204.     function CancelTransaction($newTA = "") {
  1205.         /* constructor */
  1206.         $this->service = "ReservationService";
  1207.         $this->action = "CancelTransaction";
  1208.         $this->transArray = $newTA;
  1209.     }
  1210.     function cancel($url, $sessId) {
  1211.         $xmldoc = $this->buildRequestXMLDoc($sessId);
  1212.         $this->setUrl($url);
  1213.         $this->setReqXML($xmldoc->saveXML());
  1214.         //echo htmlentities($xmldoc->saveXML());
  1215.         $resXml = $this->postXmlMessage();
  1216.         //echo htmlentities($resXml);
  1217.         $this->parseResponse($this->resXML);
  1218.     }
  1219.     function buildRequestXMLDoc($sessId) {
  1220.         /* build request xml for e2 CancelTransaction */
  1221.         $service_name = $this->action;
  1222.         $xmldoc = $this->buildE2XMLHeader($this->service, $service_name, $sessId);
  1223.         $xpath = "//".$service_name;
  1224.         /* add cancel lines */
  1225.         if (is_array($this->transArray)) {
  1226.             foreach ($this->transArray as $cl) {
  1227.                 $trans_no = $cl;
  1228.                 if (strpos($cl, ":") >= 0){
  1229.                     list($trans_no, $supp_no) = split("\+", $cl);
  1230.                 }
  1231.                 $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "BookingTransaction", "");
  1232.                 $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/BookingTransaction", "TransactionNumber", $trans_no);
  1233.                 if (strlen($supp_no)){
  1234.                     $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/BookingTransaction", "SupplementNumber", $supp_no);
  1235.                 }
  1236.             }
  1237.         }
  1238.         return $xmldoc;
  1239.     }
  1240. }
  1241. class AddPassenger extends E2Interface {
  1242.         /* Obsolate to use this class, Please use PassengerService*/
  1243.     /* Deal with e2 AddPassenger*/
  1244.     /* it is dealt with multiple pax*/
  1245.     var $paxArray; // store array pax
  1246.     var $paxStyleArray; // store pax style value
  1247.     function setPaxArray($newPA) {
  1248.         $this->paxArray = $newPA;
  1249.     }
  1250.     function setPaxStyleArray($newPX) {
  1251.         $this->paxStyleArray = $newPX;
  1252.     }
  1253.     function getPaxArray() {
  1254.         return $this->paxArray;
  1255.     }
  1256.     function AddPassenger($newPA = "", $newPX = "") {
  1257.         /* constructor */
  1258.         $this->service = "ReservationService";
  1259.         $this->action = "AddPassenger";
  1260.         $this->paxArray = $newPA;
  1261.         $this->paxStyleArray = $newPX;
  1262.     }
  1263.     function add($url, $sessId) {
  1264.         $xmldoc = $this->buildRequestXMLDoc($sessId);
  1265.         $this->setUrl($url);
  1266.         $this->setReqXML($xmldoc->saveXML());
  1267.         //echo htmlentities($xmldoc->saveXML());
  1268.         $resXml = $this->postXmlMessage();
  1269.         //echo htmlentities($resXml);
  1270.         $this->parseResponse($this->resXML);
  1271.     }
  1272.     function buildRequestXMLDoc($sessId) {
  1273.         /* build request xml for e2 CancelTransaction */
  1274.         $service_name = $this->action;
  1275.         $xmldoc = $this->buildE2XMLHeader($this->service, $service_name, $sessId);
  1276.         $xpath = "//".$service_name;
  1277.         /* add paxs */
  1278.         if (is_array($this->paxArray)) {
  1279.             foreach ($this->paxArray as $px) {
  1280.                 $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Passenger", "");
  1281.                 if (isset ($px["Title"])) {
  1282.                     $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "Title", $px["Title"]);
  1283.                 }
  1284.                 if (isset ($px["Firstname"])) {
  1285.                     $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "Firstname", $px["Firstname"]);
  1286.                 }
  1287.                 if (isset ($px["Lastname"])) {
  1288.                     $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "Lastname", $px["Lastname"]);
  1289.                 }
  1290.                 if (isset ($px["Gender"])) {
  1291.                     $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "Gender", $px["Gender"]);
  1292.                 }
  1293.                 if (isset ($px["BirthDate"])) {
  1294.                     $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "BirthDate", $px["BirthDate"]);
  1295.                 }
  1296.                 if (isset ($px["Age"])) {
  1297.                     $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "Age", $px["Age"]);
  1298.                 }
  1299.                 if (isset ($px["InfantAge"])) {
  1300.                     $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "InfantAge", $px["InfantAge"]);
  1301.                 }
  1302.                 if (isset ($px["Smoker"])) {
  1303.                     $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "Smoker", $px["Smoker"]);
  1304.                 }
  1305.                 /* add paxs style value */
  1306.                 if (is_array($this->paxStyleArray)) {
  1307.                     $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "PaxStyleDetails", "");
  1308.                     $pxs_path = "/Passenger/PaxStyleDetails";
  1309.                     foreach ($this->paxStyleArray as $pxs) {
  1310.                         $xmldoc = $this->setXNodeValue($xmldoc, $xpath.$pxs_path, "PaxStyle", "");
  1311.                         //print ($this->paxStyleValueArray[$pxs["Field"]]);
  1312.                         if (isset ($px[$pxs["Field"]])) {
  1313.                             $xmldoc = $this->setXNodeValue($xmldoc, $xpath.$pxs_path."/PaxStyle", "Field", $pxs["Field"]);
  1314.                             $xmldoc = $this->setXNodeValue($xmldoc, $xpath.$pxs_path."/PaxStyle", "Value", $px[$pxs["Field"]]);
  1315.                         }
  1316.                     }
  1317.                 }
  1318.             }
  1319.         }
  1320.         return $xmldoc;
  1321.     }
  1322. }
  1323. class UpdatePassenger extends E2Interface {
  1324.     /* Deal with e2 UpdatePassenger*/
  1325.     /* it is dealt with multiple pax*/
  1326.     /* Added by Yayun Sun*/
  1327.     var $paxArray; // store array pax
  1328.     var $paxStyleArray; // store pax style value
  1329.     function setPaxArray($newPA) {
  1330.         $this->paxArray = $newPA;
  1331.     }
  1332.     function setPaxStyleArray($newPX) {
  1333.         $this->paxStyleArray = $newPX;
  1334.     }
  1335.     function getPaxArray() {
  1336.         return $this->paxArray;
  1337.     }
  1338.     function UpdatePassenger($newPA = "", $newPX = "") {
  1339.         /* constructor */
  1340.         $this->service = "ReservationService";
  1341.         $this->action = "UpdatePassenger";
  1342.         $this->paxArray = $newPA;
  1343.         $this->paxStyleArray = $newPX;
  1344.     }
  1345.     function update($url, $sessId) {
  1346.         $xmldoc = $this->buildRequestXMLDoc($sessId);
  1347.         $this->setUrl($url);
  1348.         $this->setReqXML($xmldoc->saveXML());
  1349.         //echo htmlentities($xmldoc->saveXML());
  1350.         $resXml = $this->postXmlMessage();
  1351.         //echo htmlentities($resXml);
  1352.         $this->parseResponse($this->resXML);
  1353.     }
  1354.     function buildRequestXMLDoc($sessId) {
  1355.         /* build request xml for e2 UpdatePassenger */
  1356.         $service_name = $this->action;
  1357.         $xmldoc = $this->buildE2XMLHeader($this->service, $service_name, $sessId);
  1358.         $xpath = "//".$service_name;
  1359.         /* add paxs */
  1360.         if (is_array($this->paxArray)) {
  1361.             foreach ($this->paxArray as $px) {
  1362.                 $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Passenger", "");
  1363.                 if (isset ($px["PaxCode"])) {
  1364.                     $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "PaxCode", $px["PaxCode"]);
  1365.                 }
  1366.                 if (isset ($px["Title"])) {
  1367.                     $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "Title", $px["Title"]);
  1368.                 }
  1369.                 if (isset ($px["Firstname"])) {
  1370.                     $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "Firstname", $px["Firstname"]);
  1371.                 }
  1372.                 if (isset ($px["Lastname"])) {
  1373.                     $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "Lastname", $px["Lastname"]);
  1374.                 }
  1375.                 if (isset ($px["Gender"])) {
  1376.                     $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "Gender", $px["Gender"]);
  1377.                 }
  1378.                 if (isset ($px["BirthDate"])) {
  1379.                     $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "BirthDate", $px["BirthDate"]);
  1380.                 }
  1381.                 if (isset ($px["Age"])) {
  1382.                     $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "Age", $px["Age"]);
  1383.                 }
  1384.                 if (isset ($px["AgeCategory"])) {
  1385.                     $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "AgeCategory", $px["AgeCategory"]);
  1386.                 }
  1387.                 if (isset ($px["InfantAge"])) {
  1388.                     $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "InfantAge", $px["InfantAge"]);
  1389.                 }
  1390.                 if (isset ($px["Smoker"])) {
  1391.                     $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "Smoker", $px["Smoker"]);
  1392.                 }
  1393.                 /* add paxs style value */
  1394.                 if (is_array($this->paxStyleArray)) {
  1395.                     $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "PaxStyleDetails", "");
  1396.                     $pxs_path = "/Passenger/PaxStyleDetails";
  1397.                     foreach ($this->paxStyleArray as $pxs) {
  1398.                         $xmldoc = $this->setXNodeValue($xmldoc, $xpath.$pxs_path, "PaxStyle", "");
  1399.                         if (isset ($px[$pxs["Field"]])) {
  1400.                             $xmldoc = $this->setXNodeValue($xmldoc, $xpath.$pxs_path."/PaxStyle", "Field", $pxs["Field"]);
  1401.                             $xmldoc = $this->setXNodeValue($xmldoc, $xpath.$pxs_path."/PaxStyle", "Value", $px[$pxs["Field"]]);
  1402.                         }
  1403.                     }
  1404.                 }
  1405.             }
  1406.         }
  1407.         return $xmldoc;
  1408.     }
  1409. }
  1410. class PreparePassenger extends E2Interface {
  1411.         /* Obsolate to use this class, Please use PassengerService*/
  1412.     /* Deal with e2 PreparePassenger*/
  1413.     function PreparePassenger() {
  1414.         $this->service = "ReservationService";
  1415.         $this->action = "PreparePassenger";
  1416.         /* constructor */
  1417.     }
  1418.     function prepare($url, $sessId) {
  1419.         $xmldoc = $this->buildRequestXMLDoc($sessId);
  1420.         $this->setUrl($url);
  1421.         $this->setReqXML($xmldoc->saveXML());
  1422.         //echo htmlentities($xmldoc->saveXML());
  1423.         $resXml = $this->postXmlMessage();
  1424.         //echo htmlentities($resXml);
  1425.         $this->parseResponse($this->resXML);
  1426.     }
  1427.     function buildRequestXMLDoc($sessId) {
  1428.         /* build request xml for e2 CancelTransaction */
  1429.         $service_name = $this->action;
  1430.         $xmldoc = $this->buildE2XMLHeader($this->service, $service_name, $sessId);
  1431.         return $xmldoc;
  1432.     }
  1433. }
  1434. class PassengerService extends E2Interface {
  1435.     /* Deal with e2 AddPassenger, prepare passenger, update passenger*/
  1436.     /* it is dealt with multiple pax*/
  1437.     var $paxArray; // store array pax
  1438.     var $paxStyleArray; // store pax style value
  1439.     var $skipNumberCheck; // whether to skip number check on names
  1440.     function setPaxArray($newPA) {
  1441.         $this->paxArray = $newPA;
  1442.     }
  1443.     function setPaxStyleArray($newPX) {
  1444.         $this->paxStyleArray = $newPX;
  1445.     }
  1446.     function setSkipNumberCheck($newS) {
  1447.         $this->setSkipNumberCheck = $newS;
  1448.     }
  1449.     function getPaxArray() {
  1450.         return $this->paxArray;
  1451.     }
  1452.     function PassengerService($newAction, $url, $sessId) {
  1453.         /* constructor */
  1454.         $this->service = "ReservationService";
  1455.         $this->action = $newAction;
  1456.         $this->url = $url;
  1457.         $this->sessionId = $sessId;
  1458.     }
  1459.  
  1460.     function perform() {
  1461.         $xmldoc = $this->buildRequestXMLDoc();
  1462.         $this->setReqXML($xmldoc->saveXML());
  1463.         //echo htmlentities($xmldoc->saveXML());
  1464.         $resXml = $this->postXmlMessage();
  1465.         //echo htmlentities($resXml);
  1466.         $this->responseArray = $this->parseResponse($resXml);
  1467.         return $this->responseArray;
  1468.     }
  1469.     function buildRequestXMLDoc() {
  1470.         /* build request xml for e2 CancelTransaction */
  1471.         $service_name = $this->action;
  1472.         $xmldoc = $this->buildE2XMLHeader($this->service, $service_name, $this->sessionId);
  1473.         $xpath = "//".$service_name;
  1474.         /* add paxs */
  1475.         if (is_array($this->paxArray) && $this->action != 'PreparePassenger') {
  1476.             foreach ($this->paxArray as $px) {
  1477.                 $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Passenger", "");
  1478.                 if (isset ($px["PaxCode"])) {
  1479.                     $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "PaxCode", $px["PaxCode"]);
  1480.                 }
  1481.                 if (isset ($px["Title"])) {
  1482.                     $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "Title", $px["Title"]);
  1483.                 }
  1484.                 if (isset ($px["Firstname"])) {
  1485.                     $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "Firstname", $px["Firstname"]);
  1486.                 }
  1487.                 if (isset ($px["Lastname"])) {
  1488.                     $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "Lastname", $px["Lastname"]);
  1489.                 }
  1490.                 if (isset ($px["Gender"])) {
  1491.                     $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "Gender", $px["Gender"]);
  1492.                 }
  1493.                 if (isset ($px["BirthDate"])) {
  1494.                     $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "BirthDate", $px["BirthDate"]);
  1495.                 }
  1496.                 if (isset ($px["InfantAge"])) {
  1497.                     $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "InfantAge", $px["InfantAge"]);
  1498.                 }
  1499.                 if (isset ($px["Smoker"])) {
  1500.                     $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "Smoker", $px["Smoker"]);
  1501.                 }
  1502.                 /* add paxs style value */
  1503.                 if (is_array($this->paxStyleArray)) {
  1504.                     $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Passenger", "PaxStyleDetails", "");
  1505.                     $pxs_path = "/Passenger/PaxStyleDetails";
  1506.                     foreach ($this->paxStyleArray as $pxs) {
  1507.                         $xmldoc = $this->setXNodeValue($xmldoc, $xpath.$pxs_path, "PaxStyle", "");
  1508.                         //print ($this->paxStyleValueArray[$pxs["Field"]]);
  1509.                         if (isset ($px[$pxs["Field"]])) {
  1510.                             $xmldoc = $this->setXNodeValue($xmldoc, $xpath.$pxs_path."/PaxStyle", "Field", $pxs["Field"]);
  1511.                             $xmldoc = $this->setXNodeValue($xmldoc, $xpath.$pxs_path."/PaxStyle", "Value", $px[$pxs["Field"]]);
  1512.                         }
  1513.                     }
  1514.                 }
  1515.             }
  1516.         }
  1517.         if ($this->setSkipNumberCheck) {
  1518.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "SkipNumberCheck", "");
  1519.         }
  1520.         return $xmldoc;
  1521.     }
  1522. }
  1523.  
  1524. class FindAcceptedCards extends E2Interface {
  1525.     var $cardType;
  1526.     function setCardType($newCT) {
  1527.       $this->cardType = $newCT;
  1528.     }
  1529.     function FindAcceptedCards($url, $sessId, $newCT="") {
  1530.       $this->service = "PaymentService";
  1531.       $this->action = "FindAcceptedCards";
  1532.       $this->url = $url;
  1533.       $this->sessionId = $sessId;
  1534.       $this->cardType = $newCT;
  1535.     }
  1536.     function find() {
  1537.       $xmldoc = $this->buildRequestXMLDoc();
  1538.       $this->setReqXML($xmldoc->saveXML());
  1539.       //echo htmlentities($xmldoc->saveXML());
  1540.       $resXml = $this->postXmlMessage();
  1541.       //echo htmlentities($resXml);
  1542.       $this->parseResponse($this->resXML);
  1543.     }
  1544.     function buildRequestXMLDoc() {
  1545.       /* build request xml for e2 CancelTransaction */
  1546.       $xmldoc = $this->buildE2XMLHeader();
  1547.       $xpath = "//".$this->action;
  1548.       if (isset ($this->paymentType)) {
  1549.         $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "CardType", $this->cardType);
  1550.       }
  1551.       return $xmldoc;
  1552.     }
  1553. }
  1554.  
  1555. class PreviousCards extends E2Interface {
  1556.     var $clientCode;
  1557.     function setClientCode($newCL) {
  1558.       $this->clientCode = $newCL;
  1559.     }
  1560.     function PreviousCards($url, $sessId, $newCL="") {
  1561.       $this->service = "PaymentService";
  1562.       $this->action = "PreviousCards";
  1563.       $this->url = $url;
  1564.       $this->sessionId = $sessId;
  1565.       $this->clientCode = $newCL;
  1566.     }
  1567.     function find() {
  1568.       $xmldoc = $this->buildRequestXMLDoc();
  1569.       $this->setReqXML($xmldoc->saveXML());
  1570.       //echo htmlentities($xmldoc->saveXML());
  1571.       $resXml = $this->postXmlMessage();
  1572.       //echo htmlentities($resXml);
  1573.       $this->parseResponse($this->resXML);
  1574.       return $this->responseArray;
  1575.     }
  1576.     function buildRequestXMLDoc() {
  1577.       /* build request xml for e2 CancelTransaction */
  1578.       $xmldoc = $this->buildE2XMLHeader();
  1579.       $xpath = "//".$this->action;
  1580.       if (isset ($this->clientCode)) {
  1581.         $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "ClientCode", $this->clientCode);
  1582.       }
  1583.       return $xmldoc;
  1584.     }
  1585. }
  1586.  
  1587. class AcceptPayment extends E2Interface {
  1588.     /* Deal with e2 AcceptPayment */
  1589.     var $paymentType;
  1590.     var $amount;
  1591.     var $paymentDate;
  1592.     var $note;
  1593.     /*var $chequeNo; // cheque payment is not necessary yet
  1594.     var $authCode;*/
  1595.     function setPaymentType($newPT) {
  1596.         $this->paymentType = $newPT;
  1597.     }
  1598.     function setAmount($newA) {
  1599.         $this->amount = $newA;
  1600.     }
  1601.     function setPaymentDate($newPD) {
  1602.         $this->paymentDate = $newPD;
  1603.     }
  1604.     function setNote($newN) {
  1605.         $this->note = $newN;
  1606.     }
  1607.     /*function setChequeNo ($newCN) {
  1608.         $this->chequeNo =$newCN;
  1609.     }
  1610.     function setAuthCode ($newAC) {
  1611.         $this->authCode = $newAC;
  1612.     }*/
  1613.     function AcceptPayment($pType = "", $amnt = 0) {
  1614.         $this->paymentType = $pType;
  1615.         $htis->amount = $amnt;
  1616.     }
  1617. }
  1618. class CCPayment extends AcceptPayment {
  1619.     var $collectInFuture;
  1620.     var $cardType;
  1621.     var $cardNo;
  1622.     var $expires;
  1623.     var $startDate;
  1624.     var $issueNo;
  1625.     var $securityCode;
  1626.     var $charge;
  1627.     var $authOption;
  1628.     var $authCode;
  1629.     var $previousCardRef;
  1630.     var $cardHolder; // will hold CardHolder object
  1631.     var $threeDSecureStep; // ThreeDSecure step verify or finalise
  1632.     var $paResFile;
  1633.     var $datacashReference;
  1634.     function setCollectionInFuture($newCIF) {
  1635.         $this->collectInFuture = $newCIF;
  1636.     }
  1637.     function setCardType($newCT) {
  1638.         $this->cardType = $newCT;
  1639.     }
  1640.     function setCardNo($newCN) {
  1641.         $this->cardNo = $newCN;
  1642.     }
  1643.     function setStartDate($newSD) {
  1644.         $this->startDate = $newSD;
  1645.     }
  1646.     function setExpires($newE) {
  1647.         $this->expires = $newE;
  1648.     }
  1649.     function setIssueNo($newIN) {
  1650.         $this->issueNo = $newIN;
  1651.     }
  1652.     function setSecurityCode($newSC) {
  1653.         $this->securityCode = $newSC;
  1654.     }
  1655.     function setCharge($newC) {
  1656.         $this->charge = $newC;
  1657.     }
  1658.     function setAuthOption($newAO) {
  1659.         $this->authOption = $newAO;
  1660.     }
  1661.     function setAuthCode($newAC) {
  1662.         $this->authCode = $newAC;
  1663.     }
  1664.     function setPreviousCardRef($newRef){
  1665.         $this->previousCardRef = $newRef;
  1666.     }
  1667.     function setCardHolder($newCH) {
  1668.         $this->cardHolder = $newCH;
  1669.     }
  1670.     function setThreeDSecureStep($step){
  1671.         $this->threeDSecureStep = $step;
  1672.     }
  1673.     function setPaResFile($file){
  1674.         $this->paResFile = $file;
  1675.     }
  1676.     function setDatacashReference($ref){
  1677.         $this->datacashReference = $ref;
  1678.     }
  1679.     function getCollectionInFuture() {
  1680.         return $this->collectInFuture;
  1681.     }
  1682.     function getCardType() {
  1683.         return $this->cardType;
  1684.     }
  1685.     function getCardNo() {
  1686.         return $this->setCardNo;
  1687.     }
  1688.     function getStartDate() {
  1689.         return $this->startDate;
  1690.     }
  1691.     function getExpires() {
  1692.         return $this->expires;
  1693.     }
  1694.     function getIssueNo() {
  1695.         return $this->issueNo;
  1696.     }
  1697.     function getSecurityCode() {
  1698.         return $this->securityCode;
  1699.     }
  1700.     function getCharge() {
  1701.         return $this->charge;
  1702.     }
  1703.     function getAuthOption() {
  1704.         return $this->authOption;
  1705.     }
  1706.     function getAuthCode() {
  1707.         return $this->authCode;
  1708.     }
  1709.     function getPreviousCardRef(){
  1710.         return $this->previousCardRef;
  1711.     }
  1712.     function getCardHolder() {
  1713.         return $this->cardHolder;
  1714.     }
  1715.     function CCPayment($pType = "", $amnt = 0, $newCType = "", $newCNo = "", $newExpires = "", $newAOption = "") {
  1716.         $this->service = "PaymentService";
  1717.         $this->action = "AcceptPayment";
  1718.         $this->paymentType = $pType;
  1719.         $this->amount = $amnt;
  1720.         $this->cardType = $newCType;
  1721.         $this->cardNo = $newCNo;
  1722.         $this->expires = $newExpires;
  1723.         $this->authOption = $newAOption;
  1724.     }
  1725.     function accept($url, $sessId) {
  1726.         $xmldoc = $this->buildRequestXMLDoc($sessId);
  1727.         $this->setUrl($url);
  1728.         $this->setReqXML($xmldoc->saveXML());
  1729.         //echo htmlentities($xmldoc->saveXML());
  1730.         $resXml = $this->postXmlMessage();
  1731.         //echo htmlentities($resXml);
  1732.         $this->parseResponse($this->resXML);
  1733.     }
  1734.     function buildRequestXMLDoc($sessId) {
  1735.         /* build request xml for e2 CancelTransaction */
  1736.         $service_name = $this->action;
  1737.         $xmldoc = $this->buildE2XMLHeader($this->service, $service_name, $sessId);
  1738.         $xpath = "//".$service_name;
  1739.         if (isset ($this->paymentType)) {
  1740.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "PaymentType", $this->paymentType);
  1741.         }
  1742.     if (isset ($this->paymentDate)) {
  1743.       $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "PaymentDate", $this->paymentDate);
  1744.     }
  1745.     if (isset ($this->collectInFuture)) {
  1746.       $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "CollectInFuture", $this->collectInFuture);
  1747.     }
  1748.         if (isset ($this->amount)) {
  1749.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Amount", $this->amount);
  1750.         }
  1751.         if (isset ($this->previousCardRef)) {
  1752.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "PreviousCardRef", $this->previousCardRef);
  1753.         }
  1754.         if (isset ($this->cardType)) {
  1755.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "CardType", $this->cardType);
  1756.         }
  1757.         if (isset ($this->cardNo)) {
  1758.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "CardNo", $this->cardNo);
  1759.         }
  1760.         if (isset ($this->expires)) {
  1761.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Expires", $this->expires);
  1762.         }
  1763.         if (isset($this->securityCode)){
  1764.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "SecurityCode", $this->securityCode);
  1765.         }
  1766.         if (isset ($this->charge)) {
  1767.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Charge", $this->charge);
  1768.         }
  1769.         if (isset ($this->authOption)) {
  1770.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "AuthOption", $this->authOption);
  1771.         }
  1772.         if (isset ($this->startDate)) {
  1773.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "StartDate", $this->startDate);
  1774.         }
  1775.         if (isset ($this->issueNo)) {
  1776.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "IssueNo", $this->issueNo);
  1777.         }
  1778.         if (isset ($this->threeDSecureStep)) {
  1779.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "ThreeDSecureStep", $this->threeDSecureStep);
  1780.         }
  1781.         if (isset ($this->paResFile)) {
  1782.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "PaResFile", $this->paResFile);
  1783.         }
  1784.         if (isset ($this->datacashReference)) {
  1785.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "DatacashReference", $this->datacashReference);
  1786.         }
  1787.         /* Card holder information */
  1788.         if (isset ($this->cardHolder)) {
  1789.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "CardHolder", "");
  1790.             $xpath = $xpath."/CardHolder";
  1791.             if (strlen($this->cardHolder->getTitle()) > 0) {
  1792.                 $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Title", $this->cardHolder->getTitle());
  1793.             }
  1794.  
  1795.             if (strlen($this->cardHolder->getFirstname()) > 0) {
  1796.                 $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Firstname", $this->cardHolder->getFirstname());
  1797.             }
  1798.             if (strlen($this->cardHolder->getLastname()) > 0) {
  1799.                 $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Lastname", $this->cardHolder->getLastname());
  1800.             }
  1801.             if (strlen($this->cardHolder->getPostcode()) > 0) {
  1802.                 $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Postcode", $this->cardHolder->getPostcode());
  1803.             }
  1804.             if (strlen($this->cardHolder->getAddressLine1()) > 0) {
  1805.                 $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "AddressLine1", $this->cardHolder->getAddressLine1());
  1806.             }
  1807.             if (strlen($this->cardHolder->getAddressLine2()) > 0) {
  1808.                 $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "AddressLine2", $this->cardHolder->getAddressLine2());
  1809.             }
  1810.             if (strlen($this->cardHolder->getArea()) > 0) {
  1811.                 $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Area", $this->cardHolder->getArea());
  1812.             }
  1813.             if (strlen($this->cardHolder->getTown()) > 0) {
  1814.                 $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Town", $this->cardHolder->getTown());
  1815.             }
  1816.             if (strlen($this->cardHolder->getCounty()) > 0) {
  1817.                 $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "County", $this->cardHolder->getCounty());
  1818.             }
  1819.             if (strlen($this->cardHolder->getCountry()) > 0) {
  1820.                 $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Country", $this->cardHolder->getCountry());
  1821.             }
  1822.         }
  1823.         return $xmldoc;
  1824.     }
  1825. }
  1826. class PPPayment extends AcceptPayment {
  1827.     /* Deal with e2 AcceptPayment for PayPal payment */
  1828.     var $email;
  1829.     var $server;
  1830.     var $authOption;
  1831.     var $payPalStep;
  1832.     var $merchantReference;
  1833.     var $datacashReference;
  1834.     function setEmail($newE) {
  1835.         $this->email = $newE;
  1836.     }
  1837.     function setServer($newS) {
  1838.         $this->server = $newS;
  1839.     }
  1840.     function setAuthOption($newA) {
  1841.         $this->authOption = $newA;
  1842.     }
  1843.     function setPayPalStep($newP) {
  1844.         $this->payPalStep = $newP;
  1845.     }
  1846.     function setMerchantReference($newM){
  1847.         $this->merchantReference = $newM;
  1848.     }
  1849.     function setDatacashReference($ref){
  1850.         $this->datacashReference = $ref;
  1851.     }
  1852.     function PPPayment($pType = "", $amnt = 0) {
  1853.         $this->service = "PaymentService";
  1854.         $this->action = "AcceptPayment";
  1855.         $this->paymentType = $pType;
  1856.         $this->amount = $amnt;
  1857.     }
  1858.     function accept($url, $sessId, $emulated = false) {
  1859.         $xmldoc = $this->buildRequestXMLDoc($sessId);
  1860.         $this->setUrl($url);
  1861.         $this->setReqXML($xmldoc->saveXML());
  1862.         //echo htmlentities($xmldoc->saveXML());
  1863.         if(!$emulated)
  1864.         {
  1865.             $resXml = $this->postXmlMessage();
  1866.             //echo htmlentities($resXml);
  1867.             $this->parseResponse($this->resXML);
  1868.         }
  1869.     }
  1870.     function buildRequestXMLDoc($sessId) {
  1871.         $service_name = $this->action;
  1872.         $xmldoc = $this->buildE2XMLHeader($this->service, $service_name, $sessId);
  1873.         $xpath = "//".$service_name;
  1874.         if (isset ($this->paymentType)) {
  1875.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "PaymentType", $this->paymentType);
  1876.         }
  1877.         if (isset ($this->amount)) {
  1878.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Amount", $this->amount);
  1879.         }
  1880.         $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "PayPal", "");
  1881.         $xpath = "//".$service_name."/PayPal";
  1882.         if (isset ($this->email)) {
  1883.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Email", $this->email);
  1884.         }
  1885.         if (isset ($this->server)) {
  1886.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Server", $this->server);
  1887.         }
  1888.         if (isset ($this->payPalStep)) {
  1889.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "PayPalStep", $this->payPalStep);
  1890.         }
  1891.         if (isset ($this->authOption)) {
  1892.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "AuthOption", $this->authOption);
  1893.         }
  1894.         if (isset($this->merchantReference)){
  1895.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "MerchantReference", $this->merchantReference);
  1896.         }
  1897.         if (isset ($this->datacashReference)) {
  1898.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "DatacashReference", $this->datacashReference);
  1899.         }
  1900.         return $xmldoc;
  1901.     }  
  1902. }
  1903. class CardHolder extends BasicE2XML {
  1904.     /* deal with e2 credit card info*/
  1905.     var $title;
  1906.     var $firstname;
  1907.     var $lastname;
  1908.     var $addressLine1;
  1909.     var $addressLine2;
  1910.     var $area;
  1911.     var $town;
  1912.     var $county;
  1913.     var $country;
  1914.     var $postcode;
  1915.     function setTitle($newT) {
  1916.         $this->title = $newT;
  1917.     }
  1918.     function setFirstname($newFN) {
  1919.         $this->firstname = $newFN;
  1920.     }
  1921.     function setLastname($newLN) {
  1922.         $this->lastName = $newLN;
  1923.     }
  1924.     function setAddressLine1($newA1) {
  1925.         $this->addressLine1 = $newA1;
  1926.     }
  1927.     function setAddressLine2($newA2) {
  1928.         $this->addressLine2 = $newA2;
  1929.     }
  1930.     function setArea($newA) {
  1931.         $this->area = $newA;
  1932.     }
  1933.     function setTown($newT) {
  1934.         $this->town = $newT;
  1935.     }
  1936.     function setCounty($newC) {
  1937.         $this->county = $newC;
  1938.     }
  1939.     function setCountry($newC) {
  1940.         $this->country = $newC;
  1941.     }
  1942.     function setPostcode($newP) {
  1943.         $this->postcode = $newP;
  1944.     }
  1945.     function getTitle() {
  1946.         return $this->title;
  1947.     }
  1948.     function getFirstname() {
  1949.         return $this->firstname;
  1950.     }
  1951.     function getLastname() {
  1952.         return $this->lastname;
  1953.     }
  1954.     function getAddressLine1() {
  1955.         return $this->addressLine1;
  1956.     }
  1957.     function getAddressLine2() {
  1958.         return $this->addressLine2;
  1959.     }
  1960.     function getArea() {
  1961.         return $this->area;
  1962.     }
  1963.     function getTown() {
  1964.         return $this->town;
  1965.     }
  1966.     function getCounty() {
  1967.         return $this->county;
  1968.     }
  1969.     function getCountry() {
  1970.         return $this->country;
  1971.     }
  1972.     function getPostcode() {
  1973.         return $this->postcode;
  1974.     }
  1975.     function CardHolder($newTitle = "", $newFirstname = "", $newLastname = "") {
  1976.         $this->title = $newTitle;
  1977.         $this->firstname = $newFirstname;
  1978.         $this->lastname = $newLastname;
  1979.     }
  1980. }
  1981. class RegisterClient extends BasicE2XML {
  1982.     /* Deal with e2 RegisterClient service*/
  1983.     /* Now this class is deprecated to use*/
  1984.     /* you suggested to use ClientService which is */
  1985.     /* more organised*/
  1986.  
  1987.     var $postcode;
  1988.     var $lastname;
  1989.     var $email;
  1990.     var $firstname;
  1991.     var $building;
  1992.     var $street;
  1993.     var $area;
  1994.     var $city;
  1995.     var $countryName;
  1996.     var $workPhone;
  1997.     var $responseArray;
  1998.     function setPostcode($newP) {
  1999.         $this->postcode = $newP;
  2000.     }
  2001.     function setLastname($newL) {
  2002.         $this->lastname = $newL;
  2003.     }
  2004.     function setEmail($newE) {
  2005.         $this->email = $newE;
  2006.     }
  2007.     function setFirstname($newF) {
  2008.         $this->firstname = $newF;
  2009.     }
  2010.     function setTitle($newT) {
  2011.         $this->title = $newT;
  2012.     }
  2013.     function setBuilding($newB) {
  2014.         $this->building = $newB;
  2015.     }
  2016.     function setStreet($newS) {
  2017.         $this->street = $newS;
  2018.     }
  2019.     function setArea($newA) {
  2020.         $this->area = $newA;
  2021.     }
  2022.     function setCity($newC) {
  2023.         $this->city = $newC;
  2024.     }
  2025.     function setCountryName($newC) {
  2026.         $this->countryName = $newC;
  2027.     }
  2028.     function setWorkPhone($newW) {
  2029.         $this->workPhone = $newW;
  2030.     }
  2031.     function getPostcode() {
  2032.         return $this->postcode;
  2033.     }
  2034.     function getLastname() {
  2035.         return $this->lastname;
  2036.     }
  2037.     function getEmail() {
  2038.         return $this->email;
  2039.     }
  2040.     function getFirstname() {
  2041.         return $this->firstname;
  2042.     }
  2043.     function getTitle() {
  2044.         return $this->title;
  2045.     }
  2046.     function getBuilding() {
  2047.         return $this->building;
  2048.     }
  2049.     function getStreet() {
  2050.         return $this->street;
  2051.     }
  2052.     function getArea() {
  2053.         return $this->area;
  2054.     }
  2055.     function getCity() {
  2056.         return $this->city;
  2057.     }
  2058.     function getCountryName() {
  2059.         return $this->countryName;
  2060.     }
  2061.     function getWorkPhone() {
  2062.         return $this->workPhone;
  2063.     }
  2064.     function getResponseArray() {
  2065.         return ($this->responseArray);
  2066.     }
  2067.  
  2068.     function RegisterClient($newPOCD = "", $newLNAM = "", $newEMAD = "") {
  2069.         /* constructor */
  2070.         $this->postcode = $newPOCD;
  2071.         $this->lastname = $newLNAM;
  2072.         $this->email = $newEMAD;
  2073.     }
  2074.     function register($url, $sessId) {
  2075.         $xmldoc = $this->buildRequestXMLDoc($sessId);
  2076.         $xpost = new XMLPosting();
  2077.         $xpost->setUrl($url);
  2078.         $xpost->setReqXML($xmldoc->saveXML());
  2079.         //echo htmlentities($xmldoc->saveXML());
  2080.         $resXml = $xpost->postXmlMessage();
  2081.         //echo htmlentities($resXml);
  2082.         $this->parseResponse($resXml);
  2083.     }
  2084.     function buildRequestXMLDoc($sessId) {
  2085.         /* build request xml for e2 CancelTransaction */
  2086.         $service_name = "RegisterClient";
  2087.         $xmldoc = $this->buildE2XMLHeader("ClientService", $service_name, $sessId);
  2088.         $xpath = "//".$service_name;
  2089.         /* add paxs */
  2090.         if (isset ($this->postcode)) {
  2091.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Postcode", $this->postcode);
  2092.         }
  2093.         if (isset ($this->lastname)) {
  2094.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Lastname", $this->lastname);
  2095.         }
  2096.         if (isset ($this->email)) {
  2097.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Email", $this->email);
  2098.         }
  2099.         if (isset ($this->firstname)) {
  2100.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Firstname", $this->firstname);
  2101.         }
  2102.         if (isset ($this->building)) {
  2103.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Building", $this->building);
  2104.         }
  2105.         if (isset ($this->street)) {
  2106.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Street", $this->street);
  2107.         }
  2108.         if (isset ($this->area)) {
  2109.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Area", $this->area);
  2110.         }
  2111.         if (isset ($this->city)) {
  2112.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "City", $this->city);
  2113.         }
  2114.         if (isset ($this->countryName)) {
  2115.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "CountryName", $this->countryName);
  2116.         }
  2117.         if (isset ($this->workPhone)) {
  2118.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "WorkPhone", $this->workPhone);
  2119.         }
  2120.         return $xmldoc;
  2121.     }
  2122.     function parseResponse($rx) {
  2123.         $doc = new DOMDocument('1.0', 'ISO-8859-1');
  2124.         if (!$doc->loadXML($rx)) {
  2125.             // it is done here to isolate e2 client library independant
  2126.             // of client website.
  2127.             $this->setErrorCode("Website-C0201");
  2128.             $this->setErrorType("fatal");
  2129.             $this->setErrorDesc("Error while parsing response xml document");
  2130.             return;
  2131.         }
  2132.         $root = $doc->firstChild;
  2133.         $this->parseNodeFault($root);
  2134.         if (strlen($this->getErrorCode()) > 0) {
  2135.             //$dom->free();
  2136.             return;
  2137.         }
  2138.         $xml2a = new xml2array($rx);
  2139.         $xa = $xml2a->getResult();
  2140.         if (is_array($xa['ClientService']["$service_name"])) {
  2141.             $this->responseArray = $xa['ClientService']["$service_name"];
  2142.         }
  2143.         //$dom->free();
  2144.     }
  2145. }
  2146.  
  2147. class AssignClient extends E2Interface {
  2148.     /* Deal with e2 AssignClient service*/
  2149.  
  2150.     var $clientCode;
  2151.     function setClientCode($newCD) {
  2152.         $this->clientCode = $newCD;
  2153.     }
  2154.     function getClientCode() {
  2155.         return $this->clientCode;
  2156.     }
  2157.  
  2158.     function AssignClient($newCD = "") {
  2159.         /* constructor */
  2160.         $this->service = "ReservationService";
  2161.         $this->action = "AssignClient";
  2162.         $this->clientCode = $newCD;
  2163.     }
  2164.     function assign($url, $sessId) {
  2165.         $xmldoc = $this->buildRequestXMLDoc($sessId);
  2166.         $this->setUrl($url);
  2167.         $this->setReqXML($xmldoc->saveXML());
  2168.         //echo htmlentities($xmldoc->saveXML());
  2169.         $resXml = $this->postXmlMessage();
  2170.         //echo htmlentities($resXml);
  2171.         $this->parseResponse($this->resXML);
  2172.     }
  2173.     function buildRequestXMLDoc($sessId) {
  2174.         /* build request xml for e2 CancelTransaction */
  2175.         $service_name = $this->action;
  2176.         $xmldoc = $this->buildE2XMLHeader($this->service, $service_name, $sessId);
  2177.         $xpath = "//".$service_name;
  2178.         /* assign client */
  2179.         if (isset ($this->clientCode)) {
  2180.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "ClientCode", $this->clientCode);
  2181.         }
  2182.         return $xmldoc;
  2183.     }
  2184. }
  2185. class UpdateStatus extends E2Interface {
  2186.     /* Deal with e2 UpdateStatus service */
  2187.  
  2188.     var $newStatus;
  2189.     var $checkOnly; // flag for checking
  2190.     var $optionTaken; // option taken
  2191.     var $optionUntil; // option until
  2192.     var $optionUntilTime; // option until time
  2193.     function setNewStatus($newS) {
  2194.         $this->newStatus = $newS;
  2195.     }
  2196.     function setCheckOnly($newC) {
  2197.         $this->checkOnly = $newC;
  2198.     }
  2199.   function setOptionTaken($newOT){
  2200.     $this->optionTaken = $newOT;
  2201.   }
  2202.   function setOptionUntil ($newOU) {
  2203.       $this->optionUntil = $newOU;
  2204.   }
  2205.     function setOptionUntilTime($newTime){
  2206.         $this->optionUntilTime = $newTime;
  2207.     }
  2208.     function getNewStatus() {
  2209.         return $this->newStatus;
  2210.     }
  2211.  
  2212.     function getCheckOnly() {
  2213.         return $this->checkOnly;
  2214.     }
  2215.     function UpdateStatus($newS = "", $newCK = "") {
  2216.         /* constructor */
  2217.         $this->service = "ReservationService";
  2218.         $this->action = "UpdateStatus";
  2219.         $this->newStatus = $newS;
  2220.         $this->checkOnly = $newCK;
  2221.     }
  2222.     function update($url, $sessId) {
  2223.         $xmldoc = $this->buildRequestXMLDoc($sessId);
  2224.         $this->setUrl($url);
  2225.         $this->setReqXML($xmldoc->saveXML());
  2226.         //echo htmlentities($xmldoc->saveXML());
  2227.         $resXml = $this->postXmlMessage();
  2228.         //echo htmlentities($resXml);
  2229.         $this->parseResponse($this->resXML);
  2230.     }
  2231.     function buildRequestXMLDoc($sessId) {
  2232.         /* build request xml for e2 CancelTransaction */
  2233.         $service_name = $this->action;
  2234.         $xmldoc = $this->buildE2XMLHeader($this->service, $service_name, $sessId);
  2235.         $xpath = "//".$service_name;
  2236.         if (isset ($this->newStatus)) {
  2237.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "NewStatus", $this->newStatus);
  2238.         }
  2239.     if (isset ($this->optionTaken) && strlen($this->optionTaken) > 0) {
  2240.        $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "OptionTaken", $this->optionTaken);
  2241.     }
  2242.     if (isset ($this->optionUntil) && strlen($this->optionUntil) > 0) {
  2243.        $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "OptionUntil", $this->optionUntil);
  2244.     }
  2245.         if (isset($this->optionUntilTime) && strlen($this->optionUntilTime) > 0){
  2246.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "OptionUntilTime", $this->optionUntilTime);
  2247.         }
  2248.         if (isset ($this->checkOnly) && strlen($this->checkOnly) > 0) {
  2249.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "CheckOnly", "");
  2250.         }
  2251.         return $xmldoc;
  2252.     }
  2253. }
  2254. class RecalcBooking extends E2Interface {
  2255.     /* Deal with e2 RecalcBooking service */
  2256.     var $BookingNumber;
  2257.     function setBookingNUmber($newBN) {
  2258.         $this->bookingNumber = $newBN;
  2259.     }
  2260.     function RecalcBooking($url, $sessId, $newBN = "") {
  2261.         /* constructor */
  2262.         $this->service = "ReservationService";
  2263.         $this->action = "RecalcBooking";
  2264.         $this->url = $url;
  2265.         $this->sessionId = $sessId;
  2266.         $this->bookingNumber = $newBN;
  2267.     }
  2268.     function recalc() {
  2269.         $xmldoc = $this->buildRequestXMLDoc();
  2270.         $this->setReqXML($xmldoc->saveXML());
  2271.         //echo htmlentities($xmldoc->saveXML());
  2272.         $resXml = $this->postXmlMessage();
  2273.         //echo htmlentities($resXml);
  2274.         $this->parseResponse($resXml);
  2275.         return $this->responseArray;
  2276.     }
  2277.     function buildRequestXMLDoc() {
  2278.         $xmldoc = $this->buildE2XMLHeader();
  2279.         $xpath = "//".$this->action;
  2280.         // postcode to find address
  2281.         if (isset ($this->bookingNumber)) {
  2282.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "BookingNumber", $this->BookingNumber);
  2283.         }
  2284.         return $xmldoc;
  2285.     }
  2286. }
  2287.  
  2288. class AddNote extends E2Interface {
  2289.     /* Deal with e2 AddNote*/
  2290.     /* it is dealt with multiple pax*/
  2291.     var $noteArray; // store array notes
  2292.     function setNoteArray($newPA) {
  2293.         $this->noteArray = $newPA;
  2294.     }
  2295.     function getNoteArray() {
  2296.         return $this->noteArray;
  2297.     }
  2298.     function AddNote($newNA = "") {
  2299.         /* constructor */
  2300.         $this->service = "ReservationService";
  2301.         $this->action = "AddNote";
  2302.         $this->noteArray = $newNA;
  2303.     }
  2304.     function add($url, $sessId) {
  2305.         $xmldoc = $this->buildRequestXMLDoc($sessId);
  2306.         $this->setUrl($url);
  2307.         $this->setReqXML($xmldoc->saveXML());
  2308.         //echo htmlentities($xmldoc->saveXML());
  2309.         $resXml = $this->postXmlMessage();
  2310.         //echo htmlentities($resXml);
  2311.         $this->parseResponse($this->resXML);
  2312.     }
  2313.     function buildRequestXMLDoc($sessId) {
  2314.         /* build request xml for e2 CancelTransaction */
  2315.         $service_name = $this->action;
  2316.         $xmldoc = $this->buildE2XMLHeader($this->service, $service_name, $sessId);
  2317.         $xpath = "//".$service_name;
  2318.         /* add paxs */
  2319.         if (is_array($this->noteArray)) {
  2320.             foreach ($this->noteArray as $note) {
  2321.                 $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Notes", "");
  2322.                 if (isset ($note["Type"])) {
  2323.                     $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Notes", "Type", $note["Type"]);
  2324.                 }
  2325.                 if (isset ($note["TransactionNumber"])) {
  2326.                     $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Notes", "TransactionNumber", $note["TransactionNumber"]);
  2327.                 }
  2328.                 if (isset ($note["SupplementNumber"])) {
  2329.                     $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Notes", "SupplementNumber", $note["SupplementNumber"]);
  2330.                 }
  2331.                 if (isset ($note["Note"])) {
  2332.                     $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Notes", "Note", $note["Note"]);
  2333.                 }
  2334.         if (isset ($note["Auto"])) {
  2335.           $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Notes", "Auto", $note["Auto"]);
  2336.          }
  2337.  
  2338.                 if (isset ($note["PrecodedNote"])) {
  2339.                     $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Notes", "PrecodedNote", $note["PrecodedNote"]);
  2340.                 }
  2341.                 if (isset ($note["TellClient"])) {
  2342.                     $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Notes", "TellClient", "Y");
  2343.                 }
  2344.                 if (isset ($note["TellSupplier"])) {
  2345.                     $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Notes", "TellSupplier", "Y");
  2346.                 }
  2347.             }
  2348.         }
  2349.         return $xmldoc;
  2350.     }
  2351. }
  2352. class RequestInvoice extends E2Interface {
  2353.     /* Deal with e2 RequestInvoice*/
  2354.     var $queue; // invoice queue
  2355.     var $bookingCode; // booking code (human readable)
  2356.     var $email; // email address to send invoice to
  2357.     function setQueue($newQ) {
  2358.         $this->queue = $newQ;
  2359.     }
  2360.     function setBookingCode($newBCODE) {
  2361.         $this->bookingCode = $newBCODE;
  2362.     }
  2363.     function setEmail($newEmail) {
  2364.         $this->email = $newEmail;
  2365.     }
  2366.     function getNoteArray() {
  2367.         return $this->invoiceType;
  2368.     }
  2369.     function RequestInvoice($newQ = "") {
  2370.         /* constructor */
  2371.         $this->service = "PaymentService";
  2372.         $this->action = "RequestInvoice";
  2373.         $this->queue = $newQ;
  2374.     }
  2375.     function invoice($url, $sessId) {
  2376.         $xmldoc = $this->buildRequestXMLDoc($sessId);
  2377.         $this->setUrl($url);
  2378.         $this->setReqXML($xmldoc->saveXML());
  2379.         //echo htmlentities($xmldoc->saveXML());
  2380.         $resXml = $this->postXmlMessage();
  2381.         //echo htmlentities($resXml);
  2382.         $this->parseResponse($this->resXML);
  2383.     }
  2384.     function buildRequestXMLDoc($sessId) {
  2385.         /* build request xml for e2 CancelTransaction */
  2386.         $service_name = $this->action;
  2387.         $xmldoc = $this->buildE2XMLHeader($this->service, $service_name, $sessId);
  2388.         $xpath = "//".$service_name;
  2389.         if (isset ($this->queue)) {
  2390.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Queue", $this->queue);
  2391.         }
  2392.         if (isset ($this->bookingCode)) {
  2393.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "BookingCode", $this->bookingCode);
  2394.         }
  2395.         if (isset ($this->email)) {
  2396.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Email", $this->email);
  2397.         }
  2398.         return $xmldoc;
  2399.     }
  2400. }
  2401. class RequestDummyInvoice extends E2Interface {
  2402.     /* Deal with e2 RequestInvoice*/
  2403.     var $bookingCode; // booking code (human readable)
  2404.     function setBookingCode($newBCODE) {
  2405.         $this->bookingCode = $newBCODE;
  2406.     }
  2407.     function RequestDummyInvoice() {
  2408.         /* constructor */
  2409.         $this->service = "PaymentService";
  2410.         $this->action = "RequestDummyInvoice";
  2411.     }
  2412.     function invoice($url, $sessId) {
  2413.         $xmldoc = $this->buildRequestXMLDoc($sessId);
  2414.         $this->setUrl($url);
  2415.         $this->setReqXML($xmldoc->saveXML());
  2416.         //echo htmlentities($xmldoc->saveXML());
  2417.         $resXml = $this->postXmlMessage();
  2418.         //echo htmlentities($resXml);
  2419.         $this->parseResponse($this->resXML);
  2420.     }
  2421.     function buildRequestXMLDoc($sessId) {
  2422.         /* build request xml for e2 CancelTransaction */
  2423.         $service_name = $this->action;
  2424.         $xmldoc = $this->buildE2XMLHeader($this->service, $service_name, $sessId);
  2425.         $xpath = "//".$service_name;
  2426.         if (isset ($this->bookingCode)) {
  2427.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "BookingCode", $this->bookingCode);
  2428.         }
  2429.         return $xmldoc;
  2430.     }
  2431. }
  2432. class DataService extends E2Interface {
  2433.     /* Deal with e2 Data service*/
  2434.     // product type, TOR, VIS, ACC etc.
  2435.     var $productType;
  2436.     // Transport code
  2437.     var $transportCode;
  2438.     // accommmodation code
  2439.     var $accommodationCode;
  2440.     // component code
  2441.     var $componentCode;
  2442.     // 270208 added by Sunny: Package code for GetPackages
  2443.     var $packageCode;
  2444.     // 271108 added by Sunny: Property code for GetProperties
  2445.     var $propertyCode;
  2446.     // code from
  2447.     var $codeFrom;
  2448.     // code to
  2449.     var $codeTo;
  2450.     // Live flag
  2451.     var $liveOnly;
  2452.     // Item detail flag
  2453.     var $item;
  2454.     // detail detail flag
  2455.     var $detail;
  2456.     // trans detail flag for Transport
  2457.     var $trans;
  2458.     // response array of the service
  2459.     var $responseArray;
  2460.     // detail level array
  2461.     var $detailLevel;
  2462.     // 120508 added by Sarah: Misc Fields
  2463.     var $miscFields;
  2464.     // 120508 added by Sarah: Code
  2465.     var $code;
  2466.     /* constructor */
  2467.     function DataService($newAction, $newProductType, $url, $sessId) {
  2468.         $this->service = "DataService";
  2469.         $this->action = $newAction;
  2470.         $this->productType = $newProductType;
  2471.         $this->url = $url;
  2472.         $this->sessionId = $sessId;
  2473.     }
  2474.     // set product type
  2475.     function setProductType($newProductType) {
  2476.         $this->productType = $newProductType;
  2477.     }
  2478.     // set transaction code
  2479.     function setTransportCode($newTransCode) {
  2480.         $this->transportCode = $newTransCode;
  2481.     }
  2482.     // set component code
  2483.     function setComponentCode($newComponentCode) {
  2484.         $this->componentCode = $newComponentCode;
  2485.     }
  2486.     // 270208 added by Sunny: set package code for GetPackages
  2487.     function setPackageCode($newPackageCode) {
  2488.         $this->packageCode = $newPackageCode;
  2489.     }
  2490.     // 271108 added by Sunny: set property code for GetProperties
  2491.     function setPropertyCode($newPropertyCode) {
  2492.         $this->propertyCode = $newPropertyCode;
  2493.     }
  2494.     // set accommodation code
  2495.     function setAccommodationCode($newAccCode){
  2496.         $this->accommodationCode = $newAccCode;
  2497.     }
  2498.     //set code from for find
  2499.     function setCodeFrom($newCode) {
  2500.         $this->codeFrom = $newCode;
  2501.     }
  2502.     // set code to for find
  2503.     function setCodeTo($newCode) {
  2504.         $this->codeTo = $newCode;
  2505.     }
  2506.     // set live only flag
  2507.     function setLiveOnly($newFlag) {
  2508.         $this->liveOnly = $newFlag;
  2509.     }
  2510.     // set item detail flag
  2511.     function setItem($newFlag) {
  2512.         $this->item = $newFlag;
  2513.     }
  2514.     // set Detail of  detail flag
  2515.     function setDetail($newFlag) {
  2516.         $this->detail = $newFlag;
  2517.     }
  2518.     // set Detail of  detail flag
  2519.     function setDetailLevel($newDtl) {
  2520.         $this->detailLevel = $newDtl;
  2521.     }
  2522.     // set Trans of  detail flag
  2523.     function setTrans($newFlag) {
  2524.         $this->trans = $newFlag;
  2525.     }
  2526.      // 120508 added by Sarah: set Misc fields
  2527.     function setMiscFields($newMiscFields) {
  2528.         $this->miscFields = $newMiscFields;
  2529.     }
  2530.      // 120508 added by Sarah: set Code
  2531.     function setCode($newCode) {
  2532.         $this->code = $newCode;
  2533.     }
  2534.     function setResponseArray($newRA) {
  2535.         $this->responseArray = $newRA;
  2536.     }
  2537.     function getResponseArray() {
  2538.         return $this->responseArray;
  2539.     }
  2540.     // return data
  2541.     function getData($newResType="array") {
  2542.         $xmldoc = $this->buildRequestXMLDoc();
  2543.         $this->setReqXML($xmldoc->saveXML());
  2544.         //echo htmlentities($xmldoc->saveXML());
  2545.         $resXml = $this->postXmlMessage();
  2546.         //echo htmlentities($resXml);
  2547.         if (strlen($this->getErrorCode()) > 0) {
  2548.             return;
  2549.         }
  2550.         if ($newResType == 'array'){
  2551.           $this->responseArray = $this->parseResponse($resXml);
  2552.           return $this->responseArray;
  2553.         }else{
  2554.           return $resXml;
  2555.         }
  2556.     }
  2557.     function buildRequestXMLDoc() {
  2558.         /* build request xml for e2 CancelTransaction */
  2559.         $xmldoc = $this->buildE2XMLHeader();
  2560.         $xpath = "//".$this->action;
  2561.         // add product type node
  2562.         if (isset ($this->productType)) {
  2563.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Type", $this->productType);
  2564.         }
  2565.         // add ComponentCode node in request
  2566.         if (isset ($this->componentCode)) {
  2567.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "ComponentCode", $this->componentCode);
  2568.         }
  2569.         // 270208 added by Sunny: add PackageCode node in request
  2570.         if (isset ($this->packageCode)) {
  2571.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "PackageCode", $this->packageCode);
  2572.         }
  2573.         // 280208 added by Sunny: add PropertyCode node in request
  2574.         if (isset ($this->propertyCode)) {
  2575.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "PropertyCode", $this->propertyCode);
  2576.         }
  2577.         // add accommodation code
  2578.         if (isset($this->accommodationCode)){
  2579.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "AccommodationCode", $this->accommodationCode);
  2580.         }
  2581.         // add TransportCode node
  2582.         if (isset ($this->transportCode)) {
  2583.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "TransportCode", $this->transportCode);
  2584.         }
  2585.         // 120508 added by Sarah: add Misc Fields node
  2586.         if (isset ($this->miscFields)) {
  2587.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "MiscFields", $this->miscFields);
  2588.         }
  2589.         // 120508 added by Sarah: add Room Type Code node
  2590.         if (isset ($this->code)) {
  2591.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Code", $this->code);
  2592.         }
  2593.         // find
  2594.         if (isset($this->codeFrom) || isset($this->codeTo)) {
  2595.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Find", "");
  2596.             if (isset($this->codeFrom)) {
  2597.                $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Find", "CodeFrom", $this->codeFrom);
  2598.             }
  2599.             if (isset($this->codeTo)) {
  2600.                $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Find", "CodeTo", $this->codeTo);
  2601.             }
  2602.         }
  2603.         // add detail level node
  2604.         $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "DetailLevel", "");
  2605.         // add LiveOnly flag
  2606.         if (isset ($this->liveOnly)) {
  2607.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "LiveOnly", (!$this->liveOnly) ? "false" :
  2608.             "true");
  2609.         }
  2610.         // add Itemdetail flag
  2611.         if (isset ($this->item)) {
  2612.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/DetailLevel", "Item", "");
  2613.         }
  2614.         // add Detail flag
  2615.         if (isset ($this->detail)) {
  2616.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/DetailLevel", "Detail", "");
  2617.         }
  2618.         // add trans flag for transport
  2619.         if (isset ($this->trans)) {
  2620.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/DetailLevel", "Trans", "");
  2621.         }
  2622.         /* for detail information*/
  2623.         for ($index = 0; $index < sizeof($this->detailLevel) && isset ($this->detailLevel[$index]); $index ++) {
  2624.             $detailFlag = $this->detailLevel[$index];
  2625.             $xmldoc = $detailFlag->buildRequestXMLDoc($xmldoc, $xpath."/DetailLevel");
  2626.         }
  2627.         return $xmldoc;
  2628.     }
  2629. }
  2630. class ClientService extends E2Interface {
  2631.     /* Deal with e2 Client service*/
  2632.     /* obsolate to use RegisterClient from RegsiterClient Class*/
  2633.     var $code;
  2634.     var $postcode;
  2635.     var $title;
  2636.     var $lastname;
  2637.     var $email;
  2638.     var $firstname;
  2639.     var $building;
  2640.     var $street;
  2641.     var $area;
  2642.     var $city;
  2643.     var $countryName;
  2644.     var $countryCode;
  2645.     var $workPhone;
  2646.     var $homePhone;
  2647.     var $mobilePhone;
  2648.     // agent code
  2649.     var $agentCode;
  2650.     // agent Internet password (CL.IPWD)
  2651.     var $password;
  2652.     // private client password (CL.IPWD)
  2653.     var $internetPassword;
  2654.     // exlcude bulk email
  2655.     var $excludeBulkEmail;
  2656.     // exlcude mail
  2657.     var $excludeMail;
  2658.     // 220108 added by Sunny: user defined fields
  2659.     var $userDef;
  2660.     // comment 1
  2661.     var $comments1;
  2662.     // date of birth
  2663.     var $birthDate;
  2664.     // flag to remember credit card info for further use
  2665.     var $rememberCard;
  2666.     // private client validation booking number
  2667.     var $bookingNumber;
  2668.     // private client validation booking departure date
  2669.     var $departureDate;
  2670.     // flag to get client's password in email
  2671.     var $getPassword;
  2672.     // template to be used for forget password email
  2673.     var $template;
  2674.     // 221008 added by Sunny: Flag to regenerate password
  2675.     var $regenPass;
  2676.     //client source
  2677.     var $source;
  2678.     // whether the passsword validation should be case sensitive
  2679.     var $isPassCaseSensitive;
  2680.     // whether the client details can be cleared when updating
  2681.     var $isAgentOnly;
  2682.     var $isPrivateOnly;
  2683.     var $isInternetOnly;
  2684.     var $responseArray;
  2685.     function setPostcode($newP) {
  2686.         $this->postcode = $newP;
  2687.     }
  2688.     function setCode($newC) {
  2689.         $this->code = $newC;
  2690.     }
  2691.  
  2692.     function setLastname($newL) {
  2693.         $this->lastname = $newL;
  2694.     }
  2695.     function setEmail($newE) {
  2696.         $this->email = $newE;
  2697.     }
  2698.     function setFirstname($newF) {
  2699.         $this->firstname = $newF;
  2700.     }
  2701.     function setTitle($newT) {
  2702.         $this->title = $newT;
  2703.     }
  2704.     function setBuilding($newB) {
  2705.         $this->building = $newB;
  2706.     }
  2707.     function setStreet($newS) {
  2708.         $this->street = $newS;
  2709.     }
  2710.     function setArea($newA) {
  2711.         $this->area = $newA;
  2712.     }
  2713.     function setCity($newC) {
  2714.         $this->city = $newC;
  2715.     }
  2716.     function setCountryName($newC) {
  2717.         $this->countryName = $newC;
  2718.     }
  2719.     function setCountryCode($newC) {
  2720.         $this->countryCode = $newC;
  2721.     }
  2722.     function setWorkPhone($newW) {
  2723.         $this->workPhone = $newW;
  2724.     }
  2725.     function setHomePhone($newHP){
  2726.         $this->homePhone = $newHP;
  2727.     }
  2728.     function setMobilePhone($newMP){
  2729.         $this->mobilePhone = $newMP;
  2730.     }
  2731.     function setAgentCode($newAGCD) {
  2732.         $this->agentCode = $newAGCD;
  2733.     }
  2734.     function setPassword($newPassword) {
  2735.         $this->password = $newPassword;
  2736.     }
  2737.     function setInternetPassword($newPassword) {
  2738.         $this->internetPassword = $newPassword;
  2739.     }
  2740.     function setExcludeMail($newExcludeMail){
  2741.         $this->excludeMail = $newExcludeMail;
  2742.     }
  2743.     function setExcludeBulkEmail($newEM) {
  2744.         $this->excludeBulkEmail = $newEM;
  2745.     }
  2746.     function setComments1($newC1) {
  2747.         $this->comments1 = $newC1;
  2748.     }
  2749.     function setBirthDate($new_date){
  2750.         $this->birthDate = $new_date;
  2751.     }
  2752.     function setRememberCard($newFlag = 'false'){
  2753.         $this->rememberCard = $newFlag;
  2754.     }
  2755.     function setBookingNumber($newBcod) {
  2756.         $this->bookingNumber = $newBcod;
  2757.     }
  2758.     function setDepartureDate($newDdep) {
  2759.         $this->departureDate = $newDdep;
  2760.     }
  2761.     function setSendMePass($newFlag="false") {
  2762.         $this->sendMePass = $newFlag;
  2763.     }
  2764.     // 221008 added by Sunny: Flag to regenerate password
  2765.     function setRegenPass($newFlag="false") {
  2766.         $this->regenPass = $newFlag;
  2767.     }
  2768.     // 050208 added by Sunny: The flag to match one and only client record
  2769.     function setUniqueMatchOnly($newFlag="false") {
  2770.     $this->uniqueMatchOnly = $newFlag;
  2771.     }
  2772.     function setSource($newVal) {
  2773.         $this->source = $newVal;
  2774.     }
  2775.     function setTemplate($newTmpl){
  2776.         $this->template = $newTmpl;
  2777.     }
  2778.     // 220108 added by Sunny: Set the user defined fields
  2779.     function setUserDef($keyValuePairs) {
  2780.         $this->userDef = $keyValuePairs;
  2781.     }
  2782.     // 070808 added by Sunny: Whether the client details can be cleared when updating
  2783.     function setCanClear($newCanClear) {
  2784.     $this->canClear = $newCanClear;
  2785.     }
  2786.     function setIsPassCaseSensitive($newP) {
  2787.         $this->isPassCaseSensitive = $newP;
  2788.     }
  2789.     function setIsAgentOnly($newA) {
  2790.         $this->isAgentOnly = $newA;
  2791.     }
  2792.     function setIsPrivateOnly($newP) {
  2793.         $this->isPrivateOnly = $newP;
  2794.     }
  2795.     function setIsInternetOnly($newI) {
  2796.         $this->isInternetOnly = $newI;
  2797.     }
  2798.     function getPostcode() {
  2799.         return $this->postcode;
  2800.     }
  2801.     function getLastname() {
  2802.         return $this->lastname;
  2803.     }
  2804.     function getEmail() {
  2805.         return $this->email;
  2806.     }
  2807.     function getFirstname() {
  2808.         return $this->firstname;
  2809.     }
  2810.     function getTitle() {
  2811.         return $this->title;
  2812.     }
  2813.     function getBuilding() {
  2814.         return $this->building;
  2815.     }
  2816.     function getStreet() {
  2817.         return $this->street;
  2818.     }
  2819.     function getArea() {
  2820.         return $this->area;
  2821.     }
  2822.     function getCity() {
  2823.         return $this->city;
  2824.     }
  2825.     function getCountryName() {
  2826.         return $this->countryName;
  2827.     }
  2828.     function getWorkPhone() {
  2829.         return $this->workPhone;
  2830.     }
  2831.     function getBirthDate(){
  2832.         return $this->birthDate;
  2833.     }
  2834.     function getRememberCard(){
  2835.         return $this->rememberCard;
  2836.     }
  2837.     function getResponseArray() {
  2838.         return ($this->responseArray);
  2839.     }
  2840.  
  2841.     function ClientService($newAction, $newURL, $newSessId) {
  2842.         /* constructor */
  2843.         $this->service = "ClientService";
  2844.         $this->action = $newAction;
  2845.         $this->url = $newURL;
  2846.         $this->sessionId = $newSessId;
  2847.     }
  2848.     function getClientInfo() {
  2849.         $xmldoc = $this->buildRequestXMLDoc();
  2850.         $this->setReqXML($xmldoc->saveXML());
  2851.         //echo htmlentities($xmldoc->saveXML());
  2852.         $resXml = $this->postXmlMessage();
  2853.         //echo htmlentities($resXml);
  2854.         if (strlen($this->getErrorCode()) > 0) {
  2855.             return;
  2856.         }
  2857.         $this->responseArray = $this->parseResponse($resXml);
  2858.         return $this->responseArray;
  2859.     }
  2860.     function buildRequestXMLDoc() {
  2861.         /* build request xml for e2 CancelTransaction */
  2862.         $xmldoc = $this->buildE2XMLHeader();
  2863.         $xpath = "//".$this->action;
  2864.         /* add paxs */
  2865.         if (isset ($this->postcode)) {
  2866.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Postcode", $this->postcode);
  2867.         }
  2868.         if (isset ($this->code)) {
  2869.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Code", $this->code);
  2870.         }
  2871.         if (isset ($this->title)) {
  2872.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Title", $this->title);
  2873.         }
  2874.         if (isset ($this->lastname)) {
  2875.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Lastname", $this->lastname);
  2876.         }
  2877.         if (isset ($this->email)) {
  2878.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Email", $this->email);
  2879.         }
  2880.         if (isset ($this->firstname)) {
  2881.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Firstname", $this->firstname);
  2882.         }
  2883.         if (isset ($this->building)) {
  2884.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Building", $this->building);
  2885.             if ($this->building == "" && isset ($this->canClear) && $this->canClear) {
  2886.                 $xmldoc = $this->setXNodeAttribute($xmldoc, $xpath."/Building", "Null", "true");
  2887.             }
  2888.         }
  2889.         if (isset ($this->street)) {
  2890.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Street", $this->street);
  2891.             if ($this->street == "" && isset ($this->canClear) && $this->canClear) {
  2892.                 $xmldoc = $this->setXNodeAttribute($xmldoc, $xpath."/Street", "Null", "true");
  2893.             }
  2894.         }
  2895.         if (isset ($this->area)) {
  2896.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Area", $this->area);
  2897.             if ($this->area == "" && isset ($this->canClear) && $this->canClear) {
  2898.                 $xmldoc = $this->setXNodeAttribute($xmldoc, $xpath."/Area", "Null", "true");
  2899.             }
  2900.         }
  2901.         if (isset ($this->city)) {
  2902.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "City", $this->city);
  2903.             if ($this->city == "" && isset ($this->canClear) && $this->canClear) {
  2904.                 $xmldoc = $this->setXNodeAttribute($xmldoc, $xpath."/City", "Null", "true");
  2905.             }
  2906.         }
  2907.         if (isset ($this->countryName)) {
  2908.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "CountryName", $this->countryName);
  2909.         }
  2910.         if (isset ($this->countryCode)) {
  2911.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "CountryCode", $this->countryCode);
  2912.         }
  2913.         if (isset ($this->workPhone)) {
  2914.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "WorkPhone", $this->workPhone);
  2915.         }
  2916.         if (isset($this->homePhone)){
  2917.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "HomePhone", $this->homePhone);
  2918.         }
  2919.         if (isset($this->mobilePhone)){
  2920.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Phone3", $this->mobilePhone);
  2921.         }
  2922.         // set agent code
  2923.         if (isset ($this->agentCode)) {
  2924.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "AgentCode", $this->agentCode);
  2925.         }
  2926.         // set password in the request
  2927.         if (isset ($this->password)) {
  2928.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Password", $this->password);
  2929.         }
  2930.         // set Internet password(for private client) in the request
  2931.         if (isset ($this->internetPassword)) {
  2932.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "InternetPassword", $this->internetPassword);
  2933.         }
  2934.         // set excludeEmail in the request
  2935.         if (isset ($this->excludeMail)) {
  2936.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "ExcludeMail", $this->excludeMail);
  2937.         }
  2938.         // set excludeEmail in the request
  2939.         if (isset ($this->excludeBulkEmail)) {
  2940.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "ExcludeBulkEmail", $this->excludeBulkEmail);
  2941.         }
  2942.         // set comments1 in the request
  2943.         if (isset ($this->comments1)) {
  2944.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Comments1", $this->comments1);
  2945.         }
  2946.         if (isset ($this->birthDate)) {
  2947.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "BirthDate", $this->birthDate);
  2948.         }
  2949.         if (isset ($this->rememberCard)) {
  2950.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "RememberCard", $this->rememberCard);
  2951.         }
  2952.         // set Booking number for client validation
  2953.         if (isset ($this->bookingNumber)) {
  2954.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "BookingNumber", $this->bookingNumber);
  2955.         }
  2956.         // set Booking departure for client validation
  2957.         if (isset ($this->departureDate)) {
  2958.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "DepartureDate", $this->departureDate);
  2959.         }
  2960.         // set flag to get client's password
  2961.         if (isset ($this->sendMePass)) {
  2962.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "SendMePass", $this->sendMePass);
  2963.         }
  2964.         // 221008 added by Sunny: Set flag to regenerate password
  2965.         if (isset ($this->regenPass)) {
  2966.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "RegeneratePassword", $this->regenPass);
  2967.         }
  2968.         // 050208 added by Sunny: Set flag to match one and only client record
  2969.         if (isset ($this->uniqueMatchOnly)) {
  2970.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "UniqueMatchOnly", $this->uniqueMatchOnly);
  2971.         }
  2972.         //template to be used for the password recovery email
  2973.         if (isset ($this->template)) {
  2974.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Template", $this->template);
  2975.         }
  2976.  
  2977.         // set client source
  2978.         if (isset ($this->source)) {
  2979.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Source", $this->source);
  2980.         }
  2981.         // 220108 added by Sunny: set the user defined fields
  2982.         if (isset($this->userDef)) {
  2983.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "UDF", "");
  2984.             $userDefKeys = array_keys($this->userDef);
  2985.             for ($i = 0; $i < count($userDefKeys); $i++) {
  2986.                 $key = $userDefKeys[$i];
  2987.                 $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/UDF", "Index", $key);
  2988.                 $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/UDF", "Value", $this->userDef[$key]);
  2989.             }
  2990.         }
  2991.         if (isset ($this->isPassCaseSensitive)) {
  2992.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "IsPassCaseSensitive", ($this->isPassCaseSensitive ? "true" : "false"));
  2993.         }
  2994.         if (isset ($this->isAgentOnly)) {
  2995.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "AgentOnly", ($this->isAgentOnly ? "true" : "false"));
  2996.         }
  2997.         if (isset ($this->isPrivateOnly)) {
  2998.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "PrivateOnly", ($this->isPrivateOnly ? "true" : "false"));
  2999.         }
  3000.         if (isset ($this->isInternetOnly)) {
  3001.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "InternetOnly", ($this->isInternetOnly ? "true" : "false"));
  3002.         }
  3003.         return $xmldoc;
  3004.     }
  3005. }
  3006.  
  3007. class SupplierService extends E2Interface {
  3008.     /* Deal with e2 Supplier service*/
  3009.     /* 140208 Added by Sunny */
  3010.     var $code;
  3011.     var $responseArray;
  3012.     function setCode($newC) {
  3013.         $this->code = $newC;
  3014.     }
  3015.     function getResponseArray() {
  3016.         return ($this->responseArray);
  3017.     }
  3018.  
  3019.     function SupplierService($newAction, $newURL, $newSessId) {
  3020.         /* constructor */
  3021.         $this->service = "SupplierService";
  3022.         $this->action = $newAction;
  3023.         $this->url = $newURL;
  3024.         $this->sessionId = $newSessId;
  3025.     }
  3026.     function getSupplierInfo() {
  3027.         $xmldoc = $this->buildRequestXMLDoc();
  3028.         $this->setReqXML($xmldoc->saveXML());
  3029.         //echo htmlentities($xmldoc->saveXML());
  3030.         $resXml = $this->postXmlMessage();
  3031.         //echo htmlentities($resXml);
  3032.         if (strlen($this->getErrorCode()) > 0) {
  3033.             return;
  3034.         }
  3035.         $this->responseArray = $this->parseResponse($resXml);
  3036.         return $this->responseArray;
  3037.     }
  3038.     function buildRequestXMLDoc() {
  3039.         /* build request xml for e2 FindSupplier */
  3040.         $xmldoc = $this->buildE2XMLHeader();
  3041.         $xpath = "//".$this->action;
  3042.         if (isset ($this->code)) {
  3043.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Code", $this->code);
  3044.         }
  3045.         return $xmldoc;
  3046.     }
  3047. }
  3048.  
  3049. class BookingDetail extends e2Interface {
  3050.     /* Deal with e2 BookingDetail*/
  3051.     /* Booking info is obsolate to use*/
  3052.  
  3053.     var $bookingNumber; // human readable booking number
  3054.     var $leadname; // Booking lead name
  3055.     var $departureDate; // departure date
  3056.     var $departFrom;   // departure date from
  3057.     var $departTo;     // departure date to
  3058.     var $customerCode; // customer code
  3059.     var $agentNumber; // agent number
  3060.     var $bookingStatList; // allowed booking status for find booking
  3061.     var $bookingSummary; // flag for booking summary details
  3062.     var $transactions; // flag for transaction details
  3063.     var $pax; // flag for passenger details
  3064.     var $notes; // flag for booking notes details
  3065.     var $docs; // flag for booking docs details
  3066.     var $toggleOrder; // flag for toggle itinerary order
  3067.     var $showCanx; // flag for showing cancelled lines
  3068.     var $lines; // flag for line detail of a line
  3069.     var $ShortDesc; // flag for shortdesc only in line header of a line
  3070.     var $finance;   // flag for finance information
  3071.     var $lastInvoice; // flag for last invoice only
  3072.     var $info; // info array
  3073.     var $responseArray; // responseArray
  3074.     var $params;
  3075.     var $userOnly; // flag for user only notification email
  3076.     var $detailLevel = array(); // for detail level flag
  3077.     var $error; // error code for user only notification email
  3078.     // booking notify
  3079.     var $emailTemplate;
  3080.     var $emailSender;
  3081.     var $emailTo;
  3082.     var $emailCc;
  3083.     var $emailBcc;
  3084.     var $emailSubject;
  3085.     var $emailMsg;
  3086.     var $emailNoMerge;
  3087.     var $emailUserRef;
  3088.     function addAllDetailLevel($dtl_array){
  3089.         if (!is_array($dtl_array)) {return;}
  3090.         foreach ($dtl_array as $dtl_item){
  3091.             array_push($this->detailLevel, $dtl_item);
  3092.         }
  3093.     }
  3094.     function addDetailLevel($flag, $value){
  3095.         if (strlen($flag)){
  3096.             $dtlLevel = new  AvailDetails($flag, $value);
  3097.             array_push($this->detailLevel, $dtlLevel);
  3098.         }
  3099.     }
  3100.     function setUserOnly($newUO) {
  3101.         $this->userOnly = $newUO;
  3102.     }
  3103.     function setError($newE) {
  3104.         $this->error = $newE;
  3105.     }
  3106.     function setParams($newParams) {
  3107.         $this->params = $newParams;
  3108.     }
  3109.     function setBookingNumber($newB) {
  3110.         $this->bookingNumber = $newB;
  3111.     }
  3112.     // set lead name
  3113.     function setLeadname($newLeadname) {
  3114.         $this->leadname = $newLeadname;
  3115.     }
  3116.     function setDepartureDate($newDEPDT) {
  3117.         $this->departureDate = $newDEPDT;
  3118.     }
  3119.     function setDepartureFrom($newDEPFR) {
  3120.         $this->departureFrom = $newDEPFR;
  3121.     }
  3122.     function setDepartureTo($newDEPTO) {
  3123.         $this->departureTo = $newDEPTO;
  3124.     }
  3125.     function setAgentNumber($newAGTCD) {
  3126.         $this->agentNumber = $newAGTCD;
  3127.     }
  3128.     function setCustomerCode($newCLCD) {
  3129.         $this->customerCode = $newCLCD;
  3130.     }
  3131.     function setBookingStatusList($newStatLs) {
  3132.         $this->bookingStatusList = $newStatLs;
  3133.     }
  3134.     function setBookingSummary($newBS = "") {
  3135.         $this->addDetailLevel("BookingSummary", $newBS);
  3136.     }
  3137.     function setTransactions($newT = "") {
  3138.         $this->addDetailLevel("Transactions", $newT);
  3139.     }
  3140.     function setPax($newP = "") {
  3141.         $this->addDetailLevel("Pax", $newP);
  3142.     }
  3143.     function setNotes($newN = "") {
  3144.         $this->addDetailLevel("Notes", $newN);
  3145.     }
  3146.     function setDocs($newD = "") {
  3147.         $this->addDetailLevel("Docs", $newD);
  3148.     }
  3149.     function setLatestDocs($newD = "") {
  3150.         $this->addDetailLevel("LatestDocs", $newD);
  3151.     }
  3152.     function setToggleOrder($newTG = "") {
  3153.         $this->addDetailLevel("ToggleOrder", $newTG);
  3154.     }
  3155.     function setShowCanx($newSC = "") {
  3156.         $this->addDetailLevel("ShowCanx", $newSC);
  3157.     }
  3158.     function setLines($newP = "Y") {
  3159.         $this->addDetailLevel("Lines", $newP);
  3160.     }
  3161.     function setShortDesc($newSD = "Y") {
  3162.         $this->addDetailLevel("ShortDesc", $newSD);
  3163.     }
  3164.     function setFinance($newSD = "Y") {
  3165.         $this->addDetailLevel("Finance", $newSD);
  3166.     }
  3167.     function setLastInvoice($newSD = "Y") {
  3168.         $this->addDetailLevel("LastInvoice", $newSD);
  3169.     }
  3170.     function setInfo($newI) {
  3171.         $this->addDetailLevel("Info", $newI);
  3172.     }
  3173.     function setEmailSender($sndr){
  3174.         $this->emailSender = $sndr;
  3175.     }
  3176.     function setEmailTo($to){
  3177.         $this->emailTo = $to;
  3178.     }
  3179.     function setEmailCc($cc){
  3180.         $this->emailCc = $cc;
  3181.     }
  3182.     function setEmailBcc($bcc){
  3183.         $this->emailBcc = $bcc;
  3184.     }
  3185.     function setEmailSubject($subject){
  3186.         $this->emailSubject = $subject;
  3187.     }
  3188.     function setEmailTemplate($template){
  3189.         $this->emailTemplate = $template;
  3190.     }
  3191.     function setEmailMsg($msg){
  3192.         $this->emailMsg = $msg;
  3193.     }
  3194.     function setEmailNoMerge($no_merge){
  3195.         $this->emailNoMerge = $no_merge;
  3196.     }
  3197.     function setEmailUserRef($userRef) {
  3198.         $this->emailUserRef = $userRef;
  3199.     }
  3200.     function getBookingNumber() {
  3201.         return $this->bookingNumber;
  3202.     }
  3203.     function getBookingSummary() {
  3204.         return $this->bookingSummary;
  3205.     }
  3206.     function getTransactions() {
  3207.         return $this->transaction;
  3208.     }
  3209.     function getPax() {
  3210.         return $this->pax;
  3211.     }
  3212.     function getNotes() {
  3213.         return $this->notes;
  3214.     }
  3215.     function getDocs() {
  3216.         return $this->docs;
  3217.     }
  3218.     function getToggleOrder() {
  3219.         return $this->toggleOrder;
  3220.     }
  3221.     function getShowCanx() {
  3222.         return $this->showCanx;
  3223.     }
  3224.     function getInfo() {
  3225.         return $this->info;
  3226.     }
  3227.     function getResponseArray() {
  3228.         return ($this->responseArray);
  3229.     }
  3230.     function BookingDetail($newAction, $newURL, $newSessId, $newBookingNumber = "") {
  3231.         /* constructor */
  3232.         $this->service = "ReservationService";
  3233.         $this->action = $newAction;
  3234.         $this->url = $newURL;
  3235.         $this->sessionId = $newSessId;
  3236.         $this->bookingNumber = $newBookingNumber;
  3237.     }
  3238.     function findInfo() {
  3239.         $xmldoc = $this->buildRequestXMLDoc();
  3240.         $this->setReqXML($xmldoc->saveXML());
  3241.         //echo htmlentities($xmldoc->saveXML());
  3242.         $resXml = $this->postXmlMessage();
  3243.         //echo htmlentities($resXml);
  3244.         if (strlen($this->getErrorCode()) > 0) {
  3245.             return;
  3246.         }
  3247.         $this->responseArray = $this->parseResponse($resXml);
  3248.         return $this->responseArray;
  3249.     }
  3250.     function buildRequestXMLDoc() {
  3251.         /* build request xml for e2 BookingDetails*/
  3252.         $xmldoc = $this->buildE2XMLHeader();
  3253.         $xpath = "//".$this->action;
  3254.         if (isset ($this->bookingNumber)) {
  3255.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "BookingNumber", $this->bookingNumber);
  3256.         }
  3257.         if (isset ($this->leadname)) {
  3258.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Leadname", $this->leadname);
  3259.         }
  3260.         if (isset ($this->departureDate)) {
  3261.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "DepartureDate", $this->departureDate);
  3262.         }
  3263.         if (isset ($this->departureFrom)) {
  3264.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "DepartFrom", $this->departureFrom);
  3265.         }
  3266.         if (isset ($this->departureTo)) {
  3267.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "DepartTo", $this->departureTo);
  3268.         }
  3269.         if (isset ($this->customerCode)) {
  3270.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "CustomerCode", $this->customerCode);
  3271.         }
  3272.         if (isset ($this->agentNumber)) {
  3273.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "AgentNumber", $this->agentNumber);
  3274.         }
  3275.         if (isset ($this->bookingStatusList)) {
  3276.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "BookingStatusList", $this->bookingStatusList);
  3277.         }
  3278.         // detail level only for BookingInfo action
  3279.         if ($this->action == "BookingInfo") {
  3280.             /* for detail information*/
  3281.             for ($index = 0; $index < sizeof($this->detailLevel) && isset ($this->detailLevel[$index]); $index ++) {
  3282.                 $detailFlag = $this->detailLevel[$index];
  3283.                 if ($index == 0) {
  3284.                     $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "DetailLevel", "");
  3285.                 }
  3286.                 $xmldoc = $detailFlag->buildRequestXMLDoc($xmldoc, $xpath."/DetailLevel");
  3287.             }
  3288.         }
  3289.     if ($this->action == "BookingNotify") {
  3290.       if (isset ($this->error) && strlen($this->error)) {
  3291.         $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Error", $this->error);
  3292.       }
  3293.       if (isset($this->emailSender)){
  3294.         $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Sender", $this->emailSender);
  3295.       }
  3296.       if (isset($this->emailBcc)){
  3297.         $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Bcc", $this->emailBcc);
  3298.       }
  3299.       if (isset($this->emailCc)){
  3300.         $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Cc", $this->emailCc);
  3301.       }
  3302.       if (isset($this->emailTo)){
  3303.         $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "To", $this->emailTo);
  3304.       }
  3305.       if (isset($this->emailTemplate)){
  3306.         $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Template", $this->emailTemplate);
  3307.       }
  3308.       if (isset($this->emailSubject)){
  3309.         $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Subject", $this->emailSubject);
  3310.       }
  3311.       if (isset($this->emailMsg)){
  3312.         $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Message", $this->emailMsg);
  3313.       }
  3314.       if (isset($this->emailNoMerge) && $this->emailNoMerge){
  3315.         $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "NoMerge", '');
  3316.       }
  3317.       if (isset($this->emailUserRef) && $this->emailUserRef){
  3318.         $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "UserReference", $this->emailUserRef);
  3319.       }
  3320.     }
  3321.  
  3322.     // detail level only for BookingInfo action
  3323.     if ($this->action == "BookingParams") {
  3324.       for ($i = 0; $i < count($this->params); $i ++) {
  3325.         $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Param", "");
  3326.         $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Param", "Action", $this->params[$i]->getAction());
  3327.         $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Param", "Name", $this->params[$i]->getName());
  3328.         $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Param", "Value", $this->params[$i]->getValue());
  3329.       }
  3330.     }
  3331.         return $xmldoc;
  3332.     }
  3333. }
  3334. class BasicDataService extends E2Interface {
  3335.     /* Deal with e2 Data service*/
  3336.     /* Modified by Yayun Sun to have a desciption field and to set LiveOnly properly */
  3337.     // postcode to find address
  3338.     var $postcode;
  3339.     // type to find code
  3340.     var $type;
  3341.     // code to find code
  3342.     var $code;
  3343.     // miscelinious Fields to find code
  3344.     var $miscFields;
  3345.     // description field to find code
  3346.     var $desc;
  3347.     // Live flag
  3348.     var $liveOnly;
  3349.     //Available on the Internet flag
  3350.     var $internetOnly;
  3351.     // response array of the service
  3352.     var $responseArray;
  3353.     // set postcode
  3354.     function setPostcode($newPOCD) {
  3355.         $this->postcode = $newPOCD;
  3356.     }
  3357.     // set type
  3358.     function setType($newT) {
  3359.         $this->type = $newT;
  3360.     }
  3361.     // set code
  3362.     function setCode($newC) {
  3363.         $this->code = $newC;
  3364.     }
  3365.     // set description
  3366.     function setDesc($newD) {
  3367.         $this->setDesc = $newD;
  3368.     }
  3369.     // set misc fields for DC
  3370.     function setMiscFields($newM) {
  3371.         $this->miscFields = $newM;
  3372.     }
  3373.     //set live only flag
  3374.     function setLiveOnly($newFlag) {
  3375.         $this->liveOnly = $newFlag;
  3376.     }
  3377.     // Set available on the Internet
  3378.     function setInternetOnly($newFlag){
  3379.         $this->internetOnly = $newFlag;
  3380.     }
  3381.     function setResponseArray($newRA) {
  3382.         $this->responseArray = $newRA;
  3383.     }
  3384.  
  3385.     function getResponseArray() {
  3386.         return $this->responseArray;
  3387.     }
  3388.     function BasicDataService($newAction, $url, $sessId) {
  3389.         $this->service = "DataService";
  3390.         $this->action = $newAction;
  3391.         $this->url = $url;
  3392.         $this->sessionId = $sessId;
  3393.     }
  3394.     // return data
  3395.     function getData() {
  3396.         $xmldoc = $this->buildRequestXMLDoc();
  3397.         $this->setReqXML($xmldoc->saveXML());
  3398.         //echo htmlentities($xmldoc->saveXML());
  3399.         $resXml = $this->postXmlMessage();
  3400.         //echo htmlentities($resXml);
  3401.         $this->responseArray = $this->parseResponse($resXml);
  3402.         return $this->responseArray;
  3403.     }
  3404.     function buildRequestXMLDoc() {
  3405.         /* build request xml for e2 CancelTransaction */
  3406.         $xmldoc = $this->buildE2XMLHeader();
  3407.         $xpath = "//".$this->action;
  3408.         // postcode to find address
  3409.         if (isset ($this->postcode)) {
  3410.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Postcode", $this->postcode);
  3411.         }
  3412.         // type to find code from dc
  3413.         if (isset ($this->type)) {
  3414.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Type", $this->type);
  3415.         }
  3416.         // code to find code from dc
  3417.         if (isset ($this->code)) {
  3418.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Code", $this->code);
  3419.         }
  3420.         // description to find code from dc
  3421.         if (isset ($this->desc)) {
  3422.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Description", $this->desc);
  3423.         }
  3424.         // misc fields to find code from dc
  3425.         if (isset ($this->miscFields)) {
  3426.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "MiscFields", $this->miscFields);
  3427.         }
  3428.         // add LiveOnly flag
  3429.         if (isset ($this->liveOnly)) {
  3430.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "LiveOnly", (!$this->liveOnly) ? "false" : "true");
  3431.         }
  3432.         // add available on the Internet flag
  3433.         if (isset ($this->internetOnly)) {
  3434.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "InternetOnly", (!$this->internetOnly) ? "false" : "true");
  3435.         }
  3436.         return $xmldoc;
  3437.     }
  3438. }
  3439. class PassengerInfo extends e2Interface {
  3440.     /* Deal with e2 PassengerInfo*/
  3441.     /* Added by Yayun Sun */
  3442.     var $bookingNumber; // Human readable booking number
  3443.     var $paxCode;       // The passenger code
  3444.     var $responseArray; // Response array
  3445.     function setBookingNumber($newB) {
  3446.         $this->bookingNumber = $newB;
  3447.     }
  3448.     function setPaxCode($newP) {
  3449.         $this->paxCode = $newP;
  3450.     }
  3451.     function getBookingNumber() {
  3452.         return $this->bookingNumber;
  3453.     }
  3454.     function getPaxCode() {
  3455.         return $this->paxCode;
  3456.     }
  3457.     function getResponseArray() {
  3458.         return $this->responseArray;
  3459.     }
  3460.     function PassengerInfo($newAction, $newURL, $newSessId, $newBookingNumber = "", $newPaxCode = "") {
  3461.         /* constructor */
  3462.         $this->service = "ReservationService";
  3463.         $this->action = $newAction;
  3464.         $this->url = $newURL;
  3465.         $this->sessionId = $newSessId;
  3466.         $this->bookingNumber = $newBookingNumber;
  3467.         $this->paxCode = $newPaxCode;
  3468.     }
  3469.     function findInfo() {
  3470.         $xmldoc = $this->buildRequestXMLDoc();
  3471.         $this->setReqXML($xmldoc->saveXML());
  3472.         $resXml = $this->postXmlMessage();
  3473.         if (strlen($this->getErrorCode()) > 0) {
  3474.             return;
  3475.         }
  3476.         //$this->responseArray = $this->parseResponse($resXml);
  3477.         //return $this->responseArray;
  3478.         return $resXml;
  3479.     }
  3480.     function buildRequestXMLDoc() {
  3481.         /* build request xml for e2 PassengerInfo*/
  3482.         $xmldoc = $this->buildE2XMLHeader();
  3483.         $xpath = "//".$this->action;
  3484.         if (isset ($this->bookingNumber)) {
  3485.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "BookingNumber", $this->bookingNumber);
  3486.         }
  3487.         if (isset ($this->paxCode)) {
  3488.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "PaxCode", $this->paxCode);
  3489.         }
  3490.         return $xmldoc;
  3491.     }
  3492. }
  3493.  
  3494. class AssignPassenger extends e2Interface {
  3495.     /* Deal with e2 AssignPassenger*/
  3496.     /* Added by Yayun Sun */
  3497.     var $transactionNumber; // The transaction number
  3498.     var $paxList;       // The list of passenger codes
  3499.     var $toReplace;     // Whether the passenger list should replace the existing one or simply appending
  3500.     var $canClear;      // Whether the passenger list can be cleared by replacing
  3501.     function setTransactionNumber($newT) {
  3502.         $this->transactionNumber = $newT;
  3503.     }
  3504.     function setPaxList($newP) {
  3505.         $this->paxList = $newP;
  3506.     }
  3507.     function setToReplace($newR) {
  3508.         $this->toReplace = $newR;
  3509.     }
  3510.     function setCanClear($newC) {
  3511.         $this->canClear = $newC;
  3512.     }
  3513.     function getTransactionNumber() {
  3514.         return $this->TransactionNumber;
  3515.     }
  3516.     function getPaxList() {
  3517.         return $this->paxList;
  3518.     }
  3519.     function getToReplace() {
  3520.         return $this->toReplace;
  3521.     }
  3522.     function getCanClear() {
  3523.         return $this->canClear;
  3524.     }
  3525.  
  3526.     function AssignPassenger($newURL, $newSessId, $newTransactionNumber = "", $newPaxList = "", $newToReplace = false, $newCanClear = false) {
  3527.         /* constructor */
  3528.         $this->service = "ReservationService";
  3529.         $this->action = "AssignPassenger";
  3530.         $this->url = $newURL;
  3531.         $this->sessionId = $newSessId;
  3532.         $this->transactionNumber = $newTransactionNumber;
  3533.         $this->paxList = $newPaxList;
  3534.         $this->toReplace = $newToReplace;
  3535.         $this->canClear = $newCanClear;
  3536.     }
  3537.     function assign() {
  3538.         $xmldoc = $this->buildRequestXMLDoc();
  3539.         $this->setReqXML($xmldoc->saveXML());
  3540.         $resXml = $this->postXmlMessage();
  3541.         if (strlen($this->getErrorCode()) > 0) {
  3542.             return;
  3543.         }
  3544.         $this->responseArray = $this->parseResponse($resXml);
  3545.         return $this->responseArray;
  3546.     }
  3547.     function buildRequestXMLDoc() {
  3548.         /* build request xml for e2 AssignPassenger */
  3549.         $xmldoc = $this->buildE2XMLHeader();
  3550.         $xpath = "//".$this->action;
  3551.         $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "BookingTransaction", "");
  3552.         if (isset ($this->transactionNumber)) {
  3553.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/BookingTransaction", "TransactionNumber", $this->transactionNumber);
  3554.         }
  3555.         if (isset ($this->paxList)) {
  3556.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/BookingTransaction", "PassengerList", $this->paxList);
  3557.         }
  3558.         if (isset ($this->toReplace) && $this->toReplace) {
  3559.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/BookingTransaction", "Replace", "");
  3560.             if (isset ($this->canClear) && $this->canClear) {
  3561.                 $xmldoc = $this->setXNodeAttribute($xmldoc, $xpath."/BookingTransaction/Replace", "Null", "true");
  3562.             }
  3563.         }
  3564.         return $xmldoc;
  3565.     }
  3566. }
  3567.  
  3568. class PrepareUpdateTransaction extends e2Interface {
  3569.     /* Deal with e2 PrepareUpdateTransaction */
  3570.     /* Added by Yayun Sun */
  3571.     var $tranNumber;    // Booking transaction number
  3572.     var $suppNumber;    // Booking supplemenet number
  3573.     var $responseArray; // Response array
  3574.     var $resType;       // Response type: array or xml
  3575.     function setTranNumber($newT) {
  3576.         $this->tranNumber = $newT;
  3577.     }
  3578.     function setSuppNumber($newS) {
  3579.         $this->suppNumber = $newS;
  3580.     }
  3581.     function setResType($newType) {
  3582.         $this->resType = $newType;
  3583.     }
  3584.     function getTranNumber() {
  3585.         return $this->tranNumber;
  3586.     }
  3587.     function getSuppNumber() {
  3588.         return $this->suppNumber;
  3589.     }
  3590.     function getResponseArray() {
  3591.         return $this->responseArray;
  3592.     }
  3593.     function PrepareUpdateTransaction($newAction, $newURL, $newSessId, $newTranNumber = "", $newSuppNumber = "", $newType = "array") {
  3594.         /* constructor */
  3595.         $this->service = "ReservationService";
  3596.         $this->action = $newAction;
  3597.         $this->url = $newURL;
  3598.         $this->sessionId = $newSessId;
  3599.         $this->tranNumber = $newTranNumber;
  3600.         $this->suppNumber = $newSuppNumber;
  3601.         $this->resType = $newType;
  3602.     }
  3603.     function findTranInfo() {
  3604.         $xmldoc = $this->buildRequestXMLDoc();
  3605.         $this->setReqXML($xmldoc->saveXML());
  3606.         //echo htmlentities($xmldoc->saveXML());
  3607.         $resXml = $this->postXmlMessage();
  3608.         //echo htmlentities($resXml);
  3609.         if ($this->resType == "array") {
  3610.             $this->responseArray = $this->parseResponse($resXml);
  3611.             return $this->responseArray;
  3612.         } else if ($this->resType == "xml") {
  3613.             return $resXml;
  3614.         }
  3615.     }
  3616.     function buildRequestXMLDoc() {
  3617.         /* build request xml for e2 UpdateTransactionInfo*/
  3618.         $xmldoc = $this->buildE2XMLHeader();
  3619.         $xpath = "//".$this->action;
  3620.         if (isset ($this->tranNumber)) {
  3621.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "TransactionNumber", $this->tranNumber);
  3622.         }
  3623.         if (isset ($this->suppNumber)) {
  3624.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "SupplementNumber", $this->suppNumber);
  3625.         }
  3626.         return $xmldoc;
  3627.     }
  3628. }
  3629. class UpdateTransaction extends e2Interface {
  3630.     /* Deal with e2 UpdateTransaction */
  3631.     /* Added by Yayun Sun */
  3632.     var $tranNumber;    // Booking transaction number
  3633.     var $suppNumber;    // Booking supplemenet number
  3634.     var $lineStyleArray; // Store line style fields
  3635.     function setTranNumber($newT) {
  3636.         $this->tranNumber = $newT;
  3637.     }
  3638.     function setSuppNumber($newS) {
  3639.         $this->suppNumber = $newS;
  3640.     }
  3641.     function setLineStyleArray($newLX) {
  3642.         $this->lineStyleArray = $newLX;
  3643.     }
  3644.     function getTranNumber() {
  3645.         return $this->tranNumber;
  3646.     }
  3647.     function getSuppNumber() {
  3648.         return $this->suppNumber;
  3649.     }
  3650.     function UpdateTransaction($newAction, $newURL, $newSessId, $newTranNumber = "", $newSuppNumber = "", $newLX = "") {
  3651.         /* constructor */
  3652.         $this->service = "ReservationService";
  3653.         $this->action = $newAction;
  3654.         $this->url = $newURL;
  3655.         $this->sessionId = $newSessId;
  3656.         $this->tranNumber = $newTranNumber;
  3657.         $this->suppNumber = $newSuppNumber;
  3658.         $this->lineStyleArray = $newLX;
  3659.     }
  3660.     function update($sessId) {
  3661.         $xmldoc = $this->buildRequestXMLDoc($sessId);
  3662.         $this->setReqXML($xmldoc->saveXML());
  3663.         //echo htmlentities($xmldoc->saveXML());
  3664.         $resXml = $this->postXmlMessage();
  3665.         //echo htmlentities($resXml);
  3666.         $this->parseResponse($this->resXML);
  3667.     }
  3668.     function buildRequestXMLDoc($sessId) {
  3669.         /* build request xml for e2 UpdateTransaction */
  3670.         $service_name = $this->action;
  3671.         $xmldoc = $this->buildE2XMLHeader($this->service, $service_name, $sessId);
  3672.         $xpath = "//".$service_name;
  3673.         $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "TransactionNumber", $this->tranNumber);
  3674.         $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "SupplementNumber", $this->suppNumber);
  3675.         if (is_array($this->lineStyleArray)) {
  3676.           $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "LineStyleDetails", "");
  3677.           foreach ($this->lineStyleArray as $lxs) {
  3678.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/LineStyleDetails", "LineStyle", "");
  3679.             if (isset ($lxs["Field"])) {
  3680.               $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/LineStyleDetails/LineStyle", "Field", $lxs["Field"]);
  3681.               $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/LineStyleDetails/LineStyle", "Value", $lxs["Value"]);
  3682.             }
  3683.           }
  3684.         }
  3685.         return $xmldoc;
  3686.     }
  3687. }
  3688. class FindBookings extends e2Interface {
  3689.     /* Deal with e2 FindBookings */
  3690.     /* Added by Yayun Sun */
  3691.     var $clientCode;
  3692.     var $bookingNumber;
  3693.     var $departFrom;
  3694.     var $departTo;
  3695.     function setClientCode($newC) {
  3696.         $this->clientCode = $newC;
  3697.     }
  3698.     function getClientCode($newC) {
  3699.         return $this->clientCode;
  3700.     }
  3701.     function setBookingNumber($newB) {
  3702.         $this->bookingNumber = $newB;
  3703.     }
  3704.     function getBookingNumber($newB) {
  3705.         return $this->bookingNumber;
  3706.     }
  3707.     function setDepartFrom($newD) {
  3708.         $this->departFrom = $newD;
  3709.     }
  3710.     function setDepartTo($newD) {
  3711.         $this->departTo = $newD;
  3712.     }
  3713.     function FindBookings($newAction, $newURL, $newSessId, $newClientCode = "") {
  3714.         /* constructor */
  3715.         $this->service = "ReservationService";
  3716.         $this->action = $newAction;
  3717.         $this->url = $newURL;
  3718.         $this->sessionId = $newSessId;
  3719.         $this->clientCode = $newClientCode;
  3720.     }
  3721.     function findBookingList() {
  3722.         $xmldoc = $this->buildRequestXMLDoc();
  3723.         $this->setReqXML($xmldoc->saveXML());
  3724.         //echo htmlentities($xmldoc->saveXML());
  3725.         $resXml = $this->postXmlMessage();
  3726.         //echo htmlentities($resXml);
  3727.         if (strlen($this->getErrorCode()) > 0) {
  3728.             return;
  3729.         }
  3730.         $this->responseArray = $this->parseResponse($resXml);
  3731.         return $this->responseArray;
  3732.     }
  3733.     function buildRequestXMLDoc() {
  3734.         /* build request xml for e2 FindBookings*/
  3735.         $xmldoc = $this->buildE2XMLHeader();
  3736.         $xpath = "//".$this->action;
  3737.         if (isset ($this->clientCode)) {
  3738.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "CustomerCode", $this->clientCode);
  3739.         }
  3740.         if (isset ($this->bookingNumber)) {
  3741.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "BookingNumber", $this->bookingNumber);
  3742.         }
  3743.         if (isset ($this->departFrom)) {
  3744.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "DepartFrom", $this->departFrom);
  3745.         }
  3746.         if (isset ($this->departTo)) {
  3747.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "DepartTo", $this->departTo);
  3748.         }
  3749.         return $xmldoc;
  3750.     }
  3751. }
  3752.  
  3753. class PriceOverride extends E2Interface{
  3754.     /* Deal with  price override*/
  3755.     var $adult, $conc1, $conc2, $conc3, $infant, $unit;
  3756.     function setAdult($price){
  3757.         $this->adult = $price;
  3758.     }
  3759.     function setConc1($price){
  3760.         $this->conc1 = $price;
  3761.     }
  3762.     function setConc2($price){
  3763.         $this->conc2 = $price;
  3764.     }
  3765.     function setConc3($price){
  3766.         $this->conc3 = $price;
  3767.     }
  3768.     function setInfant($price){
  3769.         $this->infant = $price;
  3770.     }
  3771.     function setUnit($price){
  3772.         $this->unit = $price;
  3773.     }
  3774.     function buildOverrideXML($xmldoc, $xpath){
  3775.         if (isset($this->adult)){
  3776.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Adult", $this->adult);
  3777.         }
  3778.         if (isset($this->conc1)){
  3779.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Conc1", $this->conc1);
  3780.         }
  3781.         if (isset($this->conc2)){
  3782.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Conc2", $this->conc2);
  3783.         }
  3784.         if (isset($this->conc3)){
  3785.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Conc3", $this->conc3);
  3786.         }
  3787.         if (isset($this->infant)){
  3788.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Infant", $this->infant);
  3789.         }
  3790.         if (isset($this->unit)){
  3791.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Unit", $this->unit);
  3792.         }
  3793.         return $xmldoc;
  3794.     }
  3795. }
  3796.  
  3797. class SellPriceOverride extends PriceOverride{
  3798.     function  SellPriceOverride(){
  3799.     }
  3800.     function buildReqXML($xmldoc, $xpath){
  3801.         $override_tag_name = "SellPriceOverride";
  3802.         $xmldoc = $this->setXNodeValue($xmldoc, $xpath, $override_tag_name, "");
  3803.         $xmldoc = $this->buildOverrideXML($xmldoc, $xpath ."/".$override_tag_name);
  3804.         return $xmldoc;
  3805.  
  3806.     }
  3807. }
  3808.  
  3809. class CostPriceOverride extends PriceOverride{
  3810.     function  SellPriceOverride($adult_prc){
  3811.         $this->adult = $adult_prc;
  3812.     }
  3813.     function buildReqXML($xmldoc, $xpath){
  3814.         $override_tag_name = "CostPriceOverride";
  3815.         $xmldoc = $this->setXNodeValue($xmldoc, $xpath, $override_tag_name, "");
  3816.         $xmldoc = $this->buildOverrideXML($xmldoc, $xpath ."/".$override_tag_name);
  3817.         return $xmldoc;
  3818.  
  3819.     }
  3820. }
  3821.  
  3822. class FindDBData extends E2Interface {
  3823.     /* Deal with e2 Maintenance Service - Find*/
  3824.     /* Added by Yayun Sun*/
  3825.     var $table; // the table name in Embarque
  3826.     var $tableKey;  // the key name of the table used for the search
  3827.     var $matchFrom; // the starting search point for the key
  3828.     var $matchTo;   // the end search point for the key
  3829.     var $select;    // the filter criteria
  3830.     // 120208 added by Sunny: The fields to return in response
  3831.     var $showFields;// the fields to return
  3832.     var $liveOnly;  // the live flag
  3833.     var $resType;   // Response type: array or xml
  3834.     function setTable($newTable) {
  3835.         $this->table = $newTable;
  3836.     }
  3837.     function setTableKey($newTableKey) {
  3838.         $this->tableKey = $newTableKey;
  3839.     }
  3840.     function setMatchFrom($keyValuePairs) {
  3841.         $this->matchFrom = $keyValuePairs;
  3842.     }
  3843.     function setMatchTo($keyValuePairs) {
  3844.         $this->matchTo = $keyValuePairs;
  3845.     }
  3846.     function setSelect($keyValuePairs) {
  3847.         $this->select = $keyValuePairs;
  3848.     }
  3849.         function setShowFields($fields) {
  3850.                 $this->showFields = $fields;
  3851.         }
  3852.     function setLiveOnly($newLiveOnly) {
  3853.         $this->liveOnly = $newLiveOnly;
  3854.     }
  3855.     function setResType($newType) {
  3856.         $this->resType = $newType;
  3857.     }
  3858.     function getResponseArray() {
  3859.         return $this->responseArray;
  3860.     }
  3861.     function FindDBData($newTable = "", $newTableKey = "", $newLiveOnly = true, $newType = "array") {
  3862.         /* constructor */
  3863.         $this->service = "MaintenanceService";
  3864.         $this->action = "Find";
  3865.         $this->table = $newTable;
  3866.         $this->tableKey = $newTableKey;
  3867.         $this->liveOnly = $newLiveOnly;
  3868.         $this->resType = $newType;
  3869.     }
  3870.     function find($url, $sessId) {
  3871.         $xmldoc = $this->buildRequestXMLDoc($sessId);
  3872.         $this->setUrl($url);
  3873.         $this->setReqXML($xmldoc->saveXML());
  3874.         //echo htmlentities($xmldoc->saveXML());
  3875.         $resXml = $this->postXmlMessage();
  3876.         //echo htmlentities($resXml);
  3877.         if ($this->resType == "array") {
  3878.             $this->responseArray = $this->parseResponse($this->resXML);
  3879.             return $this->responseArray;
  3880.         } else if ($this->resType == "xml") {
  3881.             return $resXml;
  3882.         }
  3883.     }
  3884.     function buildRequestXMLDoc($sessId) {
  3885.         /* build request xml for e2 MaintenanceService - Find */
  3886.         $service_name = $this->action;
  3887.         $xmldoc = $this->buildE2XMLHeader($this->service, $service_name, $sessId);
  3888.         $xpath = "//".$service_name;
  3889.         /* add search criteria */
  3890.         if (isset($this->table)) {
  3891.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Table", $this->table);
  3892.         }
  3893.         if (isset($this->tableKey)) {
  3894.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Key", $this->tableKey);
  3895.         }
  3896.         if (isset($this->matchFrom)) {
  3897.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "MatchFrom", "");
  3898.             $matchFromKeys = array_keys($this->matchFrom);
  3899.             for ($i = 0; $i < count($matchFromKeys); $i++) {
  3900.                 $key = $matchFromKeys[$i];
  3901.                 $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/MatchFrom", $key, $this->matchFrom[$key]);
  3902.             }
  3903.         }
  3904.         if (isset($this->matchTo)) {
  3905.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "MatchTo", "");
  3906.             $matchToKeys = array_keys($this->matchTo);
  3907.             for ($i = 0; $i < count($matchToKeys); $i++) {
  3908.                 $key = $matchToKeys[$i];
  3909.                 $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/MatchTo", $key, $this->matchTo[$key]);
  3910.             }
  3911.         }
  3912.         if (isset($this->select)) {
  3913.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Select", "");
  3914.             $selectKeys = array_keys($this->select);
  3915.             for ($i = 0; $i < count($selectKeys); $i++) {
  3916.                 $key = $selectKeys[$i];
  3917.                 $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Select", $key, $this->select[$key]);
  3918.             }
  3919.         }
  3920.         if (isset($this->showFields)) {
  3921.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "ShowFields", $this->showFields);
  3922.         }
  3923.         if (isset($this->liveOnly)) {
  3924.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "LiveOnly", (!$this->liveOnly) ? "false" : "true");
  3925.         }
  3926.         return $xmldoc;
  3927.     }
  3928. }
  3929.  
  3930. class UpdateDBData extends E2Interface {
  3931.     /* Deal with e2 Maintenance Service - Update*/
  3932.     /* Added by Yayun Sun*/
  3933.     var $table;         // the table name in Embarque
  3934.     var $tableKey;      // the key name of the table used for the search
  3935.     var $bookmark;      // the bookmark of the record to be updated
  3936.     var $updates;       // the updates
  3937.     function setTable($newTable) {
  3938.         $this->table = $newTable;
  3939.     }
  3940.     function setTableKey($newTableKey) {
  3941.         $this->tableKey = $newTableKey;
  3942.     }
  3943.     function setBookmark($bookmark) {
  3944.         $this->bookmark = $bookmark;
  3945.     }
  3946.     function setUpdates($keyValuePairs) {
  3947.         $this->updates = $keyValuePairs;
  3948.     }
  3949.     function getResponseArray() {
  3950.         return $this->responseArray;
  3951.     }
  3952.     function UpdateDBData($newTable = "", $newTableKey = "", $bookmark = "") {
  3953.         /* constructor */
  3954.         $this->service = "MaintenanceService";
  3955.         $this->action = "Update";
  3956.         $this->table = $newTable;
  3957.         $this->tableKey = $newTableKey;
  3958.         $this->bookmark = $bookmark;
  3959.     }
  3960.     function update($url, $sessId) {
  3961.         $xmldoc = $this->buildRequestXMLDoc($sessId);
  3962.         $this->setUrl($url);
  3963.         $this->setReqXML($xmldoc->saveXML());
  3964.         //echo htmlentities($xmldoc->saveXML());
  3965.         $resXml = $this->postXmlMessage();
  3966.         //echo htmlentities($resXml);
  3967.         $this->responseArray = $this->parseResponse($this->resXML);
  3968.         return $this->responseArray;
  3969.     }
  3970.     function buildRequestXMLDoc($sessId) {
  3971.         /* build request xml for e2 MaintenanceService - Update */
  3972.         $service_name = $this->action;
  3973.         $xmldoc = $this->buildE2XMLHeader($this->service, $service_name, $sessId);
  3974.         $xpath = "//".$service_name;
  3975.         /* add search criteria */
  3976.         if (isset($this->table)) {
  3977.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Table", $this->table);
  3978.         }
  3979.         if (isset($this->tableKey)) {
  3980.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Key", $this->tableKey);
  3981.         }
  3982.         if (isset($this->bookmark)) {
  3983.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Record", "");
  3984.             $xmldoc = $this->setXNodeAttribute($xmldoc, $xpath."/Record", "Bookmark", $this->bookmark);
  3985.         }
  3986.         if (isset($this->updates)) {
  3987.             $updatesKeys = array_keys($this->updates);
  3988.             for ($i = 0; $i < count($updatesKeys); $i++) {
  3989.                 $key = $updatesKeys[$i];
  3990.                 $xmldoc = $this->setXNodeValue($xmldoc, $xpath."/Record", $key, $this->updates[$key]);
  3991.             }
  3992.         }
  3993.         return $xmldoc;
  3994.     }
  3995. }
  3996.  
  3997. class GetProperties extends E2Interface {
  3998.     /* Deal with e2 Data Service (Ext 1) - GetProperties*/
  3999.     /* Added by Yayun Sun*/
  4000.     var $propertyCode; // the property code
  4001.     var $liveOnly;  // the live flag
  4002.     function setPropertyCode($newCode) {
  4003.         $this->propertyCode = $newCode;
  4004.     }
  4005.     function setLiveOnly($newLiveOnly) {
  4006.         $this->liveOnly = $newLiveOnly;
  4007.     }
  4008.     function getResponseArray() {
  4009.         return $this->responseArray;
  4010.     }
  4011.     function GetProperties($newCode = "", $newLiveOnly = true) {
  4012.         /* constructor */
  4013.         $this->service = "DataService";
  4014.         $this->action = "GetProperties";
  4015.         $this->propertyCode = $newCode;
  4016.         $this->liveOnly = $newLiveOnly;
  4017.     }
  4018.     function findProperty($url, $sessId) {
  4019.         $xmldoc = $this->buildRequestXMLDoc($sessId);
  4020.         $this->setUrl($url);
  4021.         $this->setReqXML($xmldoc->saveXML());
  4022.         //echo htmlentities($xmldoc->saveXML());
  4023.         $resXml = $this->postXmlMessage();
  4024.         //echo htmlentities($resXml);
  4025.         $this->responseArray = $this->parseResponse($this->resXML);
  4026.         return $this->responseArray;
  4027.     }
  4028.     function buildRequestXMLDoc($sessId) {
  4029.         /* build request xml for e2 Data Service (Ext 1) - GetProperties */
  4030.         $service_name = $this->action;
  4031.         $xmldoc = $this->buildE2XMLHeader($this->service, $service_name, $sessId);
  4032.         $xpath = "//".$service_name;
  4033.         /* add search criteria */
  4034.         if (isset($this->propertyCode)) {
  4035.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "PropertyCode", $this->propertyCode);
  4036.         }
  4037.         if (isset($this->liveOnly)) {
  4038.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "LiveOnly", (!$this->liveOnly) ? "N" : "Y");
  4039.         }
  4040.         return $xmldoc;
  4041.     }
  4042. }
  4043.  
  4044. class GetAccommodations extends E2Interface {
  4045.     /* Deal with e2 Data Service (Ext 1) - GetAccommodations*/
  4046.     /* Added by NR*/
  4047.     var $accommodationCode; // the room/accommodation code
  4048.     // 150508 added by Sunny: Code from/to
  4049.     var $codeFrom;
  4050.     var $codeTo;
  4051.     var $features; // the room feature code(s)
  4052.     var $liveOnly;      // the live flag
  4053.     // 210508 added by Sunny: Detail level
  4054.     var $detailLevel;   // the details level array
  4055.     function setAccommodationCode($newCode) {
  4056.         $this->accommodationCode = $newCode;
  4057.     }
  4058.     function setCodeFrom($newCodeFrom) {
  4059.         $this->codeFrom = $newCodeFrom;
  4060.     }
  4061.     function setCodeTo($newCodeTo) {
  4062.         $this->codeTo = $newCodeTo;
  4063.     }
  4064.     function setLiveOnly($newLiveOnly) {
  4065.         $this->liveOnly = $newLiveOnly;
  4066.     }
  4067.     function setFeatures($newFeatures) {
  4068.         $this->features = $newFeatures;
  4069.     }
  4070.     function setDetailLevel($newDetailLevel) {
  4071.         $this->detailLevel = $newDetailLevel;
  4072.     }
  4073.     function getResponseArray() {
  4074.         return $this->responseArray;
  4075.     }
  4076.     function GetAccommodations($newCode = "", $newLiveOnly = true, $detailLevel = array()) {
  4077.         /* constructor */
  4078.         $this->service = "DataService";
  4079.         $this->action = "GetAccommodations";
  4080.         $this->accommodationCode = $newCode;
  4081.         $this->liveOnly = $newLiveOnly;
  4082.         $this->detailLevel = $detailLevel;
  4083.     }
  4084.     function findAccommodation($url, $sessId) {
  4085.         $xmldoc = $this->buildRequestXMLDoc($sessId);
  4086.         $this->setUrl($url);
  4087.         $this->setReqXML($xmldoc->saveXML());
  4088.         //echo htmlentities($xmldoc->saveXML());
  4089.         $resXml = $this->postXmlMessage();
  4090.         //echo htmlentities($resXml);
  4091.         $this->responseArray = $this->parseResponse($this->resXML);
  4092.         return $this->responseArray;
  4093.     }
  4094.     function buildRequestXMLDoc($sessId) {
  4095.         /* build request xml for e2 Data Service (Ext 1) - GetAccommodations */
  4096.         $service_name = $this->action;
  4097.         $xmldoc = $this->buildE2XMLHeader($this->service, $service_name, $sessId);
  4098.         $xpath = "//".$service_name;
  4099.         /* add search criteria */
  4100.         if (isset($this->accommodationCode)) {
  4101.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "AccommodationCode", $this->accommodationCode);
  4102.         }
  4103.         if (isset($this->codeFrom)) {
  4104.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "CodeFrom", $this->codeFrom);
  4105.         }
  4106.         if (isset($this->codeTo)) {
  4107.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "CodeTo", $this->codeTo);
  4108.         }
  4109.         if (isset($this->features)) {
  4110.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Features", $this->features);
  4111.         }
  4112.         if (isset($this->liveOnly)) {
  4113.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "LiveOnly", (!$this->liveOnly) ? "N" : "Y");
  4114.         }
  4115.         /* for detail information */
  4116.         for ($index = 0; $index < sizeof($this->detailLevel) and isset ($this->detailLevel[$index]); $index ++) {
  4117.             $detailFlag = $this->detailLevel[$index];
  4118.             if ($index == 0) {
  4119.                 $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "DetailLevel", "");
  4120.             }
  4121.             $xmldoc = $detailFlag->buildRequestXMLDoc($xmldoc, $xpath."/DetailLevel");
  4122.         }
  4123.         return $xmldoc;
  4124.     }
  4125. }
  4126.  
  4127. class Util {
  4128.     // return node array whether there are single node or multiple
  4129.     //
  4130.     public static function getNodeArray($node, $child)
  4131.     {
  4132.         $node_array = array();
  4133.         if(is_array($node)){
  4134.             if (is_array($node[$child])){
  4135.                 if (isset($node[$child][0])){
  4136.                     $node_array = $node[$child];
  4137.                 }else{
  4138.                     $node_array[] = $node[$child];
  4139.                 }
  4140.             }else if (isset($node[$child])){
  4141.                 $node_array[] = $node[$child];
  4142.             }
  4143.         }
  4144.         return ($node_array);
  4145.     }
  4146.     // Is e2 error?
  4147.     function isE2Err($e2Obj){
  4148.         if ( $e2Obj && strlen($e2Obj->getErrorCode())>0) {
  4149.             return true;
  4150.         }
  4151.         return false;
  4152.     }
  4153.     // Create an e2 session
  4154.     function createE2Session($e2db, $e2user, $e2pass, $e2sessUrl, $params=array()){
  4155.         $sessionId = '';
  4156.         $session = new Session($e2db, $e2user, $e2pass);
  4157.         $session->createSession($e2sessUrl, $params);
  4158.         if (!$this->isE2Err($session)) {
  4159.             $sessionId = $session->getSessionID();
  4160.         }
  4161.         return $sessionId;
  4162.     }
  4163. }
  4164.  
  4165. class MarketingService extends E2Interface {
  4166.     /* Deal with e2 Marketing service*/
  4167.     var $brochure;
  4168.     var $client;
  4169.     var $quantity;
  4170.     var $source;
  4171.     var $letter;
  4172.     var $dispatchMethod;
  4173.     var $responseArray;
  4174.     function setBrochure($newBrochure){
  4175.         $this->brochure = $newBrochure;
  4176.     }
  4177.     function setClient($newCl){
  4178.         $this->client = $newCl;
  4179.     }
  4180.     function setQuantity($newQnty){
  4181.         $this->quantity = $newQnty;
  4182.     }
  4183.     function setSource($newSrc){
  4184.         $this->source = $newSrc;
  4185.     }
  4186.     function setLetter($newLetter){
  4187.         $this->letter = $newLetter;
  4188.     }
  4189.     function setDispatchMethod($newDM){
  4190.         $this->dispatchMethod = $newDM;
  4191.     }
  4192.     function getBrochure(){
  4193.         return $this->brochure;
  4194.     }
  4195.     function getClient(){
  4196.         return $this->client;
  4197.     }
  4198.     function getQuantity(){
  4199.         return  $this->quantity;
  4200.     }
  4201.     function getSource(){
  4202.         return $this->source;
  4203.     }
  4204.     function getLetter(){
  4205.         return  $this->letter;
  4206.     }
  4207.     function getDispatchMethod(){
  4208.         return $this->dispatchMethod;
  4209.     }
  4210.  
  4211.     function getResponseArray() {
  4212.         return ($this->responseArray);
  4213.     }
  4214.  
  4215.     function MarketingService($newAction, $newURL, $newSessId) {
  4216.         /* constructor */
  4217.         $this->service = "MarketingService";
  4218.         $this->action = $newAction;
  4219.         $this->url = $newURL;
  4220.         $this->sessionId = $newSessId;
  4221.     }
  4222.     function getMarketingInfo() {
  4223.         $xmldoc = $this->buildRequestXMLDoc();
  4224.         $this->setReqXML($xmldoc->saveXML());
  4225.         //echo htmlentities($xmldoc->saveXML());
  4226.         $resXml = $this->postXmlMessage();
  4227.         //echo htmlentities($resXml);
  4228.         if (strlen($this->getErrorCode()) > 0) {
  4229.             return;
  4230.         }
  4231.         $this->responseArray = $this->parseResponse($resXml);
  4232.         return $this->responseArray;
  4233.     }
  4234.     function buildRequestXMLDoc() {
  4235.         /* build request xml for e2 CancelTransaction */
  4236.         $xmldoc = $this->buildE2XMLHeader();
  4237.         $xpath = "//".$this->action;
  4238.         /* add paxs */
  4239.         if (isset ($this->brochure)) {
  4240.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Brochure", $this->brochure);
  4241.         }
  4242.         if (isset ($this->client)) {
  4243.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Client", $this->client);
  4244.         }
  4245.         if (isset ($this->letter)) {
  4246.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Letter", $this->letter);
  4247.         }
  4248.         if (isset ($this->dispatchMethod)) {
  4249.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "DispatchMethod", $this->dispatchMethod);
  4250.         }
  4251.         if (isset ($this->quantity)) {
  4252.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Quantity", $this->quantity);
  4253.         }
  4254.         // set source
  4255.         if (isset ($this->source)) {
  4256.             $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Source", $this->source);
  4257.         }
  4258.         return $xmldoc;
  4259.     }
  4260. }
  4261. class E2UtilityService extends E2Interface {
  4262.     /* Deal with e2 Utility service*/
  4263.     // booking notify
  4264.     var $emailMsgFile;
  4265.     var $emailSender;
  4266.     var $emailTo;
  4267.     var $emailCc;
  4268.     var $emailBcc;
  4269.     var $emailSubject;
  4270.     var $emailMsg;
  4271.     var $responseArray;
  4272.     function setEmailSender($sndr){
  4273.         $this->emailSender = $sndr;
  4274.     }
  4275.     function setEmailTo($to){
  4276.         $this->emailTo = $to;
  4277.     }
  4278.     function setEmailCc($cc){
  4279.         $this->emailCc = $cc;
  4280.     }
  4281.     function setEmailBcc($bcc){
  4282.         $this->emailBcc = $bcc;
  4283.     }
  4284.     function setEmailSubject($subject){
  4285.         $this->emailSubject = $subject;
  4286.     }
  4287.     function setEmailMsgFile($messageFile){
  4288.         $this->emailMsgFile = $messageFile;
  4289.     }
  4290.     function setEmailMsg($msg){
  4291.         $this->emailMsg = $msg;
  4292.     }
  4293.  
  4294.     function getResponseArray() {
  4295.         return ($this->responseArray);
  4296.     }
  4297.  
  4298.     function E2UtilityService($newAction, $newURL, $newSessId) {
  4299.         /* constructor */
  4300.         $this->service = "UtilityService";
  4301.         $this->action = $newAction;
  4302.         $this->url = $newURL;
  4303.         $this->sessionId = $newSessId;
  4304.     }
  4305.     function getUtilityInfo() {
  4306.         $xmldoc = $this->buildRequestXMLDoc();
  4307.         $this->setReqXML($xmldoc->saveXML());
  4308.         //echo htmlentities($xmldoc->saveXML());
  4309.         $resXml = $this->postXmlMessage();
  4310.         //echo htmlentities($resXml);
  4311.         if (strlen($this->getErrorCode()) > 0) {
  4312.             return;
  4313.         }
  4314.         $this->responseArray = $this->parseResponse($resXml);
  4315.         return $this->responseArray;
  4316.     }
  4317.     function buildRequestXMLDoc() {
  4318.         /* build request xml for e2 CancelTransaction */
  4319.         $xmldoc = $this->buildE2XMLHeader();
  4320.         $xpath = "//".$this->action;
  4321.         if ($this->action == "EmailNotify") {
  4322.               if (isset($this->emailSender)){
  4323.                 $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Sender", $this->emailSender);
  4324.               }
  4325.               if (isset($this->emailBcc)){
  4326.                 $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Bcc", $this->emailBcc);
  4327.               }
  4328.               if (isset($this->emailCc)){
  4329.                 $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Cc", $this->emailCc);
  4330.               }
  4331.               if (isset($this->emailTo)){
  4332.                 $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "To", $this->emailTo);
  4333.               }
  4334.               if (isset($this->emailMsgFile)){
  4335.                 $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "MessageFile", $this->emailMsgFile);
  4336.               }
  4337.               if (isset($this->emailSubject)){
  4338.                 $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Subject", $this->emailSubject);
  4339.               }
  4340.               if (isset($this->emailMsg)){
  4341.                 $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Message", $this->emailMsg);
  4342.               }
  4343.         }
  4344.         return $xmldoc;
  4345.     }
  4346. }
  4347.  
  4348. class DocumentService extends E2Interface {
  4349.     /* Deal with e2 Document service*/
  4350.     var $bookingNumber;
  4351.     var $unpaidTolerance;
  4352.     var $email;
  4353.     function setBookingNumber($bookingNumber) {
  4354.         $this->bookingNumber = $bookingNumber;
  4355.     }
  4356.     function setUnpaidTolerance($unpaidTolerance) {
  4357.         $this->unpaidTolerance = $unpaidTolerance;
  4358.     }
  4359.     function setEmail($email) {
  4360.         $this->email = $email;
  4361.     }
  4362.     function DocumentService($newAction, $newURL, $newSessId) {
  4363.         /* constructor */
  4364.         $this->service = "DocumentService";
  4365.         $this->action = $newAction;
  4366.         $this->url = $newURL;
  4367.         $this->sessionId = $newSessId;
  4368.     }
  4369.     function run() {
  4370.         $xmldoc = $this->buildRequestXMLDoc();
  4371.         $this->setReqXML($xmldoc->saveXML());
  4372.         //echo htmlentities($xmldoc->saveXML());
  4373.         $resXml = $this->postXmlMessage();
  4374.         //echo htmlentities($resXml);
  4375.         if (strlen($this->getErrorCode()) > 0) {
  4376.             return;
  4377.         }
  4378.         $this->responseArray = $this->parseResponse($resXml);
  4379.         return $this->responseArray;
  4380.     }
  4381.     function buildRequestXMLDoc() {
  4382.         /* build request xml for e2 Document service */
  4383.         $xmldoc = $this->buildE2XMLHeader();
  4384.         $xpath = "//".$this->action;
  4385.         if ($this->action == "RunPicklist") {
  4386.             if (isset($this->bookingNumber)){
  4387.                 $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "BookingNumber", $this->bookingNumber);
  4388.             }
  4389.             if (isset($this->unpaidTolerance)){
  4390.                 $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "UnpaidTolerance", $this->unpaidTolerance);
  4391.             }
  4392.             if (isset($this->email)){
  4393.                 $xmldoc = $this->setXNodeValue($xmldoc, $xpath, "Email", $this->email);
  4394.             }
  4395.         }
  4396.         return $xmldoc;
  4397.     }  
  4398. }
  4399.  
  4400. class EndSession extends E2Interface {
  4401.     /*
  4402.     Deal with the e2 xml service: EndSession
  4403.     Added by Yayun Sun (Sunny)
  4404.     */
  4405.     function EndSession($newAction, $newURL, $newSessId) {
  4406.         /* constructor */
  4407.         $this->service = "SystemService";
  4408.         $this->action = $newAction;
  4409.         $this->url = $newURL;
  4410.         $this->sessionId = $newSessId;
  4411.     }
  4412.     function removeSession() {
  4413.         $xmldoc = $this->buildRequestXMLDoc();
  4414.         $this->setReqXML($xmldoc->saveXML());
  4415.         //echo htmlentities($xmldoc->saveXML());
  4416.         $resXml = $this->postXmlMessage();
  4417.         //echo htmlentities($resXml);
  4418.         if (strlen($this->getErrorCode()) > 0) {
  4419.             return;
  4420.         }
  4421.         $this->responseArray = $this->parseResponse($resXml);
  4422.         return $this->responseArray;
  4423.     }
  4424.     function buildRequestXMLDoc() {
  4425.         /* build request xml for e2 EndSession*/
  4426.         $xmldoc = $this->buildE2XMLHeader();
  4427.         return $xmldoc;
  4428.     }
  4429.  
  4430. }
  4431. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement