Subversion Repositories ORC

Rev

Rev 8 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8 Rev 35
Line 1... Line 1...
1
#!/usr/bin/perl
1
#!/usr/bin/perl
Line 2... Line 2...
2
 
2
 
Line -... Line 3...
-
 
3
#if ($ENV{SHELL}) { die "This script shouldn't be executed from the command line!\n"; }
3
#if ($ENV{SHELL}) { die "This script shouldn't be executed from the command line!\n"; }
4
 
-
 
5
#use strict;
4
 
6
use cPanelUserConfig;
5
use cPanelUserConfig;
7
use CGI qw/param cookie header start_html url/;
6
use CGI qw/:standard/;
8
use HTML::Tiny;
7
use scanFunctions;
-
 
8
use RollerCon;
-
 
9
use Spreadsheet::WriteExcel;
9
use tableViewer;
Line 10... Line 10...
10
use DateTime;
10
use RollerCon;
11
use DateTime::Duration;
11
our $h = HTML::Tiny->new( mode => 'html' );
12
 
12
 
13
my $secure = "";
13
my $secure = "";
14
if ($ENV{REQUEST_URI}  =~ /^\/scores.pl/) {
14
if ($ENV{REQUEST_URI}  =~ /^\/scores.pl/) {
15
	$secure = 0;
15
	$secure = 0;
Line 16... Line 16...
16
} else {
16
} else {
17
	$secure = 1;
17
	$secure = 1;
18
}
18
}
19
 
19
 
20
my $cookie_string;
20
my $cookie_string;
21
my ($EML, $PWD, $LVL);
21
our ($EML, $PWD, $LVL);
22
my $user;
22
my $user;
Line 23... Line 23...
23
my $username;
23
my $username;
24
my $RCid;
24
my $RCid;
25
my $RCAUTH_cookie;
25
my $RCAUTH_cookie;
26
my $YEAR = 1900 + (localtime)[5]; #which year of data to display, default to current
26
my $YEAR = "2022";
27
 
27
 
28
if ($secure) {
28
if ($secure) {
29
	$cookie_string = authenticate(2) || die;
29
	$cookie_string = authenticate(2) || die;
30
	($EML, $PWD, $LVL) = split /&/, $cookie_string;
30
	($EML, $PWD, $LVL) = split /&/, $cookie_string;
Line -... Line 31...
-
 
31
	$user = getUser($EML);
-
 
32
	$username = $h->a ({ href=>"/schedule/manage_user.pl?submit=View&RCid=$user->{RCid}" }, $user->{derby_name});
-
 
33
	$RCid = $user->{RCid};
31
	$user = getUser($EML);
34
	$RCAUTH_cookie = CGI::Cookie->new(-name=>'RCAUTH',-value=>"$cookie_string",-expires=>"+30m");
32
	$username = $user->{derby_name};
35
}
-
 
36
 
-
 
37
 
-
 
38
my $pageTitle = "Game Scores";
-
 
39
my $prefscookie = "rcscores";
-
 
40
our $DBTABLE = 'v_scores';
-
 
41
my %COLUMNS = (
-
 
42
# colname   =>  [qw(DisplayName       N    type     status)],   status ->  static | default | <blank>
-
 
43
	id					=> [qw(ID            5    number            )],
-
 
44
	date				=> [qw(Date         10    date              )],
-
 
45
	dayofweek		=> [qw(Day          15    select    default )],
-
 
46
	track				=> [qw(Track        20    select    default )],
-
 
47
	type				=> [qw(Type         25    select            )],
-
 
48
	time				=> [qw(Time         30    text      default )],
-
 
49
	team1				=> [qw(Team1        35    text      static )],
-
 
50
	team2				=> [qw(Team2        40    text      static )]
-
 
51
);
-
 
52
my $stylesheet = "/style.css";
-
 
53
my $homeURL = '/schedule/';
-
 
54
my @pagelimitoptions = ("All", 5, 10, 25);
-
 
55
 
33
	$RCid = $user->{RCid};
56
# Set any custom "where" DB filters here...
34
	$RCAUTH_cookie = CGI::Cookie->new(-name=>'RCAUTH',-value=>"$cookie_string",-expires=>"+30m");
57
my @whereClause;
35
}
58
 
-
 
59
# If we need to modify line item values, create a subroutine named "modify_$columnname"
-
 
60
#    It will receive a hashref to the object lineitem
36
 
61
 
-
 
