Subversion Repositories ORC

Rev

Rev 2 | Rev 25 | 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 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->now;
17
$dt->subtract( hours => 7 );
18
my $day = $dt->day_name;
19
my $date = $dt->date;
20
my $curtime = $dt->hms;
21
 
22
#$day = "Wednesday";
23
#$date = "2019-07-17";
24
 
25
my %class = qw(
26
	U Unrestricted
27
	M Mens
28
	W Womens
29
	SS Single-Gender
30
);
31
 
32
my $dbh = getDBConnection();
33
 
34
print CGI::header(-cookie=>$RCAUTH_cookie);
35
 
36
my $query = new CGI;
37
my $track = $query->param('t') || 'ALL';
38
 
39
 
40
print<<output;
41
<html><head><title>ORC Right Now - $day ($date) $curtime - Track $track</title>
42
<link rel="stylesheet" type="text/css" href="/rollercon.css">
43
</head>
44
<body text="#000000" bgcolor="#FFFFFF" link="#0000EE" vlink="#551A8B" alink="#FF0000">
45
output
46
 
47
my $rnh = $dbh->prepare("select * from v_shift_admin_view where id = (select id from game where date = ? and track = ? and time < now() - interval 3 hour and end_time > now() - interval 3 hour)");
48
my $nuh = $dbh->prepare("select * from v_shift_admin_view where id = (select id from game where date = ? and track = ? and time > now() - interval 3 hour order by time limit 1)");
49
 
50
my $lrnh = $dbh->prepare("select * from v_lead_shift where id in (select id from lead_shift where date = ? and start_time < now() - interval 3 hour and end_time > now() - interval 3 hour) order by track");
51
my $lnuh = $dbh->prepare("select * from v_lead_shift where id in (select id from lead_shift where date = ? and start_time > now() - interval 3 hour order by track, start_time)");
52
 
53
#my $gcount = 1; my $tcount = '';
54
#my $sth = $dbh->prepare("select distinct teams, track, level, time, gtype, restrictions from v_shift where date = ? order by track, time");
55
#my $crewhan = $dbh->prepare("select role, derby_name from v_shift where date = ? and track = ? and time = ?");
56
#my $leadhan = $dbh->prepare("select track, time, derby_name from v_lead_shift where date = ? order by track, time");
57
#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");
58
 
59
print "<table>\n<tr><td colspan=5><b>Right Now [$day $curtime Track $track]</b></td></tr></table><br>\n";
60
 
61
 
62
print "<table>\n<tr><td colspan=5><b>All Leads On Duty</b></td></tr>\n";
63
$lrnh->execute($date);
64
while (my $lshift = $lrnh->fetchrow_hashref()) {
65
	print "<tr><td>$lshift->{track}</td><td>&nbsp;</td><td>$lshift->{time}</td><td>&nbsp;</td><td>$lshift->{derby_name}</td></tr>\n";
66
}
67
print "</table>\n";
68
print "<br><br>\n";
69
 
70
my %crew;
71
my $g;
72
my $c = 1;
73
$rnh->execute($date, $track);
74
while (my $tg = $rnh->fetchrow_hashref()) {
75
	if ($c) {
76
		$g = $tg;
77
		$c=0;
78
	}
79
	if ($tg->{derby_name}) {
80
		$tg->{derby_name} .= " <A HREF='#' onClick=\"window.open('make_shift_change.pl?change=del&RCid=$tg->{RCid}&id=$tg->{id}&role=$tg->{role}','Confirm Shift Change','resizable,height=260,width=370'); return false;\">[DROP]</a>";
81
		$tg->{derby_name} .= " | <A HREF='#' onClick=\"if (confirm('Really? They were a no show?')==true) { window.open('make_shift_change.pl?noshow=true&change=del&RCid=$tg->{RCid}&id=$tg->{id}&role=$tg->{role}','Confirm Shift Change','resizable,height=260,width=370'); return false; }\">[NO SHOW]</a>";
82
	} else {
83
		$tg->{derby_name} = "<A HREF='#' onClick=\"window.open('make_shift_change.pl?change=lookup&RCid=$tg->RCid&id=$tg->{id}&role=$tg->{role}','Confirm Shift Change','resizable,height=260,width=370'); return false;\">[ADD USER]</a>";
84
	}
85
 
86
	$crew{$tg->{role}} = $tg->{derby_name};
87
}
88
 
