<?php require_once('Connections/conn_newland.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$currentPage = $_SERVER["PHP_SELF"];

$maxRows_rs_tourDetail = 5;
$pageNum_rs_tourDetail = 0;
if (isset($_GET['pageNum_rs_tourDetail'])) {
  $pageNum_rs_tourDetail = $_GET['pageNum_rs_tourDetail'];
}
$startRow_rs_tourDetail = $pageNum_rs_tourDetail * $maxRows_rs_tourDetail;

mysql_select_db($database_conn_newland, $conn_newland);

if (!isset($_POST['tourCountry'])) {
	if (!isset($_GET['regionID'])) {
		$query_rs_tourDetail = "SELECT tourID, tourName, countryName, countryID, tbl_tours.description, itinerary, numNights, exerciseReqd, tour_imageURL, tour_imageALT, meals_per_day FROM tbl_tours INNER JOIN tbl_country  ON tbl_country.countryID=tbl_tours.country ORDER BY tbl_country.countryName "; 
		} else {
		$query_rs_tourDetail = "SELECT tourID, tourName, countryName, countryID, tbl_tours.description, itinerary, numNights, exerciseReqd, tour_imageURL, tour_imageALT, meals_per_day FROM tbl_tours INNER JOIN tbl_country  ON tbl_country.countryID=tbl_tours.country WHERE tbl_country.region = ". GetSQLValueString($_GET['regionID'], "int") ." ORDER BY tbl_country.countryName ";
	}
	} else {
	$query_rs_tourDetail = "SELECT tourID, tourName, countryName, countryID, tbl_tours.description, itinerary, numNights, exerciseReqd, tour_imageURL, tour_imageALT, meals_per_day FROM tbl_tours INNER JOIN tbl_country  ON tbl_country.countryID=tbl_tours.country WHERE tbl_country.countryID = ". GetSQLValueString($_POST['tourCountry'], "int") ." ORDER BY tbl_country.countryName ";
}

$query_limit_rs_tourDetail = sprintf("%s LIMIT %d, %d", $query_rs_tourDetail, $startRow_rs_tourDetail, $maxRows_rs_tourDetail);
$rs_tourDetail = mysql_query($query_limit_rs_tourDetail, $conn_newland) or die(mysql_error());
$row_rs_tourDetail = mysql_fetch_assoc($rs_tourDetail);

if (isset($_GET['totalRows_rs_tourDetail'])) {
  $totalRows_rs_tourDetail = $_GET['totalRows_rs_tourDetail'];
} else {
  $all_rs_tourDetail = mysql_query($query_rs_tourDetail);
  $totalRows_rs_tourDetail = mysql_num_rows($all_rs_tourDetail);
}
$totalPages_rs_tourDetail = ceil($totalRows_rs_tourDetail/$maxRows_rs_tourDetail)-1;

$queryString_rs_tourDetail = "";
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_rs_tourDetail") == false && 
        stristr($param, "totalRows_rs_tourDetail") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_rs_tourDetail = "&" . htmlentities(implode("&", $newParams));
  }
}
$queryString_rs_tourDetail = sprintf("&totalRows_rs_tourDetail=%d%s", $totalRows_rs_tourDetail, $queryString_rs_tourDetail);
?><!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Newland Tours: Opisy wyjazdów</title>
<link href="css/main.css" rel="stylesheet" type="text/css" />
</head>

<body class="oneColFixCtrHdr">
<a href="#top"><img src="images/spacer.gif" alt="Przejdź do głównej treści strony" border="0" /></a>
<div id="container">
  <div id="header">
    <img src="images/banner_left.gif" width="451" height="68" alt="Banner Newland Tours, strona lewa." /><img src="images/banner_right.jpg" width="276" height="68" id="bannerRight" alt="Banner Newland Tours, strona prawa" />
  <!-- end #header --></div>
  <div id="navigation">
  	<ul>
        <li><a href="index.php">Główna</a></li>
        <li><span class=""><span class=""><a href="about.cfm">O firmie</a></span></span></li>
