| 2 |
- |
1 |
#!/usr/bin/perl
|
|
|
2 |
|
|
|
3 |
use strict;
|
| 8 |
- |
4 |
use cPanelUserConfig;
|
| 2 |
- |
5 |
use Data::ICal;
|
|
|
6 |
use Data::ICal::Entry::Event;
|
|
|
7 |
use Date::ICal;
|
|
|
8 |
use DateTime;
|
|
|
9 |
use Date::Calc qw(Add_Delta_DHMS);
|
|
|
10 |
use Time::HiRes;
|
|
|
11 |
|
|
|
12 |
use CGI qw(:standard);
|
|
|
13 |
use DBI;
|
| 29 |
- |
14 |
use tableViewer;
|
|
|
15 |
use WebDB;
|
| 2 |
- |
16 |
|
|
|
17 |
|
|
|
18 |
my %games = ();
|
|
|
19 |
my @shifts = ();
|
|
|
20 |
|
|
|
21 |
my $query = new CGI;
|
|
|
22 |
my $RCid = $query->param('RCid');
|
|
|
23 |
if (!$RCid) { $RCid = '0'; }
|
|
|
24 |
|
|
|
25 |
my @stamp = localtime();
|
|
|
26 |
my $dstamp = sprintf("%d%02d%02dT%02d%02d%02dZ",
|
|
|
27 |
$stamp[5] + 1900,
|
|
|
28 |
$stamp[4] + 1,
|
|
|
29 |
$stamp[3],
|
|
|
30 |
$stamp[2],
|
|
|
31 |
$stamp[1],
|
|
|
32 |
$stamp[0]);
|
|
|
33 |
|
|
|
34 |
my $tz = DateTime::TimeZone->new(name => 'America/Los_Angeles');
|
|
|
35 |
|
| 29 |
- |
36 |
my $dbh = WebDB::connect;
|
|
|
37 |
my $sth = $dbh->prepare("select * from (select id, date, dayofweek, track as 'location', time, role, teams from v_shift_officiating where RCid = ? union select id, date, dayofweek, track as 'location', time, role, teams from v_shift_announcer where RCid = ? union select id, date, dayofweek, location, time, role, '' as teams from v_shift where RCid = ?) temp order by date, time");
|
|
|
38 |
$sth->execute($RCid, $RCid, $RCid);
|
| 2 |
- |
39 |
while (my $s = $sth->fetchrow_hashref) {
|
|
|
40 |
$s->{role} =~ s/\-\d$//;
|
|
|
41 |
push @shifts, $s;
|
|
|
42 |
}
|
|
|
43 |
|
|
|
44 |
my $calendar = Data::ICal->new();
|
|
|
45 |
my $count = 0;
|
|
|
46 |
|
|
|
47 |
for my $S (@shifts) {
|
|
|
48 |
my ($startyear, $startmonth, $startday) = split /\-/, $S->{date};
|
|
|
49 |
my ($endyear, $endmonth, $endday) = ($startyear, $startmonth, $startday);
|
|
|
50 |
my ($stime, $etime) = split / \- /, $S->{time};
|
|
|
51 |
my ($starthour, $startmin) = split /:/, $stime;
|
|
|
52 |
my ($endhour, $endmin) = split /:/, $etime;
|
|
|
53 |
|
|
|
54 |
my $event = Data::ICal::Entry::Event->new();
|
|
|
55 |
|
|
|
56 |
my @tm = localtime();
|
|
|
57 |
my $uid = sprintf("%d%02d%02d%02d%02d%02d%s%02d\@rollercon.com",
|
|
|
58 |
$tm[5] + 1900, $tm[4] + 1, $tm[3], $tm[2],
|
|
|
59 |
$tm[1], $tm[0], scalar(Time::HiRes::gettimeofday()), $count);
|
|
|
60 |
|
|
|
61 |
$event->add_properties(
|
|
|
62 |
uid => $uid,
|
| 29 |
- |
63 |
summary => "ORC: $S->{role} on $S->{location} - $S->{teams}",
|
| 2 |
- |
64 |
description => "" ,
|
| 29 |
- |
65 |
categories => "RollerCon Officiating;RollerCon Schedule;RollerCon Volunteer",
|
|
|
66 |
location => "$S->{location}",
|
| 2 |
- |
67 |
dtstamp => $dstamp,
|
|
|
68 |
dtstart => Date::ICal->new(
|
|
|
69 |
year => $startyear,
|
|
|
70 |
month => $startmonth,
|
|
|
71 |
day => $startday,
|
|
|
72 |
hour => $starthour,
|
|
|
73 |
min => $startmin,
|
|
|
74 |
sec => 0,
|
|
|
75 |
offset => "-0700")->ical,
|
|
|
76 |
dtend => Date::ICal->new(
|
|
|
77 |
year => $endyear,
|
|
|
78 |
month => $endmonth,
|
|
|
79 |
day => $endday,
|
|
|
80 |
hour => $endhour,
|
|
|
81 |
min => $endmin,
|
|
|
82 |
sec => 0,
|
|
|
83 |
offset => "-0700")->ical,
|
|
|
84 |
);
|
|
|
85 |
|
|
|
86 |
$calendar->add_entry($event);
|
|
|
87 |
$count++;
|
|
|
88 |
}
|
|
|
89 |
|
|
|
90 |
$calendar->add_properties(
|
|
|
91 |
# calscale => 'GREGORIAN',
|
|
|
92 |
# method => 'PUBLISH',
|
| 29 |
- |
93 |
'X-WR-CALNAME' => 'RollerCon Volunteer Schedule'
|
| 2 |
- |
94 |
);
|
|
|
95 |
|
|
|
96 |
print header('Content-type: text/calendar; charset=utf-8');
|
|
|
97 |
#print header('Content-Disposition: attachment; filename=export_ics.pl.ics');
|
|
|
98 |
print $calendar->as_string;
|