Subversion Repositories VORC

Rev

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

Rev 140 Rev 196
Line 18... Line 18...
18
use DateTime;
18
use DateTime;
19
use DateTime::Duration;
19
use DateTime::Duration;
20
my $now = DateTime->now (time_zone => 'America/Los_Angeles');
20
my $now = DateTime->now (time_zone => 'America/Los_Angeles');
Line 21... Line 21...
21
 
21
 
22
my $cookie_string = authenticate (1) || die;
-
 
23
# Add checking to make sure they're in this department
22
my $cookie_string = authenticate (1) || die;
24
our ($EML, $PWD, $LVL) = split /&/, $cookie_string;
-
 
25
my $user = getUser ($EML);
23
our ($EML, $PWD, $LVL) = split /&/, $cookie_string;
Line -... Line 24...
-
 
24
my $RCAUTH_cookie = CGI::Cookie->new (-name=>'RCAUTH', -value=>"$cookie_string", -expires=>"+30m");
26
$user->{department} = convertDepartments $user->{department};
25
 
27
 
-
 
28
if ($user->{department}->{"ANN"} < 1 and $LVL < 4) {
26
# Add checking to make sure they're in this department
29
  no strict;
27
if ($ORCUSER->{department}->{"ANN"} < 1 and $LVL < 4 and $ORCUSER->{department}->{"VCI"} < 2) {
30
	print header(-cookie=>$RCAUTH_cookie);
28
  print header (-cookie=>$RCAUTH_cookie);
31
	printRCHeader("Unauthorized Page");
29
  printRCHeader ("Unauthorized Page");
32
	print $h->div ({ class=>"error" }, "You're not an Announcer");
30
  print $h->div ({ class=>"error" }, "You're not an Announcer");
33
	print $h->div ("Your user account is not registered as an Announcer, so you can't see these shifts.  It's possible that your access is still being reviewed.  Please be patient.");
31
  print $h->div ("Your user account is not registered as an Announcer, so you can't see these shifts.  It's possible that your access is still being reviewed.  Please be patient."), $h->br;
34
	print $h->a ({ href=>"/schedule/" }, "[Go Home]");
32
  print $h->button ({ onClick=>"window.location.href='/schedule/';" }, "Home");
35
	print $h->close ("html");
33
  print $h->close ("html");
Line 36... Line 34...
36
	exit;	
34
  exit; 
37
}
35
}
38
 
-
 
39
my $username = $h->a ({ href=>"/schedule/view_user.pl?submit=View&RCid=$user->{RCid}" }, $user->{derby_name});
-
 
40
my $RCid = $user->{RCid};
-
 
41
my $RCAUTH_cookie = CGI::Cookie->new(-name=>'RCAUTH',-value=>"$cookie_string",-expires=>"+30m");
-
 
42
#my $YEAR = 1900 + (localtime)[5]; #which year of data to display, default to current
-
 
Line 43... Line 36...
43
my $YEAR = 1900 + (localtime)[5];
36
 
44
 
-
 
45
#$LVL = 1;
37
my $username = $h->a ({ href=>"/schedule/view_user.pl?submit=View&RCid=$ORCUSER->{RCid}" }, $ORCUSER->{derby_name});
46
 
38
my $RCid = $ORCUSER->{RCid};
47
my $pageTitle = "Announcer Shifts";
39
 
