16 |
|
|
17 |
my $dbh = $self->dbh; |
my $dbh = $self->dbh; |
18 |
|
|
19 |
|
my $size = $self->room->seats; |
20 |
|
|
21 |
my $sth = $dbh->prepare(qq{ |
my $sth = $dbh->prepare(qq{ |
22 |
update reservation |
update reservation |
23 |
set |
set |
25 |
_seat_number = ( |
_seat_number = ( |
26 |
select |
select |
27 |
min(seat.nr) |
min(seat.nr) |
28 |
from (select generate_series(1,600) as nr) as seat |
from (select generate_series(1,$size) as nr) as seat |
29 |
full join reservation on reservation._seat_number = seat.nr |
full join reservation on reservation._seat_number = seat.nr |
30 |
where id is null |
where id is null |
31 |
group by seat.nr |
group by seat.nr |
34 |
) |
) |
35 |
where |
where |
36 |
md5(id||email) = ? |
md5(id||email) = ? |
37 |
and _confirmed is false |
and _canceled is false |
38 |
|
and ( |
39 |
|
_confirmed is false |
40 |
|
or |
41 |
|
( _confirmed is true and _seat_number is null ) |
42 |
|
) |
43 |
}); |
}); |
44 |
|
|
45 |
$sth->execute( $self->token ); |
my $token = $self->token; |
46 |
|
|
47 |
|
$sth->execute( $token ); |
48 |
|
|
49 |
if ( $sth->rows == 0 ) { |
if ( $sth->rows == 0 ) { |
50 |
warn "can't confirm ", $self->token, " check if it's allready confirmed"; |
warn "can't confirm ", $self->token, " check if it's allready confirmed"; |
55 |
md5(id||email) = ? |
md5(id||email) = ? |
56 |
and _confirmed is true |
and _confirmed is true |
57 |
}); |
}); |
58 |
$sth->execute( $self->token ); |
$sth->execute( $token ); |
59 |
} |
} |
60 |
|
|
61 |
if ( $sth->rows == 1 ) { |
if ( $sth->rows == 1 ) { |
62 |
|
|
63 |
$sth = $dbh->prepare(qq{ |
die qq|<error>can't find account associated with $token</error>| unless $sth->rows == 1; |
|
select |
|
|
ime||' '||prezime, |
|
|
_seat_number, |
|
|
email |
|
|
from reservation |
|
|
where |
|
|
_confirmed is true |
|
|
-- and _seat_number is not null |
|
|
and md5(id||email) = ? |
|
|
}); |
|
|
|
|
|
$sth->execute( $self->token ); |
|
64 |
|
|
65 |
die "can't find account associated with ", $self->token unless $sth->rows == 1; |
return $self->seat_confirmation_message( token => $token ); |
|
|
|
|
my @reservation = $sth->fetchrow_array; |
|
|
push @reservation, |
|
|
$self->url_for( 'Confirmation/cancel_as_markup?token=' . $self->token ); |
|
|
|
|
|
return $self->seat_confirmation_message( @reservation ); |
|
66 |
|
|
67 |
} else { |
} else { |
68 |
die "Problem with confirmation.\n"; |
die qq|<error>Can't find confirmation $token<br> |
69 |
|
Did you copy-pasted whole URL in your browser?</error>|; |
70 |
} |
} |
71 |
} |
} |
72 |
|
|
78 |
my $sth = $dbh->prepare(qq{ |
my $sth = $dbh->prepare(qq{ |
79 |
update reservation |
update reservation |
80 |
set |
set |
81 |
_confirmed = false, |
_canceled = true, |
82 |
_seat_number = null |
_seat_number = null |
83 |
where |
where |
84 |
md5(id||email) = ? |
md5(id||email) = ? |
88 |
|
|
89 |
if ( $sth->rows == 1 ) { |
if ( $sth->rows == 1 ) { |
90 |
qq| |
qq| |
91 |
Your <em>reservation is canceled</em>, thanks for your effort to provide seat to somebody else |
Vaš <em>dolazak je odjavljen</em>. |
92 |
|
|
93 |
|
Hvala što ste omogućili dolazak nekom drugom! |
94 |
|; |
|; |
95 |
} else { |
} else { |
96 |
die "Problem with cancelation.\n"; |
die qq|<error>Can't find reservation which you are trying to cancel.<br> |
97 |
|
Did you copy-pasted whole URL in your browser?</error>|; |
98 |
} |
} |
99 |
} |
} |
100 |
|
|