89
$g->{gtype} = join '', map { ucfirst lc } split /(\s+)/, $g->{gtype}; # Capitalize the game type to look nicer
90
 
91
my $P1 = "PLT-1";
92
my $P2 = "PLT-2";
93
my $PH = "PLT";
94
if ($g->{gtype} eq "Full Length" or $g->{gtype} eq "Selected Staffing") {
95
	$P1 = 'PLT/H';
96
	$P2 = 'PLT';
97
	$PH = $P1;
98
}
99
my $A = '';
100
if (defined $crew{'ALT'}) {
101
	$A = "ALT:";
102
} else {
103
	$crew{'ALT'} = '';
104
}
105
 
106
if ($g->{teams}) {
107
	print<<game;
108
<table>
109
	<tr><td>Date:</td><td>$day ($date)</td><td>&nbsp;</td><td>Track:</td><td>$g->{track}</td></tr>
110
	<tr><td>Time:</td><td>$g->{time}</td><td>&nbsp;</td><td>Class:</td><td>$class{$g->{restrictions}} $g->{level} $g->{gtype}</td></tr>
111
	<tr><td>Game:</td><td colspan=4>$g->{teams}</td></tr>
112
	<tr><td colspan=5>&nbsp;</td></tr>
113
	<tr><td>HR:</td><td>$crew{'HR'}</td><td>&nbsp;</td><td>$PH:</td><td>$crew{$P1}</td></tr>
114
	<tr><td>IPR:</td><td>$crew{'IPR'}</td><td>&nbsp;</td><td>PLT:</td><td>$crew{$P2}</td></tr>
115
	<tr><td>JR:</td><td>$crew{'JR-1'}</td><td>&nbsp;</td><td>SK:</td><td>$crew{'SK-1'}</td></tr>
116
	<tr><td>JR:</td><td>$crew{'JR-2'}</td><td>&nbsp;</td><td>SK:</td><td>$crew{'SK-2'}</td></tr>
117
	<tr><td>OPR:</td><td>$crew{'OPR-1'}</td><td>&nbsp;</td><td>PBM:</td><td>$crew{'PBM'}</td></tr>
118
	<tr><td>OPR:</td><td>$crew{'OPR-2'}</td><td>&nbsp;</td><td>PBT:</td><td>$crew{'PBT-1'}</td></tr>
119
	<tr><td>OPR:</td><td>$crew{'OPR-3'}</td><td>&nbsp;</td><td>PBT:</td><td>$crew{'PBT-2'}</td></tr>
120
	<tr><td>$A</td><td>$crew{'ALT'}</td><td>&nbsp;</td><td>JT:</td><td>$crew{'JT'}</td></tr>
121
	<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>SO:</td><td>$crew{'SO'}</td></tr>
122
</table><br>
123
game
124
} else {
125
	print "<table>\n<tr><td colspan=5>There doesn't seem to be a game on this track right now.</td></tr></table><br>\n";
126
}
127
#	$gcount++ % 2 == 0 ? print "<div class='pagebreak'><hr></div>\n" : { };
128
 
129
 
130
print "<table>\n<tr><td colspan=5><b>Next Up...</b></td></tr></table>\n";
131
 
132
print "<table>\n<tr><td colspan=5><b>Leads On Duty Later</b></td></tr>\n";
133
$lnuh->execute($date);
134
while (my $lshift = $lnuh->fetchrow_hashref()) {
135
	print "<tr><td>$lshift->{track}</td><td>&nbsp;</td><td>$lshift->{time}</td><td>&nbsp;</td><td>$lshift->{derby_name}</td></tr>\n";
136
}
137
print "</table>\n";
138
print "<br><br>\n";
139
 
