Bug 6151: Add AllowReturnToBranch system preference
authorIan Walls <ian.walls@bywatersolutions.com>
Thu, 1 Dec 2011 21:15:04 +0000 (16:15 -0500)
committerPaul Poulain <paul.poulain@biblibre.com>
Mon, 17 Sep 2012 17:17:41 +0000 (19:17 +0200)
commit850b4eeab96e4d9f298e67b1987ad9aad5b28fd8
tree79684c982cc1c8cc4158330b634bb95f1875dc38
parentcbca4e8b0e2143fe5ec1bb221ace0e51597ac308
Bug 6151: Add AllowReturnToBranch system preference

In order to solve the issue of IndependantBranches being incompatible with HomeOrHoldingBranchReturn,
this patch changes the mechanism by which the question "can I return this material here?" is answered.  Before,
the conditions were "if IndependantBranches is on, and this branch isn't HomeOrHoldingBranchReturn for the item,
then no, otherwise yes".  Now, the question is answered by consulting CanBookBeReturned (new subroutine)

New system preference:  AllowReturnToBranch
Possible values:
  - anywhere (default for new installs, and for existing systems with IndependantBranches turned off)
  - homebranch
  - holdingbranch (which is also the issuing branch in all normal circumstances)
  - homeorholdingbranch (default for existing systems with IndependantBranches turned on)

New subroutine:  CanBookBeReturned
Input:  $item hash (from GetItems), and $branchcode
Output: 0 or 1 to indicate "allowed" or not, and an optional message if not allowed.  Message is the 'correct' branchcode
to return the material to

To Test:
1.  Install patch and new syspref
2.  Check that default value of the preference:
    - if IndependantBranches was OFF at install time, should be 'anywhere'
    - if IndependantBranches was ON at install time, should be 'homeorholdingbranch'

Case:  'anywhere'
1.  Checkout a Library A book at Library A.  Return at Library A should be successful
2.  Repeat step 1, returning to Library B.  Return should be successful
3.  Checkout a Library A book at Library B.  Return to A should be successful
4.  Repeat step 3 with Library B and Library C

Case: 'homebranch'
1.  Checkout a Library A book at Library A.  Return at Library A should be successful
2.  Repeat step 1, returning to Library B.  Return should FAIL (returning message to return at A)
3.  Checkout a Library A book at Library B.  Return to Library A should be successful
4.  Repeat step 3 with Library B and Library C.  Both should FAIL (returning message to return at A)

Case: 'holdingbranch'
1.  Checkout a Library A book at Library A.  Return at Library A should be successful
2.  Repeat step 1, returning to Library B.  Return should FAIL (returning message to return at A)
3.  Checkout a Library A book at Library B.  Return to A should FAIL (returning message to return at B)
4.  Repeat step 3 with Library B. Return should be successful
5.  Repeat step 3 with Library C. Return should FAIL (returning message to return at B)

Case: 'homeorholdingbranch'
1.  Checkout a Library A book at Library A.  Return at Library A should be successful
2.  Repeat step 1, returning to Library B.  Return should FAIL (returning message to return at A)
3.  Checkout a Library A book at Library B.  Return to A should be successful
4.  Repeat step 3 with Library B. Return should be successful
5.  Repeat step 3 with Library C. Return should FAIL (returning message to return at A)

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
C4/Circulation.pm
admin/systempreferences.pl
installer/data/mysql/sysprefs.sql
installer/data/mysql/updatedatabase.pl
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref