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