Bug 14610 - Add and update scripts
[koha.git] / svc / holds
index 1db9338..3c3a2b0 100755 (executable)
--- a/svc/holds
+++ b/svc/holds
@@ -24,13 +24,13 @@ use JSON qw(to_json);
 
 use C4::Auth qw(check_cookie_auth);
 use C4::Biblio qw(GetMarcBiblio GetFrameworkCode GetRecordValue );
-use C4::Branch qw(GetBranchName);
 use C4::Charset;
 use C4::Circulation qw(GetTransfers);
 use C4::Context;
 
 use Koha::DateUtils;
 use Koha::Holds;
+use Koha::Libraries;
 
 my $input = new CGI;
 
@@ -79,6 +79,10 @@ while ( my $h = $holds_rs->next() ) {
         $itemtype_limit = $itemtype->{translated_description};
     }
 
+    my $libraries = Koha::Libraries->search({}, { order_by => ['branchname'] })->unblessed;
+    for my $library ( @$libraries ) {
+        $library->{selected} = 1 if $library->{branchcode} eq $h->branchcode();
+    }
     my $hold = {
         DT_RowId       => $h->reserve_id(),
         biblionumber   => $biblionumber,
@@ -86,6 +90,7 @@ while ( my $h = $holds_rs->next() ) {
         author         => $h->biblio()->author(),
         reserve_id     => $h->reserve_id(),
         branchcode     => $h->branch()->branchname(),
+        branches       => $libraries,
         reservedate    => $h->reservedate(),
         expirationdate => $h->expirationdate(),
         suspend        => $h->suspend(),
@@ -134,7 +139,7 @@ while ( my $h = $holds_rs->next() ) {
             $hold->{color}       = 'transferred';
             $hold->{transferred} = 1;
             $hold->{date_sent} = output_pref( dt_from_string($transferred_when) );
-            $hold->{from_branch} = GetBranchName($transferred_from);
+            $hold->{from_branch} = Koha::Libraries->find($transferred_from)->branchname;
         }
         elsif ( $item->holding_branch() && $item->holding_branch()->branchcode() ne
             $h->branch()->branchcode() )