Bug 21301: Remove patron informations in issues for GetRecords ILS-DI service
[koha-ffzg.git] / C4 / ILSDI / Services.pm
index 0416f5c..30a03bc 100644 (file)
@@ -228,7 +228,14 @@ sub GetRecords {
         # Get most of the needed data
         my $biblioitemnumber = $biblioitem->{'biblioitemnumber'};
         my $holds  = $biblio->current_holds->unblessed;
-        my $issues           = GetBiblioIssues($biblionumber);
+        my $checkouts = Koha::Checkouts->search(
+            { biblionumber => $biblionumber },
+            {
+                join => 'item',
+                '+select' => ['item.barcode'],
+                '+as'     => ['barcode'],
+            }
+        )->unblessed;
         my @items            = $biblio->items->as_list;
 
         $biblioitem->{items}->{item} = [];
@@ -246,6 +253,20 @@ sub GetRecords {
             $item{'homebranchname'}    = $home_library    ? $home_library->branchname    : '';
             $item{'holdingbranchname'} = $holding_library ? $holding_library->branchname : '';
 
+            if ($item->location) {
+                my $authorised_value = Koha::AuthorisedValues->find_by_koha_field({ kohafield => 'items.location', authorised_value => $item->location });
+                if ($authorised_value) {
+                    $item{location_description} = $authorised_value->opac_description;
+                }
+            }
+
+            if ($item->itype) {
+                my $itemtype = Koha::ItemTypes->find($item->itype);
+                if ($itemtype) {
+                    $item{itype_description} = $itemtype->description;
+                }
+            }
+
             my $transfer = $item->get_transfer;
             if ($transfer) {
                 $item{transfer} = {
@@ -260,7 +281,7 @@ sub GetRecords {
 
         # Hashref building...
         $biblioitem->{'reserves'}->{'reserve'} = $holds;
-        $biblioitem->{'issues'}->{'issue'}     = $issues;
+        $biblioitem->{'issues'}->{'issue'}     = $checkouts;
 
         push @records, $biblioitem;
     }
@@ -506,8 +527,18 @@ sub GetPatronInfo {
     if ( $show_attributes && $show_attributes eq "1" ) {
         # FIXME Regression expected here, we do not retrieve the same field as previously
         # Waiting for answer on bug 14257 comment 15
-        my $attrs = $patron->get_extended_attributes->search({ opac_display => 1 })->unblessed;
-        $borrower->{'attributes'} = $attrs;
+        $borrower->{'attributes'} = [
+            map {
+                $_->type->opac_display
+                  ? {
+                    %{ $_->unblessed },
+                    %{ $_->type->unblessed },
+                    value             => $_->attribute,   # Backward compatibility
+                    value_description => $_->description, # Awkward retro-compability...
+                  }
+                  : ()
+            } $patron->extended_attributes->search
+        ];
     }
 
     # Add is expired information
@@ -645,7 +676,7 @@ sub RenewLoan {
 
     # Add renewal if possible
     my @renewal = CanBookBeRenewed( $borrowernumber, $itemnumber );
-    if ( $renewal[0] ) { AddRenewal( $borrowernumber, $itemnumber ); }
+    if ( $renewal[0] ) { AddRenewal( $borrowernumber, $itemnumber, undef, undef, undef, undef, 0 ); }
 
     my $issue = $item->checkout;
     return unless $issue; # FIXME should be handled
@@ -746,7 +777,7 @@ sub HoldTitle {
     my $priority= C4::Reserves::CalculatePriority( $biblionumber );
     AddReserve(
         {
-            branch           => $branch,
+            branchcode       => $branch,
             borrowernumber   => $borrowernumber,
             biblionumber     => $biblionumber,
             priority         => $priority,
@@ -842,7 +873,7 @@ sub HoldItem {
     my $priority = C4::Reserves::CalculatePriority($biblionumber);
     AddReserve(
         {
-            branch           => $branch,
+            branchcode       => $branch,
             borrowernumber   => $borrowernumber,
             biblionumber     => $biblionumber,
             priority         => $priority,