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 AddReserve( $branch, $patron->borrowernumber, $item->biblionumber );
65 # unfortunately no meaningful return value
72 unless ($self->{patron}) {
73 $self->screen_msg('drop_hold called with undefined patron');
77 my $patron = Koha::Patrons->find( { cardnumber => $self->{patron}->id } );
79 $self->screen_msg('No borrower matches cardnumber "' . $self->{patron}->id . '".');
83 my $item = Koha::Items->find({ barcode => $self->{item}->id });
85 my $holds = Koha::Holds->search(
87 biblionumber => $item->biblionumber,
88 itemnumber => $self->{item}->id,
89 borrowernumber => $patron->borrowernumber
92 return $self unless $holds->count;
102 unless ($self->{patron}) {
103 $self->screen_msg('change_hold called with undefined patron');
107 my $patron = Koha::Patrons->find( { cardnumber => $self->{patron}->id } );
109 $self->screen_msg('No borrower matches cardnumber "' . $self->{patron}->id . '".');
113 my $item = Koha::Items->find({ barcode => $self->{item}->id });
115 $self->screen_msg('No biblio record matches barcode "' . $self->{item}->id . '".');
119 my $branch = ($self->pickup_location || $self->{patron}->branchcode);
121 $self->screen_msg('No branch specified (or found w/ patron).');
125 ModReserve({ biblionumber => $item->biblionumber, borrowernumber => $patron->borrowernumber, branchcode => $branch });