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;
Line 18... Line 18...
18
use DateTime::Duration;
18
use DateTime::Duration;
19
our $h = HTML::Tiny->new( mode => 'html' );
19
our $h = HTML::Tiny->new( mode => 'html' );
Line 20... Line 20...
20
 
20
 
21
my $cookie_string = authenticate (RollerCon::USER) || die;
21
my $cookie_string = authenticate (RollerCon::USER) || die;
22
our ($EML, $PWD, $LVL) = split /&/, $cookie_string;
-
 
23
my $user = getUser ($EML);
-
 
24
$user->{department} = convertDepartments $user->{department};
-
 
25
my $username = $h->a ({ href=>"/schedule/view_user.pl?submit=View&RCid=$user->{RCid}" }, $user->{derby_name});
-
 
26
my $RCid = $user->{RCid};
22
our ($EML, $PWD, $LVL) = split /&/, $cookie_string;
27
my $RCAUTH_cookie = CGI::Cookie->new(-name=>'RCAUTH',-value=>"$cookie_string",-expires=>"+30m");
-
 
28
my $YEAR = 1900 + (localtime)[5];
23
my $RCAUTH_cookie = CGI::Cookie->new (-name=>'RCAUTH', -value=>"$cookie_string", -expires=>"+30m");
Line 29... Line -...
29
my $now = DateTime->now (time_zone => 'America/Los_Angeles');
-
 
30
 
24
my $now = DateTime->now (time_zone => 'America/Los_Angeles');
31
 
-
 
32
my $pageTitle = "Shift Management";
25
 
33
my $prefscookie = "shiftmanager";
26
my $pageTitle = "Shift Management";
34
our $DBTABLE = 'v_shift';
27
our $DBTABLE = 'v_shift';
35
my %COLUMNS = (
28
my %COLUMNS = (
36
# colname   =>  [qw(DisplayName       N    type     status)],   status ->  static | default | <blank>
29
# colname   =>  [qw(DisplayName       N    type     status)],   status ->  static | default | <blank>
37
	id          => [qw(ID             5    number         )],
30
  id          => [qw(ID             5    number         )],
38
	dept        => [qw(Department    10    select       )],
31
  dept        => [qw(Department    10    select       )],
39
	date        => [qw(Date          15    date        default )],
32
  date        => [qw(Date          15    date        default )],
40
  dayofweek   => [qw(Day           17    select      )],
33
  dayofweek   => [qw(Day           17    select      )],
41
	time        => [qw(Time          20    text        default )],
34
  time        => [qw(Time          20    text        default )],
42
	start_time  => [qw(Start         25    text         )],
35
  start_time  => [qw(Start         25    text         )],
43
	end_time    => [qw(End           30    text         )],
36
  end_time    => [qw(End           30    text         )],
44
	mod_time    => [qw(ModTime       35    number         )],
37
  mod_time    => [qw(ModTime       35    number         )],
45
	doubletime  => [qw(DoubleTime    37    boolean         )],
38
  doubletime  => [qw(DoubleTime    37    boolean         )],
46
	volhours    => [qw(VolHours      40    number         )],
39
  volhours    => [qw(VolHours      40    number         )],
47
	role        => [qw(Role          45    text      default )],
40
  role        => [qw(Role          45    text      default )],
48
	type        => [qw(Type          50    select      default )],
41
  type        => [qw(Type          50    select      default )],
49
	location    => [qw(Location      55    select      default )],
42
  location    => [qw(Location      55    select      default )],
50
	note        => [qw(Notes         60    text        default )],
43
  note        => [qw(Notes         60    text        default )],
51
	RCid        => [qw(RCID          65    text         )],
44
  RCid        => [qw(RCID          65    text         )],
52
	derby_name  => [qw(Assignee      70    select      default   )],
-
 
53
);
-
 
54
my $stylesheet = "/style.css";
-
 
Line 55... Line 45...
55
my $homeURL = '/schedule/';
45
  derby_name  => [qw(Assignee      70    select      default   )],
-
 
46
);
56
my @pagelimitoptions = ("All", 5, 10, 25);
47
 
57
 
