Subversion Repositories VORC

Rev

Rev 122 | Rev 131 | 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};
130 - 119
 		warn "DEBUG: RCid: ".$t->{RCid};
56 bgadell 120
 
121
  if ($t->{derby_name}) {
69 bgadell 122
    if ($user->{department}->{$dept} >= RollerCon::LEAD or $LVL >= RollerCon::ADMIN) {
56 bgadell 123
      $t->{derby_name} = $h->a ({ href=>"/schedule/view_user.pl?RCid=$t->{RCid}" }, $t->{derby_name});
124
    } else {
122 - 125
      $t->{derby_name} = "FILLED" unless getUser($t->{RCid})->{showme};
56 bgadell 126
      return $t->{derby_name};
127
    }
7 - 128
  }
129
 
77 bgadell 130
  if ($dept eq "COA" and $t->{location} =~ /MVP/) {
56 bgadell 131
    return $LVL >= RollerCon::ADMIN ? $t->{derby_name} . " | " . $h->a ({ href=>"view_class.pl?id=".getClassID ($t->{id})."&choice=Update" }, "[Edit Class]") : $t->{derby_name};
132
  }
133
 
7 - 134
 	my ($yyyy, $mm, $dd) = split /\-/, $t->{date};
135
	my $cutoff = DateTime->new(
136
        year => $yyyy,
137
        month => $mm,
138
        day => $dd,
139
        hour => 5,
140
        minute => 0,
141
        second => 0,
142
        time_zone => 'America/Los_Angeles'
143
  );
56 bgadell 144
 
130 - 145
 	if (($t->{RCid} == $RCid and $t->{type} ne "selected" and $now < $cutoff) or ($t->{derby_name} and ($user->{department}->{$dept} >= 2 or $LVL >= 5))) {
56 bgadell 146
 		# DROP
130 - 147
 		$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->{RCid}&id=$t->{id}','Confirm Shift Change','resizable,height=260,width=370'); return false; }\">[DROP]</a>";
69 bgadell 148
 		if ($user->{department}->{$dept} >= 2 or $LVL > 4) {
56 bgadell 149
 		  # NO SHOW
130 - 150
 		  $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->{RCid}&id=$t->{id}','Confirm Shift Change','resizable,height=260,width=370'); return false; }\">[NO SHOW]</a>";
56 bgadell 151
 		}
7 - 152
 	} elsif (!$t->{derby_name}) {
100 bgadell 153
 		if (findConflict ($ORCUSER->{RCid}, $t->{id})) {
154
      $t->{derby_name} .= "*schedule conflict*";
155
    } elsif (signUpEligible ($ORCUSER, $t, "vol") and $now < $cutoff) {
7 - 156
 			# SIGN UP
56 bgadell 157
 			$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 - 158
 		}
69 bgadell 159
 		if ($user->{department}->{$dept} >= 2 or $LVL > 4) {
7 - 160
 			# ADD USER
161
 			$t->{derby_name} ? $t->{derby_name} .= " | " : {};
56 bgadell 162
 			$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 - 163
 		}
164
 	}
165
 	return $t->{derby_name};
166
}
167
 
56 bgadell 168
sub modify_time {
169
  my $t = shift;
170
  return convertTime $t->{time};
7 - 171
}
172
 
56 bgadell 173
sub modify_start_time {
174
  my $t = shift;
175
  return convertTime $t->{start_time};
7 - 176
}
177
 
56 bgadell 178
sub modify_end_time {
50 bgadell 179
  my $t = shift;
56 bgadell 180
  return convertTime $t->{end_time};
50 bgadell 181
}
7 - 182
 
50 bgadell 183
 
7 - 184
# Ideally, nothing below this comment needs to change
185
#-------------------------------------------------------------------------------
186
 
187
 
188
our %NAME              = map  { $_ => $COLUMNS{$_}->[0] } keys %COLUMNS;
189
our %colOrderHash      = map  { $_ => $COLUMNS{$_}->[1] } keys %COLUMNS;
190
our %colFilterTypeHash = map  { $_ => $COLUMNS{$_}->[2] } keys %COLUMNS;
191
our @staticFields      = sort byfield grep { $COLUMNS{$_}->[3] eq 'static' } keys %COLUMNS;
192
our @defaultFields     = sort byfield grep { defined $COLUMNS{$_}->[3] } keys %COLUMNS;
193
#our @defaultFields     = grep { $COLUMNS{$_}->[3] eq 'default' or inArray ($_, \@staticFields) } keys %COLUMNS;
194
 