62
sub modify_id {
-
 
63
  my $t = shift;
-
 
64
 	if ($secure) {
37
our $DBTABLE = 'v_scores';
65
  	if ($t->{team1_score} or $t->{team2_score}) {
-
 
66
			$t->{id} .= " <A HREF='#' onClick=\"window.open('update_score.pl?GID=$t->{id}','Enter Score','resizable,height=260,width=370'); return false;\">[update score]</a>";
-
 
67
		} else {
38
our %NAME = qw(
68
			$t->{id} .= " <A HREF='#' onClick=\"window.open('update_score.pl?GID=$t->{id}','Enter Score','resizable,height=260,width=370'); return false;\">[enter score]</a>";
39
		id						 ID
69
		}
-
 
70
	}
-
 
71
  return $t->{id};
-
 
72
}
-
 
73
 
-
 
74
sub modify_team1 {
-
 
75
  my $t = shift;
40
		date					 Date
76
	$t->{team1} .= " ($t->{team1_score})" unless !defined $t->{team1_score};
41
		dayofweek			 Day
77
	$t->{team2} .= " ($t->{team2_score})" unless !defined $t->{team2_score};;
-
 
78
  
-
 
79
	if ($t->{team1_score} > 0 or $t->{team2_score} > 0) { #SPIKE SEZ DO SOMETHING HERE RE GAME SCORE OF 0
-
 
80
 		if ($t->{team1_score} > $t->{team2_score}) { $t->{team1} = "<b>$t->{team1}</b>"; } else { $t->{team2} = "<b>$t->{team2}</b>"; }
-
 
81
  }
-
 
82
 	return $t->{team1};
-
 
83
}
-
 
84
 
-
 
85
 
42
		track					 Track
86
 
43
		type					 Type
87
# Ideally, nothing below this comment needs to change
-
 
88
#-------------------------------------------------------------------------------
44
		time					 Time
89
 
-
 
90
 
-
 
91
our %NAME              = map  { $_ => $COLUMNS{$_}->[0] } keys %COLUMNS;
45
		team1					 Team1
92
our %colOrderHash      = map  { $_ => $COLUMNS{$_}->[1] } keys %COLUMNS;
46
		team2					 Team2
93
our %colFilterTypeHash = map  { $_ => $COLUMNS{$_}->[2] } keys %COLUMNS;
47
	);
94
our @staticFields      = sort byfield grep { $COLUMNS{$_}->[3] eq 'static' } keys %COLUMNS;
48
our %colOrderHash = qw(id 1 date 2 dayofweek 3 track 4 time 5 type 6 team1 7 team2 8);
-
 
49
my $orderby = "date, time";
95
our @defaultFields     = sort byfield grep { defined $COLUMNS{$_}->[3] } keys %COLUMNS;
50
our @allFields = sort { $colOrderHash{$a} <=> $colOrderHash{$b} } keys %NAME;
-
 
51
our @defaultFields = (qw(dayofweek track time team1 team2));
-
 
52
our @displayFields = ();
-
 
53
our @hideFields = ();
-
 
54
our %colFilterTypeHash = qw(
-
 
55
		id						 number
-
 
56
		date					 date
-
 
57
		dayofweek			 select
-
 
Line -... Line 96...
-
 
96
#our @defaultFields     = grep { $COLUMNS{$_}->[3] eq 'default' or inArray ($_, \@staticFields) } keys %COLUMNS;
-
 
97
 
Line 58... Line 98...
58
		track					 select
98
our @allFields = sort byfield keys %NAME;
-
 
99
our @displayFields = ();
59
		type					 select
100
our @hideFields = ();
60
		time					 text
-
 
61
		team1					 text
101
my $QUERY_STRING;
62
		team2					 text
102
 
63
	);
103
my $pagelimit = param ("limit") // $pagelimitoptions[$#pagelimitoptions];
64
 
104
my $curpage = param ("page") // 1;
65
 
105
 
66
 
106
our %FORM;
Line 67... Line 107...
67
foreach (param())
107
my $FILTER;
68
{
-
 
69
	if (/^year$/) { #
108
foreach (param()) {
70
		$YEAR = param($_);
-
 
71
		next;
109
 	if (/^year$/) { #
72
	}
-
 
73
	
110
		$YEAR = param($_);
-
 
111
		next;
-
 
112
	}
-
 
113
 
-
 
114
	$FORM{$_} = param($_);				# Retrieve all of the FORM data submitted
-
 
115
	
74
	$FORM{$_} = param($_);				# Retrieve all of the FORM data submitted
116
	if ((/^filter/) and ($FORM{$_} ne '')) {	# Build a set of filters to apply
75
	
117
		my ($filter,$field) = split /-/, $_;		
Line 76... Line 118...
76
	if ((/^filter/) and ($FORM{$_} ne ''))		# Build a set of filters to apply
118
		$FILTER->{$field} = $FORM{$_};
77
		{		
119
	}	elsif ($FORM{$_} eq "true")			# Compile list of fields to display
78
		my ($filter,$field) = split /-/, $_;
120
		{ push @displayFields, $_; }
79
		
-
 
80
		$FILTER->{$field} = $FORM{$_};
-
 
81
		}
-
 
82
	elsif ($FORM{$_} eq "true")			# Compile list of fields to display
121
}
83
		{ push @displayFields, $_; }			# @displayFields is declared in scanFunctions.pm
-
 
Line 84... Line 122...
84
}
122
 
85
 
123
my @yearoptions;
Line 86... Line 124...
86
 
