View | Details | Raw Unified | Return to bug 14783
Collapse All | Expand All

(-)a/Koha/Hold.pm (-4 / +4 lines)
Lines 906-920 sub to_api_mapping { Link Here
906
    };
906
    };
907
}
907
}
908
908
909
=head3 can_change_branch_opac
909
=head3 can_update_pickup_location_opac
910
910
911
returns if a hold can change pickup location from opac
911
    my $can_update_pickup_location_opac = $hold->can_update_pickup_location_opac;
912
912
913
my $can_change_branch_opac = $hold->can_change_branch_opac;
913
Returns if a hold can change pickup location from opac
914
914
915
=cut
915
=cut
916
916
917
sub can_change_branch_opac {
917
sub can_update_pickup_location_opac {
918
    my ($self) = @_;
918
    my ($self) = @_;
919
919
920
    my @statuses = split /,/, C4::Context->preference("OPACAllowUserToChangeBranch");
920
    my @statuses = split /,/, C4::Context->preference("OPACAllowUserToChangeBranch");
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc (-1 / +1 lines)
Lines 83-89 Link Here
83
                            <td class="branch">
83
                            <td class="branch">
84
                                <span class="tdlabel">Pickup location:</span>
84
                                <span class="tdlabel">Pickup location:</span>
85
                                [% HOLD.branch.branchname | html %]
85
                                [% HOLD.branch.branchname | html %]
86
                                [% IF ( HOLD.can_change_branch_opac ) %]
86
                                [% IF ( HOLD.can_update_pickup_location_opac ) %]
87
                                    <button type="button" class="btn btn-sm btn-link" data-toggle="modal" data-target="#changePickup[% HOLD.reserve_id | html %]">
87
                                    <button type="button" class="btn btn-sm btn-link" data-toggle="modal" data-target="#changePickup[% HOLD.reserve_id | html %]">
88
                                        <i class="fa fa-pencil" aria-hidden="true"></i> Change
88
                                        <i class="fa fa-pencil" aria-hidden="true"></i> Change
89
                                    </button>
89
                                    </button>
(-)a/opac/opac-modrequest.pl (-1 / +1 lines)
Lines 60-66 if ( $reserve_id && $borrowernumber ) { Link Here
60
    }
60
    }
61
    elsif ( $new_pickup_location ) {
61
    elsif ( $new_pickup_location ) {
62
62
63
        if ($hold->can_change_branch_opac){
63
        if ($hold->can_update_pickup_location_opac) {
64
            $hold->set_pickup_location({ library_id => $new_pickup_location });
64
            $hold->set_pickup_location({ library_id => $new_pickup_location });
65
        }
65
        }
66
        else {
66
        else {
(-)a/t/db_dependent/Hold.t (-51 / +1 lines)
Lines 29-35 use Koha::Item; Link Here
29
use Koha::DateUtils qw( dt_from_string );
29
use Koha::DateUtils qw( dt_from_string );
30
use t::lib::TestBuilder;
30
use t::lib::TestBuilder;
31
31
32
use Test::More tests => 36;
32
use Test::More tests => 35;
33
use Test::Exception;
33
use Test::Exception;
34
use Test::Warn;
34
use Test::Warn;
35
35
Lines 386-438 subtest 'suspend() tests' => sub { Link Here
386
386
387
    $schema->storage->txn_rollback;
387
    $schema->storage->txn_rollback;
388
};
388
};
389
390
subtest 'can_change_branch_opac() tests' => sub {
391
392
    plan tests => 8;
393
394
    $schema->storage->txn_begin;
395
396
    my $hold = $builder->build_object(
397
        {   class => 'Koha::Holds',
398
            value => { found => undef, suspend => 0, suspend_until => undef, waitingdate => undef }
399
        }
400
    );
401
402
    t::lib::Mocks::mock_preference( 'OPACAllowUserToChangeBranch', '' );
403
    $hold->found(undef);
404
    is( $hold->can_change_branch_opac, 0, "Pending hold pickup can't be changed (No change allowed)" );
405
406
    $hold->found('T');
407
    is( $hold->can_change_branch_opac, 0, "In transit hold pickup can't be changed (No change allowed)" );
408
409
    $hold->found('W');
410
    is( $hold->can_change_branch_opac, 0, "Waiting hold pickup can't be changed (No change allowed)" );
411
412
    $hold->found(undef);
413
    $dt = dt_from_string();
414
415
    $hold->suspend_hold( $dt );
416
    is( $hold->can_change_branch_opac, 0, "Suspended hold pickup can't be changed (No change allowed)" );
417
    $hold->resume();
418
419
    t::lib::Mocks::mock_preference( 'OPACAllowUserToChangeBranch', 'pending,intransit,suspended' );
420
    $hold->found(undef);
421
    is( $hold->can_change_branch_opac, 1, "Pending hold pickup can be changed (pending,intransit,suspended allowed)" );
422
423
    $hold->found('T');
424
    is( $hold->can_change_branch_opac, 1, "In transit hold pickup can be changed (pending,intransit,suspended allowed)" );
425
426
    $hold->found('W');
427
    is( $hold->can_change_branch_opac, 0, "Waiting hold pickup can't be changed (pending,intransit,suspended allowed)" );
428
429
    $hold->found(undef);
430
    $dt = dt_from_string();
431
    $hold->suspend_hold( $dt );
432
    is( $hold->can_change_branch_opac, 1, "Suspended hold pickup can be changed (pending,intransit,suspended allowed)" );
433
    $hold->resume();
434
435
436
    $schema->storage->txn_rollback;
437
438
};
(-)a/t/db_dependent/Koha/Hold.t (-2 / +49 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 9;
22
use Test::More tests => 10;
23
23
24
use Test::Exception;
24
use Test::Exception;
25
use Test::MockModule;
25
use Test::MockModule;
Lines 29-34 use t::lib::TestBuilder; Link Here
29
use t::lib::Mocks;
29
use t::lib::Mocks;
30
30
31
use Koha::ActionLogs;
31
use Koha::ActionLogs;
32
use Koha::DateUtils qw(dt_from_string);
32
use Koha::Holds;
33
use Koha::Holds;
33
use Koha::Libraries;
34
use Koha::Libraries;
34
use Koha::Old::Holds;
35
use Koha::Old::Holds;
Lines 863-865 subtest 'cancellation_requestable_from_opac() tests' => sub { Link Here
863
864
864
    $schema->storage->txn_rollback;
865
    $schema->storage->txn_rollback;
865
};
866
};
866
- 
867
868
subtest 'can_update_pickup_location_opac() tests' => sub {
869
870
    plan tests => 8;
871
872
    $schema->storage->txn_begin;
873
874
    my $hold = $builder->build_object(
875
        {   class => 'Koha::Holds',
876
            value => { found => undef, suspend => 0, suspend_until => undef, waitingdate => undef }
877
        }
878
    );
879
880
    t::lib::Mocks::mock_preference( 'OPACAllowUserToChangeBranch', '' );
881
    $hold->found(undef);
882
    is( $hold->can_update_pickup_location_opac, 0, "Pending hold pickup can't be changed (No change allowed)" );
883
884
    $hold->found('T');
885
    is( $hold->can_update_pickup_location_opac, 0, "In transit hold pickup can't be changed (No change allowed)" );
886
887
    $hold->found('W');
888
    is( $hold->can_update_pickup_location_opac, 0, "Waiting hold pickup can't be changed (No change allowed)" );
889
890
    $hold->found(undef);
891
    my $dt = dt_from_string();
892
893
    $hold->suspend_hold( $dt );
894
    is( $hold->can_update_pickup_location_opac, 0, "Suspended hold pickup can't be changed (No change allowed)" );
895
    $hold->resume();
896
897
    t::lib::Mocks::mock_preference( 'OPACAllowUserToChangeBranch', 'pending,intransit,suspended' );
898
    $hold->found(undef);
899
    is( $hold->can_update_pickup_location_opac, 1, "Pending hold pickup can be changed (pending,intransit,suspended allowed)" );
900
901
    $hold->found('T');
902
    is( $hold->can_update_pickup_location_opac, 1, "In transit hold pickup can be changed (pending,intransit,suspended allowed)" );
903
904
    $hold->found('W');
905
    is( $hold->can_update_pickup_location_opac, 0, "Waiting hold pickup can't be changed (pending,intransit,suspended allowed)" );
906
907
    $hold->found(undef);
908
    $dt = dt_from_string();
909
    $hold->suspend_hold( $dt );
910
    is( $hold->can_update_pickup_location_opac, 1, "Suspended hold pickup can be changed (pending,intransit,suspended allowed)" );
911
912
    $schema->storage->txn_rollback;
913
};

Return to bug 14783