48
my @whereClause;
58
my @whereClause;
49
# Users should only see shifts within their own departments (except VCI sees all)
59
if ($LVL < 5) {
50
if ($LVL < 5 and $ORCUSER->{VCI} < 2) {
60
  my $string = "dept in (".join ",", map { '"'.$_.'"' } grep { $ORCUSER->{department}->{$_} >= 1 } keys %{$ORCUSER->{department}};
51
  my $string = "dept in (".join ",", map { '"'.$_.'"' } grep { $ORCUSER->{department}->{$_} >= 1 } keys %{$ORCUSER->{department}};
61
  $string .= ")";
52
  $string .= ")";
Line 94... Line 85...
94
  $hr->{dept} = $DEPTS->{$hr->{dept}};
85
  $hr->{dept} = $DEPTS->{$hr->{dept}};
95
}
86
}
Line 96... Line 87...
96
 
87
 
97
sub filter_dept {
88
sub filter_dept {
98
  my $colName = shift;
89
  my $colName = shift;
99
	my $filter = shift;
90
  my $filter = shift;
100
	
91
  
101
	if (defined $filter)	{
92
  if (defined $filter)  {
102
		if ($filter eq "-blank-") {
93
    if ($filter eq "-blank-") {
103
			return "($colName = '' or isNull($colName) = 1)";
94
      return "($colName = '' or isNull($colName) = 1)";
104
		}
95
    }
105
		return "$colName = \"$filter\"";
96
    return "$colName = \"$filter\"";
106
	}	else {
97
  } else {
107
		my $thing = "filter-${colName}";	  
98
    my $tmpFormValue = param ("filter-${colName}");
108
    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};
99
    my $categories = join "", map { $tmpFormValue eq $_ ? $h->option ({ value=>$_, selected=>[] }, $DEPTS->{$_}) : $h->option ({ value=>$_ }, $DEPTS->{$_}) } grep { $LVL > 4 or exists $ORCUSER->{department}->{$_} } grep { !/^PER$/ } sort keys %{$DEPTS};
109
		my $Options = "<OPTION></OPTION>".$categories;
100
    my $Options = "<OPTION></OPTION>".$categories;
110
 
101
    
-
 
102
    $Options =~ s/>($tmpFormValue)/ selected>$1/;
111
		$Options =~ s/>($FORM{$thing})/ selected>$1/;
103
    my $onChange = param ("autoload") ? "onChange='page.value = 1; submit();'" : "";
112
		return "<SELECT name=filter-${colName} $onChange>$Options</SELECT>";
104
    return "<SELECT name=filter-${colName} $onChange>$Options</SELECT>";
113
	}
105
  }
Line 114... Line 106...
114
}
106
}
115
 
107
 
