PageRenderTime 56ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/cgadmin/ToursAdmin.php

https://github.com/Elieser/choosing-guides
PHP | 334 lines | 288 code | 40 blank | 6 comment | 54 complexity | bbfa0092260c2866827a1a0eb4e71a63 MD5 | raw file
  1. <?php require_once('Connections/ChoosingGuidesConnection.php'); ?>
  2. <?php
  3. if (!function_exists("GetSQLValueString")) {
  4. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  5. {
  6. if (PHP_VERSION < 6) {
  7. $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  8. }
  9. $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  10. switch ($theType) {
  11. case "text":
  12. $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  13. break;
  14. case "long":
  15. case "int":
  16. $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  17. break;
  18. case "double":
  19. $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  20. break;
  21. case "date":
  22. $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  23. break;
  24. case "defined":
  25. $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  26. break;
  27. }
  28. return $theValue;
  29. }
  30. }
  31. $currentPage = $_SERVER["PHP_SELF"];
  32. $maxRows_Tours = 10;
  33. $pageNum_Tours = 0;
  34. if (isset($_GET['pageNum_Tours'])) {
  35. $pageNum_Tours = $_GET['pageNum_Tours'];
  36. }
  37. $startRow_Tours = $pageNum_Tours * $maxRows_Tours;
  38. $maxRows_Tours = 10;
  39. $pageNum_Tours = 0;
  40. if (isset($_GET['pageNum_Tours'])) {
  41. $pageNum_Tours = $_GET['pageNum_Tours'];
  42. }
  43. $startRow_Tours = $pageNum_Tours * $maxRows_Tours;
  44. $WebLanguage_Tours = "-1";
  45. if (isset($_POST['weblanguage'])) {
  46. $WebLanguage_Tours = $_POST['weblanguage'];
  47. }
  48. else
  49. {
  50. if (isset($_SESSION['MM_WebLanguageId'])){
  51. $WebLanguage_Tours = $_SESSION['MM_WebLanguageId'];
  52. }
  53. }
  54. $country_Tours = "";
  55. if (isset($_POST['country']) && $_POST['country']!='0') {
  56. $country_Tours = 'AND tblTours.CountryId='.$_POST['country'];
  57. }
  58. else
  59. {
  60. if (isset($_SESSION['MM_CountryId']) && $_SESSION['MM_CountryId']!='0'){
  61. $country_Tours = ' AND tblTours.CountryId='.$_SESSION['MM_CountryId'];
  62. }
  63. }
  64. $state_Tours = "";
  65. if (isset($_POST['state']) && $_POST['state']!='0') {
  66. $state_Tours = ' AND tblTours.StateId='.$_POST['state'];
  67. }
  68. else
  69. {
  70. if (isset($_SESSION['MM_StateId']) && $_SESSION['MM_StateId']!='0'){
  71. $state_Tours = ' AND tblTours.StateId='.$_SESSION['MM_StateId'];
  72. }
  73. }
  74. $location_Tours = "";
  75. if (isset($_POST['location']) && $_POST['location']!='0') {
  76. $location_Tours = ' AND tblTours.LocationId='.$_POST['location'];
  77. }
  78. else
  79. {
  80. if (isset($_SESSION['MM_LocationId']) && $_SESSION['MM_LocationId']!='0'){
  81. $location_Tours = ' AND tblTours.LocationId='.$_SESSION['MM_LocationId'];
  82. }
  83. }
  84. $word_Tours = "";
  85. if (isset($_POST['wordfilter'])) {
  86. $word_Tours = $_POST['wordfilter'];
  87. }
  88. $sorted_Tours = "TourId DESC";
  89. mysql_select_db($database_ChoosingGuidesConnection, $ChoosingGuidesConnection);
  90. $query_Tours = sprintf("SELECT tblTours.TourId, tblToursdet.WebLanguageId, tblTours.CountryId, tblTours.StateId, tblTours.LocationId, tblTours.TourPicture, tblTours.TourPictureName, tblToursdet.TourName, CONVERT(tblToursdet.TourDesc, char(290)) AS TourDesc FROM tblTours LEFT OUTER JOIN tblToursdet ON tblTours.TourId = tblToursdet.TourId WHERE WebLanguageId = %s %s %s %s AND (tblToursdet.TourName like %s or tblToursdet.TourDesc like %s) GROUP BY tblTours.TourId ORDER BY %s", GetSQLValueString($WebLanguage_Tours, "int"),$country_Tours,$state_Tours,$location_Tours,GetSQLValueString("%" . $word_Tours . "%", "text"),GetSQLValueString("%" . $word_Tours . "%", "text"),$sorted_Tours);
  91. $query_limit_Tours = sprintf("%s LIMIT %d, %d", $query_Tours, $startRow_Tours, $maxRows_Tours);
  92. $Tours = mysql_query($query_limit_Tours, $ChoosingGuidesConnection) or die(mysql_error());
  93. $row_Tours = mysql_fetch_assoc($Tours);
  94. if (isset($_GET['totalRows_Tours'])) {
  95. $totalRows_Tours = $_GET['totalRows_Tours'];
  96. } else {
  97. $all_Tours = mysql_query($query_Tours);
  98. $totalRows_Tours = mysql_num_rows($all_Tours);
  99. }
  100. $totalPages_Tours = ceil($totalRows_Tours/$maxRows_Tours)-1;
  101. $queryString_Tours = "";
  102. if (!empty($_SERVER['QUERY_STRING'])) {
  103. $params = explode("&", $_SERVER['QUERY_STRING']);
  104. $newParams = array();
  105. foreach ($params as $param) {
  106. if (stristr($param, "pageNum_Tours") == false &&
  107. stristr($param, "totalRows_Tours") == false) {
  108. array_push($newParams, $param);
  109. }
  110. }
  111. if (count($newParams) != 0) {
  112. $queryString_Tours = "&" . htmlentities(implode("&", $newParams));
  113. }
  114. }
  115. $queryString_Tours = sprintf("&totalRows_Tours=%d%s", $totalRows_Tours, $queryString_Tours);
  116. ?>
  117. <script type="text/javascript">
  118. function MM_goToURL() { //v3.0
  119. var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  120. for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
  121. }
  122. </script>
  123. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  124. <html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="../Templates/AdminTemplate.dwt.php" codeOutsideHTMLIsLocked="false" -->
  125. <head><link rel="Shortcut Icon" href="../images/cg.ico" type="image/x-icon" />
  126. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  127. <!-- InstanceBeginEditable name="doctitle" -->
  128. <title>Choosing Guides Admin</title>
  129. <!-- InstanceEndEditable -->
  130. <link href="../CSS/twoColLiqLtHdr.css" rel="stylesheet" type="text/css" />
  131. <link href="../SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
  132. <link href="../Spry-UI-1.7/css/SpryImageSlideShow.css" rel="stylesheet" type="text/css" />
  133. <!--[if lte IE 7]>
  134. <style>
  135. .content { margin-right: -1px; } /* this 1px negative margin can be placed on any of the columns in this layout with the same corrective effect. */
  136. ul.nav a { zoom: 1; } /* the zoom property gives IE the hasLayout trigger it needs to correct extra whiltespace between the links */
  137. </style>
  138. <![endif]-->
  139. <!-- InstanceBeginEditable name="head" -->
  140. <!-- InstanceEndEditable -->
  141. <script src="../SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
  142. <script src="../Spry-UI-1.7/includes/SpryDOMUtils.js" type="text/javascript"></script>
  143. <script src="../Spry-UI-1.7/includes/SpryDOMEffects.js" type="text/javascript"></script>
  144. <script src="../Spry-UI-1.7/includes/SpryWidget.js" type="text/javascript"></script>
  145. <script src="../Spry-UI-1.7/includes/SpryPanelSet.js" type="text/javascript"></script>
  146. <script src="../Spry-UI-1.7/includes/SpryFadingPanels.js" type="text/javascript"></script>
  147. <script src="../Spry-UI-1.7/includes/SpryImageLoader.js" type="text/javascript"></script>
  148. <script src="../Spry-UI-1.7/includes/SpryImageSlideShow.js" type="text/javascript"></script>
  149. <script src="../Spry-UI-1.7/includes/plugins/ImageSlideShow/SpryPanAndZoomPlugin.js" type="text/javascript"></script>
  150. <style type="text/css">
  151. /* BeginOAWidget_Instance_2141542: #ImageSlideShow */
  152. #ImageSlideShow.ImageSlideShow {
  153. width: 250px;
  154. height: 98px;
  155. border: solid 1px #000000;
  156. }
  157. #ImageSlideShow .ISSClip {
  158. background-color: #000000;
  159. }
  160. /* EndOAWidget_Instance_2141542 */
  161. </style>
  162. <script type="text/xml">
  163. <!--
  164. <oa:widgets>
  165. <oa:widget wid="2141542" binding="#ImageSlideShow" />
  166. </oa:widgets>
  167. -->
  168. </script>
  169. </head>
  170. <body bgcolor="#D2D2FF">
  171. <div class="container">
  172. <div class="header">
  173. <div class="logo">
  174. <a href="../IndexAdmin.php"><img src="../images/LogoChoosingGuides.gif" alt="Insert Logo Here" name="Insert_logo" width="300" height="100" class="logo" id="Insert_logo" style="background-color: #8090AB; display:block;" /></a>
  175. <!-- end .header -->
  176. </div>
  177. <ul id="ImageSlideShow">
  178. <li><img src="../images/camp-nou.jpg" alt="" width="250" height="98" /></li>
  179. <li><img src="../images/diagonal.jpg" alt="" width="250" height="96" /></li>
  180. <li><img src="../images/gardens-royal-palace-pedralbes.jpg" alt="" width="250" height="96" /></li>
  181. <li><img src="../images/pedralbes-monastery.jpg" alt="" width="250" height="96" /></li>
  182. <li><img src="../images/pla&ccedil;a-catalunya.jpg" alt="" width="250" height="96" /></li>
  183. </ul>
  184. <div class="weblanguage">
  185. <?php
  186. include ("../Includes/SelectLanguage.php");
  187. ?>
  188. <script type="text/javascript">
  189. // BeginOAWidget_Instance_2141542: #ImageSlideShow
  190. var ImageSlideShow = new Spry.Widget.ImageSlideShow("#ImageSlideShow", {
  191. widgetID: "ImageSlideShow",
  192. injectionType: "replace",
  193. autoPlay: true,
  194. displayInterval: 4000,
  195. transitionDuration: 2000,
  196. componentOrder: ["view"],
  197. plugIns: [ ]
  198. });
  199. // EndOAWidget_Instance_2141542
  200. </script>
  201. </div>
  202. </div>
  203. <div class="menu">
  204. <ul id="MenuBar1" class="MenuBarHorizontal">
  205. <li><a href="#">Guides Admin</a></li>
  206. <li><a href="#">Travel Agencies Admin</a></li>
  207. <li><a href="ToursAdmin.php">Tours Admin</a></li>
  208. <li><a href="PlacesAdmin.php">Interesting Places Admin</a></li>
  209. </ul>
  210. </div>
  211. <div class="content"><!-- InstanceBeginEditable name="Body" -->
  212. <?php
  213. include ("Includes/filter.php");
  214. ?>
  215. <table border="0" align="right">
  216. <tr>
  217. <td align="left"><?php if (mysql_num_rows($Tours)!=0){?>
  218. Found <?php echo $totalRows_Tours?> Results<?php }?></td>
  219. <td width="200">
  220. <td width="72"><input name="new" type="button" id="new" onClick="MM_goToURL('parent','ToursAdminAdd.php');return document.MM_returnValue" value="New Tour" /></td>
  221. <td width="0"></td>
  222. <td width="0"></td>
  223. <td><?php if ($pageNum_Tours > 0) { // Show if not first page ?>
  224. <a href="<?php printf("%s?pageNum_Tours=%d%s", $currentPage, 0, $queryString_Tours); ?>"><img src="../images/First.gif" /></a>
  225. <?php } else {?><img src="../images/First_disable.gif" /> <?php } // Show if not first page ?></td>
  226. <td><?php if ($pageNum_Tours > 0) { // Show if not first page ?>
  227. <a href="<?php printf("%s?pageNum_Tours=%d%s", $currentPage, max(0, $pageNum_Tours - 1), $queryString_Tours); ?>"><img src="../images/Previous.gif" /></a>
  228. <?php } else {?><img src="../images/Previous_disable.gif" /> <?php } // Show if not first page ?></td>
  229. <td><?php echo $pageNum_Tours+1 ?> of <?php echo $totalPages_Tours+1 ?></td>
  230. <td><?php if ($pageNum_Tours < $totalPages_Tours) { // Show if not last page ?>
  231. <a href="<?php printf("%s?pageNum_Tours=%d%s", $currentPage, min($totalPages_Tours, $pageNum_Tours + 1), $queryString_Tours); ?>"><img src="../images/Next.gif" /></a>
  232. <?php } else {?><img src="../images/Next_disable.gif" /> <?php }// Show if not last page ?></td>
  233. <td><?php if ($pageNum_Tours < $totalPages_Tours) { // Show if not last page ?>
  234. <a href="<?php printf("%s?pageNum_Tours=%d%s", $currentPage, $totalPages_Tours, $queryString_Tours); ?>"><img src="../images/Last.gif" /></a>
  235. <?php } else {?><img src="../images/Last_disable.gif" /> <?php }// Show if not last page ?></td>
  236. </tr>
  237. </table>
  238. <?php
  239. if (mysql_num_rows($Tours)==0)
  240. {
  241. echo "No Results were found ...";
  242. }
  243. else
  244. {
  245. do { ?>
  246. <div class="placesList"> <div class="placeImage"> <a href="ToursAdminDetails.php?tour=<?php echo $row_Tours['TourId']; ?>"><img src="<?php echo "../".$row_Tours['TourPicture']; ?>" width="196" height="156" alt="<?php echo $row_Tours['TourPictureName']; ?>" /></a> </div>
  247. <div class="PlaceDesc">
  248. <div class="EditDelete">
  249. <input name="Delete" type="button" onClick="MM_goToURL('parent','ToursAdminDel.php?Tour=<?php echo $row_Tours['TourId']; ?>');return document.MM_returnValue" value="Delete" />
  250. </div>
  251. <h4><a href="ToursAdminDetails.php?tour=<?php echo $row_Tours['TourId']; ?>"><?php echo $row_Tours['TourName']; ?></a></h4>
  252. <p class="placeDesc"><?php echo $row_Tours['TourDesc']; ?> ...</p>
  253. </div>
  254. </div>
  255. <?php } while ($row_Tours = mysql_fetch_assoc($Tours)); ?>
  256. <p>
  257. <table border="0" align="right">
  258. <tr>
  259. <td><input name="new" type="button" id="new" onClick="MM_goToURL('parent','ToursAdminAdd.php');return document.MM_returnValue" value="New Tour" /></td>
  260. <td></td>
  261. <td></td>
  262. <td><?php if ($pageNum_Tours > 0) { // Show if not first page ?>
  263. <a href="<?php printf("%s?pageNum_Tours=%d%s", $currentPage, 0, $queryString_Tours); ?>"><img src="../images/First.gif" /></a>
  264. <?php } else {?><img src="../images/First_disable.gif" /> <?php } // Show if not first page ?></td>
  265. <td><?php if ($pageNum_Tours > 0) { // Show if not first page ?>
  266. <a href="<?php printf("%s?pageNum_Tours=%d%s", $currentPage, max(0, $pageNum_Tours - 1), $queryString_Tours); ?>"><img src="../images/Previous.gif" /></a>
  267. <?php } else {?><img src="../images/Previous_disable.gif" /> <?php } // Show if not first page ?></td>
  268. <td><?php echo $pageNum_Tours+1 ?> of <?php echo $totalPages_Tours+1 ?></td>
  269. <td><?php if ($pageNum_Tours < $totalPages_Tours) { // Show if not last page ?>
  270. <a href="<?php printf("%s?pageNum_Tours=%d%s", $currentPage, min($totalPages_Tours, $pageNum_Tours + 1), $queryString_Tours); ?>"><img src="../images/Next.gif" /></a>
  271. <?php } else {?><img src="../images/Next_disable.gif" /> <?php }// Show if not last page ?></td>
  272. <td><?php if ($pageNum_Tours < $totalPages_Tours) { // Show if not last page ?>
  273. <a href="<?php printf("%s?pageNum_Tours=%d%s", $currentPage, $totalPages_Tours, $queryString_Tours); ?>"><img src="../images/Last.gif" /></a>
  274. <?php } else {?><img src="../images/Last_disable.gif" /> <?php }// Show if not last page ?></td>
  275. </tr>
  276. </table>
  277. </p>
  278. <!-- InstanceEndEditable --><!-- end .content --></div>
  279. <div class="sidebar1">
  280. <p>Barra Lateral aaa</p>
  281. </div>
  282. <div class="footer">
  283. <p>&nbsp;</p>
  284. <!-- end .footer --></div>
  285. <!-- end .container --></div>
  286. <script type="text/javascript">
  287. var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"../SpryAssets/SpryMenuBarDownHover.gif", imgRight:"../SpryAssets/SpryMenuBarRightHover.gif"});
  288. </script>
  289. </body>
  290. <!-- InstanceEnd --></html>
  291. <?php
  292. }
  293. mysql_free_result($Tours);
  294. ?>