| Line 6... |
Line 6... |
| 6 |
open STDERR, '>>', $error_log_path.'vorc_error.log' or warn "Failed to open redirected logfile ($0): $!";
|
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";
|
7 |
#warn "Redirecting errors to ${error_log_path}vorc_error.log";
|
| Line 8... |
Line 8... |
| 8 |
|
8 |
|
| Line 9... |
Line 9... |
| 9 |
#if ($ENV{SHELL}) { die "This script shouldn't be executed from the command line!\n"; }
|
9 |
#if ($ENV{SHELL}) { die "This script shouldn't be executed from the command line!\n"; }
|
| 10 |
|
10 |
|
| 11 |
#use strict;
|
11 |
use strict;
|
| 12 |
use cPanelUserConfig;
|
12 |
use cPanelUserConfig;
|
| 13 |
use CGI qw/param cookie header start_html url/;
|
13 |
use CGI qw/param cookie header start_html url/;
|
| 14 |
use HTML::Tiny;
|
14 |
use HTML::Tiny;
|
| 15 |
use tableViewer;
|
15 |
use tableViewer;
|
| 16 |
use RollerCon;
|
16 |
use RollerCon;
|
| 17 |
our $h = HTML::Tiny->new( mode => 'html' );
|
17 |
our $h = HTML::Tiny->new( mode => 'html' );
|
| 18 |
use DateTime;
|
18 |
use DateTime;
|
| Line 19... |
Line -... |
| 19 |
use DateTime::Duration;
|
- |
|
| 20 |
my $now = DateTime->now (time_zone => 'America/Los_Angeles');
|
19 |
use DateTime::Duration;
|
| 21 |
|
- |
|
| 22 |
|
20 |
my $now = DateTime->now (time_zone => 'America/Los_Angeles');
|
| 23 |
my $cookie_string = authenticate (1) || die;
|
- |
|
| 24 |
# Add checking to make sure they're in this department
|
21 |
|
| Line -... |
Line 22... |
| - |
|
22 |
my $cookie_string = authenticate (1) || die;
|
| 25 |
our ($EML, $PWD, $LVL) = split /&/, $cookie_string;
|
23 |
our ($EML, $PWD, $LVL) = split /&/, $cookie_string;
|
| 26 |
my $user = getUser ($EML);
|
24 |
my $RCAUTH_cookie = CGI::Cookie->new (-name=>'RCAUTH', -value=>"$cookie_string", -expires=>"+30m");
|
| 27 |
$user->{department} = convertDepartments $user->{department};
|
25 |
|
| 28 |
|
26 |
# Add checking to make sure they're in this department
|
| 29 |
if ($user->{department}->{"OFF"} < 1 and $LVL < 4) {
|
27 |
if ($ORCUSER->{department}->{"OFF"} < 1 and $LVL < 4 and $ORCUSER->{department}->{"VCI"} < 2) {
|
| 30 |
print header(-cookie=>$RCAUTH_cookie);
|
28 |
print header (-cookie=>$RCAUTH_cookie);
|
| 31 |
printRCHeader("Unauthorized Page");
|
29 |
printRCHeader ("Unauthorized Page");
|
| 32 |
print $h->div ({ class=>"error" }, "You're not an Official");
|
30 |
print $h->div ({ class=>"error" }, "You're not an Official");
|
| 33 |
print $h->div ("Your user account is not registered as an Official, so you can't see these shifts. It's possible that your access is still being reviewed. Please be patient.");
|
31 |
print $h->div ("Your user account is not registered as an Official, so you can't see these shifts. It's possible that your access is still being reviewed. Please be patient.");
|
| Line 34... |
Line -... |
| 34 |
print $h->a ({ href=>"/schedule/" }, "[Go Home]");
|
- |
|
| 35 |
print $h->close ("html");
|
- |
|
| 36 |
exit;
|
- |
|
| 37 |
}
|
- |
|
| 38 |
|
- |
|
| 39 |
my $username = $h->a ({ href=>"/schedule/view_user.pl?submit=View&RCid=$user->{RCid}" }, $user->{derby_name});
|
- |
|
| 40 |
my $RCid = $user->{RCid};
|
- |
|
| 41 |
my $RCAUTH_cookie = CGI::Cookie->new(-name=>'RCAUTH',-value=>"$cookie_string",-expires=>"+30m");
|
- |
|
| 42 |
#my $YEAR = 1900 + (localtime)[5]; #which year of data to display, default to current
|
32 |
print $h->button ({ onClick=>"window.location.href='/schedule/';" }, "Home");
|
| 43 |
my $YEAR = 1900 + (localtime)[5];
|
- |
|
| 44 |
|
33 |
print $h->close ("html");
|
| 45 |
#$LVL = 1;
|
34 |
exit;
|
| 46 |
|
35 |
}
|
| 47 |
my $pageTitle = "Officiating Shifts";
|
36 |
|
| 48 |
my $prefscookie = "oshiftscookie";
|
37 |
my $pageTitle = "Officiating Shifts";
|
| 49 |
our $DBTABLE = 'v_shift_officiating';
|
38 |
our $DBTABLE = 'v_shift_officiating';
|
| 50 |
my %COLUMNS = (
|
39 |
my %COLUMNS = (
|
| 51 |
# colname => [qw(DisplayName N type status)], status -> static | default | <blank>
|
40 |
# colname => [qw(DisplayName N type status)], status -> static | default | <blank>
|
| 52 |
id => [qw(ID 5 number )],
|
41 |
id => [qw(ID 5 number )],
|
| 53 |
date => [qw(Date 10 date default )],
|
42 |
date => [qw(Date 10 date default )],
|
| 54 |
dayofweek => [qw(Day 15 select )],
|
43 |
dayofweek => [qw(Day 15 select )],
|
| 55 |
time => [qw(Time 20 text default )],
|
44 |
time => [qw(Time 20 text default )],
|
| 56 |
volhours => [qw(VolHours 23 number )],
|
45 |
volhours => [qw(VolHours 23 number )],
|
| 57 |
track => [qw(Track 25 select default )],
|
46 |
track => [qw(Track 25 select default )],
|
| 58 |
teams => [qw(Teams 30 text default )],
|
47 |
teams => [qw(Teams 30 text default )],
|
| 59 |
level => [qw(Level 35 select default )],
|
48 |
level => [qw(Level 35 select default )],
|
| 60 |
restrictions => [qw(Rs 40 select )],
|
49 |
restrictions => [qw(Rs 40 select )],
|
| 61 |
gtype => [qw(Type 45 select default )],
|
50 |
gtype => [qw(Type 45 select default )],
|
| 62 |
signup => [qw(SignUp 46 select )],
|
51 |
signup => [qw(SignUp 46 select )],
|
| 63 |
notes => [qw(Notes 50 text )],
|
52 |
notes => [qw(Notes 50 text )],
|
| 64 |
role => [qw(Role 55 select )],
|
53 |
role => [qw(Role 55 select )],
|
| 65 |
tla => [qw(TLA 60 select default )],
|
54 |
tla => [qw(TLA 60 select default )],
|
| Line 66... |
Line 55... |
| 66 |
name => [qw(Position 65 text )],
|
55 |
name => [qw(Position 65 text )],
|
| 67 |
type => [qw(Class 70 select default )],
|
56 |
type => [qw(Class 70 select default )],
|
| 68 |
RCid => [qw(RCid 75 number )],
|
57 |
RCid => [qw(RCid 75 number )],
|
| 69 |
derby_name => [qw(Assignee 80 select default )]
|
58 |
derby_name => [qw(Assignee 80 select default )]
|
| 70 |
);
|
59 |
);
|
| 71 |
|
60 |
|
| 72 |
if ($user->{department}->{"OFF"} > 1) {
|
61 |
if ($ORCUSER->{department}->{"OFF"} > 1) {
|
| Line 73... |
Line -... |
| 73 |
# Add:
|
- |
|
| 74 |
# real_name RealName
|
- |
|
| 75 |
# email Email
|
- |
|
| 76 |
$COLUMNS{'real_name'} = [qw(RealName 85 text)];
|
- |
|
| 77 |
$COLUMNS{'email'} = [qw(Email 90 text)];
|
62 |
# Add:
|
| 78 |
}
|
63 |
# real_name RealName
|
| Line 79... |
Line 64... |
| 79 |
|
64 |
# email Email
|
| 80 |
my $stylesheet = "/style.css";
|
65 |
$COLUMNS{'real_name'} = [qw(RealName 85 text)];
|
| 81 |
my $homeURL = '/schedule/';
|
66 |
$COLUMNS{'email'} = [qw(Email 90 text)];
|
| 82 |
my @pagelimitoptions = ("All", 5, 10, 25);
|
67 |
}
|
| 83 |
|
68 |
|
| 84 |
# If we need to modify line item values, create a subroutine named "modify_$columnname"
|
69 |
# If we need to modify line item values, create a subroutine named "modify_$columnname"
|
| Line 85... |
Line 70... |
| 85 |
# It will receive a hashref to the object lineitem (RETURN the modified field at the end of the function!)
|
70 |
# It will receive a hashref to the object lineitem (RETURN the modified field at the end of the function!)
|
| 86 |
|
71 |
|
| 87 |
sub modify_derby_name {
|
72 |
sub modify_derby_name {
|
| 88 |
my $t = shift;
|
73 |
my $t = shift;
|
| 89 |
|
74 |
|
| 90 |
if ($user->{department}->{"OFF"} < 2 and $t->{derby_name} and $t->{RCid} != $RCid and $LVL < 5) {
|
75 |
if ($ORCUSER->{department}->{"OFF"} < 2 and $t->{derby_name} and $t->{RCid} != $ORCUSER->{RCid} and $LVL < 5) {
|
| 91 |
$t->{derby_name} = "FILLED" unless getUser($t->{RCid})->{showme};
|
76 |
$t->{derby_name} = "FILLED" unless getUser($t->{RCid})->{showme};
|
| 92 |
}
|
77 |
}
|
| 93 |
|
78 |
|
| 94 |
my ($yyyy, $mm, $dd) = split /\-/, $t->{date};
|
79 |
my ($yyyy, $mm, $dd) = split /\-/, $t->{date};
|
| 95 |
my $cutoff = DateTime->new(
|
80 |
my $cutoff = DateTime->new(
|
| 96 |
year => $yyyy,
|
81 |
year => $yyyy,
|
| 97 |
month => $mm,
|
82 |
month => $mm,
|
| 98 |
day => $dd,
|
83 |
day => $dd,
|
| 99 |
hour => 5,
|
84 |
hour => 5,
|
| 100 |
minute => 0,
|
85 |
minute => 0,
|
| 101 |
second => 0,
|
86 |
second => 0,
|
| 102 |
time_zone => 'America/Los_Angeles'
|
87 |
time_zone => 'America/Los_Angeles'
|
| 103 |
);
|
88 |
);
|
| 104 |
|
89 |
|
| 105 |
if (($t->{RCid} == $RCid and $t->{signup} ne "selected" and $now < $cutoff) or ($t->{derby_name} and ($user->{department}->{"OFF"} >= 2 or $LVL >= 5))) {
|
90 |
if (($t->{RCid} == $ORCUSER->{RCid} and $t->{signup} ne "selected" and $now < $cutoff) or ($t->{derby_name} and ($ORCUSER->{department}->{"OFF"} >= 2 or $LVL >= 5))) {
|
| 106 |
# DROP
|
91 |
# DROP
|
| 107 |
$t->{derby_name} = "$t->{derby_name} <A HREF='#' onClick=\"window.open('make_shift_change.pl?change=del&RCid=$t->{RCid}&id=$t->{id}&role=$t->{role}','Confirm Shift Change','resizable,height=260,width=370'); return false;\">[DROP]</a>";
|
92 |
$t->{derby_name} = "$t->{derby_name} <A HREF='#' onClick=\"window.open('make_shift_change.pl?change=del&RCid=$t->{RCid}&id=$t->{id}&role=$t->{role}','Confirm Shift Change','resizable,height=260,width=370'); return false;\">[DROP]</a>";
|
| 108 |
if ($user->{department}->{"OFF"} >= 2) {
|
93 |
if ($ORCUSER->{department}->{"OFF"} >= 2) {
|
| 109 |
# NO SHOW
|
94 |
# NO SHOW
|
| 110 |
$t->{derby_name} .= " | <A HREF='#' onClick=\"if (confirm('Really? They were a no show?')==true) { window.open('make_shift_change.pl?noshow=true&change=del&RCid=$t->{RCid}&id=$t->{id}&role=$t->{role}','Confirm Shift Change','resizable,height=260,width=370'); return false; }\">[NO SHOW]</a>";
|
95 |
$t->{derby_name} .= " | <A HREF='#' onClick=\"if (confirm('Really? They were a no show?')==true) { window.open('make_shift_change.pl?noshow=true&change=del&RCid=$t->{RCid}&id=$t->{id}&role=$t->{role}','Confirm Shift Change','resizable,height=260,width=370'); return false; }\">[NO SHOW]</a>";
|
| 111 |
}
|
96 |
}
|
| 112 |
} elsif (!$t->{derby_name}) {
|
97 |
} elsif (!$t->{derby_name}) {
|
| 113 |
$t->{dept} = "OFF";
|
98 |
$t->{dept} = "OFF";
|
| 114 |
if (findConflict ($ORCUSER->{RCid}, $t->{id}, "game")) {
|
99 |
if (findConflict ($ORCUSER->{RCid}, $t->{id}, "game")) {
|
| 115 |
$t->{derby_name} .= "*schedule conflict*";
|
100 |
$t->{derby_name} .= "*schedule conflict*";
|
| 116 |
} elsif (signUpEligible ($ORCUSER, $t) and $now < $cutoff) {
|
101 |
} elsif (signUpEligible ($ORCUSER, $t) and $now < $cutoff) {
|
| 117 |
# SIGN UP
|
102 |
# SIGN UP
|
| 118 |
$t->{derby_name} = "<A HREF='#' onClick=\"window.open('make_shift_change.pl?change=add&RCid=$RCid&id=$t->{id}&role=$t->{role}','Confirm Shift Change','resizable,height=260,width=370'); return false;\">[SIGN UP]</a>";
|
103 |
$t->{derby_name} = "<A HREF='#' onClick=\"window.open('make_shift_change.pl?change=add&RCid=$ORCUSER->{RCid}&id=$t->{id}&role=$t->{role}','Confirm Shift Change','resizable,height=260,width=370'); return false;\">[SIGN UP]</a>";
|
| Line 119... |
Line 104... |
| 119 |
}
|
104 |
}
|
| 120 |
if ($user->{department}->{"OFF"} >= 2 or $LVL > 4) {
|
105 |
if ($ORCUSER->{department}->{"OFF"} >= 2 or $LVL > 4) {
|
| 121 |
# ADD USER
|
106 |
# ADD USER
|
| 122 |
$t->{derby_name} ? $t->{derby_name} .= " | " : {};
|
107 |
$t->{derby_name} ? $t->{derby_name} .= " | " : {};
|
| Line -... |
Line 108... |
| - |
|
108 |
$t->{derby_name} .= "<A HREF='#' onClick=\"window.open('make_shift_change.pl?change=lookup&RCid=$ORCUSER->{RCid}&id=$t->{id}&role=$t->{role}','Confirm Shift Change','resizable,height=260,width=370'); return false;\">[ADD USER]</a>";
|
| - |
|
109 |
}
|
| Line -... |
Line 110... |
| - |
|
110 |
}
|
| - |
|
111 |
return $t->{derby_name};
|
| - |
|
112 |
}
|
| - |
|
113 |
|
| - |
|
114 |
sub modify_time {
|
| - |
|
115 |
my $t = shift;
|
| - |
|
116 |
return convertTime $t->{time};
|
| - |
|
117 |
}
|
| - |
|
118 |
|
| - |
|
119 |
# If we need to modify how a filter works, create a subroutine named "filter_$columnname"
|
| - |
|
120 |
# It will receive two fields, the field name and the current filter value (if any)
|
| - |
|
121 |
|
| - |
|
122 |
# Uncomment and update if we want to enable clicking on a row to open a new page.
|
| - |
|
123 |
#
|
| - |
|
124 |
#sub addRowClick {
|
| - |
|
125 |
# my $t = shift;
|
| - |
|
126 |
# return "location.href='view_thing.pl?field=$t->{field}&choice=View'";
|
| Line 123... |
Line -... |
| 123 |
$t->{derby_name} .= "<A HREF='#' onClick=\"window.open('make_shift_change.pl?change=lookup&RCid=$RCid&id=$t->{id}&role=$t->{role}','Confirm Shift Change','resizable,height=260,width=370'); return false;\">[ADD USER]</a>";
|
- |
|
| 124 |
}
|
- |
|
| 125 |
}
|
- |
|
| 126 |
return $t->{derby_name};
|
- |
|
| 127 |
}
|
- |
|
| 128 |
|
- |
|
| 129 |
sub modify_time {
|
- |
|
| 130 |
my $t = shift;
|
- |
|
| 131 |
return convertTime $t->{time};
|
- |
|
| 132 |
}
|
- |
|
| 133 |
|
- |
|
| 134 |
|
- |
|
| 135 |
|
- |
|
| 136 |
# Ideally, nothing below this comment needs to change
|
- |
|
| 137 |
#-------------------------------------------------------------------------------
|
- |
|
| 138 |
|
- |
|
| 139 |
|
- |
|
| 140 |
our %NAME = map { $_ => $COLUMNS{$_}->[0] } keys %COLUMNS;
|
- |
|
| 141 |
our %colOrderHash = map { $_ => $COLUMNS{$_}->[1] } keys %COLUMNS;
|
- |
|
| 142 |
our %colFilterTypeHash = map { $_ => $COLUMNS{$_}->[2] } keys %COLUMNS;
|
- |
|
| 143 |
our @staticFields = sort byfield grep { $COLUMNS{$_}->[3] eq 'static' } keys %COLUMNS;
|
- |
|
| 144 |
our @defaultFields = sort byfield grep { defined $COLUMNS{$_}->[3] } keys %COLUMNS;
|
- |
|
| 145 |
#our @defaultFields = grep { $COLUMNS{$_}->[3] eq 'default' or inArray ($_, \@staticFields) } keys %COLUMNS;
|
- |
|
| 146 |
|
- |
|
| 147 |
our @allFields = sort byfield keys %NAME;
|
- |
|
| 148 |
our @displayFields = ();
|
- |
|
| 149 |
our @hideFields = ();
|
- |
|
| 150 |
my $QUERY_STRING;
|
- |
|
| 151 |
|
- |
|
| 152 |
my $pagelimit = param ("limit") // $pagelimitoptions[$#pagelimitoptions];
|
- |
|
| 153 |
my $curpage = param ("page") // 1;
|
- |
|
| 154 |
|
- |
|
| 155 |
our %FORM;
|
- |
|
| 156 |
my $FILTER;
|
- |
|
| 157 |
foreach (param()) {
|
- |
|
| 158 |
if (/^year$/) { #
|
- |
|
| 159 |
$YEAR = param($_);
|
- |
|
| 160 |
next;
|
- |
|
| 161 |
}
|
- |
|
| 162 |
|
- |
|
| 163 |
$FORM{$_} = param($_); # Retrieve all of the FORM data submitted
|
- |
|
| 164 |
|
- |
|
| 165 |
if ((/^filter/) and ($FORM{$_} ne '')) { # Build a set of filters to apply
|
- |
|
| 166 |
my ($filter,$field) = split /-/, $_;
|
- |
|
| 167 |
$FILTER->{$field} = $FORM{$_} unless notInArray ($field, \@allFields);
|
- |
|
| 168 |
} elsif ($FORM{$_} eq "true") { # Compile list of fields to display
|
- |
|
| 169 |
if ($_ ne "shiftinclude") {
|
- |
|
| 170 |
push @displayFields, $_;
|
- |
|
| 171 |
}
|
- |
|
| 172 |
}
|
- |
|
| 173 |
}
|
- |
|
| 174 |
|
- |
|
| 175 |
my @addToWhereClause = ("year(date) = '$YEAR'", "type != 'announcer'");
|
- |
|
| 176 |
|
- |
|
| 177 |
if (exists $FORM{autoload}) { # If the FORM was submitted (i.e. the page is being redisplayed),
|
- |
|
| 178 |
# build the data for the cookie that remembers the page setup
|
- |
|
| 179 |
my $disFields = join ":", @displayFields;
|
- |
|
| 180 |
my $fils = join ":", map { "$_=$FILTER->{$_}" } keys %{$FILTER};
|
- |
|
| 181 |
|
- |
|
| 182 |
$QUERY_STRING = $disFields.'&'.$fils.'&'.$FORM{sortby}.'&'.$FORM{autoload}.'&'.$FORM{shiftinclude};
|
- |
|
| 183 |
}
|
- |
|
| 184 |
|
- |
|
| 185 |
|
- |
|
| 186 |
if (!(exists $FORM{autoload})) { # No FORM was submitted...
|
- |
|
| 187 |
if (my $prefs = cookie ($prefscookie) and !defined param ("ignoreCookie")) { # Check for cookies from previous visits.
|
- |
|
| 188 |
my ($disF, $filts, $sb, $al, $si) = split /&/, $prefs;
|
- |
|
| 189 |
@displayFields = split /:/,$disF;
|
- |
|
| 190 |
|
- |
|
| 191 |
foreach my $pair (split /:/, $filts) {
|
- |
|
| 192 |
my ($key, $value) = split /=/, $pair;
|
- |
|
| 193 |
$FORM{"filter-$key"} = $value;
|
- |
|
| 194 |
$FILTER->{$key} = $value;
|
- |
|
| 195 |
}
|
- |
|
| 196 |
|
- |
|
| 197 |
$FORM{sortby} = $sb;
|
- |
|
| 198 |
$FORM{autoload} = $al;
|
- |
|
| 199 |
$FORM{shiftinclude} = $si;
|
- |
|
| 200 |
$QUERY_STRING = $prefs;
|
- |
|
| 201 |
} else {
|
- |
|
| 202 |
@displayFields = @defaultFields; # Otherwise suppply a default list of columns.
|
- |
|
| 203 |
$FORM{autoload} = 1; # And turn aut0load on by default.
|
- |
|
| 204 |
}
|
- |
|
| 205 |
}
|
- |
|
| 206 |
|
- |
|
| 207 |
# let's just make sure the columns are in the right order (and there aren't any missing)
|
- |
|
| 208 |
@displayFields = grep { inArray($_, \@allFields) } sort byfield uniq @displayFields, @staticFields;
|
- |
|
| 209 |
|
- |
|
| 210 |
# If the field isn't in the displayFields list, then add it to the hideFields list
|
- |
|
| 211 |
@hideFields = grep { notInArray ($_, \@displayFields) } @allFields;
|
- |
|
| 212 |
|
- |
|
| 213 |
# Process any filters provided in the form to pass to the database
|
- |
|
| 214 |
my @whereClause = map { filter ($_, $FILTER->{$_}) } grep { defined $FILTER->{$_} } @displayFields;
|
- |
|
| 215 |
push @whereClause, @addToWhereClause;
|
- |
|
| 216 |
|
- |
|
| 217 |
# Given the fields to display and the where conditions,
|
- |
|
| 218 |
# "getData" will return a reference to an array of
|
- |
|
| 219 |
# hash references of the results.
|
- |
|
| 220 |
my ($data, $datacount) = getData (\@displayFields, \@whereClause, $DBTABLE, $FORM{sortby}, $curpage, $pagelimit);
|
- |
|
| 221 |
my @ProductList = @{ $data };
|
- |
|
| 222 |
|
- |
|
| 223 |
#my @ProductList = @{ getData (\@displayFields, \@whereClause, $DBTABLE, $FORM{sortby}, $curpage, $pagelimit) };
|
- |
|
| 224 |
my $x = scalar @ProductList; # How many results were returned?
|
- |
|
| 225 |
|
- |
|
| 226 |
# If the user is trying to download the Excel file, send it to them and then exit out.
|
- |
|
| 227 |
if ($FORM{excel}) {
|
- |
|
| 228 |
exportExcel (\@ProductList, "RC_Officiating_Shifts");
|
- |
|
| 229 |
exit;
|
- |
|
| 230 |
}
|
- |
|
| 231 |
|
- |
|
| 232 |
my @shifts;
|
- |
|
| 233 |
if ($FORM{shiftinclude} eq "true") {
|
- |
|
| 234 |
my @SIWhere = ("year(date) = '$YEAR'");
|
- |
|
| 235 |
push @SIWhere, "RCid = $ORCUSER->{RCid}";
|
- |
|
| 236 |
my ($d, $c) = getData (\@displayFields, \@SIWhere, $DBTABLE, $FORM{sortby});
|
- |
|
| 237 |
@shifts = @{ $d };
|
- |
|
| 238 |
}
|
- |
|
| 239 |
|
- |
|
| 240 |
|
- |
|
| 241 |
my $signedOnAs = $username ? "Welcome, $username. ".$h->a ({ href=>"index.pl?LOGOUT" }, "[Log Out]") : "You are not signed in.";
|
- |
|
| 242 |
|
- |
|
| 243 |
# Set some cookie stuff...
|
- |
|
| 244 |
my $path = `dirname $ENV{SCRIPT_NAME}`; chomp $path; $path .= '/' unless $path eq "/";
|
- |
|
| 245 |
my $queryCookie = cookie(-NAME=>$prefscookie,
|
- |
|
| 246 |
-VALUE=>"$QUERY_STRING",
|
- |
|
| 247 |
-PATH=>"$path",
|
- |
|
| 248 |
-EXPIRES=>'+365d');
|
- |
|
| 249 |
|
- |
|
| 250 |
# Print the header
|
- |
|
| 251 |
print header (-cookie=> [ $queryCookie, $RCAUTH_cookie ] );
|
- |
|
| 252 |
|
- |
|
| 253 |
# print "<!-- FORM \n\n"; # Debug code to dump the FORM to a html comment
|
- |
|
| 254 |
# print "I'm catching updates!!!\n\n";
|
- |
|
| 255 |
# foreach $key (sort (keys %FORM)) # Must be done after the header is written!
|
- |
|
| 256 |
# { print "\t$key: $FORM{$key}\n"; }
|
- |
|
| 257 |
# print "--> \n\n";
|
- |
|
| 258 |
#
|
- |
|
| 259 |
#
|
- |
|
| 260 |
# print "<!-- ENV \n\n"; # Debug code to dump the ENV to a html comment
|
- |
|
| 261 |
# foreach $key (sort (keys %ENV)) # Must be done after the header is written!
|
- |
|
| 262 |
# { print "\t$key: $ENV{$key}\n"; }
|
- |
|
| 263 |
# print "--> \n\n";
|
- |
|
| 264 |
#
|
- |
|
| 265 |
# print "\n\n\n\n<!-- $QUERY_STRING --> \n\n\n\n";
|
- |
|
| 266 |
|
- |
|
| 267 |
|
- |
|
| 268 |
#------------------
|
- |
|
| 269 |
|
- |
|
| 270 |
# Toggle the autoload fields within the table elements
|
- |
|
| 271 |
our ($onClick, $onChange); # (also used in scanFunctions)
|
- |
|
| 272 |
my ($radiobutton, $refreshbutton, $sortby);
|
- |
|
| 273 |
if ($FORM{autoload}) {
|
- |
|
| 274 |
$onClick = "onClick='submit();'";
|
- |
|
| 275 |
$onChange = "onChange='page.value = 1; submit();'";
|
- |
|
| 276 |
$radiobutton = $h->div ({ class=>'autoload' },
|
- |
|
| 277 |
["Autoload Changes: ",
|
- |
|
| 278 |
$h->input ({ type=>"radio", name=>'autoload', class=>'accent', value=>1, onClick=>'submit();', checked=>[] }), "On ",
|
- |
|
| 279 |
$h->input ({ type=>"radio", name=>'autoload', class=>'accent', value=>0, onClick=>'submit();' }), "Off ",
|
- |
|
| 280 |
]);
|
- |
|
| 281 |
$refreshbutton = "";
|
- |
|
| 282 |
$sortby = $h->select ({name=>"sortby", onChange=>'submit();' }, [ map { $FORM{sortby} eq $_ ? $h->option ({ value=>$_, selected=>[] }, $NAME{$_}) : $h->option ({ value=>$_ }, $NAME{$_}) } @displayFields ]);
|
- |
|
| 283 |
} else {
|
- |
|
| 284 |
$onClick = "";
|
- |
|
| 285 |
$onChange = "onChange='page.value = 1;'";
|
- |
|
| 286 |
$radiobutton = $h->div ({ class=>'autoload' },
|
- |
|
| 287 |
["Autoload Changes: ",
|
- |
|
| 288 |
$h->input ({ type=>"radio", name=>'autoload', class=>'accent', value=>1, onClick=>'submit();' }), "On ",
|
- |
|
| 289 |
$h->input ({ type=>"radio", name=>'autoload', class=>'accent', value=>0, onClick=>'submit();', checked=>[] }), "Off ",
|
- |
|
| 290 |
]);
|
- |
|
| 291 |
$refreshbutton = $h->input ({ type=>"button", value=>"Refresh", onClick=>"submit(); return false;" });
|
- |
|
| 292 |
$sortby = $h->select ({ name=>"sortby" }, [ map { $FORM{sortby} eq $_ ? $h->option ({ value=>$_, selected=>[] }, $NAME{$_}) : $h->option ({ value=>$_ }, $NAME{$_}) } @displayFields ]);
|
- |
|
| 293 |
}
|
- |
|
| 294 |
|
- |
|
| 295 |
my $SIChecked;
|
- |
|
| 296 |
if ($FORM{shiftinclude}) {
|
- |
|
| 297 |
$SIChecked = $h->input ({ type=>"checkbox", name=>"shiftinclude", value=>"true", checked=>[], onClick=>'submit();' });
|
- |
|
| 298 |
} else {
|
- |
|
| 299 |
$SIChecked = $h->input ({ type=>"checkbox", name=>"shiftinclude", value=>"true", onClick=>'submit();' });
|
- |
|
| 300 |
}
|
- |
|
| 301 |
|
- |
|
| 302 |
|
- |
|
| 303 |
|
- |
|
| 304 |
print start_html (-title => $pageTitle, -style => {'src' => $stylesheet} );
|
- |
|
| 305 |
|
- |
|
| 306 |
print $h->open ('form', { action=>url, method=>'POST', name=>'Req' });
|
- |
|
| 307 |
print $h->input ({ type=>"hidden", name=>"excel", value=>0 });
|
- |
|
| 308 |
print $h->div ({ class => "accent pageheader" }, [
|
- |
|
| 309 |
$h->h1 ($pageTitle),
|
- |
|
| 310 |
$h->div ({ class=>"sp0" }, [
|
- |
|
| 311 |
$h->div ({ class=>"spLeft" }, [
|
- |
|
| 312 |
$radiobutton
|
- |
|
| 313 |
]),
|
- |
|
| 314 |
$h->div ({ class=>"spRight" }, [
|
- |
|
| 315 |
$h->input ({ type=>"button", value=>"Home", onClick=>"window.location.href='$homeURL'" }),
|
- |
|
| 316 |
$refreshbutton
|
- |
|
| 317 |
]),
|
- |
|
| 318 |
]),
|
- |
|
| 319 |
]);
|
- |
|
| 320 |
|
- |
|
| 321 |
# Print the Hidden fields' check boxes (if there are any)
|
- |
|
| 322 |
|
- |
|
| 323 |
my $c = 1;
|
- |
|
| 324 |
my @hiddencheckboxes;
|
- |
|
| 325 |
my @hiddenrows;
|
- |
|
| 326 |
foreach my $field (sort { $NAME{$a} cmp $NAME{$b}; } @hideFields) {
|
- |
|
| 327 |
if ($FORM{autoload}) {
|
- |
|
| 328 |
push @hiddencheckboxes, $h->div ({ class=>'rTableCell quarters nowrap', onClick=>"Req.$field.click();" }, [ $h->input ({ type=>'checkbox', class=>'accent', name=>$field, value=>'true', onClick=>"event.stopPropagation(); submit();" }), $NAME{$field} ]);
|
- |
|
| 329 |
} else {
|
- |
|
| 330 |
push @hiddencheckboxes, $h->div ({ class=>'rTableCell quarters nowrap', onClick=>"Req.$field.checked=!Req.$field.checked;" }, [ $h->input ({ type=>'checkbox', class=>'accent', name=>$field, value=>'true', onClick=>"event.stopPropagation();" }), $NAME{$field} ]);
|
- |
|
| 331 |
}
|
- |
|
| 332 |
if ($c++ % 4 == 0) {
|
- |
|
| 333 |
push @hiddenrows, $h->div ({ class=>'rTableRow' }, [ @hiddencheckboxes ]);
|
- |
|
| 334 |
@hiddencheckboxes = [];
|
- |
|
| 335 |
}
|
- |
|
| 336 |
}
|
- |
|
| 337 |
push @hiddenrows, $h->div ({ class=>'rTableRow' }, [ @hiddencheckboxes ]) unless --$c % 4 == 0;
|
- |
|
| 338 |
|
- |
|
| 339 |
my @yearoptions;
|
- |
|
| 340 |
foreach (@{&getYears()}) {
|
- |
|
| 341 |
push @yearoptions, $YEAR eq $_ ? $h->option ({ selected=>[] }, $_) : $h->option ($_);
|
- |
|
| 342 |
}
|
- |
|
| 343 |
|
- |
|
| 344 |
if (scalar @hideFields) {
|
- |
|
| 345 |
my @topleft;
|
- |
|
| 346 |
push @topleft, $h->div ({ class=>"nowrap" }, "Hidden Columns:");
|
- |
|
| 347 |
push @topleft, $h->div ({ class=>'rTable' }, [ @hiddenrows ]);
|
- |
|
| 348 |
|
- |
|
| 349 |
print $h->div ({ class=>"sp0" }, [
|
- |
|
| 350 |
$h->div ({ class=>"spLeft" }, [ @topleft ]),
|
- |
|
| 351 |
$h->div ({ class=>"spRight" }, [
|
- |
|
| 352 |
$signedOnAs, $h->br,
|
- |
|
| 353 |
"Show my shifts: ", $SIChecked, $h->br,
|
- |
|
| 354 |
$h->input ({ type=>"button", value=>"Block Personal Time", onClick=>"window.location.href='personal_time.pl'" }),
|
- |
|
| 355 |
])
|
- |
|
| 356 |
]);
|
- |
|
| 357 |
}
|
- |
|
| 358 |
|
- |
|
| 359 |
# Print the main table...............................................
|
- |
|
| 360 |
|
- |
|
| 361 |
print $h->open ('div', { class=>'rTable' });
|
- |
|
| 362 |
|
- |
|
| 363 |
my @tmptitlerow;
|
- |
|
| 364 |
foreach my $f (@displayFields) { # Print the Column headings
|
- |
|
| 365 |
if (inArray ($f, \@staticFields)) {
|
- |
|
| 366 |
push @tmptitlerow, $h->div ({ class=>'rTableHead' }, [ $h->input ({ type=>"hidden", name=>$f, value=>"true" }), $NAME{$f} ]);
|
- |
|
| 367 |
} else {
|
- |
|
| 368 |
if ($FORM{autoload}) {
|
- |
|
| 369 |
push @tmptitlerow, $h->div ({ class=>'rTableHead', onClick=>"Req.$f.click();" }, [ $h->input ({ type=>"checkbox", class=>"accent", name=>$f, value=>"true", checked=>[], onClick=>'event.stopPropagation(); submit();' }), $NAME{$f} ]);
|
- |
|
| 370 |
} else {
|
- |
|
| 371 |
push @tmptitlerow, $h->div ({ class=>'rTableHead', onClick=>"Req.$f.checked=!Req.$f.checked;" }, [ $h->input ({ type=>"checkbox", class=>"accent", name=>$f, value=>"true", checked=>[], onClick=>"event.stopPropagation();" }), $NAME{$f} ]);
|
- |
|
| 372 |
}
|
- |
|
| 373 |
}
|
- |
|
| 374 |
}
|
- |
|
| 375 |
|
- |
|
| 376 |
# Print the filter boxes...
|
- |
|
| 377 |
print $h->div ({ class=>'rTableHeading' }, [ @tmptitlerow ], [ map { $h->div ({ class=>'rTableCell filters' }, filter ($_)) } @displayFields ], $h->div ({ class=>"rTableCell" }));
|
- |
|
| 378 |
|
- |
|
| 379 |
|
- |
|
| 380 |
if ($FORM{shiftinclude}) { # Include all of the user's shifts at the top
|
- |
|
| 381 |
foreach my $t (@shifts) {
|
- |
|
| 382 |
no strict;
|
- |
|
| 383 |
print $h->div ({ class=>'rTableRow highlighted' }, [ map { $h->div ({ class=>'rTableCell' }, exists &{"modify_".$_} ? &{"modify_".$_} ($t) : $t->{$_} ? $t->{$_} : "") } @displayFields ]);
|
- |
|
| 384 |
}
|
- |
|
| 385 |
print $h->hr ({ width=>"500%" });
|
- |
|
| 386 |
}
|
- |
|
| 387 |
|
- |
|
| 388 |
|
- |
|
| 389 |
# Print the things
|
- |
|
| 390 |
foreach my $t (@ProductList) {
|
- |
|
| 391 |
no strict;
|
- |
|
| 392 |
if ($t->{RCid} eq $ORCUSER->{RCid}) {
|
- |
|
| 393 |
print $h->div ({ class=>'rTableRow highlighted' }, [ map { $h->div ({ class=>'rTableCell' }, exists &{"modify_".$_} ? &{"modify_".$_} ($t) : $t->{$_}) } @displayFields ]);
|
- |
|
| 394 |
} else {
|
- |
|
| 395 |
print $h->div ({ class=>'rTableRow shaded' }, [ map { $h->div ({ class=>'rTableCell' }, exists &{"modify_".$_} ? &{"modify_".$_} ($t) : $t->{$_}) } @displayFields ]);
|
- |
|
| 396 |
}
|
- |
|
| 397 |
}
|
- |
|
| 398 |
|
- |
|
| 399 |
|
- |
|
| 400 |
print $h->close ('div');
|
- |
|
| 401 |
|
- |
|
| 402 |
# close things out................................................
|
- |
|
| 403 |
|
- |
|
| 404 |
my $pages = $pagelimit eq "All" ? 1 : int( $datacount / $pagelimit + 0.99 );
|
- |
|
| 405 |
if ($curpage > $pages) { $curpage = $pages; }
|
- |
|
| 406 |
|
- |
|
| 407 |
my @pagerange;
|
- |
|
| 408 |
if ($pages <= 5 ) {
|
- |
|
| 409 |
@pagerange = 1 .. $pages;
|
- |
|
| 410 |
} else {
|
- |
|
| 411 |
if ($curpage <= 3) {
|
- |
|
| 412 |
@pagerange = (1, 2, 3, 4, ">>");
|
- |
|
| 413 |
} elsif ($curpage >= $pages - 2) {
|
- |
|
| 414 |
@pagerange = ("<<", $pages-3, $pages-2, $pages-1, $pages);
|
- |
|
| 415 |
} else {
|
- |
|
| 416 |
@pagerange = ("<<", $curpage-1, $curpage, $curpage+1, ">>");
|
- |
|
| 417 |
}
|
- |
|
| 418 |
}
|
- |
|
| 419 |
|
- |
|
| 420 |
print $h->br; # print $h->br;
|
- |
|
| 421 |
print $h->div ({ class=>"sp0" }, [
|
- |
|
| 422 |
$h->div ({ class=>"spLeft" }, [
|
- |
|
| 423 |
$h->div ({ class=>"footer" }, [
|
- |
|
| 424 |
"To bookmark, save, or send this exact view, use the ",
|
- |
|
| 425 |
$h->a ({ href=>'', onClick=>"window.document.Req.method = 'GET'; Req.submit(); return false;" }, "[Full URL]"),
|
- |
|
| 426 |
$h->br,
|
- |
|
| 427 |
"If this page is displaying oddly, ", $h->a ({ href=>url ()."?ignoreCookie=1" }, "[Reset Your View]"),
|
- |
|
| 428 |
$h->br,
|
- |
|
| 429 |
$h->a ({ href=>"", target=>"_new", onClick=>"window.document.Req.excel.value=1; window.document.Req.submit(); window.document.Req.excel.value=0; return false;" }, "[Export Displayed Data as an Excel Document.]"),
|
- |
|
| 430 |
$h->br,
|
- |
|
| 431 |
"This page was displayed on ", currentTime (),
|
- |
|
| 432 |
$h->br,
|
- |
|
| 433 |
"Please direct questions, problems, and concerns to $SYSTEM_EMAIL",
|
- |
|
| 434 |
$h->br,
|
- |
|
| 435 |
"Displaying: ", $h->select ({ name=>"year", onchange=>"Req.submit();" }, [ @yearoptions ])
|
- |
|
| 436 |
])
|
- |
|
| 437 |
]),
|
- |
|
| 438 |
$h->div ({ class=>"spRight" }, [
|
- |
|
| 439 |
$h->h5 ([
|
- |
|
| 440 |
"$x of $datacount Record". ($x == 1 ? "" : "s") ." Displayed", $h->br,
|
- |
|
| 441 |
"Sorted by ", $sortby, $h->br,
|
- |
|
| 442 |
"Displaying ", $h->select ({ name=>"limit", onChange=>"page.value = 1; submit();" }, [ map { $pagelimit == $_ ? $h->option ({ selected=>[] }, $_) : $h->option ($_) } @pagelimitoptions ]), " Per Page", $h->br,
|
- |
|
| 443 |
( $pages > 1 ? ( join " ", map { $_ == $curpage ? "<B>$_</b>" :
|
- |
|
| 444 |
$_ eq "<<" ? $h->a ({ onClick=>qq{Req.page.value=1; Req.submit();} }, "$_") :
|
- |
|
| 445 |
$_ eq ">>" ? $h->a ({ onClick=>qq{Req.page.value=$pages; Req.submit();} }, "$_") :
|
- |
|
| 446 |
$h->a ({ onClick=>qq{Req.page.value=$_; Req.submit();} }, "[$_]") } @pagerange ) : "" ), $h->br,
|
- |
|
| 447 |
$h->input ({ type=>"hidden", name=>"page", value=>$curpage })
|
- |
|
| 448 |
])
|
- |
|
| 449 |
]),
|
- |
|
| 450 |
]);
|
- |
|
| 451 |
|
- |
|
| 452 |
#print $h->br; # print $h->br;
|
- |
|