adding 'exempt fine on return' option.
authorRyan Higgins <rch@liblime.com>
Thu, 27 Dec 2007 22:47:25 +0000 (16:47 -0600)
committerJoshua Ferraro <jmf@liblime.com>
Thu, 27 Dec 2007 23:22:45 +0000 (17:22 -0600)
Signed-off-by: Chris Cormack <crc@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
C4/Circulation.pm
circ/returns.pl
installer/data/mysql/en/mandatory/sysprefs.sql
koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css
koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tmpl

index 156158a..eebbe41 100644 (file)
@@ -1079,12 +1079,13 @@ warn "in get loan lenght $borrowertype $itemtype $branchcode ";
 =head2 AddReturn
 
 ($doreturn, $messages, $iteminformation, $borrower) =
-    &AddReturn($barcode, $branch);
+    &AddReturn($barcode, $branch, $exemptfine);
 
 Returns a book.
 
 C<$barcode> is the bar code of the book being returned. C<$branch> is
-the code of the branch where the book is being returned.
+the code of the branch where the book is being returned.  C<$exemptfine>
+indicates that overdue charges for the item will not be applied.
 
 C<&AddReturn> returns a list of four items:
 
@@ -1127,7 +1128,7 @@ patron who last borrowed the book.
 =cut
 
 sub AddReturn {
-    my ( $barcode, $branch ) = @_;
+    my ( $barcode, $branch, $exemptfine ) = @_;
     my $dbh      = C4::Context->dbh;
     my $messages;
     my $doreturn = 1;
@@ -1233,7 +1234,7 @@ sub AddReturn {
         }
         # fix up the overdues in accounts...
         FixOverduesOnReturn( $borrower->{'borrowernumber'},
-            $iteminformation->{'itemnumber'} );
+            $iteminformation->{'itemnumber'}, $exemptfine );
     
     # find reserves.....
     #     if we don't have a reserve with the status W, we launch the Checkreserves routine