48
my $prefscookie = "ashiftscookie";
40
my $pageTitle = "Announcer Shifts";
49
our $DBTABLE = 'v_shift_announcer';
41
our $DBTABLE = 'v_shift_announcer';
50
my %COLUMNS = (
42
my %COLUMNS = (
51
# colname   =>  [qw(DisplayName       N    type     status)],   status ->  static | default | <blank>
43
# colname   =>  [qw(DisplayName       N    type     status)],   status ->  static | default | <blank>
52
	id						 => [qw(ID           5    number            )],
44
  id             => [qw(ID           5    number            )],
53
	date					 => [qw(Date        10    date      default )],
45
  date           => [qw(Date        10    date      default )],
54
	dayofweek			 => [qw(Day         15    select            )],
46
  dayofweek      => [qw(Day         15    select            )],
55
	time					 => [qw(Time        20    text      default )],
47
  time           => [qw(Time        20    text      default )],
56
	volhours       => [qw(VolHours    23    number            )],
48
  volhours       => [qw(VolHours    23    number            )],
57
	track					 => [qw(Track       25    select    default )],
49
  track          => [qw(Track       25    select    default )],
58
	teams					 => [qw(Teams       30    text      default )],
50
  teams          => [qw(Teams       30    text      default )],
59
	level					 => [qw(Level       35    select    default )],
51
  level          => [qw(Level       35    select    default )],
60
	restrictions   => [qw(Rs          40    select            )],
52
  restrictions   => [qw(Rs          40    select            )],
61
	gtype					 => [qw(Type        45    select    default )],
53
  gtype          => [qw(Type        45    select    default )],
62
	signup				 => [qw(SignUp      46    select            )],
54
  signup         => [qw(SignUp      46    select            )],
63
	notes  				 => [qw(Notes       50    text              )],
55
  notes          => [qw(Notes       50    text              )],
64
	role					 => [qw(Role        55    select            )],
56
  role           => [qw(Role        55    select            )],
65
	tla						 => [qw(TLA         60    select    default )],
57
  tla            => [qw(TLA         60    select    default )],
66
	name					 => [qw(Position    65    text              )],
58
  name           => [qw(Position    65    text              )],
Line 67... Line 59...
67
	type					 => [qw(Class       70    select    default )],
59
  type           => [qw(Class       70    select    default )],
68
	RCid					 => [qw(RCid        75    number            )],
-
 
69
	derby_name     => [qw(Assignee    80    select    default )]
60
  RCid           => [qw(RCid        75    number            )],
70
);
-
 
71
 
61
  derby_name     => [qw(Assignee    80    select    default )]
72
if ($user->{department}->{"ANN"} > 1) {
62
);
73
# Add:
63
 
Line 74... Line -...
74
#		real_name			 RealName
-
 
75
#		email					 Email
-
 
76
  $COLUMNS{'real_name'} = [qw(RealName    85    text)];
-
 
77
  $COLUMNS{'email'}     = [qw(Email       90    text)];
-
 
78
}
64
if ($ORCUSER->{department}->{"ANN"} > 1 or $LVL >= 4 or $ORCUSER->{department}->{"VCI"} >= 2) {
79
 
65
  # Announcer Leads (and higher) can see a couple of extra fields
Line 80... Line 66...
80
my $stylesheet = "/style.css";
66
  $COLUMNS{'real_name'} = [qw(RealName    85    text)];
81
my $homeURL = '/schedule/';
67
  $COLUMNS{'email'}     = [qw(Email       90    text)];
82
my @pagelimitoptions = ("All", 5, 10, 25);
68
}
83
 
69
 
84
# If we need to modify line item values, create a subroutine named "modify_$columnname"
70
# If we need to modify line item values, create a subroutine named "modify_$columnname"
85
#    It will receive a hashref to the object lineitem (RETURN the modified field at the end of the function!)
71
#    It will receive a hashref to the object lineitem (RETURN the modified field at the end of the function!)
Line 86... Line 72...
86
 
72
 
