1 |
dpavlin |
1086 |
package App::RoomReservation::Reservation; |
2 |
|
|
use Moose; |
3 |
|
|
|
4 |
dpavlin |
1098 |
extends 'App::RoomReservation'; |
5 |
dpavlin |
1086 |
|
6 |
dpavlin |
1095 |
use lib 'lib'; |
7 |
|
|
use Frey::PPI; |
8 |
|
|
|
9 |
dpavlin |
1086 |
has ime => ( |
10 |
|
|
is => 'rw', |
11 |
|
|
isa => 'Str', |
12 |
|
|
required => 1, |
13 |
|
|
); |
14 |
|
|
|
15 |
|
|
has prezime => ( |
16 |
|
|
is => 'rw', |
17 |
|
|
isa => 'Str', |
18 |
|
|
required => 1, |
19 |
|
|
); |
20 |
|
|
|
21 |
|
|
has institucija => ( |
22 |
|
|
is => 'rw', |
23 |
|
|
isa => 'Str', |
24 |
|
|
required => 1, |
25 |
|
|
); |
26 |
|
|
|
27 |
|
|
has zanimanje => ( |
28 |
|
|
is => 'rw', |
29 |
|
|
isa => 'Str', |
30 |
|
|
required => 1, |
31 |
|
|
); |
32 |
|
|
|
33 |
|
|
has grad => ( |
34 |
|
|
is => 'rw', |
35 |
|
|
isa => 'Str', |
36 |
|
|
required => 1, |
37 |
|
|
); |
38 |
|
|
|
39 |
|
|
has drzava => ( |
40 |
|
|
is => 'rw', |
41 |
|
|
isa => 'Str', |
42 |
|
|
required => 1, |
43 |
|
|
); |
44 |
|
|
|
45 |
|
|
has telefon => ( |
46 |
|
|
is => 'rw', |
47 |
|
|
isa => 'Str', |
48 |
|
|
required => 1, |
49 |
|
|
); |
50 |
|
|
|
51 |
|
|
has mobitel => ( |
52 |
|
|
is => 'rw', |
53 |
|
|
isa => 'Str', |
54 |
|
|
required => 1, |
55 |
|
|
); |
56 |
|
|
|
57 |
|
|
has email => ( |
58 |
|
|
is => 'rw', |
59 |
|
|
isa => 'Str', |
60 |
|
|
required => 1, |
61 |
|
|
); |
62 |
|
|
|
63 |
|
|
has email_verify => ( |
64 |
|
|
is => 'rw', |
65 |
|
|
isa => 'Str', |
66 |
|
|
required => 1, |
67 |
|
|
); |
68 |
|
|
|
69 |
|
|
has _confirmed => ( |
70 |
|
|
is => 'rw', |
71 |
|
|
isa => 'Bool', |
72 |
|
|
required => 1, |
73 |
|
|
default => sub { 0 }, |
74 |
|
|
); |
75 |
|
|
|
76 |
dpavlin |
1104 |
sub BUILD { |
77 |
|
|
my $self = shift; |
78 |
|
|
die "e-mail not verified\n" unless $self->email eq $self->email_verify; |
79 |
|
|
} |
80 |
|
|
|
81 |
dpavlin |
1095 |
my @cols = Frey::PPI->new( class => __PACKAGE__ )->attribute_order; |
82 |
|
|
warn "# cols = ",join(',', @cols), $/; |
83 |
|
|
|
84 |
dpavlin |
1098 |
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 |
dpavlin |
1095 |
sub create_as_markup { |
95 |
dpavlin |
1086 |
my ($self) = @_; |
96 |
|
|
|
97 |
dpavlin |
1095 |
my @vals; |
98 |
|
|
my @p; |
99 |
|
|
|
100 |
|
|
map { |
101 |
|
|
push @vals, $self->$_; |
102 |
|
|
push @p, '?'; |
103 |
|
|
} @cols; |
104 |
|
|
|
105 |
|
|
my $n = $#cols + 1; |
106 |
|
|
|
107 |
|
|
my $sql |
108 |
|
|
= 'insert into reservation (' |
109 |
|
|
. join(',', @cols) |
110 |
|
|
. ') values (' |
111 |
|
|
. join(',', map { '?' } @cols ) |
112 |
|
|
. ')' |
113 |
|
|
; |
114 |
|
|
|
115 |
|
|
warn "sql: $sql\n"; |
116 |
|
|
|
117 |
dpavlin |
1098 |
my $sth = $self->dbh->prepare( $sql ); |
118 |
dpavlin |
1095 |
$sth->execute( @vals ); |
119 |
|
|
|
120 |
dpavlin |
1098 |
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 |
dpavlin |
1086 |
} |
138 |
|
|
|
139 |
dpavlin |
1098 |
|
140 |
dpavlin |
1086 |
1; |