Subversion Repositories VORC

Rev

Rev 138 | Rev 222 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 138 Rev 196
Line 6... Line 6...
6
open STDERR, '>>', $error_log_path.'vorc_error.log' or warn "Failed to open redirected logfile ($0): $!";
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";
7
#warn "Redirecting errors to ${error_log_path}vorc_error.log";
Line 8... Line 8...
8
 
8
 
Line 9... Line 9...
9
#if ($ENV{SHELL}) { die "This script shouldn't be executed from the command line!\n"; }
9
#if ($ENV{SHELL}) { die "This script shouldn't be executed from the command line!\n"; }
10
 
10
 
11
#use strict;
11
use strict;
12
use cPanelUserConfig;
12
use cPanelUserConfig;
13
use CGI qw/param cookie header start_html url/;
13
use CGI qw/param cookie header start_html url/;
14
use HTML::Tiny;
14
use HTML::Tiny;
15
use tableViewer;
15
use tableViewer;
Line 16... Line 16...
16
use RollerCon;
16
use RollerCon;
17
our $h = HTML::Tiny->new( mode => 'html' );
17
our $h = HTML::Tiny->new( mode => 'html' );
18
 
-
 
19
my $cookie_string = authenticate (RollerCon::LEAD) || die;
-
 
20
our ($EML, $PWD, $LVL) = split /&/, $cookie_string;
-
 
21
my $user = getUser ($EML);
18
 
22
my $username = $h->a ({ href=>"/schedule/view_user.pl?submit=View&RCid=$user->{RCid}" }, $user->{derby_name});
-
 
Line 23... Line 19...
23
my $RCid = $user->{RCid};
19
my $cookie_string = authenticate (RollerCon::LEAD) || die;
24
my $RCAUTH_cookie = CGI::Cookie->new(-name=>'RCAUTH',-value=>"$cookie_string",-expires=>"+30m");
-
 
25
my $YEAR;
20
our ($EML, $PWD, $LVL) = split /&/, $cookie_string;
26
 
21
our $RCAUTH_cookie = CGI::Cookie->new (-name=>'RCAUTH', -value=>"$cookie_string", -expires=>"+30m");
27
my $pageTitle = "User Report";
22
 
28
my $prefscookie = "userreport";
23
my $pageTitle = "User Report";
29
our $DBTABLE = 'v_official';
24
our $DBTABLE = 'v_official';
30
my %COLUMNS = (
25
my %COLUMNS = (
31
# colname   =>  [qw(DisplayName       N    type     status)],   status ->  static | default | <blank>
26
# colname   =>  [qw(DisplayName       N    type     status)],   status ->  static | default | <blank>
32
	RCid         => [qw(ID           5    number       )],
27
  RCid         => [qw(ID           5    number       )],
33
	derby_name   => [qw(DerbyName   10    text        default )],
28
  derby_name   => [qw(DerbyName   10    text        default )],
34
	email        => [qw(Email       15    text        default )],
29
  email        => [qw(Email       15    text        default )],
35
	real_name    => [qw(FullName    20    text        default )],
30
  real_name    => [qw(FullName    20    text        default )],
36
	pronouns     => [qw(Pronouns    25    text        default )],
31
  pronouns     => [qw(Pronouns    25    text        default )],
37
	tshirt       => [qw(TShirtSize  30    select        default )],
32
  tshirt       => [qw(TShirtSize  30    select      default )],
38
  phone        => [qw(Phone       35    text                )],
33
  phone        => [qw(Phone       35    text                )],
39
	access       => [qw(vOrcAccess  40    select              )],
34
  access       => [qw(vOrcAccess  40    select              )],
40
	MVPid        => [qw(MVPPass     42    select              )],
35
  MVPid        => [qw(MVPPass     42    select              )],
41
	department   => [qw(Department  45    select      default )],
36
  department   => [qw(Department  45    select      default )],
Line -... Line 37...
-
 
37
  emt_verified => [qw(EMTVerified 46    select       )],
-
 
38
  added        => [qw(Added       50    date         )],
-
 
39
  last_login   => [qw(LastLogin   55    date         )] 
-
 
40
);
-
 
41
 
-
 
42
my $defaultWhere;
42
	emt_verified => [qw(EMTVerified 46    select       )],
43
if ($LVL < 4 and $ORCUSER->{department}->{VCI} < 2) {
43
	added        => [qw(Added       50    date         )],
44
  $defaultWhere = join " or ", map { 'department like "%'.$_.'%"' } grep { $ORCUSER->{department}->{$_} >= 2 } keys %{$ORCUSER->{department}};
Line 44... Line -...
44
	last_login   => [qw(LastLogin   55    date         )]	
-
 
45
);
-
 
46
 
-
 
47
my $ROLE = getAccessLevels;
-
 
48
my $DepartmentNames = getDepartments ();
45
  $defaultWhere = "($defaultWhere)";
49
 
46
}
50
my $stylesheet = "/style.css";
47
 
