Subversion Repositories VORC

Rev

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

Rev 53 Rev 56
Line 1... Line 1...
1
#!/usr/bin/perl
1
#!/usr/bin/perl
Line -... Line 2...
-
 
2
 
-
 
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";
2
 
8
 
Line 3... Line 9...
3
#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"; }
4
 
10
 
5
#use strict;
11
#use strict;
6
use cPanelUserConfig;
12
use cPanelUserConfig;
7
use CGI qw/param cookie header start_html url/;
13
use CGI qw/param cookie header start_html url/;
8
use HTML::Tiny;
14
use HTML::Tiny;
9
use tableViewer;
15
use tableViewer;
10
use RollerCon;
16
use RollerCon;
11
use DateTime;
-
 
12
use DateTime::Duration;
17
use DateTime;
Line 13... Line 18...
13
my $now = DateTime->now (time_zone => 'America/Los_Angeles');
18
use DateTime::Duration;
14
our $h = HTML::Tiny->new( mode => 'html' );
19
our $h = HTML::Tiny->new( mode => 'html' );
15
 
20
 
16
my $cookie_string = authenticate (1) || die;
21
my $cookie_string = authenticate (RollerCon::USER) || die;
17
our ($EML, $PWD, $LVL) = split /&/, $cookie_string;
22
our ($EML, $PWD, $LVL) = split /&/, $cookie_string;
18
my $user = getUser ($EML);
23
my $user = getUser ($EML);
19
$user->{department} = convertDepartments $user->{department};
24
$user->{department} = convertDepartments $user->{department};
20
my $username = $h->a ({ href=>"/schedule/manage_user.pl?submit=View&RCid=$user->{RCid}" }, $user->{derby_name});
25
my $username = $h->a ({ href=>"/schedule/view_user.pl?submit=View&RCid=$user->{RCid}" }, $user->{derby_name});
21
my $RCid = $user->{RCid};
-
 
22
my $RCAUTH_cookie = CGI::Cookie->new(-name=>'RCAUTH',-value=>"$cookie_string",-expires=>"+30m");
-
 
23
my $YEAR = 1900 + (localtime)[5];
-
 
24
 
-
 
25
if (!scalar (grep { $user->{department}->{$_} > 0 } grep { !/^(ANN|OFF)$/ } keys %{$user->{department}}) and 
-
 
26
    $user->{department}->{ANN} < 2 and 
-
 
27
    $user->{department}->{OFF} < 2 and 
-
 
28
    $LVL < 4) {
26
my $RCid = $user->{RCid};
29
	print header(-cookie=>$RCAUTH_cookie);
-
 
30
	printRCHeader("Unauthorized Page");
-
 
31
	print $h->div ({ class=>"error" }, "No Access");
-
 
32
	print $h->div ("Your user account is not registered as a Volunteer in a department that uses this view, so you can't see these shifts.  It's possible that your access is still being reviewed.  Please be patient.");
-
 
33
	print $h->a ({ href=>"/schedule/" }, "[Go Home]");
-
 
Line 34... Line 27...
34
	print $h->close ("html");
27
my $RCAUTH_cookie = CGI::Cookie->new(-name=>'RCAUTH',-value=>"$cookie_string",-expires=>"+30m");
35
	exit;	
28
my $YEAR = 1900 + (localtime)[5];
36
}
29
my $now = DateTime->now (time_zone => 'America/Los_Angeles');
37
 
30
 
38
 
31
 
