Bug 31095: Remove GetDebarments from Circulation.t
[koha-ffzg.git] / catalogue / ISBDdetail.pl
index 898f57a..d7431e8 100755 (executable)
@@ -36,19 +36,18 @@ This script needs a biblionumber as parameter
 use Modern::Perl;
 
 use HTML::Entities;
-use C4::Auth;
+use C4::Auth qw( get_template_and_user );
 use C4::Context;
-use C4::Output;
+use C4::Output qw( output_html_with_http_headers );
 use CGI qw ( -utf8 );
-use C4::Koha;
-use C4::Biblio;
-use C4::Items;
-use C4::Serials;    # CountSubscriptionFromBiblionumber
-use C4::Search;                # enabled_staff_search_views
+use C4::Biblio qw( GetBiblioData GetISBDView );
+use C4::Serials qw( CountSubscriptionFromBiblionumber GetSubscription GetSubscriptionsFromBiblionumber );
+use C4::Search qw( z3950_search_args enabled_staff_search_views );
 
 use Koha::Biblios;
 use Koha::Patrons;
 use Koha::RecordProcessor;
+use Koha::Virtualshelves;
 
 
 my $query = CGI->new;
@@ -67,18 +66,17 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
     }
 );
 
-if ( not defined $biblionumber ) {
-       # biblionumber invalid -> report and exit
-       $template->param( unknownbiblionumber => 1,
-                                biblionumber => $biblionumber
-       );
-       output_html_with_http_headers $query, $cookie, $template->output;
-       exit;
+my $biblio = Koha::Biblios->find( $biblionumber );
+unless ( $biblionumber && $biblio ) {
+   # biblionumber invalid -> report and exit
+   $template->param( unknownbiblionumber => 1,
+                            biblionumber => $biblionumber
+   );
+   output_html_with_http_headers $query, $cookie, $template->output;
+   exit;
 }
 
-my $record = GetMarcBiblio({
-    biblionumber => $biblionumber,
-    embed_items  => 1 });
+my $record = $biblio->metadata->record({ embed_items => 1 });
 
 if ( not defined $record ) {
        # biblionumber invalid -> report and exit
@@ -89,8 +87,7 @@ if ( not defined $record ) {
        exit;
 }
 
-my $biblio = Koha::Biblios->find( $biblionumber );
-my $framework = GetFrameworkCode( $biblionumber );
+my $framework = $biblio->frameworkcode;
 my $record_processor = Koha::RecordProcessor->new({
     filters => 'ViewPolicy',
     options => {
@@ -109,10 +106,8 @@ my $res = GetISBDView({
 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,
     );
 }
 
@@ -138,6 +133,38 @@ if ($subscriptionsnumber) {
     );
 }
 
+# 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 (
     ISBD                => $res,
     biblionumber        => $biblionumber,