From 346ce1bf087c2226c46db394dc49aa7ecf5a182f Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 20 Jul 2012 11:43:34 -0400 Subject: [PATCH] Bug 8484 - Add ability to choose of lost items are removed from a borrowers record. Adds the system preference ReturnLostItems to control whether setting an item as lost will remove the item from the borrower's record. Important note: this system preference affects misc/cronjobs/longoverdue.pl! Test plan: Apply the patch and let the database update run. Test the process of marking something lost with the ReturnLostItems preference in the default "on" state: - Find an item which is checked out and mark it lost from moredetail.pl - Find an item which is checked out and mark it lost using the batch item modification tool In both cases the item should be removed from the patron's account (checked in) and a fine applied. Next test with the ReturnLostItems preference turned off. The same procedure should result in the item being checked in but the fine applied. Signed-off-by: Owen Leonard Passes the test plan which I made up. Bug 8484 - Add ability to choose if lost items are removed from a borrowers record. - Followup --- C4/Circulation.pm | 4 ++-- catalogue/updateitem.pl | 2 +- installer/data/mysql/sysprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 7 +++++++ .../prog/en/modules/admin/preferences/circulation.pref | 8 ++++++++ misc/cronjobs/longoverdue.pl | 5 +---- tools/batchMod.pl | 2 +- 7 files changed, 21 insertions(+), 8 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index df3245d..5971a40 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -3293,7 +3293,7 @@ sub ReturnLostItem{ sub LostItem{ - my ($itemnumber, $mark_returned, $charge_fee) = @_; + my ( $itemnumber, $charge_fee ) = @_; my $dbh = C4::Context->dbh(); my $sth=$dbh->prepare("SELECT issues.*,items.*,biblio.title @@ -3313,7 +3313,7 @@ sub LostItem{ if $charge_fee; #FIXME : Should probably have a way to distinguish this from an item that really was returned. #warn " $issues->{'borrowernumber'} / $itemnumber "; - MarkIssueReturned($borrowernumber,$itemnumber,undef,undef,$borrower->{'privacy'}) if $mark_returned; + MarkIssueReturned( $borrowernumber, $itemnumber, undef, undef, $borrower->{'privacy'} ) if C4::Context->preference("WhenLostReturnItems"); } } diff --git a/catalogue/updateitem.pl b/catalogue/updateitem.pl index 63514c1..5cd2449 100755 --- a/catalogue/updateitem.pl +++ b/catalogue/updateitem.pl @@ -74,6 +74,6 @@ if (defined $itemnotes) { # i.e., itemnotes parameter passed from form ModItem($item_changes, $biblionumber, $itemnumber); -LostItem($itemnumber, 'MARK RETURNED', 'CHARGE FEE') if $itemlost; +LostItem($itemnumber, 'CHARGE FEE') if $itemlost; print $cgi->redirect("moredetail.pl?biblionumber=$biblionumber&itemnumber=$itemnumber#item$itemnumber"); diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index e8ca401..3e08cff 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -409,6 +409,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('virtualshelves','1','','If ON, enables Lists management','YesNo'), ('WaitingNotifyAtCheckin','0',NULL,'If ON, notify librarians of waiting holds for the patron whose items they are checking in.','YesNo'), ('WebBasedSelfCheck','0',NULL,'If ON, enables the web-based self-check system','YesNo'), +('WhenLostReturnItems', '1', NULL, 'If enabled, items marked as lost will be automatically returned.', 'YesNo'), ('XISBN','0','','Use with FRBRizeEditions. If ON, Koha will use the OCLC xISBN web service in the Editions tab on the detail pages. See: http://www.worldcat.org/affiliate/webservices/xisbn/app.jsp','YesNo'), ('XISBNDailyLimit','999','','The xISBN Web service is free for non-commercial use when usage does not exceed 1000 requests per day','Integer'), ('XSLTDetailsDisplay','default','','Enable XSL stylesheet control over details page display on intranet','Free'), diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index ddcc455..f1caeba 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -7104,6 +7104,13 @@ if ( CheckVersion($DBversion) ) { SetVersion($DBversion); } +$DBversion ="3.13.00.XXX"; +if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { + $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('WhenLostReturnItems', '1', '','If enabled, items marked as lost will be automatically returned.', 'YesNo')"); + print "Upgrade to $DBversion done (Add system preference WhenLostReturnItems)\n"; + SetVersion($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref index 026b7fa..aad1d9d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref @@ -569,3 +569,11 @@ Circulation: yes: Use no: "Don't use" - course reserves + Lost Items Policy: + - + - pref: WhenLostReturnItems + type: choice + choices: + yes: "Check in" + no: "Don't check in" + - items marked as lost that are checked out to a patron. diff --git a/misc/cronjobs/longoverdue.pl b/misc/cronjobs/longoverdue.pl index 159db51..9ca4551 100755 --- a/misc/cronjobs/longoverdue.pl +++ b/misc/cronjobs/longoverdue.pl @@ -50,7 +50,6 @@ GetOptions( 'verbose' => \$verbose, 'quiet' => \$quiet, 'maxdays=s' => \$endrange, - 'mark-returned' => \$mark_returned, ); my $usage = << 'ENDUSAGE'; @@ -77,8 +76,6 @@ This script takes the following parameters : --maxdays Specifies the end of the range of overdue days to deal with (defaults to 366). This value is universal to all lost num days overdue passed. - --mark-returned When an item is marked lost, remove it from the borrowers issued items. - examples : $PERL5LIB/misc/cronjobs/longoverdue.pl --lost 30=1 Would set LOST=1 after 30 days (up to one year), but not charge the account. @@ -165,7 +162,7 @@ foreach my $startrange (sort keys %$lost) { printf ("Due %s: item %5s from borrower %5s to lost: %s\n", $row->{date_due}, $row->{itemnumber}, $row->{borrowernumber}, $lostvalue) if($verbose); if($confirm) { ModItem({ itemlost => $lostvalue }, $row->{'biblionumber'}, $row->{'itemnumber'}); - LostItem($row->{'itemnumber'}, $mark_returned, 'CHARGE FEE') if( $charge && $charge eq $lostvalue); + LostItem($row->{'itemnumber'}, 'CHARGE FEE') if( $charge && $charge eq $lostvalue); } $count++; } diff --git a/tools/batchMod.pl b/tools/batchMod.pl index acb4f0b..7f46902 100755 --- a/tools/batchMod.pl +++ b/tools/batchMod.pl @@ -189,7 +189,7 @@ if ($op eq "action") { UpdateMarcWith( $marcitem, $localmarcitem ); eval{ if ( my $item = ModItemFromMarc( $localmarcitem, $itemdata->{biblionumber}, $itemnumber ) ) { - LostItem($itemnumber, 'MARK RETURNED', 'CHARGE FEE') if $item->{itemlost}; + LostItem($itemnumber, 'CHARGE FEE') if $item->{itemlost}; } }; } -- 1.7.10.4