| 112 |
- |
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 |
use strict;
|
|
|
10 |
use cPanelUserConfig;
|
|
|
11 |
use RollerCon;
|
|
|
12 |
use tableViewer;
|
|
|
13 |
use CGI qw/param cookie header start_html url/;
|
|
|
14 |
use HTML::Tiny;
|
|
|
15 |
my $h = HTML::Tiny->new( mode => 'html' );
|
|
|
16 |
|
|
|
17 |
my $cookie_string = authenticate(1) || die;
|
|
|
18 |
my ($EML, $PWD, $LVL) = split /&/, $cookie_string;
|
|
|
19 |
my $user = getUser($EML);
|
|
|
20 |
$user->{department} = convertDepartments ($user->{department});
|
|
|
21 |
my $RCAUTH_cookie = CGI::Cookie->new(-name=>'RCAUTH',-value=>"$cookie_string",-expires=>"+30m");
|
|
|
22 |
|
|
|
23 |
print header (),
|
|
|
24 |
start_html (-title => "Updating Officating Huddle Hours", -style => {'src' => "/style.css"} );
|
|
|
25 |
|
|
|
26 |
my %huddles = (
|
| 171 |
- |
27 |
Thursday => "2023-07-11",
|
|
|
28 |
Friday => "2023-07-12",
|
|
|
29 |
Saturday => "2023-07-13",
|
| 112 |
- |
30 |
);
|
|
|
31 |
|
|
|
32 |
my $dbh = getRCDBH ();
|
|
|
33 |
|
|
|
34 |
#$dbh->do ("INSERT INTO shift
|
|
|
35 |
# (dept,role,type,date,location,start_time,end_time,doubletime,note,assignee_id)
|
|
|
36 |
# VALUES(?,?,?,?,?,?,?,?,?)", undef, "OFF", "Officiating Huddle", "selected", $FTS->{date}, "C1", "09:00:00", "09:30:00", 0, "", $user->{RCid});
|
|
|
37 |
|
|
|
38 |
|
|
|
39 |
|
|
|
40 |
#foreach (sort keys %ENV) {
|
|
|
41 |
# print "$_: $ENV{$_}\n<br>";
|
|
|
42 |
#}
|
|
|
43 |
|
|
|
44 |
print $h->p ("Updating your Officiating Huddle Attendance:");
|
|
|
45 |
print $h->open ("ul");
|
|
|
46 |
foreach (sort { $huddles{$a} cmp $huddles{$b} } keys %huddles) {
|
|
|
47 |
my ($exists) = $dbh->selectrow_array ("select id from shift where date = ? and assignee_id = ? and role = 'Officiating Huddle'", undef, $huddles{$_}, $user->{RCid});
|
|
|
48 |
if (param ($_)) {
|
|
|
49 |
if (!$exists) {
|
|
|
50 |
print $h->li ("Adding $huddles{$_} $_");
|
|
|
51 |
logit ($user->{RCid}, "Added Officiating Huddle attendance for $huddles{$_}");
|
|
|
52 |
$dbh->do ("INSERT INTO shift
|
|
|
53 |
(dept,role,type,date,location,start_time,end_time,doubletime,note,assignee_id)
|
|
|
54 |
VALUES(?,?,?,?,?,?,?,?,?,?)", undef, "OFF", "Officiating Huddle", "selected", $huddles{$_}, "C1", "09:00:00", "09:30:00", 0, "", $user->{RCid})
|
|
|
55 |
or print $h->div ({class=>"error"}, $dbh->errstr());
|
|
|
56 |
}
|
|
|
57 |
} else {
|
|
|
58 |
if ($exists) {
|
|
|
59 |
print $h->li ("Deleting $huddles{$_} $_");
|
|
|
60 |
logit ($user->{RCid}, "Removed Officiating Huddle attendance for $huddles{$_}");
|
|
|
61 |
$dbh->do ("DELETE FROM shift where dept = ? and role = ? and date = ? and start_time = ? and assignee_id = ?", undef,
|
|
|
62 |
"OFF", "Officiating Huddle", $huddles{$_}, "09:00:00", $user->{RCid})
|
|
|
63 |
or print $h->div ({class=>"error"}, $dbh->errstr());
|
|
|
64 |
}
|
|
|
65 |
}
|
|
|
66 |
}
|
|
|
67 |
print $h->close ("ul");
|
|
|
68 |
print $h->p ("Done");
|
|
|
69 |
print $h->button ({ onClick=>"window.close();" }, "Close");
|
|
|
70 |
print $h->close ("html");
|
|
|
71 |
|
|
|
72 |
exit;
|
|
|
73 |
|
|
|
74 |
|