<li><a href="tours.php">Znajdź wyjazd</a></li>
        <li><a href="profiles.php">Opisy krajów</a></li>
        <li><a href="contact.php">Kontakt z nami</a></li>
    </ul>
    </div>
  <div id="mainContent">
    <h1><a name="top" id="top"></a>Opisy  wyjazdów</h1>
    <p><a href="tours.php">Znajdź  wyjazd</a>: Opisy wyjazdów</p>
    <hr />
    <?php do { ?>
      <h2><img src="<?php echo 'images/'.$row_rs_tourDetail['tour_imageURL']; ?>" alt="<?php echo $row_rs_tourDetail['tour_imageALT']; ?>" align="right" /><?php echo $row_rs_tourDetail['countryName']; ?>: <?php echo $row_rs_tourDetail['tourName']; ?></h2>
      <p><strong>Opis wyjazdu</strong>: <?php echo $row_rs_tourDetail['description']; ?></p>
      <p> <strong>Ilość noclegów</strong>: <?php echo $row_rs_tourDetail['numNights']; ?></p>
      <p> <strong>Ilość posiłków w ciągu dnia</strong>: <?php echo $row_rs_tourDetail['meals_per_day']; ?></p>
      <p> <strong>Czy potrzebujesz przygotowania  kondycyjnego</strong>: <?php echo $row_rs_tourDetail['exerciseReqd']; ?></p>
      <table width="60%" border="1" cellpadding="3" cellspacing="0">
        <tr>
          <td><strong>Plan podróży</strong>:</td>
          <td><?php echo $row_rs_tourDetail['itinerary']; ?></td>
        </tr>
      </table>
      <p>Dowiedz się więcej o państwie <a href="profiles.php?countryID=<?php echo $row_rs_tourDetail['countryID']; ?>"><?php echo $row_rs_tourDetail['countryName']; ?></a></p>
      <p> Sprawdź cenę wyjazdu, używając  <a href="tourprice.php?tourID=<?php echo $row_rs_tourDetail['tourID']; ?>">kalkulatora ceny wyjazdu</a></p><hr />
    <?php } while ($row_rs_tourDetail = mysql_fetch_assoc($rs_tourDetail)); ?>
  
  	<?php if ($totalPages_rs_tourDetail != 0) { ?>
      <table width="50%" border="0" align="center" bgcolor="#eeeeee">
        <tr>
          <td align="center"><?php if ($pageNum_rs_tourDetail > 0) { // Show if not first page ?>
                <a href="<?php printf("%s?pageNum_rs_tourDetail=%d%s", $currentPage, 0, $queryString_rs_tourDetail); ?>">Pierwszy</a>
          <?php } // Show if not first page ?>          </td>
          <td align="center"><?php if ($pageNum_rs_tourDetail > 0) { // Show if not first page ?>
                <a href="<?php printf("%s?pageNum_rs_tourDetail=%d%s", $currentPage, max(0, $pageNum_rs_tourDetail - 1), $queryString_rs_tourDetail); ?>">Poprzedni</a>
          <?php } // Show if not first page ?>          </td>
          <td align="center"><?php if ($pageNum_rs_tourDetail < $totalPages_rs_tourDetail) { // Show if not last page ?>
                <a href="<?php printf("%s?pageNum_rs_tourDetail=%d%s", $currentPage, min($totalPages_rs_tourDetail, $pageNum_rs_tourDetail + 1), $queryString_rs_tourDetail); ?>">Następny</a>
                <?php } // Show if not last page ?>
          </td>
          <td align="center"><?php if ($pageNum_rs_tourDetail < $totalPages_rs_tourDetail) { // Show if not last page ?>
                <a href="<?php printf("%s?pageNum_rs_tourDetail=%d%s", $currentPage, $totalPages_rs_tourDetail, $queryString_rs_tourDetail); ?>">Ostatni</a>
          <?php } // Show if not last page ?>          </td>
        </tr>
      </table>
      <?php } ?>
      <p>Wszystkie zdjęcia &copy; PhotoDisc </p>
    <p><a href="tours.php">Znajdź  wyjazd</a>: Opisy wyjazdów</p>
    <br clear="all" />
  <!-- end #mainContent --></div>
  <div id="footer">
    <p>&copy; 2007 Newland Tours</p>
  <!-- end #footer --></div>
<!-- end #container --></div>

</body>
</html>
<?php
mysql_free_result($rs_tourDetail);
?>
