/[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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1086 by dpavlin, Sun Jun 28 14:21:10 2009 UTC revision 1098 by dpavlin, Sun Jun 28 22:14:22 2009 UTC
# Line 1  Line 1 
1  package App::RoomReservation::Reservation;  package App::RoomReservation::Reservation;
2  use Moose;  use Moose;
3    
4  extends 'Frey';  extends 'App::RoomReservation';
5  with 'Frey::Web';  
6  #with 'Frey::Storage';  use lib 'lib';
7    use Frey::PPI;
8    
9  has ime => (  has ime => (
10          is => 'rw',          is => 'rw',
# Line 72  has _confirmed => ( Line 73  has _confirmed => (
73          default => sub { 0 },          default => sub { 0 },
74  );  );
75    
76  sub as_markup {  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) = @_;          my ($self) = @_;
91    
92          $self->ime;          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;  1;

Legend:
Removed from v.1086  
changed lines
  Added in v.1098

  ViewVC Help
Powered by ViewVC 1.1.26