}
# Remove the hold from the patron's record first
- foreach my $i (0 .. scalar @{$patron->{hold_items}}-1) {
- $hold = $patron->{hold_items}[$i];
-
- if ($hold->{item_id} eq $item_id) {
- # found it: now delete it
- splice @{$patron->{hold_items}}, $i, 1;
- $trans->ok(1);
- last;
- }
- }
+ $trans->ok($patron->drop_hold($item_id));
if (!$trans->ok) {
# We didn't find it on the patron record
return map $_->{item_id}, @{$self->{hold_items}}[$start-1 .. $end-1];
}
-sub hold_items_count {
- my $self = shift;
+#
+# remove the hold on item item_id from my hold queue.
+# return true if I was holding the item, false otherwise.
+#
+sub drop_hold {
+ my ($self, $item_id) = @_;
+ my $i;
+
+ for ($i = 0; $i < scalar @{$self->{hold_items}}; $i += 1) {
+ if ($self->{hold_items}[$i]->{item_id} eq $item_id) {
+ splice @{$self->{hold_items}}, $i, 1;
+ return 1;
+ }
+ }
- return scalar @{$self->{hold_items}};
+ return 0;
}
sub overdue_items {
$resp .= $lang . Sip::timestamp();
$resp .= add_count('patron_info/hold_items',
- $patron->hold_items_count);
+ scalar $patron->hold_items);
$resp .= add_count('patron_info/overdue_items',
$patron->overdue_items_count);
$resp .= add_count('patron_info/charged_items',