39
my $pageTitle = "Volunteer Shifts";
32
my $pageTitle = "Shift Management";
40
my $prefscookie = "vorcshifts";
33
my $prefscookie = "shiftmanager";
41
our $DBTABLE = 'v_shift';
34
our $DBTABLE = 'v_shift';
42
my %COLUMNS = (
35
my %COLUMNS = (
43
# colname   =>  [qw(DisplayName       N    type     status)],   status ->  static | default | <blank>
36
# colname   =>  [qw(DisplayName       N    type     status)],   status ->  static | default | <blank>
44
	id          => [qw(ShiftID        5    number       )],
37
	id          => [qw(ID             5    number         )],
45
	dept        => [qw(Department    10    select      default )],
38
	dept        => [qw(Department    10    select       )],
46
	role        => [qw(Role          15    text      default )],
39
	date        => [qw(Date          15    date        default )],
47
	type        => [qw(Type          20    select      default )],
40
  dayofweek   => [qw(Day           17    select      )],
48
	date        => [qw(Date          25    date        default )],
41
	time        => [qw(Time          20    text        default )],
49
  dayofweek   => [qw(Day           27    select              )],
42
	start_time  => [qw(Start         25    text         )],
50
	location    => [qw(Location      30    select      default )],
43
	end_time    => [qw(End           30    text         )],
51
	time        => [qw(Time          35    text        default )],
44
	mod_time    => [qw(ModTime       35    number         )],
52
	start_time  => [qw(Start         36    text         )],
45
	doubletime  => [qw(DoubleTime    37    boolean         )],
53
	end_time    => [qw(End           40    text         )],
46
	volhours    => [qw(VolHours      40    number         )],
54
	mod_time    => [qw(ModTime       45    number         )],
47
	role        => [qw(Role          45    text      default )],
55
	doubletime  => [qw(DoubleTime    47    boolean         )],
48
	type        => [qw(Type          50    select      default )],
56
	volhours    => [qw(VolHours      50    number         )],
49
	location    => [qw(Location      55    select      default )],
57
	note        => [qw(Notes         55    text        default )],
50
	note        => [qw(Notes         60    text        default )],
58
	RCid        => [qw(AssigneeID    60    text         )],
51
	RCid        => [qw(RCID          65    text         )],
Line 59... Line 52...
59
	derby_name  => [qw(DerbyName     65    select      default   )],
52
	derby_name  => [qw(Assignee      70    select      default   )],
60
);
53
);
61
my $stylesheet = "/style.css";
54
my $stylesheet = "/style.css";
62
my $homeURL = '/schedule/';
55
my $homeURL = '/schedule/';
63
my @pagelimitoptions = ("All", 5, 10, 25);
-
 
64
 
56
my @pagelimitoptions = ("All", 5, 10, 25);
65
my @whereClause;
57
 
66
if ($LVL <= 3 and $user->{department}->{VCI} < 2) {
58
my @whereClause;
67
  my $string = "dept in (".join ",", map { '"'.$_.'"' } grep { $ORCUSER->{department}->{$_} > 0 } keys %{$ORCUSER->{department}};
-
 
Line 68... Line 59...
68
  $string .= ")";
59
if ($LVL < 5) {
69
#   warn $string;
60
  my $string = "dept in (".join ",", map { '"'.$_.'"' } grep { $ORCUSER->{department}->{$_} >= 1 } keys %{$ORCUSER->{department}};
Line 70... Line 61...
70
  push @whereClause, $string;
61
  $string .= ")";
71
}
62
  push @whereClause, $string;
72
push @whereClause, "(dept != 'PER' or RCid = $RCid)";
63
}
73
 
64
push @whereClause, "dept != 'PER'";
Line -... Line 65...
-
 
65
 
-
 
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
 
-
 
69
sub modify_doubletime {
-
 
70
  my $thing = shift;
-
 
71
  return $thing->{doubletime} ? "True" : "False";
-
 
72
}
-
 
73
 
-
 
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." : "";
74
 
83
    return join "&nbsp;", #$hr->{id},
75
# If we need to modify line item values, create a subroutine named "modify_$columnname"
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;
-
 
94
  $hr->{dept} = $DEPTS->{$hr->{dept}};
-
 
95
}
-
 
96
 
-
 
