PageRenderTime 48ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/booking/reservations/agent_calendar_by_year.php

https://bitbucket.org/anneivycat/california-tour
PHP | 333 lines | 287 code | 23 blank | 23 comment | 90 complexity | 5fb543e846821abe3e6b57dec33017e2 MD5 | raw file
  1. <?php
  2. error_reporting(0);
  3. extract($_GET);
  4. include ("../sqlfuncs.php");
  5. $l = connect_to_db();
  6. $l = select_db($l);
  7. if ($city=="") { $city="SF"; }
  8. $myCities["SB"]="Santa Barbara";
  9. $myCities["SF"]="San Francisco";
  10. $myCities["SD"]="San Diego";
  11. $myCities["LA"]="Los Angeles";
  12. $sql = 'SELECT `TOUR_TYPE` AS tt, `TOUR_NAME` AS tn
  13. FROM `TOUR`
  14. ORDER BY tt;';
  15. $r = mysql_query($sql);
  16. $nr = mysql_num_rows($r);
  17. for ($i=0;$i<$nr;$i++) {
  18. $line=mysql_fetch_array($r);
  19. $myTours[$line['tt']]=ucwords(strtolower($line['tn']));
  20. // echo $line['tt']."=".$line['tn']."<br />\n";
  21. }
  22. ?>
  23. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
  24. <HTML>
  25. <HEAD>
  26. <TITLE>Tours from <?php echo $myCities[$city]; ?></TITLE>
  27. <?php if($languageUsed == "JP") { ?>
  28. <meta http-equiv=\"Content-Type\" content="text/html; charset=x-sjis">
  29. <?php
  30. } else {
  31. ?>
  32. <meta http-equiv=\"Content-Type\" content="text/html; charset=UTF-8">
  33. <?php
  34. }
  35. ?>
  36. <style type="text/css">
  37. BODY {
  38. font: 300 10px Verdana, Arial, sans-serif;
  39. }
  40. A SPAN { display: none; }
  41. A:HOVER SPAN { display: block; }
  42. </style>
  43. <?php echo "<title>California Tours - Tours From $city</title>\n"; ?>
  44. <script language="JavaScript">
  45. <!--
  46. function MM_swapImgRestore() { //v3.0
  47. var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
  48. }
  49. function MM_preloadImages() { //v3.0
  50. var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
  51. var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
  52. if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
  53. }
  54. function MM_findObj(n, d) { //v4.0
  55. var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
  56. d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  57. if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  58. for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  59. if(!x && document.getElementById) x=document.getElementById(n); return x;
  60. }
  61. function MM_swapImage() { //v3.0
  62. var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
  63. if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
  64. }
  65. //-->
  66. </script>
  67. </head>
  68. <?php
  69. function getFirstWeekDay($CurrentYear,$CurrentMonth,$CurrentDay) {
  70. /*
  71. if($CurrentDay == "")
  72. $CurrentDay = "1";
  73. $day=mktime(0, 0, 0, $CurrentMonth,$CurrentDay,$CurrentYear);
  74. echo "<p>day: $day; 0, 0, 0, $CurrentMonth,$CurrentDay,$CurrentYear";
  75. $day=date("w",$day);
  76. echo " date: $day</p>";
  77. */
  78. $day = date("w",strtotime("$CurrentMonth/1/$CurrentYear"));
  79. return ($day);
  80. }
  81. function getMonthName($iMonth) {
  82. if ($iMonth == 1) { return("January"); }
  83. if ($iMonth == 2) { return("February"); }
  84. if ($iMonth == 3) { return("March"); }
  85. if ($iMonth == 4) { return("April"); }
  86. if ($iMonth == 5) { return("May"); }
  87. if ($iMonth == 6) { return("June"); }
  88. if ($iMonth == 7) { return("July"); }
  89. if ($iMonth == 8) { return("August"); }
  90. if ($iMonth == 9) { return("September"); }
  91. if ($iMonth == 10) { return("October"); }
  92. if ($iMonth == 11) { return("November"); }
  93. if ($iMonth == 12) { return("December"); }
  94. return("INVALID MONTH");
  95. }
  96. function getDaysInMonth($CurrentYear,$CurrentMonth) {
  97. $iDaysInMonth = 31;
  98. if (getMonthName($CurrentMonth) == "January") { return(31); }
  99. if (getMonthName($CurrentMonth) == "March") { return(31); }
  100. if (getMonthName($CurrentMonth) == "April") { return(30); }
  101. if (getMonthName($CurrentMonth) == "May") { return(31); }
  102. if (getMonthName($CurrentMonth) == "June") { return(30); }
  103. if (getMonthName($CurrentMonth) == "July") { return(31); }
  104. if (getMonthName($CurrentMonth) == "August") { return(31); }
  105. if (getMonthName($CurrentMonth) == "September") { return(30); }
  106. if (getMonthName($CurrentMonth) == "October") { return(31); }
  107. if (getMonthName($CurrentMonth) == "November") { return(30); }
  108. if (getMonthName($CurrentMonth) == "December") { return(31); }
  109. if (getMonthName($CurrentMonth) == "February") {
  110. $strCurrentYear = sprintf("%s",$CurrentYear);
  111. if (($CurrentYear %4) == 0) {
  112. return(29);
  113. } else {
  114. return(28);
  115. }
  116. return ($iDaysInMonth);
  117. }
  118. }
  119. $day="";
  120. $dtToday = getdate(time());
  121. if(isset($_REQUEST["year"]) && is_numeric($_REQUEST["year"]))
  122. $year = $_REQUEST["year"];
  123. else
  124. $year = date("Y",time());
  125. if(isset($_REQUEST["month"]) && is_numeric($_REQUEST["month"]))
  126. $month = $_REQUEST["month"];
  127. else
  128. $month = 1;
  129. if(isset($_REQUEST["day"]) && is_numeric($_REQUEST["day"]))
  130. $day = $_REQUEST["day"];
  131. else
  132. $day = "";
  133. /*
  134. if ($year=="") {
  135. $year=2011;
  136. $month=1;
  137. if($year==2004) {
  138. $year=2005;
  139. $month=1;
  140. $day="";
  141. }
  142. }
  143. */
  144. $dtCurrentDate = sprintf("%s/%s/%s",$month,$day,$year);
  145. $CurrentYear = $year;
  146. $CurrentMonth = $month;
  147. $CurrentDay = $day;
  148. echo "<table ALIGN='CENTER' BORDER='0' bgcolor= '#000000' CELLSPACING='0' WIDTH='80%'>";
  149. $iFirstWeekDay = getFirstWeekDay($year,$month,$day);
  150. $iDaysInMonth = getDaysInMonth($year,$month);
  151. $i=$iDaysInMonth+$iFirstWeekDay;
  152. for ($iLoop = $iFirstWeekDay; $iLoop < $i; $iLoop++) {
  153. $aCalendarDays[$iLoop] = $iLoop+1-$iFirstWeekDay;
  154. }
  155. ?>
  156. <STYLE TYPE="text/css">
  157. BODY, TD {
  158. font: 300 12px Verdana, Arial, sans-serif;
  159. color: black;
  160. }
  161. .blueType {
  162. color: #33F;
  163. }
  164. A:link {COLOR: #3366FF; TEXT-DECORATION: none}
  165. A:visited {COLOR: #3366FF; TEXT-DECORATION: none}
  166. A:hover {COLOR: #0000CC; TEXT-DECORATION: none}
  167. .style1 {color: #3300FF}
  168. .style2 {color: #0033FF}
  169. </STYLE>
  170. </head>
  171. <body>
  172. <table width="742" border="0" cellspacing="0" cellpadding="0">
  173. <tr><td width="106">&nbsp;</td>
  174. <td width="261"><img src="/booking/images/california_tours_logo/home153_64.gif" width="153" height="64" alt="California Tours"></td>
  175. <td width="315" align="center"><h3><?php echo $year; ?> tours from <?php echo $myCities[$city]; ?></h3></td>
  176. <td width="60">&nbsp;</td>
  177. </tr>
  178. </table>
  179. <br>
  180. <table width="768" border="0" cellspacing="0" cellpadding="0">
  181. <tr align="center" valign="middle" bgcolor="#ffba3d">
  182. <td width="31" height="13" bgcolor="#FFCC66"></td>
  183. <td width="293" height="13" bgcolor="#FFCC66" align="left"></td>
  184. <td width="351" height="13" bgcolor="#FFCC66" valign="middle" align="right"><a href="mailto:tours@california-tour.com"><img src="/booking/images/links_position/contact.gif" width="310" height="17" border="0" alt="California Tour"></a></td>
  185. <td width="63" height="13" bgcolor="#FFCC66"></td>
  186. </tr>
  187. <tr align="center" valign="top">
  188. <td colspan="5">
  189. <table width="720" border="0" cellspacing="0" cellpadding="0">
  190. <tr>
  191. <td width="130" align="left" valign="top">
  192. <table width="124" border="0" cellspacing="0" cellpadding="0">
  193. <tr><td height="12" align="left" valign="top"><img src="/booking/images/spacer/120_10.gif" width="120" height="10"></td>
  194. </tr>
  195. <tr><td height="168" align="left" valign="top">
  196. </td></tr></table></td>
  197. <td width="485" align="left" valign="top">
  198. <table width="477" border="0" cellspacing="0" cellpadding="0">
  199. <tr><td width="8">&nbsp;</td>
  200. <td align="left" valign="top">
  201. <div align="center">
  202. <br>
  203. <font size="2" color="#006699"><strong>
  204. <font face="Verdana, Arial, Helvetica, sans-serif" size="2">
  205. Tours from
  206. <?php
  207. echo $myCities[$city];
  208. ?>
  209. </strong></font>
  210. </font>
  211. <br />
  212. <a href="agent_calendar_by_year.php?city=<?php echo $city; ?>&year=<?php echo $year; ?>&month=1">jan</a>&nbsp;
  213. <a href="agent_calendar_by_year.php?city=<?php echo $city; ?>&year=<?php echo $year; ?>&month=2">feb</a>&nbsp;
  214. <a href="agent_calendar_by_year.php?city=<?php echo $city; ?>&year=<?php echo $year; ?>&month=3">mar</a>&nbsp;
  215. <a href="agent_calendar_by_year.php?city=<?php echo $city; ?>&year=<?php echo $year; ?>&month=4">apr</a>&nbsp;
  216. <a href="agent_calendar_by_year.php?city=<?php echo $city; ?>&year=<?php echo $year; ?>&month=5">may</a>&nbsp;
  217. <a href="agent_calendar_by_year.php?city=<?php echo $city; ?>&year=<?php echo $year; ?>&month=6">june</a>&nbsp;
  218. <a href="agent_calendar_by_year.php?city=<?php echo $city; ?>&year=<?php echo $year; ?>&month=7">july</a>&nbsp;
  219. <a href="agent_calendar_by_year.php?city=<?php echo $city; ?>&year=<?php echo $year; ?>&month=8">aug</a>&nbsp;
  220. <a href="agent_calendar_by_year.php?city=<?php echo $city; ?>&year=<?php echo $year; ?>&month=9">sept</a>&nbsp;
  221. <a href="agent_calendar_by_year.php?city=<?php echo $city; ?>&year=<?php echo $year; ?>&month=10">oct</a>&nbsp;
  222. <a href="agent_calendar_by_year.php?city=<?php echo $city; ?>&year=<?php echo $year; ?>&month=11">nov</a>&nbsp;
  223. <a href="agent_calendar_by_year.php?city=<?php echo $city; ?>&year=<?php echo $year; ?>&month=12">dec</a>
  224. </font>
  225. <br /><br />
  226. <table width="565" cellspacing="0" cellpadding="0" style="border: 0px; padding: 2px;">
  227. <tr bgcolor="#FFFFFF" align="center" valign="top">
  228. <td colspan="7" height="19">
  229. <font face="Verdana, Arial, Helvetica, sans-serif" color="#006699">
  230. <strong><font size="2" color="#FF6600"><?php echo getMonthName($month); ?> <?php echo $year ?></font></strong>
  231. </font>
  232. </td></tr>
  233. <!-- Display Days of the Week -->
  234. <tr bgcolor="#006699" align="center" valign="middle">
  235. <td width="80"><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#FFFFFF">Sun</font></td>
  236. <td width="80"><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#FFFFFF">Mon</font></td>
  237. <td width="80"><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#FFFFFF">Tues</font></td>
  238. <td width="80"><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#FFFFFF">Wed</font></td>
  239. <td width="80"><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#FFFFFF">Thur</font></td>
  240. <td width="83"><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#FFFFFF">Fri</font></td>
  241. <td width="82"><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#FFFFFF">Sat</font></td></tr>
  242. <!-- Display Calendar -->
  243. <?php for ($iDayBanner = 1; $iDayBanner <= $iColumns; $iDayBanner++) ?>
  244. <tr align="center" valign="top">
  245. <?php
  246. $ImgIndex = 0;
  247. $kk=0;
  248. $dm=substr("000".$month,-2);
  249. for ($i = 0; $i < 42; $i++) {
  250. $dd = $aCalendarDays[$i]+0;
  251. if ($dd == "") {
  252. echo"<TD BGCOLOR='WHITE' VALIGN= 'TOP' ALIGN='Left' style='width: 120px; height: 80px;'>&nbsp;</td>\n";
  253. } else {
  254. // $dd=($i-$iFirstWeekDay+1);
  255. $dd=substr("000".$dd,-2);
  256. echo"<TD BGCOLOR='WHITE' VALIGN= 'TOP' ALIGN='Left' id='tagada$dd' style='width: 120px; height: 80px;'>
  257. <font face='arial'>".($dd+0)."<br />";
  258. $MonthName = getMonthName($month);
  259. $ShortYear = substr($year,2,2);
  260. $query = "SELECT SCHEDULEDTOUR_CODE, TOUR_ID
  261. FROM SCHEDULEDTOUR
  262. WHERE SCHEDULEDTOUR_CODE
  263. LIKE '%$dm$dd$ShortYear'
  264. AND SCHEDULEDTOUR_CODE like '$city%'";
  265. // echo "<span style='font-size: 70%;'>$query</span><br />\n";
  266. $mysql_result = mysql_query($query);
  267. $totalnumrows = mysql_num_rows($mysql_result);
  268. if ($totalnumrows>0) {
  269. while ($row = mysql_fetch_array($mysql_result)) {
  270. $ScheduledTourCode = strtoupper($row[0]);
  271. $TourId = strtoupper($row[1]);
  272. $querytour = "SELECT * FROM TOUR WHERE TOUR_ID = '$TourId'";
  273. $mysql_result_tour = mysql_query($querytour);
  274. $rowtour = mysql_fetch_array($mysql_result_tour);
  275. $TourName = $rowtour[2];
  276. $ImgList = strtolower($rowtour[24]);
  277. if (strlen($ImgList) > 0) {
  278. $ImgListArray = explode(",",$ImgList);
  279. if ($ImgIndex >= count($ImgListArray)) {
  280. $ImgIndex = 0;
  281. $ThmImg = $ImgListArray[$ImgIndex];
  282. } else {
  283. $ThmImg = $ImgListArray[$ImgIndex];
  284. $ImgIndex = $ImgIndex+1;
  285. }
  286. }
  287. $SchedCodeLength = strlen($ScheduledTourCode);
  288. $ScheduledTourShortCode = substr($ScheduledTourCode,0,$SchedCodeLength - 2);
  289. $ScheduledTourShortCode = $ScheduledTourCode;
  290. $myURL="agenttoursignup.php?LocalScheduledTourCode=$ScheduledTourShortCode&languageUsed=$languageUsed&city=$city&year=$year&month=$month&day=$day&SchoolCode=$SchoolCode&UserName=$UserName";
  291. $ucTourName=$myTours[substr($ScheduledTourShortCode,0,4)];
  292. echo "\n<a href=\"$myURL\"><font face='arial' size='-1'>$ucTourName</font></a><br />\n";
  293. }
  294. }
  295. echo "</td>\n";
  296. }
  297. $kk+=1;
  298. if ($kk == 7) {
  299. $kk=0;
  300. echo "</tr>\n";
  301. }
  302. }
  303. ?>
  304. </table></table></table></table>
  305. <center><FONT SIZE="1" FACE="Verdana, Arial, Helvetica, sans-serif" COLOR="#333333">Schedule subject to change.</FONT>
  306. <br>
  307. <br>
  308. <hr width="99%">
  309. </center>
  310. </body></html>