| 250 |
- |
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;
|
|
|
16 |
use RollerCon;
|
|
|
17 |
our $h = HTML::Tiny->new( mode => 'html' );
|
|
|
18 |
|
|
|
19 |
my $cookie_string = authenticate (3) || die;
|
|
|
20 |
our ($EML, $PWD, $LVL) = split /&/, $cookie_string;
|
|
|
21 |
my $RCAUTH_cookie = CGI::Cookie->new(-name=>'RCAUTH',-value=>"$cookie_string",-expires=>"+30m");
|
|
|
22 |
|
|
|
23 |
my $pageTitle = "Open Shift Report";
|
|
|
24 |
our $DBTABLE = 'v_shift_report_pct';
|
|
|
25 |
my %COLUMNS = (
|
|
|
26 |
# colname => [qw(DisplayName N type status)], status -> static | default | <blank>
|
|
|
27 |
dept => [qw(Dept 5 select default )],
|
|
|
28 |
name => [qw(DeptName 10 text default )],
|
|
|
29 |
open => [qw(Open 15 number default )],
|
|
|
30 |
filled => [qw(Filled 20 number default )],
|
|
|
31 |
total => [qw(Total 25 number default )],
|
|
|
32 |
percent => [qw(PctFilled 30 number default )],
|
|
|
33 |
);
|
|
|
34 |
|
|
|
35 |
# Set any custom "where" DB filters here...
|
|
|
36 |
my @whereClause;
|
|
|
37 |
|
|
|
38 |
# If we need to modify line item values, create a subroutine named "modify_$columnname"
|
|
|
39 |
# It will receive a hashref to the object lineitem
|
|
|
40 |
|
|
|
41 |
sub modify_percent {
|
|
|
42 |
my $line = shift;
|
|
|
43 |
return $line->{percent}." %";
|
|
|
44 |
}
|
|
|
45 |
|
|
|
46 |
# If we need to modify how a filter works, create a subroutine named "filter_$columnname"
|
|
|
47 |
# It will receive two fields, the field name and the current filter value (if any)
|
|
|
48 |
|
|
|
49 |
# Uncomment and update if we want to enable clicking on a row to open a new page.
|
|
|
50 |
#
|
|
|
51 |
sub addRowClick {
|
|
|
52 |
my $t = shift;
|
|
|
53 |
# return "location.href='view_thing.pl?field=$t->{field}&choice=View'";
|
|
|
54 |
if ($t->{name} =~ /^Officiating - /) {
|
|
|
55 |
my ($g, $type) = split / - /, $t->{name};
|
|
|
56 |
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'";
|
|
|
57 |
} elsif ($t->{name} eq "Announcers - Game") {
|
|
|
58 |
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'";
|
|
|
59 |
} else {
|
|
|
60 |
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'";
|
|
|
61 |
}
|
|
|
62 |
}
|
|
|
63 |
|
|
|
64 |
# Call the function to print the table view page (with available options)
|
|
|
65 |
printTablePage ({ Title => $pageTitle,
|
|
|
66 |
# Prefs => $prefscookie,
|
|
|
67 |
Table => $DBTABLE,
|
|
|
68 |
Columns => \%COLUMNS,
|
|
|
69 |
RCAuth => $RCAUTH_cookie,
|
|
|
70 |
Where => join (" and ", @whereClause),
|
|
|
71 |
DisplayYearSelect => 0,
|
|
|
72 |
ShowMyShifts => 0,
|
|
|
73 |
PersonalTimeButton => 0,
|
|
|
74 |
HighlightShifts => 0,
|
|
|
75 |
# HeaderButton => { field => "id",
|
|
|
76 |
# button => $h->input ({ type=>"button", value=>"Add", onClick=>"window.location.href='view_game.pl'" }) }
|
|
|
77 |
});
|
|
|
78 |
|