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

(-)a/C4/Circulation.pm (-15 / +20 lines)
Lines 1582-1587 holdallowed => Hold policy for this branch and itemtype. Possible values: Link Here
1582
returnbranch => branch to which to return item.  Possible values:
1582
returnbranch => branch to which to return item.  Possible values:
1583
  noreturn: do not return, let item remain where checked in (floating collections)
1583
  noreturn: do not return, let item remain where checked in (floating collections)
1584
  homebranch: return to item's home branch
1584
  homebranch: return to item's home branch
1585
  holdingbranch: return to issuer branch
1585
1586
1586
This searches branchitemrules in the following order:
1587
This searches branchitemrules in the following order:
1587
1588
Lines 1697-1702 fields from the reserves table of the Koha database, and Link Here
1697
C<biblioitemnumber>. It also has the key C<ResFound>, whose value is
1698
C<biblioitemnumber>. It also has the key C<ResFound>, whose value is
1698
either C<Waiting>, C<Reserved>, or 0.
1699
either C<Waiting>, C<Reserved>, or 0.
1699
1700
1701
=item C<WasReturned>
1702
1703
Value 1 if return is successful.
1704
1705
=item C<NeedsTransfer>
1706
1707
If AutomaticItemReturn is disabled, return branch is given as value of NeedsTransfer.
1708
1700
=back
1709
=back
1701
1710
1702
C<$iteminformation> is a reference-to-hash, giving information about the
1711
C<$iteminformation> is a reference-to-hash, giving information about the
Lines 1728-1734 sub AddReturn { Link Here
1728
        return (0, { BadBarcode => $barcode }); # no barcode means no item or borrower.  bail out.
1737
        return (0, { BadBarcode => $barcode }); # no barcode means no item or borrower.  bail out.
1729
    }
1738
    }
1730
    my $issue  = GetItemIssue($itemnumber);
1739
    my $issue  = GetItemIssue($itemnumber);