Line 51... Line -...
51
my $homeURL = '/schedule/';
-
 
52
my @pagelimitoptions = ("All", 5, 10, 25);
-
 
53
 
-
 
54
# If we need to modify line item values, create a subroutine named "modify_$columnname"
-
 
55
#    It will receive a hashref to the object lineitem
-
 
56
# You can also create specific "filter_column" subroutines...
-
 
57
 
-
 
58
#sub modify_RCid {
48
my $ROLE = getAccessLevels;
59
#  my $li = shift // "";
49
my $DepartmentNames = getDepartments ();
60
#  return join "&nbsp;", $li->{RCid},
50
 
61
#         $h->a ({ href=>"view_user.pl?RCid=$li->{RCid}" }, "[Edit]"),
51
# If we need to modify line item values, create a subroutine named "modify_$columnname"
62
#  ; 
52
#    It will receive a hashref to the object lineitem
Line 89... Line 79...
89
  return "" unless exists convertDepartments($li->{"department"})->{EMT};
79
  return "" unless exists convertDepartments($li->{"department"})->{EMT};
Line 90... Line 80...
90
  
80
  
91
  return $li->{"emt_verified"} ? "True" : "False";
81
  return $li->{"emt_verified"} ? "True" : "False";
Line -... Line 82...
-
 
82
}
-
 
83
 
-
 
84
# If we need to modify how a filter works, create a subroutine named "filter_$columnname"
92
}
85
#    It will receive two fields, the field name and the current filter value (if any)
93
 
86
 
94
sub filter_department {
87
sub filter_department {
Line 95... Line 88...
95
  my $colName = shift;
88
  my $colName = shift;
96
  my $filter = shift // "";
89
  my $filter = shift // "";
97
  
90
  
98
	if ($filter)	{
91
  if ($filter)  {
99
		if ($filter eq "-blank-") {
92
    if ($filter eq "-blank-") {
-
 
93
      return "($colName = '' or isNull($colName) = 1)";
100
			return "($colName = '' or isNull($colName) = 1)";
94
    }
101
		}
95
    
102
		
96
    no strict;
103
		if ($filtered_by_access ne "") {
97
    if ($filtered_by_access ne "") {
104
		  return "$colName like \"%$filter-$filtered_by_access%\"";
98
      return "$colName like \"%$filter-$filtered_by_access%\"";
105
		} else {
99
    } else {
106
		  return "$colName like \"%$filter%\"";
100
      return "$colName like \"%$filter%\"";
-
 
101
    }
-
 
102
  } else {
107
		}
103
    my @options = ();
108
	} else {
104
    my $tmpFormValue = param ("filter-".$colName);
Line 109... Line 105...
109
    my @options = ("");
105
    
110
    push @options, "-blank-" unless $LVL < 4;
106
    push @options, "-blank-" unless $LVL < 4;
111
    push @options, ($LVL < 4 and $ORCUSER->{department}->{VCI} < 2) ? grep { $ORCUSER->{department}->{$_} >= 2 } sort keys %{$ORCUSER->{department}} : sort keys %{$DepartmentNames};
107
    push @options, ($LVL < 4 and $ORCUSER->{department}->{VCI} < 2) ? grep { $ORCUSER->{department}->{$_} >= 2 } sort keys %{$ORCUSER->{department}} : sort keys %{$DepartmentNames};
Line -... Line 108...
-
 
108
    
-
 
109
    @options = map { $tmpFormValue eq $_ ?
112
    
110
                       ( $h->option ({ selected=>[], value=>$_ }, $_ eq "-blank-" ? $_ : $DepartmentNames->{$_}) ) :
113
    @options = map { $FORM{"filter-department"} eq $_ ?
111
                       ( $h->option ({ value=>$_ },               $_ eq "-blank-" ? $_ : $DepartmentNames->{$_}) )  } @options;
114
                       ( $h->option ({ selected=>[], value=>$_ }, $_ eq "-blank-" ? $_ : $DepartmentNames->{$_}) ) :
112
    
Line 115... Line 113...
115
                       ( $h->option ({ value=>$_ },               $_ eq "-blank-" ? $_ : $DepartmentNames->{$_}) )  } @options;
113
    unshift @options, $tmpFormValue eq "" ? "<option selected></option>" : "<option></option>";
116
    
114
    
117
    return $FORM{autoload} ? $h->select ({ name=>"filter-department", onChange=>"page.value = 1; submit();" }, [@options]) : $h->select ({ name=>"filter-department" }, [$h->option (), @options]);
115
    return param ("autoload") ? $h->select ({ name=>"filter-".$colName, onChange=>"page.value = 1; submit();" }, [@options]) : $h->select ({ name=>"filter-".$colName }, [$h->option (), @options]);
118
  }
116
  }
Line 119... Line 117...
119
}
117
}
120
 
