fix for bug 1101: Renew All for the OPAC
[koha.git] / circ / transferstoreceive.pl
old mode 100644 (file)
new mode 100755 (executable)
index 547321e..f3cdd8d
@@ -1,6 +1,5 @@
 #!/usr/bin/perl
 
-# $Id$
 
 # Copyright 2000-2002 Katipo Communications
 #
@@ -25,11 +24,10 @@ use C4::Context;
 use C4::Output;
 use C4::Branch;
 use C4::Auth;
-use C4::Date;
+use C4::Dates qw/format_date/;
 use C4::Biblio;
 use C4::Circulation;
 use C4::Members;
-use C4::Interface::CGI::Output;
 use Date::Calc qw(
   Today
   Add_Delta_Days
@@ -43,12 +41,6 @@ my $input = new CGI;
 
 my $theme = $input->param('theme');    # only used if allowthemeoverride is set
 my $itemnumber = $input->param('itemnumber');
-my $todaysdate = join "-", &Today;
-
-# if we have a resturn of the form to delete the transfer, we launch the subrroutine
-if ($itemnumber) {
-    C4::Circulation::Circ2::DeleteTransfer($itemnumber);
-}
 
 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
     {
@@ -70,12 +62,12 @@ my @branchesloop;
 foreach my $br ( keys %$branches ) {
     my @transferloop;
     my %branchloop;
-    $branchloop{'branchname'} = $branches->{$br}->{'branchname'};
-    $branchloop{'branchcode'} = $branches->{$br}->{'branchcode'};
     my @gettransfers =
       GetTransfersFromTo( $branches->{$br}->{'branchcode'}, $default );
 
     if (@gettransfers) {
+        $branchloop{'branchname'} = $branches->{$br}->{'branchname'};
+        $branchloop{'branchcode'} = $branches->{$br}->{'branchcode'};
         foreach my $num (@gettransfers) {
             my %getransf;
 
@@ -95,15 +87,11 @@ foreach my $br ( keys %$branches ) {
             my $gettitle     = GetBiblioFromItemNumber( $num->{'itemnumber'} );
             my $itemtypeinfo = getitemtypeinfo( $gettitle->{'itemtype'} );
 
-            $getransf{'title'}        = $gettitle->{'title'};
             $getransf{'datetransfer'} = format_date( $num->{'datesent'} );
-            $getransf{'biblionumber'} = $gettitle->{'biblionumber'};
-            $getransf{'itemnumber'}   = $gettitle->{'itemnumber'};
-            $getransf{'barcode'}      = $gettitle->{'barcode'};
-            $getransf{'itemtype'}       = $itemtypeinfo->{'description'};
-            $getransf{'homebranch'}     = $gettitle->{'homebranch'};
-            $getransf{'holdingbranch'}  = $gettitle->{'holdingbranch'};
-            $getransf{'itemcallnumber'} = $gettitle->{'itemcallnumber'};
+            $getransf{'itemtype'} = $itemtypeinfo->{'description'};
+                       foreach (qw(title biblionumber itemnumber barcode homebranch holdingbranch itemcallnumber)) {
+               $getransf{$_} = $gettitle->{$_};
+                       }
 
             #                          we check if we have a reserv for this transfer
             my @checkreserv = GetReservesFromItemnumber($num->{'itemnumber'} );
@@ -125,18 +113,13 @@ foreach my $br ( keys %$branches ) {
       #                If we have a return of reservloop we put it in the branchloop sequence
         $branchloop{'reserv'} = \@transferloop;
     }
-    else {
-
-#      if we don't have a retrun from reservestobranch we unset branchname and branchcode
-        $branchloop{'branchname'} = 0;
-        $branchloop{'branchcode'} = 0;
-    }
-    push( @branchesloop, \%branchloop );
+    push( @branchesloop, \%branchloop ) if %branchloop;
 }
 
 $template->param(
     branchesloop => \@branchesloop,
-    show_date    => format_date($todaysdate),
+    show_date    => format_date(C4::Dates->today('iso')),
+       dateformat    => C4::Context->preference("dateformat"),
 );
 
 output_html_with_http_headers $input, $cookie, $template->output;