195
our @allFields = sort byfield keys %NAME;
196
our @displayFields = ();
197
our @hideFields = ();
198
my $QUERY_STRING;
199
 
200
my $pagelimit = param ("limit") // $pagelimitoptions[$#pagelimitoptions];
201
my $curpage = param ("page") // 1;
202
 
203
our %FORM;
204
my $FILTER;
205
foreach (param()) {
206
 	if (/^year$/) { #
2 - 207
		$YEAR = param($_);
208
		next;
209
	}
7 - 210
 
2 - 211
	$FORM{$_} = param($_);				# Retrieve all of the FORM data submitted
60 bgadell 212
 
7 - 213
	if ((/^filter/) and ($FORM{$_} ne '')) {	# Build a set of filters to apply
214
		my ($filter,$field) = split /-/, $_;
56 bgadell 215
		$FILTER->{$field} = $FORM{$_} unless notInArray ($field, \@allFields);
216
	}	elsif ($FORM{$_} eq "true")			# Compile list of fields to display
217
		{ push @displayFields, $_; }
2 - 218
}
56 bgadell 219
push @whereClause, "year(date) = '$YEAR'";
2 - 220
 
7 - 221
if (exists $FORM{autoload})	{			# If the FORM was submitted (i.e. the page is being redisplayed),
222
							                    #  	build the data for the cookie that remembers the page setup
2 - 223
	my $disFields = join ":", @displayFields;
7 - 224
	my $fils = join ":", map { "$_=$FILTER->{$_}" } keys %{$FILTER};
2 - 225
 
56 bgadell 226
	$QUERY_STRING = $disFields.'&'.$fils.'&'.$FORM{sortby}.'&'.$FORM{autoload};
2 - 227
}
228
 
229
 
7 - 230
if (!(exists $FORM{autoload}))	{			# No FORM was submitted...
231
	if (my $prefs = cookie ($prefscookie) and !defined param ("ignoreCookie"))	{ # Check for cookies from previous visits.
56 bgadell 232
		my ($disF, $filts, $sb, $al) = split /&/,$prefs;
2 - 233
		@displayFields = split /:/,$disF;
234
 
7 - 235
		foreach my $pair (split /:/, $filts)	{
2 - 236
			my ($key, $value) = split /=/, $pair;
237
			$FORM{"filter-$key"} = $value;
238
			$FILTER->{$key} = $value;
239
		}
240
 
7 - 241
		$FORM{sortby} = $sb;
2 - 242
		$FORM{autoload} = $al;
243
		$QUERY_STRING = $prefs;
7 - 244
	}	else {
56 bgadell 245
	  @displayFields = @defaultFields; # Otherwise suppply a default list of columns.
246
	  $FORM{sortby} = $displayFields[1];
7 - 247
	  $FORM{autoload} = 1;             # And turn aut0load on by default.
248
	}
2 - 249
}
250
 
7 - 251
# let's just make sure the columns are in the right order (and there aren't any missing)
56 bgadell 252
@displayFields = grep { inArray($_, \@allFields) } sort byfield uniq @displayFields, @staticFields;
2 - 253
 
7 - 254
# If the field isn't in the displayFields list,	then add it to the hideFields list
255
@hideFields = grep { notInArray ($_, \@displayFields) } @allFields;
2 - 256
 
7 - 257
# Process any filters provided in the form to pass to the database
258
push @whereClause, map { filter ($_, $FILTER->{$_}) } grep { defined $FILTER->{$_} } @displayFields;
2 - 259
 
7 - 260
							#  Given the fields to display and the where conditions,
261
							#	  "getData" will return a reference to an array of
262
							#	  hash references of the results.
56 bgadell 263
#warn join " and ", @whereClause;
7 - 264
my ($data, $datacount) = getData (\@displayFields, \@whereClause, $DBTABLE, $FORM{sortby}, $curpage, $pagelimit);
265
my @ProductList = @{ $data };
266
 
267
#my @ProductList = @{ getData (\@displayFields, \@whereClause, $DBTABLE, $FORM{sortby}, $curpage, $pagelimit) };
268
my $x = scalar @ProductList; # How many results were returned?
269
 
270
# If the user is trying to download the Excel file, send it to them and then exit out.
271
if ($FORM{excel}) {
272
  exportExcel (\@ProductList, "RC_Officiating_Shifts");
273
  exit;
2 - 274
}
275
 
7 - 276
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 - 277
 