116
sub modify_derby_name {
108
sub modify_derby_name {
Line 117... Line 109...
117
  my $t = shift;
109
  my $t = shift;
118
  my $dept = $t->{orig_dept} // $t->{dept};
110
  my $dept = $t->{orig_dept} // $t->{dept};
119
  
111
  
120
  if ($t->{derby_name}) {
112
  if ($t->{derby_name}) {
121
    if ($user->{department}->{$dept} >= RollerCon::LEAD or $LVL >= RollerCon::ADMIN) {
113
    if ($ORCUSER->{department}->{$dept} >= RollerCon::LEAD or $LVL >= RollerCon::ADMIN) {
122
      $t->{derby_name} = $h->a ({ href=>"/schedule/view_user.pl?RCid=$t->{RCid}" }, $t->{derby_name});
114
      $t->{derby_name} = $h->a ({ href=>"/schedule/view_user.pl?RCid=$t->{RCid}" }, $t->{derby_name});
123
    } else {
115
    } else {
124
      $t->{derby_name} = "FILLED" unless getUser($t->{RCid})->{showme};
116
      $t->{derby_name} = "FILLED" unless getUser($t->{RCid})->{showme};
Line -... Line 117...
-
 
117
      return $t->{derby_name};
-
 
118
    }
-
 
119
  }
-
 
120
  
-
 
121
  if ($t->{type} eq "request" or $t->{type} eq "approved" or $t->{type} eq "denied") {
125
      return $t->{derby_name};
122
    # Don't let anyone change the assignee for an Hours Request.
126
    }
123
    return $t->{derby_name};
127
  }
124
  }
Line 128... Line 125...
128
  
125
  
129
  if ($dept eq "COA" and $t->{location} =~ /MVP/) {
126
  if ($dept eq "COA" and $t->{location} =~ /MVP/) {
130
    return $LVL >= RollerCon::ADMIN ? $t->{derby_name} . " | " . $h->a ({ href=>"view_class.pl?id=".getClassID ($t->{id})."&choice=Update" }, "[Edit Class]") : $t->{derby_name};
127
    return $LVL >= RollerCon::ADMIN ? $t->{derby_name} . " | " . $h->a ({ href=>"view_class.pl?id=".getClassID ($t->{id})."&choice=Update" }, "[Edit Class]") : $t->{derby_name};
131
  }
128
  }
132
  
129
  
133
 	my ($yyyy, $mm, $dd) = split /\-/, $t->{date};
130
  my ($yyyy, $mm, $dd) = split /\-/, $t->{date};
134
	my $cutoff = DateTime->new(
131
  my $cutoff = DateTime->new(
135
        year => $yyyy,
132
        year => $yyyy,
136
        month => $mm,
133
        month => $mm,
137
        day => $dd,
134
        day => $dd,
Line 138... Line 135...
138
        hour => 5,
135
        hour => 5,
139
        minute => 0,
136
        minute => 0,
140
        second => 0,
137
        second => 0,
141
        time_zone => 'America/Los_Angeles'
138
        time_zone => 'America/Los_Angeles'
142
  );
139
  );
143
  
140
  
144
 	if (($t->{RCid} == $RCid and $t->{type} ne "selected" and $now < $cutoff) or ($t->{derby_name} and ($user->{department}->{$dept} >= 2 or $LVL >= 5))) {
141
  if (($t->{RCid} == $ORCUSER->{RCid} and $t->{type} ne "selected" and $now < $cutoff) or ($t->{derby_name} and ($ORCUSER->{department}->{$dept} >= 2 or $LVL >= 5))) {
145
 		# DROP
142
    # DROP
146
 		$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->{RCid}&id=$t->{id}','Confirm Shift Change','resizable,height=260,width=370'); return false; }\">[DROP]</a>";
143
    $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->{RCid}&id=$t->{id}','Confirm Shift Change','resizable,height=260,width=370'); return false; }\">[DROP]</a>";
147
 		if ($user->{department}->{$dept} >= 2 or $LVL > 4) {
144
    if ($ORCUSER->{department}->{$dept} >= 2 or $LVL > 4) {
148
 		  # NO SHOW
145
      # NO SHOW
149
 		  $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->{RCid}&id=$t->{id}','Confirm Shift Change','resizable,height=260,width=370'); return false; }\">[NO SHOW]</a>";
146
      $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->{RCid}&id=$t->{id}','Confirm Shift Change','resizable,height=260,width=370'); return false; }\">[NO SHOW]</a>";
150
 		}
147
    }
151
 	} elsif (!$t->{derby_name}) {
148
  } elsif (!$t->{derby_name}) {
152
 		if (findConflict ($ORCUSER->{RCid}, $t->{id})) {
149
    if (findConflict ($ORCUSER->{RCid}, $t->{id})) {
153
      $t->{derby_name} .= "*schedule conflict*";
150
      $t->{derby_name} .= "*schedule conflict*";
154
		} elsif ($dept eq "EMT" and !$ORCUSER->{emt_verified}) {
151
    } elsif ($dept eq "EMT" and !$ORCUSER->{emt_verified}) {
155
			$t->{derby_name} .= "*needs verification*";
152
      $t->{derby_name} .= "*needs verification*";
156
    } elsif (signUpEligible ($ORCUSER, $t, "vol") and $now < $cutoff) {
153
    } elsif (signUpEligible ($ORCUSER, $t, "vol") and $now < $cutoff) {
157
 			# SIGN UP
154
      # SIGN UP
158
 			$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>";
155
      $t->{derby_name} = "<A HREF='#' onClick=\"event.stopPropagation(); window.open('make_shift_change.pl?change=add&RCid=$ORCUSER->{RCid}&id=$t->{id}','Confirm Shift Change','resizable,height=260,width=370'); return false;\">[SIGN UP]</a>";
159
 		}
156
    }
160
 		if ($user->{department}->{$dept} >= 2 or $LVL > 4) {
157
    if ($ORCUSER->{department}->{$dept} >= 2 or $LVL > 4) {
161
 			# ADD USER
158
      # ADD USER
Line 162... Line 159...
162
 			$t->{derby_name} ? $t->{derby_name} .= " | " : {};
159
      $t->{derby_name} ? $t->{derby_name} .= " | " : {};
163
 			$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>";
160
      $t->{derby_name} .= "<A HREF='#' onClick=\"event.stopPropagation(); window.open('make_shift_change.pl?change=lookup&RCid=$ORCUSER->{RCid}&id=$t->{id}','Confirm Shift Change','resizable,height=260,width=370'); return false;\">[ADD USER]</a>";
164
 		}
161
    }
Line 179... Line 176...
179
sub modify_end_time {
176
sub modify_end_time {
180
  my $t = shift;
177
  my $t = shift;
181
  return convertTime $t->{end_time};
178
  return convertTime $t->{end_time};
182
}
179
}
Line 183... Line -...
183
 
-
 
184
 
-
 
185
# Ideally, nothing below this comment needs to change
-
 
186
#-------------------------------------------------------------------------------
-
 
187
 
-
 
188
 
-
 
189
our %NAME              = map  { $_ => $COLUMNS{$_}->[0] } keys %COLUMNS;
-
 
190
our %colOrderHash      = map  { $_ => $COLUMNS{$_}->[1] } keys %COLUMNS;
-
 
191
our %colFilterTypeHash = map  { $_ => $COLUMNS{$_}->[2] } keys %COLUMNS;
-
 
192
our @staticFields      = sort byfield grep { $COLUMNS{$_}->[3] eq 'static' } keys %COLUMNS;
-
 
193
our @defaultFields     = sort byfield grep { defined $COLUMNS{$_}->[3] } keys %COLUMNS;
-
 
194
#our @defaultFields     = grep { $COLUMNS{$_}->[3] eq 'default' or inArray ($_, \@staticFields) } keys %COLUMNS;
-
 
195
 
-
 
196
our @allFields = sort byfield keys %NAME;
-
 
197
our @displayFields = ();
-
 
198
our @hideFields = ();
-
 
199
my $QUERY_STRING;
-
 
200
 
-
 
201
my $pagelimit = param ("limit") // $pagelimitoptions[$#pagelimitoptions];
-
 
202
my $curpage = param ("page") // 1;
-
 
203
 
-
 
204
our %FORM;
-
 
205
my $FILTER;
-
 
206
foreach (param()) {
-
 
207
 	if (/^year$/) { #
-
 
208
		$YEAR = param($_);
-
 
209
		next;
-
 
210
	}
-
 
211
 
-
 
212
	$FORM{$_} = param($_);				# Retrieve all of the FORM data submitted
-
 
213
  
-
 
214
	if ((/^filter/) and ($FORM{$_} ne '')) {	# Build a set of filters to apply
-
 
215
		my ($filter,$field) = split /-/, $_;		
-
 
216
		$FILTER->{$field} = $FORM{$_} unless notInArray ($field, \@allFields);
-
 
217
	}	elsif ($FORM{$_} eq "true")			# Compile list of fields to display
-
 
218
		{ push @displayFields, $_; }
-
 
219
}
-
 
220
push @whereClause, "year(date) = '$YEAR'";
-
 
221
 
-
 
222
if (exists $FORM{autoload})	{			# If the FORM was submitted (i.e. the page is being redisplayed),
-
 
223
							                    #  	build the data for the cookie that remembers the page setup
-
 
224
	my $disFields = join ":", @displayFields;
-
 
225
	my $fils = join ":", map { "$_=$FILTER->{$_}" } keys %{$FILTER};
-
 
226
		
-
 
227
	$QUERY_STRING = $disFields.'&'.$fils.'&'.$FORM{sortby}.'&'.$FORM{autoload};
-
 
228
}
-
 
229
 
-
 
230
 
-
 
231
if (!(exists $FORM{autoload}))	{			# No FORM was submitted...
-
 
232
	if (my $prefs = cookie ($prefscookie) and !defined param ("ignoreCookie"))	{ # Check for cookies from previous visits.
-
 
233
		my ($disF, $filts, $sb, $al) = split /&/,$prefs;
-
 
234
		@displayFields = split /:/,$disF;
-
 
235
		
-
 
236
		foreach my $pair (split /:/, $filts)	{
-
 
237
			my ($key, $value) = split /=/, $pair;
-
 
238
			$FORM{"filter-$key"} = $value;
-
 
239
			$FILTER->{$key} = $value;
-
 
240
		}
-
 
241
		
-
 
242
		$FORM{sortby} = $sb;
-
 
243
		$FORM{autoload} = $al;
-
 
244
		$QUERY_STRING = $prefs;
-
 
245
	}	else {
-
 
246
	  @displayFields = @defaultFields; # Otherwise suppply a default list of columns.
-
 
247
	  $FORM{sortby} = $displayFields[1];
-
 
248
	  $FORM{autoload} = 1;             # And turn aut0load on by default.
-
 
249
	} 
-
 
250
}
-
 
251
 
-
 
252
# let's just make sure the columns are in the right order (and there aren't any missing)
-
 
253
@displayFields = grep { inArray($_, \@allFields) } sort byfield uniq @displayFields, @staticFields;
-
 
254
 
-
 
255
# If the field isn't in the displayFields list,	then add it to the hideFields list
-
 
256
@hideFields = grep { notInArray ($_, \@displayFields) } @allFields;
-
 
257
 
-
 
258
# Process any filters provided in the form to pass to the database
-
 
259
push @whereClause, map { filter ($_, $FILTER->{$_}) } grep { defined $FILTER->{$_} } @displayFields;
-
 
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
#warn join " and ", @whereClause;
-
 
265
my ($data, $datacount) = getData (\@displayFields, \@whereClause, $DBTABLE, $FORM{sortby}, $curpage, $pagelimit);
-
 
266
my @ProductList = @{ $data };
-
 
267
 
-
 
268
#my @ProductList = @{ getData (\@displayFields, \@whereClause, $DBTABLE, $FORM{sortby}, $curpage, $pagelimit) };
-
 
269
my $x = scalar @ProductList; # How many results were returned?
-
 
270
 
-
 
271
# If the user is trying to download the Excel file, send it to them and then exit out.
-
 
272
if ($FORM{excel}) {
-
 
273
  exportExcel (\@ProductList, "RC_Officiating_Shifts");
-
 
274
  exit;
-
 
275
}
-
 
276
 
-
 
277
my $signedOnAs = $username ? "Welcome, $username. ".$h->a ({ href=>"index.pl?LOGOUT" }, "[Log Out]") : "You are not signed in.";
-
 
278
 
-
 
279
# Set some cookie stuff...
-
 
280
my $path = `dirname $ENV{SCRIPT_NAME}`; chomp $path; $path .= '/' unless $path eq "/";
-
 
281
my $queryCookie = cookie(-NAME=>$prefscookie,
-
 
282
			-VALUE=>"$QUERY_STRING",
-
 
283
			-PATH=>"$path",
-
 
284
			-EXPIRES=>'+365d');
-
 
285
 
-
 
286
# Print the header
-
 
287
print header (-cookie=> [ $queryCookie, $RCAUTH_cookie ] );
-
 
288
 
-
 
289
# 	print "<!-- FORM \n\n";				# Debug code to dump the FORM to a html comment
-
 
290
#	print "I'm catching updates!!!\n\n";
-
 
291
#	foreach $key (sort (keys %FORM))		#	Must be done after the header is written!
-
 
292
# 		{ print "\t$key:  $FORM{$key}\n"; }
-
 
293
# 	print "--> \n\n";
-
 
294
# 	
-
 
295
# 
-
 
296
# 	print "<!-- ENV \n\n";				# Debug code to dump the ENV to a html comment
-
 
297
# 	foreach $key (sort (keys %ENV))			#	Must be done after the header is written!
-
 
298
# 		{ print "\t$key:  $ENV{$key}\n"; }
-
 
299
# 	print "--> \n\n";
-
 
300
# 
-
 
301
# 	print "\n\n\n\n<!-- $QUERY_STRING --> \n\n\n\n";
-
 
302
 
-
 
303
 
-
 
304
#------------------
-
 
305
 
-
 
306
# Toggle the autoload fields within the table elements 
-
 
307
our ($onClick, $onChange);   # (also used in scanFunctions)
-
 
308
my ($radiobutton, $refreshbutton, $sortby);
180
 
309
if ($FORM{autoload}) {					  
-
 
310
	$onClick = "onClick='submit();'";
-
 
311
	$onChange = "onChange='page.value = 1; submit();'";
-
 
312
  $radiobutton = $h->div ({ class=>'autoload' },
-
 
313
    ["Autoload Changes: ",
-
 
314
    $h->input ({ type=>"radio", name=>'autoload', class=>'accent', value=>1, onClick=>'submit();', checked=>[] }), "On ", 
-
 
315
    $h->input ({ type=>"radio", name=>'autoload', class=>'accent', value=>0, onClick=>'submit();' }), "Off ",
-
 
316
    ]);
-
 
317
  $refreshbutton = "";
-
 
318
  $sortby = $h->select ({name=>"sortby", onChange=>'submit();' }, [ map { $FORM{sortby} eq $_ ? $h->option ({ value=>$_, selected=>[] }, $NAME{$_}) : $h->option ({ value=>$_ }, $NAME{$_}) } grep { $_ ne "id" } @displayFields ]);
-
 
319
} else {
-
 
320
  $onClick = "";
-
 
321
	$onChange = "onChange='page.value = 1;'";
-
 
322
  $radiobutton = $h->div ({ class=>'autoload' }, 
-
 
323
    ["Autoload Changes: ",
-
 
324
    $h->input ({ type=>"radio", name=>'autoload', class=>'accent', value=>1, onClick=>'submit();' }), "On ", 
-
 
325
    $h->input ({ type=>"radio", name=>'autoload', class=>'accent', value=>0, onClick=>'submit();', checked=>[] }), "Off ",
-
 
326
    ]);
-
 
327
  $refreshbutton = $h->input ({ type=>"button", value=>"Refresh", onClick=>"submit(); return false;" });
-
 
328
  $sortby = $h->select ({name=>"sortby" }, [ map { $FORM{sortby} eq $_ ? $h->option ({ value=>$_, selected=>[] }, $NAME{$_}) : $h->option ({ value=>$_ }, $NAME{$_}) } @displayFields ]);
-
 
329
}
-
 
330
 
-
 
331
 
-
 
332
 
-
 
333
	 
-
 
334
print start_html (-title => $pageTitle, -style => {'src' => $stylesheet} );
-
 
335
 
-
 
336
print $h->open ('form', { action=>url, method=>'POST', name=>'Req' });
-
 
337
print $h->input ({ type=>"hidden", name=>"excel", value=>0 });
-
 
338
print $h->div ({ class => "accent pageheader" }, [
-
 
339
  $h->h1 ($pageTitle),
-
 
340
  $h->div ({ class=>"sp0" }, [
-
 
341
    $h->div ({ class=>"spLeft" }, [
-
 
342
      $radiobutton
-
 
343
    ]),
-
 
344
    $h->div ({ class=>"spRight" }, [
-
 
345
      $h->input ({ type=>"button", value=>"Home", onClick=>"window.location.href='$homeURL'" }),
-
 
346
      $refreshbutton
-
 
347
    ]),
-
 
348
  ]),
-
 
349
]);
-
 
350
 
-
 
351
# Print the Hidden fields' check boxes (if there are any)
-
 
352
 
181
sub modify_volhours {
353
my $c = 1;
-
 
354
my @hiddencheckboxes;
-
 
355
my @hiddenrows;
-
 
356
foreach my $field (sort { $NAME{$a} cmp $NAME{$b}; } @hideFields) {
182
  my $t = shift;
357
  if ($FORM{autoload}) {
183
  if ($t->{type} eq "request") {
358
    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} ]);
184
    return "<i>TBD</i>";
359
  } else {
185
  } else {
360
    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} ]);
-
 
361
  }
-
 
362
  if ($c++ % 4 == 0) {
-
 
363
    push @hiddenrows, $h->div ({ class=>'rTableRow' }, [ @hiddencheckboxes ]);
-
 
364
    @hiddencheckboxes = [];
186
    return $t->{volhours};
365
  }
187
  }
