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', |
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 ); |
my $token = $self->token; |
40 |
|
|
41 |
if ( $sth->rows == 1 ) { |
$sth->execute( $token ); |
42 |
|
|
43 |
|
if ( $sth->rows == 0 ) { |
44 |
|
warn "can't confirm ", $self->token, " check if it's allready confirmed"; |
45 |
$sth = $dbh->prepare(qq{ |
$sth = $dbh->prepare(qq{ |
46 |
select ime||' '||prezime,_seat_number |
select 1 |
47 |
from reservation |
from reservation |
48 |
where md5(id||email) = ? and _confirmed is true and _seat_number is not null |
where |
49 |
|
md5(id||email) = ? |
50 |
|
and _confirmed is true |
51 |
}); |
}); |
52 |
|
$sth->execute( $token ); |
53 |
|
} |
54 |
|
|
55 |
$sth->execute( $self->token ); |
if ( $sth->rows == 1 ) { |
56 |
my ($name, $seat) = $sth->fetchrow_array; |
|
57 |
|
die qq|<error>can't find account associated with $token</error>| unless $sth->rows == 1; |
58 |
|
|
59 |
|
return $self->seat_confirmation_message( token => $token ); |
60 |
|
|
|
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. |
|
|
|; |
|
61 |
} else { |
} else { |
62 |
die "Problem with confirmation.\n"; |
die qq|<error>Can't find confirmation $token<br> |
63 |
|
Did you copy-pasted whole URL in your browser?</error>|; |
64 |
} |
} |
65 |
} |
} |
66 |
|
|
72 |
my $sth = $dbh->prepare(qq{ |
my $sth = $dbh->prepare(qq{ |
73 |
update reservation |
update reservation |
74 |
set |
set |
75 |
_confirmed = false, |
_canceled = true, |
76 |
_seat_number = null |
_seat_number = null |
77 |
where md5(id||email) = ? and _confirmed is true |
where |
78 |
|
md5(id||email) = ? |
79 |
|
-- and _confirmed is true |
80 |
}); |
}); |
81 |
$sth->execute( $self->token ); |
$sth->execute( $self->token ); |
82 |
|
|
83 |
if ( $sth->rows == 1 ) { |
if ( $sth->rows == 1 ) { |
84 |
qq|Your <em>reservation is canceled</em>, thanks for your effort to provide seat to somebody else|; |
qq| |
85 |
|
Your <em>reservation is canceled</em>, thanks for your effort to provide seat to somebody else |
86 |
|
|; |
87 |
} else { |
} else { |
88 |
die "Problem with cancelation.\n"; |
die qq|<error>Can't find reservation which you are trying to cancel.<br> |
89 |
|
Did you copy-pasted whole URL in your browser?</error>|; |
90 |
} |
} |
91 |
} |
} |
92 |
|
|
93 |
|
__PACKAGE__->meta->make_immutable; |
94 |
|
no Moose; |
95 |
|
|
96 |
1; |
1; |