1731
#   warn Dumper($iteminformation);
1732
    if ($issue and $issue->{borrowernumber}) {
1740
    if ($issue and $issue->{borrowernumber}) {
1733
        $borrower = C4::Members::GetMemberDetails($issue->{borrowernumber})
1741
        $borrower = C4::Members::GetMemberDetails($issue->{borrowernumber})
1734
            or die "Data inconsistency: barcode $barcode (itemnumber:$itemnumber) claims to be issued to non-existant borrowernumber '$issue->{borrowernumber}'\n"
1742
            or die "Data inconsistency: barcode $barcode (itemnumber:$itemnumber) claims to be issued to non-existant borrowernumber '$issue->{borrowernumber}'\n"
Lines 1748-1765 sub AddReturn { Link Here
1748
    my $item = GetItem($itemnumber) or die "GetItem($itemnumber) failed";
1756
    my $item = GetItem($itemnumber) or die "GetItem($itemnumber) failed";
1749
        # full item data, but no borrowernumber or checkout info (no issue)
1757
        # full item data, but no borrowernumber or checkout info (no issue)
1750
        # we know GetItem should work because GetItemnumberFromBarcode worked
1758
        # we know GetItem should work because GetItemnumberFromBarcode worked
1751
    my $hbr      = GetBranchItemRule($item->{'homebranch'}, $item->{'itype'})->{'returnbranch'} || "homebranch";
1759
    my $hbr = GetBranchItemRule($item->{'homebranch'}, $item->{'itype'})->{'returnbranch'} || "homebranch";
1752
        # get the proper branch to which to return the item
1760
        # get the proper branch to which to return the item
1753
    $hbr = $item->{$hbr} || $branch ;
1761
    my $returnbranch = $item->{$hbr} || $branch ;
1754
        # if $hbr was "noreturn" or any other non-item table value, then it should 'float' (i.e. stay at this branch)
1762
        # if $hbr was "noreturn" or any other non-item table value, then it should 'float' (i.e. stay at this branch)
1755
1763
1756
    my $borrowernumber = $borrower->{'borrowernumber'} || undef;    # we don't know if we had a borrower or not
1764
    my $borrowernumber = $borrower->{'borrowernumber'} || undef;    # we don't know if we had a borrower or not
1757
1765
1758
    # check if the book is in a permanent collection....
1766
    # check if the book is in a permanent collection....
1759
    # FIXME -- This 'PE' attribute is largely undocumented.  afaict, there's no user interface that reflects this functionality.
1767
    # FIXME -- This 'PE' attribute is largely undocumented.  afaict, there's no user interface that reflects this functionality.
1760
    if ( $hbr ) {
1768
    if ( $returnbranch ) {
1761
        my $branches = GetBranches();    # a potentially expensive call for a non-feature.
1769
        my $branches = GetBranches();    # a potentially expensive call for a non-feature.
1762
        $branches->{$hbr}->{PE} and $messages->{'IsPermanent'} = $hbr;
1770
        $branches->{$returnbranch}->{PE} and $messages->{'IsPermanent'} = $returnbranch;
1763
    }
1771
    }
1764
1772
1765
    # check if the return is allowed at this branch
1773
    # check if the return is allowed at this branch
Lines 1931-1951 sub AddReturn { Link Here
1931
        DelUniqueDebarment({ borrowernumber => $borrowernumber, type => 'OVERDUES' });
1939
        DelUniqueDebarment({ borrowernumber => $borrowernumber, type => 'OVERDUES' });
1932
    }
1940
    }
1933
1941
1934
    # FIXME: make this comment intelligible.
1942
    # Transfer to returnbranch if Automatic transfer set or append message NeedsTransfer 
1935
    #adding message if holdingbranch is non equal a userenv branch to return the document to homebranch
1943
    if (($doreturn or $messages->{'NotIssued'}) and !$resfound and ($branch ne $returnbranch) and not $messages->{'WrongTransfer'}){
1936
    #we check, if we don't have reserv or transfert for this document, if not, return it to homebranch .
1944
        if  (C4::Context->preference("AutomaticItemReturn"    ) or
1937
1938
    if (($doreturn or $messages->{'NotIssued'}) and !$resfound and ($branch ne $hbr) and not $messages->{'WrongTransfer'}){
1939
        if ( C4::Context->preference("AutomaticItemReturn"    ) or
1940
            (C4::Context->preference("UseBranchTransferLimits") and
1945
            (C4::Context->preference("UseBranchTransferLimits") and
1941
             ! IsBranchTransferAllowed($branch, $hbr, $item->{C4::Context->preference("BranchTransferLimitsType")} )
1946
             ! IsBranchTransferAllowed($branch, $returnbranch, $item->{C4::Context->preference("BranchTransferLimitsType")} )
1942
           )) {
1947
           )) {
1943
            $debug and warn sprintf "about to call ModItemTransfer(%s, %s, %s)", $item->{'itemnumber'},$branch, $hbr;
1948
            $debug and warn sprintf "about to call ModItemTransfer(%s, %s, %s)", $item->{'itemnumber'},$branch, $returnbranch;
1944
            $debug and warn "item: " . Dumper($item);
1949
            $debug and warn "item: " . Dumper($item);
1945
            ModItemTransfer($item->{'itemnumber'}, $branch, $hbr);
1950
            ModItemTransfer($item->{'itemnumber'}, $branch, $returnbranch);
1946
            $messages->{'WasTransfered'} = 1;
1951
            $messages->{'WasTransfered'} = 1;
1947
        } else {
1952
        } else {
1948
            $messages->{'NeedsTransfer'} = 1;   # TODO: instead of 1, specify branchcode that the transfer SHOULD go to, $item->{homebranch}
1953
            $messages->{'NeedsTransfer'} = $returnbranch;
1949
        }
1954
        }
1950
    }
1955
    }
1951
    return ( $doreturn, $messages, $issue, $borrower );
1956
    return ( $doreturn, $messages, $issue, $borrower );
(-)a/circ/returns.pl (-6 / +12 lines)
Lines 215-224 if ($barcode) { Link Here
215
#
215
#
216
# save the return
216
# save the return
217
#
217
#
218
    ( $returned, $messages, $issueinformation, $borrower ) =
218
    
219
      AddReturn( $barcode, $userenv_branch, $exemptfine, $dropboxmode);     # do the return
220
    my $homeorholdingbranchreturn = C4::Context->preference('HomeOrHoldingBranchReturn');
221
    $homeorholdingbranchreturn ||= 'homebranch';
222
219
223
    # get biblio description
220
    # get biblio description
224
    my $biblio = GetBiblioFromItemNumber($itemnumber);
221
    my $biblio = GetBiblioFromItemNumber($itemnumber);
Lines 235-244 if ($barcode) { Link Here
235
        );
232
        );
236
    }
233
    }
