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

(-)a/C4/Circulation.pm (-8 / +51 lines)
Lines 1008-1013 sub CanBookBeIssued { Link Here
1008
    return ( \%issuingimpossible, \%needsconfirmation, \%alerts );
1008
    return ( \%issuingimpossible, \%needsconfirmation, \%alerts );
1009
}
1009
}
1010
1010
1011
=head2 CanBookBeReturned
1012
1013
  ($returnallowed, $message) = CanBookBeReturned($item, $branch)
1014
1015
Check whether the item can be returned to the provided branch
1016
1017
=over 4
1018
1019
=item C<$item> is a hash of item information as returned from GetItem
1020
1021
=item C<$branch> is the branchcode where the return is taking place
1022
1023
=back
1024
1025
Returns:
1026
1027
=over 4
1028
1029
=item C<$returnallowed> is 0 or 1, corresponding to whether the return is allowed (1) or not (0)
1030
1031
=item C<$message> is the branchcode where the item SHOULD be returned, if the return is not allowed
1032
1033
=cut
1034
1035
sub CanBookBeReturned {
1036
  my ($item, $branch) = @_;
1037
  my $allowreturntobranch = C4::Context->preference("AllowReturnToBranch") || 'anywhere';
1038
1039
  # assume return is allowed to start
1040
  my $allowed = 1;
1041
  my $message;
1042
1043
  # identify all cases where return is forbidden
1044
  if ($allowreturntobranch eq 'homebranch' && $branch ne $item->{'homebranch'}) {
1045
     $allowed = 0;
1046
     $message = $item->{'homebranch'};
1047
  } elsif ($allowreturntobranch eq 'holdingbranch' && $branch ne $item->{'holdingbranch'}) {
1048
     $allowed = 0;
1049
     $message = $item->{'holdingbranch'};
1050
  } elsif ($allowreturntobranch eq 'homeorholdingbranch' && $branch ne $item->{'homebranch'} && $branch ne $item->{'holdingbranch'}) {
1051
     $allowed = 0;
1052
     $message = $item->{'homebranch'}; # FIXME: choice of homebranch is arbitrary
1053
  }
1054
1055
  return ($allowed, $message);
1056
}
1057
1011
=head2 AddIssue
1058
=head2 AddIssue
1012
1059
1013
  &AddIssue($borrower, $barcode, [$datedue], [$cancelreserve], [$issuedate])
1060
  &AddIssue($borrower, $barcode, [$datedue], [$cancelreserve], [$issuedate])
Lines 1623-1640 sub AddReturn { Link Here
1623
        $branches->{$hbr}->{PE} and $messages->{'IsPermanent'} = $hbr;
1670
        $branches->{$hbr}->{PE} and $messages->{'IsPermanent'} = $hbr;
1624
    }
1671
    }
1625
1672
1626
    # if indy branches and returning to different branch, refuse the return unless canreservefromotherbranches is turned on
1673
    # check if the return is allowed at this branch
1627
    if ($hbr ne $branch && C4::Context->preference("IndependantBranches") && !(C4::Context->preference("canreservefromotherbranches"))){
1674
    my ($returnallowed, $message) = CanBookBeReturned($item, $branch);
1675
    unless ($returnallowed){
1628
        $messages->{'Wrongbranch'} = {
1676
        $messages->{'Wrongbranch'} = {
1629
            Wrongbranch => $branch,
1677
            Wrongbranch => $branch,
1630
            Rightbranch => $hbr,
1678
            Rightbranch => $message
1631
        };
1679
        };
1632
        $doreturn = 0;
1680
        $doreturn = 0;
1633
        # bailing out here - in this case, current desired behavior
1634
        # is to act as if no return ever happened at all.
1635
        # FIXME - even in an indy branches situation, there should
1636
        # still be an option for the library to accept the item
1637
        # and transfer it to its owning library.
1638
        return ( $doreturn, $messages, $issue, $borrower );
1681
        return ( $doreturn, $messages, $issue, $borrower );
1639
    }
1682
    }
