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

(-)a/C4/Circulation.pm (-15 / +20 lines)
Lines 1580-1585 holdallowed => Hold policy for this branch and itemtype. Possible values: Link Here
1580
returnbranch => branch to which to return item.  Possible values:
1580
returnbranch => branch to which to return item.  Possible values:
1581
  noreturn: do not return, let item remain where checked in (floating collections)
1581
  noreturn: do not return, let item remain where checked in (floating collections)
1582
  homebranch: return to item's home branch
1582
  homebranch: return to item's home branch
1583
  holdingbranch: return to issuer branch
1583
1584
1584
This searches branchitemrules in the following order:
1585
This searches branchitemrules in the following order:
1585
1586
Lines 1695-1700 fields from the reserves table of the Koha database, and Link Here
1695
C<biblioitemnumber>. It also has the key C<ResFound>, whose value is
1696
C<biblioitemnumber>. It also has the key C<ResFound>, whose value is
1696
either C<Waiting>, C<Reserved>, or 0.
1697
either C<Waiting>, C<Reserved>, or 0.
1697
1698
1699
=item C<WasReturned>
1700
1701
Value 1 if return is successful.
1702
1703
=item C<NeedsTransfer>
1704
1705
If AutomaticItemReturn is disabled, return branch is given as value of NeedsTransfer.
1706
1698
=back
1707
=back
1699
1708
1700
C<$iteminformation> is a reference-to-hash, giving information about the
1709
C<$iteminformation> is a reference-to-hash, giving information about the
Lines 1726-1732 sub AddReturn { Link Here
1726
        return (0, { BadBarcode => $barcode }); # no barcode means no item or borrower.  bail out.
1735
        return (0, { BadBarcode => $barcode }); # no barcode means no item or borrower.  bail out.
1727
    }
1736
    }
1728
    my $issue  = GetItemIssue($itemnumber);
1737
    my $issue  = GetItemIssue($itemnumber);
