/travel.php
PHP | 777 lines | 627 code | 149 blank | 1 comment | 114 complexity | 77e1f1565269b2651aaad275e192d5b9 MD5 | raw file
- <?php
- session_start();
- header('Content-Type: text/html; charset=utf-8');
- date_default_timezone_set('Europe/Paris');
- include_once("functions.php");
- ?>
- <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
- <html xmlns='http://www.w3.org/1999/xhtml'>
-
- <?php
- $settingsXml = new DOMDocument('1.0','UTF-8');
- $settingsXml->formatOutput = true;
- $settingsXml->preserveWhiteSpace = false;
- $settingsXml->load("settings.xml");
- $settingsXpath = new DOMXPath($settingsXml);
- if ($_SESSION['userConnected']) {
- $userConnected = $_SESSION['userConnected'];
- $userFile = $_SESSION['userFile'];
- $query = '//settings/accounts/user[@id="'.$userConnected.'"]';
- $entries = $settingsXpath->query($query);
- $userNumber = $entries->item(0)->getAttribute('number');
-
- $userFileXml = new DOMDocument('1.0','UTF-8');
- $userFileXml->formatOutput = true;
- $userFileXml->preserveWhiteSpace = false;
- $userFileXml->load("data/".$userFile);
- $userFileXpath = new DOMXPath($userFileXml);
- }
- if (!$userConnected) { $notLogged = true; }
-
- if ($userConnected) {
- $userData = array(
- 'id' => $userConnected,
- 'fullName' => getUserFullName($userFileXpath), 'firstName' => getUserFirstName($userFileXpath),
- 'email' => getUserEmail($userFileXpath), 'location' => getUserLocation($userFileXpath), 'img' => getUserImg($userFileXpath)
- );
-
- if (isset($_GET['id'])) {
- if ($_GET['id'] != null) {
-
- $travelID = $_GET['id'];
- $travelOwnerNumber = substr($travelID,1,1);
-
- if ($travelOwnerNumber == $userNumber) {
- $myTravel = true;
- $lookupUser = $userConnected;
- $lookupUserFile = $userFile;
- $lookupUserFileXml = $userFileXml;
- $lookupUserFileXpath = $userFileXpath;
- }
- else {
- $myTravel = false;
- $query = '//settings/accounts/user[@number="'.$travelOwnerNumber.'"]';
- $entries = $settingsXpath->query($query);
- $lookupUserFile = $entries->item(0)->getAttribute('file');
- $lookupUser = $entries->item(0)->getAttribute('id');
-
- $lookupUserFileXml = new DOMDocument('1.0','UTF-8');
- $lookupUserFileXml->formatOutput = true;
- $lookupUserFileXml->preserveWhiteSpace = false;
- $lookupUserFileXml->load("data/".$lookupUserFile);
- $lookupUserFileXpath = new DOMXPath($lookupUserFileXml);
- }
-
- $userLookupData = array(
- 'id' => $lookupUser,
- 'fullName' => getUserFullName($lookupUserFileXpath), 'firstName' => getUserFirstName($lookupUserFileXpath),
- 'email' => getUserEmail($lookupUserFileXpath), 'location' => getUserLocation($lookupUserFileXpath), 'img' => getUserImg($lookupUserFileXpath)
- );
-
- $query = '//travel-document/travel-data/travel[@id="'.$travelID.'"]';
- $entries = $lookupUserFileXpath->query($query);
- $travelNode = $entries->item(0);
-
- if (isset($_POST['insertDep']) && isset($_POST['insertArr']) && isset($_POST['depDate']) && isset($_POST['transport'])) {
- $insertDep = $_POST['insertDep'];
- if ($insertDep == 'true') { $inserDep = true; }
- else { $insertDep = false; }
-
- $insertArr = $_POST['insertArr'];
- if ($insertArr == 'true') { $inserArr = true; }
- else { $insertArr = false; }
-
- $resultDepID = $_POST['resultDepID'];
- $resultDepLocation = $_POST['resultDepLocation'];
- $resultDepCountry = $_POST['resultDepCountry'];
- $resultDepLatitude = $_POST['resultDepLatitude'];
- $resultDepLongitude = $_POST['resultDepLongitude'];
-
- $resultArrID = $_POST['resultArrID'];
- $resultArrLocation = $_POST['resultArrLocation'];
- $resultArrCountry = $_POST['resultArrCountry'];
- $resultArrLatitude = $_POST['resultArrLatitude'];
- $resultArrLongitude = $_POST['resultArrLongitude'];
-
- if ($insertDep) {
- if (isset($_POST['resultDepID']) && isset($_POST['resultDepLocation']) && isset($_POST['resultDepCountry']) && isset($_POST['resultDepLatitude']) && isset($_POST['resultDepLongitude'])) {
- $insertID = $resultDepID;
- $insertLocation = $resultDepLocation;
- $insertCountry = $resultDepCountry;
- $insertLatitude = $resultDepLatitude;
- $insertLongitude = $resultDepLongitude;
-
- $query = '//settings/location-data';
- $entries = $settingsXpath->query($query);
- $locationDataNode = $entries->item(0);
-
- $newLocationNode = $settingsXml->createElement("location");
- $newLocationNode->setAttribute('id',$insertID);
- $newLocationNode->setAttribute('name',$insertLocation);
- $newLocationNode->setAttribute('country',$insertCountry);
- $newLocationNode->setAttribute('lat',$insertLatitude);
- $newLocationNode->setAttribute('lng',$insertLongitude);
-
- $locationDataNode->appendChild($newLocationNode);
- $settingsXml->save("settings.xml");
- }
- else { $unknownError = true; }
- }
- if ($insertArr) {
- if (isset($_POST['resultArrID']) && isset($_POST['resultArrLocation']) && isset($_POST['resultArrCountry']) && isset($_POST['resultArrLatitude']) && isset($_POST['resultArrLongitude'])) {
- $insertID = $resultArrID;
- $insertLocation = $resultArrLocation;
- $insertCountry = $resultArrCountry;
- $insertLatitude = $resultArrLatitude;
- $insertLongitude = $resultArrLongitude;
-
- $query = '//settings/location-data';
- $entries = $settingsXpath->query($query);
- $locationDataNode = $entries->item(0);
-
- $newLocationNode = $settingsXml->createElement("location");
- $newLocationNode->setAttribute('id',$insertID);
- $newLocationNode->setAttribute('name',$insertLocation);
- $newLocationNode->setAttribute('country',$insertCountry);
- $newLocationNode->setAttribute('lat',$insertLatitude);
- $newLocationNode->setAttribute('lng',$insertLongitude);
-
- $locationDataNode->appendChild($newLocationNode);
- $settingsXml->save("settings.xml");
- }
- else { $unknownError = true; }
- }
-
- $depDate = $_POST['depDate'];
- $arrDate = $_POST['depDate'];
- $depLocation = $resultDepID;
- $depCountry = $resultDepCountry;
- $arrLocation = $resultArrID;
- $arrCountry = $resultArrCountry;
- $transport = $_POST['transport'];
-
- $systemDepDate = substr($enteredDepDate,6,4) . "-" . substr($enteredDepDate,3,2) . "-" . substr($enteredDepDate,0,2);
- $systemArrDate = substr($enteredDepDate,6,4) . "-" . substr($enteredDepDate,3,2) . "-" . substr($enteredDepDate,0,2);
-
- if ($depLocation != $arrLocation) {
- if (strtotime($systemDepDate) <= strtotime($systemArrDate)) {
-
- $newItineraryNode = $userFileXml->createElement("itinerary");
- $newItineraryNode->setAttribute('transport',$transport);
- $newItineraryNode->setAttribute('departure',$depLocation);
- $newItineraryNode->setAttribute('arrival',$arrLocation);
- $newItineraryNode->setAttribute('date',$depDate);
- $travelNode->appendChild($newItineraryNode);
- $userFileXml->save("data/".$userFile);
- $insertion = true;
- }
- }
- }
-
- if (isset($_POST['newTravelName']) && isset($_POST['travelType'])) {
- $newTravelName = $_POST['newTravelName'];
- $newTravelType = $_POST['travelType'];
-
- if ($newTravelName != null) {
- if ($newTravelName != $travelNode->getAttribute('name')) { $travelNode->setAttribute('name',$newTravelName); }
- if ($newTravelType != $travelNode->getAttribute('type')) { $travelNode->setAttribute('type',$newTravelType); }
- }
-
- $userFileXml->save("data/".$userFile);
- $nameChanged = true;
- }
-
- if (isset($_POST['remItineraryNumber']) && isset($_POST['remItineraryDepLocation']) && isset($_POST['remItineraryArrLocation'])
- && isset($_POST['remItineraryDepCountry'])&& isset($_POST['remItineraryArrCountry'])) {
- $remItineraryNumber = $_POST['remItineraryNumber'];
- $remItineraryDepLocation = $_POST['remItineraryDepLocation'];
- $remItineraryDepCountry = $_POST['remItineraryDepCountry'];
- $remItineraryArrLocation = $_POST['remItineraryArrLocation'];
- $remItineraryArrCountry = $_POST['remItineraryArrCountry'];
-
- if (!empty($remItineraryNumber) && !empty($remItineraryDepLocation) && !empty($remItineraryDepCountry)
- && !empty($remItineraryArrLocation) && !empty($remItineraryArrCountry)) {
- $query = '//travel-document/travel-data/travel[@id="'.$travelID.'"]/itinerary[position()=last()]';
- $entries = $userFileXpath->query($query);
- $itineraryNode = $entries->item(0);
- $travelNode->removeChild($itineraryNode);
- $userFileXml->save("data/".$userFile);
-
- $deletion = true;
- }
- }
-
- $travel = array(
- 'number' => substr(strrchr($travelID,'t'),1),
- 'id' => $travelNode->getAttribute('id'), 'name' => $travelNode->getAttribute('name'),
- 'type' => $travelNode->getAttribute('type'),
- 'typeName' => null, 'typeImg' => null,
- 'firstDay' => null, 'lastDay' => null, 'lastCity' => null,
- 'days' => 0, 'km' => 0, 'avgSpeed' => null, 'itineraries' => array(), 'lastItinerary' => array(),
- 'visitedCities' => array(), 'visitedCountries' => array(), 'transportTypes' => array()
- );
-
- $travel['typeName'] = getTravelTypeName($settingsXpath,$travel['type']);
- $travel['typeImg'] = getTravelTypeImg($settingsXpath,$travel['type']);
-
- $itineraryCount = 0;
- $itinerariesNode = $travelNode->childNodes;
-
- foreach ($itinerariesNode as $itinerary) {
- $itineraryCount++;
-
- $currentItinerary = array(
- 'number' => $itineraryCount,
- 'depLocation' => getItineraryDepartureLocation($lookupUserFileXpath,$itinerary),
- 'depDate' => getItineraryDepartureDate($lookupUserFileXpath,$itinerary),
- 'arrLocation' => getItineraryArrivalLocation($lookupUserFileXpath,$itinerary),
- 'arrDate' => getItineraryArrivalDate($lookupUserFileXpath,$itinerary),
- 'transport' => getItineraryTransport($lookupUserFileXpath,$itinerary),
- 'depLocationName' => null, 'depLocationCountry' => null, 'depLocationLat' => null, 'depLocationLng' => null,
- 'arrLocationName' => null, 'arrLocationCountry' => null, 'arrLocationLat' => null, 'arrLocationLng' => null,
- 'km' => null, 'days' => null
- );
-
- $currentItinerary['depLocationName'] = getLocationName($settingsXpath,$currentItinerary['depLocation']);
- $currentItinerary['depLocationCountry'] = getLocationCountry($settingsXpath,$currentItinerary['depLocation']);
- $depCoords = getLocationLatLng($settingsXpath,$currentItinerary['depLocation']);
- $currentItinerary['depLocationLat'] = $depCoords['lat'];
- $currentItinerary['depLocationLng'] = $depCoords['lng'];
-
- $currentItinerary['arrLocationName'] = getLocationName($settingsXpath,$currentItinerary['arrLocation']);
- $currentItinerary['arrLocationCountry'] = getLocationCountry($settingsXpath,$currentItinerary['arrLocation']);
- $arrCoords = getLocationLatLng($settingsXpath,$currentItinerary['arrLocation']);
- $currentItinerary['arrLocationLat'] = $arrCoords['lat'];
- $currentItinerary['arrLocationLng'] = $arrCoords['lng'];
-
- if (!in_array($currentItinerary['depLocation'],$travel['visitedCities'])) { $travel['visitedCities'][] = $currentItinerary['depLocation']; }
- if (!in_array($currentItinerary['depLocationCountry'],$travel['visitedCountries'])) { $travel['visitedCountries'][] = $currentItinerary['depLocationCountry']; }
- $systemDepDate = substr($currentItinerary['depDate'],6,4) . "-" . substr($currentItinerary['depDate'],3,2) . "-" . substr($currentItinerary['depDate'],0,2);
-
- if (!in_array($currentItinerary['arrLocation'],$travel['visitedCities'])) { $travel['visitedCities'][] = $currentItinerary['arrLocation']; }
- if (!in_array($currentItinerary['arrLocationCountry'],$travel['visitedCountries'])) { $travel['visitedCountries'][] = $currentItinerary['arrLocationCountry']; }
- $systemArrDate = substr($currentItinerary['arrDate'],6,4) . "-" . substr($currentItinerary['arrDate'],3,2) . "-" . substr($currentItinerary['arrDate'],0,2);
-
- if ($travel['firstDay'] == null) { $travel['firstDay'] = $systemDepDate; }
- if (strtotime($systemDepDate) < strtotime($travel['firstDay'])) { $travel['firstDay'] = $systemDepDate; }
- if ($travel['lastDay'] == null) { $travel['lastDay'] = $systemArrDate; }
- if (strtotime($systemArrDate) > strtotime($travel['lastDay'])) { $travel['lastDay'] = $systemArrDate; }
-
- $travel['lastCity'] = $currentItinerary['arrLocation'];
- $travel['lastCountry'] = $currentItinerary['arrLocationCountry'];
-
- if (!in_array($currentItinerary['transport'],$travel['transportTypes'])) {
- $travel['transportTypes'][] = $currentItinerary['transport'];
- }
-
- $currentItinerary['days'] = _date_diff(strtotime($systemDepDate),strtotime($systemArrDate));
- $currentItinerary['km'] = getDistance($currentItinerary['depLocationLat'],$currentItinerary['depLocationLng'],$currentItinerary['arrLocationLat'],$currentItinerary['arrLocationLng']);
- $travel['km'] = $travel['km'] + $currentItinerary['km'];
-
- $travel['lastItinerary'] = $currentItinerary;
- $travel['itineraries'][] = $currentItinerary;
- }
-
- $systemTravelDays = _date_diff(strtotime($travel['firstDay']),strtotime($travel['lastDay']));
- $travel['days'] = $systemTravelDays['days'];
- if (($travel['days'] == 0) && ($travel['km'] != 0)) { $travel['days'] = 1; }
-
- if ($travel['days'] == 0) { $travel['avgSpeed'] = 0; }
- else { $travel['avgSpeed'] = round($travel['km'] / ($travel['days'] * 24),2); }
-
- $query = '//settings/transports/transport';
- $entries = $settingsXpath->query($query);
- $transportsNode = $entries;
-
- $transportsTypes = array();
- foreach ($transportsNode as $transport) {
- $transportData = array('id' => $transport->getAttribute('id'), 'name' => $transport->getAttribute('name'), 'img' => $transport->getAttribute('img'));
- $transportsTypes[] = $transportData;
- }
-
- $query = '//settings/location-data/location';
- $entries = $settingsXpath->query($query);
- $locationsNode = $entries;
-
- $locations = array();
- foreach ($locationsNode as $location) {
- $locationCountry = getCountryName($settingsXpath,$location->getAttribute('country'));
- if (empty($locations[$locationCountry])) { $locations[$locationCountry] = array(); }
- $locations[$locationCountry][$location->getAttribute('id')] = array('id' => $location->getAttribute('id'), 'name' => $location->getAttribute('name'));
- }
- ksort($locations);
-
- $query = '//settings/travel-types/travel-type';
- $entries = $settingsXpath->query($query);
- $travelTypesNode = $entries;
-
- $travelTypes = array();
- foreach ($travelTypesNode as $type) {
- $typeData = array('id' => $type->getAttribute('id'), 'name' => $type->getAttribute('name'), 'img' => $type->getAttribute('img'));
- $travelTypes[] = $typeData;
- }
- }
- }
- else { $withoutID = true; }
- }
- openHeadTag();
- if ($notLogged) { title("Error"); }
- else { title("Travel: ".$travel['name']." [".$travel['id']."]"); }
- defaultMetaTag();
- echo "<script type='text/javascript'>
- function initialiser() { ";
-
- if (empty($travel['lastDay'])) { echo "datepickerSimple();"; }
- else { echo "datepickerLimit('".substr($travel['lastDay'],0,4).",". substr($travel['lastDay'],5,2) .",".substr($travel['lastDay'],8,2)."');"; }
-
- if (count($travel['itineraries']) > 0) {
- echo "var latlng = new google.maps.LatLng(".$travel['itineraries'][0]['depLocationLat'].",".$travel['itineraries'][0]['depLocationLng'].");";
- }
- else {
- echo "var latlng = new google.maps.LatLng(20,-20);";
- }
-
- echo "
- var bounds = new google.maps.LatLngBounds();
- var myPoints = [];";
-
- foreach ($travel['visitedCities'] as $city) {
- $cityCoords = getLocationLatLng($settingsXpath,$city);
- $cityLat = $cityCoords['lat'];
- $cityLng = $cityCoords['lng'];
- echo "myPoints.push(new google.maps.LatLng(".$cityLat.",".$cityLng."));";
- }
-
- echo "var options = { center: latlng, zoom: 2, mapTypeId: google.maps.MapTypeId.ROADMAP };
- var carte = new google.maps.Map(document.getElementById('map'),options);
-
- for(var i = 0; i < myPoints.length; i++) {
- bounds.extend(myPoints[i]);
- var thisMarker = addThisMarker(myPoints[i],i);
- thisMarker.setMap(carte);
- }
-
- var parcoursBus = [";
-
- $itineraryCount = 0;
- foreach ($travel['itineraries'] as $itinerary) {
- $itineraryCount++;
- if ($itineraryCount == 1) {
- $depLocationLat = $itinerary['depLocationLat']; $depLocationLng = $itinerary['depLocationLng'];
- echo "new google.maps.LatLng(".$depLocationLat.",".$depLocationLng."),";
- }
- $arrLocationLat = $itinerary['arrLocationLat']; $arrLocationLng = $itinerary['arrLocationLng'];
- echo "new google.maps.LatLng(".$arrLocationLat.",".$arrLocationLng."),";
- }
-
- echo "];
-
- var traceParcoursBus = new google.maps.Polyline({
- path: parcoursBus,
- strokeColor: '#000033',
- strokeOpacity: 1.0,
- strokeWeight: 2,
- geodesic: true
- });
-
- traceParcoursBus.setMap(carte);
-
- if (myPoints.length > 0) { carte.fitBounds(bounds); }
-
- function addThisMarker(point,m) {
- if (m == 0) { var marker = new google.maps.Marker({position: point, map: carte, icon: 'images/marker-finish.png'}); }
- else { var marker = new google.maps.Marker({position: point, map: carte, icon: 'images/marker-city.png'}); }
- return marker;
- }
- }
- </script>
- ";
- closeHeadTag();
- echo "<body class='bodygrey' onload='initialiser()'>
- <div class='headerspace'></div>
- <div class='header'>
-
- <!-- logo -->
- <a href=''><img src='images/logo2.png' alt='Logo' /></a>";
-
- displayNavbar("Travel");
- displayAccountInfo($userData);
-
- echo "</div><!-- header -->";
- displaySidebar("Travel");
- if ($notLogged) { displayNotLogged(); }
- else {
-
- if ($myTravel) {
- echo "<div class='maincontent'>
-
- <div class='breadcrumbs'>
- <a href='index.php'>Dashboard</a>
- <a href='travelinfo.php'>Travel Information</a>";
- if ($travel['km'] == 0) { echo "<a href='empty.php'>Empty Travels</a>"; }
- else if (strtotime($travel['firstDay']) > strtotime(date("Y-m-d")) || strtotime($travel['lastDay']) > strtotime(date("Y-m-d"))) { echo "<a href='upcoming.php'>Upcoming Travels</a>"; }
- else { echo "<a href='trips.php'>Completed Travels</a>"; }
- echo "<span>Travel: ".$travel['name']." [".$travel['id']."]</span>
- </div><!-- breadcrumbs -->
- <div class='two_third maincontent_inner '>
- <div class='left'>
-
- <h1 class='pageTitle'>Travel: ".$travel['name']." [".$travel['id']."]</h1>";
-
- if ($nameChanged) {
- echo "<div class='notification msgsuccess'>
- The travel details were successfully modified.
- </div><!-- notification info -->";
- }
- if ($deletion) {
- echo "<div class='notification msgerror'>
- Itinerary between <img src='images/flags/".$remItineraryDepCountry.".png' alt=''/> ".$remItineraryDepLocation."
- and <img src='images/flags/".$remItineraryArrCountry.".png' alt=''/> ".$remItineraryArrLocation." was successfully removed.
- </div><!-- notification info -->";
- }
- if ($insertion) {
- echo "<div class='notification msgsuccess'>
- Itinerary between <img src='images/flags/".$depCountry.".png' alt=''/> ".getLocationName($settingsXpath,$depLocation)."
- and <img src='images/flags/".$arrCountry.".png' alt=''/> ".getLocationName($settingsXpath,$arrLocation)." was successfully added to the travel.
- </div><!-- notification info -->";
- }
- echo "<div class='widgetbox'>
- <h3><span>Travel Map</span></h3>
- <div class='content'>
- <div id='map' style='width: 650px; height: 370px; margin: 0 auto 10px; border:1px solid #000000;'></div>
- </div><!-- content-->
- </div><!-- widgetbox -->
-
- <div class='widgetbox'>
- <h3><span>Itineraries</span></h3>
- <div class='content nopadding ohidden'>
- <table cellpadding='0' cellspacing='0' class='sTable3' width='100%'>
- <thead>
- <tr>
- <td align='center'>Number</td>
- <td align='center'>From</td>
- <td align='center'>To</td>
- <td align='center'>Transport Type</td>
- <td align='center'>Distance (km)</td>
- <td align='center'>Date</td>
- </tr>
- </thead>
- <tbody>";
- foreach ($travel['itineraries'] as $itinerary) {
- echo "<tr>
- <td align='center'>#".$itinerary['number']."</td>
- <td align='center'><img src='images/flags/".$itinerary['depLocationCountry'].".png' alt=''/> <a href='location.php?id=".$itinerary['depLocation']."'>".$itinerary['depLocationName']."</a></td>
- <td align='center'><img src='images/flags/".$itinerary['arrLocationCountry'].".png' alt=''/> <a href='location.php?id=".$itinerary['arrLocation']."'>".$itinerary['arrLocationName']."</a></td>
- <td align='center'><img src='images/".getTransportImg($settingsXpath,$itinerary['transport'])."' alt=''/> ".getTransportName($settingsXpath,$itinerary['transport'])."</td>
- <td align='center'>".$itinerary['km']." km</td>
- <td align='center'>".str_replace('-','/',$itinerary['depDate'])."</td>
- </tr>";
- }
- echo "</tbody>
- </table>
- </div><!-- content -->
- </div><!-- widgetbox2 -->
-
- <div id='tabs' class='tabs'>
- <ul>
- <li><a href='#tabs-1'>Add new itinerary</a></li>";
- if (!empty($travel['lastItinerary'])) {
- echo "<li><a href='#tabs-2'>Remove last itinerary</a></li>";
- }
- echo "</ul>
- <div id='tabs-1' style='text-align:center;'>
- <div class='form_default'>
- <form id='formAddItinerary' action='additinerary.php?id=".$travel['id']."' method='post'>";
-
- if (empty($travel['lastCity'])) { echo "<input type='hidden' name='itineraryFirst' value='true'/>"; }
- else { echo "<input type='hidden' name='itineraryFirst' value='false'/>"; }
-
- echo "<h2>Enter itinerary details</h2>
- <br/>
- <div class='three_fifth'>
- <label for='travelName' style='width:50px;'>From</label>";
- if (empty($travel['lastCity'])) {
- echo "<input type='text' id='depLocation' name='depLocation' value='' style='width:120px;' />";
- }
- else {
- echo "<input type='text' id='depLocation' name='depLocation' value='".getLocationName($settingsXpath,$travel['lastCity'])."' style='width:120px;padding:6px 5px;' />";
- }
-
- echo "<select style='width: 150px' id='depCountry' name='depCountry'><option value='null' selected='selected'>Select a country...</option>";
-
- $query = '//settings/countries/country';
- $entries = $settingsXpath->query($query);
-
- foreach ($entries as $country) {
- if ($country->getAttribute('code') == $travel['lastCountry']) { echo "<option selected value='".$country->getAttribute('code')."'>".$country->nodeValue."</option>"; }
- else { echo "<option value='".$country->getAttribute('code')."'>".$country->nodeValue."</option>"; }
- }
- echo "</select>";
-
- echo "<br/><br/>
- <label for='arrLocation' style='width:50px;'>To</label>
- <input type='text' id='arrLocation' name='arrLocation' value='' style='width:120px;padding:6px 5px;' />";
-
- //echo "<input id='arrCountry' />";
-
- echo "<select style='width: 150px' id='arrCountry' name='arrCountry'><option value='null' selected='selected'>Select a country...</option>";
-
- foreach ($entries as $country) { echo "<option value='".$country->getAttribute('code')."'>".$country->nodeValue."</option>"; }
- echo "</select>";
-
- echo "</div>
- <div class='two_fifth last'>
- <label for='datepickerDep' style='width:50px;'>Date</label>
- <input type='text' id='depDate' name='depDate' readonly='readonly' style='width:140px;padding:6px 5px;'/><br/></br>
- <table><tr>";
-
- $typeCount = 0;
- foreach ($transportsTypes as $transport) {
- $typeCount++;
- echo "<td width='68px' align='center'><img src='images/".$transport['img']."' alt=''/>";
- if ($typeCount == 1) { echo "<input type='radio' name='transport' style='margin:0 0 6px 2px;' value='".$transport['id']."' checked></input>"; }
- else { echo "<input type='radio' name='transport' style='margin:0 0 6px 2px;' value='".$transport['id']."'></input>"; }
- echo "<br/>".$transport['name']."</td>";
- }
- echo "</tr></table>
- </div>
- <div class='clear'></div>
- <button style='margin-left:0px;'>ADD ITINERARY</button>
- </form>
- </div>
- </div>";
-
- if (!empty($travel['lastItinerary'])) {
- echo "<div id='tabs-2' style='overflow:hidden;text-align:center;'>
- <form action='travel.php?id=".$travel['id']."' method='post'>
- <input type='hidden' name='remItineraryNumber' value='".$travel['lastItinerary']['number']."'/>
- <input type='hidden' name='remItineraryDepLocation' value='".$travel['lastItinerary']['depLocationName']."'/>
- <input type='hidden' name='remItineraryArrLocation' value='".$travel['lastItinerary']['arrLocationName']."'/>
- <input type='hidden' name='remItineraryDepCountry' value='".$travel['lastItinerary']['depLocationCountry']."'/>
- <input type='hidden' name='remItineraryArrCountry' value='".$travel['lastItinerary']['arrLocationCountry']."'/>
-
- <h2>Remove last itinerary</h2>
- <br/>
- <div class='three_fifth' style='text-align:center;'>
- <p>The last recorded itinerary in this travel is:</p><br/>
- <h2>#".$travel['lastItinerary']['number']."</h2>
- <p><img src='images/flags/".$travel['lastItinerary']['depLocationCountry'].".png' alt=''/> <b>".$travel['lastItinerary']['depLocationName']."</b> to <img src='images/flags/".$travel['lastItinerary']['arrLocationCountry'].".png' alt=''/> <b>".$travel['lastItinerary']['arrLocationName']."</b> (".$travel['lastItinerary']['km']." km)</p>
- </div>
- <div class='two_fifth last' style='text-align:center;'>
- <p style='margin: 3px 0 0 0;'>Are you sure you want to remove the itinerary between <b>".$travel['lastItinerary']['depLocationName']."</b> and <b>".$travel['lastItinerary']['arrLocationName']."</b>?</p>
- <br/>
- <input type='submit' value='Remove itinerary'/>
- </div>
- </form>
- </div>";
- }
- echo "</div><!-- tabs -->
-
- </div><!-- left -->
- </div><!-- two_third -->
-
- <div class='one_third last'>
- <div class='right'>
-
- <div class='widgetbox'>
- <h3><span>Travel details</span></h3>
- <div class='content'>
-
- <form id='formEdit' action='travel.php?id=".$travel['id']."' method='post'>
- <div class='form_default'>
-
- <label for='newTravelName' style='width:30px;'>Name</label>
- <input type='text' name='newTravelName' id='newTravelName' value='".$travel['name']."' style='width:200px;' />
-
- <p style='margin: 14px 0 0 !important;'><label for='travelType' class='nopadding' style='width:30px;'>Type</label>
- <table><tr>";
-
- $typeCount = 0;
-
- foreach ($travelTypes as $type) {
- echo "<td width='82px' align='center'><img src='images/".$type['img']."' alt=''/>";
- if ($travel['type'] == $type['id']) { echo "<input type='radio' style='margin: 0 0 6px 2px;' name='travelType' value='".$type['id']."' checked></input>"; }
- else { echo "<input type='radio' style='margin: 0 0 6px 2px;' name='travelType' value='".$type['id']."'></input>"; }
- echo "<br/>".$type['name']."</td>";
- }
- echo "</tr></table></p>
-
- <p style='margin: 14px 0 2px !important;'><button style='margin-left:52px;'>Edit details</button></p>
-
- </div><!--form-->
- </form>
-
- </div><!-- content -->
- </div><!-- widgetbox -->
-
- <div class='widgetbox'>
- <h3><span>Numbers</span></h3>
- <div class='content'>
- <h1 class='prize'>".$travel['km']." km</h1>
- <p>Number of days: <strong>".$travel['days']." ".qty('day','days',$travel['days'])."</strong></p>
- <br/>
- <div class='one_half bright'>
- <h2 class='prize'>".$travel['avgSpeed']." km/h</h2>
- <small>Average Speed</small>
- </div><!--one_half-->
-
- <div class='one_half last'>
- <h2 class='prize'>".count($travel['visitedCities'])." ".qty('city','cities',count($travel['visitedCities']))."</h2>
- <small>Cities visited</small>
- </div><!--one_half-->
- </div><!-- content -->
- </div><!-- widgetbox -->
-
- <div class='widgetbox'>
- <h3><span>Miscellaneous</span></h3>
- <div class='content'>
-
- <h2 class='prize'>".count($travel['visitedCountries'])." ".qty('country','countries',count($travel['visitedCountries']))."</h2>
- <p>Countries visited: ".displayCountryFlags($travel['visitedCountries'])."</p><br/>
-
- <h2 class='prize'>".count($travel['transportTypes'])." transport ".qty('type','types',count($travel['transportTypes']))."</h2>
- <p>Transport types used: ".displayTransportUsed($travel['transportTypes'])."</p>
-
- </div><!-- content -->
- </div><!-- widgetbox -->
-
- <div class='widgetbox'>
- <h3><span>Delete travel</span></h3>
- <div class='content'>
-
- <form id='form' action='travelinfo.php' method='post'>
- <input type='hidden' name='deletedID' value='".$travel['id']."'/>
- <input type='hidden' name='deletedName' value='".$travel['name']."'/>
- <div class='form_default' style='text-align:center;'>
-
- Delete <b>".$travel['name']."</b> travel?<br/>
- All itineraries contained in the travel will also be deleted.
-
- <p><button style='margin-left:0px;'>Delete travel</button></p>
-
- </div><!--form-->
- </form>
- </div><!-- content -->
- </div><!-- widgetbox -->
-
- </div><!--right-->
- </div><!--one_third last-->
-
- <br clear='all' />
-
- </div><!--maincontent-->
- <br />";
- }
-
- else {
-
- echo "<div class='maincontent'>
-
- <div class='breadcrumbs'>
- <a href='index.php'>Dashboard</a>
- <a href='userslist.php'>Users List</a>
- <a href='user.php?id=".$lookupUser."'>User: ".$lookupUser."</a>
- <span>Travel: ".$travel['name']." [".$travel['id']."]</span>
- </div><!-- breadcrumbs -->
- <div class='three_fifth'>
- <div class='left'>
-
- <h1 class='pageTitle'>Travel: ".$travel['name']." [".$travel['id']."]</h1>
-
- <div class='widgetbox'>
- <h3><span>Travel Info</span></h3>
- <div class='content'>
- <div class='one_fourth' style='text-align:center;'>
- <img src='".$userLookupData['img']."' alt='' style='border:1px solid black' width='64' height='64'/><br/>
- <a href='user.php?id=".$lookupUser."'>".$lookupUser."</a>
- </div>
- <div class='one_fourth' style='text-align:center;'><h2 class='prize'>".$travel['km']." km</h2><br/>
- Itineraries</div>
- <div class='one_fourth' style='text-align:center;'><h2 class='prize'>".$travel['days']." ".qty('day','days',$travel['days'])."</h2><br/>
- From<br/>to</div>
- <div class='one_fourth last' style='text-align:center;'><h2 class='prize'>".$travel['avgSpeed']." km/h</h2><br/>
- ".count($travel['visitedCities'])." ".qty('city','cities',count($travel['visitedCities']))."<br/>
- Countries</div>
- </div><!-- content-->
- </div><!-- widgetbox -->
-
- <div class='widgetbox'>
- <h3><span>Travel Map</span></h3>
- <div class='content'>
- <div id='map' style='width: 540px; height: 370px; margin: 0 auto 10px; border:1px solid #000000;'></div>
- </div><!-- content-->
- </div><!-- widgetbox -->
-
- </div><!-- left -->
- </div><!-- two_third -->
-
- <div class='two_fifth last'>
- <div class='right'>
-
- <div class='widgetbox'>
- <h3><span>Itineraries</span></h3>
- <div class='content nopadding ohidden'>
- <table cellpadding='0' cellspacing='0' class='sTable3' width='100%'>
- <thead>
- <tr>
- <td align='center' colspan='3'>List of itineraries</td>
- </tr>
- </thead>
- <tbody>";
- foreach ($travel['itineraries'] as $itinerary) {
- echo "<tr>
- <td align='center' width='24%'><b>#".$itinerary['number']."</b></td>
- <td align='center' width='38%'><img src='images/flags/".$itinerary['depLocationCountry'].".png' alt=''/> <a href='location.php?id=".$itinerary['depLocation']."'>".$itinerary['depLocationName']."</a></td>
- <td align='center' width='38%'><img src='images/flags/".$itinerary['arrLocationCountry'].".png' alt=''/> <a href='location.php?id=".$itinerary['arrLocation']."'>".$itinerary['arrLocationName']."</a></td>
- </tr>
- <tr>
- <td align='center' style='border-bottom:1px solid black;'>".$itinerary['km']." km</td>
- <td align='center' style='border-bottom:1px solid black;'><img src='images/".getTransportImg($settingsXpath,$itinerary['transport'])."' alt=''/> ".getTransportName($settingsXpath,$itinerary['transport'])."</td>
- <td align='center' style='border-bottom:1px solid black;'>".str_replace('-','/',$itinerary['depDate'])."</td>
- </tr>";
- }
- echo "<tr>
- <td align='center' colspan='3'>Total: ".count($travel['itineraries'])." ".qty('itinerary','itineraries',count($travel['itineraries']))."</td>
- </tr>";
- echo "</tbody>
- </table>
- </div><!-- content -->
- </div><!-- widgetbox2 -->
-
-
- </div><!--right-->
- </div><!--one_third last-->
-
- <br clear='all' />
-
- </div><!--maincontent-->
- <br />";
- }
- displayFooter();
- echo "</body>";
- }
- ?>