124
foreach (@{&getYears()}) {
87
if (exists $FORM{autoload})				# If the FORM was submitted (i.e. the page is being redisplayed),
-
 
88
{							#	build the data for the cookie that remembers the page setup
125
	push @yearoptions, $YEAR eq $_ ? $h->option ({ selected=>[] }, $_) : $h->option ($_);
89
	my $disFields = join ":", @displayFields;
-
 
90
	my @filters;
126
}
91
	my @f = keys %{$FILTER};
127
 
Line 92... Line 128...
92
	foreach $key (@f)
128
 
93
		{ push @filters, "$key=$FILTER->{$key}"; }
-
 
94
	my $fils = join ":", @filters;
129
if (exists $FORM{autoload})	{			# If the FORM was submitted (i.e. the page is being redisplayed),
95
		
130
							                    #  	build the data for the cookie that remembers the page setup
96
	$QUERY_STRING = "$disFields\&$fils\&$FORM{autoload}";
131
	my $disFields = join ":", @displayFields;
97
}
132
	my $fils = join ":", map { "$_=$FILTER->{$_}" } keys %{$FILTER};
Line -... Line 133...
-
 
133
		
98
 
134
	$QUERY_STRING = $disFields.'&'.$fils.'&'.$FORM{sortby}.'&'.$FORM{autoload};
99
 
135
}
100
if (!(exists $FORM{autoload}))				# No FORM was submitted, suppply a default list of columns
-
 
101
{
136
 
102
	if (my $prefs = cookie('RCSCORES'))	# Has this user been here before and saved a cookie?
137
 
-
 
138
if (!(exists $FORM{autoload}))	{			# No FORM was submitted...
-
 
139
	if (my $prefs = cookie ($prefscookie) and !defined param ("ignoreCookie"))	{ # Check for cookies from previous visits.
103
	{
140
		my ($disF, $filts, $sb, $al) = split /&/,$prefs;
Line -... Line 141...
-
 
141
		@displayFields = split /:/,$disF;
-
 
142
		
Line 104... Line -...
104
		my ($disF, $filts, $al) = split /&/,$prefs;
-
 
105
		@displayFields = split /:/,$disF;
143
		foreach my $pair (split /:/, $filts)	{
106
		
-
 
107
		foreach $pair (split /:/, $filts)
-
 
108
		{
-
 
109
			my ($key, $value) = split /=/, $pair;
144
			my ($key, $value) = split /=/, $pair;
110
			$FORM{"filter-$key"} = $value;
-
 
111
			$FILTER->{$key} = $value;
-
 
112
		}
-
 
113
		
-
 
114
		$FORM{autoload} = $al;
-
 
115
		$QUERY_STRING = $prefs;
-
 
116
	}
-
 
117
	else
-
 
118
		{ @displayFields = @defaultFields; }
-
 
119
}
-
 
120
 
-
 
121
 
-
 
122
							# Build the field lists to display and hide columns.
-
 
123
							#	If the field isn't in the displayFields list,
-
 
Line 124... Line 145...
124
							#	then add it to the hideFields list.
145
			$FORM{"filter-$key"} = $value;
125
							#
-
 
126
@displayFields = sort byfield @displayFields;
-
 
127
foreach $field (@allFields) { if (! &inArray($field, \@displayFields)) { push @hideFields, $field; } }
146
			$FILTER->{$key} = $value;
128
 
147
		}
Line 129... Line -...
129
 
-
 
130
my @whereClause = ("year(date) = '$YEAR'");					# Process the filters to build the components of the where clause
-
 
131
foreach $field (@allFields)
-
 
132
{
148
		
133
	if (! &inArray($field, \@hideFields))
-
 
134
	{
149
		$FORM{sortby} = $sb;
135
		if ($FILTER->{$field})
-
 
136
		{
150
		$FORM{autoload} = $al;
137
			push @whereClause, &generica($field, $FILTER->{$field});
-
 
138
			delete $FILTER->{$field};
151
		$QUERY_STRING = $prefs;
139
		}
-
 
140
	}
152
	}	else {
141
}
-
 
142
 
-
 
143
							#  Given the fields to display and the where conditions,
-
 
144
							#	"getData" will return a reference to an array of
-
 
145
							#	hash references of the results.
-
 
Line 146... Line -...
146
my @ProductList = @{&getData(\@displayFields, \@whereClause, $DBTABLE, $orderby)};
-
 
147
my $x = scalar @ProductList;
-
 
148
 
-
 
149
 
-
 
150
if ($secure) {
-
 
151
	if ($FORM{excel})
-
 
152
	{
-
 
153
		my $date = `date +"%m%d%y%H%M%S"`; chomp $date;
153
	  @displayFields = @defaultFields; # Otherwise suppply a default list of columns.
154
	#	$filename = `dirname $ENV{REQUEST_URI}`; chomp $filename; $filename .= "/xls/${date}_$$.xls";
-
 
155
		$filename = "/schedule/xls/${date}_$$.xls";
154
	  $FORM{autoload} = 1;             # And turn aut0load on by default.
156
		
-
 
157
	        # Create a new Excel workbook
-
 
158
#		my $workbook = Spreadsheet::WriteExcel->new("/var/www/html${filename}");
-
 
159
	my $workbook = Spreadsheet::WriteExcel->new("/home/rollerco/officials.rollercon.com${filename}");
-
 
160
		
-
 
161
	        # Add a worksheet
-
 
162
	        my $worksheet = $workbook->add_worksheet();
-
 
163
	        
-
 
164
	#	open my $fh, '>', \my $str or die "Failed to open filehandle: $!";
-
 
165
	#	my $workbook  = Spreadsheet::WriteExcel->new($fh);
-
 
166
	#	my $worksheet = $workbook->add_worksheet();
-
 
167
 
-
 
168
		
-
 
169
		my $format = $workbook->add_format();
-
 
170
		$format->set_bold();
-
 
Line -... Line 155...
-
 
155
	} 
-
 
156
}
-
 
157
 
171
		
158
# let's just make sure the columns are in the right order (and there aren't any missing)
172
		my $col = $row = 0;
159
@displayFields = sort byfield uniq @displayFields, @staticFields;
Line -... Line 160...
-
 
160
 
Line -... Line 161...
-
 
161
# If the field isn't in the displayFields list,	then add it to the hideFields list
173
		
162
@hideFields = grep { notInArray ($_, \@displayFields) } @allFields;
174
		foreach $f (@displayFields)
163
 
175
			{ $worksheet->write($row, $col++, "$NAME{$f}", $format); }
164
# Process any filters provided in the form to pass to the database
176
		
165
push @whereClause, map { filter ($_, $FILTER->{$_}) } grep { defined $FILTER->{$_} } @displayFields;
177
		foreach $t (sort @ProductList)			# Unt now we print the tickets!
166
push @whereClause, "year(date) = '$YEAR'";
178
		{
-
 
179
			$col = 0;
-
 
180
			$row++;
-
 
Line -... Line 167...
-
 
167
 
181
			if (exists $f->{team1_score} and exists $f->{team2_score}) {
168
 
182
				$f->{team1} .= " ($f->{team1_score})";
169
							#  Given the fields to display and the where conditions,
183
				$f->{team2} .= " ($f->{team2_score})";
170
							#	  "getData" will return a reference to an array of
184
			}
171
							#	  hash references of the results.
185
 
172
my ($data, $datacount) = getData (\@displayFields, \@whereClause, $DBTABLE, $FORM{sortby}, $curpage, $pagelimit);
Line 186... Line -...
186
			foreach $f (@displayFields)
-
 
187
				{
173
my @ProductList = @{ $data };
188
					$t->{$f} =~ s/<br>/\n/ig; $worksheet->write($row, $col++, "$t->{$f}");
174
 
189
				}
175
#my @ProductList = @{ getData (\@displayFields, \@whereClause, $DBTABLE, $FORM{sortby}, $curpage, $pagelimit) };
190
		}
176
my $x = scalar @ProductList; # How many results were returned?
191
		
177
 
192
		$workbook->close();
178
# If the user is trying to download the Excel file, send it to them and then exit out.
193
 
179
if ($secure and $FORM{excel}) {
194
	}
180
  exportExcel (\@ProductList, "RC_Officiating_Shifts");
195
}
181
  exit;
196
 
182
}
197
 