87
sub modify_derby_name {
73
sub modify_derby_name {
88
  my $t = shift;  
74
  my $t = shift;  
89
 
75
  
90
  if ($user->{department}->{"ANN"} < 2 and $t->{derby_name} and $t->{RCid} != $RCid and $LVL < 5) {
76
  if ($ORCUSER->{department}->{"ANN"} < 2 and $t->{derby_name} and $t->{RCid} != $RCid and $LVL < 5) {
91
    $t->{derby_name} = "FILLED" unless getUser($t->{RCid})->{showme};
77
    $t->{derby_name} = "FILLED" unless getUser($t->{RCid})->{showme};
92
  }
78
  }
93
  
79
  
94
 	my ($yyyy, $mm, $dd) = split /\-/, $t->{date};
80
  my ($yyyy, $mm, $dd) = split /\-/, $t->{date};
95
	my $cutoff = DateTime->new(
81
  my $cutoff = DateTime->new(
96
        year => $yyyy,
82
        year => $yyyy,
97
        month => $mm,
83
        month => $mm,
98
        day => $dd,
84
        day => $dd,
99
        hour => 5,
85
        hour => 5,
100
        minute => 0,
86
        minute => 0,
101
        second => 0,
87
        second => 0,
102
        time_zone => 'America/Los_Angeles'
88
        time_zone => 'America/Los_Angeles'
103
  );
89
  );
104
 
90
  
105
 	if (($t->{RCid} == $RCid and $t->{signup} ne "selected" and $now < $cutoff) or ($t->{derby_name} and ($user->{department}->{"ANN"} >= 2 or $LVL >= 5))) {
91
  if (($t->{RCid} == $RCid and $t->{signup} ne "selected" and $now < $cutoff) or ($t->{derby_name} and ($ORCUSER->{department}->{"ANN"} >= 2 or $LVL >= 5))) {
106
 		# DROP
92
    # DROP
107
 		$t->{derby_name} = "$t->{derby_name} <A HREF='#' onClick=\"window.open('make_shift_change.pl?change=del&RCid=$t->{RCid}&id=$t->{id}&role=$t->{role}','Confirm Shift Change','resizable,height=260,width=370'); return false;\">[DROP]</a>";
93
    $t->{derby_name} = "$t->{derby_name} <A HREF='#' onClick=\"window.open('make_shift_change.pl?change=del&RCid=$t->{RCid}&id=$t->{id}&role=$t->{role}','Confirm Shift Change','resizable,height=260,width=370'); return false;\">[DROP]</a>";
108
 		if ($user->{department}->{"ANN"} >= 2 or $LVL > 4) {
94
    if ($ORCUSER->{department}->{"ANN"} >= 2 or $LVL > 4) {
109
 		  # NO SHOW
95
      # NO SHOW
110
 		  $t->{derby_name} .= " | <A HREF='#' onClick=\"if (confirm('Really? They were a no show?')==true) { window.open('make_shift_change.pl?noshow=true&change=del&RCid=$t->{RCid}&id=$t->{id}&role=$t->{role}','Confirm Shift Change','resizable,height=260,width=370'); return false; }\">[NO SHOW]</a>";
96
      $t->{derby_name} .= " | <A HREF='#' onClick=\"if (confirm('Really? They were a no show?')==true) { window.open('make_shift_change.pl?noshow=true&change=del&RCid=$t->{RCid}&id=$t->{id}&role=$t->{role}','Confirm Shift Change','resizable,height=260,width=370'); return false; }\">[NO SHOW]</a>";
111
 		}
97
    }
112
 	} elsif (!$t->{derby_name}) {
98
  } elsif (!$t->{derby_name}) {
113
 		$t->{dept} = "ANN";
99
    $t->{dept} = "ANN";
114
 		if ($t->{track} eq "C3" or $t->{track} eq "C5") {
100
    if ($t->{track} eq "C3" or $t->{track} eq "C5") {
115
 			return "*no announcers*";
101
      return "*no announcers*";
116
 		}
102
    }
117
 	  if (findConflict ($ORCUSER->{RCid}, $t->{id}, "game")) {
103
    if (findConflict ($ORCUSER->{RCid}, $t->{id}, "game")) {
118
      $t->{derby_name} .= "*schedule conflict*";
104
      $t->{derby_name} .= "*schedule conflict*";
119
    } elsif (signUpEligible ($ORCUSER, $t) and $now < $cutoff) {
105
    } elsif (signUpEligible ($ORCUSER, $t) and $now < $cutoff) {
120
 			# SIGN UP
106
      # SIGN UP
121
 			$t->{derby_name} = "<A HREF='#' onClick=\"window.open('make_shift_change.pl?change=add&RCid=$RCid&id=$t->{id}&role=$t->{role}','Confirm Shift Change','resizable,height=260,width=370'); return false;\">[SIGN UP]</a>";
107
      $t->{derby_name} = "<A HREF='#' onClick=\"window.open('make_shift_change.pl?change=add&RCid=$RCid&id=$t->{id}&role=$t->{role}','Confirm Shift Change','resizable,height=260,width=370'); return false;\">[SIGN UP]</a>";
122
 		}
108
    }
Line 123... Line 109...
123
 		if ($user->{department}->{"ANN"} >= 2 or $LVL > 4) {
109
    if ($ORCUSER->{department}->{"ANN"} >= 2 or $LVL > 4) {
124
 			# ADD USER
110
      # ADD USER
125
 			$t->{derby_name} ? $t->{derby_name} .= " | " : {};
111
      $t->{derby_name} ? $t->{derby_name} .= " | " : {};
126
 			$t->{derby_name} .= "<A HREF='#' onClick=\"window.open('make_shift_change.pl?change=lookup&RCid=$RCid&id=$t->{id}&role=$t->{role}','Confirm Shift Change','resizable,height=260,width=370'); return false;\">[ADD USER]</a>";
112
      $t->{derby_name} .= "<A HREF='#' onClick=\"window.open('make_shift_change.pl?change=lookup&RCid=$RCid&id=$t->{id}&role=$t->{role}','Confirm Shift Change','resizable,height=260,width=370'); return false;\">[ADD USER]</a>";
Line -... Line 113...
-
 
113
    }
-
 
114
  }
Line -... Line 115...
-
 
115
  return $t->{derby_name};
-
 
116
}
-
 
117
 
-
 
118
sub modify_time {
-
 
119
  my $t = shift;
-
 
120
  return convertTime $t->{time};
-
 
121
}
-
 
122
 
-
 
123
# If we need to modify how a filter works, create a subroutine named "filter_$columnname"
-
 
124
#    It will receive two fields, the field name and the current filter value (if any)
-
 
125
 
-
 
126
# Uncomment and update if we want to enable clicking on a row to open a new page.
-
 
127
#
-
 
128
#sub addRowClick {
-
 
129
#  my $t = shift;
-
 
130
#  return "location.href='view_thing.pl?field=$t->{field}&choice=View'";
-
 
131
#}
-
 
132
 
Line 127... Line -...
127
 		}
-
 
128
 	}
-
 
129
 	return $t->{derby_name};
-
 
130
}
-
 