118
 
121
our $filtered_by_access = "";
119
our $filtered_by_access = "";
122
sub filter_access {
120
sub filter_access {
123
  my $colName = shift;
121
  my $colName = shift;
-
 
122
  my $filter = shift // "";
Line 124... Line 123...
124
  my $filter = shift // "";
123
  
125
  
124
  if ($filter ne "")  {
126
	if ($filter ne "")	{
125
    $filtered_by_access = $filter;
Line -... Line 126...
-
 
126
    return $filter eq "-1" ? "$colName = $filter" : "($colName = $filter or department like '%$filter%')";
-
 
127
  } else {
127
	  $filtered_by_access = $filter;
128
    my @options = (-1, 0, 1, 2, 3, 4, 5);
128
		return $filter eq "-1" ? "$colName = $filter" : "($colName = $filter or department like '%$filter%')";
129
    my $tmpFormValue = param ("filter-".$colName);
129
	} else {
130
    
Line 130... Line 131...
130
    my @options = ("", -1, 0, 1, 2, 3, 4, 5);
131
    @options = map { $tmpFormValue eq $_ ?
131
    
132
                       ( $h->option ({ selected=>[], value=>$_ }, $ROLE->{$_}) ) :
132
    @options = map { $FORM{"filter-access"} eq $_ ?
133
                       ( $h->option ({ value=>$_ },               $ROLE->{$_}) )  } @options;
Line 133... Line 134...
133
                       ( $h->option ({ selected=>[], value=>$_ }, $ROLE->{$_}) ) :
134
    
134
                       ( $h->option ({ value=>$_ },               $ROLE->{$_}) )  } @options;
135
    unshift @options, $tmpFormValue eq "" ? "<option selected></option>" : "<option></option>";
135
    
136
    
136
    return $FORM{autoload} ? $h->select ({ name=>"filter-access", onChange=>"page.value = 1; submit();" }, [@options]) : $h->select ({ name=>"filter-access" }, [$h->option (), @options]);
137
    return param ("autoload") ? $h->select ({ name=>"filter-".$colName, onChange=>"page.value = 1; submit();" }, [@options]) : $h->select ({ name=>"filter-".$colName }, [$h->option (), @options]);
137
  }
138
  }
138
}
-
 
Line 139... Line 139...
139
 
139
}
140
sub filter_MVPid {
140
 
141
  my $colName = shift;
141
sub filter_MVPid {
Line 142... Line 142...
142
  my $filter = shift // "";
142
  my $colName = shift;
143
  
143
  my $filter = shift // "";
144
	if ($filter)	{
144
  
Line 145... Line 145...
145
		return $filter =~ /^R-/ ? "$colName = '$filter'" : $filter eq "pass" ? "isnull($colName) = 0" : "isnull($colName) = 1";
145
  if ($filter)  {
146
	} else {
146
    return $filter =~ /^R-/ ? "$colName = '$filter'" : $filter eq "pass" ? "isnull($colName) = 0" : "isnull($colName) = 1";
147
    my @options = ("", "pass", "no pass");
147
  } else {
Line 148... Line 148...
148
    my $dbh = getRCDBH;
148
    my @options = ("", "pass", "no pass");
149
    push @options, map { @{$_} } @{$dbh->selectall_arrayref ("select MVPid from RCid_ticket_link where year = year(now()) order by MVPid")};
149
    my $tmpFormValue = param ("filter-".$colName);
150
    
150
    
151
    @options = map { $FORM{"filter-MVPid"} eq $_ ?
151
    @options = map { $tmpFormValue eq $_ ?
-
 
152
                       ( $h->option ({ selected=>[] }, $_) ) :
Line 152... Line 153...
152
                       ( $h->option ({ selected=>[] }, $_) ) :
153
                       ( $h->option (                  $_) )  } @options;
153
                       ( $h->option (                  $_) )  } @options;
154
    
154
    
155
    return param ("autoload") ? $h->select ({ name=>"filter-".$colName, onChange=>"page.value = 1; submit();" }, [@options]) : $h->select ({ name=>"filter-".$colName }, [$h->option (), @options]);
Line 155... Line 156...
155
    return $FORM{autoload} ? $h->select ({ name=>"filter-MVPid", onChange=>"page.value = 1; submit();" }, [@options]) : $h->select ({ name=>"filter-MVPid" }, [$h->option (), @options]);
156
  }
156
  }
157
}
157
}
158
 
