Subversion Repositories VORC

Rev

Rev 100 | Rev 122 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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