1 |
package App::RoomReservation::Reservation; |
package App::RoomReservation::Reservation; |
2 |
use Moose; |
use Moose; |
3 |
|
|
4 |
extends 'Frey'; |
extends 'App::RoomReservation'; |
|
with 'Frey::Web'; |
|
5 |
|
|
|
use DBI; |
|
6 |
use lib 'lib'; |
use lib 'lib'; |
7 |
use Frey::PPI; |
use Frey::PPI; |
8 |
|
|
73 |
default => sub { 0 }, |
default => sub { 0 }, |
74 |
); |
); |
75 |
|
|
76 |
sub dsn { 'DBI:Pg:dbname=room-reservation' } |
sub BUILD { |
77 |
|
my $self = shift; |
78 |
|
die "e-mail not verified\n" unless $self->email eq $self->email_verify; |
79 |
|
} |
80 |
|
|
81 |
my @cols = Frey::PPI->new( class => __PACKAGE__ )->attribute_order; |
my @cols = Frey::PPI->new( class => __PACKAGE__ )->attribute_order; |
82 |
warn "# cols = ",join(',', @cols), $/; |
warn "# cols = ",join(',', @cols), $/; |
83 |
|
|
84 |
|
sub token { |
85 |
|
my ( $self ) = @_; |
86 |
|
my $self = shift; |
87 |
|
my $sth = $self->dbh->prepare(qq{ |
88 |
|
select md5( id || email ) from reservation where email = ? |
89 |
|
}); |
90 |
|
$sth->execute( $self->email ); |
91 |
|
$sth->fetchrow_array; |
92 |
|
} |
93 |
|
|
94 |
sub create_as_markup { |
sub create_as_markup { |
95 |
my ($self) = @_; |
my ($self) = @_; |
96 |
|
|
|
my $dbh = DBI->connect( $self->dsn, '', '', { RaiseError => 1 } ) || die $DBI::errstr; |
|
|
$dbh->do( qq{ set client_encoding='utf-8' } ) if $self->dsn =~ m{pg}i; |
|
|
|
|
97 |
my @vals; |
my @vals; |
98 |
my @p; |
my @p; |
99 |
|
|
114 |
|
|
115 |
warn "sql: $sql\n"; |
warn "sql: $sql\n"; |
116 |
|
|
117 |
my $sth = $dbh->prepare( $sql ); |
my $sth = $self->dbh->prepare( $sql ); |
118 |
$sth->execute( @vals ); |
$sth->execute( @vals ); |
119 |
|
|
120 |
$sth->rows; |
return |
121 |
|
$self->ime . ' ' . $self->prezime |
122 |
|
. qq| we have accepted your registration!| |
123 |
|
. qq| |
124 |
|
<div style="color:red"> |
125 |
|
You have to confirm your e-mail address and registration |
126 |
|
by clicking on link which should be in your e-mail INBOX shortly |
127 |
|
</div> |
128 |
|
| |
129 |
|
. qq|<a href="/App::RoomReservation::Reservation::Confirmation/verify_as_markup?token=| |
130 |
|
. $self->token |
131 |
|
. qq|">verify</a>| |
132 |
|
. ' or ' |
133 |
|
. qq|<a href="/App::RoomReservation::Reservation::Confirmation/cancel_as_markup?token=| |
134 |
|
. $self->token |
135 |
|
. qq|">cancel</a>| |
136 |
|
; |
137 |
} |
} |
138 |
|
|
139 |
|
|
140 |
1; |
1; |