7 - 278
# Set some cookie stuff...
65 bgadell 279
my $path = `dirname $ENV{SCRIPT_NAME}`; chomp $path; $path .= '/' unless $path eq "/";
7 - 280
my $queryCookie = cookie(-NAME=>$prefscookie,
2 - 281
			-VALUE=>"$QUERY_STRING",
282
			-PATH=>"$path",
283
			-EXPIRES=>'+365d');
284
 
7 - 285
# Print the header
286
print header (-cookie=> [ $queryCookie, $RCAUTH_cookie ] );
2 - 287
 
7 - 288
# 	print "<!-- FORM \n\n";				# Debug code to dump the FORM to a html comment
289
#	print "I'm catching updates!!!\n\n";
290
#	foreach $key (sort (keys %FORM))		#	Must be done after the header is written!
291
# 		{ print "\t$key:  $FORM{$key}\n"; }
292
# 	print "--> \n\n";
2 - 293
#
294
#
295
# 	print "<!-- ENV \n\n";				# Debug code to dump the ENV to a html comment
296
# 	foreach $key (sort (keys %ENV))			#	Must be done after the header is written!
297
# 		{ print "\t$key:  $ENV{$key}\n"; }
298
# 	print "--> \n\n";
299
#
300
# 	print "\n\n\n\n<!-- $QUERY_STRING --> \n\n\n\n";
301
 
302
 
303
#------------------
56 bgadell 304
 
7 - 305
# Toggle the autoload fields within the table elements
306
our ($onClick, $onChange);   # (also used in scanFunctions)
307
my ($radiobutton, $refreshbutton, $sortby);
308
if ($FORM{autoload}) {
309
	$onClick = "onClick='submit();'";
310
	$onChange = "onChange='page.value = 1; submit();'";
311
  $radiobutton = $h->div ({ class=>'autoload' },
312
    ["Autoload Changes: ",
313
    $h->input ({ type=>"radio", name=>'autoload', class=>'accent', value=>1, onClick=>'submit();', checked=>[] }), "On ",
314
    $h->input ({ type=>"radio", name=>'autoload', class=>'accent', value=>0, onClick=>'submit();' }), "Off ",
315
    ]);
56 bgadell 316
  $refreshbutton = "";
317
  $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 - 318
} else {
319
  $onClick = "";
320
	$onChange = "onChange='page.value = 1;'";
321
  $radiobutton = $h->div ({ class=>'autoload' },
322
    ["Autoload Changes: ",
323
    $h->input ({ type=>"radio", name=>'autoload', class=>'accent', value=>1, onClick=>'submit();' }), "On ",
324
    $h->input ({ type=>"radio", name=>'autoload', class=>'accent', value=>0, onClick=>'submit();', checked=>[] }), "Off ",
325
    ]);
11 - 326
  $refreshbutton = $h->input ({ type=>"button", value=>"Refresh", onClick=>"submit(); return false;" });
7 - 327
  $sortby = $h->select ({name=>"sortby" }, [ map { $FORM{sortby} eq $_ ? $h->option ({ value=>$_, selected=>[] }, $NAME{$_}) : $h->option ({ value=>$_ }, $NAME{$_}) } @displayFields ]);
2 - 328
}
329
 
330
 
331
 
56 bgadell 332
 
7 - 333
print start_html (-title => $pageTitle, -style => {'src' => $stylesheet} );
2 - 334
 
7 - 335
print $h->open ('form', { action=>url, method=>'POST', name=>'Req' });
336
print $h->input ({ type=>"hidden", name=>"excel", value=>0 });
337
print $h->div ({ class => "accent pageheader" }, [
338
  $h->h1 ($pageTitle),
339
  $h->div ({ class=>"sp0" }, [
340
    $h->div ({ class=>"spLeft" }, [
341
      $radiobutton
342
    ]),
343
    $h->div ({ class=>"spRight" }, [
344
      $h->input ({ type=>"button", value=>"Home", onClick=>"window.location.href='$homeURL'" }),
345
      $refreshbutton
346
    ]),
347
  ]),
348
]);
2 - 349
 
7 - 350
# Print the Hidden fields' check boxes (if there are any)
2 - 351
 
7 - 352
my $c = 1;
353
my @hiddencheckboxes;
354
my @hiddenrows;
355
foreach my $field (sort { $NAME{$a} cmp $NAME{$b}; } @hideFields) {
356
  if ($FORM{autoload}) {
357
    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} ]);
358
  } else {
359
    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} ]);
360
  }
361
  if ($c++ % 4 == 0) {
362
    push @hiddenrows, $h->div ({ class=>'rTableRow' }, [ @hiddencheckboxes ]);
363
    @hiddencheckboxes = [];
364
  }
