/[Frey]/trunk/lib/App/RoomReservation/Confirmation.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/Confirmation.pm

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

revision 1150 by dpavlin, Wed Jul 1 17:35:48 2009 UTC revision 1151 by dpavlin, Wed Jul 1 21:47:04 2009 UTC
# Line 3  use Moose; Line 3  use Moose;
3    
4  extends 'App::RoomReservation';  extends 'App::RoomReservation';
5    
6  with 'App::RoomReservation::Email';  with 'App::RoomReservation::Email', 'App::RoomReservation::Messages';
7    
8  has token => (  has token => (
9          is => 'ro',          is => 'ro',
# Line 30  sub verify_as_markup { Line 30  sub verify_as_markup {
30                                  order by seat.nr asc                                  order by seat.nr asc
31                                  limit 1                                  limit 1
32                          )                          )
33                  where md5(id||email) = ? and _confirmed is false                  where
34                            md5(id||email) = ?
35                            and _confirmed is false
36          });          });
37    
38          $sth->execute( $self->token );          $sth->execute( $self->token );
39    
40          if ( $sth->rows == 1 ) {          if ( $sth->rows == 0 ) {
41                    warn "can't confirm ", $self->token, " check if it's allready confirmed";
42                  $sth = $dbh->prepare(qq{                  $sth = $dbh->prepare(qq{
43                          select ime||' '||prezime,_seat_number,email                          select 1
44                          from reservation                          from reservation
45                          where md5(id||email) = ? and _confirmed is true and _seat_number is not null                          where
46                                    md5(id||email) = ?
47                                    and _confirmed is true
48                  });                  });
   
49                  $sth->execute( $self->token );                  $sth->execute( $self->token );
50                  my ($name, $seat, $email) = $sth->fetchrow_array;          }
51    
52                  my $html =          if ( $sth->rows == 1 ) {
                 qq|  
                         $name, <em>reservation has been confirmed</em> and seat number <big>$seat</big> is waiting for you.  
                         <br>  
                         Please print this notice and show it when entering lecture.  
                 |;  
53    
54                  my $url = $self->url_for( 'Confirmation/cancel_as_markup?token=' . $self->token );                  $sth = $dbh->prepare(qq{
55                            select
56                                    ime||' '||prezime,
57                                    _seat_number,
58                                    email
59                            from reservation
60                            where
61                                    _confirmed is true
62    --                              and _seat_number is not null
63                                    and md5(id||email) = ?
64                    });
65    
66                  my $token = $self->token;                  $sth->execute( $self->token );
                 $self->send( $email,  
                         "Lecture seat $seat is assigned to you",  
                         $html . <<__EMAIL__  
67    
68  If you wish to cancel your reservation please click on link below:                  die "can't find account associated with ", $self->token unless $sth->rows == 1;
69    
70  $url                  my @reservation = $sth->fetchrow_array;
71  __EMAIL__                  push @reservation,
72                  );                          $self->url_for( 'Confirmation/cancel_as_markup?token=' . $self->token );
73    
74                  return $html;                  return $self->seat_confirmation_message( @reservation );
75    
76          } else {          } else {
77                  die "Problem with confirmation.\n";                  die "Problem with confirmation.\n";
# Line 83  sub cancel_as_markup { Line 88  sub cancel_as_markup {
88                  set                  set
89                          _confirmed = false,                          _confirmed = false,
90                          _seat_number = null                          _seat_number = null
91                  where md5(id||email) = ? and _confirmed is true                  where
92                            md5(id||email) = ?
93    --                      and _confirmed is true
94          });          });
95          $sth->execute( $self->token );          $sth->execute( $self->token );
96    
97          if ( $sth->rows == 1 ) {          if ( $sth->rows == 1 ) {
98                  qq|Your <em>reservation is canceled</em>, thanks for your effort to provide seat to somebody else|;                  qq|
99                            Your <em>reservation is canceled</em>, thanks for your effort to provide seat to somebody else
100                    |;
101          } else {          } else {
102                  die "Problem with cancelation.\n";                  die "Problem with cancelation.\n";
103          }          }

Legend:
Removed from v.1150  
changed lines
  Added in v.1151

  ViewVC Help
Powered by ViewVC 1.1.26