#!/usr/bin/perl
use lib '/web/home.physics.ucla.edu/webroot/cgi-bin/rooms/';
require "cgi-lib.pl";
require "room_schedule_lib.pl";
#OHMNEW
$database_root = "/web/home.physics.ucla.edu/webroot/html/calendar/rooms/db/";
&ReadParse(*input);
if($input{'day'} && $input{'month'} && $input{'year'}){
$day=$input{'day'};
$month=$input{'month'};
$year=$input{'year'};
}
else {
$day=(localtime)[3];
$month=(January,February,March,April,May,June,July,August,September,October,November,December)[(localtime)[4]];
#OHMNEW
#$year=(localtime)[5];
$year=(localtime)[5] + 1900;
}
$sch_database="$database_root$year$month";
print &PrintHeader;
@update_s=&update;
@class_data = &read_classes($sch_database);
print &schedule_head;
print &print_schedule(@class_data);
print &schedule_tail;
#----------------------------------------------------
sub unique_time { # prints time slots
local ($start,$end,$length,$half) = @_;
$half = "";
($start =~ /\.5/) && ($half = ":30");
$start =~ s/\.5//;
if($start >= 13) {
$start -= 12;
$start .= "$half pm";
} elsif($start < 12) {
$start .= "$half am";
} else {
$start .= "$half pm";
}
$half = "";
($end =~ /\.5/) && ($half = ":30");
$end =~ s/\.5//;
if($end >= 13) {
$end -= 12;
$end .= "$half pm";
} elsif($end < 12) {
$end .= "$half am";
} else {
$end .= "$half pm";
}
$length = "
$start - $end";
return $length;
}
#----------------------------------------------------
sub print_schedule { # prints the room schedule for the date selected
local (@class_data,$time) = @_;
local (@rooms,$start,$end,$room,$record,@record,$has_record);
local ($length);
#@rooms = ("2-222 Knudsen","3-121 Knudsen","4-134 Knudsen","6-129 Knudsen","2-707A PAB","3-703 PAB","4-330 PAB","4-708 PAB","PAB Patio");
#@rooms = ("2-222 Knudsen","3-121 Knudsen","4-134 Knudsen","6-129 Knudsen","2-707A PAB","Astro Reading Room","3-703 PAB","4-330 PAB","4-708 PAB","PAB Patio");
@rooms = ("2-222 Knudsen","3-121 Knudsen","4-134 Knudsen","6-129 Knudsen","2-707A PAB","Astro Reading Room","3-703 PAB","4-330 PAB","4-708 PAB","4-740 PAB","PAB Patio");
print "
";
print "
Physics & Astronomy Conference Rooms
$day $month $year \n"; print " | |||||||||||
&\#160 | \n"; foreach $room (@rooms) { print "$room | \n"; } print "||||||||||
";
print "$start $end"; print " | \n";
foreach $room (@rooms) { # scan thru the data by room
$has_record = 0;
foreach $record (@class_data) {
@record = split(":",$record);
$length = undef;
if ( ($record[0] eq $room) &&
(($record[2] == $time) ||
(($record[2] < $time) && ($record[3] > $time)))) {
#(($time + 1) != $record[3]) &&
# ($length = &unique_time($record[2],$record[3]));
$length = &unique_time($record[2],$record[3]);
if ($record[1] == $day && $has_record==0){
print "";
print "\n";
print "$record[5] $record[4]$length"; print "\n"; print " | \n";
$has_record = 1;
}
} # if room & time
} # foreach $class_data
if ($has_record==0) {
print "&\#160 | \n"; #print "\n"; } } # foreach @room print " |