/[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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1151 by dpavlin, Wed Jul 1 21:47:04 2009 UTC revision 1155 by dpavlin, Thu Jul 2 10:12:54 2009 UTC
# Line 2  package App::RoomReservation::Messages; Line 2  package App::RoomReservation::Messages;
2  use Moose::Role;  use Moose::Role;
3    
4  sub seat_confirmation_message {  sub seat_confirmation_message {
5          my ( $self, $name, $seat, $email, $url ) = @_;          my ( $self, $col, $value ) = @_;
6    
7          my $html =          die "wrong column name $col = $value" unless $col =~ m{^(token|email)$};
8          qq|  
9                  $name, <em>reservation has been confirmed</em>          $col =~ s{token}{md5(id||email)};
10          |  
11          . ( $seat          my $sth = $self->dbh->prepare(qq{
12          ? qq|                  select
13                  and seat number <big>$seat</big> is waiting for you.                          ime||' '||prezime,
14                  <br>                          _seat_number,
15                  Please print this notice and show it when entering lecture.                          email,
16          | : qq|                          md5(id||email) as token,
17                  we <big>currently don't have any seats available</big>,                          _confirmed,
18                  but you will be notified if we get some vacancies for this lecture!                          _canceled
19          | )                  from reservation
20          ;                  where
21                            $col = ?
22          $self->send( $email,          });
23                  "Lecture confirmation" . $seat ? " [seat $seat]" : " [wating for vacancy]",  
24                  $html . <<__EMAIL__          $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:  If you wish to cancel your reservation please click on link below:
71    
72  $url  $url
73    
74  __EMAIL__  __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          return $html;  }
 };  
107    
108  1;  1;

Legend:
Removed from v.1151  
changed lines
  Added in v.1155

  ViewVC Help
Powered by ViewVC 1.1.26