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