[MRBS-general] Date Selects in trailer.inc
Brought to you by:
jberanek
From: Jeff H. <Jef...@in...> - 2004-06-18 17:37:45
|
When upgrading my reservation system, I realized that I have some code you might be interested in. If not, sorry to waste your time. The code replaces the list of dates in the trailer with three forms (select fields). The current day, week and month are selected by default. I had to modify trailer.inc to do this. Also, I had to make a small addition to day.php, week.php and month.php. Feel free to use, modify or ignore :) -- Jeff I don't have a diff for day.php, week.php and month.php because the addition is a simple one (but I can make the diff). Just place the following block of code towards the top before $day, $month and $year are figured out: # If $date was passed from trailer if (!empty($date)) { $year = substr ( $date, 0, 4 ); $month = substr ( $date, 4, 2 ); $day = substr ( $date, 6, 2 ); } Here is the diff for the trailer: 6,21c6,19 < echo "<P><HR><B>".get_vocab("viewday").":</B>\n"; < < if(!isset($year)) < $year = strftime("%Y"); < < if(!isset($month)) < $month = strftime("%m"); < < if(!isset($day)) < $day = strftime("%d"); < < if (empty($area)) < $params = ""; < else < $params = "&area=$area"; < --- > if(!isset($year)) $year = strftime("%Y"); > if(!isset($month)) $month = strftime("%m"); > if(!isset($day)) $day = strftime("%d"); > $params = ""; > if (!empty($area)) $params = "<input type=\"hidden\" name=\"area\" value=\"$area\" />\n"; > ?> > > <table style="border-width:0px; width:100%;" cellpadding="0" cellspacing="0"><tr> > <td style="text-align:right; width:33%;" valign="top"> > <p><form action="day.php" method="post"> > <span style="font-weight:bold;"><?php echo get_vocab("viewday")?>:</span> > <?php echo $params; ?> > <select name="date" onchange="submit()"> > <?php 25d22 < 27,32c24,28 < < $cyear = date("Y", $ctime); < $cmonth = date("m", $ctime); < $cday = date("d", $ctime); < if ($i != -6) echo " | "; < echo "<a href=\"day.php?year=$cyear&month=$cmonth&day=$cday$params\">$str</a>\n"; --- > $cdate = date("Ymd", $ctime); > > echo "<option value=\"$cdate\""; > if ($i==0) echo " selected=\"selected\""; > echo ">$str</option>\n"; 34,38c30,44 < < echo "<BR><B>".get_vocab("viewweek").":</B>\n"; < < if (!empty($room)) $params .= "&room=$room"; < --- > ?> > </select> > <input type="submit" value="<?php echo get_vocab("goto")?>" /> > </form></p> > </td> > > <td style="text-align:center; width:33%;" valign="top"> > <p><form action="week.php" method="post"> > <?php > if (!empty($room)) $params .= "<input type=\"hidden\" name=\"room\" value=\"$room\" />\n"; > echo $params; > ?> > <span style="font-weight:bold;"><?php echo get_vocab("viewweek")?>:</span> > <select name="date" onchange="submit()"> > <?php 46d51 < 48,53c53,60 < $cday = date("d", $ctime); < $cmonth = date("m", $ctime); < $cyear = date("Y", $ctime); < if ($i != -4) echo " | "; < ($view_week_number) ? $str = $cweek : $str = utf8_strftime(empty($dateformat)? "%b %d" : "%d %b", $ctime); < echo "<a href=\"week.php?year=$cyear&month=$cmonth&day=$cday$params\">$str</a>\n"; --- > $cdate = date("Ymd", $ctime); > $ctime_end = $ctime + ( 3600 * 24 * 6 ); > ($view_week_number) ? $str = $cweek : $str = utf8_strftime(empty($dateformat)? "%b %d" : "%d %b", $ctime); > if (!$view_week_number) $str .= utf8_strftime(empty($dateformat)? " - %b %d" : " - %d %b", $ctime_end); > > echo "<option value=\"$cdate\""; > if ($i==0) echo " selected=\"selected\""; > echo ">$str</option>\n"; 55,56c62,73 < < echo "<BR><B>".get_vocab("viewmonth").":</B>\n"; --- > ?> > </select> > <input type="submit" value="<?php echo get_vocab("goto")?>" /> > </form></p> > </td> > > <td style="text-align:left; width:33%;" valign="top"> > <p><form action="month.php" method="post"> > <?php echo $params; ?> > <span style="font-weight:bold;"><?php echo get_vocab("viewmonth")?>:</span> > <select name="date" onchange="submit()"> > <?php 61,66c78 < < $cmonth = date("m", $ctime); < $cyear = date("Y", $ctime); < if ($i != -2) echo " | "; < echo "<a href=\"month.php?year=$cyear&month=$cmonth$params\">$str</a>\n"; < } --- > $cdate = date("Ym", $ctime)."01"; 67a80,84 > echo "<option value=\"$cdate\""; > if ($i==0) echo " selected=\"selected\""; > echo ">$str</option>\n"; > } > echo "</select>\n<input type=\"submit\" value=\"". get_vocab("goto")."\" />\n</form></p>\n</td></tr>\n</table>\n\n"; |