131
 
-
 
132
sub modify_time {
-
 
133
  my $t = shift;
-
 
134
  return convertTime $t->{time};
-
 
135
}
-
 
136
 
-
 
137
 
-
 
138
 
-
 
139
 
-
 
140
# Ideally, nothing below this comment needs to change
-
 
141
#-------------------------------------------------------------------------------
-
 
142
 
-
 
143
 
-
 
144
our %NAME              = map  { $_ => $COLUMNS{$_}->[0] } keys %COLUMNS;
-
 
145
our %colOrderHash      = map  { $_ => $COLUMNS{$_}->[1] } keys %COLUMNS;
-
 
146
our %colFilterTypeHash = map  { $_ => $COLUMNS{$_}->[2] } keys %COLUMNS;
-
 
147
our @staticFields      = sort byfield grep { $COLUMNS{$_}->[3] eq 'static' } keys %COLUMNS;
-
 
148
our @defaultFields     = sort byfield grep { defined $COLUMNS{$_}->[3] } keys %COLUMNS;
-
 
149
#our @defaultFields     = grep { $COLUMNS{$_}->[3] eq 'default' or inArray ($_, \@staticFields) } keys %COLUMNS;
-
 
150
 
-
 
151
our @allFields = sort byfield keys %NAME;
-
 
152
our @displayFields = ();
-
 
153
our @hideFields = ();
-
 
154
my $QUERY_STRING;
-
 
155
 
-
 
156
my $pagelimit = param ("limit") // $pagelimitoptions[$#pagelimitoptions];
-
 
157
my $curpage = param ("page") // 1;
-
 
158
 
-
 
159
our %FORM;
-
 
160
my $FILTER;
-
 
161
foreach (param()) {
-
 
162
	if (/^year$/) { #
-
 
163
		$YEAR = param($_);
-
 
164
		next;
-
 
165
	}
-
 
166
 
-
 
167
	$FORM{$_} = param($_);				# Retrieve all of the FORM data submitted
-
 
168
	
-
 
169
	if ((/^filter/) and ($FORM{$_} ne '')) {	# Build a set of filters to apply
-
 
170
		my ($filter,$field) = split /-/, $_;		
-
 
171
		$FILTER->{$field} = $FORM{$_} unless notInArray ($field, \@allFields);
-
 
172
	}	elsif ($FORM{$_} eq "true")	{		# Compile list of fields to display
-
 
173
	  if ($_ ne "shiftinclude") {
-
 
174
		  push @displayFields, $_;
-
 
175
		}
-
 
176
  }
-
 
177
}
-
 