140
my %crew;
141
my $g;
142
my $c = 1;
143
$nuh->execute($date, $track);
144
while (my $tg = $nuh->fetchrow_hashref()) {
145
	if ($c) {
146
		$g = $tg;
147
		$c=0;
148
	}
149
	if ($tg->{derby_name}) {
150
		$tg->{derby_name} .= " <A HREF='#' onClick=\"window.open('make_shift_change.pl?change=del&RCid=$tg->{RCid}&id=$tg->{id}&role=$tg->{role}','Confirm Shift Change','resizable,height=260,width=370'); return false;\">[DROP]</a>";
151
		$tg->{derby_name} .= " | <A HREF='#' onClick=\"if (confirm('Really? They were a no show?')==true) { window.open('make_shift_change.pl?noshow=true&change=del&RCid=$tg->{RCid}&id=$tg->{id}&role=$tg->{role}','Confirm Shift Change','resizable,height=260,width=370'); return false; }\">[NO SHOW]</a>";
152
	} else {
153
		$tg->{derby_name} = "<A HREF='#' onClick=\"window.open('make_shift_change.pl?change=lookup&RCid=$tg->RCid&id=$tg->{id}&role=$tg->{role}','Confirm Shift Change','resizable,height=260,width=370'); return false;\">[ADD USER]</a>";
154
	}
155
 
156
	$crew{$tg->{role}} = $tg->{derby_name};
157
}
158
 
159
$g->{gtype} = join '', map { ucfirst lc } split /(\s+)/, $g->{gtype}; # Capitalize the game type to look nicer
160
 
161
my $P1 = "PLT-1";
162
my $P2 = "PLT-2";
163
my $PH = "PLT";
164
if ($g->{gtype} eq "Full Length" or $g->{gtype} eq "Selected Staffing") {
165
	$P1 = 'PLT/H';
166
	$P2 = 'PLT';
167
	$PH = $P1;
168
}
169
my $A = '';
170
if (defined $crew{'ALT'}) {
171
	$A = "ALT:";
172
} else {
173
	$crew{'ALT'} = '';
174
}
175
 
176
if ($g->{teams}) {
177
	print<<game;
178
<table>
179
	<tr><td>Date:</td><td>$day ($date)</td><td>&nbsp;</td><td>Track:</td><td>$g->{track}</td></tr>
180
	<tr><td>Time:</td><td>$g->{time}</td><td>&nbsp;</td><td>Class:</td><td>$class{$g->{restrictions}} $g->{level} $g->{gtype}</td></tr>
181
	<tr><td>Game:</td><td colspan=4>$g->{teams}</td></tr>
182
	<tr><td colspan=5>&nbsp;</td></tr>
183
	<tr><td>HR:</td><td>$crew{'HR'}</td><td>&nbsp;</td><td>$PH:</td><td>$crew{$P1}</td></tr>
184
	<tr><td>IPR:</td><td>$crew{'IPR'}</td><td>&nbsp;</td><td>PLT:</td><td>$crew{$P2}</td></tr>
185
	<tr><td>JR:</td><td>$crew{'JR-1'}</td><td>&nbsp;</td><td>SK:</td><td>$crew{'SK-1'}</td></tr>
186
	<tr><td>JR:</td><td>$crew{'JR-2'}</td><td>&nbsp;</td><td>SK:</td><td>$crew{'SK-2'}</td></tr>
187
	<tr><td>OPR:</td><td>$crew{'OPR-1'}</td><td>&nbsp;</td><td>PBM:</td><td>$crew{'PBM'}</td></tr>
188
	<tr><td>OPR:</td><td>$crew{'OPR-2'}</td><td>&nbsp;</td><td>PBT:</td><td>$crew{'PBT-1'}</td></tr>
189
	<tr><td>OPR:</td><td>$crew{'OPR-3'}</td><td>&nbsp;</td><td>PBT:</td><td>$crew{'PBT-2'}</td></tr>
190
	<tr><td>$A</td><td>$crew{'ALT'}</td><td>&nbsp;</td><td>JT:</td><td>$crew{'JT'}</td></tr>
191
	<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>SO:</td><td>$crew{'SO'}</td></tr>
192
</table><br>
193
game
194
} else {
195
	print "<table>\n<tr><td colspan=5>There don't seem to be any more games on this track today.</td></tr></table><br>\n";
196
}
197
 
198
	print "<table>\n<tr><td colspan=5><a href='/schedule/'>[ go home ]</td></tr></table><br>\n";
199
 
200
 
201
 
202
print<<tail;
203
</BODY>
204
</HTML>
205
tail