Line 158... Line -...
158
 
-
 
159
sub filter_emt_verified {
-
 
160
  my $colName = shift;
-
 
161
  my $filter = shift // "";
-
 
162
  
-
 
163
	if ($filter ne "")	{
-
 
164
		return join " and ", "department like '%EMT%'", $filter eq "True" ? "$colName = 1" : "$colName = 0";
-
 
165
	} else {
-
 
166
    my @options = ("", "True", "False");
-
 
167
    
-
 
168
    @options = map { $FORM{"filter-".$colName} eq $_ ?
-
 
169
                       ( $h->option ({ selected=>[] }, $_) ) :
-
 
170
                       ( $h->option (                  $_) )  } @options;
-
 
171
    
-
 
172
    return $FORM{autoload} ? $h->select ({ name=>"filter-".$colName, onChange=>"page.value = 1; submit();" }, [@options]) : $h->select ({ name=>"filter-".$colName }, [$h->option (), @options]);
-
 
173
  }
-
 
174
}
-
 
175
 
-
 
176
 
-
 
177
# Ideally, nothing below this comment needs to change
-
 
178
#-------------------------------------------------------------------------------
-
 
179
 
-
 
180
 
-
 
181
our %NAME              = map  { $_ => $COLUMNS{$_}->[0] } keys %COLUMNS;
-
 
182
our %colOrderHash      = map  { $_ => $COLUMNS{$_}->[1] } keys %COLUMNS;
-
 
183
our %colFilterTypeHash = map  { $_ => $COLUMNS{$_}->[2] } keys %COLUMNS;
-
 
184
our @staticFields      = sort byfield grep { $COLUMNS{$_}->[3] eq 'static' } keys %COLUMNS;
-
 
185
our @defaultFields     = sort byfield grep { defined $COLUMNS{$_}->[3] } keys %COLUMNS;
-
 
186
#our @defaultFields     = grep { $COLUMNS{$_}->[3] eq 'default' or inArray ($_, \@staticFields) } keys %COLUMNS;
-
 
187
 
-
 
188
our @allFields = sort byfield keys %NAME;
-
 
189
our @displayFields = ();
-
 
190
our @hideFields = ();
-
 
191
my $QUERY_STRING;
-
 
192
 
-
 
193
my $pagelimit = param ("limit") // $pagelimitoptions[$#pagelimitoptions];
-
 
194
my $curpage = param ("page") // 1;
-
 
195
 
-
 
196
our %FORM;
-
 
197
my $FILTER;
-
 