178
 
-
 
179
my @addToWhereClause = ("year(date) = '$YEAR'", "type = 'announcer'", "track <> 'C3'");
-
 
180
 
-
 
181
if (exists $FORM{autoload})	{			# If the FORM was submitted (i.e. the page is being redisplayed),
-
 
182
							                    #  	build the data for the cookie that remembers the page setup
-
 
183
	my $disFields = join ":", @displayFields;
-
 
184
	my $fils = join ":", map { "$_=$FILTER->{$_}" } keys %{$FILTER};
-
 
185
		
-
 
186
	$QUERY_STRING = $disFields.'&'.$fils.'&'.$FORM{sortby}.'&'.$FORM{autoload}.'&'.$FORM{shiftinclude};
-
 
187
}
-
 
188
 
-
 
189
 
-
 
190
if (!(exists $FORM{autoload}))	{			# No FORM was submitted...
-
 
191
	if (my $prefs = cookie ($prefscookie) and !defined param ("ignoreCookie"))	{ # Check for cookies from previous visits.
-
 
192
		my ($disF, $filts, $sb, $al, $si) = split /&/, $prefs;
-
 
193
		@displayFields = split /:/,$disF;
-
 
194
		
-
 
195
		foreach my $pair (split /:/, $filts)	{
-
 
196
			my ($key, $value) = split /=/, $pair;
-
 
197
			$FORM{"filter-$key"} = $value;
-
 
198
			$FILTER->{$key} = $value;
-
 
199
		}
-
 
200
		
-
 
201
		$FORM{sortby} = $sb;
-
 
202
		$FORM{autoload} = $al;
-
 
203
		$FORM{shiftinclude} = $si;
-
 
204
		$QUERY_STRING = $prefs;
-
 
205
	}	else {
-
 
206
	  @displayFields = @defaultFields; # Otherwise suppply a default list of columns.
-
 
207
	  $FORM{autoload} = 1;             # And turn aut0load on by default.
-
 
208
	} 
-
 
209
}
-
 
210
 
-
 
211
# let's just make sure the columns are in the right order (and there aren't any missing)
-
 
212
@displayFields = sort byfield uniq @displayFields, @staticFields;
-
 
213
 
-
 
214
# If the field isn't in the displayFields list,	then add it to the hideFields list
-
 
215
@hideFields = grep { notInArray ($_, \@displayFields) } @allFields;
-
 
216
 
-
 
217
# Process any filters provided in the form to pass to the database
-
 
218
my @whereClause = map { filter ($_, $FILTER->{$_}) } grep { defined $FILTER->{$_} } @displayFields;
-
 
219
push @whereClause, @addToWhereClause;
-
 
220
 
-
 
221
							#  Given the fields to display and the where conditions,
-
 
222
							#	  "getData" will return a reference to an array of
-
 
223
							#	  hash references of the results.
-
 
224
my ($data, $datacount) = getData (\@displayFields, \@whereClause, $DBTABLE, $FORM{sortby}, $curpage, $pagelimit);
-
 
225
my @ProductList = @{ $data };
-
 
226
 
-
 
227
#my @ProductList = @{ getData (\@displayFields, \@whereClause, $DBTABLE, $FORM{sortby}, $curpage, $pagelimit) };
-
 
228
my $x = scalar @ProductList; # How many results were returned?
-
 
229
 
-
 
230
# If the user is trying to download the Excel file, send it to them and then exit out.
-
 
231
if ($FORM{excel}) {
-
 
232
  exportExcel (\@ProductList, "RC_Officiating_Shifts");
-
 
233
  exit;
-
 
234
}
-
 
235
 
-
 
236
my @shifts;
-
 
237
if ($FORM{shiftinclude} eq "true") {
-
 
238
  my @SIWhere = ("year(date) = '$YEAR'");
-
 
239
  push @SIWhere, "RCid = $ORCUSER->{RCid}";
-
 
240
  my ($d, $c) = getData (\@displayFields, \@SIWhere, $DBTABLE, $FORM{sortby});
-
 
241
  @shifts = @{ $d };
-
 
242
}
-
 
243
 
-
 
244
 
-
 
245
my $signedOnAs = $username ? "Welcome, $username. ".$h->a ({ href=>"index.pl?LOGOUT" }, "[Log Out]") : "You are not signed in.";
-
 
