Lines 100-105
sub get {
Link Here
|
100 |
}; |
100 |
}; |
101 |
} |
101 |
} |
102 |
|
102 |
|
|
|
103 |
=head3 _check_availability |
104 |
|
105 |
Internal function to call CanBookBeIssued and return an appropriately filtered |
106 |
set return |
107 |
|
108 |
=cut |
109 |
|
110 |
sub _check_availability { |
111 |
my ( $c, $patron, $item ) = @_; |
112 |
|
113 |
my $inprocess = 0; # What does this do? |
114 |
my $ignore_reserves = 0; # Don't ignore reserves |
115 |
my $params = { item => $item }; |
116 |
|
117 |
my ( $impossible, $confirmation, $alerts, $messages ) = |
118 |
C4::Circulation::CanBookBeIssued( $patron, undef, undef, $inprocess, |
119 |
$ignore_reserves, $params ); |
120 |
|
121 |
if ( $c->stash('is_public') ) { |
122 |
|
123 |
# Upgrade some confirmations to blockers |
124 |
my @should_block = |
125 |
qw/TOO_MANY ISSUED_TO_ANOTHER RESERVED RESERVED_WAITING TRANSFERRED PROCESSING AGE_RESTRICTION/; |
126 |
for my $block (@should_block) { |
127 |
if ( exists( $confirmation->{$block} ) ) { |
128 |
$impossible->{$block} = $confirmation->{$block}; |
129 |
delete $confirmation->{$block}; |
130 |
} |
131 |
} |
132 |
|
133 |
# Remove any non-public info that's returned by CanBookBeIssued |
134 |
my @restricted_keys = |
135 |
qw/issued_borrowernumber issued_cardnumber issued_firstname issued_surname resborrowernumber resbranchcode rescardnumber reserve_id resfirstname resreservedate ressurname item_notforloan/; |
136 |
for my $key (@restricted_keys) { |
137 |
delete $confirmation->{$key}; |
138 |
delete $impossible->{$key}; |
139 |
delete $alerts->{$key}; |
140 |
delete $messages->{$key}; |
141 |
} |
142 |
} |
143 |
|
144 |
return ( $impossible, $confirmation, { %{$alerts}, %{$messages} } ); |
145 |
} |
146 |
|
103 |
=head3 get_availability |
147 |
=head3 get_availability |
104 |
|
148 |
|
105 |
Controller function that handles retrieval of Checkout availability |
149 |
Controller function that handles retrieval of Checkout availability |
Lines 111-126
sub get_availability {
Link Here
|
111 |
my $user = $c->stash('koha.user'); |
155 |
my $user = $c->stash('koha.user'); |
112 |
|
156 |
|
113 |
my $patron = Koha::Patrons->find( $c->param('patron_id') ); |
157 |
my $patron = Koha::Patrons->find( $c->param('patron_id') ); |
114 |
my $inprocess = 0; # What does this do? |
|
|
115 |
my $ignore_reserves = 0; # Don't ignore reserves |
116 |
my $item = Koha::Items->find( $c->param('item_id') ); |
158 |
my $item = Koha::Items->find( $c->param('item_id') ); |
117 |
my $params = { |
|
|
118 |
item => $item |
119 |
}; |
120 |
|
159 |
|
121 |
my ( $impossible, $confirmation, $alerts, $messages ) = |
160 |
my ( $impossible, $confirmation, $warnings ) = |
122 |
C4::Circulation::CanBookBeIssued( $patron, undef, undef, $inprocess, $ignore_reserves, |
161 |
$c->_check_availability( $patron, $item ); |
123 |
$params ); |
|
|
124 |
|
162 |
|
125 |
my $confirm_keys = join( ":", sort keys %{$confirmation} ); |
163 |
my $confirm_keys = join( ":", sort keys %{$confirmation} ); |
126 |
$confirm_keys = $user->id . ":" . $item->id . ":" . $confirm_keys; |
164 |
$confirm_keys = $user->id . ":" . $item->id . ":" . $confirm_keys; |
Lines 129-135
sub get_availability {
Link Here
|
129 |
my $response = { |
167 |
my $response = { |
130 |
blockers => $impossible, |
168 |
blockers => $impossible, |
131 |
confirms => $confirmation, |
169 |
confirms => $confirmation, |
132 |
warnings => { %{$alerts}, %{$messages} }, |
170 |
warnings => $warnings, |
133 |
confirmation_token => $token |
171 |
confirmation_token => $token |
134 |
}; |
172 |
}; |
135 |
|
173 |
|
Lines 174-193
sub add {
Link Here
|
174 |
); |
212 |
); |
175 |
} |
213 |
} |
176 |
|
214 |
|
177 |
my $inprocess = 0; # What does this do? |
215 |
my ( $impossible, $confirmation, $warnings ) = |
178 |
my $ignore_reserves = 0; # Don't ignore reserves |
216 |
$c->_check_availability( $patron, $item ); |
179 |
my $params = { item => $item }; |
|
|
180 |
|
181 |
# Call 'CanBookBeIssued' |
182 |
my ( $impossible, $confirmation, $alerts, $messages ) = |
183 |
C4::Circulation::CanBookBeIssued( |
184 |
$patron, |
185 |
undef, |
186 |
undef, |
187 |
$inprocess, |
188 |
$ignore_reserves, |
189 |
$params |
190 |
); |
191 |
|
217 |
|
192 |
# * Fail for blockers - render 403 |
218 |
# * Fail for blockers - render 403 |
193 |
if ( keys %{$impossible} ) { |
219 |
if ( keys %{$impossible} ) { |