public function testCalculateDaysInTheTimesheetPeriod()
 {
     $key = 'timesheet_period_and_start_date';
     $xmlString = TestDataService::getRecords("SELECT value from hs_hr_config WHERE `key` = '" . $key . "'");
     $xmlString = $xmlString[0]['value'];
     $xmlString = simplexml_load_String($xmlString);
     $currentDate = '2011-04-24';
     // This is necessary to make timeStampDiff 0 in MonthlyTimesheetPeriod::getDatesOfTheTimesheetPeriod
     // $timeStampDiff = $clientTimeZoneOffset * 3600 - $serverTimezoneOffset;
     $serverTimezoneOffset = (int) date('Z');
     sfContext::getInstance()->getUser()->setAttribute('system.timeZoneOffset', $serverTimezoneOffset / 3600);
     $datesArray = $this->weeklyTimesheetPeriod->calculateDaysInTheTimesheetPeriod($currentDate, $xmlString);
     $this->assertEquals($datesArray[0], "2011-04-18 00:00");
     $this->assertEquals($datesArray[3], "2011-04-21 00:00");
     $this->assertEquals(end($datesArray), "2011-04-24 00:00");
     $currentDate = '2012-02-28';
     $datesArray = $this->weeklyTimesheetPeriod->calculateDaysInTheTimesheetPeriod($currentDate, $xmlString);
     $this->assertEquals($datesArray[0], "2012-02-27 00:00");
     $this->assertEquals($datesArray[3], "2012-03-01 00:00");
     $this->assertEquals(end($datesArray), "2012-03-04 00:00");
     $currentDate = '2011-12-29';
     $datesArray = $this->weeklyTimesheetPeriod->calculateDaysInTheTimesheetPeriod($currentDate, $xmlString);
     $this->assertEquals($datesArray[0], "2011-12-26 00:00");
     $this->assertEquals($datesArray[3], "2011-12-29 00:00");
     $this->assertEquals(end($datesArray), "2012-01-01 00:00");
 }
function parseOutput($content)
{
    //parse the Search response to get values to use in detail request
    $UniversalRecordImportRsp = $content;
    //use this if response is not saved anywhere else use above variable
    //echo $AirAvailabilitySearchRsp;
    $xml = simplexml_load_String("{$UniversalRecordImportRsp}", null, null, 'SOAP', true);
    if ($xml) {
        echo "Processing! Please wait!";
    } else {
        trigger_error("Encoding Error!", E_USER_ERROR);
    }
    $Results = $xml->children('SOAP', true);
    foreach ($Results->children('SOAP', true) as $fault) {
        if (strcmp($fault->getName(), 'Fault') == 0) {
            trigger_error("Error occurred request/response processing!", E_USER_ERROR);
        }
    }
    $count = 0;
    $fileName = "UniversalRecord.txt";
    if (file_exists($fileName)) {
        file_put_contents($fileName, "");
    }
    foreach ($Results->children('universal', true) as $nodes) {
        //this will put the UniversalRecord attributes in the file
        foreach ($nodes->children('universal', true) as $hsr) {
            if (strcmp($hsr->getName(), 'UniversalRecord') == 0) {
                foreach ($hsr->attributes() as $a => $b) {
                    $GLOBALS[$a] = "{$b}";
                    file_put_contents($fileName, $a . " : " . $b . "\r\n", FILE_APPEND);
                }
            }
        }
    }
    $fileName = "Reservation.txt";
    if (file_exists($fileName)) {
        file_put_contents($fileName, "");
    }
    foreach ($Results->children('universal', true) as $nodes) {
        //this will put the air reservation attributes in the file
        foreach ($nodes->children('universal', true) as $hsr) {
            foreach ($hsr->children('air', true) as $reservations) {
                if (strcmp($reservations->getName(), 'AirReservation') == 0) {
                    foreach ($reservations->attributes() as $a => $b) {
                        $GLOBALS[$a] = "{$b}";
                        file_put_contents($fileName, $a . " : " . $b . "\r\n", FILE_APPEND);
                    }
                }
            }
        }
    }
    echo "\r\n" . "Processing Done. Please check results in files.";
}
 public function index()
 {
     //create DOMDocument object
     $dom = new DOMDocument();
     //load xml file
     //  $dom->load('http://localhost/AirLineSOAPProject.V2/AirCreateReservationRsp.xml');
     $dom->load('C:\\xampp\\htdocs\\IBE-Codeignitor-project1\\application\\controllers\\AirCreateReservationRsp.xml');
     //save dom object as string
     $valuenew = $dom->saveXML();
     //$xml = simplexml_load_String("$valuenew", null, null, 'SOAP', true);
     $xml = simplexml_load_String("{$valuenew}");
     $this->parseAirCreateReservationRsp($xml);
 }
 public function testCalculateDaysInTheTimesheetPeriod()
 {
     $key = 'timesheet_period_and_start_date';
     $xmlString = TestDataService::getRecords("SELECT value from hs_hr_config WHERE `key` = '" . $key . "'");
     $xmlString = $xmlString[0]['value'];
     $xmlString = simplexml_load_String($xmlString);
     $currentDate = '2011-04-24';
     $dates = $this->monthlyTimesheetPeriod->calculateDaysInTheTimesheetPeriod($currentDate, $xmlString);
     $this->assertEquals("2011-04-13", $dates[0]);
     $this->assertEquals("2011-05-12", end($dates));
     $this->assertEquals("2011-04-18", $dates[5]);
     $dates = $this->monthlyTimesheetPeriod->calculateDaysInTheTimesheetPeriod("2011-02-18", $xmlString);
     $this->assertEquals("2011-02-13", $dates[0]);
     $this->assertEquals("2011-03-12", end($dates));
     $this->assertEquals("2011-02-23", $dates[10]);
     $dates = $this->monthlyTimesheetPeriod->calculateDaysInTheTimesheetPeriod("2012-02-18", $xmlString);
     $this->assertEquals("2012-02-13", $dates[0]);
     $this->assertEquals("2012-03-12", end($dates));
     $this->assertEquals("2012-02-28", $dates[15]);
     $dates = $this->monthlyTimesheetPeriod->calculateDaysInTheTimesheetPeriod("2012-12-31", $xmlString);
     $this->assertEquals("2012-12-13", $dates[0]);
     $this->assertEquals("2013-01-12", end($dates));
     $this->assertEquals("2013-01-02", $dates[20]);
 }
