Subversion Repositories ORC

Rev

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