-
 
198
my $path = `dirname $ENV{REQUEST_URI}`; chomp $path; $path .= '/';
183
 
199
my $queryCookie = cookie(-NAME=>'RCSCORES',
184
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.";
200
			-VALUE=>"$QUERY_STRING",
185
 
Line 201... Line 186...
201
			-PATH=>"$path",
186
# Set some cookie stuff...
Line 202... Line -...
202
			-EXPIRES=>'+365d');
-
 
203
#my $Auth_Cook = cookie(-NAME=>'RequestToolAuthorized',
187
my $path = `dirname $ENV{REQUEST_URI}`; chomp $path; $path .= '/' unless $path eq "/";
204
#			-VALUE=>"$authCookie",
-
 
205
#			-PATH=>'/cbrt/cgi-bin/');
-
 
206
 
-
 
207
if ($secure) {
-
 
208
	print header(-cookie=>[$RCAUTH_cookie,$queryCookie]);
-
 
209
} else {
-
 
210
	print header(-cookie=>[$queryCookie]);	
-
 
211
}
-
 
212
 
-
 
213
 
-
 
214
 	print "<!-- FORM \n\n";				# Debug code to dump the FORM to a html comment
-
 
215
	print "I'm catching updates!!!\n\n";
-
 
216
	foreach $key (sort (keys %FORM))		#	Must be done after the header is written!
-
 
217
 		{ print "\t$key:  $FORM{$key}\n"; }
-
 
218
 	print "--> \n\n";
-
 
219
# 	
-
 
220
# 
-
 
221
 	print "<!-- ENV \n\n";				# Debug code to dump the ENV to a html comment
