From dd5293acb661a48ee3807b5d97b2025ba54ed8a9 Mon Sep 17 00:00:00 2001 From: Meenakshi.R Date: Fri, 6 Jul 2012 10:42:50 +0530 Subject: [PATCH] Bug 7639 - system preference to forgive fines on lost items Forgive fine when an item is set to lost status, fines are forgiven only when syspref ForgiveFineWhenLost is set to yes. Item can be set to lost status from: catalogue/moredetail.pl cataloguing/additem.pl tools/batchMod.pl misc/cronjobs/longoverdue.pl Changed sub C4::Circulation::LostItem to forgive fines on the item depending on the value of syspref ForgiveFineWhenLost. This sub is currently used to return an item and charge a replacement cost. Also added a new syspref in C4::Circulation::LostItem - ChargeReplFeeWhenLost. Replacement fee will now be charged only if this syspref is set to yes. Signed-off-by: Kyle M Hall --- C4/Circulation.pm | 20 ++++++++++++++------ catalogue/updateitem.pl | 2 +- cataloguing/additem.pl | 7 +++++++ installer/data/mysql/sysprefs.sql | 2 ++ installer/data/mysql/updatedatabase.pl | 9 +++++++++ .../en/modules/admin/preferences/circulation.pref | 12 ++++++++++++ misc/cronjobs/longoverdue.pl | 2 +- tools/batchMod.pl | 2 +- 8 files changed, 47 insertions(+), 9 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 063a409..b4ba34e 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -3286,7 +3286,7 @@ sub ReturnLostItem{ sub LostItem{ - my ($itemnumber, $mark_returned, $charge_fee) = @_; + my ($itemnumber, $mark_returned) = @_; my $dbh = C4::Context->dbh(); my $sth=$dbh->prepare("SELECT issues.*,items.*,biblio.title @@ -3298,14 +3298,22 @@ sub LostItem{ my $issues=$sth->fetchrow_hashref(); $sth->finish; - # if a borrower lost the item, add a replacement cost to the their record + # If a borrower lost the item, add a replacement cost to the their record if ( my $borrowernumber = $issues->{borrowernumber} ){ my $borrower = C4::Members::GetMemberDetails( $borrowernumber ); - C4::Accounts::chargelostitem($borrowernumber, $itemnumber, $issues->{'replacementprice'}, "Lost Item $issues->{'title'} $issues->{'barcode'}") - if $charge_fee; - #FIXME : Should probably have a way to distinguish this from an item that really was returned. - #warn " $issues->{'borrowernumber'} / $itemnumber "; + if (C4::Context->preference('ForgiveFineWhenLost')){ + my $exemptfine=1; + my $dropbox=0; + my $fix = _FixOverduesOnReturn($borrowernumber, $itemnumber, $exemptfine, $dropbox); + defined($fix) or warn "_FixOverduesOnReturn($borrowernumber, $itemnumber...) failed!"; # zero is OK, check defined + } + if (C4::Context->preference('ChargeReplFeeWhenLost')){ + C4::Accounts::chargelostitem($borrowernumber, $itemnumber, $issues->{'replacementprice'}, "Lost Item $issues->{'title'} $issues->{'barcode'}"); + #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; } } diff --git a/catalogue/updateitem.pl b/catalogue/updateitem.pl index abc809d..21e3c01 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, 'MARK RETURNED') if $itemlost; print $cgi->redirect("moredetail.pl?biblionumber=$biblionumber&itemnumber=$itemnumber#item$itemnumber"); diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl index c9875ca..5baf2e8 100755 --- a/cataloguing/additem.pl +++ b/cataloguing/additem.pl @@ -27,6 +27,7 @@ use C4::Output; use C4::Biblio; use C4::Items; use C4::Context; +use C4::Circulation; use C4::Koha; # XXX subfield_is_koha_internal_p use C4::Branch; # XXX subfield_is_koha_internal_p use C4::ClassSource; @@ -595,6 +596,12 @@ if ($op eq "additem") { ModItemFromMarc($itemtosave,$biblionumber,$itemnumber); $itemnumber=""; } + my $item = GetItem( $itemnumber ); + my $olditemlost = $item->{'itemlost'}; + my $newitemlost = $itemtosave->subfield('952','1'); + if (($olditemlost eq '0' or $olditemlost eq '' ) and $newitemlost ge '1'){ + LostItem($itemnumber,'MARK RETURNED'); + } $nextop="additem"; } elsif ($op eq "delinkitem"){ my $analyticfield = '773'; diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 7e9f43d..82cfa48 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -28,6 +28,8 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('expandedSearchOption',0,'If ON, set advanced search to be expanded by default',NULL,'YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('FineNotifyAtCheckin',0,'If ON notify librarians of overdue fines on the items they are checking in.',NULL,'YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('FinesLog',1,'If ON, log fines',NULL,'YesNo'); +INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES('ForgiveFineWhenLost','0',NULL,'If ON, Forgives the fines on an item when it is lost.','YesNo'); +INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES('ChargeReplFeeWhenLost','1',NULL,'If ON, Charge the replacement price when a patron loses an item.','YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('hidelostitems',0,'If ON, disables display of\"lost\" items in OPAC.','','YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('hide_marc',0,'If ON, disables display of MARC fields, subfield codes & indicators (still shows data)',NULL,'YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('WaitingNotifyAtCheckin',0,'If ON, notify librarians of waiting holds for the patron whose items they are checking in.',NULL,'YesNo'); diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index bd0fc99..90b2827 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -6020,6 +6020,7 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion ($DBversion); } +<<<<<<< HEAD $DBversion = "3.09.00.063"; if (C4::Context->preference("Version") < TransformToNum($DBversion)) { my $gst_booksellers = $dbh->selectcol_arrayref("SELECT DISTINCT(gstrate) FROM aqbooksellers"); @@ -6347,6 +6348,14 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion($DBversion); } +$DBversion = "3.11.00.XXX"; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('ForgiveFineWhenLost','0',NULL,'If ON, Forgives the fines on an item when it is lost.','YesNo')"); + $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('ChargeReplFeeWhenLost','1',NULL,'If ON, Charge the replacement price when a patron loses an item.','YesNo')"); + print "Upgrade to $DBversion done (Added sysprefs ForgiveFineWhenLost and ChargeReplFeeWhenLost)\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 82c1c02..4afa4cc 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 @@ -482,6 +482,18 @@ Circulation: yes: Refund no: "Don't refund" - lost item fees charged to a borrower when the lost item is returned. + - + - pref: ForgiveFineWhenLost + choices: + yes: Forgive + no: "Don't Forgive" + - the fines on an item when it is lost. + - + - pref: ChargeReplFeeWhenLost + choices: + yes: Charge + no: "Don't Charge" + - the replacement price when a patron loses an item. Self Checkout: - - "Include the following JavaScript on all pages in the web-based self checkout:" diff --git a/misc/cronjobs/longoverdue.pl b/misc/cronjobs/longoverdue.pl index 159db51..0f64712 100755 --- a/misc/cronjobs/longoverdue.pl +++ b/misc/cronjobs/longoverdue.pl @@ -165,7 +165,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'}, $mark_returned) if( $charge && $charge eq $lostvalue); } $count++; } diff --git a/tools/batchMod.pl b/tools/batchMod.pl index 2a87b88..7688015 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, 'MARK RETURNED') if $item->{itemlost}; } }; } -- 1.7.2.5