366
}
-
 
Line 367... Line -...
367
push @hiddenrows, $h->div ({ class=>'rTableRow' }, [ @hiddencheckboxes ]) unless --$c % 4 == 0;
-
 
368
 
188
}
369
my @yearoptions;
189
 
370
foreach (@{&getYears()}) {
-
 
Line -... Line 190...
-
 
190
# If we need to modify how a filter works, create a subroutine named "filter_$columnname"
-
 
191
#    It will receive two fields, the field name and the current filter value (if any)
371
	push @yearoptions, $YEAR eq $_ ? $h->option ({ selected=>[] }, $_) : $h->option ($_);
192
 
372
}
193
# Uncomment and update if we want to enable clicking on a row to open a new page.
373
 
-
 
374
if (scalar @hideFields) {
-
 
Line 375... Line -...
375
  my @topleft;
-
 
376
  push @topleft, $h->div ({ class=>"nowrap" }, "Hidden Columns:");
-
 
377
  push @topleft, $h->div ({ class=>'rTable' }, [ @hiddenrows ]);
-
 
378
  
-
 
379
  print $h->div ({ class=>"sp0" }, [
-
 
380
    $h->div ({ class=>"spLeft"  }, [ @topleft ]),
-
 
381
    $h->div ({ class=>"spRight" }, [
-
 
382
      $signedOnAs
-
 
383
    ])
-
 
384
  ]);
-
 
385
}
-
 
