Subversion Repositories VORC

Rev

Rev 142 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
8 - 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
 
8 - 9
use strict;
10
use cPanelUserConfig;
11
use RollerCon;
38 - 12
use WebDB;
13
use tableViewer;
112 - 14
use CGI qw/param header start_html url/;
8 - 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
 
44 - 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
}
8 - 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
 
38 - 45
my $dbh = WebDB::connect ();
8 - 46
 
47
print CGI::header(-cookie=>$RCAUTH_cookie);
48
 
49
 
50
 
51
 
52
print<<output;
38 - 53
<html><head><title>RollerCon VORC - Daily Officiating Schedule - $day ($date)</title>
8 - 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 = '';
38 - 60
my $sth = $dbh->prepare("select distinct teams, track, level, time, gtype, restrictions from v_shift_officiating where date = ? order by track, time");
61
my $crewhan = $dbh->prepare("select role, derby_name from v_shift_officiating where date = ? and track = ? and time = ?");
62
my $leadhan = $dbh->prepare("select location, time, derby_name from v_shift where dept = 'OFF' and date = ? order by location, time");
63
my $openshifthan = $dbh->prepare("select time, level, restrictions, gtype, teams, tla, name from v_shift_officiating where tla <> 'ALT' and isNull(derby_name) = 1 and date = ? and track = ? order by time");
8 - 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()) {
38 - 69
	if ($tc ne $lshift->{location}) {
8 - 70
		push @leads, "<tr><td colspan=5>&nbsp;</td></tr>\n";
38 - 71
		$tc = $lshift->{location};
8 - 72
	}
38 - 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";
8 - 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
 
142 - 98
	$g->{gtype} = join '', map { ucfirst lc } split /(\s+)/, $g->{gtype}; # Capitalize the game type to look nicer
8 - 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
	my $P1 = "PLT-1";
106
	my $P2 = "PLT-2";
107
	my $PH = "PLT";
108
	my $OPR1 = "OPR-1";
109
	if ($g->{gtype} eq "Full Length" or $g->{gtype} eq "Selected Staffing") {
110
		$P1 = 'PLT/H';
111
		$P2 = 'PLT';
112
		$PH = $P1;
113
	} elsif ($g->{gtype} eq "Challenge-rs1") {
114
		$crew{'OPR-1'} = "<i>-not staffed-</i>";
115
		$crew{'OPR-2'} = "<i>-not staffed-</i>";
116
		$crew{'OPR-3'} = "<i>-not staffed-</i>";
117
		$crew{'PLT-1'} = "<i>-not staffed-</i>";
118
		$crew{'PLT-2'} = "<i>-not staffed-</i>";
119
		$crew{'SK-1'} = "<i>-not staffed-</i>";
120
		$crew{'SK-2'} = "<i>-not staffed-</i>";
121
		$crew{'PBM'} = "<i>-not staffed-</i>";
122
	} elsif ($g->{gtype} eq "Challenge-rs2") {
123
		$OPR1 = "OPR";
124
 
125
		$crew{'IPR'} = "<i>-not staffed-</i>";
126
		$crew{'OPR-2'} = "<i>-not staffed-</i>";
127
		$crew{'OPR-3'} = "<i>-not staffed-</i>";
128
		$crew{'PLT-1'} = "<i>-not staffed-</i>";
129
		$crew{'PLT-2'} = "<i>-not staffed-</i>";
130
		$crew{'SK-1'} = "<i>-not staffed-</i>";
131
		$crew{'SK-2'} = "<i>-not staffed-</i>";
132
		$crew{'PBM'} = "<i>-not staffed-</i>";
38 - 133
	} elsif ($g->{gtype} eq "Scrimmage") {
134
		$crew{'PLT-1'} = "<i>-not staffed-</i>";
135
		$crew{'PLT-2'} = "<i>-not staffed-</i>";
136
		$crew{'SK-1'} = "<i>-not staffed-</i>";
137
		$crew{'SK-2'} = "<i>-not staffed-</i>";
138
		$crew{'PBM'} = "<i>-not staffed-</i>";
139
		$crew{'PBT-1'} = "<i>-not staffed-</i>";
140
		$crew{'PBT-2'} = "<i>-not staffed-</i>";
143 - 141
		$crew{'SBO'} = "<i>-not staffed-</i>";
8 - 142
	}
143
 
144
	my $A = '';
145
	if (defined $crew{'ALT'}) {
146
		$A = "ALT:";
147
	} else {
148
		$crew{'ALT'} = '';
149
	}
150
 
142 - 151
	if ($g->{track} eq "BT") {
152
	  print<<BTgame;
8 - 153
<table>
154
	<tr><td>Date:</td><td>$day ($date)</td><td>&nbsp;</td><td>Track:</td><td>$g->{track}</td></tr>
155
	<tr><td>Time:</td><td>$g->{time}</td><td>&nbsp;</td><td>Class:</td><td>$class{$g->{restrictions}} $g->{level} $g->{gtype}</td></tr>
156
	<tr><td>Game:</td><td colspan=4>$g->{teams}</td></tr>
157
	<tr><td colspan=5>&nbsp;</td></tr>
142 - 158
	<tr><td>HR:</td><td>$crew{'HR'}</td><td>&nbsp;</td><td>GE:</td><td>$crew{'GE'}</td></tr>
159
	<tr><td>PR:</td><td>$crew{'PR-1'}</td><td>&nbsp;</td><td>PT:</td><td>$crew{'PT'}</td></tr>
160
	<tr><td>PR:</td><td>$crew{'PR-2'}</td><td>&nbsp;</td><td>PTA:</td><td>$crew{'PTA'}</td></tr>
161
	<tr><td>JR:</td><td>$crew{'JR-1'}</td><td>&nbsp;</td><td>PB:</td><td>$crew{'PB-1'}</td></tr>
162
	<tr><td>JR:</td><td>$crew{'JR-2'}</td><td>&nbsp;</td><td>PB:</td><td>$crew{'PB-2'}</td></tr>
163
	<tr><td>OPR:</td><td>$crew{$OPR1}</td><td>&nbsp;</td><td>EYE:</td><td>$crew{'EYE-1'}</td></tr>
164
	<tr><td>OPR:</td><td>$crew{'OPR-2'}</td><td>&nbsp;</td><td>EYE:</td><td>$crew{'EYE-2'}</td></tr>
165
	<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>WB:</td><td>$crew{'WB'}</td></tr>
166
	<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>SBO:</td><td>$crew{'SBO'}</td></tr>
167
</table><br><br><br><br><br><br><br><br><br><br><br><br>
168
BTgame
169
 
170
	} else {
171
	  print<<game;
172
<table>
173
	<tr><td>Date:</td><td>$day ($date)</td><td>&nbsp;</td><td>Track:</td><td>$g->{track}</td></tr>
174
	<tr><td>Time:</td><td>$g->{time}</td><td>&nbsp;</td><td>Class:</td><td>$class{$g->{restrictions}} $g->{level} $g->{gtype}</td></tr>
175
	<tr><td>Game:</td><td colspan=4>$g->{teams}</td></tr>
176
	<tr><td colspan=5>&nbsp;</td></tr>
8 - 177
	<tr><td>HR:</td><td>$crew{'HR'}</td><td>&nbsp;</td><td>$PH:</td><td>$crew{$P1}</td></tr>
178
	<tr><td>IPR:</td><td>$crew{'IPR'}</td><td>&nbsp;</td><td>PLT:</td><td>$crew{$P2}</td></tr>
179
	<tr><td>JR:</td><td>$crew{'JR-1'}</td><td>&nbsp;</td><td>SK:</td><td>$crew{'SK-1'}</td></tr>
180
	<tr><td>JR:</td><td>$crew{'JR-2'}</td><td>&nbsp;</td><td>SK:</td><td>$crew{'SK-2'}</td></tr>
181
	<tr><td>OPR:</td><td>$crew{$OPR1}</td><td>&nbsp;</td><td>PBM:</td><td>$crew{'PBM'}</td></tr>
182
	<tr><td>OPR:</td><td>$crew{'OPR-2'}</td><td>&nbsp;</td><td>PBT:</td><td>$crew{'PBT-1'}</td></tr>
183
	<tr><td>OPR:</td><td>$crew{'OPR-3'}</td><td>&nbsp;</td><td>PBT:</td><td>$crew{'PBT-2'}</td></tr>
184
	<tr><td>$A</td><td>$crew{'ALT'}</td><td>&nbsp;</td><td>JT:</td><td>$crew{'JT'}</td></tr>
142 - 185
	<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>SBO:</td><td>$crew{'SBO'}</td></tr>
8 - 186
</table><br><br><br><br><br><br><br><br><br><br><br><br>
187
game
142 - 188
  }
189
 
8 - 190
	$gcount++ % 2 == 0 ? print "<div class='pagebreak'><hr></div>\n" : { };
191
}
192
 
193
 
194
 
195
print<<tail;
196
</BODY>
197
</HTML>
198
tail