198
foreach (param()) {
-
 
199
 	if (/^year$/) { #
-
 
200
		$YEAR = param($_);
-
 
201
		next;
-
 
202
	}
-
 
203
 
-
 
204
	$FORM{$_} = param($_);				# Retrieve all of the FORM data submitted
-
 
205
	#warn "$_: $FORM{$_}";
-
 
206
	
-
 
207
	if ((/^filter/) and ($FORM{$_} ne '')) {	# Build a set of filters to apply
-
 
208
		my ($filter,$field) = split /-/, $_;		
-
 
209
		$FILTER->{$field} = $FORM{$_} unless notInArray ($field, \@allFields);
-
 
210
	}	elsif ($FORM{$_} eq "true")			# Compile list of fields to display
-
 
211
		{ push @displayFields, $_; }
-
 
212
}
-
 
213
 
-
 
214
if (exists $FORM{autoload})	{			# If the FORM was submitted (i.e. the page is being redisplayed),
-
 
215
							                    #  	build the data for the cookie that remembers the page setup
-
 
216
	my $disFields = join ":", @displayFields;
-
 
217
	my $fils = join ":", map { "$_=$FILTER->{$_}" } keys %{$FILTER};
-
 
218
		
-
 
219
	$QUERY_STRING = $disFields.'&'.$fils.'&'.$FORM{sortby}.'&'.$FORM{autoload};
-
 
220
}
-
 
221
 
-
 
222
if (!(exists $FORM{autoload}))	{			# No FORM was submitted...
-
 
223
	if (my $prefs = cookie ($prefscookie) and !defined param ("ignoreCookie"))	{ # Check for cookies from previous visits.
-
 
224
		my ($disF, $filts, $sb, $al) = split /&/,$prefs;
-
 
225
		@displayFields = split /:/,$disF;
-
 
226
		
-
 
227
		foreach my $pair (split /:/, $filts)	{
-
 
228
			my ($key, $value) = split /=/, $pair;
-
 
229
			$FORM{"filter-$key"} = $value;
-
 
230
			$FILTER->{$key} = $value;
159
sub filter_emt_verified {
231
		}
-
 
232
		
-
 
233
		$FORM{sortby} = $sb;
-
 
234
		$FORM{autoload} = $al;
-
 
235
		$QUERY_STRING = $prefs;
-
 
236
	}	else {
-
 
237
	  @displayFields = @defaultFields; # Otherwise suppply a default list of columns.
-
 
238
	  $FORM{autoload} = 1;             # And turn aut0load on by default.
-
 
239
	} 
-
 
240
}
-
 
241
 
-
 
242
# let's just make sure the columns are in the right order (and there aren't any missing)
-
 
243
@displayFields = grep { inArray($_, \@allFields) } sort byfield uniq @displayFields, @staticFields;
-
 
244
 
-
 
245
# If the field isn't in the displayFields list,	then add it to the hideFields list
-
 
246
@hideFields = grep { notInArray ($_, \@displayFields) } @allFields;
-
 
247
 
-
 
248
# Process any filters provided in the form to pass to the database
-
 
249
my @whereClause = map { filter ($_, $FILTER->{$_}) } grep { defined $FILTER->{$_} } @displayFields;
-
 
250
#warn @whereClause;
-
 
251
if ($LVL < 4 and $ORCUSER->{department}->{VCI} < 2) {
-
 
252
#  warn keys %{$ORCUSER->{department}};
-
 
253
  my $string = join " or ", map { 'department like "%'.$_.'%"' } grep { $ORCUSER->{department}->{$_} >= 2 } keys %{$ORCUSER->{department}};
-
 
254
  $string = "($string)";
-
 
255
#  warn $string;
-
 
256
  push @whereClause, $string;
-
 
257
}
-
 
258
#push @whereClause, "year(date) = '$YEAR'";
-
 
259
 
-
 
260
 
-
 
261
							#  Given the fields to display and the where conditions,
-
 
262
							#	  "getData" will return a reference to an array of
-
 
263
							#	  hash references of the results.
-
 
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;
-
 
274
}
-
 
275
 
-
 
