Subversion Repositories VORC

Rev

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

Rev Author Line No. Line
58 bgadell 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 cPanelUserConfig;
13
use CGI qw/param cookie header start_html url/;
14
use HTML::Tiny;
15
use tableViewer;
16
use RollerCon;
17
our $h = HTML::Tiny->new( mode => 'html' );
18
 
19
my $cookie_string = authenticate (3) || die;
20
our ($EML, $PWD, $LVL) = split /&/, $cookie_string;
196 - 21
my $RCAUTH_cookie = CGI::Cookie->new (-name=>'RCAUTH', -value=>"$cookie_string", -expires=>"+30m");
58 bgadell 22
 
23
my $pageTitle = "MVP Pass Tickets";
24
our $DBTABLE = 'v_ticket';
25
my %COLUMNS = (
26
# colname   =>  [qw(DisplayName       N    type     status)],   status ->  static | default | <blank>
196 - 27
  id          => [qw(MVPid         5    text      default )],
28
  event_name  => [qw(Event        10    text         )],
58 bgadell 29
  order_date  => [qw(PurchaseDate 15    date        default )],
196 - 30
  ticket_type => [qw(TicketType   20    select              )],
31
  full_name   => [qw(MVPFullName     25    text       default         )],
32
  email       => [qw(MVPEmail        30    text       default         )],
33
  derby_name  => [qw(MVPDerbyName    35    text       default )],
34
  RCid        => [qw(RCID         40    select      default )],
35
  vorc_full_name   => [qw(VORCFullName     45    text       default         )],
36
  vorc_email       => [qw(VORCEmail        50    text       default         )],
37
  vorc_derby_name  => [qw(VORCDerbyName    55    text       default )],
58 bgadell 38
);
39
 
40
# Set any custom "where" DB filters here...
41
my @whereClause;
42
 
43
# If we need to modify line item values, create a subroutine named "modify_$columnname"
44
#    It will receive a hashref to the object lineitem
45
 
46
sub modify_RCid {
47
  my $t = shift;
48
  return $t->{RCid} if $t->{RCid};
49
  $t->{RCid} = "";
50
 
51
  my $dbh = getRCDBH;
52
  my ($match) = $dbh->selectrow_array ("select RCid from v_official where isnull(MVPid) = true and email = (select email from v_ticket where id = ?) union
53
    select RCid from v_official where isnull(MVPid) = true and real_name = (select full_name from v_ticket where id = ?) union
54
    select RCid from v_official where isnull(MVPid) = true and derby_name = (select derby_name from v_ticket where id = ?)", undef, $t->{id}, $t->{id}, $t->{id});
55
 
56
  if ($match) {
57
    my $tempuser = getUser $match;
58
    $t->{RCid} = $h->button ({ onClick=>"window.open('update_mvp_ticket.pl?change=add&RCid=$match&MVPid=$t->{id}','Change MVP Ticket','resizable,height=260,width=370'); return false;" }, "Accept $match");
59
    $t->{vorc_full_name}  = $h->div ({ class=>"hint", style=>"font-size:x-small" }, $tempuser->{real_name});
60
    $t->{vorc_email}      = $h->div ({ class=>"hint", style=>"font-size:x-small" }, $tempuser->{email});
61
    $t->{vorc_derby_name} = $h->div ({ class=>"hint", style=>"font-size:x-small" }, $tempuser->{derby_name});
62
  }
63
 
64
  return $t->{RCid};
65
}
66
 
67
sub modify_email {
68
  my $t = shift;
69
 
70
  if ($t->{email} and !$t->{RCid}) {
71
    $t->{email} = $h->a ({ href=>"/schedule/users.pl?filter-email=$t->{email}&ignoreCookie=1" }, $t->{email});
72
  }
73
 
74
  return $t->{email};
75
}
76
 
77
sub modify_derby_name {
78
  my $t = shift;
79
 
80
  if ($t->{derby_name} and !$t->{RCid}) {
81
    my $temp = $t->{derby_name};
82
    $temp =~ s/"//g;
83
    $t->{derby_name} = $h->a ({ href=>"/schedule/users.pl?filter-derby_name=$temp&ignoreCookie=1" }, $t->{derby_name});
84
  }
196 - 85
 
58 bgadell 86
  return $t->{derby_name};
87
}
88
 
89
sub modify_full_name {
90
  my $t = shift;
91
 
92
  if ($t->{full_name} and !$t->{RCid}) {
93
    $t->{full_name} = $h->a ({ href=>"/schedule/users.pl?filter-real_name=$t->{full_name}&ignoreCookie=1" }, $t->{full_name});
94
  }
196 - 95
 
58 bgadell 96
  return $t->{full_name};
97
}
98
 
196 - 99
# If we need to modify how a filter works, create a subroutine named "filter_$columnname"
100
#    It will receive two fields, the field name and the current filter value (if any)
101
 
58 bgadell 102
sub filter_RCid {
103
  my $colName = shift;
104
  my $filter = shift // "";
105
 
196 - 106
  if ($filter)  {
107
    return $filter =~ /^\d+$/ ? "$colName = $filter" : $filter eq "true" ? "isnull($colName) = 0" : "isnull($colName) = 1";
108
  } else {
58 bgadell 109
    no strict;
110
    my @options = ("", "true", "-blank-");
111
    my $dbh = getRCDBH;
62 bgadell 112
    push @options, map { @{$_} } @{$dbh->selectall_arrayref ("select distinct RCid from v_ticket where isnull(RCid) = 0 order by RCid")};
58 bgadell 113
 
114
    @options = map { $FORM{"filter-RCid"} eq $_ ?
115
                       ( $h->option ({ selected=>[] }, $_) ) :
116
                       ( $h->option (                  $_) )  } @options;
117
 
118
    return $FORM{autoload} ? $h->select ({ name=>"filter-RCid", onChange=>"page.value = 1; submit();" }, [@options]) : $h->select ({ name=>"filter-RCid" }, [$h->option (), @options]);
119
  }
120
}
121
 
196 - 122
# Uncomment and update if we want to enable clicking on a row to open a new page.
123
#
124
#sub addRowClick {
125
#  my $t = shift;
126
#  return "location.href='view_thing.pl?field=$t->{field}&choice=View'";
127
#}
58 bgadell 128
 
196 - 129
# Call the function to print the table view page (with available options)
130
printTablePage ({ Title   => $pageTitle,
131
                  Table   => $DBTABLE,
132
                  Columns => \%COLUMNS,
133
                  RCAuth  => $RCAUTH_cookie,
134
                  DisplayYearSelect  => 0,
135
                 });