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