Bug 11182: get rid of some warnings in circulation
authorSrdjan <srdjan@catalyst.net.nz>
Fri, 1 Nov 2013 07:17:40 +0000 (20:17 +1300)
committerGalen Charlton <gmc@esilibrary.com>
Tue, 29 Apr 2014 17:57:46 +0000 (17:57 +0000)
TEST PLAN
---------
 1) Log into staff client
 2) Koha administration
 3) Global system preferences
 4) Circulation
 5) Make sure FineNotifyAtCheckin is set to Notify.
 6) Check out tab
 7) Type patron's name and click 'Submit'
 8) Select patron if required
 9) Check out an item, but set the due date to be overdue.
10) Check in the overdue item.
11) Check the error log
     $ cat ~/koha-dev/var/log/koha-error_log
     NOTE: only the warnings from lines 269 and 540 in returns.pl
           are the ones to note.
12) Apply this patch
13) Repeat steps 6 through 11, there should no new
    warnings related to lines 269 or 540 from returns.pl.

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
circ/circulation.pl
circ/returns.pl

index 70f89d3..3459df5 100755 (executable)
@@ -485,7 +485,7 @@ sub build_issue_data {
         ($it->{'charge'}, $it->{'itemtype_charge'}) = GetIssuingCharges(
             $it->{'itemnumber'}, $it->{'borrowernumber'}
         );
-        $it->{'charge'} = sprintf("%.2f", $it->{'charge'});
+        $it->{'charge'} = sprintf("%.2f", $it->{'charge'}) if defined $it->{'charge'};
         my ($can_renew, $can_renew_error) = CanBookBeRenewed( 
             $it->{'borrowernumber'},$it->{'itemnumber'}
         );
index 208bb71..cb5ccf1 100755 (executable)
@@ -49,7 +49,8 @@ use Koha::Calendar;
 
 my $query = new CGI;
 
-if (!C4::Context->userenv){
+my $userenv = C4::Context->userenv;
+if (!$userenv){
     my $sessionID = $query->cookie("CGISESSID");
     my $session = get_session($sessionID);
     if ($session->param('branch') eq 'NO_LIBRARY_SET'){
@@ -74,11 +75,10 @@ my ( $template, $librarian, $cookie ) = get_template_and_user(
 #Global vars
 my $branches = GetBranches();
 my $printers = GetPrinters();
+my $userenv_branch = $userenv->{'branch'} // '';
+my $printer = $userenv->{'branchprinter'} // '';
 
-my $printer = C4::Context->userenv ? C4::Context->userenv->{'branchprinter'} : "";
 my $overduecharges = (C4::Context->preference('finesMode') && C4::Context->preference('finesMode') ne 'off');
-
-my $userenv_branch = C4::Context->userenv->{'branch'} || '';
 #
 # Some code to handle the error if there is no branch or printer setting.....
 #
@@ -274,7 +274,7 @@ if ($barcode) {
 
         if ( C4::Context->preference("FineNotifyAtCheckin") ) {
             my ( $od, $issue, $fines ) = GetMemberIssuesAndFines( $borrower->{'borrowernumber'} );
-            if ($fines > 0) {
+            if ($fines && $fines > 0) {
                 $template->param( fines => sprintf("%.2f",$fines) );
                 $template->param( fineborrowernumber => $borrower->{'borrowernumber'} );
             }
@@ -544,11 +544,18 @@ foreach ( sort { $a <=> $b } keys %returneditems ) {
     }
     push @riloop, \%ri;
 }
+my ($genbrname, $genprname);
+if (my $b = $branches->{$userenv_branch}) {
+    $genbrname = $b->{'branchname'};
+}
+if (my $p = $printers->{$printer}) {
+    $genprname = $p->{'printername'};
+}
 $template->param(
     riloop         => \@riloop,
-    genbrname      => $branches->{$userenv_branch}->{'branchname'},
-    genprname      => $printers->{$printer}->{'printername'},
-    branchname     => $branches->{$userenv_branch}->{'branchname'},
+    genbrname      => $genbrname,
+    genprname      => $genprname,
+    branchname     => $genbrname,
     printer        => $printer,
     errmsgloop     => \@errmsgloop,
     exemptfine     => $exemptfine,