Subversion Repositories ORC

Rev

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

Rev Author Line No. Line
8 - 1
#!/usr/bin/perl
2
 
3
use strict;
4
use cPanelUserConfig;
5
use RollerCon;
38 - 6
use WebDB;
7
use tableViewer;
8 - 8
use CGI;
9
use CGI::Cookie;
10
use DateTime;
11
 
12
my $cookie_string = authenticate(2) || die;
13
my ($EML, $PWD, $LVL) = split /&/, $cookie_string;
14
my $user = getUser($EML);
15
my $RCAUTH_cookie = CGI::Cookie->new(-name=>'RCAUTH',-value=>"$cookie_string",-expires=>"+30m");
16
 
44 - 17
my $date = param ("date");
18
my $dt;
19
if ($date =~ /^\d{4}-\d{2}-\d{2}$/) {
20
  my ($YYYY, $MM, $DD) = split /-/, $date;
21
  $dt = DateTime->new(
22
    year  => $YYYY,
23
    month => $MM,
24
    day   => $DD
25
  );
26
} else {
27
  $dt = DateTime->today;
28
  $date = $dt->date;
29
}
8 - 30
my $day = $dt->day_name;
31
 
32
my %class = qw(
33
	U Unrestricted
34
	M Mens
35
	W Womens
36
	SS Single-Gender
37
);
38
 
38 - 39
my $dbh = WebDB::connect ();
8 - 40
 
41
print CGI::header(-cookie=>$RCAUTH_cookie);
42
 
43
 
44
 
45
 
46
print<<output;
38 - 47
<html><head><title>RollerCon VORC - Daily Officiating Schedule - $day ($date)</title>
8 - 48
<link rel="stylesheet" type="text/css" href="/rollercon.css">
49
</head>
50
<body text="#000000" bgcolor="#FFFFFF" link="#0000EE" vlink="#551A8B" alink="#FF0000">
51
output
52
 
53
my $gcount = 1; my $tcount = '';
38 - 54
my $sth = $dbh->prepare("select distinct teams, track, level, time, gtype, restrictions from v_shift_officiating where date = ? order by track, time");
55
my $crewhan = $dbh->prepare("select role, derby_name from v_shift_officiating where date = ? and track = ? and time = ?");
56
my $leadhan = $dbh->prepare("select location, time, derby_name from v_shift where dept = 'OFF' and date = ? order by location, time");
57
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 - 58
 
59
my @leads = ("<table>\n", "<tr><td colspan=5><b>Lead Shifts</b></td></tr>\n");
60
$leadhan->execute($date);
61
my $tc = 'C1';
62
while (my $lshift = $leadhan->fetchrow_hashref()) {
38 - 63
	if ($tc ne $lshift->{location}) {
8 - 64
		push @leads, "<tr><td colspan=5>&nbsp;</td></tr>\n";
38 - 65
		$tc = $lshift->{location};
8 - 66
	}
38 - 67
	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 - 68
}
69
push @leads, "</table>\n";
70
 