386
 
-
 
387
# Print the main table...............................................
-
 
388
 
-
 
389
print $h->open ('div', { class=>'rTable' });
-
 
390
 
194
#
391
my @tmptitlerow;
195
sub addRowClick {
392
foreach my $f (@displayFields)	{  # Print the Column headings
196
  my $t = shift;
393
  if ($f eq $allFields[0]) {
-
 
394
#    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'" }) : "" ]);
-
 
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}, $LVL >= RollerCon::MANAGER ? "&nbsp;".$h->input ({ type=>"button", value=>"Add", onClick=>"event.stopPropagation(); window.location.href='view_shift.pl'" }) : "" ]);
-
 
396
  } else {
-
 
397
    if ($FORM{autoload}) {
-
 
398
      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} ]);
-
 
399
    } else {
-
 
400
      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} ]);      
-
 
401
    }
-
 
402
  }
-
 
403
}
-
 
404
 
-
 
405
# Print the filter boxes...
-
 
406
print $h->div ({ class=>'rTableHeading' }, [ @tmptitlerow ], [ map { $h->div ({ class=>'rTableCell filters' }, filter ($_)) } @displayFields ], $h->div ({ class=>"rTableCell" }));
-
 
407
 
-
 
408
# Print the things
-
 
409
foreach my $t (@ProductList)	{
-
 
410
  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 ]);