237
234
235
    # make sure return branch respects home branch circulation rules, default to homebranch
236
    my $hbr = GetBranchItemRule($biblio->{'homebranch'}, $itemtype)->{'returnbranch'} || "homebranch";
237
    my $returnbranch = $biblio->{$hbr} ;
238
238
    $template->param(
239
    $template->param(
239
        title            => $biblio->{'title'},
240
        title            => $biblio->{'title'},
240
        homebranch       => $biblio->{'homebranch'},
241
        homebranch       => $biblio->{'homebranch'},
241
        homebranchname   => GetBranchName( $biblio->{$homeorholdingbranchreturn} ),
242
        homebranchname   => GetBranchName( $biblio->{'homebranch'} ),
243
        returnbranch     => $returnbranch,
244
        returnbranchname => GetBranchName( $returnbranch ),
242
        author           => $biblio->{'author'},
245
        author           => $biblio->{'author'},
243
        itembarcode      => $biblio->{'barcode'},
246
        itembarcode      => $biblio->{'barcode'},
244
        itemtype         => $biblio->{'itemtype'},
247
        itemtype         => $biblio->{'itemtype'},
Lines 253-258 if ($barcode) { Link Here
253
        barcode => $barcode,
256
        barcode => $barcode,
254
    );
257
    );
255
258
259
    ( $returned, $messages, $issueinformation, $borrower ) =
260
      AddReturn( $barcode, $userenv_branch, $exemptfine, $dropboxmode);     # do the return
261
      
256
    if ($returned) {
262
    if ($returned) {
257
        my $time_now = DateTime->now( time_zone => C4::Context->tz )->truncate( to => 'minute');
263
        my $time_now = DateTime->now( time_zone => C4::Context->tz )->truncate( to => 'minute');
258
        my $duedate = $issueinformation->{date_due}->strftime('%Y-%m-%d %H:%M');
264
        my $duedate = $issueinformation->{date_due}->strftime('%Y-%m-%d %H:%M');
Lines 318-324 if ( $messages->{'WasTransfered'} ) { Link Here
318
if ( $messages->{'NeedsTransfer'} ){
324
if ( $messages->{'NeedsTransfer'} ){
319
    $template->param(
325
    $template->param(
320
        found          => 1,
326
        found          => 1,
321
        needstransfer  => 1,
327
        needstransfer  => $messages->{'NeedsTransfer'},
322
        itemnumber     => $itemnumber,
328
        itemnumber     => $itemnumber,
323
    );
329
    );
324
}
330
}
(-)a/installer/data/mysql/updatedatabase.pl (+9 lines)
Lines 8083-8088 if ( CheckVersion($DBversion) ) { Link Here
8083
    SetVersion($DBversion);
8083
    SetVersion($DBversion);
8084
}
8084
}
8085
8085
8086
$DBversion = "3.15.00.XXX";
8087
if ( CheckVersion($DBversion) ) {
8088
    $dbh->do(q{
8089
        DELETE FROM systempreferences WHERE variable = 'HomeOrHoldingBranchReturn';
8090
    });
8091
    print "Upgrade to $DBversion done (Bug 7981 - Transfer message when returning item)\n";
8092
    SetVersion($DBversion);
8093
}
8094
8086
=head1 FUNCTIONS
8095
=head1 FUNCTIONS
8087
8096
8088
=head2 TableExists($table)
8097
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (-7 lines)
Lines 323-335 Circulation: Link Here
323
                  confirmation: Ask for confirmation
323
                  confirmation: Ask for confirmation
324
            - when checking out to a borrower that has overdues outstanding	    
324
            - when checking out to a borrower that has overdues outstanding	    
325
        -
325
        -
326
            - On checkin route the returned item to
327
            - pref: HomeOrHoldingBranchReturn
328
              type: choice
329
              choices:
330
                  homebranch: the library the item is from.
331
                  holdingbranch: the library the item was checked out from.
332
        -
333
            - "When issuing an item that has been marked as lost, "
326
            - "When issuing an item that has been marked as lost, "
334
            - pref: IssueLostItem
327
            - pref: IssueLostItem
335
              choices:
328
              choices:
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt (-6 / +5 lines)
Lines 201-209 $(document).ready(function () { Link Here
201
    [% END %]
201
    [% END %]
202
202
203
    [% IF ( transfer ) %]
203
    [% IF ( transfer ) %]
204
    <!-- transfer: item with no reservation, must be returned to its home library -->
204
    <!-- transfer: item with no reservation, must be returned according to home library circulation rules -->
205
	<div id="return1" class="dialog message">
205
	<div id="return1" class="dialog message">
206
            <h3>Please return <a href="/cgi-bin/koha/catalogue/detail.pl?type=intra&amp;biblionumber=[% itembiblionumber %]">[% title or "item" |html %]</a> to [% homebranchname %]<br/>( <a href="#" onclick="Dopop('transfer-slip.pl?transferitem=[% itemnumber %]&amp;branchcode=[% homebranch %]&amp;op=slip'); return true;">Print slip</a> )</h3>
206
            <h3>Please return <a href="/cgi-bin/koha/catalogue/detail.pl?type=intra&amp;biblionumber=[% itembiblionumber %]">[% title or "item" |html %]</a> to [% returnbranchname %]<br/>( <a href="#" onclick="Dopop('transfer-slip.pl?transferitem=[% itemnumber %]&amp;branchcode=[% returnbranch %]&amp;op=slip'); return true;">Print slip</a> )</h3>
207
        </div>
207
        </div>
208
        [% IF ( soundon ) %]
208
        [% IF ( soundon ) %]
209
        <audio src="[% interface %]/[% theme %]/sound/opening.ogg" autoplay="autoplay" autobuffer="autobuffer"></audio>
209
        <audio src="[% interface %]/[% theme %]/sound/opening.ogg" autoplay="autoplay" autobuffer="autobuffer"></audio>
Lines 215-229 $(document).ready(function () { Link Here
215
        [% IF ( soundon ) %]
215
        [% IF ( soundon ) %]
216
        <audio src="[% interface %]/[% theme %]/sound/opening.ogg" autoplay="autoplay" autobuffer="autobuffer"></audio>
216
        <audio src="[% interface %]/[% theme %]/sound/opening.ogg" autoplay="autoplay" autobuffer="autobuffer"></audio>
217
        [% END %]
217
        [% END %]
218
	<div id="item-transfer" class="dialog message"><h3> This item needs to be transferred to [% homebranchname %]</h3>
218
	<div id="item-transfer" class="dialog message"><h3> This item needs to be transferred to [% returnbranchname %]</h3>
219
    Transfer now?<br />
219
    Transfer now?<br />
220
    <form method="post" action="returns.pl" name="mainform" id="mainform">
220
    <form method="post" action="returns.pl" name="mainform" id="mainform">
221
    [% IF itemnumber %]
221
    [% IF itemnumber %]
222
        <input type="submit" name="dotransfer" value="Yes, Print slip" class="print" onclick="Dopop('transfer-slip.pl?transferitem=[% itemnumber %]&amp;&amp;branchcode=[% homebranch %]&amp;op=slip'); return true;" />
222
        <input type="submit" name="dotransfer" value="Yes, Print slip" class="print" onclick="Dopop('transfer-slip.pl?transferitem=[% itemnumber %]&amp;&amp;branchcode=[% returnbranch %]&amp;op=slip'); return true;" />
223
    [% END %]
223
    [% END %]
224
	<input type="submit" name="dotransfer" value="Yes" class="submit" />
224
	<input type="submit" name="dotransfer" value="Yes" class="submit" />
225
	<input type="submit" name="notransfer" value="No" class="submit" />
225
	<input type="submit" name="notransfer" value="No" class="submit" />
226
	<input type="hidden" name="tobranch" value="[% homebranch %]" />
226
	<input type="hidden" name="tobranch" value="[% returnbranch %]" />
227
	<input type="hidden" name="transferitem" value="[% itemnumber %]" />
227
	<input type="hidden" name="transferitem" value="[% itemnumber %]" />
228
        <input type="hidden" name="exemptfine" value="[% exemptfine %]" />
228
        <input type="hidden" name="exemptfine" value="[% exemptfine %]" />
229
        <input type="hidden" name="dropboxmode" value="[% dropboxmode %]" />
229
        <input type="hidden" name="dropboxmode" value="[% dropboxmode %]" />
230
- 

Return to bug 7981