--- trunk/lib/App/RoomReservation/Messages.pm 2009/07/01 21:47:04 1151
+++ trunk/lib/App/RoomReservation/Messages.pm 2009/07/01 22:25:11 1152
@@ -2,35 +2,87 @@
use Moose::Role;
sub seat_confirmation_message {
- my ( $self, $name, $seat, $email, $url ) = @_;
+ my ( $self, $col, $value ) = @_;
- my $html =
- qq|
- $name, reservation has been confirmed
- |
- . ( $seat
- ? qq|
- and seat number $seat is waiting for you.
-
- Please print this notice and show it when entering lecture.
- | : qq|
- we currently don't have any seats available,
- but you will be notified if we get some vacancies for this lecture!
- | )
- ;
-
- $self->send( $email,
- "Lecture confirmation" . $seat ? " [seat $seat]" : " [wating for vacancy]",
- $html . <<__EMAIL__
+ $col =~ s{token}{md5(id||email};
+
+ my $sth = $self->dbh->prepare(qq{
+ select
+ ime||' '||prezime,
+ _seat_number,
+ email,
+ md5(id||email) as token,
+ _confirmed
+ from reservation
+ where
+ $col = ?
+ });
+
+ $sth->execute( $value );
+
+ die "can't find user $col = $value" if $sth->rows == 0;
+
+ my ( $name, $seat, $email, $token, $confirmed ) = $sth->fetchrow_array;
+
+ if ( $confirmed ) {
+
+ my $url = $self->url_for( 'Confirmation/cancel_as_markup?token=' . $token );
+
+ my $html =
+ qq|
+ $name, reservation has been confirmed
+ |
+ . ( $seat
+ ? qq|
+ and seat number $seat is waiting for you.
+
+ Please print this notice and show it when entering lecture.
+ | : qq|
+ we currently don't have any seats available,
+ but you will be notified if we get some vacancies for this lecture!
+ | )
+ ;
+
+ $self->send( $email,
+ "Lecture confirmation" . $seat ? " [seat $seat]" : " [wating for vacancy]",
+ $html . <<__EMAIL__
If you wish to cancel your reservation please click on link below:
$url
__EMAIL__
- );
+ );
+
+ return $html;
+
+ } else { # not verified
+
+ my $url = $self->url_for( 'Confirmation/verify_as_markup?token=' . $token );
+
+ $self->send( $self->email,
+ 'Confirm your reservation for lecture', <<__EMAIL__
+
+Please click following link to confirm your reservation for lecture
+and get seat assigned to you.
+
+$url
+
+__EMAIL__
+ );
+
+ return qq|
+
+ $name we have accepted your registration!
+
+