71
$sth->execute($date);
72
while (my $g = $sth->fetchrow_hashref()) {
73
	if ($tcount ne $g->{track}) { #pagebreak whenever we change tracks
74
		print "<div class='pagebreak'><hr></div>\n" unless !$tcount;
75
		print @leads;
76
 
77
		my @openshifts = ("<table>\n", "<tr><td colspan=5><b>Open Shifts on $g->{track}</b></td></tr>\n");
78
		$openshifthan->execute($date, $g->{track});
79
		while (my @oshift = $openshifthan->fetchrow_array()) {
80
			my $sh = join "</td><td>&nbsp;</td><td>", @oshift;
81
			push @openshifts, "<tr><td>$sh</td></tr>\n";
82
		}
83
		push @openshifts, "</table>\n";
84
		print "<br><br><br><br>";
85
		print @openshifts;
86
 
87
		print "<div class='pagebreak'><hr></div>\n";
88
		$gcount = 1;
89
		$tcount = $g->{track};
90
	}
91
 
92
	$g->{gtype} = join '', map { ucfirst lc } split /(\s+)/, $g->{gtype}; # Capitalize the game time to look nicer
93
 
94
	my %crew;
95
	$crewhan->execute($date, $g->{track}, $g->{time});
96
	while (my ($k, $v) = $crewhan->fetchrow_array()) {
97
		$crew{$k} = $v;
98
	}
99
	my $P1 = "PLT-1";
100
	my $P2 = "PLT-2";
101
	my $PH = "PLT";
102
	my $OPR1 = "OPR-1";
103
	if ($g->{gtype} eq "Full Length" or $g->{gtype} eq "Selected Staffing") {
104
		$P1 = 'PLT/H';
105
		$P2 = 'PLT';
106
		$PH = $P1;
107
	} elsif ($g->{gtype} eq "Challenge-rs1") {
108
		$crew{'OPR-1'} = "<i>-not staffed-</i>";
109
		$crew{'OPR-2'} = "<i>-not staffed-</i>";
110
		$crew{'OPR-3'} = "<i>-not staffed-</i>";
111
		$crew{'PLT-1'} = "<i>-not staffed-</i>";
112
		$crew{'PLT-2'} = "<i>-not staffed-</i>";
113
		$crew{'SK-1'} = "<i>-not staffed-</i>";
114
		$crew{'SK-2'} = "<i>-not staffed-</i>";
115
		$crew{'PBM'} = "<i>-not staffed-</i>";
116
	} elsif ($g->{gtype} eq "Challenge-rs2") {
117
		$OPR1 = "OPR";
118
 
119
		$crew{'IPR'} = "<i>-not staffed-</i>";
120
		$crew{'OPR-2'} = "<i>-not staffed-</i>";
121
		$crew{'OPR-3'} = "<i>-not staffed-</i>";
122
		$crew{'PLT-1'} = "<i>-not staffed-</i>";
123
		$crew{'PLT-2'} = "<i>-not staffed-</i>";
124
		$crew{'SK-1'} = "<i>-not staffed-</i>";
125
		$crew{'SK-2'} = "<i>-not staffed-</i>";
126
		$crew{'PBM'} = "<i>-not staffed-</i>";
38 - 127
	} elsif ($g->{gtype} eq "Scrimmage") {
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>";
133
		$crew{'PBT-1'} = "<i>-not staffed-</i>";
134
		$crew{'PBT-2'} = "<i>-not staffed-</i>";
135
		$crew{'SO'} = "<i>-not staffed-</i>";
8 - 136
	}
137
 
138
	my $A = '';
139
	if (defined $crew{'ALT'}) {
140
		$A = "ALT:";
141
	} else {
142
		$crew{'ALT'} = '';
143
	}
144
 
145
	print<<game;
146
<table>
147
	<tr><td>Date:</td><td>$day ($date)</td><td>&nbsp;</td><td>Track:</td><td>$g->{track}</td></tr>
148
	<tr><td>Time:</td><td>$g->{time}</td><td>&nbsp;</td><td>Class:</td><td>$class{$g->{restrictions}} $g->{level} $g->{gtype}</td></tr>
149
	<tr><td>Game:</td><td colspan=4>$g->{teams}</td></tr>
150
	<tr><td colspan=5>&nbsp;</td></tr>
151
	<tr><td>HR:</td><td>$crew{'HR'}</td><td>&nbsp;</td><td>$PH:</td><td>$crew{$P1}</td></tr>
152
	<tr><td>IPR:</td><td>$crew{'IPR'}</td><td>&nbsp;</td><td>PLT:</td><td>$crew{$P2}</td></tr>
153
	<tr><td>JR:</td><td>$crew{'JR-1'}</td><td>&nbsp;</td><td>SK:</td><td>$crew{'SK-1'}</td></tr>
154
	<tr><td>JR:</td><td>$crew{'JR-2'}</td><td>&nbsp;</td><td>SK:</td><td>$crew{'SK-2'}</td></tr>
155
	<tr><td>OPR:</td><td>$crew{$OPR1}</td><td>&nbsp;</td><td>PBM:</td><td>$crew{'PBM'}</td></tr>
156
	<tr><td>OPR:</td><td>$crew{'OPR-2'}</td><td>&nbsp;</td><td>PBT:</td><td>$crew{'PBT-1'}</td></tr>
157
	<tr><td>OPR:</td><td>$crew{'OPR-3'}</td><td>&nbsp;</td><td>PBT:</td><td>$crew{'PBT-2'}</td></tr>
158
	<tr><td>$A</td><td>$crew{'ALT'}</td><td>&nbsp;</td><td>JT:</td><td>$crew{'JT'}</td></tr>
159
	<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>SO:</td><td>$crew{'SO'}</td></tr>
160
</table><br><br><br><br><br><br><br><br><br><br><br><br>
161
game
162
 
163
	$gcount++ % 2 == 0 ? print "<div class='pagebreak'><hr></div>\n" : { };
164
}
165
 
166
 
167
 
168
print<<tail;
169
</BODY>
170
</HTML>
171
tail