function parseDetailOutput()
{
    //$hotelDetailRsp = file_get_contents('002_HotelDetailRsp.xml'); // Parsing the Hotel Detail Response xml
    $hotelDetailRsp = $_SESSION["content"];
    //use this if response is not saved anywhere else use above variable
    $xml = simplexml_load_String("{$hotelDetailRsp}", null, null, 'SOAP', true);
    if (!$xml) {
        header("Location: http://LocationOfErrorPage/projects/Hotel/error.php");
        // Use the location of the error page
    }
    $Results = $xml->children('SOAP', true);
    foreach ($Results->children('SOAP', true) as $fault) {
        if (strcmp($fault->getName(), 'Fault') == 0) {
            //trigger_error("Error occurred request processing!", E_USER_ERROR);
            header("Location: http://LocationOfErrorPage/projects/Hotel/error.php");
            // Use the location of the error page
        }
    }
    foreach ($Results->children('hotel', true) as $nodes) {
        foreach ($nodes->children('hotel', true) as $hsr) {
            if (strcmp($hsr->getName(), 'RequestedHotelDetails') == 0) {
                foreach ($hsr->children('hotel', true) as $hp) {
                    if (strcmp($hp->getName(), 'HotelProperty') == 0) {
                        foreach ($hp->attributes() as $a => $b) {
                            $GLOBALS[$a] = "{$b}";
                        }
                        $COUNT = 0;
                        $Address = 'Address';
                        foreach ($hp->children('hotel', true) as $pa) {
                            if (strcmp($pa->getName(), 'PropertyAddress') == 0) {
                                foreach ($pa->children('hotel', true) as $ha) {
                                    if (strcmp($ha->getName(), 'Address') == 0) {
                                        $GLOBALS[$Address . $COUNT++] = $ha[0];
                                    }
                                }
                            }
                        }
                    }
                }
                foreach ($hsr->children('hotel', true) as $hp) {
                    if (strcmp($hp->getName(), 'HotelRateDetail') == 0) {
                        foreach ($hp->attributes() as $a => $b) {
                            $GLOBALS[$a] = "{$b}";
                        }
                        break;
                    }
                }
            }
            break;
        }
    }
}
function parseOutput($content)
{
    //parse the Search response to get values to use in detail request
    $AirAvailabilitySearchRsp = $content;
    //use this if response is not saved anywhere else use above variable
    //echo $AirAvailabilitySearchRsp;
    $xml = simplexml_load_String("{$AirAvailabilitySearchRsp}", null, null, 'SOAP', true);
    if ($xml) {
        echo "Processing! Please wait!";
    } else {
        trigger_error("Encoding Error!", E_USER_ERROR);
    }
    $Results = $xml->children('SOAP', true);
    foreach ($Results->children('SOAP', true) as $fault) {
        if (strcmp($fault->getName(), 'Fault') == 0) {
            trigger_error("Error occurred request/response processing!", E_USER_ERROR);
        }
    }
    $count = 0;
    $fileName = "flights.txt";
    if (file_exists($fileName)) {
        file_put_contents($fileName, "");
    }
    foreach ($Results->children('air', true) as $nodes) {
        foreach ($nodes->children('air', true) as $hsr) {
            if (strcmp($hsr->getName(), 'AirSegmentList') == 0) {
                foreach ($hsr->children('air', true) as $hp) {
                    if (strcmp($hp->getName(), 'AirSegment') == 0) {
                        $count = $count + 1;
                        file_put_contents($fileName, "\r\n" . "Air Segment " . $count . "\r\n" . "\r\n", FILE_APPEND);
                        foreach ($hp->attributes() as $a => $b) {
                            $GLOBALS[$a] = "{$b}";
                            //echo "$a"." : "."$b";
                            file_put_contents($fileName, $a . " : " . $b . "\r\n", FILE_APPEND);
                        }
                    }
                }
            }
            //break;
        }
    }
    $Token = 'Token';
    $TokenKey = 'TokenKey';
    $fileName = "tokens.txt";
    if (file_exists($fileName)) {
        file_put_contents($fileName, "");
    }
    foreach ($Results->children('air', true) as $nodes) {
        foreach ($nodes->children('air', true) as $hsr) {
            if (strcmp($hsr->getName(), 'HostTokenList') == 0) {
                foreach ($hsr->children('common_v29_0', true) as $ht) {
                    if (strcmp($ht->getName(), 'HostToken') == 0) {
                        $GLOBALS[$Token] = $ht[0];
                        foreach ($ht->attributes() as $a => $b) {
                            if (strcmp($a, 'Key') == 0) {
                                file_put_contents($fileName, $TokenKey . ":" . $b . "\r\n", FILE_APPEND);
                            }
                        }
                        file_put_contents($fileName, $Token . ":" . $ht[0] . "\r\n", FILE_APPEND);
                    }
                }
            }
        }
    }
    echo "\r\n" . "Processing Done. Please check results in files.";
}
 public function getTimesheetHeading()
 {
     $xmlString = $this->getTimesheetPeriodDao()->getDefinedTimesheetPeriod();
     $xml = simplexml_load_String($xmlString);
     return $xml->Heading;
 }
