| 180 |
- |
1 |
#!/usr/bin/perl
|
|
|
2 |
|
|
|
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 |
|
|
|
9 |
#if ($ENV{SHELL}) { die "This script shouldn't be executed from the command line!\n"; }
|
|
|
10 |
|
|
|
11 |
#use strict;
|
|
|
12 |
use cPanelUserConfig;
|
|
|
13 |
use CGI qw/param cookie header start_html url/;
|
|
|
14 |
use HTML::Tiny;
|
|
|
15 |
use tableViewer;
|
| 181 |
- |
16 |
use WebDB;
|
| 180 |
- |
17 |
use RollerCon;
|
|
|
18 |
our $h = HTML::Tiny->new( mode => 'html' );
|
|
|
19 |
use DateTime;
|
|
|
20 |
use DateTime::Duration;
|
|
|
21 |
my $now = DateTime->now (time_zone => 'America/Los_Angeles');
|
|
|
22 |
|
|
|
23 |
|
|
|
24 |
my $cookie_string = authenticate (1) || die;
|
|
|
25 |
# Add checking to make sure they're in this department
|
|
|
26 |
our ($EML, $PWD, $LVL) = split /&/, $cookie_string;
|
|
|
27 |
my $user = getUser ($EML);
|
|
|
28 |
$user->{department} = convertDepartments $user->{department};
|
|
|
29 |
|
|
|
30 |
if ($user->{department}->{"OFF"} < 1 and $LVL < 4) {
|
|
|
31 |
print header(-cookie=>$RCAUTH_cookie);
|
|
|
32 |
printRCHeader("Unauthorized Page");
|
|
|
33 |
print $h->div ({ class=>"error" }, "You're not an Official");
|
| 181 |
- |
34 |
print $h->div ("Your user account is not registered as an Official, so you can't see this page. It's possible that your access is still being reviewed. Please be patient.");
|
| 180 |
- |
35 |
print $h->a ({ href=>"/schedule/" }, "[Go Home]");
|
|
|
36 |
print $h->close ("html");
|
|
|
37 |
exit;
|
|
|
38 |
}
|
|
|
39 |
|
|
|
40 |
my $username = $h->a ({ href=>"/schedule/view_user.pl?submit=View&RCid=$user->{RCid}" }, $user->{derby_name});
|
|
|
41 |
my $RCid = $user->{RCid};
|
|
|
42 |
my $RCAUTH_cookie = CGI::Cookie->new(-name=>'RCAUTH',-value=>"$cookie_string",-expires=>"+30m");
|
|
|
43 |
#my $YEAR = 1900 + (localtime)[5]; #which year of data to display, default to current
|
|
|
44 |
my $YEAR = 1900 + (localtime)[5];
|
|
|
45 |
|
|
|
46 |
#$LVL = 1;
|
|
|
47 |
|
| 181 |
- |
48 |
my $dbh = WebDB::connect ();
|
| 180 |
- |
49 |
|
| 182 |
- |
50 |
my $games = $dbh->prepare ("select * from v_shift_officiating where year(date) = ? and now() > date and RCid = ? and gtype in ('challenge', 'selected staffing', 'full length') order by date desc, time desc");
|
| 181 |
- |
51 |
my $teams = $dbh->prepare ("select team1, team2 from game where id = ?");
|
|
|
52 |
my $headofficial = $dbh->prepare ("select derby_name from v_shift_officiating where id = ? and tla = ?");
|
| 180 |
- |
53 |
|
| 181 |
- |
54 |
my $date = `date +"%m%d%y%H%M%S"`; chomp $date;
|
|
|
55 |
my $filename = "RollerCon_${YEAR}_OHD_$user->{derby_name}_${date}_$$.csv";
|
|
|
56 |
|
|
|
57 |
print "Content-type: text/CSV\n";
|
|
|
58 |
# The Content-Disposition will generate a prompt to save the file. If you want
|
|
|
59 |
# to stream the file to the browser, comment out the following line.
|
|
|
60 |
print "Content-Disposition: attachment; filename=$filename\n";
|
|
|
61 |
print "\n";
|
| 180 |
- |
62 |
|
| 181 |
- |
63 |
print "Date,Event Name,Event Location,Event Host,Home / High Seed,Visitor / Low Seed,Association,Game Type,Position,2nd Position,Software,Head Referee,Head NSO,Notes\n";
|
| 180 |
- |
64 |
|
| 181 |
- |
65 |
$games->execute ($YEAR, $user->{RCid});
|
|
|
66 |
while (my $game = $games->fetchrow_hashref ()) {
|
|
|
67 |
$teams->execute ($game->{id});
|
|
|
68 |
my ($team1, $team2) = $teams->fetchrow_array ();
|
| 180 |
- |
69 |
|
| 181 |
- |
70 |
$headofficial->execute ($game->{id}, "HR");
|
|
|
71 |
my ($HR) = $headofficial->fetchrow_array ();
|
|
|
72 |
|
|
|
73 |
$headofficial->execute ($game->{id}, "PLT/HNSO");
|
|
|
74 |
my ($HNSO) = $headofficial->fetchrow_array ();
|
|
|
75 |
|
|
|
76 |
if ($game->{tla} eq "PLT/HNSO") {
|
|
|
77 |
$game->{tla} = "HNSO";
|
|
|
78 |
$game->{tla2} = "PLT";
|
|
|
79 |
} elsif ($game->{tla} eq "HR") {
|
|
|
80 |
$game->{tla2} = "IPR";
|
| 180 |
- |
81 |
} else {
|
| 181 |
- |
82 |
$game->{tla2} = "";
|
| 180 |
- |
83 |
}
|
|
|
84 |
|
| 181 |
- |
85 |
my @line;
|
|
|
86 |
push @line, $game->{date};
|
|
|
87 |
push @line, 'RollerCon '.$YEAR;
|
|
|
88 |
push @line, '"The Expo at World Market Center, Las Vegas, NV"';
|
|
|
89 |
push @line, 'RollerCon';
|
|
|
90 |
push @line, $team1;
|
|
|
91 |
push @line, $team2;
|
|
|
92 |
push @line, "Other";
|
|
|
93 |
push @line, $game->{gtype} eq "challenge" ? "Other" : "Reg";
|
|
|
94 |
push @line, $game->{tla};
|
|
|
95 |
push @line, $game->{tla2};
|
|
|
96 |
push @line, $game->{tla} eq "SBO" ? "C" : "";
|
|
|
97 |
push @line, $HR;
|
|
|
98 |
push @line, $HNSO;
|
| 182 |
- |
99 |
push @line, $game->{gtype} eq "challenge" ? "30 minute game without a halftime" : "";
|
| 181 |
- |
100 |
|
|
|
101 |
print join ",", @line;
|
|
|
102 |
print "\n";
|
| 180 |
- |
103 |
}
|
|
|
104 |
|
| 181 |
- |
105 |
exit;
|