188
my $queryCookie = cookie(-NAME=>$prefscookie,
222
# 	foreach $key (sort (keys %ENV))			#	Must be done after the header is written!
-
 
223
# 		{ print "\t$key:  $ENV{$key}\n"; }
-
 
224
	print "REQUEST_URI: $ENV{REQUEST_URI}\n";
-
 
225
 	print "--> \n\n";
-
 
226
# 
-
 
227
# 	print "\n\n\n\n<!-- $QUERY_STRING --> \n\n\n\n";
-
 
228
 
-
 
229
 
-
 
230
#------------------
-
 
231
 
-
 
232
 
-
 
233
if ($FORM{autoload})					  # Toggle the autoload fields within the table elements
-
 
234
	{ $auto = "onClick='submit();'";
-
 
235
	 $auto2 = "onChange='submit();'"; }
-
 
236
else
-
 
237
	{ $auto = "";
-
 
238
	 $auto2 = ""; }
-
 
239
 
-
 
240
 
-
 
241
my $signedOnAs = $username ? "You are currently signed in as $username. <font size=-2><a href='index.pl' onClick=\"document.cookie = 'RCAUTH=; expires=Thu, 01 Jan 1970 00:00:01 GMT; path=/';return true;\">[Log Out]</a></font>" : "You are not signed in.";
-
 
242
my $xlsLink = $filename ? "&nbsp; &nbsp; <A href='$filename'><FONT color='#0077BD'>Download Now.</FONT></a>" : "";
-
 
243
my $yearoptions;
-
 
244
foreach (@{&getYears()}) {
-
 
245
	$yearoptions .= $YEAR eq $_ ? "<option selected>$_</option>" : "<option>$_</option>";
189
			-VALUE=>"$QUERY_STRING",
246
}
-
 
247
 
-
 
248
print<<header;
-
 
249
	<html><head><title>RollerCon Game Scores - $YEAR</title></head>
-
 
250
	<body text="#000000" bgcolor="#FFFFFF" link="#000000" vlink="#000000" alink="#FF0000">
-
 
251
	<form action="scores.pl" method=POST name=Scores>
-
 
252
	<input type=hidden name=excel value=0>
-
 
253
	
-
 
254
	<TABLE cellpadding=0 cellspacing=0 hspace=0 vspace=0 border=0>
-
 
255
		<TR>
-
 
256
			<TD>
-
 
257
			<TABLE cellpadding=0 cellspacing=0 hspace=0 vspace=0 border=0>
-
 
258
				<TR>
190
			-PATH=>"$path",
259
					<TD width=680 bgcolor="#0077BD" height=60><FONT color=white face=verdana size=6><i><strong>&nbsp;RollerCon Game Scores - $YEAR</strong></i></font></TD>
-
 
260
					<TD><img SRC="/images/headerblank.gif" NOSAVE height=38 width=165></TD>
191
			-EXPIRES=>'+365d');
261
				</TR>
192
 
262
			</TABLE>
-
 
263
			</TD>
-
 
264
		<TR>
-
 
265
			<TD>&nbsp</TD>
-
 
266
		</TR>
193
# Print the header
267
		<TR>
-
 
268
			<TD>
-
 
269
			<TABLE cellpadding=0 cellspacing=0 hspace=0 vspace=0 border=0>
194
if ($secure) {
270
				<TR>
-
 
271
					<TD rowspan=2 align=left width=610>
-
 
272
					<TABLE border=0 cellspacing=0>
195
	print header(-cookie=>[$RCAUTH_cookie,$queryCookie]);
273
header
-
 
274
 
-
 
275
							# Print the Hidden fields' check boxes
-
 
276
 
-
 
277
					my $tc = 1;
-
 
278
					foreach $field (sort { $NAME{$a} cmp $NAME{$b}; } @hideFields)
196
} else {
279
						{
197
	print header(-cookie=>[$queryCookie]);	
280
						if ($tc == 1)
-
 
281
							{print "\t\t\t\t\t\t<TR>\n\t\t\t\t\t\t\t<TD width=25% nowrap><FONT face=verdana size=1><b><INPUT type=checkbox name=$field value=true $auto>$NAME{$field}</TD>\n"; $tc++;}
-
 
282
						elsif ($tc == 4)
-
 
283
							{print "\t\t\t\t\t\t\t<TD width=25% nowrap><FONT face=verdana size=1><b><INPUT type=checkbox name=$field value=true $auto>$NAME{$field}</TD>\n\t\t\t\t\t\t</TR>\n"; $tc=1;}
198
}
284
						else 
-
 
285
							{print "\t\t\t\t\t\t\t<TD width=25% nowrap><FONT face=verdana size=1><b><INPUT type=checkbox name=$field value=true $auto>$NAME{$field}</TD>\n"; $tc++;}
-
 
286
						}
-
 
287
 
-
 
288
 					if ($FORM{autoload}) 
-
 
