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

(-)a/C4/Circulation.pm (-8 / +51 lines)
Lines 901-906 sub CanBookBeIssued { Link Here
901
	return ( \%issuingimpossible, \%needsconfirmation );
901
	return ( \%issuingimpossible, \%needsconfirmation );
902
}
902
}
903
903
904
=head2 CanBookBeReturned
905
906
  ($returnallowed, $message) = CanBookBeReturned($item, $branch)
907
908
Check whether the item can be returned to the provided branch
909
910
=over 4
911
912
=item C<$item> is a hash of item information as returned from GetItem
913
914
=item C<$branch> is the branchcode where the return is taking place
915
916
=back
917
918
Returns:
919
920
=over 4
921
922
=item C<$returnallowed> is 0 or 1, corresponding to whether the return is allowed (1) or not (0)
923
924
=item C<$message> is the branchcode where the item SHOULD be returned, if the return is not allowed
925
926
=cut
927
928
sub CanBookBeReturned {
929
  my ($item, $branch) = @_;
930
  my $allowreturntobranch = C4::Context->preference("AllowReturnToBranch") || 'anywhere';
931
932
  # assume return is allowed to start
933
  my $allowed = 1;
934
  my $message;
935
936
  # identify all cases where return is forbidden
937
  if ($allowreturntobranch eq 'homebranch' && $branch ne $item->{'homebranch'}) {
938
     $allowed = 0;
939
     $message = $item->{'homebranch'};
940
  } elsif ($allowreturntobranch eq 'holdingbranch' && $branch ne $item->{'holdingbranch'}) {
941
     $allowed = 0;
942
     $message = $item->{'holdingbranch'};
943
  } elsif ($allowreturntobranch eq 'homeorholdingbranch' && $branch ne $item->{'homebranch'} && $branch ne $item->{'holdingbranch'}) {
944
     $allowed = 0;
945
     $message = $item->{'homebranch'}; # FIXME: choice of homebranch is arbitrary
946
  }
947
948
  return ($allowed, $message);
949
}
950
904
=head2 AddIssue
951
=head2 AddIssue
905
952
906
  &AddIssue($borrower, $barcode, [$datedue], [$cancelreserve], [$issuedate])
953
  &AddIssue($borrower, $barcode, [$datedue], [$cancelreserve], [$issuedate])
Lines 1556-1573 sub AddReturn { Link Here
1556
        $branches->{$hbr}->{PE} and $messages->{'IsPermanent'} = $hbr;
1603
        $branches->{$hbr}->{PE} and $messages->{'IsPermanent'} = $hbr;
1557
    }
1604
    }
1558
1605
1559
    # if indy branches and returning to different branch, refuse the return
1606
    # check if the return is allowed at this branch
1560
    if ($hbr ne $branch && C4::Context->preference("IndependantBranches")){
1607
    my ($returnallowed, $message) = CanBookBeReturned($item, $branch);
1608
    unless ($returnallowed){
1561
        $messages->{'Wrongbranch'} = {
1609
        $messages->{'Wrongbranch'} = {
1562
            Wrongbranch => $branch,
1610
            Wrongbranch => $branch,
1563
            Rightbranch => $hbr,
1611
            Rightbranch => $message
1564
        };
1612
        };
1565
        $doreturn = 0;
1613
        $doreturn = 0;
1566
        # bailing out here - in this case, current desired behavior
1567
        # is to act as if no return ever happened at all.
1568
        # FIXME - even in an indy branches situation, there should
1569
        # still be an option for the library to accept the item
1570
        # and transfer it to its owning library.
1571
        return ( $doreturn, $messages, $issue, $borrower );
1614
        return ( $doreturn, $messages, $issue, $borrower );
1572
    }
1615
    }
1573
1616
(-)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 184-189 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES Link Here
184
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('PatronsPerPage','20','Number of Patrons Per Page displayed by default','20','Integer');
184
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('PatronsPerPage','20','Number of Patrons Per Page displayed by default','20','Integer');
185
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');
185
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');
186
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');
186
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');
187
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AllowReturnToBranch', 'anywhere', 'Where an item may be returned', 'anywhere|homebranch|holdingbranch|homeorholdingbranch', 'Choice');
187
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OpacHighlightedWords','1','If Set, then queried words are higlighted in OPAC','','YesNo');
188
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OpacHighlightedWords','1','If Set, then queried words are higlighted in OPAC','','YesNo');
188
189
189
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OAI-PMH','0','if ON, OAI-PMH server is enabled',NULL,'YesNo');
190
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 (+10 lines)
Lines 4578-4583 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
4578
    SetVersion($DBversion);
4578
    SetVersion($DBversion);
4579
}
4579
}
4580
4580
4581
$DBversion = "3.07.00.XXX";
4582
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4583
    # to preserve default behaviour as best as possible, set this new preference differently depending on whether IndependantBranches is set or not
4584
    my $prefvalue = 'anywhere';
4585
    if (C4::Context->preference("IndependantBranches")) { $prefvalue = 'homeorholdingbranch';}
4586
    $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AllowReturnToBranch', '$prefvalue', 'Where an item may be returned', 'anywhere|homebranch|holdingbranch|homeorholdingbranch', 'Choice');");
4587
    print "Upgrade to $DBversion done: adding AllowReturnToBranch syspref (bug 6151)";
4588
    SetVersion($DBversion);
4589
}
4590
4581
=head1 FUNCTIONS
4591
=head1 FUNCTIONS
4582
4592
4583
=head2 DropAllForeignKeys($table)
4593
=head2 DropAllForeignKeys($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (-1 / +9 lines)
Lines 161-166 Circulation: Link Here
161
                  homebranch: the library the item is from.
161
                  homebranch: the library the item is from.
162
                  holdingbranch: the library the item was checked out from.
162
                  holdingbranch: the library the item was checked out from.
163
        -
163
        -
164
            - Allow materials to be returned to
165
            - pref: AllowReturnToBranch
166
              type: choice
167
              choices:
168
                  anywhere: to any library.
169
                  homebranch: only the library the item is from.
170
                  holdingbranch: only the library the item was checked out from.
171
                  homeorholdingbranch: either the library the item is from or the library it was checked out from.
172
        -
164
            - Calculate the due date using 
173
            - Calculate the due date using 
165
            - pref: useDaysMode
174
            - pref: useDaysMode
166
              choices:
175
              choices:
167
- 

Return to bug 6151