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

(-)a/C4/Circulation.pm (-6 / +30 lines)
Lines 1143-1149 Returns: Link Here
1143
1143
1144
=item C<$returnallowed> is 0 or 1, corresponding to whether the return is allowed (1) or not (0)
1144
=item C<$returnallowed> is 0 or 1, corresponding to whether the return is allowed (1) or not (0)
1145
1145
1146
=item C<$message> is the branchcode where the item SHOULD be returned, if the return is not allowed
1146
=item C<$message> is a HASHref of following possible keys:
1147
1148
C<toBranch> branchcode where the item SHOULD be returned, if the return is not allowed
1149
C<transferLimit> transfer limit exists, HASHref of following keys: C<from>, C<to>
1147
1150
1148
=back
1151
=back
1149
1152
Lines 1155-1172 sub CanBookBeReturned { Link Here
1155
1158
1156
    # assume return is allowed to start
1159
    # assume return is allowed to start
1157
    my $allowed = 1;
1160
    my $allowed = 1;
1161
    my $to_branch = $branch;
1158
    my $message;
1162
    my $message;
1159
1163
1160
    # identify all cases where return is forbidden
1164
    # identify all cases where return is forbidden
1161
    if ($allowreturntobranch eq 'homebranch' && $branch ne $item->homebranch) {
1165
    if ($allowreturntobranch eq 'homebranch' && $branch ne $item->homebranch) {
1162
        $allowed = 0;
1166
        $allowed = 0;
1163
        $message = $item->homebranch;
1167
        $message->{toBranch} = $to_branch = $item->homebranch;
1164
    } elsif ($allowreturntobranch eq 'holdingbranch' && $branch ne $item->holdingbranch) {
1168
    } elsif ($allowreturntobranch eq 'holdingbranch' && $branch ne $item->holdingbranch) {
1165
        $allowed = 0;
1169
        $allowed = 0;
1166
        $message = $item->holdingbranch;
1170
        $message->{toBranch} = $to_branch = $item->holdingbranch;
1167
    } elsif ($allowreturntobranch eq 'homeorholdingbranch' && $branch ne $item->homebranch && $branch ne $item->holdingbranch) {
1171
    } elsif ($allowreturntobranch eq 'homeorholdingbranch' && $branch ne $item->homebranch && $branch ne $item->holdingbranch) {
1168
        $allowed = 0;
1172
        $allowed = 0;
1169
        $message = $item->homebranch; # FIXME: choice of homebranch is arbitrary
1173
        $message->{toBranch} = $to_branch = $item->homebranch; # FIXME: choice of homebranch is arbitrary
1174
    }
1175
1176
    # Make sure there are no branch transfer limits between item's current
1177
    # branch (holdinbranch) and the return branch
1178
    my $to_library = Koha::Libraries->find($to_branch);
1179
    if (!$item->can_be_transferred({ to => $to_library })) {
1180
        $allowed = 0;
1181
        $message->{transferLimit} = {
1182
            from => $item->holdingbranch,
1183
            to   => $to_branch
1184
        };
1170
    }
1185
    }
1171
1186
1172
    return ($allowed, $message);
1187
    return ($allowed, $message);
Lines 1830-1835 This book has was returned to the wrong branch. The value is a hashref Link Here
1830
so that C<$messages->{Wrongbranch}->{Wrongbranch}> and C<$messages->{Wrongbranch}->{Rightbranch}>
1845
so that C<$messages->{Wrongbranch}->{Wrongbranch}> and C<$messages->{Wrongbranch}->{Rightbranch}>
1831
contain the branchcode of the incorrect and correct return library, respectively.
1846
contain the branchcode of the incorrect and correct return library, respectively.
1832
1847
1848
=item C<Transferlimit>
1849
1850
A transfer limit exists between item's holding branch and the return branch.
1851
1833
=item C<ResFound>
1852
=item C<ResFound>
1834
1853
1835
The item was reserved. The value is a reference-to-hash whose keys are
1854
The item was reserved. The value is a reference-to-hash whose keys are
Lines 1958-1965 sub AddReturn { Link Here
1958
    unless ($returnallowed){
1977
    unless ($returnallowed){
1959
        $messages->{'Wrongbranch'} = {
1978
        $messages->{'Wrongbranch'} = {
1960
            Wrongbranch => $branch,
1979
            Wrongbranch => $branch,
1961
            Rightbranch => $message
1980
            Rightbranch => $message->{toBranch}
1962
        };
1981
        } if $message->{toBranch};
1982
1983
        if ($message->{'transferLimit'}) {
1984
            $messages->{'Transferlimit'} = $message->{'transferLimit'};
1985
        }
1986
1963
        $doreturn = 0;
1987
        $doreturn = 0;
1964
        return ( $doreturn, $messages, $issue, $patron_unblessed);
1988
        return ( $doreturn, $messages, $issue, $patron_unblessed);
1965
    }
1989
    }
(-)a/C4/SIP/ILS/Transaction/Checkin.pm (+3 lines)
Lines 100-105 sub do_checkin { Link Here
100
        $self->{item}->destination_loc($messages->{Wrongbranch}->{Rightbranch});
100
        $self->{item}->destination_loc($messages->{Wrongbranch}->{Rightbranch});
101
        $self->alert_type('04');            # send to other branch
101
        $self->alert_type('04');            # send to other branch
102
    }
102
    }
103
    if ($messages->{Transferlimit}) {
104
        $self->alert_type('04');
105
    }
103
    if ($messages->{WrongTransfer}) {
106
    if ($messages->{WrongTransfer}) {
104
        $self->{item}->destination_loc($messages->{WrongTransfer});
107
        $self->{item}->destination_loc($messages->{WrongTransfer});
105
        $self->alert_type('04');            # send to other branch
108
        $self->alert_type('04');            # send to other branch
(-)a/circ/returns.pl (+3 lines)
Lines 511-516 foreach my $code ( keys %$messages ) { Link Here
511
    }
511
    }
512
    elsif ( $code eq 'Wrongbranch' ) {
512
    elsif ( $code eq 'Wrongbranch' ) {
513
    }
513
    }
514
    elsif ( $code eq 'Transferlimit' ) {
515
        $err{transferlimit} = $messages->{'Transferlimit'};
516
    }
514
    elsif ( $code eq 'Debarred' ) {
517
    elsif ( $code eq 'Debarred' ) {
515
        $err{debarred}            = $messages->{'Debarred'};
518
        $err{debarred}            = $messages->{'Debarred'};
516
        $err{debarcardnumber}     = $borrower->{cardnumber};
519
        $err{debarcardnumber}     = $borrower->{cardnumber};
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt (-1 / +3 lines)
Lines 272-277 Link Here
272
                                            [% END %]
272
                                            [% END %]
273
                                           <p class="problem">Item is withdrawn.</p>
273
                                           <p class="problem">Item is withdrawn.</p>
274
                                        [% END %]
274
                                        [% END %]
275
                                        [% IF ( errmsgloo.transferlimit ) %]
276
                                            <p class="problem">Transfer is forbidden between [% Branches.GetName( holdingbranch ) | html %] (item's current library) and [% LoginBranchname | html %].</p>
277
                                        [% END %]
275
                                        [% IF ( errmsgloo.debarred ) %]
278
                                        [% IF ( errmsgloo.debarred ) %]
276
                                            <p class="problem"><a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% errmsgloo.debarborrowernumber | uri %]">[% errmsgloo.debarname | html %]([% errmsgloo.debarcardnumber | html %])</a> is now debarred until [% errmsgloo.debarred | $KohaDates %].</p>
279
                                            <p class="problem"><a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% errmsgloo.debarborrowernumber | uri %]">[% errmsgloo.debarname | html %]([% errmsgloo.debarcardnumber | html %])</a> is now debarred until [% errmsgloo.debarred | $KohaDates %].</p>
277
                                        [% END %]
280
                                        [% END %]
278
- 

Return to bug 7376