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

(-)a/Koha/Libraries.pm (-11 / +19 lines)
Lines 67-83 sub pickup_locations { Link Here
67
67
68
    my $item = $params->{'item'};
68
    my $item = $params->{'item'};
69
    my $biblio = $params->{'biblio'};
69
    my $biblio = $params->{'biblio'};
70
    my $patron = $params->{'patron'};
71
72
    if ($biblio && $item) {
70
    if ($biblio && $item) {
73
        Koha::Exceptions::BadParameter->throw(
71
        Koha::Exceptions::BadParameter->throw(
74
            error => "Koha::Libraries->pickup_locations takes either 'biblio' or "
72
            error => "Koha::Libraries->pickup_locations takes either 'biblio' or "
75
            ." 'item' as parameter, but not both."
73
            ." 'item' as parameter, but not both."
76
        );
74
        );
77
    }
75
    }
78
    unless (! defined $patron || ref($patron) eq 'Koha::Patron') {
79
        $patron = Koha::Patrons->find($patron);
80
    }
81
76
82
    # Select libraries that are configured as pickup locations
77
    # Select libraries that are configured as pickup locations
83
    my $libraries = $self->search({
78
    my $libraries = $self->search({
Lines 86-105 sub pickup_locations { Link Here
86
        order_by => ['branchname']
81
        order_by => ['branchname']
87
    });
82
    });
88
83
89
    return $libraries unless $item or $biblio;
84
    return $libraries->unblessed unless $item or $biblio;
90
    if($item) {
85
    return $libraries->unblessed
86
        unless C4::Context->preference('UseBranchTransferLimits');
87
    my $limittype = C4::Context->preference('BranchTransferLimitsType');
88
89
    if ($item) {
91
        unless (ref($item) eq 'Koha::Item') {
90
        unless (ref($item) eq 'Koha::Item') {
92
            $item = Koha::Items->find($item);
91
            $item = Koha::Items->find($item);
93
            return $libraries unless $item;
92
            return $libraries->unblessed unless $item;
94
        }
93
        }
95
        return $item->pickup_locations( {patron => $patron} );
96
    } else {
94
    } else {
97
        unless (ref($biblio) eq 'Koha::Biblio') {
95
        unless (ref($biblio) eq 'Koha::Biblio') {
98
            $biblio = Koha::Biblios->find($biblio);
96
            $biblio = Koha::Biblios->find($biblio);
99
            return $libraries unless $biblio;
97
            return $libraries->unblessed unless $biblio;
100
        }
98
        }
101
        return $biblio->pickup_locations( {patron => $patron} );
102
    }
99
    }
100
101
    my @pickup_locations;
102
    foreach my $library ($libraries->as_list) {
103
        if ($item && $item->can_be_transferred({ to => $library })) {
104
            push @pickup_locations, $library->unblessed;
105
        } elsif ($biblio && $biblio->can_be_transferred({ to => $library })) {
106
            push @pickup_locations, $library->unblessed;
107
        }
108
    }
109
110
    return wantarray ? @pickup_locations : \@pickup_locations;
103
}
111
}
104
112
105
=head3 search_filtered
113
=head3 search_filtered
(-)a/Koha/Template/Plugin/Branches.pm (-5 / +24 lines)
Lines 87-99 sub InIndependentBranchesMode { Link Here
87
87
88
sub pickup_locations {
88
sub pickup_locations {
89
    my ( $self, $params ) = @_;
89
    my ( $self, $params ) = @_;
90
91
    my $search_params = $params->{search_params} || {};
90
    my $search_params = $params->{search_params} || {};
92
    my $selected      = $params->{selected};
91
    my $selected      = $params->{selected};
93
    my $libraries     = Koha::Libraries->pickup_locations($search_params);
92
    my @libraries;
93
94
    if(defined $search_params->{item} || defined $search_params->{biblio}) {
95
        my $item = $search_params->{'item'};
96
        my $biblio = $search_params->{'biblio'};
97
        my $patron = $search_params->{'patron'};
98
99
        unless (! defined $patron || ref($patron) eq 'Koha::Patron') {
100
            $patron = Koha::Patrons->find($patron);
101
        }
102
103
        if($item) {
104
            $item = Koha::Items->find($item) unless ref($item) eq 'Koha::Item';
105
            @libraries = map { $_->unblessed } $item->pickup_locations( {patron => $patron} ) if defined $item;
106
        } elsif($biblio) {
107
            $biblio = Koha::Biblios->find($biblio) unless ref($biblio) eq 'Koha::Biblio';
108
            @libraries = map { $_->unblessed } $biblio->pickup_locations( {patron => $patron} ) if defined $biblio;
109
        }
110
111
    }
94
112
95
    for my $l (@$libraries) {
113
    @libraries = Koha::Libraries->pickup_locations() unless @libraries;
96
        $l = $l->unblessed;
114
115
    for my $l (@libraries) {
97
        if ( defined $selected and $l->{branchcode} eq $selected
116
        if ( defined $selected and $l->{branchcode} eq $selected
98
            or not defined $selected
117
            or not defined $selected
99
            and C4::Context->userenv
118
            and C4::Context->userenv
Lines 103-109 sub pickup_locations { Link Here
103
        }
122
        }
104
    }
123
    }
105
124
106
    return $libraries;
125
    return \@libraries;
107
}
126
}
108
127
109
1;
128
1;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc (-2 / +1 lines)
Lines 131-137 Link Here
131
                        [% Branches.GetName(hold.branchcode) | html %] <input type="hidden" name="pickup" value="[% hold.branchcode | html %]" />
131
                        [% Branches.GetName(hold.branchcode) | html %] <input type="hidden" name="pickup" value="[% hold.branchcode | html %]" />
132
                    [% ELSE %]
132
                    [% ELSE %]
133
                        <select name="pickup">
133
                        <select name="pickup">
134
                            [% PROCESS options_for_libraries libraries => Branches.pickup_locations( { search_params => { item => hold.itemnumber, patron => hold.patron }, selected => hold.branchcode }) %]
134
                            [% PROCESS options_for_libraries libraries => Branches.pickup_locations( { search_params => { item => hold.itemnumber, biblio => hold.biblionumber, patron => hold.patron }, selected => hold.branchcode }) %]
135
                        </select>
135
                        </select>
136
                    [% END %]
136
                    [% END %]
137
                [% END %]
137
                [% END %]
138
- 

Return to bug 24350