--- trunk/lib/App/RoomReservation/Reservation.pm 2009/06/30 15:10:55 1133 +++ trunk/lib/App/RoomReservation/Reservation.pm 2009/07/02 17:59:56 1164 @@ -11,6 +11,8 @@ extends 'App::RoomReservation'; +with 'App::RoomReservation::Email', 'App::RoomReservation::Messages'; + use lib 'lib'; use Frey::PPI; @@ -59,7 +61,7 @@ has mobitel => ( is => 'rw', isa => 'Str', - required => 1, + default => '', # FIXME without this we get undef in form ); has email => ( @@ -86,29 +88,46 @@ isa => 'Int', ); +has _canceled => ( + is => 'rw', + isa => 'Bool', + default => sub { 0 }, +); + +sub form_labels {{ + ime => 'Ime', + prezime => 'Prezime', + institucija => 'Institucija', + zanimanje => 'Zanimanje', + grad => 'Grad', + drzava => 'Država', + telefon => 'Telefon', + mobitel => 'Mobitel', + email => 'e-mail adresa', + verify => 'unesite ponovo', + submit => 'Pošalji', # submit button +}} + sub BUILD { my $self = shift; - die "e-mail not verified\n" unless $self->email eq $self->email_verify; + my $email = $self->email; + die "e-mail not verified\n" unless $email eq $self->email_verify; my $sth = $self->dbh->prepare(qq{ select count(*) from reservation where email = ? }); - $sth->execute( $self->email ); + $sth->execute( $email ); my ($registred) = $sth->fetchrow_array; - die "e-mail address ", $self->email, " allready registred\n" if $registred; + if ( $registred ) { + die qq| + e-mail address $email allready registred + | . $self->seat_confirmation_message( email => $email ) + ; + } } my @cols = Frey::PPI->new( class => __PACKAGE__ )->attribute_order; warn "# cols = ",join(',', @cols), $/; -sub token { - my $self = shift; - my $sth = $self->dbh->prepare(qq{ - select md5( id || email ) from reservation where email = ? - }); - $sth->execute( $self->email ); - $sth->fetchrow_array; -} - sub create_as_markup { my ($self) = @_; @@ -135,23 +154,8 @@ my $sth = $self->dbh->prepare( $sql ); $sth->execute( @vals ); - return - $self->ime . ' ' . $self->prezime - . qq| we have accepted your registration!| - . qq| -
- You have to confirm your e-mail address and registration - by clicking on link which should be in your e-mail INBOX shortly -
- | - . qq|verify| - . ' or ' - . qq|cancel| - ; + return $self->seat_confirmation_message( email => $self->email ); + } __PACKAGE__->meta->make_immutable;