1640
1683
(-)a/admin/systempreferences.pl (-1 / +1 lines)
Lines 204-210 $tabsysprefs{AllowAllMessageDeletion} = "Circulation"; Link Here
204
$tabsysprefs{OverdueNoticeBcc}               = "Circulation";
204
$tabsysprefs{OverdueNoticeBcc}               = "Circulation";
205
$tabsysprefs{OverduesBlockCirc}              = "Circulation";
205
$tabsysprefs{OverduesBlockCirc}              = "Circulation";
206
$tabsysprefs{UseTransportCostMatrix}         = "Circulation";
206
$tabsysprefs{UseTransportCostMatrix}         = "Circulation";
207
207
$tabsysprefs{AllowReturnToBranch}            = "Circulation";
208
208
209
# Staff Client
209
# Staff Client
210
$tabsysprefs{template}                = "StaffClient";
210
$tabsysprefs{template}                = "StaffClient";
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 180-185 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES Link Here
180
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('PatronsPerPage','20','Number of Patrons Per Page displayed by default','20','Integer');
180
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('PatronsPerPage','20','Number of Patrons Per Page displayed by default','20','Integer');
181
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('HomeOrHoldingBranch','holdingbranch','Used by Circulation to determine which branch of an item to check with independent branches on, and by search to determine which branch to choose for availability ','holdingbranch|homebranch','Choice');
181
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('HomeOrHoldingBranch','holdingbranch','Used by Circulation to determine which branch of an item to check with independent branches on, and by search to determine which branch to choose for availability ','holdingbranch|homebranch','Choice');
182
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('HomeOrHoldingBranchReturn','homebranch','Used by Circulation to determine which branch of an item to check checking-in items','holdingbranch|homebranch','Choice');
182
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('HomeOrHoldingBranchReturn','homebranch','Used by Circulation to determine which branch of an item to check checking-in items','holdingbranch|homebranch','Choice');
183
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AllowReturnToBranch', 'anywhere', 'Where an item may be returned', 'anywhere|homebranch|holdingbranch|homeorholdingbranch', 'Choice');
183
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OpacHighlightedWords','1','If Set, then queried words are higlighted in OPAC','','YesNo');
184
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OpacHighlightedWords','1','If Set, then queried words are higlighted in OPAC','','YesNo');
184
185
185
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OAI-PMH','0','if ON, OAI-PMH server is enabled',NULL,'YesNo');
186
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OAI-PMH','0','if ON, OAI-PMH server is enabled',NULL,'YesNo');
(-)a/installer/data/mysql/updatedatabase.pl (+11 lines)
Lines 5781-5786 if (C4::Context->preference("Version") < TransformToNum($DBversion)) { Link Here
5781
    SetVersion ($DBversion);
5781
    SetVersion ($DBversion);
5782
}
5782
}
5783
5783
5784
$DBversion = "3.09.00.XXX";
5785
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5786
    # to preserve default behaviour as best as possible, set this new preference differently depending on whether IndependantBranches is set or not
5787
    my $prefvalue = 'anywhere';
5788
    if (C4::Context->preference("IndependantBranches")) { $prefvalue = 'homeorholdingbranch';}
5789
    $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AllowReturnToBranch', '$prefvalue', 'Where an item may be returned', 'anywhere|homebranch|holdingbranch|homeorholdingbranch', 'Choice');");
5790
5791
    print "Upgrade to $DBversion done: adding AllowReturnToBranch syspref (bug 6151)";
5792
    SetVersion($DBversion);
5793
}
5794
5784
=head1 FUNCTIONS
5795
=head1 FUNCTIONS
5785
5796
5786
=head2 TableExists($table)
5797
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (-1 / +9 lines)
Lines 198-203 Circulation: Link Here
198
                  homebranch: the library the item is from.
198
                  homebranch: the library the item is from.
199
                  holdingbranch: the library the item was checked out from.
199
                  holdingbranch: the library the item was checked out from.
200
        -
200
        -
201
            - Allow materials to be returned to
202
            - pref: AllowReturnToBranch
203
              type: choice
204
              choices:
205
                  anywhere: to any library.
206
                  homebranch: only the library the item is from.
207
                  holdingbranch: only the library the item was checked out from.
208
                  homeorholdingbranch: either the library the item is from or the library it was checked out from.
209
        -
201
            - Calculate the due date using 
210
            - Calculate the due date using 
202
            - pref: useDaysMode
211
            - pref: useDaysMode
203
              choices:
212
              choices:
204
- 

Return to bug 6151