Subversion Repositories VORC

Rev

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

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