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

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

revision 1098 by dpavlin, Sun Jun 28 22:14:22 2009 UTC revision 1121 by dpavlin, Tue Jun 30 13:24:03 2009 UTC
# Line 12  has token => ( Line 12  has token => (
12  sub verify_as_markup {  sub verify_as_markup {
13          my ($self) = @_;          my ($self) = @_;
14    
15          my $sth = $self->dbh->prepare(qq{          my $dbh = $self->dbh;
16                  update reservation set _confirmed = true  
17            my $sth = $dbh->prepare(qq{
18                    update reservation
19                    set
20                            _confirmed = true,
21                            _seat_number = (
22                                    select
23                                            min(seat.nr)
24                                    from (select generate_series(1,600) as nr) as seat
25                                    full join reservation on reservation._seat_number = seat.nr
26                                    where id is null
27                                    group by seat.nr
28                                    order by seat.nr asc
29                                    limit 1
30                            )
31                  where md5(id||email) = ? and _confirmed is false                  where md5(id||email) = ? and _confirmed is false
32          });          });
33    
34          $sth->execute( $self->token );          $sth->execute( $self->token );
35    
36          if ( $sth->rows == 1 ) {          if ( $sth->rows == 1 ) {
37                  qq|Your <em>reservation has been confirmed</em> and seat is waiting for you|;  
38                    $sth = $dbh->prepare(qq{
39                            select ime||' '||prezime,_seat_number
40                            from reservation
41                            where md5(id||email) = ? and _confirmed is true and _seat_number is not null
42                    });
43    
44                    $sth->execute( $self->token );
45                    my ($name, $seat) = $sth->fetchrow_array;
46    
47                    qq|
48                            $name, <em>reservation has been confirmed</em> and seat number <big>$seat</big> is waiting for you.
49                            <br>
50                            Please print this notice and show it when entering lecture.
51                    |;
52          } else {          } else {
53                  qq|We have problem with your confirmation|                  die "Problem with confirmation.\n";
54          }          }
55  }  }
56    
57  sub cancel_as_markup {  sub cancel_as_markup {
58          my ($self) = @_;          my ($self) = @_;
59    
60          my $sth = $self->dbh->prepare(qq{          my $dbh = $self->dbh;
61                  update reservation set _confirmed = false  
62            my $sth = $dbh->prepare(qq{
63                    update reservation
64                    set
65                            _confirmed = false,
66                            _seat_number = null
67                  where md5(id||email) = ? and _confirmed is true                  where md5(id||email) = ? and _confirmed is true
68          });          });
69          $sth->execute( $self->token );          $sth->execute( $self->token );
# Line 37  sub cancel_as_markup { Line 71  sub cancel_as_markup {
71          if ( $sth->rows == 1 ) {          if ( $sth->rows == 1 ) {
72                  qq|Your <em>reservation is canceled</em>, thanks for your effort to provide seat to somebody else|;                  qq|Your <em>reservation is canceled</em>, thanks for your effort to provide seat to somebody else|;
73          } else {          } else {
74                  qq|We have problem with cancelation|                  die "Problem with cancelation.\n";
75          }          }
76  }  }
77    

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

  ViewVC Help
Powered by ViewVC 1.1.26