Subversion Repositories VORC

Rev

Rev 138 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
7 - 1
#!/usr/bin/perl
2
 
56 bgadell 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
 
7 - 9
#if ($ENV{SHELL}) { die "This script shouldn't be executed from the command line!\n"; }
10
 
196 - 11
use strict;
8 - 12
use cPanelUserConfig;
7 - 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
use DateTime;
19
use DateTime::Duration;
25 - 20
my $now = DateTime->now (time_zone => 'America/Los_Angeles');
7 - 21
 
22
my $cookie_string = authenticate (1) || die;
23
our ($EML, $PWD, $LVL) = split /&/, $cookie_string;
196 - 24
my $RCAUTH_cookie = CGI::Cookie->new (-name=>'RCAUTH', -value=>"$cookie_string", -expires=>"+30m");
7 - 25
 
196 - 26
# Add checking to make sure they're in this department
27
if ($ORCUSER->{department}->{"OFF"} < 1 and $LVL < 4 and $ORCUSER->{department}->{"VCI"} < 2) {
28
  print header (-cookie=>$RCAUTH_cookie);
29
  printRCHeader ("Unauthorized Page");
30
  print $h->div ({ class=>"error" }, "You're not an Official");
31
  print $h->div ("Your user account is not registered as an Official, so you can't see these shifts.  It's possible that your access is still being reviewed.  Please be patient.");
32
  print $h->button ({ onClick=>"window.location.href='/schedule/';" }, "Home");
33
  print $h->close ("html");
34
  exit;
7 - 35
}
36
 
37
my $pageTitle = "Officiating Shifts";
38
our $DBTABLE = 'v_shift_officiating';
39
my %COLUMNS = (
40
# colname   =>  [qw(DisplayName       N    type     status)],   status ->  static | default | <blank>
196 - 41
  id             => [qw(ID           5    number            )],
42
  date           => [qw(Date        10    date      default )],
43
  dayofweek      => [qw(Day         15    select            )],
44
  time           => [qw(Time        20    text      default )],
45
  volhours       => [qw(VolHours    23    number            )],
46
  track          => [qw(Track       25    select    default )],
47
  teams          => [qw(Teams       30    text      default )],
48
  level          => [qw(Level       35    select    default )],
49
  restrictions   => [qw(Rs          40    select            )],
50
  gtype          => [qw(Type        45    select    default )],
51
  signup         => [qw(SignUp      46    select            )],
52
  notes          => [qw(Notes       50    text              )],
53
  role           => [qw(Role        55    select            )],
54
  tla            => [qw(TLA         60    select    default )],
55
  name           => [qw(Position    65    text              )],
56
  type           => [qw(Class       70    select    default )],
57
  RCid           => [qw(RCid        75    number            )],
58
  derby_name     => [qw(Assignee    80    select    default )]
7 - 59
);
60
 
196 - 61
if ($ORCUSER->{department}->{"OFF"} > 1) {
7 - 62
# Add:
196 - 63
#   real_name      RealName
64
#   email          Email
7 - 65
  $COLUMNS{'real_name'} = [qw(RealName    85    text)];
66
  $COLUMNS{'email'}     = [qw(Email       90    text)];
67
}
68
 
69
# If we need to modify line item values, create a subroutine named "modify_$columnname"
70
#    It will receive a hashref to the object lineitem (RETURN the modified field at the end of the function!)
71
 
72
sub modify_derby_name {
73
  my $t = shift;
196 - 74
 
75
  if ($ORCUSER->{department}->{"OFF"} < 2 and $t->{derby_name} and $t->{RCid} != $ORCUSER->{RCid} and $LVL < 5) {
122 - 76
    $t->{derby_name} = "FILLED" unless getUser($t->{RCid})->{showme};
7 - 77
  }
78
 
196 - 79
  my ($yyyy, $mm, $dd) = split /\-/, $t->{date};
80
  my $cutoff = DateTime->new(
7 - 81
        year => $yyyy,
82
        month => $mm,
83
        day => $dd,
84
        hour => 5,
85
        minute => 0,
86
        second => 0,
87
        time_zone => 'America/Los_Angeles'
88
  );
196 - 89
 
90
  if (($t->{RCid} == $ORCUSER->{RCid} and $t->{signup} ne "selected" and $now < $cutoff) or ($t->{derby_name} and ($ORCUSER->{department}->{"OFF"} >= 2 or $LVL >= 5))) {
91
    # DROP
92
    $t->{derby_name} = "$t->{derby_name} <A HREF='#' onClick=\"window.open('make_shift_change.pl?change=del&RCid=$t->{RCid}&id=$t->{id}&role=$t->{role}','Confirm Shift Change','resizable,height=260,width=370'); return false;\">[DROP]</a>";
93
    if ($ORCUSER->{department}->{"OFF"} >= 2) {
94
      # NO SHOW
95
      $t->{derby_name} .= " | <A HREF='#' onClick=\"if (confirm('Really? They were a no show?')==true) { window.open('make_shift_change.pl?noshow=true&change=del&RCid=$t->{RCid}&id=$t->{id}&role=$t->{role}','Confirm Shift Change','resizable,height=260,width=370'); return false; }\">[NO SHOW]</a>";
96
    }
97
  } elsif (!$t->{derby_name}) {
98
    $t->{dept} = "OFF";
99
    if (findConflict ($ORCUSER->{RCid}, $t->{id}, "game")) {
101 bgadell 100
      $t->{derby_name} .= "*schedule conflict*";
101
    } elsif (signUpEligible ($ORCUSER, $t) and $now < $cutoff) {
196 - 102
      # SIGN UP
103
      $t->{derby_name} = "<A HREF='#' onClick=\"window.open('make_shift_change.pl?change=add&RCid=$ORCUSER->{RCid}&id=$t->{id}&role=$t->{role}','Confirm Shift Change','resizable,height=260,width=370'); return false;\">[SIGN UP]</a>";
104
    }
105
    if ($ORCUSER->{department}->{"OFF"} >= 2 or $LVL > 4) {
106
      # ADD USER
107
      $t->{derby_name} ? $t->{derby_name} .= " | " : {};
108
      $t->{derby_name} .= "<A HREF='#' onClick=\"window.open('make_shift_change.pl?change=lookup&RCid=$ORCUSER->{RCid}&id=$t->{id}&role=$t->{role}','Confirm Shift Change','resizable,height=260,width=370'); return false;\">[ADD USER]</a>";
109
    }
110
  }
111
  return $t->{derby_name};
7 - 112
}
113
 
50 bgadell 114
sub modify_time {
115
  my $t = shift;
116
  return convertTime $t->{time};
117
}
7 - 118
 
196 - 119
# If we need to modify how a filter works, create a subroutine named "filter_$columnname"
120
#    It will receive two fields, the field name and the current filter value (if any)
7 - 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
#}
7 - 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 => 1,
135
                  ShowMyShifts  => 1,
136
                  HighlightShifts => 1,
137
                  PersonalTimeButton => 1,
138
               });
7 - 139