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 my $patron = Koha::Patrons->find( $self->{patron}->borrowernumber );
42 $self->screen_msg('do_hold called with undefined patron');
46 my $item = Koha::Items->find({ barcode => $self->{item}->id });
48 $self->screen_msg( 'No biblio record matches barcode "' . $self->{item}->id . '".' );
52 my $branch = ( $self->pickup_location || $self->{patron}->{branchcode} );
54 $self->screen_msg('No branch specified (or found w/ patron).');
58 unless ( $item->can_be_transferred( { to => Koha::Libraries->find( $branch ) } ) ) {
59 $self->screen_msg('Item cannot be transferred.');
64 my $priority = C4::Reserves::CalculatePriority($item->biblionumber);
67 priority => $priority,
68 branchcode => $branch,
69 borrowernumber => $patron->borrowernumber,
70 biblionumber => $item->biblionumber
74 # unfortunately no meaningful return value
81 my $patron = Koha::Patrons->find( $self->{patron}->borrowernumber );
83 $self->screen_msg('drop_hold called with undefined patron');
88 my $item = Koha::Items->find({ barcode => $self->{item}->id });
89 my $holds = $item->holds->search({ borrowernumber => $patron->borrowernumber });
91 return $self unless $holds->count;
101 my $patron = Koha::Patrons->find( $self->{patron}->borrowernumber );
103 $self->screen_msg('change_hold called with undefined patron');
107 my $item = Koha::Items->find({ barcode => $self->{item}->id });
109 $self->screen_msg('No biblio record matches barcode "' . $self->{item}->id . '".');
113 my $branch = ($self->pickup_location || $self->{patron}->branchcode);
115 $self->screen_msg('No branch specified (or found w/ patron).');
119 ModReserve({ biblionumber => $item->biblionumber, borrowernumber => $patron->borrowernumber, branchcode => $branch });