Subversion Repositories VORC

Rev

Rev 56 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

#!/usr/bin/perl

# Redirect error messages to a log of my choosing. (it's annoying to filter for errors in the shared env)
my $error_log_path = $ENV{SERVER_NAME} eq "volunteers.rollercon.com" ? "/home3/rollerco/logs/" : "/tmp/";
close STDERR;
open STDERR, '>>', $error_log_path.'vorc_error.log' or warn "Failed to open redirected logfile ($0): $!";
#warn "Redirecting errors to ${error_log_path}vorc_error.log";

use strict;
use cPanelUserConfig;
use RollerCon;
use WebDB;
use tableViewer;
use CGI qw/param header start_html url/;
use CGI::Cookie;
use DateTime;

my $cookie_string = authenticate(2) || die;
my ($EML, $PWD, $LVL) = split /&/, $cookie_string;
my $user = getUser($EML);
my $RCAUTH_cookie = CGI::Cookie->new(-name=>'RCAUTH',-value=>"$cookie_string",-expires=>"+30m");

my $date = param ("date");
my $dt;
if ($date =~ /^\d{4}-\d{2}-\d{2}$/) {
  my ($YYYY, $MM, $DD) = split /-/, $date;
  $dt = DateTime->new(
    year  => $YYYY,
    month => $MM,
    day   => $DD
  );
} else {
  $dt = DateTime->today;
  $date = $dt->date;
}
my $day = $dt->day_name;

## Uncomment and update to test:
#$day = "Wednesday";
#$date = "2023-07-13";

my $dbh = WebDB::connect ();

print CGI::header(-cookie=>$RCAUTH_cookie);

print<<output;
<html><head><title>RollerCon VORC - MVP Class Sign-Ups - $day ($date)</title>
<link rel="stylesheet" type="text/css" href="/style.css">
</head>
<body text="#000000" bgcolor="#FFFFFF" link="#0000EE" vlink="#551A8B" alink="#FF0000">
output

my $gcount = 1; my $tcount = '';
my $sth = $dbh->prepare("select distinct name, coach, note, location, time from v_class where date = ? order by location, time");
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");


$sth->execute($date);
while (my $g = $sth->fetchrow_hashref()) {
        if ($tcount ne $g->{location}) { #pagebreak whenever we change tracks
                print "<div class='pagebreak'></div>\n" unless (!$tcount or $gcount++ % 2);
#               print "<div class='pagebreak'><hr></div>\n";
                $gcount = 1;
                $tcount = $g->{location};
        }
        
        print<<game;
<table>
  <tr><td colspan=5 class="mvp bold">Class: ($g->{location}) $g->{name}</td></tr>
        <tr><td colspan=3 class="mvp">Date: $day ($date)</td><td colspan=2 class='mvp right'>Time: $g->{time}</td></tr>
        <tr><td colspan=5 class="mvp">Coach: $g->{coach}</td></tr>
        <tr><td colspan=5 class="mvp">Note: $g->{note}</td></tr>
        <tr><td colspan=5 class="mvp">&nbsp;</td></tr>
game

  my $counter = 1;
        $crewhan->execute($date, $g->{location}, $g->{time});
        while (my ($derby_name, $real_name) = $crewhan->fetchrow_array()) {
    print "<tr><td class='mvp right'>".$counter++."</td><td>&nbsp;</td><td class='mvp'>".$derby_name."</td><td>&nbsp;</td><td class='mvp'>".$real_name."</td></tr>";
        }
        for ($counter..20) {
          print "<tr><td class='mvp right'>".$_."</td><td colspan=4>&nbsp;</td></tr>";
        }
                
  print "</table><br><br>";

        $gcount++ % 2 == 0 ? print "<div class='pagebreak'></div>\n" : { };
}



print<<tail;
</BODY>
</HTML>
tail