=head3 suspend_hold
-my $hold = $hold->suspend_hold( $suspend_until_dt );
+my $hold = $hold->suspend_hold( $suspend_until );
=cut
sub suspend_hold {
- my ( $self, $dt ) = @_;
+ my ( $self, $date ) = @_;
- my $date = $dt ? $dt->clone()->truncate( to => 'day' )->datetime : undef;
+ $date &&= dt_from_string($date)->truncate( to => 'day' )->datetime;
if ( $self->is_found ) { # We can't suspend found holds
if ( $self->is_waiting ) {
$self->found('T');
$self->store();
+ Koha::Plugins->call(
+ 'after_hold_action',
+ {
+ action => 'transfer',
+ payload => { hold => $self->get_from_storage }
+ }
+ );
+
return $self;
}
$self->set($values)->store();
+ Koha::Plugins->call(
+ 'after_hold_action',
+ {
+ action => 'waiting',
+ payload => { hold => $self->get_from_storage }
+ }
+ );
+
return $self;
}
$self->found('P');
$self->store();
+ Koha::Plugins->call(
+ 'after_hold_action',
+ {
+ action => 'processing',
+ payload => { hold => $self->get_from_storage }
+ }
+ );
+
return $self;
}
return $self->{_item};
}
+=head3 item_group
+
+Returns the related Koha::Biblio::ItemGroup object for this Hold
+
+=cut
+
+sub item_group {
+ my ($self) = @_;
+
+ my $item_group_rs = $self->_result->item_group;
+ return unless $item_group_rs;
+ return Koha::Biblio::ItemGroup->_new_from_dbic($item_group_rs);
+}
+
=head3 branch
Returns the related Koha::Library object for this Hold
};
}
+=head3 can_update_pickup_location_opac
+
+ my $can_update_pickup_location_opac = $hold->can_update_pickup_location_opac;
+
+Returns if a hold can change pickup location from opac
+
+=cut
+
+sub can_update_pickup_location_opac {
+ my ($self) = @_;
+
+ my @statuses = split /,/, C4::Context->preference("OPACAllowUserToChangeBranch");
+ foreach my $status ( @statuses ){
+ return 1 if ($status eq 'pending' && !$self->is_found && !$self->is_suspended );
+ return 1 if ($status eq 'intransit' && $self->is_in_transit);
+ return 1 if ($status eq 'suspended' && $self->is_suspended);
+ }
+ return 0;
+}
+
=head2 Internal methods
=head3 _type