};
}
-=head3 can_change_branch_opac
+=head3 can_update_pickup_location_opac
-returns if a hold can change pickup location from opac
+ my $can_update_pickup_location_opac = $hold->can_update_pickup_location_opac;
-my $can_change_branch_opac = $hold->can_change_branch_opac;
+Returns if a hold can change pickup location from opac
=cut
-sub can_change_branch_opac {
+sub can_update_pickup_location_opac {
my ($self) = @_;
my @statuses = split /,/, C4::Context->preference("OPACAllowUserToChangeBranch");
<td class="branch">
<span class="tdlabel">Pickup location:</span>
[% HOLD.branch.branchname | html %]
- [% IF ( HOLD.can_change_branch_opac ) %]
+ [% IF ( HOLD.can_update_pickup_location_opac ) %]
<button type="button" class="btn btn-sm btn-link" data-toggle="modal" data-target="#changePickup[% HOLD.reserve_id | html %]">
<i class="fa fa-pencil" aria-hidden="true"></i> Change
</button>
}
elsif ( $new_pickup_location ) {
- if ($hold->can_change_branch_opac){
+ if ($hold->can_update_pickup_location_opac) {
$hold->set_pickup_location({ library_id => $new_pickup_location });
}
else {
use Koha::DateUtils qw( dt_from_string );
use t::lib::TestBuilder;
-use Test::More tests => 36;
+use Test::More tests => 35;
use Test::Exception;
use Test::Warn;
$schema->storage->txn_rollback;
};
-
-subtest 'can_change_branch_opac() tests' => sub {
-
- plan tests => 8;
-
- $schema->storage->txn_begin;
-
- my $hold = $builder->build_object(
- { class => 'Koha::Holds',
- value => { found => undef, suspend => 0, suspend_until => undef, waitingdate => undef }
- }
- );
-
- t::lib::Mocks::mock_preference( 'OPACAllowUserToChangeBranch', '' );
- $hold->found(undef);
- is( $hold->can_change_branch_opac, 0, "Pending hold pickup can't be changed (No change allowed)" );
-
- $hold->found('T');
- is( $hold->can_change_branch_opac, 0, "In transit hold pickup can't be changed (No change allowed)" );
-
- $hold->found('W');
- is( $hold->can_change_branch_opac, 0, "Waiting hold pickup can't be changed (No change allowed)" );
-
- $hold->found(undef);
- $dt = dt_from_string();
-
- $hold->suspend_hold( $dt );
- is( $hold->can_change_branch_opac, 0, "Suspended hold pickup can't be changed (No change allowed)" );
- $hold->resume();
-
- t::lib::Mocks::mock_preference( 'OPACAllowUserToChangeBranch', 'pending,intransit,suspended' );
- $hold->found(undef);
- is( $hold->can_change_branch_opac, 1, "Pending hold pickup can be changed (pending,intransit,suspended allowed)" );
-
- $hold->found('T');
- is( $hold->can_change_branch_opac, 1, "In transit hold pickup can be changed (pending,intransit,suspended allowed)" );
-
- $hold->found('W');
- is( $hold->can_change_branch_opac, 0, "Waiting hold pickup can't be changed (pending,intransit,suspended allowed)" );
-
- $hold->found(undef);
- $dt = dt_from_string();
- $hold->suspend_hold( $dt );
- is( $hold->can_change_branch_opac, 1, "Suspended hold pickup can be changed (pending,intransit,suspended allowed)" );
- $hold->resume();
-
-
- $schema->storage->txn_rollback;
-
-};
use Modern::Perl;
-use Test::More tests => 9;
+use Test::More tests => 10;
use Test::Exception;
use Test::MockModule;
use t::lib::Mocks;
use Koha::ActionLogs;
+use Koha::DateUtils qw(dt_from_string);
use Koha::Holds;
use Koha::Libraries;
use Koha::Old::Holds;
$schema->storage->txn_rollback;
};
+
+subtest 'can_update_pickup_location_opac() tests' => sub {
+
+ plan tests => 8;
+
+ $schema->storage->txn_begin;
+
+ my $hold = $builder->build_object(
+ { class => 'Koha::Holds',
+ value => { found => undef, suspend => 0, suspend_until => undef, waitingdate => undef }
+ }
+ );
+
+ t::lib::Mocks::mock_preference( 'OPACAllowUserToChangeBranch', '' );
+ $hold->found(undef);
+ is( $hold->can_update_pickup_location_opac, 0, "Pending hold pickup can't be changed (No change allowed)" );
+
+ $hold->found('T');
+ is( $hold->can_update_pickup_location_opac, 0, "In transit hold pickup can't be changed (No change allowed)" );
+
+ $hold->found('W');
+ is( $hold->can_update_pickup_location_opac, 0, "Waiting hold pickup can't be changed (No change allowed)" );
+
+ $hold->found(undef);
+ my $dt = dt_from_string();
+
+ $hold->suspend_hold( $dt );
+ is( $hold->can_update_pickup_location_opac, 0, "Suspended hold pickup can't be changed (No change allowed)" );
+ $hold->resume();
+
+ t::lib::Mocks::mock_preference( 'OPACAllowUserToChangeBranch', 'pending,intransit,suspended' );
+ $hold->found(undef);
+ is( $hold->can_update_pickup_location_opac, 1, "Pending hold pickup can be changed (pending,intransit,suspended allowed)" );
+
+ $hold->found('T');
+ is( $hold->can_update_pickup_location_opac, 1, "In transit hold pickup can be changed (pending,intransit,suspended allowed)" );
+
+ $hold->found('W');
+ is( $hold->can_update_pickup_location_opac, 0, "Waiting hold pickup can't be changed (pending,intransit,suspended allowed)" );
+
+ $hold->found(undef);
+ $dt = dt_from_string();
+ $hold->suspend_hold( $dt );
+ is( $hold->can_update_pickup_location_opac, 1, "Suspended hold pickup can be changed (pending,intransit,suspended allowed)" );
+
+ $schema->storage->txn_rollback;
+};