97
sub filter_dept {
-
 
98
  my $colName = shift;
-
 
99
	my $filter = shift;
-
 
100
	
Line -... Line 101...
-
 
101
	if (defined $filter)	{
76
#    It will receive a hashref to the object lineitem
102
		if ($filter eq "-blank-") {
-
 
103
			return "($colName = '' or isNull($colName) = 1)";
-
 
104
		}
-
 
105
		return "$colName = \"$filter\"";
-
 
106
	}	else {
-
 
107
		my $thing = "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};
77
 
109
		my $Options = "<OPTION></OPTION>".$categories;
78
sub modify_doubletime {
110
 
79
  my $thing = shift;
111
		$Options =~ s/>($FORM{$thing})/ selected>$1/;
-
 
112
		return "<SELECT name=filter-${colName} $onChange>$Options</SELECT>";
-
 
113
	}
-
 
114
}
-
 
115
 
-
 
116
sub modify_derby_name {
-
 
117
  my $t = shift;
-
 
118
  
-
 
119
  if ($t->{derby_name}) {
80
  return $thing->{doubletime} ? "True" : "False";
120
    if ($user->{department}->{$t->{dept}} >= RollerCon::LEAD or $LVL >= RollerCon::ADMIN) {
Line 81... Line 121...
81
}
121
      $t->{derby_name} = $h->a ({ href=>"/schedule/view_user.pl?RCid=$t->{RCid}" }, $t->{derby_name});
82
 
122
    } else {
83
sub modify_derby_name {
123
      $t->{derby_name} = "FILLED";
Line 97... Line 137...
97
        hour => 5,
137
        hour => 5,
98
        minute => 0,
138
        minute => 0,
99
        second => 0,
139
        second => 0,
100
        time_zone => 'America/Los_Angeles'
140
        time_zone => 'America/Los_Angeles'
101
  );
141
  );
102
 
142
  
103
 	if (($t->{RCid} == $RCid and $t->{type} ne "selected" and $now < $cutoff) or ($t->{derby_name} and ($user->{department}->{$t->{dept}} >= 2 or $LVL >= 5 or $user->{department}->{VCI} >= 2))) {
143
 	if (($t->{assignee_id} == $RCid and $t->{type} ne "selected" and $now < $cutoff) or ($t->{derby_name} and ($user->{department}->{$t->{dept}} >= 2 or $LVL >= 5))) {
104
 	  if ($t->{dept} eq "PER") {
-
 
105
 	    # DEL Personal Block
-
 
106
 	    $t->{derby_name} .= " ".$h->a ({ onClick=>"if (confirm('Really? You want to delete this personal time?')==true) { window.open('manage_personal_time.pl?choice=Delete&id=$s[0]','Confirm Change','resizable,height=260,width=370'); return false; }" }, "[DEL]");
144
 		# DROP
107
 	  } else {
145
 		$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>";
108
   		# DROP
-
 
109
 	    $t->{derby_name} .= " ".$h->a ({ onClick=>"if (confirm('Really? You want to drop this shift?')==true) { window.open('make_shift_change.pl?change=del&RCid=$t->{RCid}&id=$t->{id}','Confirm Change','resizable,height=260,width=370'); return false; }" }, "[DROP]");
146
 		if ($user->{department}->{$t->{dept}} >= 2 or $LVL > 4) {
110
   		if ($user->{department}->{$t->{dept}} >= 2 or $LVL >= 5 or $user->{department}->{VCI} >= 2) {
-
 
111
   		  # NO SHOW and MOD TIME
-
 
112
   		  $t->{derby_name} .= " | ".$h->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}','Confirm Shift Change','resizable,height=260,width=370'); return false; }" }, "[NO SHOW]");
147
 		  # NO SHOW
113
   		  $t->{derby_name} .= " | ".$h->a ({ onClick=>"window.open('mod_shift_time.pl?RCid=$t->{RCid}&shiftid=$t->{id}','Mod Vol Hours','resizable,height=260,width=370');" }, "[MOD]");
148
 		  $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>";
114
   		}
149
 		}
115
 	  }
-
 
116
 	} elsif (!$t->{derby_name}) {
150
 	} elsif (!$t->{derby_name}) {
117
 		if (signUpEligible ($ORCUSER, $t, "vol") and $now < $cutoff) {
151
 		if (signUpEligible ($ORCUSER, $t, "vol") and $now < $cutoff) {
118
 			# SIGN UP
152
 			# SIGN UP
119
 			$t->{derby_name} = $h->a ({ onClick=>"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]");
153
 			$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>";
120
 		}
154
 		}
121
 		if ($user->{department}->{$t->{dept}} >= 2 or $LVL > 4 or $user->{department}->{VCI} >= 2) {
155
 		if ($user->{department}->{$t->{dept}} >= 2 or $LVL > 4) {
122
 			# ADD USER
156
 			# ADD USER
123
 			$t->{derby_name} ? $t->{derby_name} .= " | " : {};
157
 			$t->{derby_name} ? $t->{derby_name} .= " | " : {};
124
 			$t->{derby_name} .= $h->a ({ onClick=>"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]");
158
 			$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>";
125
 		}
159
 		}
126
 	}
160
 	}
127
 	return $t->{derby_name};
161
 	return $t->{derby_name};
128
}
162
}
Line 129... Line -...
129
 
-
 
130
my $DEPTS = getDepartments;
163
 
131
sub modify_dept {
164
sub modify_time {
132
  my $hr = shift;
165
  my $t = shift;
133
  return $DEPTS->{$hr->{dept}};
166
  return convertTime $t->{time};
Line 134... Line 167...
134
}
167
}
135
 
168
 
136
sub filter_dept {
-
 
137
  my $colName = shift;
-
 
138
	my $filter = shift;
-
 
139
	
-
 
140
	if (defined $filter)	{
-
 
141
		if ($filter eq "-blank-") {
-
 
142
			return "($colName = '' or isNull($colName) = 1)";
-
 
143
		}
-
 
144
		return "$colName = \"$filter\"";
-
 
145
	}	else {
169
sub modify_start_time {
146
		my $thing = "filter-${colName}";	  
-
 
147
    my $categories = join "", map { $FORM{$thing} eq $_ ? $h->option ({ value=>$_, selected=>[] }, $DEPTS->{$_}) : $h->option ({ value=>$_ }, $DEPTS->{$_}) } grep { $LVL > 4 or $user->{department}->{VCI} >= 2 or exists $user->{department}->{$_} } sort keys %{$DEPTS};
-
 
148
		my $Options = "<OPTION></OPTION>".$categories;
-
 
149
 
-
 
150
		$Options =~ s/>($FORM{$thing})/ selected>$1/;
-
 
151
		return "<SELECT name=filter-${colName} $onChange>$Options</SELECT>";
170
  my $t = shift;
Line 152... Line 171...
152
	}
171
  return convertTime $t->{start_time};
153
}
172
}
154
 
173
 
155
sub modify_time {
174
sub modify_end_time {
Line 156... Line 175...
156
  my $t = shift;
175
  my $t = shift;
157
  return convertTime $t->{time};
176
  return convertTime $t->{end_time};
Line 187... Line 206...
187
 
206
 
Line 188... Line 207...
188
	$FORM{$_} = param($_);				# Retrieve all of the FORM data submitted
207
	$FORM{$_} = param($_);				# Retrieve all of the FORM data submitted
189
	
208
	
190
	if ((/^filter/) and ($FORM{$_} ne '')) {	# Build a set of filters to apply
209
	if ((/^filter/) and ($FORM{$_} ne '')) {	# Build a set of filters to apply
191
		my ($filter,$field) = split /-/, $_;		
210
		my ($filter,$field) = split /-/, $_;		
192
		$FILTER->{$field} = $FORM{$_};
-
 
193
	}	elsif ($FORM{$_} eq "true")	{		# Compile list of fields to display
211
		$FILTER->{$field} = $FORM{$_} unless notInArray ($field, \@allFields);
194
	  if ($_ ne "shiftinclude") {
-
 
195
		  push @displayFields, $_;
-
 
196
		}
212
	}	elsif ($FORM{$_} eq "true")			# Compile list of fields to display
197
	}
-
 
198
}
213
		{ push @displayFields, $_; }
Line 199... Line 214...
199
 
214
}
200
my @addToWhereClause = ("year(date) = '$YEAR'", "type != 'announcer'");
215
push @whereClause, "year(date) = '$YEAR'";
201
 
216
 
202
if (exists $FORM{autoload})	{			# If the FORM was submitted (i.e. the page is being redisplayed),
217
if (exists $FORM{autoload})	{			# If the FORM was submitted (i.e. the page is being redisplayed),
Line 203... Line 218...
203
							                    #  	build the data for the cookie that remembers the page setup
218
							                    #  	build the data for the cookie that remembers the page setup
204
	my $disFields = join ":", @displayFields;
219
	my $disFields = join ":", @displayFields;
Line 205... Line 220...
205
	my $fils = join ":", map { "$_=$FILTER->{$_}" } keys %{$FILTER};
220
	my $fils = join ":", map { "$_=$FILTER->{$_}" } keys %{$FILTER};
206
		
221
		
207
	$QUERY_STRING = $disFields.'&'.$fils.'&'.$FORM{sortby}.'&'.$FORM{autoload}.'&'.$FORM{shiftinclude};
222
	$QUERY_STRING = $disFields.'&'.$fils.'&'.$FORM{sortby}.'&'.$FORM{autoload};
208
}
223
}
Line 209... Line 224...
209
 
224
 
210
 
225
 
211
if (!(exists $FORM{autoload}))	{			# No FORM was submitted...
226
if (!(exists $FORM{autoload}))	{			# No FORM was submitted...
212
	if (my $prefs = cookie ($prefscookie) and !defined param ("ignoreCookie"))	{ # Check for cookies from previous visits.
227
	if (my $prefs = cookie ($prefscookie) and !defined param ("ignoreCookie"))	{ # Check for cookies from previous visits.
213
		my ($disF, $filts, $sb, $al, $si) = split /&/, $prefs;
228
		my ($disF, $filts, $sb, $al) = split /&/,$prefs;
Line 214... Line 229...
214
		@displayFields = split /:/,$disF;
229
		@displayFields = split /:/,$disF;
215
		
230
		
216
		foreach my $pair (split /:/, $filts)	{
-
 
217
			my ($key, $value) = split /=/, $pair;
231
		foreach my $pair (split /:/, $filts)	{
218
			$FORM{"filter-$key"} = $value;
232
			my ($key, $value) = split /=/, $pair;
219
			$FILTER->{$key} = $value;
233
			$FORM{"filter-$key"} = $value;
-
 
234
			$FILTER->{$key} = $value;
220
		}
235
		}
221
		
236
		
222
		$FORM{sortby} = $sb;
237
		$FORM{sortby} = $sb;
Line 223... Line 238...
223
		$FORM{autoload} = $al;
238
		$FORM{autoload} = $al;
224
		$FORM{shiftinclude} = $si;
239
		$QUERY_STRING = $prefs;
Line 225... Line 240...
225
		$QUERY_STRING = $prefs;
240
	}	else {
226
	}	else {
241
	  @displayFields = @defaultFields; # Otherwise suppply a default list of columns.
Line 227... Line 242...
227
	  @displayFields = sort byfield @defaultFields; # Otherwise suppply a default list of columns.
242
	  $FORM{sortby} = $displayFields[1];
228
	  $FORM{autoload} = 1;             # And turn aut0load on by default.
243
	  $FORM{autoload} = 1;             # And turn aut0load on by default.
229
	} 
-
 
Line 230... Line 244...
230
}
244
	} 
231
 
245
}
232
# let's just make sure the columns are in the right order (and there aren't any missing)
246
 
-
 
247
# let's just make sure the columns are in the right order (and there aren't any missing)
233
@displayFields = sort byfield uniq @displayFields, @staticFields;
248
@displayFields = grep { inArray($_, \@allFields) } sort byfield uniq @displayFields, @staticFields;
234
 
249
 
Line 235... Line 250...
235
# If the field isn't in the displayFields list,	then add it to the hideFields list
250
# If the field isn't in the displayFields list,	then add it to the hideFields list
236
@hideFields = grep { notInArray ($_, \@displayFields) } @allFields;
251
@hideFields = grep { notInArray ($_, \@displayFields) } @allFields;
Line 252... Line 267...
252
if ($FORM{excel}) {
267
if ($FORM{excel}) {
253
  exportExcel (\@ProductList, "RC_Officiating_Shifts");
268
  exportExcel (\@ProductList, "RC_Officiating_Shifts");
254
  exit;
269
  exit;
255
}
270
}
Line 256... Line -...
256
 
-
 
257
my @shifts;
-
 
258
if ($FORM{shiftinclude} eq "true") {
-
 
259
  my @SIWhere = ("year(date) = '$YEAR'");
-
 
260
  push @SIWhere, "RCid = $ORCUSER->{RCid}";
-
 
261
  my ($d, $c) = getData (\@displayFields, \@SIWhere, $DBTABLE, $FORM{sortby});
-
 
262
  @shifts = @{ $d };
-
 
263
}
-
 
264
 
-
 
265
 
271
 
Line 266... Line 272...
266
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.";
272
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.";
267
 
-
 
268
# Set some cookie stuff...
273
 
269
my ($uri) = split /\?/, $ENV{REQUEST_URI};
274
# Set some cookie stuff...
270
my $path = `dirname $uri`; chomp $path; $path .= '/' unless $path eq "/";
275
my $path = `dirname $ENV{REQUEST_URI}`; chomp $path; $path .= '/' unless $path eq "/";
271
my $queryCookie = cookie(-NAME=>$prefscookie,
276
my $queryCookie = cookie(-NAME=>$prefscookie,
272
			-VALUE=>"$QUERY_STRING",
277
			-VALUE=>"$QUERY_STRING",
Line 273... Line -...
273
			-PATH=>"$path",
-
 
274
			-EXPIRES=>'+365d');
-
 
275
 
-
 
276
my $SIChecked;
-
 
277
if ($FORM{shiftinclude}) {
-
 
278
  $SIChecked = $h->input ({ type=>"checkbox", name=>"shiftinclude", value=>"true", checked=>[], onClick=>'submit();' });
-
 
279
} else {
-
 
280
  $SIChecked = $h->input ({ type=>"checkbox", name=>"shiftinclude", value=>"true", onClick=>'submit();' });
278
			-PATH=>"$path",
281
}
279
			-EXPIRES=>'+365d');
Line 282... Line 280...
282
 
280
 
283
# Print the header
281
# Print the header
Line 297... Line 295...
297
# 
295
# 
298
# 	print "\n\n\n\n<!-- $QUERY_STRING --> \n\n\n\n";
296
# 	print "\n\n\n\n<!-- $QUERY_STRING --> \n\n\n\n";
Line 299... Line 297...
299
 
297
 
-
 
298
 
300
 
299
#------------------
301
#------------------
300
 
302
# Toggle the autoload fields within the table elements 
301
# Toggle the autoload fields within the table elements 
303
our ($onClick, $onChange);   # (also used in scanFunctions)
302
our ($onClick, $onChange);   # (also used in scanFunctions)
304
my ($radiobutton, $refreshbutton, $sortby);
303
my ($radiobutton, $refreshbutton, $sortby);
Line 308... Line 307...
308
  $radiobutton = $h->div ({ class=>'autoload' },
307
  $radiobutton = $h->div ({ class=>'autoload' },
309
    ["Autoload Changes: ",
308
    ["Autoload Changes: ",
310
    $h->input ({ type=>"radio", name=>'autoload', class=>'accent', value=>1, onClick=>'submit();', checked=>[] }), "On ", 
309
    $h->input ({ type=>"radio", name=>'autoload', class=>'accent', value=>1, onClick=>'submit();', checked=>[] }), "On ", 
311
    $h->input ({ type=>"radio", name=>'autoload', class=>'accent', value=>0, onClick=>'submit();' }), "Off ",
310
    $h->input ({ type=>"radio", name=>'autoload', class=>'accent', value=>0, onClick=>'submit();' }), "Off ",
312
    ]);
311
    ]);
-
 
312
  $refreshbutton = "";
313
  $sortby = $h->select ({name=>"sortby", onChange=>'submit();' }, [ map { $FORM{sortby} eq $_ ? $h->option ({ value=>$_, selected=>[] }, $NAME{$_}) : $h->option ({ value=>$_ }, $NAME{$_}) } @displayFields ]);
313
  $sortby = $h->select ({name=>"sortby", onChange=>'submit();' }, [ map { $FORM{sortby} eq $_ ? $h->option ({ value=>$_, selected=>[] }, $NAME{$_}) : $h->option ({ value=>$_ }, $NAME{$_}) } grep { $_ ne "id" } @displayFields ]);
314
} else {
314
} else {
315
  $onClick = "";
315
  $onClick = "";
316
	$onChange = "onChange='page.value = 1;'";
316
	$onChange = "onChange='page.value = 1;'";
317
  $radiobutton = $h->div ({ class=>'autoload' }, 
317
  $radiobutton = $h->div ({ class=>'autoload' }, 
318
    ["Autoload Changes: ",
318
    ["Autoload Changes: ",
Line 323... Line 323...
323
  $sortby = $h->select ({name=>"sortby" }, [ map { $FORM{sortby} eq $_ ? $h->option ({ value=>$_, selected=>[] }, $NAME{$_}) : $h->option ({ value=>$_ }, $NAME{$_}) } @displayFields ]);
323
  $sortby = $h->select ({name=>"sortby" }, [ map { $FORM{sortby} eq $_ ? $h->option ({ value=>$_, selected=>[] }, $NAME{$_}) : $h->option ({ value=>$_ }, $NAME{$_}) } @displayFields ]);
324
}
324
}
Line -... Line 325...
-
 
325
 
325
 
326
 
326
 
-
 
Line 327... Line 327...
327
 
327
 
328
print start_html (-title => $pageTitle, -style => {'src' => $stylesheet} );
328
	 
329
#printRCHeader ($pageTitle);
329
print start_html (-title => $pageTitle, -style => {'src' => $stylesheet} );
330
 
330
 
Line 372... Line 372...
372
  push @topleft, $h->div ({ class=>'rTable' }, [ @hiddenrows ]);
372
  push @topleft, $h->div ({ class=>'rTable' }, [ @hiddenrows ]);
Line 373... Line 373...
373
  
373
  
374
  print $h->div ({ class=>"sp0" }, [
374
  print $h->div ({ class=>"sp0" }, [
375
    $h->div ({ class=>"spLeft"  }, [ @topleft ]),
375
    $h->div ({ class=>"spLeft"  }, [ @topleft ]),
376
    $h->div ({ class=>"spRight" }, [
376
    $h->div ({ class=>"spRight" }, [
377
      $signedOnAs, $h->br,
-
 
378
      "Show my shifts: ", $SIChecked, $h->br,
-
 
379
      $h->input ({ type=>"button", value=>"Block Personal Time", onClick=>"window.location.href='manage_personal_time.pl'" }),
377
      $signedOnAs
380
    ])
378
    ])
381
  ]);
379
  ]);
Line 382... Line 380...
382
}
380
}
Line 383... Line 381...
383
 
381
 
Line 384... Line 382...
384
# Print the main table...............................................
382
# Print the main table...............................................
385
 
383
 
386
print $h->open ('div', { class=>'rTable' });
384
print $h->open ('div', { class=>'rTable' });
387
 
385
 
388
my @tmptitlerow;
386
my @tmptitlerow;
389
foreach my $f (@displayFields)	{  # Print the Column headings
387
foreach my $f (@displayFields)	{  # Print the Column headings
390
  if (inArray ($f, \@staticFields)) {
388
  if ($f eq $allFields[0]) {
391
    push @tmptitlerow, $h->div ({ class=>'rTableHead' }, [ $h->input ({ type=>"hidden", name=>$f, value=>"true" }), $NAME{$f}, "&nbsp;", $h->input ({ type=>"button", value=>"Add", onClick=>"window.location.href='manage_shift.pl'" }) ]);
389
    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
  } else {
390
  } else {
Line 399... Line 397...
399
}
397
}
Line 400... Line 398...
400
 
398
 
401
# Print the filter boxes...
399
# Print the filter boxes...
Line 402... Line -...
402
print $h->div ({ class=>'rTableHeading' }, [ @tmptitlerow ], [ map { $h->div ({ class=>'rTableCell filters' }, filter ($_)) } @displayFields ], $h->div ({ class=>"rTableCell" }));
-
 
403
 
-
 
404
if ($FORM{shiftinclude}) {  # Include all of the user's shifts at the top
-
 
405
  foreach my $t (@shifts)	{
-
 
406
	  print $h->div ({ class=>'rTableRow highlighted' }, [ map { $h->div ({ class=>'rTableCell' }, exists &{"modify_".$_} ? &{"modify_".$_} ($t) : $t->{$_}) } @displayFields ]);
-
 
407
  }
-
 
408
  print $h->hr ({ width=>"500%" });
-
 
409
}
400
print $h->div ({ class=>'rTableHeading' }, [ @tmptitlerow ], [ map { $h->div ({ class=>'rTableCell filters' }, filter ($_)) } @displayFields ], $h->div ({ class=>"rTableCell" }));
410
 
-
 
411
# Print the things
-
 
412
#foreach my $t (@ProductList)	{
-
 
413
#  print $h->div ({ class=>'rTableRow shaded' }, [ map { $h->div ({ class=>'rTableCell' }, exists &{"modify_".$_} ? &{"modify_".$_} ($t) : $t->{$_}) } @displayFields ]);
401
 
414
#}
-
 
415
foreach my $t (@ProductList)	{
402
# Print the things
416
  if ($t->{RCid} eq $ORCUSER->{RCid}) {
-
 
417
	  print $h->div ({ class=>'rTableRow highlighted' }, [ map { $h->div ({ class=>'rTableCell' }, exists &{"modify_".$_} ? &{"modify_".$_} ($t) : $t->{$_}) } @displayFields ]);
-
 
418
  } else {
-
 
419
	  print $h->div ({ class=>'rTableRow shaded' }, [ map { $h->div ({ class=>'rTableCell' }, exists &{"modify_".$_} ? &{"modify_".$_} ($t) : $t->{$_}) } @displayFields ]);
403
foreach my $t (@ProductList)	{
Line 420... Line 404...
420
  }
404
  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 ]);
Line 421... Line 405...
421
}
405
}