| 2 |
- |
1 |
#!/usr/bin/perl
|
|
|
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";
|
|
|
8 |
|
|
|
9 |
#if ($ENV{SHELL}) { die "This script shouldn't be executed from the command line!\n"; }
|
|
|
10 |
|
|
|
11 |
use strict;
|
|
|
12 |
use CGI qw/param cookie header start_html url/;
|
|
|
13 |
use HTML::Tiny;
|
|
|
14 |
use tableViewer;
|
|
|
15 |
use PEEPS;
|
|
|
16 |
our $h = HTML::Tiny->new( mode => 'html' );
|
| 4 |
- |
17 |
$ENV{HTTPS} = 'ON' if $ENV{SERVER_NAME} =~ /^peeps/;
|
| 2 |
- |
18 |
|
|
|
19 |
my $cookie_string = authenticate () || die;
|
|
|
20 |
our ($EML, $PWD, $LVL) = split /&/, $cookie_string;
|
|
|
21 |
my $PEEPSAUTH_cookie = CGI::Cookie->new(-name=>'PEEPSAUTH',-value=>"$cookie_string",-expires=>"+30m");
|
|
|
22 |
|
|
|
23 |
my $pageTitle = "PEEPS - Organizations";
|
|
|
24 |
our $DBTABLE = 'organization';
|
|
|
25 |
my %COLUMNS = (
|
|
|
26 |
# colname => [qw(DisplayName N type status)], status -> static | default | <blank>
|
|
|
27 |
id => [qw(ID 5 number )],
|
|
|
28 |
league_name => [qw(LeagueName 10 text default )],
|
|
|
29 |
business_name => [qw(BusinessName 15 text )],
|
|
|
30 |
city => [qw(City 20 text default )],
|
|
|
31 |
state_province => [qw(StateProvince 25 select default )],
|
|
|
32 |
country => [qw(Country 30 select default )],
|
|
|
33 |
url => [qw(Website 35 text )],
|
|
|
34 |
type => [qw(Type 40 select default )],
|
|
|
35 |
status => [qw(Status 45 select default )],
|
|
|
36 |
legal_entity_type => [qw(LegalEntity 50 select )],
|
|
|
37 |
tax_id => [qw(TaxID 55 text )],
|
|
|
38 |
date_established => [qw(Established 60 date default )],
|
|
|
39 |
);
|
|
|
40 |
|
|
|
41 |
# Set any custom "where" DB filters here...
|
|
|
42 |
my @whereClause;
|
|
|
43 |
|
| 16 |
- |
44 |
if ($ORCUSER->{SYSADMIN}) {
|
|
|
45 |
$COLUMNS{visible} = [qw(Visible 65 select)];
|
|
|
46 |
} else {
|
|
|
47 |
push @whereClause, "visible = 1";
|
|
|
48 |
}
|
|
|
49 |
|
|
|
50 |
|
| 2 |
- |
51 |
# If we need to modify line item values, create a subroutine named "modify_$columnname"
|
|
|
52 |
# It will receive a hashref to the object lineitem
|
|
|
53 |
|
|
|
54 |
sub modify_url {
|
|
|
55 |
my $thing = shift;
|
|
|
56 |
return $h->a ({ href => $thing->{url}, target => "_blank", onClick=>"event.stopPropagation();" }, $thing->{url});
|
|
|
57 |
}
|
|
|
58 |
|
| 16 |
- |
59 |
sub modify_visible {
|
|
|
60 |
my $thing = shift;
|
|
|
61 |
return $thing->{visible} ? "True" : "False";
|
|
|
62 |
}
|
|
|
63 |
|
| 2 |
- |
64 |
# If we need to modify how a filter works, create a subroutine named "filter_$columnname"
|
|
|
65 |
# It will receive two fields, the field name and the current filter value (if any)
|
|
|
66 |
|
| 16 |
- |
67 |
sub filter_visible {
|
|
|
68 |
my $colName = shift;
|
|
|
69 |
my $filter = shift;
|
|
|
70 |
|
|
|
71 |
if (defined $filter) {
|
|
|
72 |
if ($filter eq "True") {
|
|
|
73 |
return "$colName = 1";
|
|
|
74 |
} elsif ($filter eq "False") {
|
|
|
75 |
return "$colName = 0";
|
|
|
76 |
}
|
|
|
77 |
} else {
|
|
|
78 |
my $Options = $h->option ("", "True", "False");
|
|
|
79 |
|
|
|
80 |
my $tmpfilter = getFilterValue ($colName);
|
|
|
81 |
|
|
|
82 |
$Options =~ s/>($tmpfilter)/ selected>$1/;
|
|
|
83 |
return "<SELECT name=filter-${colName} onChange='page.value = 1; submit();'>$Options</SELECT>";
|
|
|
84 |
}
|
|
|
85 |
}
|
|
|
86 |
|
| 2 |
- |
87 |
# Uncomment and update if we want to enable clicking on a row to open a new page.
|
|
|
88 |
#
|
|
|
89 |
sub addRowClick {
|
|
|
90 |
my $t = shift;
|
|
|
91 |
return "location.href='view_league?id=$t->{id}'";
|
|
|
92 |
}
|
|
|
93 |
|
|
|
94 |
# Call the function to print the table view page (with available options)
|
|
|
95 |
printTablePage ({ Title => $pageTitle,
|
|
|
96 |
# Prefs => $prefscookie,
|
|
|
97 |
Table => $DBTABLE,
|
|
|
98 |
Columns => \%COLUMNS,
|
|
|
99 |
PEEPSAuth => $PEEPSAUTH_cookie,
|
|
|
100 |
Where => join (" and ", @whereClause),
|
|
|
101 |
# HeaderButton => { field => "id",
|
|
|
102 |
# button => $h->input ({ type=>"button", value=>"Add", onClick=>"window.location.href='view_game.pl'" }) }
|
|
|
103 |
});
|
|
|
104 |
|
| 5 |
- |
105 |
|