Subversion Repositories PEEPS

Rev

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