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

(-)a/C4/Circulation.pm (-8 / +51 lines)
Lines 934-939 sub CanBookBeIssued { Link Here
934
    return ( \%issuingimpossible, \%needsconfirmation, \%alerts );
934
    return ( \%issuingimpossible, \%needsconfirmation, \%alerts );
935
}
935
}
936
936
937
=head2 CanBookBeReturned
938
939
  ($returnallowed, $message) = CanBookBeReturned($item, $branch)
940
941
Check whether the item can be returned to the provided branch
942
943
=over 4
944
945
=item C<$item> is a hash of item information as returned from GetItem
946
947
=item C<$branch> is the branchcode where the return is taking place
948
949
=back
950
951
Returns:
952
953
=over 4
954
955
=item C<$returnallowed> is 0 or 1, corresponding to whether the return is allowed (1) or not (0)
956
957
=item C<$message> is the branchcode where the item SHOULD be returned, if the return is not allowed
958
959
=cut
960
961
sub CanBookBeReturned {
962
  my ($item, $branch) = @_;
963
  my $allowreturntobranch = C4::Context->preference("AllowReturnToBranch") || 'anywhere';
964
965
  # assume return is allowed to start
966
  my $allowed = 1;
967
  my $message;
968
969
  # identify all cases where return is forbidden
970
  if ($allowreturntobranch eq 'homebranch' && $branch ne $item->{'homebranch'}) {
971
     $allowed = 0;
972
     $message = $item->{'homebranch'};
973
  } elsif ($allowreturntobranch eq 'holdingbranch' && $branch ne $item->{'holdingbranch'}) {
974
     $allowed = 0;
975
     $message = $item->{'holdingbranch'};
976
  } elsif ($allowreturntobranch eq 'homeorholdingbranch' && $branch ne $item->{'homebranch'} && $branch ne $item->{'holdingbranch'}) {
977
     $allowed = 0;
978
     $message = $item->{'homebranch'}; # FIXME: choice of homebranch is arbitrary
979
  }
980
981
  return ($allowed, $message);
982
}
983
937
=head2 AddIssue
984
=head2 AddIssue
938
985
939
  &AddIssue($borrower, $barcode, [$datedue], [$cancelreserve], [$issuedate])
986
  &AddIssue($borrower, $barcode, [$datedue], [$cancelreserve], [$issuedate])
Lines 1585-1602 sub AddReturn { Link Here
1585
        $branches->{$hbr}->{PE} and $messages->{'IsPermanent'} = $hbr;
1632
        $branches->{$hbr}->{PE} and $messages->{'IsPermanent'} = $hbr;
1586
    }
1633
    }
1587
1634
1588
    # if indy branches and returning to different branch, refuse the return unless canreservefromotherbranches is turned on
1635
    # check if the return is allowed at this branch
1589
    if ($hbr ne $branch && C4::Context->preference("IndependantBranches") && !(C4::Context->preference("canreservefromotherbranches"))){
1636
    my ($returnallowed, $message) = CanBookBeReturned($item, $branch);
1637
    unless ($returnallowed){
1590
        $messages->{'Wrongbranch'} = {
1638
        $messages->{'Wrongbranch'} = {
1591
            Wrongbranch => $branch,
1639
            Wrongbranch => $branch,
1592
            Rightbranch => $hbr,
1640
            Rightbranch => $message
1593
        };
1641
        };
1594
        $doreturn = 0;
1642
        $doreturn = 0;
1595
        # bailing out here - in this case, current desired behavior
1596
        # is to act as if no return ever happened at all.
1597
        # FIXME - even in an indy branches situation, there should
1598
        # still be an option for the library to accept the item
1599
        # and transfer it to its owning library.
1600
        return ( $doreturn, $messages, $issue, $borrower );
1643
        return ( $doreturn, $messages, $issue, $borrower );
1601
    }
1644
    }
1602
1645
(-)a/admin/systempreferences.pl (-1 / +1 lines)
Lines 203-209 $tabsysprefs{DisplayClearScreenButton} = "Circulation"; Link Here
203
$tabsysprefs{AllowAllMessageDeletion}        = "Circulation";
203
$tabsysprefs{AllowAllMessageDeletion}        = "Circulation";
204
$tabsysprefs{OverdueNoticeBcc}               = "Circulation";
204
$tabsysprefs{OverdueNoticeBcc}               = "Circulation";
205
$tabsysprefs{OverduesBlockCirc}              = "Circulation";
205
$tabsysprefs{OverduesBlockCirc}              = "Circulation";
206
206
$tabsysprefs{AllowReturnToBranch}            = "Circulation";
207
207
208
# Staff Client
208
# Staff Client
209
$tabsysprefs{template}                = "StaffClient";
209
$tabsysprefs{template}                = "StaffClient";
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 187-192 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES Link Here
187
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('PatronsPerPage','20','Number of Patrons Per Page displayed by default','20','Integer');
187
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('PatronsPerPage','20','Number of Patrons Per Page displayed by default','20','Integer');
188
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');
188
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');
189
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');
189
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');
190
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AllowReturnToBranch', 'anywhere', 'Where an item may be returned', 'anywhere|homebranch|holdingbranch|homeorholdingbranch', 'Choice');
190
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OpacHighlightedWords','1','If Set, then queried words are higlighted in OPAC','','YesNo');
191
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OpacHighlightedWords','1','If Set, then queried words are higlighted in OPAC','','YesNo');
191
192
192
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OAI-PMH','0','if ON, OAI-PMH server is enabled',NULL,'YesNo');
193
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 5610-5615 if (C4::Context->preference("Version") < TransformToNum($DBversion)) { Link Here
5610
    SetVersion($DBversion);
5610
    SetVersion($DBversion);
5611
}
5611
}
5612
5612
5613
$DBversion = "3.09.00.XXX";
5614
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5615
    # to preserve default behaviour as best as possible, set this new preference differently depending on whether IndependantBranches is set or not
5616
    my $prefvalue = 'anywhere';
5617
    if (C4::Context->preference("IndependantBranches")) { $prefvalue = 'homeorholdingbranch';}
5618
    $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AllowReturnToBranch', '$prefvalue', 'Where an item may be returned', 'anywhere|homebranch|holdingbranch|homeorholdingbranch', 'Choice');");
5619
5620
    print "Upgrade to $DBversion done: adding AllowReturnToBranch syspref (bug 6151)";
5621
    SetVersion($DBversion);
5622
}
5623
5613
=head1 FUNCTIONS
5624
=head1 FUNCTIONS
5614
5625
5615
=head2 TableExists($table)
5626
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (-1 / +9 lines)
Lines 185-190 Circulation: Link Here
185
                  homebranch: the library the item is from.
185
                  homebranch: the library the item is from.
186
                  holdingbranch: the library the item was checked out from.
186
                  holdingbranch: the library the item was checked out from.
187
        -
187
        -
188
            - Allow materials to be returned to
189
            - pref: AllowReturnToBranch
190
              type: choice
191
              choices:
192
                  anywhere: to any library.
193
                  homebranch: only the library the item is from.
194
                  holdingbranch: only the library the item was checked out from.
195
                  homeorholdingbranch: either the library the item is from or the library it was checked out from.
196
        -
188
            - Calculate the due date using 
197
            - Calculate the due date using 
189
            - pref: useDaysMode
198
            - pref: useDaysMode
190
              choices:
199
              choices:
191
- 

Return to bug 6151