Subversion Repositories VORC

Rev

Blame | 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";

#if ($ENV{SHELL}) { die "This script shouldn't be executed from the command line!\n"; }

use strict;
use cPanelUserConfig;
use CGI qw/param cookie header start_html url/;
use HTML::Tiny;
use tableViewer;
use RollerCon;
our $h = HTML::Tiny->new( mode => 'html' );

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

my $pageTitle = "Open Shift Report";
our $DBTABLE = 'v_shift_report_pct';
my %COLUMNS = (
# colname   =>  [qw(DisplayName       N    type     status)],   status ->  static | default | <blank>
  dept     => [qw(Dept        5    select      default )],
  name     => [qw(DeptName   10    text        default )],
  open     => [qw(Open       15    number      default )],
  filled   => [qw(Filled     20    number      default )],
  total    => [qw(Total      25    number      default )],
  percent  => [qw(PctFilled  30    number      default )],
);

# Set any custom "where" DB filters here...
my @whereClause;

# If we need to modify line item values, create a subroutine named "modify_$columnname"
#    It will receive a hashref to the object lineitem

sub modify_percent {
  my $line = shift;
  return $line->{percent}." %";
}

# If we need to modify how a filter works, create a subroutine named "filter_$columnname"
#    It will receive two fields, the field name and the current filter value (if any)

# Uncomment and update if we want to enable clicking on a row to open a new page.
#
sub addRowClick {
  my $t = shift;
#  return "location.href='view_thing.pl?field=$t->{field}&choice=View'";
  if ($t->{name} =~ /^Officiating - /) {
    my ($g, $type) = split / - /, $t->{name};
    return "location.href='officiating_shifts.pl?excel=0&autoload=1&date=true&dayofweek=true&time=true&teams=true&level=true&restrictions=true&name=true&type=true&derby_name=true&filter-date=&filter-dayofweek=&filter-time=&filter-teams=&filter-level=&filter-restrictions=&filter-name=&filter-type=$type&filter-derby_name=&year=2026&sortby=date&limit=25&page=1'";
  } elsif ($t->{name} eq "Announcers - Game") {
    return "location.href='announcer_shifts.pl?excel=0&autoload=1&date=true&dayofweek=true&time=true&teams=true&level=true&restrictions=true&name=true&type=true&derby_name=true&filter-date=&filter-dayofweek=&filter-time=&filter-teams=&filter-level=&filter-restrictions=&filter-name=&filter-type=&filter-derby_name=&year=2026&sortby=date&limit=25&page=1'";
  } else {
    return "location.href='shifts.pl?excel=0&autoload=1&dept=true&date=true&time=true&role=true&type=true&location=true&derby_name=true&filter-dept=$t->{dept}&filter-date=&filter-time=&filter-role=&filter-type=&filter-location=&filter-derby_name=&year=2026&sortby=date&limit=25&page=1'";
  }
}

# Call the function to print the table view page (with available options)
printTablePage ({ Title   => $pageTitle,
#                  Prefs   => $prefscookie,
                  Table   => $DBTABLE,
                  Columns => \%COLUMNS,
                  RCAuth  => $RCAUTH_cookie,
                  Where   => join (" and ", @whereClause),
                  DisplayYearSelect  => 0,
                  ShowMyShifts       => 0,
                  PersonalTimeButton => 0,
                  HighlightShifts    => 0,
#                  HeaderButton       => { field  => "id",
#                                          button => $h->input ({ type=>"button", value=>"Add", onClick=>"window.location.href='view_game.pl'" }) }
               });