Subversion Repositories VORC

Rev

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

Rev Author Line No. Line
47 - 1
#!/usr/bin/perl
2
 
3
use strict;
4
use cPanelUserConfig;
5
use RollerCon;
6
use tableViewer;
7
use DateTime;
8
use HTML::Tiny;
9
my $h = HTML::Tiny->new( mode => 'html' );
10
 
11
my $dt = DateTime->today;
12
my $day = $dt->day_name;
13
my $date = $dt->date;
189 - 14
my $year = $dt->year;
47 - 15
 
16
my $dbh = getDBConnection ();
17
my $DEPT = getDepartments ();
18
 
19
my $RCidListQuery=<<endRCidListQuery;
20
  select distinct RCid from (
21
  	select distinct RCid from v_shift             where year(date) = year(curdate()) and dept <> "PER" and dept <> "CLA" union
22
    select distinct RCid from v_shift_announcer   where year(date) = year(curdate()) union
23
    select distinct RCid from v_shift_officiating where year(date) = year(curdate())
24
    ) t1
25
  where RCid <> ''
26
  order by cast(RCid as unsigned)
27
endRCidListQuery
28
my $sth1 = $dbh->prepare($RCidListQuery);
29
 
30
my $SchedQuery=<<endSchedQuery;
31
  select * from (
32
  	select id, date, dayofweek,          location, time, volhours,          dept, role, '' as teams from v_shift             where year(date) = year(curdate()) and RCid = ? and dept <> "PER" and dept <> "CLA" union
33
    select id, date, dayofweek, track as location, time, volhours, "ANN" as dept, role,       teams from v_shift_announcer   where year(date) = year(curdate()) and RCid = ? union
34
    select id, date, dayofweek, track as location, time, volhours, "OFF" as dept, role,       teams from v_shift_officiating where year(date) = year(curdate()) and RCid = ?
35
      ) temp
36
  order by date, time
37
endSchedQuery
38
my $sth2 = $dbh->prepare($SchedQuery);
39
 
40
$sth1->execute();
41
while (my ($RCid) = $sth1->fetchrow_array()) {
42
	my $email = getUserEmail($RCid);
43
	my $dname = getUserDerbyName($RCid);
44
	my @shifts = ();
45
	my $hours;
46
 
47
	$sth2->execute($RCid, $RCid, $RCid);
48
	while (my $S = $sth2->fetchrow_hashref()) {
49
		push @shifts, $S;
50
		$hours += $S->{volhours};
51
	}
52
 
53
	my $message = $h->p ("Greetings $dname,", "Thanks for all your hard work at RollerCon. Here are the volunteer hours we captured for you:");
54
 
55
  $message .= $h->table ([
56
    map { $h->tr ([ $h->td ( $_->{date},
57
                             $_->{dayofweek},
58
                             $_->{time},
59
                             $_->{volhours}." hr(s)",
60
                             $DEPT->{$_->{dept}},
61
                             $_->{role},
62
                             $_->{teams} ) ]) } @shifts
63
  ]);
64
  $message .= $h->b ($hours." TOTAL HOURS");
65
#	foreach (@shifts) {
66
#	  $message .= join " ", $_->{date}, sprintf ("%-9s", $_->{dayofweek}), $_->{time}, sprintf ("%-12s", $_->{volhours}." hr(s)"), $DEPT->{$_->{dept}},	$_->{role},	$_->{teams}."\n";
67
#		$message .= "$_->{date} $_->{dayofweek} $_->{time}  $_->{volhours} hr(s)  $DEPT->{$_->{dept}}	$_->{role}	$_->{teams}\n";
68
#	}
69
 
70
  $message .= $h->p (
239 - 71
    "Thanks for your time and work at RollerCon! Please review your hours listed above. If you see any discrepancies, please submit a ".$h->a ({ href=>"https://volunteers.rollercon.com/schedule/missing_hours.pl" }, "Missing Volunteer Time")." request immediately. We will process requests until <B>July 31st.</B>",
72
    "When we process yours, you will see the updates on ".$h->a ({ href=>"https://volunteers.rollercon.com/schedule/view_user.pl" }, "your user profile page")." in VORC. Submissions cannot be accepted after July 31st, so please handle this now - it's a quick form!",
73
    "Look for an email (to the address in your VORC account: this one!) before November 15th with redemption links for next year's free & discounted passes. See you next year!",
74
    "And thanks again. You're the one who keeps RollerCon rolling!!!!",
47 - 75
    $h->a ({ href=>"https://rollercon.com/help-wanted/" }, "More about freebies & discounts"),
76
    $h->hr.$h->p ({ style=>"text-align:center" }, $h->b ("Volunteer Compensation")).$h->hr,
77
    "All RollerCon volunteers get cool stuff at RollerCon, including a raffle ticket, limited-edition volunteer-only tee (while they last), and other schwag, snacks, goodwill and more every year, plus cool stuff from our sponsors.",
78
    $h->ul ([
79
      $h->li (
187 - 80
        $h->b ("5-19 hours")." qualifies you for a discounted pass that can be redeemed at a lower price than we ever sell until June.",
81
        $h->b ("20 hours and over")." gets you a free pass plus all the other stuff above."
47 - 82
        )
83
    ]),
84
    $h->br,
85
    "--RollerCon HQ".$h->br.'rollercon@gmail.com'.$h->br."rollercon.com"
86
  );
87
 
88
 
89
#	$message .= "\n$hours TOTAL HOURS\n\nAgain, thank you for volunteering at RollerCon.\n\n-RollerCon Leadership Team";
90
 
189 - 91
	my $subject = $dname."'s $year RollerCon Volunteer Hours Summary";
47 - 92
 
186 - 93
	print "Emailing $RCid. $dname ($email)...\n";
47 - 94
	use RCMailer;
95
	EmailUser($email, $subject, $message);
96
	sleep (15);
97
}
98
 
156 - 99
print "\ndone.\n\n";