246
 
-
 
247
# Set some cookie stuff...
-
 
248
my $path = `dirname $ENV{SCRIPT_NAME}`; chomp $path; $path .= '/' unless $path eq "/";
-
 
249
my $queryCookie = cookie(-NAME=>$prefscookie,
-
 
250
			-VALUE=>"$QUERY_STRING",
-
 
251
			-PATH=>"$path",
-
 
252
			-EXPIRES=>'+365d');
-
 
253
 
-
 
254
# Print the header
-
 
255
print header (-cookie=> [ $queryCookie, $RCAUTH_cookie ] );
-
 
256
 
-
 
257
# 	print "<!-- FORM \n\n";				# Debug code to dump the FORM to a html comment
-
 
258
#	print "I'm catching updates!!!\n\n";
-
 
259
#	foreach $key (sort (keys %FORM))		#	Must be done after the header is written!
-
 
260
# 		{ print "\t$key:  $FORM{$key}\n"; }
-
 
261
# 	print "--> \n\n";
-
 
262
# 	
-
 
263
# 
-
 
264
# 	print "<!-- ENV \n\n";				# Debug code to dump the ENV to a html comment
-
 
265
# 	foreach $key (sort (keys %ENV))			#	Must be done after the header is written!
-
 
266
# 		{ print "\t$key:  $ENV{$key}\n"; }
-
 
267
# 	print "--> \n\n";
-
 
268
# 
-
 
269
# 	print "\n\n\n\n<!-- $QUERY_STRING --> \n\n\n\n";
-
 
270
 
-
 
271
 
-
 
272
#------------------
-
 
273
 
-
 
274
# Toggle the autoload fields within the table elements 
-
 
275
our ($onClick, $onChange);   # (also used in scanFunctions)
-
 
276
my ($radiobutton, $refreshbutton, $sortby);
-
 
277
if ($FORM{autoload}) {					  
-
 
278
	$onClick = "onClick='submit();'";
-
 
279
	$onChange = "onChange='page.value = 1; submit();'";
-
 
280
  $radiobutton = $h->div ({ class=>'autoload' },
-
 
281
    ["Autoload Changes: ",
-
 
282
    $h->input ({ type=>"radio", name=>'autoload', class=>'accent', value=>1, onClick=>'submit();', checked=>[] }), "On ", 
-
 
283
    $h->input ({ type=>"radio", name=>'autoload', class=>'accent', value=>0, onClick=>'submit();' }), "Off ",
-
 
284
    ]);
-
 
285
  $refreshbutton = "";
-
 
286
  $sortby = $h->select ({name=>"sortby", onChange=>'submit();' }, [ map { $FORM{sortby} eq $_ ? $h->option ({ value=>$_, selected=>[] }, $NAME{$_}) : $h->option ({ value=>$_ }, $NAME{$_}) } @displayFields ]);
-
 
287
} else {
-
 
288
  $onClick = "";
-
 
289
	$onChange = "onChange='page.value = 1;'";
-
 
290
  $radiobutton = $h->div ({ class=>'autoload' }, 
-
 
291
    ["Autoload Changes: ",
-
 
292
    $h->input ({ type=>"radio", name=>'autoload', class=>'accent', value=>1, onClick=>'submit();' }), "On ", 
-
 
293
    $h->input ({ type=>"radio", name=>'autoload', class=>'accent', value=>0, onClick=>'submit();', checked=>[] }), "Off ",
-
 
294
    ]);
-
 
295
  $refreshbutton = $h->input ({ type=>"button", value=>"Refresh", onClick=>"submit(); return false;" });
-
 
296
  $sortby = $h->select ({ name=>"sortby" }, [ map { $FORM{sortby} eq $_ ? $h->option ({ value=>$_, selected=>[] }, $NAME{$_}) : $h->option ({ value=>$_ }, $NAME{$_}) } @displayFields ]);
-
 
297
}
-
 
298
 
-
 
299
my $SIChecked;
-
 
300
if ($FORM{shiftinclude}) {
-
 
301
  $SIChecked = $h->input ({ type=>"checkbox", name=>"shiftinclude", value=>"true", checked=>[], onClick=>'submit();' });
-
 
302
} else {
-
 
303
  $SIChecked = $h->input ({ type=>"checkbox", name=>"shiftinclude", value=>"true", onClick=>'submit();' });
-
 
304
}
-
 