-
 
411
}
-
 
412
 
-
 
413
print $h->close ('div');
-
 
414
 
-
 
415
# close things out................................................
-
 
416
 
-
 
417
my $pages = $pagelimit eq "All" ? 1 : int( $datacount / $pagelimit + 0.99 );
-
 
418
if ($curpage > $pages) { $curpage = $pages; }
-
 
419
 
-
 
420
my @pagerange;
-
 
421
if ($pages <= 5 ) {
-
 
422
  @pagerange = 1 .. $pages;
-
 
423
} else {  
197
  
424
  if ($curpage <= 3) {
-
 
425
    @pagerange = (1, 2, 3, 4, ">>");
-
 
426
  } elsif ($curpage >= $pages - 2) {
198
  if ($t->{type} eq "request" or $t->{type} eq "approved" or $t->{type} eq "denied") {
427
    @pagerange = ("<<", $pages-3, $pages-2, $pages-1, $pages);
199
    return "location.href='missing_hours.pl?id=$t->{id}'";
Line 428... Line -...
428
  } else {
-
 
429
    @pagerange = ("<<", $curpage-1, $curpage, $curpage+1, ">>");
-
 
430
  }
-
 
431
}
-
 
432
 
-
 
433
print $h->br; # print $h->br;
-
 
434
print $h->div ({ class=>"sp0" }, [
-
 
435
    $h->div ({ class=>"spLeft" }, [
-
 
436
      $h->div ({ class=>"footer" }, [
-
 
437
        "To bookmark, save, or send this exact view, use the ",
-
 
438
        $h->a ({ href=>'', onClick=>"window.document.Req.method = 'GET'; Req.submit(); return false;" }, "[Full URL]"),
-
 
439
        $h->br,
-
 
440
        "If this page is displaying oddly, ", $h->a ({ href=>url ()."?ignoreCookie=1" }, "[Reset Your View]"),
-
 
441
        $h->br,
-
 
442
        $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.]"),
-
 
443
        $h->br,
-
 
444
        "This page was displayed on ", currentTime (),
-
 
445
        $h->br,
-
 
446
        "Please direct questions, problems, and concerns to $SYSTEM_EMAIL",
-
 
447
        $h->br,
-
 
448
        "Displaying: ", $h->select ({ name=>"year", onchange=>"Req.submit();" }, [ @yearoptions ])
-
 
449
      ])
-
 
450
    ]),
-
 
451
    $h->div ({ class=>"spRight" }, [
-
 
452
      $h->h5 ([
-
 
453
               "$x of $datacount Record". ($x == 1 ? "" : "s") ." Displayed", $h->br,               
-
 
454
               "Sorted by ", $sortby, $h->br,
-
 
455
               "Displaying ", $h->select ({ name=>"limit", onChange=>"page.value = 1; submit();" }, [ map { $pagelimit == $_ ? $h->option ({ selected=>[] }, $_) : $h->option ($_) } @pagelimitoptions ]), " Per Page", $h->br,
-
 
456
               ( $pages > 1 ? ( join " ", map { $_ == $curpage ? "<B>$_</b>" :
-
 
457
                                                $_ eq "<<"     ? $h->a ({ onClick=>qq{Req.page.value=1; Req.submit();} }, "$_") :
-
 
458
                                                $_ eq ">>"     ? $h->a ({ onClick=>qq{Req.page.value=$pages; Req.submit();} }, "$_") :
-
 
459
                                                                 $h->a ({ onClick=>qq{Req.page.value=$_; Req.submit();} }, "[$_]") } @pagerange ) : "" ), $h->br,
-
 
460
               $h->input ({ type=>"hidden", name=>"page", value=>$curpage })
-
 
461
      ])
-
 
462
    ]),
-
 
463
]);
-
 
464
 
-
 
465
#print $h->br; # print $h->br;
-
 
466
#print $h->h5 ("$x Record(s) Displayed");
-
 
467
#print $h->div ({ class=>"footer" }, [
-
 
468
#  "To bookmark, save, or send this exact view, use the ",
-
 
469
#  $h->a ({ href=>'', onClick=>"window.document.Req.method = 'GET'; Req.submit(); return false;" }, "[Full URL]"),
-
 
470
#  $h->br,
-
 
471
#  "This page was displayed on $now",
-
 
472
#  $h->br,
-
 
473
#  "Please direct questions, problems, and concerns to noone\@gmail.com"
-
 
474
#]);
200
  } else {
-
 
201
    return "location.href='view_shift.pl?id=$t->{id}'";
-
 
202
  }
-
 
203
}
-
 
204
 
-
 
205
# Call the function to print the table view page (with available options)
-
 
206
printTablePage ({ Title   => $pageTitle,
-
 
207
                  Table   => $DBTABLE,
-
 
208
                  Columns => \%COLUMNS,
-
 
209
                  Where   => join (" and ", @whereClause),
-
 
210
                  RCAuth  => $RCAUTH_cookie,
-
 
211
                  DisplayYearSelect => 1,