2 # status of a Hold transaction
4 package C4
::SIP
::ILS
::Transaction
::Hold
;
8 use C4
::SIP
::ILS
::Transaction
;
10 use C4
::Reserves
; # AddReserve
13 use parent
qw(C4::SIP::ILS::Transaction);
19 pickup_location
=> undef,
20 constraint_type
=> undef,
25 my $self = $class->SUPER::new
();
26 foreach my $element (keys %fields) {
27 $self->{_permitted
}->{$element} = $fields{$element};
29 @
{$self}{keys %fields} = values %fields;
30 return bless $self, $class;
35 return $self->item->hold_queue_position($self->patron->id);
40 unless ( $self->{patron
} ) {
41 $self->screen_msg('do_hold called with undefined patron');
45 my $patron = Koha
::Patrons
->find( { cardnumber
=> $self->{patron
}->id } );
47 $self->screen_msg( 'No borrower matches cardnumber "' . $self->{patron
}->id . '".' );
51 my $item = Koha
::Items
->find({ barcode
=> $self->{item
}->id });
53 $self->screen_msg( 'No biblio record matches barcode "' . $self->{item
}->id . '".' );
57 my $branch = ( $self->pickup_location || $self->{patron
}->{branchcode
} );
59 $self->screen_msg('No branch specified (or found w/ patron).');
63 unless ( $item->can_be_transferred( { to
=> Koha
::Libraries
->find( $branch ) } ) ) {
64 $self->screen_msg('Item cannot be transferred.');
69 AddReserve
( $branch, $patron->borrowernumber, $item->biblionumber );
71 # unfortunately no meaningful return value
78 unless ($self->{patron
}) {
79 $self->screen_msg('drop_hold called with undefined patron');
83 my $patron = Koha
::Patrons
->find( { cardnumber
=> $self->{patron
}->id } );
85 $self->screen_msg('No borrower matches cardnumber "' . $self->{patron
}->id . '".');
90 my $item = Koha
::Items
->find({ barcode
=> $self->{item
}->id });
91 my $holds = $item->holds->search({ borrowernumber
=> $patron->borrowernumber });
93 return $self unless $holds->count;
103 unless ($self->{patron
}) {
104 $self->screen_msg('change_hold called with undefined patron');
108 my $patron = Koha
::Patrons
->find( { cardnumber
=> $self->{patron
}->id } );
110 $self->screen_msg('No borrower matches cardnumber "' . $self->{patron
}->id . '".');
114 my $item = Koha
::Items
->find({ barcode
=> $self->{item
}->id });
116 $self->screen_msg('No biblio record matches barcode "' . $self->{item
}->id . '".');
120 my $branch = ($self->pickup_location || $self->{patron
}->branchcode);
122 $self->screen_msg('No branch specified (or found w/ patron).');
126 ModReserve
({ biblionumber
=> $item->biblionumber, borrowernumber
=> $patron->borrowernumber, branchcode
=> $branch });