Bug 29897: Don't use $6 for linkage but build the link instead
[srvgit] / catalogue / moredetail.pl
index 38eab6a..834678e 100755 (executable)
@@ -23,7 +23,7 @@ use Modern::Perl;
 use C4::Koha qw( GetAuthorisedValues );
 use CGI qw ( -utf8 );
 use HTML::Entities;
-use C4::Biblio qw( GetBiblioData GetFrameworkCode GetMarcBiblio );
+use C4::Biblio qw( GetBiblioData GetFrameworkCode );
 use C4::Items qw( GetHostItemsInfo GetItemsInfo );
 use C4::Acquisition qw( GetOrderFromItemnumber GetBasket GetInvoice );
 use C4::Output qw( output_and_exit output_html_with_http_headers );
@@ -55,10 +55,8 @@ $template->param(
 if($query->cookie("holdfor")){ 
     my $holdfor_patron = Koha::Patrons->find( $query->cookie("holdfor") );
     $template->param(
-        holdfor => $query->cookie("holdfor"),
-        holdfor_surname => $holdfor_patron->surname,
-        holdfor_firstname => $holdfor_patron->firstname,
-        holdfor_cardnumber => $holdfor_patron->cardnumber,
+        holdfor        => $query->cookie("holdfor"),
+        holdfor_patron => $holdfor_patron,
     );
 }
 
@@ -115,10 +113,11 @@ for my $itm (@all_items) {
                                ($itemnumber != $itm->{itemnumber}));
 }
 
-my $record=GetMarcBiblio({ biblionumber => $biblionumber });
+my $biblio = Koha::Biblios->find( $biblionumber );
+my $record = $biblio ? $biblio->metadata->record : undef;
 
 output_and_exit( $query, $cookie, $template, 'unknown_biblio')
-    unless $record;
+    unless $biblio && $record;
 
 my $hostrecords;
 # adding items linked via host biblios
@@ -128,8 +127,6 @@ if (@hostitems){
         push (@items,@hostitems);
 }
 
-my $biblio = Koha::Biblios->find( $biblionumber );
-
 my $totalcount=@all_items;
 my $showncount=@items;
 my $hiddencount = $totalcount - $showncount;
@@ -208,14 +205,13 @@ foreach my $item (@items){
         );
 
         if ( my $accountline = $accountlines->next ) {
-            my $payment_offsets = Koha::Account::Offsets->search(
+            my $payment_offsets = $accountline->debit_offsets(
                 {
-                    debit_id  => $accountline->id,
                     credit_id => { '!=' => undef }, # it is not the debit itself
-                    type => { '!=' => [ 'Writeoff', 'Forgiven' ] },
-                    amount => { '<' => 0 }    # credits are negative on the DB
+                    'credit.credit_type_code' =>
+                      { '!=' => [ 'Writeoff', 'Forgiven' ] },
                 },
-                { order_by => { '-desc' => 'created_on' } }
+                { join => 'credit', order_by => { '-desc' => 'created_on' } }
             );
 
             if ($payment_offsets->count) {
@@ -279,14 +275,14 @@ my $some_private_shelves = Koha::Virtualshelves->get_some_shelves(
     {
         borrowernumber => $loggedinuser,
         add_allowed    => 1,
-        category       => 1,
+        public         => 0,
     }
 );
 my $some_public_shelves = Koha::Virtualshelves->get_some_shelves(
     {
         borrowernumber => $loggedinuser,
         add_allowed    => 1,
-        category       => 2,
+        public         => 1,
     }
 );