1729
#   warn Dumper($iteminformation);
1730
    if ($issue and $issue->{borrowernumber}) {
1738
    if ($issue and $issue->{borrowernumber}) {
1731
        $borrower = C4::Members::GetMemberDetails($issue->{borrowernumber})
1739
        $borrower = C4::Members::GetMemberDetails($issue->{borrowernumber})
1732
            or die "Data inconsistency: barcode $barcode (itemnumber:$itemnumber) claims to be issued to non-existant borrowernumber '$issue->{borrowernumber}'\n"
1740
            or die "Data inconsistency: barcode $barcode (itemnumber:$itemnumber) claims to be issued to non-existant borrowernumber '$issue->{borrowernumber}'\n"
Lines 1746-1763 sub AddReturn { Link Here
1746
    my $item = GetItem($itemnumber) or die "GetItem($itemnumber) failed";
1754
    my $item = GetItem($itemnumber) or die "GetItem($itemnumber) failed";
1747
        # full item data, but no borrowernumber or checkout info (no issue)
1755
        # full item data, but no borrowernumber or checkout info (no issue)
1748
        # we know GetItem should work because GetItemnumberFromBarcode worked
1756
        # we know GetItem should work because GetItemnumberFromBarcode worked
1749
    my $hbr      = GetBranchItemRule($item->{'homebranch'}, $item->{'itype'})->{'returnbranch'} || "homebranch";
1757
    my $hbr = GetBranchItemRule($item->{'homebranch'}, $item->{'itype'})->{'returnbranch'} || "homebranch";
1750
        # get the proper branch to which to return the item
1758
        # get the proper branch to which to return the item
1751
    $hbr = $item->{$hbr} || $branch ;
1759
    my $returnbranch = $item->{$hbr} || $branch ;
1752
        # if $hbr was "noreturn" or any other non-item table value, then it should 'float' (i.e. stay at this branch)
1760
        # if $hbr was "noreturn" or any other non-item table value, then it should 'float' (i.e. stay at this branch)
1753
1761
1754
    my $borrowernumber = $borrower->{'borrowernumber'} || undef;    # we don't know if we had a borrower or not
1762
    my $borrowernumber = $borrower->{'borrowernumber'} || undef;    # we don't know if we had a borrower or not
1755
1763
1756
    # check if the book is in a permanent collection....
1764
    # check if the book is in a permanent collection....
1757
    # FIXME -- This 'PE' attribute is largely undocumented.  afaict, there's no user interface that reflects this functionality.
1765
    # FIXME -- This 'PE' attribute is largely undocumented.  afaict, there's no user interface that reflects this functionality.
1758
    if ( $hbr ) {
1766
    if ( $returnbranch ) {
1759
        my $branches = GetBranches();    # a potentially expensive call for a non-feature.
1767
        my $branches = GetBranches();    # a potentially expensive call for a non-feature.
1760
        $branches->{$hbr}->{PE} and $messages->{'IsPermanent'} = $hbr;
1768
        $branches->{$returnbranch}->{PE} and $messages->{'IsPermanent'} = $returnbranch;
1761
    }
1769
    }
1762
1770
1763
    # check if the return is allowed at this branch
1771
    # check if the return is allowed at this branch
Lines 1929-1949 sub AddReturn { Link Here
1929
        DelUniqueDebarment({ borrowernumber => $borrowernumber, type => 'OVERDUES' });
1937
        DelUniqueDebarment({ borrowernumber => $borrowernumber, type => 'OVERDUES' });
1930
    }
1938
    }
1931
1939
1932
    # FIXME: make this comment intelligible.
1940
    # Transfer to returnbranch if Automatic transfer set or append message NeedsTransfer
1933
    #adding message if holdingbranch is non equal a userenv branch to return the document to homebranch
1941
    if (($doreturn or $messages->{'NotIssued'}) and !$resfound and ($branch ne $returnbranch) and not $messages->{'WrongTransfer'}){
1934
    #we check, if we don't have reserv or transfert for this document, if not, return it to homebranch .
1942
        if  (C4::Context->preference("AutomaticItemReturn"    ) or
1935
1936
    if (($doreturn or $messages->{'NotIssued'}) and !$resfound and ($branch ne $hbr) and not $messages->{'WrongTransfer'}){
1937
        if ( C4::Context->preference("AutomaticItemReturn"    ) or
1938
            (C4::Context->preference("UseBranchTransferLimits") and
1943
            (C4::Context->preference("UseBranchTransferLimits") and
1939
             ! IsBranchTransferAllowed($branch, $hbr, $item->{C4::Context->preference("BranchTransferLimitsType")} )
1944
             ! IsBranchTransferAllowed($branch, $returnbranch, $item->{C4::Context->preference("BranchTransferLimitsType")} )
1940
           )) {
1945
           )) {
1941
            $debug and warn sprintf "about to call ModItemTransfer(%s, %s, %s)", $item->{'itemnumber'},$branch, $hbr;
1946
            $debug and warn sprintf "about to call ModItemTransfer(%s, %s, %s)", $item->{'itemnumber'},$branch, $returnbranch;
1942
            $debug and warn "item: " . Dumper($item);
1947
            $debug and warn "item: " . Dumper($item);
1943
            ModItemTransfer($item->{'itemnumber'}, $branch, $hbr);
1948
            ModItemTransfer($item->{'itemnumber'}, $branch, $returnbranch);
1944
            $messages->{'WasTransfered'} = 1;
1949
            $messages->{'WasTransfered'} = 1;
1945
        } else {
1950
        } else {
1946
            $messages->{'NeedsTransfer'} = 1;   # TODO: instead of 1, specify branchcode that the transfer SHOULD go to, $item->{homebranch}
1951
            $messages->{'NeedsTransfer'} = $returnbranch;
1947
        }
1952
        }
1948
    }
1953
    }
1949
    return ( $doreturn, $messages, $issue, $borrower );
1954
    return ( $doreturn, $messages, $issue, $borrower );
(-)a/circ/returns.pl (-6 / +12 lines)
Lines 223-232 if ($barcode) { Link Here
223
#
223
#
224
# save the return
224
# save the return
225
#
225
#
226
    ( $returned, $messages, $issueinformation, $borrower ) =
226
227
      AddReturn( $barcode, $userenv_branch, $exemptfine, $dropboxmode);     # do the return
228
    my $homeorholdingbranchreturn = C4::Context->preference('HomeOrHoldingBranchReturn');
229
    $homeorholdingbranchreturn ||= 'homebranch';
230
227
231
    # get biblio description
228
    # get biblio description
232
    my $biblio = GetBiblioFromItemNumber($itemnumber);
229
    my $biblio = GetBiblioFromItemNumber($itemnumber);
Lines 243-252 if ($barcode) { Link Here
243
        );
240
        );
244
    }
241
    }
