Subversion Repositories ORC

Rev

Details | 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;
14
 
15
my $dbh = getDBConnection ();
16
my $DEPT = getDepartments ();
17
 
18
my $RCidListQuery=<<endRCidListQuery;
19
  select distinct RCid from (
20
  	select distinct RCid from v_shift             where year(date) = year(curdate()) and dept <> "PER" and dept <> "CLA" union
21
    select distinct RCid from v_shift_announcer   where year(date) = year(curdate()) union
22
    select distinct RCid from v_shift_officiating where year(date) = year(curdate())
23
    ) t1
24
  where RCid <> ''
25
  order by cast(RCid as unsigned)
26
endRCidListQuery
27
my $sth1 = $dbh->prepare($RCidListQuery);
28
 
29
my $SchedQuery=<<endSchedQuery;
30
  select * from (
31
  	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
32
    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
33
    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 = ?
34
      ) temp
35
  order by date, time
36
endSchedQuery
37
my $sth2 = $dbh->prepare($SchedQuery);
38
 
39
$sth1->execute();
40
while (my ($RCid) = $sth1->fetchrow_array()) {
41
	my $email = getUserEmail($RCid);
42
	my $dname = getUserDerbyName($RCid);
43
	my @shifts = ();
44
	my $hours;
45
 
46
	$sth2->execute($RCid, $RCid, $RCid);
47
	while (my $S = $sth2->fetchrow_hashref()) {
48
		push @shifts, $S;
49
		$hours += $S->{volhours};
50
	}
51
 
52
	my $message = $h->p ("Greetings $dname,", "Thanks for all your hard work at RollerCon. Here are the volunteer hours we captured for you:");
53
 
54
  $message .= $h->table ([
55
    map { $h->tr ([ $h->td ( $_->{date},
56
                             $_->{dayofweek},
57
                             $_->{time},
58
                             $_->{volhours}." hr(s)",
59
                             $DEPT->{$_->{dept}},
60
                             $_->{role},
61
                             $_->{teams} ) ]) } @shifts
62
  ]);
63
  $message .= $h->b ($hours." TOTAL HOURS");
64
#	foreach (@shifts) {
65
#	  $message .= join " ", $_->{date}, sprintf ("%-9s", $_->{dayofweek}), $_->{time}, sprintf ("%-12s", $_->{volhours}." hr(s)"), $DEPT->{$_->{dept}},	$_->{role},	$_->{teams}."\n";
66
#		$message .= "$_->{date} $_->{dayofweek} $_->{time}  $_->{volhours} hr(s)  $DEPT->{$_->{dept}}	$_->{role}	$_->{teams}\n";
67
#	}
68
 
69
  $message .= $h->p (
70
    "Do you see any discrepancies? If so, please report them ".$h->a ({ href=>"https://docs.google.com/forms/d/e/1FAIpQLSdbzcuEz2k_6ycf826-R3lGc3L37mfENUm7pQXxlFPb2LlvWA/viewform"}, "HERE")." before August 31st. We'll update our records based on your form entries, and you will see the updates on your home page in VORC. Entries made after August can't be updated in VORC. So maybe you should update it now - it's a short form!",
71
    "Then in October, we'll send out free / discounted info for RollerCon 2023 to the email you listed in your profile in ".$h->a ({ href=>"https://volunteers.rollercon.com/schedule/" }, "VORC").".  Thanks again. You're the one who keeps RollerCon rolling!!!!",
72
    $h->a ({ href=>"https://rollercon.com/help-wanted/" }, "More about freebies & discounts"),
73
    $h->hr.$h->p ({ style=>"text-align:center" }, $h->b ("Volunteer Compensation")).$h->hr,
74
    "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.",
75
    $h->ul ([
76
      $h->li (
77
        $h->b ("10-25 hours")." qualifies you for a discounted pass that can be redeemed at a lower price than we ever sell until June.",
78
        $h->b ("Over 25 hours")." gets you a free pass plus all the other stuff above."
79
        )
80
    ]),
81
    $h->br,
82
    "--RollerCon HQ".$h->br.'rollercon@gmail.com'.$h->br."rollercon.com"
83
  );
84
 
85
 
86
#	$message .= "\n$hours TOTAL HOURS\n\nAgain, thank you for volunteering at RollerCon.\n\n-RollerCon Leadership Team";
87
 
88
	my $subject = $dname."'s RollerCon Volunteer Hours Summary";
89
 
90
	print "Emailing $dname ($email)...\n";
91
	use RCMailer;
92
	EmailUser($email, $subject, $message);
93
	sleep (15);
94
}
95
 
96
print "\ndone.\n\n";