Add fine amount to display on circ pages.
[koha.git] / circ / circulation.pl
index 3f35aa6..28d0685 100755 (executable)
@@ -92,6 +92,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user (
         flagsrequired   => { circulate => 1 },
     }
 );
+
 my $branches = GetBranches();
 
 my $printers = GetPrinters();
@@ -120,9 +121,6 @@ $printer = C4::Context->userenv->{'branchprinter'};
 my $barcode        = $query->param('barcode') || '';
 
 $barcode = barcodedecode($barcode) if( $barcode && C4::Context->preference('itemBarcodeInputFilter'));
-my $year           = $query->param('year');
-my $month          = $query->param('month');
-my $day            = $query->param('day');
 my $stickyduedate  = $query->param('stickyduedate');
 my $duedatespec    = $query->param('duedatespec');
 my $issueconfirmed = $query->param('issueconfirmed');
@@ -130,6 +128,7 @@ my $cancelreserve  = $query->param('cancelreserve');
 my $organisation   = $query->param('organisations');
 my $print          = $query->param('print');
 my $newexpiry      = $query->param('dateexpiry');
+my $debt_confirmed = $query->param('debt_confirmed') || 0; # Don't show the debt error dialog twice
 
 #set up cookie.....
 # my $branchcookie;
@@ -261,6 +260,8 @@ if ($barcode) {
   my ( $error, $question ) =
     CanBookBeIssued( $borrower, $barcode, $datedue , $inprocess );
   my $noerror = $invalidduedate ? 0 : 1;
+
+  delete $question->{'DEBT'} if ($debt_confirmed);
   foreach my $impossible ( keys %$error ) {
             $template->param(
                 $impossible => $$error{$impossible},
@@ -386,12 +387,12 @@ if ($borrowernumber) {
             my $getbibtype = getitemtypeinfo( $getbibinfo->{'itemtype'} );  # fixme - we should have item-level reserves here ?
             $getreserv{color}           = 'inwait';
             $getreserv{title}           = $getbibinfo->{'title'};
-            $getreserv{waitingposition} = $num_res->{'priority'};
             $getreserv{nottransfered}   = 0;
             $getreserv{itemtype}        = $getbibtype->{'description'};
             $getreserv{author}          = $getbibinfo->{'author'};
           $getreserv{biblionumber}    = $num_res->{'biblionumber'};
         }
+        $getreserv{waitingposition} = $num_res->{'priority'};
         push( @reservloop, \%getreserv );
 
 #         if we have a reserve waiting, initiate waitingreserveloop
@@ -452,7 +453,6 @@ if ($borrower) {
         # ADDED BY JF: NEW ITEMTYPE COUNT DISPLAY
         $issued_itemtypes_count->{ $it->{'itemtype'} }++;
 
-        warn "$todaysdate, $it->{'issuedate'}, $it->{'lastreneweddate'}, $it->{'barcode'}";
         if ( $todaysdate eq $it->{'issuedate'} or $todaysdate eq $it->{'lastreneweddate'} ) {
             push @todaysissues, $it;
         } else {
@@ -523,10 +523,7 @@ my %labels;
 my $CGIselectborrower;
 if ($borrowerslist) {
     foreach (
-        sort {
-                lc $a->{'surname'}
-              . lc $a->{'firstname'} cmp lc $b->{'surname'}
-              . lc $b->{'firstname'}
+        sort {(lc $a->{'surname'} cmp lc $b->{'surname'} ?lc $a->{'surname'} cmp lc $b->{'surname'}:lc $a->{'firstname'} cmp lc $b->{'firstname'})
         } @$borrowerslist
       )
     {
@@ -571,6 +568,7 @@ foreach $flag ( sort keys %$flags ) {
             $template->param(
                 charges    => 'true',
                 chargesmsg => $flags->{'CHARGES'}->{'message'},
+                chargesamount => $flags->{'CHARGES'}->{'amount'},
                 charges_is_blocker => 1
             );
         }
@@ -586,7 +584,8 @@ foreach $flag ( sort keys %$flags ) {
             $template->param(
                 charges    => 'true',
                 flagged    => 1,
-                chargesmsg => $flags->{'CHARGES'}->{'message'}
+                chargesmsg => $flags->{'CHARGES'}->{'message'},
+                chargesamount => $flags->{'CHARGES'}->{'amount'},
             );
         }
         if ( $flag eq 'CREDITS' ) {
@@ -673,13 +672,14 @@ $template->param(
     dateexpiry        => format_date($newexpiry),
     expiry            => format_date($borrower->{'dateexpiry'}),
     categorycode      => $borrower->{'categorycode'},
-    categoryname      => $borrowercategory->{description},
+    categoryname      => $borrower->{description},
     address           => $borrower->{'address'},
     address2          => $borrower->{'address2'},
     email             => $borrower->{'email'},
     emailpro          => $borrower->{'emailpro'},
     borrowernotes     => $borrower->{'borrowernotes'},
     city              => $borrower->{'city'},
+    zipcode          => $borrower->{'zipcode'},
     phone             => $borrower->{'phone'} || $borrower->{'mobile'},
     cardnumber        => $borrower->{'cardnumber'},
     amountold         => $amountold,
@@ -713,9 +713,10 @@ $template->param( picture => 1 ) if $picture;
 
 
 $template->param(
+    debt_confirmed           => $debt_confirmed,
     SpecifyDueDate           => C4::Context->preference("SpecifyDueDate"),
     CircAutocompl            => C4::Context->preference("CircAutocompl"),
-       dateformat            => C4::Context->preference("dateformat"),
+    dateformat               => C4::Context->preference("dateformat"),
     DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
 );
 output_html_with_http_headers $query, $cookie, $template->output;