Bug 16497: (follow-up) Adapt to existing guidelines and RFC
[koha.git] / svc / holds
index 0a6f51d..062109d 100755 (executable)
--- a/svc/holds
+++ b/svc/holds
@@ -30,6 +30,7 @@ use C4::Context;
 
 use Koha::DateUtils;
 use Koha::Holds;
+use Koha::ItemTypes;
 use Koha::Libraries;
 
 my $input = new CGI;
@@ -53,8 +54,8 @@ my $borrowernumber    = $input->param('borrowernumber');
 my $offset            = $input->param('iDisplayStart');
 my $results_per_page  = $input->param('iDisplayLength');
 my $sorting_direction = $input->param('sSortDir_0') || 'desc';
-my $sorting_column    = $sort_columns[ $input->param('iSortCol_0') ]
-  || 'reservedate';
+my $iSortCol          = $input->param('iSortCol_0') // 0;
+my $sorting_column    = $sort_columns[$iSortCol] // 'reservedate';
 
 binmode STDOUT, ":encoding(UTF-8)";
 print $input->header( -type => 'text/plain', -charset => 'UTF-8' );
@@ -75,10 +76,14 @@ while ( my $h = $holds_rs->next() ) {
 
     my $itemtype_limit;
     if ( $h->itemtype ) {
-        my $itemtype = C4::Koha::getitemtypeinfo( $h->itemtype );
-        $itemtype_limit = $itemtype->{translated_description};
+        my $itemtype = Koha::ItemTypes->find( $h->itemtype );
+        $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 +91,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(),
@@ -97,7 +103,8 @@ while ( my $h = $holds_rs->next() ) {
         priority       => $h->priority(),
         itemtype_limit => $itemtype_limit,
         subtitle       => GetRecordValue(
-            'subtitle', GetMarcBiblio($biblionumber),
+            'subtitle',
+            GetMarcBiblio({ biblionumber => $biblionumber }),
             GetFrameworkCode($biblionumber)
         ),
         reservedate_formatted => $h->reservedate() ? output_pref(
@@ -114,11 +121,6 @@ while ( my $h = $holds_rs->next() ) {
         : q{},
     };
 
-    if ( my $e = $h->waiting_expires_on() ) {
-        $hold->{expirationdate} = $e->ymd();
-        $hold->{expirationdate_formatted} = output_pref( { dt => $e, dateonly => 1 });
-    }
-
     $hold->{transfered}     = 0;
     $hold->{not_transfered} = 0;