276
my $signedOnAs = $username ? "Welcome, $username. ".$h->a ({ href=>"index.pl?LOGOUT" }, "[Log Out]") : "You are not signed in.";
-
 
277
 
-
 
278
# Set some cookie stuff...
-
 
279
my $path = `dirname $ENV{SCRIPT_NAME}`; chomp $path; $path .= '/' unless $path eq "/";
-
 
280
my $queryCookie = cookie(-NAME=>$prefscookie,
-
 
281
			-VALUE=>"$QUERY_STRING",
160
  my $colName = shift;
282
			-PATH=>"$path",
-
 
283
			-EXPIRES=>'+365d');
-
 
284
 
-
 
285
# Print the header
-
 
286
print header (-cookie=> [ $queryCookie, $RCAUTH_cookie ] );
-
 
287
 
-
 
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";
-
 
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
#------------------
-
 
304
 
-
 
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
    ]);
-
 
316
  $refreshbutton = "";
-
 
317
  $sortby = $h->select ({name=>"sortby", onChange=>'submit();' }, [ map { $FORM{sortby} eq $_ ? $h->option ({ value=>$_, selected=>[] }, $NAME{$_}) : $h->option ({ value=>$_ }, $NAME{$_}) } @displayFields ]);
-
 
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
    ]);
-
 
326
  $refreshbutton = $h->input ({ type=>"button", value=>"Refresh", onClick=>"submit(); return false;" });
-
 
327
  $sortby = $h->select ({name=>"sortby" }, [ map { $FORM{sortby} eq $_ ? $h->option ({ value=>$_, selected=>[] }, $NAME{$_}) : $h->option ({ value=>$_ }, $NAME{$_}) } @displayFields ]);
-
 
328
}
-
 
329
 
-
 
330
 
-
 
331
 
-
 
332
	 
-
 
333
print start_html (-title => $pageTitle, -style => {'src' => $stylesheet} );
-
 
334
 
-
 
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" }, [
161
  my $filter = shift // "";
340
    $h->div ({ class=>"spLeft" }, [
-
 
341
      $radiobutton
162
  
342
    ]),
-
 
343
    $h->div ({ class=>"spRight" }, [
-
 
344
      $h->input ({ type=>"button", value=>"Home", onClick=>"window.location.href=".$homeURL }),
-
 
345
      $refreshbutton
-
 
346
    ]),
-
 
347
  ]),
-
 
348
]);
-
 
349
 
-
 
350
# Print the Hidden fields' check boxes (if there are any)
-
 
351
 
-
 
352
my $c = 1;
-
 
353
my @hiddencheckboxes;
-
 
354
my @hiddenrows;
-
 
Line 355... Line -...
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;
-
 
367
 
-
 
368
 
163
  if ($filter ne "")  {
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" }, [
-
 
377
      $signedOnAs
-
 
378
    ])
-
 
379
  ]);
-
 
380
}
-
 
381
 
-
 
382
# Print the main table...............................................
-
 
383
 
-
 
384
print $h->open ('div', { class=>'rTable' });
-
 
385
 
-
 
386
my @tmptitlerow;
164
    return join " and ", "department like '%EMT%'", $filter eq "True" ? "$colName = 1" : "$colName = 0";
Line 387... Line -...
387
foreach my $f (@displayFields)	{  # Print the Column headings
-
 
388
  if (inArray ($f, \@staticFields)) {
-
 
389
    push @tmptitlerow, $h->div ({ class=>'rTableHead' }, [ $h->input ({ type=>"hidden", name=>$f, value=>"true" }), $NAME{$f} ]);
-
 
390
  } else {
-
 
391
    if ($FORM{autoload}) {
-
 
392
      push @tmptitlerow, $h->div ({ class=>'rTableHead', onClick=>"Req.$f.click();" }, [ $h->input ({ type=>"checkbox", class=>"accent", name=>$f, value=>"true", checked=>[], onClick=>'event.stopPropagation(); submit();' }), $NAME{$f} ]);
-
 
393
    } else {
-
 
394
      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} ]);      
-
 
395
    }
-
 
396
  }
-
 
397
}
-
 
398
 
-
 
399
# Print the filter boxes...
-
 
