Subversion Repositories VORC

Rev

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