Re: [MRBS-general] Booking limit for user + make certain days/weeks unavailable
Brought to you by:
jberanek
From: John M. <Joh...@se...> - 2005-06-17 19:29:30
|
On 2 Jun 2005 at 16:24, Annemie De Deckers wrote: > We would like to be able to set a limit on booking hours, but only for users, not for administrator. What I did a few years ago (MRBS 1.0-pre2) is as follows: -- config -- # Maximum number of bookings per week in a room $max_bookings = 3; # Week defined as (0) Sun-Sat or (1) sliding 7-day range $week_range = 0; -- edit_entry -- # check if maximum quota for student exceeded $sql = "SELECT start_time FROM mrbs_entry WHERE room_id = $room_id AND create_by = '" . getUserName() . "' "; $count = 0; $i1 = 6-(date("w", mktime(0,0,0,$month,$day,$year)) - $weekstarts + 7) % 7; # - - (0) for fixed week range Sunday-Saturday # - - (1) for a sliding 7-day range for ($i=($week_range?0:$i1); $i<=($week_range?6:$i1) && $count==0; $i++) { $res = sql_query($sql . "AND start_time > ". mktime(0,0,0,$month,$day+$i-6,$year) . " AND start_time < " . mktime(23,59,59,$month,$day+$i,$year)); if (sql_count($res) >= $max_bookings) { echo "Too many bookings for the 7-day period " . strftime('%A %B %d', mktime(0,0,0,$month,$day+$i-6,$year))." to " . strftime('%A %B %d', mktime(0,0,0,$month,$day+$i,$year))." in this room<br>\n"; for ($count = 0; ($row = sql_row($res, $count)); $count++) { echo strftime('%X - %A %d %B %Y', $row[0]) . "<br>\n"; } if (authGetUserLevel(getUserName(), $auth["admin"]) < 3) { include "trailer.inc"; exit; } echo "Proceeding will override this limit.<br>\n"; } } -- edit_entry_handler -- similar change Notes: This is a few years old. May not be exactly compatible with current version. Also I created multilevel admins, so the 3 may need to change. I hard-coded english messages instead of using $lang. To make certain days unavailable, I created a separate table to store all the exceptions to the standard time range for any area/room/day. -- John Meskes Computer Technical Support ... Academic Computing Systems Rm.2120 ... 70 The Pond Rd ... Toronto, ON ... M3J 3M6 416-491-5050 x3149 |