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

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

revision 1122 by dpavlin, Tue Jun 30 13:31:51 2009 UTC revision 1155 by dpavlin, Thu Jul 2 10:12:54 2009 UTC
# Line 3  use Moose; Line 3  use Moose;
3    
4  extends 'App::RoomReservation';  extends 'App::RoomReservation';
5    
6    with 'App::RoomReservation::Email', 'App::RoomReservation::Messages';
7    
8  has token => (  has token => (
9          is => 'ro',          is => 'ro',
10          isa => 'Str',          isa => 'Str',
# Line 28  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                            and _canceled is false
37          });          });
38    
39          $sth->execute( $self->token );          $sth->execute( $self->token );
40    
41          if ( $sth->rows == 1 ) {          if ( $sth->rows == 0 ) {
42                    warn "can't confirm ", $self->token, " check if it's allready confirmed";
43                  $sth = $dbh->prepare(qq{                  $sth = $dbh->prepare(qq{
44                          select ime||' '||prezime,_seat_number                          select 1
45                          from reservation                          from reservation
46                          where md5(id||email) = ? and _confirmed is true and _seat_number is not null                          where
47                                    md5(id||email) = ?
48                                    and _confirmed is true
49                  });                  });
   
50                  $sth->execute( $self->token );                  $sth->execute( $self->token );
51                  my ($name, $seat) = $sth->fetchrow_array;          }
52    
53            if ( $sth->rows == 1 ) {
54    
55                    die "can't find account associated with ", $self->token unless $sth->rows == 1;
56    
57                    return $self->seat_confirmation_message( token => $self->token );
58    
                 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.  
                 |;  
59          } else {          } else {
60                  die "Problem with confirmation.\n";                  die "Problem with confirmation.\n";
61          }          }
# Line 62  sub cancel_as_markup { Line 69  sub cancel_as_markup {
69          my $sth = $dbh->prepare(qq{          my $sth = $dbh->prepare(qq{
70                  update reservation                  update reservation
71                  set                  set
72                          _confirmed = false,                          _canceled = true,
73                          _seat_number = null                          _seat_number = null
74                  where md5(id||email) = ? and _confirmed is true                  where
75                            md5(id||email) = ?
76    --                      and _confirmed is true
77          });          });
78          $sth->execute( $self->token );          $sth->execute( $self->token );
79    
80          if ( $sth->rows == 1 ) {          if ( $sth->rows == 1 ) {
81                  qq|Your <em>reservation is canceled</em>, thanks for your effort to provide seat to somebody else|;                  qq|
82                            Your <em>reservation is canceled</em>, thanks for your effort to provide seat to somebody else
83                    |;
84          } else {          } else {
85                  die "Problem with cancelation.\n";                  die "Problem with cancelation.\n";
86          }          }
87  }  }
88    
89    __PACKAGE__->meta->make_immutable;
90    no Moose;
91    
92  1;  1;

Legend:
Removed from v.1122  
changed lines
  Added in v.1155

  ViewVC Help
Powered by ViewVC 1.1.26