@@ -1275,7 +1276,7 @@ sub AddReturn {
 
 =head2 FixOverduesOnReturn
 
-    &FixOverduesOnReturn($brn,$itm);
+    &FixOverduesOnReturn($brn,$itm, $exemptfine);
 
 C<$brn> borrowernumber
 
@@ -1286,7 +1287,7 @@ internal function, called only by AddReturn
 =cut
 
 sub FixOverduesOnReturn {
-    my ( $borrowernumber, $item ) = @_;
+    my ( $borrowernumber, $item, $exemptfine ) = @_;
     my $dbh = C4::Context->dbh;
 
     # check for overdue fine
@@ -1297,14 +1298,15 @@ sub FixOverduesOnReturn {
     $sth->execute( $borrowernumber, $item );
 
     # alter fine to show that the book has been returned
-    if ( my $data = $sth->fetchrow_hashref ) {
-        my $usth =
-          $dbh->prepare(
-"UPDATE accountlines SET accounttype='F' WHERE (borrowernumber = ?) AND (itemnumber = ?) AND (accountno = ?)"
-          );
-        $usth->execute( $borrowernumber, $item, $data->{'accountno'} );
+   my $data; 
+       if ($data = $sth->fetchrow_hashref) {
+        my $uquery =($exemptfine)? "update accountlines set accounttype='FFOR', amountoutstanding=0":"update accountlines set accounttype='F' ";
+               $uquery .= " where (borrowernumber = ?) and (itemnumber = ?) and (accountno = ?)";
+        my $usth = $dbh->prepare($uquery);
+        $usth->execute($borrowernumber,$item ,$data->{'accountno'});
         $usth->finish();
     }
+
     $sth->finish();
     return;
 }
index 4dea59f..b728496 100755 (executable)
@@ -59,7 +59,7 @@ my $printers = GetPrinters();
 
 #my $branch  = C4::Context->userenv?C4::Context->userenv->{'branch'}:"";
 my $printer = C4::Context->userenv?C4::Context->userenv->{'branchprinter'}:"";
-
+my $overduecharges = (C4::Context->preference('finesMode') && C4::Context->preference('finesMode') ne 'off');
 #
 # Some code to handle the error if there is no branch or printer setting.....
 #
@@ -153,6 +153,7 @@ my $returned = 0;
 my $messages;
 my $issueinformation;
 my $barcode = $query->param('barcode');
+my $exemptfine = $query->param('exemptfine');
 
 my $dotransfer = $query->param('dotransfer');
 if ($dotransfer){
@@ -170,7 +171,7 @@ if ($barcode) {
 # save the return
 #
     ( $returned, $messages, $issueinformation, $borrower ) =
-      AddReturn( $barcode, C4::Context->userenv->{'branch'} );
+      AddReturn( $barcode, C4::Context->userenv->{'branch'}, $exemptfine );
     # get biblio description
     my $biblio = GetBiblioFromItemNumber($issueinformation->{'itemnumber'});
     $template->param(
@@ -544,6 +545,8 @@ $template->param(
     branchname              => $branches->{C4::Context->userenv->{'branch'}}->{'branchname'},
     printer                 => $printer,
     errmsgloop              => \@errmsgloop,
+    exemptfine              => $exemptfine,
+       overduecharges          => $overduecharges,
 );
 
 # actually print the page!
index 7d87a80..d6c39c2 100644 (file)
@@ -148,7 +148,7 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('emailLibrarianWhenHoldIsPlaced',0,'If ON, emails the librarian whenever a hold is placed',NULL,'YesNo');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('holdCancelLength','','Specify how many days before a hold is canceled',NULL,'free');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('libraryAddress','','The address to use for printing receipts, overdues, etc. if different than physical address',NULL,'free');
-INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('finesMode','test','Choose the fines mode, test or production','test|production','Choice');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('finesMode','test','Choose the fines mode, \'off\', \'test\' (emails admin report) or \'production\' (accrue overdue fines).  Requires accruefines cronjob.','off|test|production','Choice');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('globalDueDate','','If set, allows a global static due date for all checkouts',NULL,'free');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('itemBarcodeInputFilter','','If set, allows specification of a item barcode input filter','cuecat','Choice');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('singleBranchMode',0,'Operate in Single-branch mode, hide branch selection in the OPAC',NULL,'YesNo');
index f023494..8fdcb4a 100644 (file)
@@ -903,6 +903,11 @@ div.error {
        margin : 1em;
 }
 
+input.alert {
+       background-color : #FFFF99;
+       border-color: #900;
+}
+
 ol.bibliodetails {
        float: left;
        margin : 0 0 1em 1em;
index d1088b9..33d4827 100644 (file)
         <!-- /TMPL_IF -->
     </div>
 <!-- /TMPL_IF -->
-
-    <form method="post" action="/cgi-bin/koha/circ/returns.pl">
+    <div id="exemptfines" class="error" style="display:none;">
+        <p>Fines for returned items are forgiven.</p>
+    </div>
+    <div class="details" >
+    <form method="post" action="/cgi-bin/koha/circ/returns.pl" >
             <fieldset><legend>Check In</legend>
-            <label for="barcode">Enter item barcode: </label><input name="barcode" id="barcode" size="14" maxlength="14" class="focus" /> <input type="submit" value="Submit" />
+            <label for="barcode">Enter item barcode: </label>
+<input name="barcode" id="barcode" size="14" maxlength="14" class="focus" <!-- TMPL_IF NAME="overduecharges" -->onfocus="if(this.form.exemptcheck.checked == true) {this.className='alert'} else {this.className='focus'};" onblur="this.className='unfocus'"  <!-- /TMPL_IF --> />
+            <input type="submit" class="submit" value="Submit" />
             <!-- TMPL_LOOP Name="inputloop" -->
                 <input type="hidden" name="ri-<!-- TMPL_VAR Name="counter" -->" value="<!-- TMPL_VAR Name="barcode" -->" />
                 <input type="hidden" name="dd-<!-- TMPL_VAR Name="counter" -->" value="<!-- TMPL_VAR Name="duedate" -->" />
                 <input type="hidden" name="bn-<!-- TMPL_VAR Name="counter" -->" value="<!-- TMPL_VAR Name="borrowernumber" -->" />
             <!-- /TMPL_LOOP -->
+                <!-- TMPL_IF NAME="overduecharges" --><label for="exemptfine" <!-- TMPL_IF NAME="exemptfine" --> class="error" <!-- /TMPL_IF -->>Forgive Overdue charges on this item</label>
+                <input type="checkbox" id='exemptcheck' name="exemptfine" value="exemptfine" 
+                               <!-- TMPL_IF NAME="exemptfine" --> checked <!-- /TMPL_IF --> onchange=" if (this.checked == true) { this.form.barcode.className='alert'; document.getElementById('exemptfines').style.display='block';} else { this.form.barcode.className='unfocus';document.getElementById('exemptfines').style.display='none'; } this.form.barcode.focus(); return false;" />
+<!-- /TMPL_IF -->
             </fieldset>
         </form>