--- trunk/lib/App/RoomReservation/Reservation/Confirmation.pm 2009/06/28 22:14:22 1098 +++ trunk/lib/App/RoomReservation/Reservation/Confirmation.pm 2009/06/30 13:24:03 1121 @@ -12,24 +12,58 @@ sub verify_as_markup { my ($self) = @_; - my $sth = $self->dbh->prepare(qq{ - update reservation set _confirmed = true + my $dbh = $self->dbh; + + my $sth = $dbh->prepare(qq{ + update reservation + set + _confirmed = true, + _seat_number = ( + select + min(seat.nr) + from (select generate_series(1,600) as nr) as seat + full join reservation on reservation._seat_number = seat.nr + where id is null + group by seat.nr + order by seat.nr asc + limit 1 + ) where md5(id||email) = ? and _confirmed is false }); + $sth->execute( $self->token ); if ( $sth->rows == 1 ) { - qq|Your reservation has been confirmed and seat is waiting for you|; + + $sth = $dbh->prepare(qq{ + select ime||' '||prezime,_seat_number + from reservation + where md5(id||email) = ? and _confirmed is true and _seat_number is not null + }); + + $sth->execute( $self->token ); + my ($name, $seat) = $sth->fetchrow_array; + + qq| + $name, reservation has been confirmed and seat number $seat is waiting for you. +
+ Please print this notice and show it when entering lecture. + |; } else { - qq|We have problem with your confirmation| + die "Problem with confirmation.\n"; } } sub cancel_as_markup { my ($self) = @_; - my $sth = $self->dbh->prepare(qq{ - update reservation set _confirmed = false + my $dbh = $self->dbh; + + my $sth = $dbh->prepare(qq{ + update reservation + set + _confirmed = false, + _seat_number = null where md5(id||email) = ? and _confirmed is true }); $sth->execute( $self->token ); @@ -37,7 +71,7 @@ if ( $sth->rows == 1 ) { qq|Your reservation is canceled, thanks for your effort to provide seat to somebody else|; } else { - qq|We have problem with cancelation| + die "Problem with cancelation.\n"; } }