Example #8
0
 public function request($url)
 {
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
     $response = curl_exec($ch);
     curl_close($ch);
     return simplexml_load_String($response);
     //,'SimpleXMLElement',LIBXML_NOCDATA);
 }
 public function fetchResponse1()
 {
     $newdom = new DOMDocument();
     $newdom->load('C:\\xampp\\htdocs\\travelPortAirlineProjectSample\\application\\controllers\\lowFareResponse.xml');
     $valuenew = $newdom->saveXML();
     $xml = simplexml_load_String("{$valuenew}");
     //print_r($xml);
     $arrKey = array();
     $count = 0;
     $soapBody = $xml->children('SOAP', true);
     $airChildren = $soapBody->children('air', true);
     foreach ($airChildren->children('air', true) as $nodes2) {
         if (strcmp($nodes2->getName(), 'FlightDetailsList') == 0) {
             foreach ($nodes2->children('air', true) as $nodes3) {
                 if (strcmp($nodes3->getName(), 'FlightDetails') == 0) {
                     foreach ($nodes3->attributes() as $a => $b) {
                         if ($a == 'Key') {
                             //  echo $b;
                             $val = (string) $b;
                             $arrKey[$count] = trim($val);
                             $count++;
                         }
                     }
                 }
             }
         }
     }
     var_dump($arrKey);
     // echo  json_encode($arrKey);
     //  print_r($airChildren);
 }
Example #10
0
<?php

