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

(-)a/Koha/Hold.pm (+20 lines)
Lines 606-611 sub to_api_mapping { Link Here
606
    };
606
    };
607
}
607
}
608
608
609
=head3 can_change_branch_opac
610
611
returns if a hold can change pickup location from opac
612
613
my $can_change_branch_opac = $hold->can_change_branch_opac;
614
615
=cut
616
617
sub can_change_branch_opac {
618
    my ($self) = @_;
619
620
    my @statuses = split /,/, C4::Context->preference("OPACAllowUserToChangeBranch");
621
    foreach my $status ( @statuses ){
622
        return 1 if ($status eq 'pending' && !$self->is_found && !$self->is_suspended );
623
        return 1 if ($status eq 'intransit' && $self->is_in_transit);
624
        return 1 if ($status eq 'suspended' && $self->is_suspended);
625
    }
626
    return 0;
627
}
628
609
=head2 Internal methods
629
=head2 Internal methods
610
630
611
=head3 _type
631
=head3 _type
(-)a/installer/data/mysql/atomicupdate/bug_14783-add_OpacAllowPickupLocationChange_syspref.perl (+8 lines)
Line 0 Link Here
1
2
3
$DBversion = 'XXX'; # will be replaced by the RM
4
if( CheckVersion( $DBversion ) ) {
5
    $dbh->do( "INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) VALUES ('OPACAllowUserToChangeBranch','','Pending, In-Transit, Suspended','Allow users to change the library to pick up a hold for these statuses:','multiple');" );
6
    # Always end with this (adjust the bug info)
7
    NewVersion( $DBversion, 14783, "Allow patrons to change pickup location for non-waiting holds");
8
}
(-)a/installer/data/mysql/mandatory/sysprefs.sql (+1 lines)
Lines 380-385 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
380
('OpacAllowPublicListCreation','1',NULL,'If set, allows opac users to create public lists','YesNo'),
380
('OpacAllowPublicListCreation','1',NULL,'If set, allows opac users to create public lists','YesNo'),
381
('OpacAllowSharingPrivateLists','0',NULL,'If set, allows opac users to share private lists with other patrons','YesNo'),
381
('OpacAllowSharingPrivateLists','0',NULL,'If set, allows opac users to share private lists with other patrons','YesNo'),
382
('OPACAllowUserToChooseBranch','1','1','Allow the user to choose the branch they want to pickup their hold from','YesNo'),
382
('OPACAllowUserToChooseBranch','1','1','Allow the user to choose the branch they want to pickup their hold from','YesNo'),
383
('OPACAllowUserToChangeBranch','','Pending, In-Transit, Suspended','Allow users to change the library to pick up a hold for these statuses:','multiple'),
383
('OPACAmazonCoverImages','0','','Display cover images on OPAC from Amazon Web Services','YesNo'),
384
('OPACAmazonCoverImages','0','','Display cover images on OPAC from Amazon Web Services','YesNo'),
384
('OpacAuthorities','1',NULL,'If ON, enables the search authorities link on OPAC','YesNo'),
385
('OpacAuthorities','1',NULL,'If ON, enables the search authorities link on OPAC','YesNo'),
385
('OPACBaseURL','',NULL,'Specify the Base URL of the OPAC, e.g., http://opac.mylibrary.com, including the protocol (http:// or https://). Otherwise, the http:// will be added automatically by Koha upon saving.','Free'),
386
('OPACBaseURL','',NULL,'Specify the Base URL of the OPAC, e.g., http://opac.mylibrary.com, including the protocol (http:// or https://). Otherwise, the http:// will be added automatically by Koha upon saving.','Free'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (+7 lines)
Lines 766-771 Circulation: Link Here
766
                  1: Allow
766
                  1: Allow
767
                  0: "Don't allow"
767
                  0: "Don't allow"
768
            - a user to choose the library to pick up a hold from.
768
            - a user to choose the library to pick up a hold from.
769
        -
770
            - 'Allow users to change the library to pick up a hold for these statuses:'
771
            - pref: OPACAllowUserToChangeBranch
772
              multiple:
773
                pending: Pending
774
                intransit: In transit
775
                suspended: Suspended
769
        -
776
        -
770
            - pref: ReservesNeedReturns
777
            - pref: ReservesNeedReturns
771
              choices:
778
              choices:
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc (-1 / +11 lines)
Lines 88-94 Link Here
88
                        [% UNLESS( singleBranchMode) %]
88
                        [% UNLESS( singleBranchMode) %]
89
                            <td class="branch">
89
                            <td class="branch">
90
                                <span class="tdlabel">Pick up location:</span>
90
                                <span class="tdlabel">Pick up location:</span>
91
                                [% HOLD.branch.branchname | html %]
91
                                [% IF ( HOLD.can_change_branch_opac ) %]
92
                                    <form class="change_branch" action="/cgi-bin/koha/opac-modrequest.pl" method="post">
93
	                                    <select name="new_branch" >
94
	                                        [% PROCESS options_for_libraries libraries = Branches.pickup_locations({ search_params => { biblio => HOLD.biblionumber, patron => HOLD.borrower }, selected => HOLD.branchcode }) %]
95
	                                    </select>
96
	                                    <input type="hidden" name="new_branch_reserveid" value="[% HOLD.reserve_id | html %]" />
97
	                                    <button class="btn btn-primary" type="submit" name="change_branch" value="1">Change</button>
98
                                    </form>
99
                                [% ELSE %]
100
                                    [% HOLD.branch.branchname | html %]
101
                                [% END  %]
92
                            </td>
102
                            </td>
93
                        [% END %]
103
                        [% END %]
94
                        [% IF ( showpriority ) %]
104
                        [% IF ( showpriority ) %]
(-)a/opac/opac-modrequest.pl (-1 / +11 lines)
Lines 49-52 if ($reserve_id && $borrowernumber) { Link Here
49
    }
49
    }
50
}
50
}
51
51
52
#Change pickup location for hold
53
my $change_branch = $query->param('change_branch');
54
if ($change_branch){
55
    my $new_branch_reserveid = $query->param('new_branch_reserveid');
56
    my $new_branch = $query->param('new_branch');
57
    my $hold = Koha::Holds->find( $new_branch_reserveid );
58
    if ($hold && $hold->can_change_branch_opac){
59
	    $hold->branchcode($new_branch)->store();
60
    }
61
}
62
52
print $query->redirect("/cgi-bin/koha/opac-user.pl#opac-user-holds");
63
print $query->redirect("/cgi-bin/koha/opac-user.pl#opac-user-holds");
53
- 

Return to bug 14783