Rev 229 | Blame | Compare with Previous | Last modification | View Log | RSS feed
#package tableViewer;######################################################################## A set of functions to assist the scan data display tool.# Kept here to unclutter the main script.########################################################################## $Log: scanFunctions.pm,v $##use strict;use Exporter 'import';use cPanelUserConfig;use DBI ();use WebDB;our @EXPORT = qw( byfield currentTime exportExcel fetchColEntries fetchDerbyNameWithRCid filter getFilterValue getData getDBConnection inArray notInArray uniq whereInArray printTablePage );my $internalDBH = WebDB::connect () || die "Unable to connect to Database\n\n";sub currentTime {use DateTime;my $now = DateTime->now (time_zone => 'America/Los_Angeles');$now =~ s/T/ at /;return $now." US/Pacific";}sub byfield { $colOrderHash{$a} <=> $colOrderHash{$b}; }sub exportExcel {my $listref = shift;my $FN_Prefix = shift // "VORC_Export";my $displayFields = shift // "";use Spreadsheet::WriteExcel;my $date = `date +"%m%d%y%H%M%S"`; chomp $date;my $filename = "${FN_Prefix}_${date}_$$.xls";print "Content-type: application/vnd.ms-excel\n";# The Content-Disposition will generate a prompt to save the file. If you want# to stream the file to the browser, comment out the following line.print "Content-Disposition: attachment; filename=$filename\n";print "\n";# Create a new workbook and add a worksheet. The special Perl filehandle - will# redirect the output to STDOUT#my $workbook = Spreadsheet::WriteExcel->new(\*STDOUT);my $worksheet = $workbook->add_worksheet();my $format = $workbook->add_format();$format->set_bold();my $col = $row = 0;foreach $f (@$displayFields){ $worksheet->write($row, $col++, "$NAME{$f}", $format); }foreach $t (sort @{ $listref }) # Unt now we print the tickets!{$col = 0;$row++;foreach $f (@$displayFields) {if ($f eq "derby_name") {if ($user->{department}->{"OFF"} < 2 and $t->{derby_name} and $t->{RCid} != $RCid and $LVL < 5) {$t->{derby_name} = "FILLED";}}$t->{$f} =~ s/<br>/\n/ig; $worksheet->write($row, $col++, "$t->{$f}");}}$workbook->close();return;}sub fetchColEntries {my $colName = shift;my $selection = shift;my $year = shift // "year(now())";my $table = $DBTABLE;my $optionList = "";if ($colName eq "derby_name" and $LVL < 2) {# special case to anonymize assignees...my @opts = ("-blank-", $ORCUSER->{derby_name});push @opts, map { @{$_} } @{ $internalDBH->selectall_arrayref ("select derby_name from official where showme = 1 and derby_name <> ? order by derby_name", undef, $ORCUSER->{derby_name}) };$optionList = join "", map { $selection eq $_ ? "<OPTION selected>$_</OPTION>" : "<OPTION>$_</OPTION>" } @opts;} else {my $dept_where = $table eq "v_shift" ? "where dept != 'PER' and year(date) = $year" : "";my $orderby = $colName eq "dayofweek" ? "field(dayofweek, 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday')" : $colName;my $cathan = $internalDBH->prepare("select distinct nullif($colName, '') from $table $dept_where order by $orderby");$cathan->execute();while (my ($cat) = $cathan->fetchrow) {if (!$cat) { $cat = "-blank-"; }if ($cat eq $selection) {$optionList .= "<OPTION selected>$cat</OPTION>";} else {$optionList .= "<OPTION>$cat</OPTION>";}}}return $optionList;}sub fetchDerbyNameWithRCid {my $ATTRIBUTES;if (ref $_[0] eq "HASH") {$ATTRIBUTES = shift;}my $DEPT = shift // "";my $selected = shift // "";my $optionList = "";my $cathan;if (!$DEPT or $DEPT eq "CMP") {$cathan = $internalDBH->prepare("select RCid, derby_name from official where access > 0 order by derby_name");$cathan->execute();} elsif ($DEPT eq "CLA") {$cathan = $internalDBH->prepare("select RCid, derby_name from v_official where access > 0 and isnull(MVPid) = false and last_login > CURRENT_DATE - INTERVAL 365 DAY order by derby_name");$cathan->execute;} elsif ($DEPT eq "EMT") {$cathan = $internalDBH->prepare("select RCid, derby_name from v_official where access > 0 and emt_verified = true and last_login > CURRENT_DATE - INTERVAL 365 DAY order by derby_name");$cathan->execute;} else {$cathan = $internalDBH->prepare("select RCid, derby_name from official where access > 0 and (department like ? and department not like ?) and last_login > CURRENT_DATE - INTERVAL 365 DAY order by derby_name");$cathan->execute("%".$DEPT."%", "%".$DEPT."-0%");}my $valuelabel = $ATTRIBUTES->{DATALIST} ? "data-value" : "value";while (my ($id, $cat) = $cathan->fetchrow) {if ($id == $selected) {$optionList .= "<OPTION $valuelabel=$id selected>$cat</OPTION>";} else {$optionList .= "<OPTION $valuelabel=$id>$cat</OPTION>";}}return $optionList;}sub filter {my $colName = shift;my $filter = shift;my $year = shift;if (exists &{"filter_".$colName}) { return &{"filter_".$colName} ($colName, $filter); }if ($colFilterTypeHash{$colName} eq 'select'){if (defined $filter) {if ($filter eq "-blank-") {return "($colName = '' or isNull($colName) = 1)";}# $filter = s/'/\'/g;return "$colName = \"$filter\"";}else{my $thing = "filter-${colName}";my $categories = $year ? fetchColEntries ($colName, $FORM{$thing}, $year) : fetchColEntries ($colName, $FORM{$thing});my $Options = "<OPTION></OPTION>".$categories;$Options =~ s/>($FORM{$thing})/ selected>$1/;return "<SELECT name=filter-${colName} $onChange>$Options</SELECT>";}} elsif ($colFilterTypeHash{$colName} eq 'text') {if (defined $filter){if ($filter =~ /\d{1,2}:\d{2}/ and $ORCUSER->{timeformat} eq "ampm") {my ($h, $m) = split /:/, $filter;my $caret;if ($h =~ s/^\^\s*//) { $caret = "^"; }if ($h < 8) { $h += 12; }$filter = $caret.join ":", $h, $m;}if ($filter =~ s/^=\s*//) { return "$colName = \"$filter\""; }if ($filter !~ s/^\^\s*//) { $filter = "\%$filter"; }if ($filter !~ s/\s*\$$//) { $filter = "$filter\%"; }$filter =~ s/\*/%/g;return "$colName like \"$filter\"";}else{my $thing = "filter-${colName}";return "<INPUT type=text name=$thing value=\"$FORM{$thing}\" size=15 $onChange>";}} elsif ($colFilterTypeHash{$colName} eq 'number') {if (defined $filter){if ($filter =~ /^[>=<]\s*/) { return "$colName $filter"; }else { return "$colName = $filter"; }}else{my $thing = "filter-${colName}";return "<INPUT type=text name=$thing value=\"$FORM{$thing}\" size=2 $onChange>";}} elsif ($colFilterTypeHash{$colName} eq 'date') {if (defined $filter){if ($filter =~ s/^<\s*//) { return "$colName < '$filter'"; }if ($filter =~ s/^>\s*//) { return "$colName > '$filter'"; }return "$colName = '$filter'";}else{my $thing = "filter-${colName}";return "<INPUT type=text name=$thing value=\"$FORM{$thing}\" size=15 $onChange>";}} elsif ($colFilterTypeHash{$colName} eq 'boolean') {if (defined $filter){return "$colName = $filter";}else{my $thing = "filter-${colName}";my $Options = "<OPTION></OPTION><OPTION>True</OPTION><OPTION>False</OPTION>";$Options =~ s/>($FORM{$thing})/ selected>$1/;return "<SELECT name=filter-${colName} $onChange>$Options</SELECT>";}} elsif ($colFilterTypeHash{$colName} eq 'ERROR') {return "<center><strong><font color=red>ERROR!</font>";} elsif ($colFilterTypeHash{$colName} eq 'none') {return;}}sub getFilterValue {my $colName = shift;return $FORM{"filter-${colName}"};# my $tmpFormValue = param ("filter-${colName}");# $tmpFormValue //= url_param ("filter-${colName}");# $tmpFormValue //= $FORM{"filter-${colName}"};## return $tmpFormValue;}sub getData {my $fields = shift;my $whereClause = shift;my $table = shift;my $orderby = shift;my $curpage = shift; $curpage = 1 unless $curpage;my $pagelimit = shift // "All";my $selected = '*';if ($table eq "v_class_new") {foreach (@{$whereClause}) {/^RCid = \d+$/ and $table = "v_class_signup_new";}}$whereClause = scalar @{$whereClause} > 0 ? "where ".join (" and ", @{$whereClause}) : '';if ($orderby eq "dayofweek") {$orderby = "order by date, time";} elsif ($orderby eq "eventid") { # only applicable to the log viewer...$orderby = "order by eventid desc";} elsif ($orderby eq "key") { # for the settings page, the column name 'key' is a reserved word in mysql$orderby = "order by ${table}.key";} else {$orderby = $orderby eq "" ? "" : "order by $orderby";}my $getMe;if ($pagelimit eq "All") {$getMe = "select distinct * from $table $whereClause $orderby";} else {$curpage = ($curpage - 1) * $pagelimit;$getMe = "select distinct * from $table $whereClause $orderby limit $curpage, $pagelimit";}my ($totalcount) = @{$internalDBH->selectrow_arrayref ("select distinct count(*) from $table $whereClause")};# warn $getMe;my $limhan = $internalDBH->prepare($getMe); # Get the tickets from the DB$limhan->execute();my @results = ();while (my $P = $limhan->fetchrow_hashref){push @results, $P;}return (\@results, $totalcount);}sub getDBConnection {use WebDB;$dbh = WebDB::connect ();return $dbh;}sub inArray {my $item = shift;my $array = shift;foreach (@{$array}){return 1 if $item eq $_;}return 0;}sub notInArray {return ! inArray (@_);}sub uniq (@) {# From CPAN List::MoreUtils, version 0.22my %h;map { $h{$_}++ == 0 ? $_ : () } @_;}sub whereInArray {my $item = shift;my $array = shift;my $i = 0;foreach (@{$array}){return $i if $item eq $_;$i++;}return -1;}sub printTablePage {my $paramhash = shift;my $RCAUTH_cookie = $paramhash->{RCAuth} // "";my $pageTitle = $paramhash->{Title};my $prefscookie = $paramhash->{Prefs} // "";($prefscookie = lc $pageTitle) =~ s/\s+//g unless $prefscookie;my $DBTABLE = $paramhash->{Table};my $COLUMNS = $paramhash->{Columns};my $defaultWhereClause = $paramhash->{Where} // "";my $displayYearSelect = $paramhash->{DisplayYearSelect} // 1;my $showMyShiftsOption = $paramhash->{ShowMyShifts} // 0;my $highlightShifts = $paramhash->{HighlightShifts} // 0;my $headerButton = $paramhash->{HeaderButton} // "";my $blockPersonalTime = $paramhash->{PersonalTimeButton} // "";use CGI qw/param cookie header start_html url url_param/;use HTML::Tiny;my $h = HTML::Tiny->new( mode => 'html' );my $stylesheet = "/style.css";my $homeURL = '/schedule/';my @pagelimitoptions = ("All", 5, 10, 25);my $YEAR;# Extract the column names and build utility variablesmy %NAME = map { $_ => $COLUMNS->{$_}->[0] } keys %{$COLUMNS};my %colOrderHash = map { $_ => $COLUMNS->{$_}->[1] } keys %{$COLUMNS};sub byfield { $colOrderHash{$a} <=> $colOrderHash{$b}; }our %colFilterTypeHash = map { $_ => $COLUMNS->{$_}->[2] } keys %{$COLUMNS};my @staticFields = sort byfield grep { $COLUMNS->{$_}->[3] and $COLUMNS->{$_}->[3] eq 'static' } keys %{$COLUMNS};my @defaultFields = sort byfield grep { defined $COLUMNS->{$_}->[3] } keys %{$COLUMNS};my @allFields = sort byfield keys %NAME;my @displayFields = ();my @hideFields = ();my $QUERY_STRING;my $pagelimit = param ("limit") // $pagelimitoptions[$#pagelimitoptions];my $curpage = param ("page") // 1;our %FORM;my $FILTER;foreach (param()) {if (/^year$/) {$YEAR = param($_);next;}$FORM{$_} = param($_); # Retrieve all of the FORM data submitted#warn "$_: $FORM{$_}";if ((/^filter/) and ($FORM{$_} ne '')) { # Build a set of filters to applymy ($filter,$field) = split /-/, $_;$FILTER->{$field} = $FORM{$_} unless notInArray ($field, \@allFields);} elsif ($FORM{$_} eq "true") # Compile list of fields to display{ push @displayFields, $_ unless /shiftinclude/; }}foreach (url_param()) {if (/^year$/) {$YEAR = url_param($_);next;}$FORM{$_} = url_param($_); # Retrieve all of the FORM data submitted#warn "$_: $FORM{$_}";if ((/^filter/) and ($FORM{$_} ne '')) { # Build a set of filters to applymy ($filter,$field) = split /-/, $_;$FILTER->{$field} = $FORM{$_} unless notInArray ($field, \@allFields);} elsif ($FORM{$_} eq "true") # Compile list of fields to display{ push @displayFields, $_ unless /shiftinclude/; }}if (exists $FORM{autoload}) { # If the FORM was submitted (i.e. the page is being redisplayed),# build the data for the cookie that remembers the page setupmy $disFields = join ":", @displayFields;my $fils = join ":", map { "$_=$FILTER->{$_}" } keys %{$FILTER};$QUERY_STRING = $disFields.'&'.$fils.'&'.$FORM{sortby}.'&'.$FORM{autoload};$QUERY_STRING .= '&'.$FORM{shiftinclude} unless !$FORM{shiftinclude};}if (!(exists $FORM{autoload})) { # No FORM was submitted...if (my $prefs = cookie ($prefscookie) and !defined param ("ignoreCookie")) { # Check for cookies from previous visits.my ($disF, $filts, $sb, $al, $si) = split /&/,$prefs;@displayFields = split /:/,$disF;foreach my $pair (split /:/, $filts) {my ($key, $value) = split /=/, $pair;$FORM{"filter-$key"} = $value;$FILTER->{$key} = $value;}$FORM{sortby} = $sb;$FORM{autoload} = $al;$FORM{shiftinclude} = $si;$QUERY_STRING = $prefs;} else {@displayFields = @defaultFields; # Otherwise suppply a default list of columns.$FORM{autoload} = 1; # And turn autoload on by default.}}# let's just make sure the columns are in the right order (and there aren't any missing)@displayFields = grep { inArray($_, \@allFields) } sort byfield uniq @displayFields, @staticFields;# If the field isn't in the displayFields list, then add it to the hideFields list@hideFields = grep { notInArray ($_, \@displayFields) } @allFields;# Process any filters provided in the form to pass to the databasemy @whereClause; # = $defaultWhereClause;push @whereClause, $defaultWhereClause unless !$defaultWhereClause;if ($displayYearSelect) {my $yearfield = inArray("date", \@allFields) ? 'year(date)' : "year"; # some pages only use the year, and not a dateif ($YEAR) {push @whereClause, "$yearfield = '$YEAR'";} else {push @whereClause, "$yearfield = year(now())";}}push @whereClause, map { filter ($_, $FILTER->{$_}) } grep { defined $FILTER->{$_} } @displayFields;# Given the fields to display and the where conditions,# "getData" will return a reference to an array of# hash references of the results.my ($data, $datacount) = getData (\@displayFields, \@whereClause, $DBTABLE, $FORM{sortby}, $curpage, $pagelimit);my @ProductList = @{ $data };my $x = scalar @ProductList; # How many results were returned?# If the user is trying to download the Excel file, send it to them and then exit out.if ($FORM{excel}) {(my $filename = $pageTitle) =~ s/\s+/_/g;exportExcel (\@ProductList, $filename, \@displayFields);exit;}my @shifts;if ($FORM{shiftinclude} eq "true") {my @SIWhere = ("year(date) = '$YEAR'");push @SIWhere, "RCid = $ORCUSER->{RCid}";my ($d, $c) = getData (\@displayFields, \@SIWhere, $DBTABLE, $FORM{sortby});@shifts = @{ $d };}my $username = $h->a ({ href=>"/schedule/view_user.pl?submit=View&RCid=$ORCUSER->{RCid}" }, $ORCUSER->{derby_name});my $signedOnAs = $username ? "Welcome, $username. ".$h->input ({ type=>"button", value=>"Log Out", onClick=>"window.location.href='index.pl?LOGOUT';" }) : "You are not signed in.";# Set some cookie stuff...my $path = `dirname $ENV{SCRIPT_NAME}`; chomp $path; $path .= '/' unless $path eq "/";my $queryCookie = cookie(-NAME=>$prefscookie,-VALUE=>"$QUERY_STRING",-PATH=>"$path",-EXPIRES=>'+365d');# Print the headerprint header (-cookie=> [ $queryCookie, $RCAUTH_cookie ] );#------------------# Toggle the autoload fields within the table elementsour ($onClick, $onChange); # (also used in scanFunctions)my ($radiobutton, $refreshbutton, $sortby);if ($FORM{autoload}) {$onClick = "onClick='submit();'";$onChange = "onChange='page.value = 1; submit();'";$radiobutton = $h->div ({ class=>'autoload' },["Autoload Changes: ",$h->input ({ type=>"radio", name=>'autoload', class=>'accent', value=>1, onClick=>'submit();', checked=>[] }), "On ",$h->input ({ type=>"radio", name=>'autoload', class=>'accent', value=>0, onClick=>'submit();' }), "Off ",]);$refreshbutton = "";$sortby = $h->select ({name=>"sortby", onChange=>'submit();' }, [ map { $FORM{sortby} eq $_ ? $h->option ({ value=>$_, selected=>[] }, $NAME{$_}) : $h->option ({ value=>$_ }, $NAME{$_}) } @displayFields ]);} else {$onClick = "";$onChange = "onChange='page.value = 1;'";$radiobutton = $h->div ({ class=>'autoload' },["Autoload Changes: ",$h->input ({ type=>"radio", name=>'autoload', class=>'accent', value=>1, onClick=>'submit();' }), "On ",$h->input ({ type=>"radio", name=>'autoload', class=>'accent', value=>0, onClick=>'submit();', checked=>[] }), "Off ",]);$refreshbutton = $h->input ({ type=>"button", value=>"Refresh", onClick=>"submit(); return false;" });$sortby = $h->select ({name=>"sortby" }, [ map { $FORM{sortby} eq $_ ? $h->option ({ value=>$_, selected=>[] }, $NAME{$_}) : $h->option ({ value=>$_ }, $NAME{$_}) } @displayFields ]);}# "Shift Include" shows a checkbox to include a users shifts at the top of the pagemy $SIChecked;if ($showMyShiftsOption) {my $things = $DBTABLE eq "v_class_new" ? "classes" : "shifts";if ($FORM{shiftinclude}) {$SIChecked = "Show my $things: ".$h->input ({ type=>"checkbox", name=>"shiftinclude", value=>"true", checked=>[], onClick=>'submit();' });} else {$SIChecked = "Show my $things: ".$h->input ({ type=>"checkbox", name=>"shiftinclude", value=>"true", onClick=>'submit();' });}}# If the block personal time flag is set, include a button to go to that form.$SIChecked .= ' '.$h->input ({ type=>"button", value=>"Block Personal Time", onClick=>"window.location.href='personal_time.pl'" }) unless !$blockPersonalTime;$SIChecked .= $h->br unless !$SIChecked;print start_html (-title => $pageTitle, -style => {'src' => $stylesheet} );print $h->open ('form', { action=>url, method=>'POST', name=>'Req' });print $h->input ({ type=>"hidden", name=>"excel", value=>0 });print $h->div ({ class => "accent pageheader" }, [$h->h1 ($pageTitle),$h->div ({ class=>"sp0" }, [$h->div ({ class=>"spLeft" }, [$radiobutton]),$h->div ({ class=>"spRight" }, [$h->input ({ type=>"button", value=>"Home", onClick=>"window.location.href=".$homeURL }),$refreshbutton]),]),]);# Print the Hidden fields' check boxes (if there are any)my $c = 1;my @hiddencheckboxes;my @hiddenrows;foreach my $field (sort { $NAME{$a} cmp $NAME{$b}; } @hideFields) {if ($FORM{autoload}) {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} ]);} else {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} ]);}if ($c++ % 4 == 0) {push @hiddenrows, $h->div ({ class=>'rTableRow' }, [ @hiddencheckboxes ]);@hiddencheckboxes = [];}}push @hiddenrows, $h->div ({ class=>'rTableRow' }, [ @hiddencheckboxes ]) unless --$c % 4 == 0;if (scalar @hideFields) {my @topleft;push @topleft, $h->div ({ class=>"nowrap" }, "Hidden Columns:");push @topleft, $h->div ({ class=>'rTable' }, [ @hiddenrows ]);print $h->div ({ class=>"sp0" }, [$h->div ({ class=>"spLeft" }, [ @topleft ]),$h->div ({ class=>"spRight" }, [$signedOnAs, $h->br,$SIChecked,])]);}# Print the main table...............................................print $h->open ('div', { class=>'rTable' });my @tmptitlerow;foreach my $f (@displayFields) { # Print the Column headingsmy $special_button = "";if ($headerButton) {if ($f eq $headerButton->{field}) {$special_button = ' '.$headerButton->{button};}}if (inArray ($f, \@staticFields)) {push @tmptitlerow, $h->div ({ class=>'rTableHead' }, [ $h->input ({ type=>"hidden", name=>$f, value=>"true" }), $NAME{$f}, $special_button ]);} else {if ($FORM{autoload}) {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}, $special_button ]);} else {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}, $special_button ]);}}}# Print the filter boxes...print $h->div ({ class=>'rTableHeading' }, [ @tmptitlerow ], [ map { $h->div ({ class=>'rTableCell filters' }, filter ($_, undef, $YEAR)) } @displayFields ], $h->div ({ class=>"rTableCell" }));if ($FORM{shiftinclude}) { # Include all of the user's shifts at the topforeach my $t (@shifts) {no strict;print $h->div ({ class=>'rTableRow highlighted' }, [ map { $h->div ({ class=>'rTableCell' }, exists &{"modify_".$_} ? &{"modify_".$_} ($t) : $t->{$_} ? $t->{$_} : "") } @displayFields ]);}print $h->hr ({ width=>"500%" });}# Print the thingsforeach my $t (@ProductList) {my $shading = ($highlightShifts and $t->{RCid} eq $ORCUSER->{RCid}) ? "highlighted" : "shaded";no strict; # 'strict' doesn't like the exists functionalitymy $rowclick = (exists &addRowClick) ? addRowClick ($t) : "";print $h->div ({ class=>'rTableRow '.$shading, onClick=>$rowclick }, [ map { $h->div ({ class=>'rTableCell' }, exists &{"modify_".$_} ? &{"modify_".$_} ($t) : $t->{$_} ? $t->{$_} : "") } @displayFields ]);}print $h->close ('div');# close things out................................................my $pages = $pagelimit eq "All" ? 1 : int( $datacount / $pagelimit + 0.99 );if ($curpage > $pages) { $curpage = $pages; }my @pagerange;if ($pages <= 5 ) {@pagerange = 1 .. $pages;} else {if ($curpage <= 3) {@pagerange = (1, 2, 3, 4, ">>");} elsif ($curpage >= $pages - 2) {@pagerange = ("<<", $pages-3, $pages-2, $pages-1, $pages);} else {@pagerange = ("<<", $curpage-1, $curpage, $curpage+1, ">>");}}my @yearoptions;if ($displayYearSelect) {my $currentyear;foreach (@{&getYears()}) {push @yearoptions, $YEAR eq $_ ? $h->option ({ selected=>[] }, $_) : $h->option ($_);$currentyear = $_;}$yearoptions[$#yearoptions] = $h->option ({ selected=>[] }, $currentyear) unless $YEAR;}print $h->br; # print $h->br;print $h->div ({ class=>"sp0" }, [$h->div ({ class=>"spLeft" }, [$h->div ({ class=>"footer" }, ["To bookmark, save, or send this exact view, use the ",$h->a ({ href=>'', onClick=>"window.document.Req.method = 'GET'; Req.submit(); return false;" }, "[Full URL]"),$h->br,"If this page is displaying oddly, ", $h->a ({ href=>url ()."?ignoreCookie=1" }, "[Reset Your View]"),$h->br,$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.]"),$h->br,"This page was displayed on ", currentTime (),$h->br,"Please direct questions, problems, and concerns to $SYSTEM_EMAIL",$displayYearSelect ? $h->br."Displaying: ".$h->select ({ name=>"year", onchange=>"Req.submit();" }, [ @yearoptions ]) : $h->br])]),$h->div ({ class=>"spRight" }, [$h->h5 (["$x of $datacount Record". ($x == 1 ? "" : "s") ." Displayed", $h->br,"Sorted by ", $sortby, $h->br,"Displaying ", $h->select ({ name=>"limit", onChange=>"page.value = 1; submit();" }, [ map { $pagelimit == $_ ? $h->option ({ selected=>[] }, $_) : $h->option ($_) } @pagelimitoptions ]), " Per Page", $h->br,( $pages > 1 ? ( join " ", map { $_ == $curpage ? "<B>$_</b>" :$_ eq "<<" ? $h->a ({ onClick=>qq{Req.page.value=1; Req.submit();} }, "$_") :$_ eq ">>" ? $h->a ({ onClick=>qq{Req.page.value=$pages; Req.submit();} }, "$_") :$h->a ({ onClick=>qq{Req.page.value=$_; Req.submit();} }, "[$_]") } @pagerange ) : "" ), $h->br,$h->input ({ type=>"hidden", name=>"page", value=>$curpage })])]),]);print $h->close('form');print $h->close('body');print $h->close('html');}# Leave this alone, it's needed to compile correctlyreturn 1;