/[Frey]/trunk/lib/App/RoomReservation/Reservation.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/lib/App/RoomReservation/Reservation.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1098 - (show annotations)
Sun Jun 28 22:14:22 2009 UTC (14 years, 10 months ago) by dpavlin
File size: 2081 byte(s)
added verification and cancelation of reservation
1 package App::RoomReservation::Reservation;
2 use Moose;
3
4 extends 'App::RoomReservation';
5
6 use lib 'lib';
7 use Frey::PPI;
8
9 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 my @cols = Frey::PPI->new( class => __PACKAGE__ )->attribute_order;
77 warn "# cols = ",join(',', @cols), $/;
78
79 sub token {
80 my ( $self ) = @_;
81 my $self = shift;
82 my $sth = $self->dbh->prepare(qq{
83 select md5( id || email ) from reservation where email = ?
84 });
85 $sth->execute( $self->email );
86 $sth->fetchrow_array;
87 }
88
89 sub create_as_markup {
90 my ($self) = @_;
91
92 my @vals;
93 my @p;
94
95 map {
96 push @vals, $self->$_;
97 push @p, '?';
98 } @cols;
99
100 my $n = $#cols + 1;
101
102 my $sql
103 = 'insert into reservation ('
104 . join(',', @cols)
105 . ') values ('
106 . join(',', map { '?' } @cols )
107 . ')'
108 ;
109
110 warn "sql: $sql\n";
111
112 my $sth = $self->dbh->prepare( $sql );
113 $sth->execute( @vals );
114
115 return
116 $self->ime . ' ' . $self->prezime
117 . qq| we have accepted your registration!|
118 . qq|
119 <div style="color:red">
120 You have to confirm your e-mail address and registration
121 by clicking on link which should be in your e-mail INBOX shortly
122 </div>
123 |
124 . qq|<a href="/App::RoomReservation::Reservation::Confirmation/verify_as_markup?token=|
125 . $self->token
126 . qq|">verify</a>|
127 . ' or '
128 . qq|<a href="/App::RoomReservation::Reservation::Confirmation/cancel_as_markup?token=|
129 . $self->token
130 . qq|">cancel</a>|
131 ;
132 }
133
134
135 1;

  ViewVC Help
Powered by ViewVC 1.1.26