245
242
243
    # make sure return branch respects home branch circulation rules, default to homebranch
244
    my $hbr = GetBranchItemRule($biblio->{'homebranch'}, $itemtype)->{'returnbranch'} || "homebranch";
245
    my $returnbranch = $biblio->{$hbr} ;
246
246
    $template->param(
247
    $template->param(
247
        title            => $biblio->{'title'},
248
        title            => $biblio->{'title'},
248
        homebranch       => $biblio->{'homebranch'},
249
        homebranch       => $biblio->{'homebranch'},
249
        homebranchname   => GetBranchName( $biblio->{$homeorholdingbranchreturn} ),
250
        homebranchname   => GetBranchName( $biblio->{'homebranch'} ),
251
        returnbranch     => $returnbranch,
252
        returnbranchname => GetBranchName( $returnbranch ),
250
        author           => $biblio->{'author'},
253
        author           => $biblio->{'author'},
251
        itembarcode      => $biblio->{'barcode'},
254
        itembarcode      => $biblio->{'barcode'},
252
        itemtype         => $biblio->{'itemtype'},
255
        itemtype         => $biblio->{'itemtype'},
Lines 261-266 if ($barcode) { Link Here
261
        barcode => $barcode,
264
        barcode => $barcode,
262
    );
265
    );
263
266
267
    ( $returned, $messages, $issueinformation, $borrower ) =
268
      AddReturn( $barcode, $userenv_branch, $exemptfine, $dropboxmode);     # do the return
269
264
    if ($returned) {
270
    if ($returned) {
265
        my $time_now = DateTime->now( time_zone => C4::Context->tz )->truncate( to => 'minute');
271
        my $time_now = DateTime->now( time_zone => C4::Context->tz )->truncate( to => 'minute');
266
        my $duedate = $issueinformation->{date_due}->strftime('%Y-%m-%d %H:%M');
272
        my $duedate = $issueinformation->{date_due}->strftime('%Y-%m-%d %H:%M');
Lines 326-332 if ( $messages->{'WasTransfered'} ) { Link Here
326
if ( $messages->{'NeedsTransfer'} ){
332
if ( $messages->{'NeedsTransfer'} ){
327
    $template->param(
333
    $template->param(
328
        found          => 1,
334
        found          => 1,
329
        needstransfer  => 1,
335
        needstransfer  => $messages->{'NeedsTransfer'},
330
        itemnumber     => $itemnumber,
336
        itemnumber     => $itemnumber,
331
    );
337
    );
332
}
338
}
(-)a/installer/data/mysql/updatedatabase.pl (+9 lines)
Lines 8202-8207 if ( CheckVersion($DBversion) ) { Link Here
8202
    SetVersion($DBversion);
8202
    SetVersion($DBversion);
8203
}
8203
}
8204
8204
8205
$DBversion = "3.15.00.XXX";
8206
if ( CheckVersion($DBversion) ) {
8207
    $dbh->do(q{
8208
        DELETE FROM systempreferences WHERE variable = 'HomeOrHoldingBranchReturn';
8209
    });
8210
    print "Upgrade to $DBversion done (Bug 7981 - Transfer message when returning item)\n";
8211
    SetVersion($DBversion);
8212
}
8213
8205
=head1 FUNCTIONS
8214
=head1 FUNCTIONS
8206
8215
8207
=head2 TableExists($table)
8216
=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