| 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 |
|
| 50 |
bgadell |
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}->{"ANN"} < 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 Announcer");
|
|
|
31 |
print $h->div ("Your user account is not registered as an Announcer, so you can't see these shifts. It's possible that your access is still being reviewed. Please be patient."), $h->br;
|
|
|
32 |
print $h->button ({ onClick=>"window.location.href='/schedule/';" }, "Home");
|
|
|
33 |
print $h->close ("html");
|
|
|
34 |
exit;
|
| 7 |
- |
35 |
}
|
|
|
36 |
|
| 196 |
- |
37 |
my $username = $h->a ({ href=>"/schedule/view_user.pl?submit=View&RCid=$ORCUSER->{RCid}" }, $ORCUSER->{derby_name});
|
|
|
38 |
my $RCid = $ORCUSER->{RCid};
|
| 7 |
- |
39 |
|
|
|
40 |
my $pageTitle = "Announcer Shifts";
|
|
|
41 |
our $DBTABLE = 'v_shift_announcer';
|
|
|
42 |
my %COLUMNS = (
|
|
|
43 |
# colname => [qw(DisplayName N type status)], status -> static | default | <blank>
|
| 196 |
- |
44 |
id => [qw(ID 5 number )],
|
|
|
45 |
date => [qw(Date 10 date default )],
|
|
|
46 |
dayofweek => [qw(Day 15 select )],
|
|
|
47 |
time => [qw(Time 20 text default )],
|
|
|
48 |
volhours => [qw(VolHours 23 number )],
|
|
|
49 |
track => [qw(Track 25 select default )],
|
|
|
50 |
teams => [qw(Teams 30 text default )],
|
|
|
51 |
level => [qw(Level 35 select default )],
|
|
|
52 |
restrictions => [qw(Rs 40 select )],
|
|
|
53 |
gtype => [qw(Type 45 select default )],
|
|
|
54 |
signup => [qw(SignUp 46 select )],
|
|
|
55 |
notes => [qw(Notes 50 text )],
|
|
|
56 |
role => [qw(Role 55 select )],
|
|
|
57 |
tla => [qw(TLA 60 select default )],
|
|
|
58 |
name => [qw(Position 65 text )],
|
|
|
59 |
type => [qw(Class 70 select default )],
|
|
|
60 |
RCid => [qw(RCid 75 number )],
|
|
|
61 |
derby_name => [qw(Assignee 80 select default )]
|
| 7 |
- |
62 |
);
|
|
|
63 |
|
| 196 |
- |
64 |
if ($ORCUSER->{department}->{"ANN"} > 1 or $LVL >= 4 or $ORCUSER->{department}->{"VCI"} >= 2) {
|
|
|
65 |
# Announcer Leads (and higher) can see a couple of extra fields
|
| 7 |
- |
66 |
$COLUMNS{'real_name'} = [qw(RealName 85 text)];
|
|
|
67 |
$COLUMNS{'email'} = [qw(Email 90 text)];
|
|
|
68 |
}
|
|
|
69 |
|
|
|
70 |
# If we need to modify line item values, create a subroutine named "modify_$columnname"
|
|
|
71 |
# It will receive a hashref to the object lineitem (RETURN the modified field at the end of the function!)
|
|
|
72 |
|
|
|
73 |
sub modify_derby_name {
|
|
|
74 |
my $t = shift;
|
| 196 |
- |
75 |
|
|
|
76 |
if ($ORCUSER->{department}->{"ANN"} < 2 and $t->{derby_name} and $t->{RCid} != $RCid and $LVL < 5) {
|
| 122 |
- |
77 |
$t->{derby_name} = "FILLED" unless getUser($t->{RCid})->{showme};
|
| 7 |
- |
78 |
}
|
|
|
79 |
|
| 196 |
- |
80 |
my ($yyyy, $mm, $dd) = split /\-/, $t->{date};
|
|
|
81 |
my $cutoff = DateTime->new(
|
| 7 |
- |
82 |
year => $yyyy,
|
|
|
83 |
month => $mm,
|
|
|
84 |
day => $dd,
|
|
|
85 |
hour => 5,
|
|
|
86 |
minute => 0,
|
|
|
87 |
second => 0,
|
|
|
88 |
time_zone => 'America/Los_Angeles'
|
|
|
89 |
);
|
| 196 |
- |
90 |
|
|
|
91 |
if (($t->{RCid} == $RCid and $t->{signup} ne "selected" and $now < $cutoff) or ($t->{derby_name} and ($ORCUSER->{department}->{"ANN"} >= 2 or $LVL >= 5))) {
|
|
|
92 |
# DROP
|
|
|
93 |
$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>";
|
|
|
94 |
if ($ORCUSER->{department}->{"ANN"} >= 2 or $LVL > 4) {
|
|
|
95 |
# NO SHOW
|
|
|
96 |
$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>";
|
|
|
97 |
}
|
|
|
98 |
} elsif (!$t->{derby_name}) {
|
|
|
99 |
$t->{dept} = "ANN";
|
| 231 |
- |
100 |
# if ($t->{track} eq "C3" or $t->{track} eq "C5") {
|
|
|
101 |
if ($t->{track} eq "C5") {
|
| 196 |
- |
102 |
return "*no announcers*";
|
|
|
103 |
}
|
|
|
104 |
if (findConflict ($ORCUSER->{RCid}, $t->{id}, "game")) {
|
| 101 |
bgadell |
105 |
$t->{derby_name} .= "*schedule conflict*";
|
|
|
106 |
} elsif (signUpEligible ($ORCUSER, $t) and $now < $cutoff) {
|
| 196 |
- |
107 |
# SIGN UP
|
|
|
108 |
$t->{derby_name} = "<A HREF='#' onClick=\"window.open('make_shift_change.pl?change=add&RCid=$RCid&id=$t->{id}&role=$t->{role}','Confirm Shift Change','resizable,height=260,width=370'); return false;\">[SIGN UP]</a>";
|
|
|
109 |
}
|
|
|
110 |
if ($ORCUSER->{department}->{"ANN"} >= 2 or $LVL > 4) {
|
|
|
111 |
# ADD USER
|
|
|
112 |
$t->{derby_name} ? $t->{derby_name} .= " | " : {};
|
|
|
113 |
$t->{derby_name} .= "<A HREF='#' onClick=\"window.open('make_shift_change.pl?change=lookup&RCid=$RCid&id=$t->{id}&role=$t->{role}','Confirm Shift Change','resizable,height=260,width=370'); return false;\">[ADD USER]</a>";
|
|
|
114 |
}
|
|
|
115 |
}
|
|
|
116 |
return $t->{derby_name};
|
| 7 |
- |
117 |
}
|
|
|
118 |
|
| 50 |
bgadell |
119 |
sub modify_time {
|
|
|
120 |
my $t = shift;
|
|
|
121 |
return convertTime $t->{time};
|
|
|
122 |
}
|
| 7 |
- |
123 |
|
| 196 |
- |
124 |
# If we need to modify how a filter works, create a subroutine named "filter_$columnname"
|
|
|
125 |
# It will receive two fields, the field name and the current filter value (if any)
|
| 7 |
- |
126 |
|
| 196 |
- |
127 |
# Uncomment and update if we want to enable clicking on a row to open a new page.
|
|
|
128 |
#
|
|
|
129 |
#sub addRowClick {
|
|
|
130 |
# my $t = shift;
|
|
|
131 |
# return "location.href='view_thing.pl?field=$t->{field}&choice=View'";
|
|
|
132 |
#}
|
| 7 |
- |
133 |
|
| 196 |
- |
134 |
# Call the function to print the table view page (with available options)
|
|
|
135 |
printTablePage ({ Title => $pageTitle,
|
|
|
136 |
Table => $DBTABLE,
|
|
|
137 |
Columns => \%COLUMNS,
|
|
|
138 |
RCAuth => $RCAUTH_cookie,
|
|
|
139 |
DisplayYearSelect => 1,
|
|
|
140 |
ShowMyShifts => 1,
|
|
|
141 |
HighlightShifts => 1,
|
|
|
142 |
PersonalTimeButton => 1,
|
| 231 |
- |
143 |
# Where => "track <> 'C3'",
|
|
|
144 |
Where => "track <> 'C5'",
|
| 196 |
- |
145 |
});
|
| 7 |
- |
146 |
|