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 ); |
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 |
|
|