Bug 29697: Replace GetMarcBiblio occurrences with $biblio->metadata->record
[srvgit] / catalogue / moredetail.pl
index 3dca1f4..834678e 100755 (executable)
 
 
 use Modern::Perl;
-use C4::Koha;
+use C4::Koha qw( GetAuthorisedValues );
 use CGI qw ( -utf8 );
 use HTML::Entities;
-use C4::Biblio;
-use C4::Items;
-use C4::Acquisition;
-use C4::Output;
-use C4::Auth;
-use C4::Serials;
-use C4::Search;                # enabled_staff_search_views
+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 );
+use C4::Auth qw( get_template_and_user );
+use C4::Serials qw( CountSubscriptionFromBiblionumber );
+use C4::Search qw( enabled_staff_search_views z3950_search_args );
 
 use Koha::Acquisition::Booksellers;
 use Koha::AuthorisedValues;
 use Koha::Biblios;
-use Koha::DateUtils;
 use Koha::Items;
 use Koha::Patrons;
 
@@ -56,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,
     );
 }
 
@@ -116,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
@@ -129,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;
@@ -209,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) {
@@ -265,6 +260,38 @@ $template->param(count => $data->{'count'},
        C4::Search::enabled_staff_search_views,
 );
 
+# get biblionumbers stored in the cart
+my @cart_list;
+
+if($query->cookie("intranet_bib_list")){
+    my $cart_list = $query->cookie("intranet_bib_list");
+    @cart_list = split(/\//, $cart_list);
+    if ( grep {$_ eq $biblionumber} @cart_list) {
+        $template->param( incart => 1 );
+    }
+}
+
+my $some_private_shelves = Koha::Virtualshelves->get_some_shelves(
+    {
+        borrowernumber => $loggedinuser,
+        add_allowed    => 1,
+        public         => 0,
+    }
+);
+my $some_public_shelves = Koha::Virtualshelves->get_some_shelves(
+    {
+        borrowernumber => $loggedinuser,
+        add_allowed    => 1,
+        public         => 1,
+    }
+);
+
+
+$template->param(
+    add_to_some_private_shelves => $some_private_shelves,
+    add_to_some_public_shelves  => $some_public_shelves,
+);
+
 $template->param(
     ITEM_DATA           => \@items,
     moredetailview      => 1,