$doc = simplexml_load_String('<?xml version="1.0"?><lists><list path="svn+ssh"><entry kind="dir"></entry><entry kind="file"></entry></list></lists>');
foreach ($doc->list[0]->entry as $r) {
    var_dump((array) $r->attributes());
}
function parseOutput()
{
    //parse the Search response to get values to use in detail request
    //$hotelSearchRsp = file_get_contents('001_HotelAvailabilityRsp.xml');
    $hotelSearchRsp = $_SESSION["content"];
    //use this if response is not saved anywhere else use above variable
    $xml = simplexml_load_String("{$hotelSearchRsp}", null, null, 'SOAP', true);
    if (!$xml) {
        //trigger_error("Encoding Error!", E_USER_ERROR);
        header("Location: http://LocationOfErrorPage/projects/Hotel/error.php");
        //Use the Location of the error page
    }
    $Results = $xml->children('SOAP', true);
    foreach ($Results->children('SOAP', true) as $fault) {
        if (strcmp($fault->getName(), 'Fault') == 0) {
            //trigger_error("Error occurred request/response processing!", E_USER_ERROR);
            header("Location: http://LocationOfErrorPage/projects/Hotel/error.php");
            //Use the Location of the error page
        }
    }
    global $count;
    $count = 2;
    foreach ($Results->children('hotel', true) as $nodes) {
        foreach ($nodes->children('hotel', true) as $hsr) {
            echo "<form name=\"form{$count}\" action=\"phpSample_HotelSelect.php\" method=\"post\">";
            echo "<table>";
            if (strcmp($hsr->getName(), 'HotelSearchResult') == 0) {
                foreach ($hsr->children('hotel', true) as $hp) {
                    if (strcmp($hp->getName(), 'HotelProperty') == 0) {
                        foreach ($hp->attributes() as $a => $b) {
                            //$a = "$b";
                            if ($a != "HotelCode" && $a != "VendorLocationKey" && $a != "NetTransCommissionInd" && $a != "MinAmountRateChanged" && $a != "MaxAmountRateChanged") {
                                echo "<tr>";
                                echo "<td><h6>{$a}</h6></td>" . "<td><input type=\"hidden\" id=\"{$a}\" name=\"{$a}\" value=\"{$b}\">{$b}</td>";
                                echo "</tr>";
                            } else {
                                echo "<tr class=\"hide\">";
                                echo "<td class=\"hide\"><h6>{$a}</h6></td>" . "<td class=\"hide\"><input type=\"hidden\" id=\"{$a}\" name=\"{$a}\" value=\"{$b}\">{$b}</td>";
                                echo "</tr>";
                            }
                        }
                    } else {
                        if (strcmp($hp->getName(), 'RateInfo') == 0) {
                            foreach ($hp->attributes() as $a => $b) {
                                //$a = "$b";
                                if ($a != "HotelCode" && $a != "VendorLocationKey" && $a != "NetTransCommissionInd" && $a != "MinAmountRateChanged" && $a != "MaxAmountRateChanged") {
                                    echo "<tr>";
                                    echo "<td><h6>{$a}</h6></td>" . "<td><input type=\"hidden\" id=\"{$a}\" name=\"{$a}\" value=\"{$b}\">{$b}</td>";
                                    echo "</tr>";
                                } else {
                                    echo "<tr class=\"hide\">";
                                    echo "<td class=\"hide\"><h6>{$a}</h6></td>" . "<td class=\"hide\"><input type=\"hidden\" id=\"{$a}\" name=\"{$a}\" value=\"{$b}\">{$b}</td>";
                                    echo "</tr>";
                                }
                            }
                        }
                    }
                }
            }
            echo "</table>";
            echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
            echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
            echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
            echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
            echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
            echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
            echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
            echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
            echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
            echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
            echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
            echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
            echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
            echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
            echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
            echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
            echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
            echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
            echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
            echo "<input id=\"submit{$count}\" class=\"myButton\" name=\"submit{$count}\" value=\"Book\" type=\"submit\">";
            echo "</form>";
            echo "</br>";
            $count = $count + 1;
        }
    }
    $Token = 'Token';
    foreach ($Results->children('hotel', true) as $nodes) {
        foreach ($nodes->children('common_v29_0', true) as $hsr) {
            if (strcmp($hsr->getName(), 'HostToken') == 0) {
                $GLOBALS[$Token] = $hsr[0];
            }
        }
    }
}