/[Frey]/trunk/lib/App/RoomReservation/Messages.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/lib/App/RoomReservation/Messages.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1155 - (show annotations)
Thu Jul 2 10:12:54 2009 UTC (14 years, 10 months ago) by dpavlin
File size: 2191 byte(s)
allow users to cancel lecture seat only once
1 package App::RoomReservation::Messages;
2 use Moose::Role;
3
4 sub seat_confirmation_message {
5 my ( $self, $col, $value ) = @_;
6
7 die "wrong column name $col = $value" unless $col =~ m{^(token|email)$};
8
9 $col =~ s{token}{md5(id||email)};
10
11 my $sth = $self->dbh->prepare(qq{
12 select
13 ime||' '||prezime,
14 _seat_number,
15 email,
16 md5(id||email) as token,
17 _confirmed,
18 _canceled
19 from reservation
20 where
21 $col = ?
22 });
23
24 $sth->execute( $value );
25
26 die "can't find user $col = $value" if $sth->rows == 0;
27
28 my ( $name, $seat, $email, $token, $confirmed, $canceled ) = $sth->fetchrow_array;
29
30 if ( $confirmed && $canceled ) {
31
32 my $html =
33 qq|
34 $name, <em>you have canceled your reservation allready</em>
35 <br>
36 If you did that by mistake, and you want to attend this lecture, please
37 contact us via e-mail.
38 |;
39
40 $self->send( $email,
41 "Lecture confirmation canceled",
42 $html
43 );
44
45 return $html;
46
47 } elsif ( $confirmed ) {
48
49 my $url = $self->url_for( 'Confirmation/cancel_as_markup?token=' . $token );
50
51 my $html =
52 qq|
53 $name, <em>reservation has been confirmed</em>
54 |
55 . ( $seat
56 ? qq|
57 and seat number <big>$seat</big> is waiting for you.
58 <br>
59 Please print this notice and show it when entering lecture.
60 | : qq|
61 we <big>currently don't have any seats available</big>,
62 but you will be notified if we get some vacancies for this lecture!
63 | )
64 ;
65
66 $self->send( $email,
67 "Lecture confirmation" . ( $seat ? " [seat $seat]" : " [wating for vacancy]" ),
68 $html . <<__EMAIL__
69
70 If you wish to cancel your reservation please click on link below:
71
72 $url
73
74 __EMAIL__
75 );
76
77 return $html;
78
79 } else { # not verified
80
81 my $url = $self->url_for( 'Confirmation/verify_as_markup?token=' . $token );
82
83 $self->send( $self->email,
84 'Confirm your reservation for lecture', <<__EMAIL__
85
86 Please click following link to confirm your reservation for lecture
87 and get seat assigned to you.
88
89 $url
90
91 __EMAIL__
92 );
93
94 return qq|
95
96 $name we have accepted your registration!
97
98 <div style="color:red">
99 You have to confirm your e-mail address and registration
100 by clicking on link which should be in your e-mail INBOX shortly
101 </div>
102 |;
103
104 }
105
106 }
107
108 1;

  ViewVC Help
Powered by ViewVC 1.1.26