289
 						{
-
 
290
 						$trueChecked = "checked";
-
 
291
 						$falseChecked = "";
199
 
-
 
200
# 	print "<!-- FORM \n\n";				# Debug code to dump the FORM to a html comment
-
 
201
#	print "I'm catching updates!!!\n\n";
-
 
202
#	foreach $key (sort (keys %FORM))		#	Must be done after the header is written!
-
 
203
# 		{ print "\t$key:  $FORM{$key}\n"; }
-
 
204
# 	print "--> \n\n";
-
 
205
# 	
-
 
206
# 
-
 
207
# 	print "<!-- ENV \n\n";				# Debug code to dump the ENV to a html comment
-
 
208
# 	foreach $key (sort (keys %ENV))			#	Must be done after the header is written!
-
 
209
# 		{ print "\t$key:  $ENV{$key}\n"; }
-
 
210
# 	print "--> \n\n";
-
 
211
# 
-
 
212
# 	print "\n\n\n\n<!-- $QUERY_STRING --> \n\n\n\n";
-
 
213
 
-
 
214
 
-
 
215
#------------------
-
 
216
 
-
 
217
# Toggle the autoload fields within the table elements 
-
 
218
our ($onClick, $onChange);   # (also used in scanFunctions)
-
 
219
my ($radiobutton, $refreshbutton, $sortby);
-
 
220
if ($FORM{autoload}) {					  
-
 
221
	$onClick = "onClick='submit();'";
-
 
222
	$onChange = "onChange='page.value = 1; submit();'";
-
 
223
  $radiobutton = $h->div ({ class=>'autoload' },
-
 
224
    ["Autoload Changes: ",
-
 
225
    $h->input ({ type=>"radio", name=>'autoload', class=>'accent', value=>1, onClick=>'submit();', checked=>[] }), "On ", 
-
 
226
    $h->input ({ type=>"radio", name=>'autoload', class=>'accent', value=>0, onClick=>'submit();' }), "Off ",
-
 
227
    ]);
-
 
228
  $sortby = $h->select ({name=>"sortby", onChange=>'submit();' }, [ map { $FORM{sortby} eq $_ ? $h->option ({ value=>$_, selected=>[] }, $NAME{$_}) : $h->option ({ value=>$_ }, $NAME{$_}) } @displayFields ]);
-
 
229
} else {
-
 
230
  $onClick = "";
-
 
231
	$onChange = "onChange='page.value = 1;'";
-
 
232
  $radiobutton = $h->div ({ class=>'autoload' }, 
-
 
233
    ["Autoload Changes: ",
-
 
234
    $h->input ({ type=>"radio", name=>'autoload', class=>'accent', value=>1, onClick=>'submit();' }), "On ", 
-
 
235
    $h->input ({ type=>"radio", name=>'autoload', class=>'accent', value=>0, onClick=>'submit();', checked=>[] }), "Off ",
-
 
236
    ]);
-
 
237
  $refreshbutton = $h->input ({ type=>"button", value=>"Refresh", onClick=>"submit(); return false;" });
-
 
238
  $sortby = $h->select ({name=>"sortby" }, [ map { $FORM{sortby} eq $_ ? $h->option ({ value=>$_, selected=>[] }, $NAME{$_}) : $h->option ({ value=>$_ }, $NAME{$_}) } @displayFields ]);
-
 
239
}
292
 						}
240
 
-
 
241
 
-
 
242
 
-
 
243
	 
-
 
244
print start_html (-title => $pageTitle, -style => {'src' => $stylesheet} );
-
 
245
 
-
 
246
print $h->open ('form', { action=>url, method=>'POST', name=>'Req' });
-
 
247
print $h->input ({ type=>"hidden", name=>"excel", value=>0 });
-
 
248
print $h->div ({ class => "accent pageheader" }, [
-
 
249
  $h->h1 ($pageTitle),
-
 
250
  $h->div ({ class=>"sp0" }, [
-
 
251
    $h->div ({ class=>"spLeft" }, [
-
 
252
      $radiobutton
-
 
253
    ]),
-
 
254
    $h->div ({ class=>"spRight" }, [
-
 
255
      $h->input ({ type=>"button", value=>"Home", onClick=>"window.location.href='$homeURL'" }),
-
 
256
      $refreshbutton
-
 
257
    ]),
-
 
258
  ]),
-
 
259
]);
-
 
260
 
-
 
261
# Print the Hidden fields' check boxes (if there are any)
-
 
262
 
-
 
263
my $c = 1;
-
 
264
my @hiddencheckboxes;
-
 
265
my @hiddenrows;
-
 
266
foreach my $field (sort { $NAME{$a} cmp $NAME{$b}; } @hideFields) {
-
 
267
  if ($FORM{autoload}) {
-
 
268
    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} ]);
-
 
269
  } else {
-
 
270
    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} ]);
-
 
271
  }
-
 
272
  if ($c++ % 4 == 0) {
-
 
273
    push @hiddenrows, $h->div ({ class=>'rTableRow' }, [ @hiddencheckboxes ]);
-
 
274
    @hiddencheckboxes = [];
-
 
275
  }
-
 
276
}
-
 
277
push @hiddenrows, $h->div ({ class=>'rTableRow' }, [ @hiddencheckboxes ]) unless --$c % 4 == 0;
-
 
278
 
-
 
279
 
-
 
