Subversion Repositories VORC

Rev

Rev 145 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
46 - 1
#!/usr/bin/perl
2
 
56 bgadell 3
# Redirect error messages to a log of my choosing. (it's annoying to filter for errors in the shared env)
4
my $error_log_path = $ENV{SERVER_NAME} eq "volunteers.rollercon.com" ? "/home3/rollerco/logs/" : "/tmp/";
5
close STDERR;
6
open STDERR, '>>', $error_log_path.'vorc_error.log' or warn "Failed to open redirected logfile ($0): $!";
7
#warn "Redirecting errors to ${error_log_path}vorc_error.log";
8
 
46 - 9
use strict;
10
use cPanelUserConfig;
11
use RollerCon;
12
use WebDB;
13
use tableViewer;
112 - 14
use CGI qw/param header start_html url/;
46 - 15
use CGI::Cookie;
16
use DateTime;
17
 
18
my $cookie_string = authenticate(2) || die;
19
my ($EML, $PWD, $LVL) = split /&/, $cookie_string;
20
my $user = getUser($EML);
21
my $RCAUTH_cookie = CGI::Cookie->new(-name=>'RCAUTH',-value=>"$cookie_string",-expires=>"+30m");
22
 
23
my $date = param ("date");
24
my $dt;
25
if ($date =~ /^\d{4}-\d{2}-\d{2}$/) {
26
  my ($YYYY, $MM, $DD) = split /-/, $date;
27
  $dt = DateTime->new(
28
    year  => $YYYY,
29
    month => $MM,
30
    day   => $DD
31
  );
32
} else {
33
  $dt = DateTime->today;
34
  $date = $dt->date;
35
}
36
my $day = $dt->day_name;
37
 
38
my %class = qw(
39
	U Unrestricted
40
	M Mens
41
	W Womens
42
	SS Single-Gender
43
);
44
 
45
my $dbh = WebDB::connect ();
46
 
47
print CGI::header(-cookie=>$RCAUTH_cookie);
48
 
49
 
50
 
51
 
52
print<<output;
53
<html><head><title>RollerCon VORC - Daily Announcer Schedule - $day ($date)</title>
54
<link rel="stylesheet" type="text/css" href="/rollercon.css">
55
</head>
56
<body text="#000000" bgcolor="#FFFFFF" link="#0000EE" vlink="#551A8B" alink="#FF0000">
57
output
58
 
59
my $gcount = 1; my $tcount = '';
60
my $sth = $dbh->prepare("select distinct teams, track, level, time, gtype, restrictions from v_shift_announcer where date = ? order by track, time");
61
my $crewhan = $dbh->prepare("select role, derby_name from v_shift_announcer where date = ? and track = ? and time = ?");
62
my $leadhan = $dbh->prepare("select location, time, derby_name from v_shift where dept = 'ANN' and date = ? order by location, time");
63
my $openshifthan = $dbh->prepare("select time, level, restrictions, gtype, teams, tla, name from v_shift_announcer where tla <> 'ALT' and isNull(derby_name) = 1 and date = ? and track = ? order by time");
64
 
65
my @leads = ("<table>\n", "<tr><td colspan=5><b>Lead Shifts</b></td></tr>\n");
66
$leadhan->execute($date);
67
my $tc = 'C1';
68
while (my $lshift = $leadhan->fetchrow_hashref()) {
69
	if ($tc ne $lshift->{location}) {
70
		push @leads, "<tr><td colspan=5>&nbsp;</td></tr>\n";
71
		$tc = $lshift->{location};
72
	}
73
	push @leads, "<tr><td>$lshift->{location}</td><td>&nbsp;</td><td>$lshift->{time}</td><td>&nbsp;</td><td>$lshift->{derby_name}</td></tr>\n";
74
}
75
push @leads, "</table>\n";
76
 
77
$sth->execute($date);
78
while (my $g = $sth->fetchrow_hashref()) {
79
	if ($tcount ne $g->{track}) { #pagebreak whenever we change tracks
80
		print "<div class='pagebreak'><hr></div>\n" unless !$tcount;
81
		print @leads;
82
 
83
		my @openshifts = ("<table>\n", "<tr><td colspan=5><b>Open Shifts on $g->{track}</b></td></tr>\n");
84
		$openshifthan->execute($date, $g->{track});
85
		while (my @oshift = $openshifthan->fetchrow_array()) {
86
			my $sh = join "</td><td>&nbsp;</td><td>", @oshift;
87
			push @openshifts, "<tr><td>$sh</td></tr>\n";
88
		}
89
		push @openshifts, "</table>\n";
90
		print "<br><br><br><br>";
91
		print @openshifts;
92
 
93
		print "<div class='pagebreak'><hr></div>\n";
94
		$gcount = 1;
95
		$tcount = $g->{track};
96
	}
97
 
98
	$g->{gtype} = join '', map { ucfirst lc } split /(\s+)/, $g->{gtype}; # Capitalize the game time to look nicer
99
 
100
	my %crew;
101
	$crewhan->execute($date, $g->{track}, $g->{time});
102
	while (my ($k, $v) = $crewhan->fetchrow_array()) {
103
		$crew{$k} = $v;
104
	}
105
 
106
	my $A = '';
107
	if (defined $crew{'ALT'}) {
108
		$A = "ALT:";
109
	} else {
110
		$crew{'ALT'} = '';
111
	}
112
 
144 - 113
	my $color = "<tr><td>Color:</td><td colspan=4>$crew{'COL'}</td></tr>";
114
	if ($g->{track} eq "BT") {
115
	  $color = "";
116
	}
117
 
118
	my $producer;
119
	if ($g->{gtype} eq "Selected Staffing") {
146 - 120
	  $producer = "<tr><td>Producer:</td><td colspan=4>$crew{'PRO'}</td></tr>";
144 - 121
	}
122
 
46 - 123
	print<<game;
124
<table>
125
	<tr><td>Date:</td><td>$day ($date)</td><td>&nbsp;</td><td>Track:</td><td>$g->{track}</td></tr>
126
	<tr><td>Time:</td><td>$g->{time}</td><td>&nbsp;</td><td>Class:</td><td>$class{$g->{restrictions}} $g->{level} $g->{gtype}</td></tr>
127
	<tr><td>Game:</td><td colspan=4>$g->{teams}</td></tr>
128
	<tr><td colspan=5>&nbsp;</td></tr>
144 - 129
	$color
46 - 130
	<tr><td>Play-by-play:</td><td colspan=4>$crew{'PBP'}</td></tr>
131
	<tr><td>Sponsorship:</td><td colspan=4>$crew{'SPO'}</td></tr>
145 - 132
	$producer
46 - 133
</table><br><br><br><br><br><br><br><br><br><br><br><br>
134
game
135
 
136
	$gcount++ % 4 == 0 ? print "<div class='pagebreak'><hr></div>\n" : { };
137
}
138
 
139
 
140
 
141
print<<tail;
142
</BODY>
143
</HTML>
144
tail