400
print $h->div ({ class=>'rTableHeading' }, [ @tmptitlerow ], [ map { $h->div ({ class=>'rTableCell filters' }, filter ($_)) } @displayFields ], $h->div ({ class=>"rTableCell" }));
-
 
401
 
165
  } else {
402
# Print the things
-
 
403
foreach my $t (@ProductList)	{
-
 
404
  print $h->div ({ class=>'rTableRow shaded', onClick=>"location.href='view_user.pl?RCid=$t->{RCid}'" }, [ map { $h->div ({ class=>'rTableCell' }, exists &{"modify_".$_} ? &{"modify_".$_} ($t) : $t->{$_} ? $t->{$_} : "") } @displayFields ]);
-
 
405
}
-
 
406
 
-
 
407
print $h->close ('div');
-
 
408
 
166
    my @options = ("", "True", "False");
409
# close things out................................................
167
    my $tmpFormValue = param ("filter-".$colName);
410
 
168
    
411
my $pages = $pagelimit eq "All" ? 1 : int( $datacount / $pagelimit + 0.99 );
-
 
412
if ($curpage > $pages) { $curpage = $pages; }
-
 
413
 
-
 
414
my @pagerange;
-
 
415
if ($pages <= 5 ) {
-
 
416
  @pagerange = 1 .. $pages;
-
 
417
} else {  
-
 
418
  if ($curpage <= 3) {
169
    @options = map { $tmpFormValue eq $_ ?
419
    @pagerange = (1, 2, 3, 4, ">>");
-
 
420
  } elsif ($curpage >= $pages - 2) {
-
 
421
    @pagerange = ("<<", $pages-3, $pages-2, $pages-1, $pages);
-
 
422
  } else {
-
 
423
    @pagerange = ("<<", $curpage-1, $curpage, $curpage+1, ">>");
-
 
424
  }
-
 
425
}
-
 
426
 
170
                       ( $h->option ({ selected=>[] }, $_) ) :
427
print $h->br; # print $h->br;
-
 
428
print $h->div ({ class=>"sp0" }, [
-
 
429
    $h->div ({ class=>"spLeft" }, [
-
 
430
      $h->div ({ class=>"footer" }, [
-
 
431
        "To bookmark, save, or send this exact view, use the ",
-
 
432
        $h->a ({ href=>'', onClick=>"window.document.Req.method = 'GET'; Req.submit(); return false;" }, "[Full URL]"),
171
                       ( $h->option (                  $_) )  } @options;
433
        $h->br,
172
    
434
        "If this page is displaying oddly, ", $h->a ({ href=>url ()."?ignoreCookie=1" }, "[Reset Your View]"),
-
 
435
        $h->br,
-
 
436
        $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.]"),
-
 
437
        $h->br,
-
 
438
        "This page was displayed on ", currentTime (),
-
 
439
        $h->br,
-
 
440
        "Please direct questions, problems, and concerns to $SYSTEM_EMAIL"
-
 
441
      ])
-
 
442
    ]),
-
 
443
    $h->div ({ class=>"spRight" }, [
-
 
444
      $h->h5 ([
-
 
445
               "$x of $datacount Record". ($x == 1 ? "" : "s") ." Displayed", $h->br,               
-
 
446
               "Sorted by ", $sortby, $h->br,
-
 
447
               "Displaying ", $h->select ({ name=>"limit", onChange=>"page.value = 1; submit();" }, [ map { $pagelimit == $_ ? $h->option ({ selected=>[] }, $_) : $h->option ($_) } @pagelimitoptions ]), " Per Page", $h->br,
-
 
Line 448... Line -...
448
               ( $pages > 1 ? ( join " ", map { $_ == $curpage ? "<B>$_</b>" :
-
 
449
                                                $_ eq "<<"     ? $h->a ({ onClick=>qq{Req.page.value=1; Req.submit();} }, "$_") :
-
 
450
                                                $_ eq ">>"     ? $h->a ({ onClick=>qq{Req.page.value=$pages; Req.submit();} }, "$_") :
173
    return param ("autoload") ? $h->select ({ name=>"filter-".$colName, onChange=>"page.value = 1; submit();" }, [@options]) : $h->select ({ name=>"filter-".$colName }, [$h->option (), @options]);