Bug 11944: use CGI( -utf8 ) everywhere
[srvgit] / C4 / SIP / ILS / Transaction / Checkout.pm
index 38951fc..70fe9cc 100644 (file)
@@ -10,7 +10,7 @@ use strict;
 use POSIX qw(strftime);
 use Sys::Syslog qw(syslog);
 use Data::Dumper;
-use CGI;
+use CGI qw ( -utf8 );
 
 use ILS;
 use ILS::Transaction;
@@ -20,13 +20,11 @@ use C4::Circulation;
 use C4::Members;
 use C4::Reserves qw(ModReserveFill);
 use C4::Debug;
+use parent qw(ILS::Transaction);
 
-use vars qw($VERSION @ISA $debug);
+our $debug;
 
-BEGIN {
-    $VERSION = 3.07.00.049;
-       @ISA = qw(ILS::Transaction);
-}
+our $VERSION = 3.07.00.049;
 
 # Most fields are handled by the Transaction superclass
 my %fields = (
@@ -54,6 +52,7 @@ sub do_checkout {
        my $shelf          = $self->{item}->hold_shelf;
        my $barcode        = $self->{item}->id;
        my $patron_barcode = $self->{patron}->id;
+        my $overridden_duedate; # usually passed as undef to AddIssue
        $debug and warn "do_checkout: patron (" . $patron_barcode . ")";
        my $borrower = $self->{patron}->getmemberdetails_object();
        $debug and warn "do_checkout borrower: . " . Dumper $borrower;
@@ -72,7 +71,7 @@ sub do_checkout {
             $noerror = 0;
         }
     } else {
-        foreach my $confirmation (keys %$needsconfirmation) {
+        foreach my $confirmation (keys %{$needsconfirmation}) {
             if ($confirmation eq 'RENEW_ISSUE'){
                 $self->screen_msg("Item already checked out to you: renewing item.");
             } elsif ($confirmation eq 'RESERVED' or $confirmation eq 'RESERVE_WAITING') {
@@ -86,7 +85,12 @@ sub do_checkout {
             } elsif ($confirmation eq 'ISSUED_TO_ANOTHER') {
                 $self->screen_msg("Item already checked out to another patron.  Please return item for check-in.");
                 $noerror = 0;
-            } elsif ($confirmation eq 'DEBT') {     # don't do anything, it's the minor debt, and alarms fire elsewhere
+            } elsif ($confirmation eq 'DEBT') {
+                $self->screen_msg('Outstanding Fines block issue');
+                $noerror = 0;
+            } elsif ($confirmation eq 'HIGHHOLDS') {
+                $overridden_duedate = $needsconfirmation->{$confirmation}->{returndate};
+                $self->screen_msg('Loan period reduced for high-demand item');
             } else {
                 $self->screen_msg($needsconfirmation->{$confirmation});
                 $noerror = 0;
@@ -118,10 +122,10 @@ sub do_checkout {
         # TODO: adjust representation in $self->item
     }
        # can issue
-       $debug and warn "do_checkout: calling AddIssue(\$borrower,$barcode, undef, 0)\n"
+       $debug and warn "do_checkout: calling AddIssue(\$borrower,$barcode, $overridden_duedate, 0)\n"
                # . "w/ \$borrower: " . Dumper($borrower)
                . "w/ C4::Context->userenv: " . Dumper(C4::Context->userenv);
-       my $due_dt  = AddIssue($borrower, $barcode, undef, 0);
+       my $due_dt  = AddIssue($borrower, $barcode, $overridden_duedate, 0);
     if ($due_dt) {
         $self->{due} = $due_dt->clone();
     } else {