365
}
366
push @hiddenrows, $h->div ({ class=>'rTableRow' }, [ @hiddencheckboxes ]) unless --$c % 4 == 0;
2 - 367
 
50 bgadell 368
my @yearoptions;
369
foreach (@{&getYears()}) {
370
	push @yearoptions, $YEAR eq $_ ? $h->option ({ selected=>[] }, $_) : $h->option ($_);
371
}
2 - 372
 
7 - 373
if (scalar @hideFields) {
374
  my @topleft;
375
  push @topleft, $h->div ({ class=>"nowrap" }, "Hidden Columns:");
376
  push @topleft, $h->div ({ class=>'rTable' }, [ @hiddenrows ]);
377
 
378
  print $h->div ({ class=>"sp0" }, [
379
    $h->div ({ class=>"spLeft"  }, [ @topleft ]),
380
    $h->div ({ class=>"spRight" }, [
56 bgadell 381
      $signedOnAs
7 - 382
    ])
383
  ]);
384
}
2 - 385
 
7 - 386
# Print the main table...............................................
2 - 387
 
7 - 388
print $h->open ('div', { class=>'rTable' });
2 - 389
 
7 - 390
my @tmptitlerow;
391
foreach my $f (@displayFields)	{  # Print the Column headings
56 bgadell 392
  if ($f eq $allFields[0]) {
60 bgadell 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 ? $h->input ({ type=>"hidden", name=>$f, value=>"true" })."&nbsp;".$h->input ({ type=>"button", value=>"Add", onClick=>"window.location.href='view_shift.pl'" }) : "" ]);
394
    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 - 395
  } else {
396
    if ($FORM{autoload}) {
397
      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} ]);
398
    } else {
399
      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} ]);
400
    }
401
  }
402
}
2 - 403
 
7 - 404
# Print the filter boxes...
405
print $h->div ({ class=>'rTableHeading' }, [ @tmptitlerow ], [ map { $h->div ({ class=>'rTableCell filters' }, filter ($_)) } @displayFields ], $h->div ({ class=>"rTableCell" }));
2 - 406
 
7 - 407
# Print the things
408
foreach my $t (@ProductList)	{
56 bgadell 409
  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 - 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,
65 bgadell 445
        "Please direct questions, problems, and concerns to $SYSTEM_EMAIL",
50 bgadell 446
        $h->br,
447
        "Displaying: ", $h->select ({ name=>"year", onchange=>"Req.submit();" }, [ @yearoptions ])
7 - 448
      ])
449
    ]),
450
    $h->div ({ class=>"spRight" }, [
451
      $h->h5 ([
452
               "$x of $datacount Record". ($x == 1 ? "" : "s") ." Displayed", $h->br,
453
               "Sorted by ", $sortby, $h->br,
454
               "Displaying ", $h->select ({ name=>"limit", onChange=>"page.value = 1; submit();" }, [ map { $pagelimit == $_ ? $h->option ({ selected=>[] }, $_) : $h->option ($_) } @pagelimitoptions ]), " Per Page", $h->br,
455
               ( $pages > 1 ? ( join " ", map { $_ == $curpage ? "<B>$_</b>" :
456
                                                $_ eq "<<"     ? $h->a ({ onClick=>qq{Req.page.value=1; Req.submit();} }, "$_") :
457
                                                $_ eq ">>"     ? $h->a ({ onClick=>qq{Req.page.value=$pages; Req.submit();} }, "$_") :
458
                                                                 $h->a ({ onClick=>qq{Req.page.value=$_; Req.submit();} }, "[$_]") } @pagerange ) : "" ), $h->br,
459
               $h->input ({ type=>"hidden", name=>"page", value=>$curpage })
460
      ])
461
    ]),
462
]);
2 - 463
 
7 - 464
#print $h->br; # print $h->br;
465
#print $h->h5 ("$x Record(s) Displayed");
466
#print $h->div ({ class=>"footer" }, [
467
#  "To bookmark, save, or send this exact view, use the ",
468
#  $h->a ({ href=>'', onClick=>"window.document.Req.method = 'GET'; Req.submit(); return false;" }, "[Full URL]"),
469
#  $h->br,
470
#  "This page was displayed on $now",
471
#  $h->br,
472
#  "Please direct questions, problems, and concerns to noone\@gmail.com"
473
#]);
2 - 474
 
475
 
7 - 476
print $h->close('form');
477
print $h->close('html');