Subversion Repositories VORC

Rev

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