--- trunk/lib/App/RoomReservation/Confirmation.pm 2009/07/01 18:41:28 1150 +++ trunk/lib/App/RoomReservation/Confirmation.pm 2009/07/01 21:47:04 1151 @@ -3,7 +3,7 @@ extends 'App::RoomReservation'; -with 'App::RoomReservation::Email'; +with 'App::RoomReservation::Email', 'App::RoomReservation::Messages'; has token => ( is => 'ro', @@ -30,43 +30,48 @@ order by seat.nr asc limit 1 ) - where md5(id||email) = ? and _confirmed is false + where + md5(id||email) = ? + and _confirmed is false }); $sth->execute( $self->token ); - if ( $sth->rows == 1 ) { - + if ( $sth->rows == 0 ) { + warn "can't confirm ", $self->token, " check if it's allready confirmed"; $sth = $dbh->prepare(qq{ - select ime||' '||prezime,_seat_number,email + select 1 from reservation - where md5(id||email) = ? and _confirmed is true and _seat_number is not null + where + md5(id||email) = ? + and _confirmed is true }); - $sth->execute( $self->token ); - my ($name, $seat, $email) = $sth->fetchrow_array; + } - my $html = - qq| - $name, reservation has been confirmed and seat number $seat is waiting for you. -
- Please print this notice and show it when entering lecture. - |; + if ( $sth->rows == 1 ) { - my $url = $self->url_for( 'Confirmation/cancel_as_markup?token=' . $self->token ); + $sth = $dbh->prepare(qq{ + select + ime||' '||prezime, + _seat_number, + email + from reservation + where + _confirmed is true +-- and _seat_number is not null + and md5(id||email) = ? + }); - my $token = $self->token; - $self->send( $email, - "Lecture seat $seat is assigned to you", - $html . <<__EMAIL__ + $sth->execute( $self->token ); -If you wish to cancel your reservation please click on link below: + die "can't find account associated with ", $self->token unless $sth->rows == 1; -$url -__EMAIL__ - ); + my @reservation = $sth->fetchrow_array; + push @reservation, + $self->url_for( 'Confirmation/cancel_as_markup?token=' . $self->token ); - return $html; + return $self->seat_confirmation_message( @reservation ); } else { die "Problem with confirmation.\n"; @@ -83,12 +88,16 @@ set _confirmed = false, _seat_number = null - where md5(id||email) = ? and _confirmed is true + where + md5(id||email) = ? +-- and _confirmed is true }); $sth->execute( $self->token ); if ( $sth->rows == 1 ) { - qq|Your reservation is canceled, thanks for your effort to provide seat to somebody else|; + qq| + Your reservation is canceled, thanks for your effort to provide seat to somebody else + |; } else { die "Problem with cancelation.\n"; }