305
 
-
 
306
 
-
 
307
 
-
 
308
print start_html (-title => $pageTitle, -style => {'src' => $stylesheet} );
-
 
309
 
-
 
310
print $h->open ('form', { action=>url, method=>'POST', name=>'Req' });
-
 
311
print $h->input ({ type=>"hidden", name=>"excel", value=>0 });
-
 
312
print $h->div ({ class => "accent pageheader" }, [
-
 
313
  $h->h1 ($pageTitle),
-
 
314
  $h->div ({ class=>"sp0" }, [
-
 
315
    $h->div ({ class=>"spLeft" }, [
-
 
316
      $radiobutton
-
 
317
    ]),
-
 
318
    $h->div ({ class=>"spRight" }, [
-
 
319
      $h->input ({ type=>"button", value=>"Home", onClick=>"window.location.href='$homeURL'" }),
-
 
320
      $refreshbutton
-
 
321
    ]),
-
 
322
  ]),
-
 
323
]);
-
 
324
 
-
 
325
# Print the Hidden fields' check boxes (if there are any)
-
 
326
 
-
 
327
my $c = 1;
-
 
328
my @hiddencheckboxes;
-
 
329
my @hiddenrows;
-
 
330
foreach my $field (sort { $NAME{$a} cmp $NAME{$b}; } @hideFields) {
-
 
331
  if ($FORM{autoload}) {
-
 
332
    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} ]);
-
 
333
  } else {
-
 
334
    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} ]);
-
 
335
  }
-
 
336
  if ($c++ % 4 == 0) {
-
 
337
    push @hiddenrows, $h->div ({ class=>'rTableRow' }, [ @hiddencheckboxes ]);
-
 
338
    @hiddencheckboxes = [];
-
 
339
  }
-
 
340
}
-
 
341
push @hiddenrows, $h->div ({ class=>'rTableRow' }, [ @hiddencheckboxes ]) unless --$c % 4 == 0;
-
 
342
 
-
 
343
my @yearoptions;
-
 
344
foreach (@{&getYears()}) {
-
 
345
	push @yearoptions, $YEAR eq $_ ? $h->option ({ selected=>[] }, $_) : $h->option ($_);
-
 
346
}
-
 
347
 
-
 
348
if (scalar @hideFields) {
-
 
349
  my @topleft;
-
 
350
  push @topleft, $h->div ({ class=>"nowrap" }, "Hidden Columns:");
-
 
351
  push @topleft, $h->div ({ class=>'rTable' }, [ @hiddenrows ]);
-
 
352
  
-
 
353
  print $h->div ({ class=>"sp0" }, [
-
 
354
    $h->div ({ class=>"spLeft"  }, [ @topleft ]),
-
 
355
    $h->div ({ class=>"spRight" }, [
-
 
356
      $signedOnAs, $h->br,
-
 
357
      "Show my shifts: ", $SIChecked, $h->br,
-
 
358
      $h->input ({ type=>"button", value=>"Block Personal Time", onClick=>"window.location.href='personal_time.pl'" }),
-
 
359
    ])
-
 
360
  ]);
-
 
361
}
-
 
362
 
-
 
363
# Print the main table...............................................
-
 
364
 
-
 
365
print $h->open ('div', { class=>'rTable' });
-
 
366
 
-
 
367
my @tmptitlerow;
-
 
368
foreach my $f (@displayFields)	{  # Print the Column headings
-
 
369
  if (inArray ($f, \@staticFields)) {
-
 
370
    push @tmptitlerow, $h->div ({ class=>'rTableHead' }, [ $h->input ({ type=>"hidden", name=>$f, value=>"true" }), $NAME{$f} ]);
-
 
371
  } else {
-
 
372
    if ($FORM{autoload}) {
-
 
373
      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} ]);
-
 
374
    } else {
-
 
375
      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} ]);      
-
 
376
    }
-
 
377
  }
-
 
378
}
-
 
379
 
-
 
380
# Print the filter boxes...
-
 
381
print $h->div ({ class=>'rTableHeading' }, [ @tmptitlerow ], [ map { $h->div ({ class=>'rTableCell filters' }, filter ($_)) } @displayFields ], $h->div ({ class=>"rTableCell" }));
-
 