280
if (scalar @hideFields) {
-
 
281
  my @topleft;
-
 
282
  push @topleft, $h->div ({ class=>"nowrap" }, "Hidden Columns:");
-
 
283
  push @topleft, $h->div ({ class=>'rTable' }, [ @hiddenrows ]);
-
 
284
  
-
 
285
  print $h->div ({ class=>"sp0" }, [
293
 					else 
286
    $h->div ({ class=>"spLeft"  }, [ @topleft ]),
Line 294... Line -...
294
 						{
-
 
Line 295... Line -...
295
 						$trueChecked = "";
-
 
296
 						$falseChecked = "checked";
-
 
297
 	 					}
-
 
298
 
-
 
299
					print<<header3;
-
 
300
						<TR>
-
 
301
							<TD colspan=4 align=center><FONT face=verdana size=1 color=#0077BD><B>
-
 
302
							Autoload: <INPUT type=radio name=autoload value=1 onClick='Scores.submit();' $trueChecked>On  <INPUT type=radio name=autoload value=0 onClick='Scores.submit();' $falseChecked>Off
-
 
303
							</TD>
-
 
304
						</TR>
-
 
305
					</TABLE>
-
 
306
					</TD>
-
 
307
					<TD nowrap>
-
 
308
						<A HREF='' onClick="window.document.Scores.submit(); return false;"><IMG SRC='/images/refresh.button.gif' border=0></A><br>
-
 
309
header3
-
 
310
 
-
 
311
if ($secure) {
-
 
312
	print<<header5;
-
 
313
						<strong><a href='' onClick='window.document.Scores.excel.value=1; window.document.Scores.submit(); return false;'><FONT face=verdana size=1>Export Displayed Data as Excel Document.</a>$xlsLink</font>
-
 
314
					</TD>
-
 
315
				</TR>
-
 
316
				<TR>
-
 
317
					<TD align=left><B><FONT face=verdana size=1>$signedOnAs<br>
-
 
318
					Display <A HREF='' onClick="window.document.Scores.method = 'GET'; window.document.Scores.submit(); return false;">Full URL</a> : <select name=year onchange='Scores.submit();'>$yearoptions</select> : <a href=/schedule/>[Go HOME]</a></TD>
-
 
319
				</TR>
-
 
320
header5
-
 
321
} else {
-
 
322
	print "</TD>\n</TR>\n";
-
 
323
}
-
 
324
 
-
 
325
print<<header4;
-
 
326
 
-
 
327
			</TABLE>
-
 
328
			</TD>
-
 
329
		</TR>
-
 
330
		<TR>
-
 
331
			<TD>&nbsp</TD>
-
 
332
		</TR>
-
 
333
		<TR>
-
 
334
			<TD>
-
 
335
			<TABLE border=0 cellspacing=2 cellpadding=4 width=100\%>
-
 
336
				<TR bgcolor=#0077BD>
-
 
337
header4
-
 
338
 
-
 
339
							# Print the Column headings
-
 
340
				foreach $f (@displayFields)
-
 
341
					{ print "\t\t\t\t\t<TD align=left nowrap><FONT face=verdana color=white size=1><B><INPUT type=checkbox name=$f value=true checked $auto>$NAME{$f}</TD>\n"; }
-
 
342
				print "<TD>&nbsp;</TD>\n" if $secure;
-
 
343
				print "\t\t\t\t</TR>\n\t\t\t\t<TR>\n";
-
 
344
							# and now the filter boxes
-
 
345
							
-
 
346
				foreach $f (@displayFields)
-
 
347
					{
-
 
348
					print "\t\t\t\t\t<TD align=left bgcolor=#E6E6E6><FONT size=1 face=verdana>";
-
 
349
					print &generica($f);
-
 
350
#					print "&nbsp;";
-
 
351
					print "</TD>\n";
-
 
352
					}
-
 
353
				print "<TD bgcolor=#E6E6E6>&nbsp;</TD>\n" if $secure;
-
 
354
				print "\t\t\t\t</TR></FORM>\n";
-
 
355
 
-
 
356
				my $cw = scalar @displayFields + 1;
-
 
357
 
-
 
358
				print<<header2;
-
 
359
				</TR>
-
 
360
				<TR>
-
 
361
					<TD colspan=$cw><P><P></TD>
-
 
362
				</TR>
-
 
Line 363... Line -...
363
header2
-
 
364
 
-
 
365
 
-
 
366
my $co = '#FFFFFF';
-
 
367
 
-
 
368
foreach $t (@ProductList)			# Unt now we print the tickets!
-
 
Line 369... Line 287...
369
{
287
    $h->div ({ class=>"spRight" }, [
-
 
288
      $signedOnAs
-
 
289
    ])
-
 
290
  ]);
-
 
291
}
-
 
292
 
-
 
293
# Print the main table...............................................
370
	if ($t->{team1_score} > 0 and $t->{team2_score} > 0) { #SPIKE SEZ DO SOMETHING HERE RE GAME SCORE OF 0
294
 
371
			$t->{team1} .= " ($t->{team1_score})";
295
print $h->open ('div', { class=>'rTable' });
372
			$t->{team2} .= " ($t->{team2_score})";
296
 
373
		if ($t->{team1_score} > $t->{team2_score}) { $t->{team1} = "<b>$t->{team1}</b>"; } else { $t->{team2} = "<b>$t->{team2}</b>"; }
297
my @tmptitlerow;
374
	}
298
foreach my $f (@displayFields)	{  # Print the Column headings
-
 
299
  if (inArray ($f, \@staticFields)) {
-
 
300
    push @tmptitlerow, $h->div ({ class=>'rTableHead' }, [ $h->input ({ type=>"hidden", name=>$f, value=>"true" }), $NAME{$f} ]);
375
	
301
  } else {
376
	
302
    if ($FORM{autoload}) {
377
	print "\t\t\t\t<TR>\n";
303
      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} ]);
378
	foreach $f (@displayFields)
-
 
-
 
304
    } else {
-
 
305
      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} ]);      
