close security holes in patron search autocompletion
[koha.git] / circ / transferstodo.pl
index ba6b80a..340dc34 100755 (executable)
@@ -1,6 +1,5 @@
 #!/usr/bin/perl
 
-# $Id$
 
 # Copyright 2000-2002 Katipo Communications
 #
@@ -25,7 +24,7 @@ use C4::Output;
 use CGI;
 use C4::Branch; # GetBranches
 use C4::Auth;
-use C4::Date;
+use C4::Dates qw/format_date/;
 use C4::Circulation;
 use C4::Reserves;
 use C4::Members;
@@ -36,6 +35,7 @@ use Date::Calc qw(
 );
 use C4::Koha;
 use C4::Biblio;
+use C4::Items;
 
 my $input = new CGI;
 
@@ -53,12 +53,6 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
 # set the userenv branch
 my $default = C4::Context->userenv->{'branch'};
 
-my @datearr    = localtime( time() );
-my $todaysdate =
-    ( 1900 + $datearr[5] ) . '-'
-  . sprintf( "%0.2d", ( $datearr[4] + 1 ) ) . '-'
-  . sprintf( "%0.2d", $datearr[3] );
-
 my $item = $input->param('itemnumber');
 my $fbr  = $input->param('fbr');
 my $tbr  = $input->param('tbr');
@@ -75,11 +69,11 @@ my @branchesloop;
 foreach my $br ( keys %$branches ) {
     my @reservloop;
     my %branchloop;
-    $branchloop{'branchname'} = $branches->{$br}->{'branchname'};
-    $branchloop{'branchcode'} = $branches->{$br}->{'branchcode'};
     my @getreserves =
       GetReservesToBranch( $branches->{$br}->{'branchcode'} );
     if (@getreserves) {
+        $branchloop{'branchname'} = $branches->{$br}->{'branchname'};
+        $branchloop{'branchcode'} = $branches->{$br}->{'branchcode'};
         foreach my $num (@getreserves) {
             my %getreserv;
             my $gettitle     = GetBiblioFromItemNumber( $num->{'itemnumber'} );
@@ -124,25 +118,17 @@ foreach my $br ( keys %$branches ) {
         if (@reservloop) {
             $branchloop{'reserv'} = \@reservloop;
         }
-
         #              else, we unset the value of the branchcode .
         else {
             $branchloop{'branchcode'} = 0;
         }
     }
-    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')),
 );
 
-print "Content-Type: text/html\n\n", $template->output;
-
+output_html_with_http_headers $input, $cookie, $template->output;