382
 
-
 
383
 
-
 
384
if ($FORM{shiftinclude}) {  # Include all of the user's shifts at the top
-
 
385
  foreach my $t (@shifts)	{
-
 
386
    no strict;
-
 
387
	  print $h->div ({ class=>'rTableRow highlighted' }, [ map { $h->div ({ class=>'rTableCell' }, exists &{"modify_".$_} ? &{"modify_".$_} ($t) : $t->{$_} ? $t->{$_} : "") } @displayFields ]);
-
 
388
  }
-
 
389
  print $h->hr ({ width=>"500%" });
-
 
390
}
-
 
391
 
-
 
392
 
-
 
393
# Print the things
-
 
394
foreach my $t (@ProductList)	{
-
 
395
  no strict;
-
 
396
  if ($t->{RCid} eq $ORCUSER->{RCid}) {
-
 
397
	  print $h->div ({ class=>'rTableRow highlighted' }, [ map { $h->div ({ class=>'rTableCell' }, exists &{"modify_".$_} ? &{"modify_".$_} ($t) : $t->{$_}) } @displayFields ]);
-
 
398
  } else {
-
 
399
    no strict;
-
 
400
	  print $h->div ({ class=>'rTableRow shaded' }, [ map { $h->div ({ class=>'rTableCell' }, exists &{"modify_".$_} ? &{"modify_".$_} ($t) : $t->{$_}) } @displayFields ]);
-
 
401
  }
-
 
402
}
-
 
403
 
-
 
404
 
-
 
405
print $h->close ('div');
-
 
406
 
-
 
407
# close things out................................................
-
 
408
 
-
 
409
my $pages = $pagelimit eq "All" ? 1 : int( $datacount / $pagelimit + 0.99 );
-
 
410
if ($curpage > $pages) { $curpage = $pages; }
-
 
411
 
-
 
412
my @pagerange;
-
 
413
if ($pages <= 5 ) {
-
 
414
  @pagerange = 1 .. $pages;
-
 
415
} else {  
-
 
416
  if ($curpage <= 3) {
-
 
417
    @pagerange = (1, 2, 3, 4, ">>");
-
 
418
  } elsif ($curpage >= $pages - 2) {
-
 
419
    @pagerange = ("<<", $pages-3, $pages-2, $pages-1, $pages);
-
 
420
  } else {
-
 
421
    @pagerange = ("<<", $curpage-1, $curpage, $curpage+1, ">>");
-
 
422
  }
-
 
423
}
-
 
424
 
-
 
425
print $h->br; # print $h->br;
-
 
426
print $h->div ({ class=>"sp0" }, [
-
 
427
    $h->div ({ class=>"spLeft" }, [
-
 
428
      $h->div ({ class=>"footer" }, [
-
 
429
        "To bookmark, save, or send this exact view, use the ",
-
 
430
        $h->a ({ href=>'', onClick=>"window.document.Req.method = 'GET'; Req.submit(); return false;" }, "[Full URL]"),
-
 
431
        $h->br,
-
 
432
        "If this page is displaying oddly, ", $h->a ({ href=>url ()."?ignoreCookie=1" }, "[Reset Your View]"),
-
 
433
        $h->br,
-
 
434
        $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.]"),
-
 
435
        $h->br,
-
 
436
        "This page was displayed on ", currentTime (),
-
 
437
        $h->br,
-
 
438
        "Please direct questions, problems, and concerns to $SYSTEM_EMAIL",
-
 
439
        $h->br,
-
 
440
        "Displaying: ", $h->select ({ name=>"year", onchange=>"Req.submit();" }, [ @yearoptions ])
-
 
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,
-
 
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();} }, "$_") :
-
 
451
                                                                 $h->a ({ onClick=>qq{Req.page.value=$_; Req.submit();} }, "[$_]") } @pagerange ) : "" ), $h->br,
-
 
452
               $h->input ({ type=>"hidden", name=>"page", value=>$curpage })
-
 
453
      ])
-
 
454
    ]),
-
 
455
]);
-
 
456
 
-
 
457
#print $h->br; # print $h->br;
-
 
458
#print $h->h5 ("$x Record(s) Displayed");
-