Subversion Repositories ORC

Rev

Rev 8 | Go to most recent revision | Details | Last modification | View Log | RSS feed

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