Followup C4::Circulation.pm previous commit
[koha.git] / serials / routing-preview.pl
index 19d80f7..d89b28c 100755 (executable)
@@ -4,6 +4,7 @@
 # lets one print out routing slip and create (in this instance) the heirarchy
 # of reserves for the serial
 use strict;
+use warnings;
 use CGI;
 use C4::Koha;
 use C4::Auth;
@@ -18,6 +19,7 @@ use C4::Biblio;
 use C4::Items;
 use C4::Serials;
 use URI::Escape;
+use C4::Branch;
 
 my $query = new CGI;
 my $subscriptionid = $query->param('subscriptionid');
@@ -31,14 +33,14 @@ my $dbh = C4::Context->dbh;
 if($delete){
     delroutingmember($routingid,$subscriptionid);
     my $sth = $dbh->prepare("UPDATE serial SET routingnotes = NULL WHERE subscriptionid = ?");
-    $sth->execute($subscriptionid);    
-    print $query->redirect("routing.pl?subscriptionid=$subscriptionid&op=new");    
+    $sth->execute($subscriptionid);
+    print $query->redirect("routing.pl?subscriptionid=$subscriptionid&op=new");
 }
 
 if($edit){
     print $query->redirect("routing.pl?subscriptionid=$subscriptionid");
 }
-    
+
 my ($routing, @routinglist) = getroutinglist($subscriptionid);
 my $subs = GetSubscription($subscriptionid);
 my ($count,@serials) = GetSerials($subscriptionid);
@@ -47,7 +49,7 @@ my ($template, $loggedinuser, $cookie);
 if($ok){
     # get biblio information....
     my $biblio = $subs->{'biblionumber'};
-    
+
     # get existing reserves .....
     my ($count,$reserves) = GetReservesFromBiblionumber($biblio);
     my $totalcount = $count;
@@ -59,6 +61,7 @@ if($ok){
     my ($count2,@bibitems) = GetBiblioItemByBiblioNumber($biblio);
     my @itemresults = GetItemsInfo($subs->{'biblionumber'}, 'intra');
     my $branch = $itemresults[0]->{'holdingbranch'};
+    my $branchname = GetBranchName($branch);
     my $const = 'o';
     my $notes;
     my $title = $subs->{'bibliotitle'};
@@ -74,8 +77,8 @@ if($ok){
         AddReserve($branch,$routinglist[$i]->{'borrowernumber'},$biblio,$const,\@bibitems,$routinglist[$i]->{'ranking'},$notes,$title);
        }
     }
-    
-    
+
+
     ($template, $loggedinuser, $cookie)
 = get_template_and_user({template_name => "serials/routing-preview-slip.tmpl",
                                query => $query,
@@ -84,7 +87,7 @@ if($ok){
                                flagsrequired => {serials => 1},
                                debug => 1,
                                });
-    $template->param("libraryname"=>C4::Context->preference("LibraryName"));
+    $template->param("libraryname"=>$branchname);
 } else {
     ($template, $loggedinuser, $cookie)
 = get_template_and_user({template_name => "serials/routing-preview.tmpl",
@@ -94,9 +97,8 @@ if($ok){
                                flagsrequired => {serials => 1},
                                debug => 1,
                                });
-}    
+}
 
-# my $firstdate = "$serials[0]->{'serialseq'} ($serials[0]->{'planneddate'})";
 my @results;
 my $data;
 for(my $i=0;$i<$routing;$i++){
@@ -110,13 +112,13 @@ for(my $i=0;$i<$routing;$i++){
 
 my $routingnotes = $serials[0]->{'routingnotes'};
 $routingnotes =~ s/\n/\<br \/\>/g;
-  
+
 $template->param(
     title => $subs->{'bibliotitle'},
     issue => $issue,
     issue_escaped => URI::Escape::uri_escape($issue),
     subscriptionid => $subscriptionid,
-    memberloop => \@results,    
+    memberloop => \@results,
     routingnotes => $routingnotes,
     );