| 40 |
- |
1 |
#!/usr/bin/perl
|
|
|
2 |
|
| 56 |
bgadell |
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 |
|
| 40 |
- |
9 |
use strict;
|
|
|
10 |
use cPanelUserConfig;
|
|
|
11 |
use RollerCon;
|
|
|
12 |
use WebDB;
|
|
|
13 |
use tableViewer;
|
| 112 |
- |
14 |
use CGI qw/param header start_html url/;
|
| 40 |
- |
15 |
use CGI::Cookie;
|
|
|
16 |
use DateTime;
|
|
|
17 |
|
|
|
18 |
my $cookie_string = authenticate(2) || die;
|
|
|
19 |
my ($EML, $PWD, $LVL) = split /&/, $cookie_string;
|
|
|
20 |
my $user = getUser($EML);
|
|
|
21 |
my $RCAUTH_cookie = CGI::Cookie->new(-name=>'RCAUTH',-value=>"$cookie_string",-expires=>"+30m");
|
|
|
22 |
|
| 41 |
- |
23 |
my $date = param ("date");
|
|
|
24 |
my $dt;
|
|
|
25 |
if ($date =~ /^\d{4}-\d{2}-\d{2}$/) {
|
|
|
26 |
my ($YYYY, $MM, $DD) = split /-/, $date;
|
|
|
27 |
$dt = DateTime->new(
|
|
|
28 |
year => $YYYY,
|
|
|
29 |
month => $MM,
|
|
|
30 |
day => $DD
|
|
|
31 |
);
|
|
|
32 |
} else {
|
|
|
33 |
$dt = DateTime->today;
|
|
|
34 |
$date = $dt->date;
|
|
|
35 |
}
|
| 40 |
- |
36 |
my $day = $dt->day_name;
|
|
|
37 |
|
|
|
38 |
## Uncomment and update to test:
|
| 41 |
- |
39 |
#$day = "Wednesday";
|
| 50 |
bgadell |
40 |
#$date = "2023-07-13";
|
| 40 |
- |
41 |
|
|
|
42 |
my $dbh = WebDB::connect ();
|
|
|
43 |
|
|
|
44 |
print CGI::header(-cookie=>$RCAUTH_cookie);
|
|
|
45 |
|
|
|
46 |
print<<output;
|
|
|
47 |
<html><head><title>RollerCon VORC - MVP Class Sign-Ups - $day ($date)</title>
|
| 41 |
- |
48 |
<link rel="stylesheet" type="text/css" href="/style.css">
|
| 40 |
- |
49 |
</head>
|
|
|
50 |
<body text="#000000" bgcolor="#FFFFFF" link="#0000EE" vlink="#551A8B" alink="#FF0000">
|
|
|
51 |
output
|
|
|
52 |
|
|
|
53 |
my $gcount = 1; my $tcount = '';
|
| 112 |
- |
54 |
my $sth = $dbh->prepare("select distinct name, coach, note, location, time from v_class where date = ? order by location, time");
|
|
|
55 |
my $crewhan = $dbh->prepare("select derby_name, real_name from v_class_signup left join official on v_class_signup.RCid = official.RCid where date = ? and location = ? and time = ? order by derby_name");
|
| 40 |
- |
56 |
|
|
|
57 |
|
| 112 |
- |
58 |
$sth->execute($date);
|
| 40 |
- |
59 |
while (my $g = $sth->fetchrow_hashref()) {
|
|
|
60 |
if ($tcount ne $g->{location}) { #pagebreak whenever we change tracks
|
| 41 |
- |
61 |
print "<div class='pagebreak'></div>\n" unless (!$tcount or $gcount++ % 2);
|
|
|
62 |
# print "<div class='pagebreak'><hr></div>\n";
|
| 40 |
- |
63 |
$gcount = 1;
|
|
|
64 |
$tcount = $g->{location};
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
print<<game;
|
|
|
68 |
<table>
|
| 112 |
- |
69 |
<tr><td colspan=5 class="mvp bold">Class: ($g->{location}) $g->{name}</td></tr>
|
| 41 |
- |
70 |
<tr><td colspan=3 class="mvp">Date: $day ($date)</td><td colspan=2 class='mvp right'>Time: $g->{time}</td></tr>
|
| 112 |
- |
71 |
<tr><td colspan=5 class="mvp">Coach: $g->{coach}</td></tr>
|
|
|
72 |
<tr><td colspan=5 class="mvp">Note: $g->{note}</td></tr>
|
| 41 |
- |
73 |
<tr><td colspan=5 class="mvp"> </td></tr>
|
| 40 |
- |
74 |
game
|
| 41 |
- |
75 |
|
| 40 |
- |
76 |
my $counter = 1;
|
| 112 |
- |
77 |
$crewhan->execute($date, $g->{location}, $g->{time});
|
| 41 |
- |
78 |
while (my ($derby_name, $real_name) = $crewhan->fetchrow_array()) {
|
|
|
79 |
print "<tr><td class='mvp right'>".$counter++."</td><td> </td><td class='mvp'>".$derby_name."</td><td> </td><td class='mvp'>".$real_name."</td></tr>";
|
|
|
80 |
}
|
|
|
81 |
for ($counter..20) {
|
|
|
82 |
print "<tr><td class='mvp right'>".$_."</td><td colspan=4> </td></tr>";
|
|
|
83 |
}
|
|
|
84 |
|
|
|
85 |
print "</table><br><br>";
|
| 40 |
- |
86 |
|
| 41 |
- |
87 |
$gcount++ % 2 == 0 ? print "<div class='pagebreak'></div>\n" : { };
|
| 40 |
- |
88 |
}
|
|
|
89 |
|
|
|
90 |
|
|
|
91 |
|
|
|
92 |
print<<tail;
|
|
|
93 |
</BODY>
|
|
|
94 |
</HTML>
|
|
|
95 |
tail
|