Line 379... Line 306...
379
		{
306
    }
380
			$f =~ s/^HOST\.//;
-
 
Line 381... Line -...
381
			$f =~ s/^FRAME\.//;
-
 
382
			print "\t\t\t\t\t<TD align=left valign=top bgcolor='$co'><FONT face=verdana size=1>".$t->{$f}."&nbsp</TD>\n";
-
 
383
		}
307
  }
384
	print "<TD>";
308
}
385
	if ($secure and $YEAR eq "2019") {
309
 
386
		if ($t->{team1_score} or $t->{team2_score}) {
-
 
387
			print "<FONT face=verdana size=1><A HREF='#' onClick=\"window.open('update_score.pl?GID=$t->{id}','Enter Score','resizable,height=260,width=370'); return false;\">[update score]</a>";
-
 
388
		} else {
310
# Print the filter boxes...
Line 389... Line -...
389
			print "<FONT face=verdana size=1><A HREF='#' onClick=\"window.open('update_score.pl?GID=$t->{id}','Enter Score','resizable,height=260,width=370'); return false;\">[enter score]</a>";
-
 
390
		}
-
 
391
	}
-
 
392
	print "</TD>";
-
 
393
	
-
 
394
	print "\t\t\t\t</TR>\n";
-
 
395
 
-
 
396
	if ($co eq '#FFFFFF')
-
 
397
		{ $co = '#F9F9F9'; }
-
 
398
	else
-
 
399
		{ $co = '#FFFFFF'; }
-
 
400
	
-
 
401
}
-
 
Line -... Line 311...
-
 
311
print $h->div ({ class=>'rTableHeading' }, [ @tmptitlerow ], [ map { $h->div ({ class=>'rTableCell filters' }, filter ($_)) } @displayFields ], $h->div ({ class=>"rTableCell" }));
-
 
312
 
-
 
313
# Print the things
-
 
314
foreach my $t (@ProductList)	{
-
 
315
  print $h->div ({ class=>'rTableRow shaded' }, [ map { $h->div ({ class=>'rTableCell' }, exists &{"modify_".$_} ? &{"modify_".$_} ($t) : $t->{$_}) } @displayFields ]);
-
 
316
}
-
 
317
 
-
 
318
 
-
 
319
 
-
 
320
 
-
 
321
print $h->close ('div');
-
 
322
 
-
 
323
# close things out................................................
-
 
324
 
-
 
325
my $pages = $pagelimit eq "All" ? 1 : int( $datacount / $pagelimit + 0.99 );
-
 
326
if ($curpage > $pages) { $curpage = $pages; }
-
 
327
 
-
 
328
my @pagerange;
-
 
329
if ($pages <= 5 ) {
-
 
330
  @pagerange = 1 .. $pages;
-
 
331
} else {  
-
 
332
  if ($curpage <= 3) {
-
 
333
    @pagerange = (1, 2, 3, 4, ">>");
-
 
334
  } elsif ($curpage >= $pages - 2) {
-
 
335
    @pagerange = ("<<", $pages-3, $pages-2, $pages-1, $pages);
-
 
336
  } else {
-
 
337
    @pagerange = ("<<", $curpage-1, $curpage, $curpage+1, ">>");
-
 
338
  }
-
 
339
}
-
 
340
 
-
 
341
my @excelcode;
-
 
342
 
-
 
343
if ($secure) {
-
 
344
  push @excelcode, $h->br;
-
 
345
  push @excelcode, $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.]");
-
 
346
}
402
 
347
 
-
 
348
 
403
print<<tail;
349
print $h->br; # print $h->br;
-
 
350
print $h->div ({ class=>"sp0" }, [
-
 
351
    $h->div ({ class=>"spLeft" }, [
Line 404... Line -...
404
			</TABLE>
-
 
405
			</TD>
-
 
Line -... Line 352...
-
 
352
      $h->div ({ class=>"footer" }, [
-
 
353
        "To bookmark, save, or send this exact view, use the ",
406
		</TR>
354
        $h->a ({ href=>'', onClick=>"window.document.Req.method = 'GET'; Req.submit(); return false;" }, "[Full URL]"),