Subversion Repositories PEEPS

Rev

Rev 25 | Rev 37 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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
 
25 - 44
my $newleaguebutton;
16 - 45
if ($ORCUSER->{SYSADMIN}) {
31 - 46
  $COLUMNS{alcohol_liability_eligible} = ["AL Eligible",   64,    "select"];
16 - 47
  $COLUMNS{visible} = [qw(Visible   65    select)];
25 - 48
  $newleaguebutton = 1;
16 - 49
} else {
50
  push @whereClause, "visible = 1";
51
}
52
 
53
 
2 - 54
# If we need to modify line item values, create a subroutine named "modify_$columnname"
55
#    It will receive a hashref to the object lineitem
56
 
57
sub modify_url {
58
  my $thing = shift;
59
  return $h->a ({ href => $thing->{url}, target => "_blank", onClick=>"event.stopPropagation();" }, $thing->{url});
60
}
61
 
16 - 62
sub modify_visible {
63
  my $thing = shift;
64
  return $thing->{visible} ? "True" : "False";
65
}
66
 
31 - 67
sub modify_alcohol_liability_eligible {
68
  my $thing = shift;
69
  return $thing->{alcohol_liability_eligible} ? "True" : "False";
70
}
71
 
2 - 72
# If we need to modify how a filter works, create a subroutine named "filter_$columnname"
73
#    It will receive two fields, the field name and the current filter value (if any)
74
 
16 - 75
sub filter_visible {
76
  my $colName = shift;
77
  my $filter = shift;
78
 
79
  if (defined $filter)  {
80
    if ($filter eq "True") {
81
      return "$colName = 1";
82
    } elsif ($filter eq "False") {
83
      return "$colName = 0";
84
    }
85
  } else {
86
    my $Options = $h->option ("", "True", "False");
87
 
88
    my $tmpfilter = getFilterValue ($colName);
89
 
90
    $Options =~ s/>($tmpfilter)/ selected>$1/;
91
    return "<SELECT name=filter-${colName} onChange='page.value = 1; submit();'>$Options</SELECT>";
92
  }
93
}
94
 
31 - 95
sub filter_alcohol_liability_eligible {
96
  my $colName = shift;
97
  my $filter = shift;
98
 
99
  if (defined $filter)  {
100
    if ($filter eq "True") {
101
      return "$colName = 1";
102
    } elsif ($filter eq "False") {
103
      return "$colName = 0";
104
    }
105
  } else {
106
    my $Options = $h->option ("", "True", "False");
107
 
108
    my $tmpfilter = getFilterValue ($colName);
109
 
110
    $Options =~ s/>($tmpfilter)/ selected>$1/;
111
    return "<SELECT name=filter-${colName} onChange='page.value = 1; submit();'>$Options</SELECT>";
112
  }
113
}
114
 
2 - 115
# Uncomment and update if we want to enable clicking on a row to open a new page.
116
#
117
sub addRowClick {
118
  my $t = shift;
119
  return "location.href='view_league?id=$t->{id}'";
120
}
121
 
122
# Call the function to print the table view page (with available options)
123
printTablePage ({ Title     => $pageTitle,
124
#                  Prefs     => $prefscookie,
125
                  Table     => $DBTABLE,
126
                  Columns   => \%COLUMNS,
127
                  PEEPSAuth => $PEEPSAUTH_cookie,
128
                  Where     => join (" and ", @whereClause),
25 - 129
                  HeaderButton       => $newleaguebutton ? { field  => "id",
130
                                          button => $h->input ({ type=>"button", value=>"Add", onClick=>"event.stopPropagation(); window.location.href='view_league.pl';" }) } : undef
2 - 131
               });
132
 
5 - 133