Bug 7534: (QA follow-up) Use Koha.Preference template plugin to fetch the pref's...
[koha.git] / opac / opac-ISBDdetail.pl
index 7af7410..fe69564 100755 (executable)
@@ -52,6 +52,8 @@ use C4::Reserves;
 use C4::Acquisition;
 use C4::Serials;    # uses getsubscriptionfrom biblionumber
 use C4::Koha;
+use Koha::IssuingRules;
+use Koha::Items;
 use Koha::ItemTypes;
 use Koha::Patrons;
 use Koha::RecordProcessor;
@@ -79,8 +81,6 @@ if(my $cart_list = $query->cookie("bib_list")){
     }
 }
 
-$template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) );
-
 my $marcflavour      = C4::Context->preference("marcflavour");
 
 my @items = GetItemsInfo($biblionumber);
@@ -171,6 +171,7 @@ my $res = GetISBDView({
 my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
 my $patron = Koha::Patrons->find( $loggedinuser );
 for my $itm (@items) {
+    my $item = Koha::Items->find( $itm->{itemnumber} );
     $norequests = 0
       if $norequests
         && !$itm->{'withdrawn'}
@@ -179,13 +180,16 @@ for my $itm (@items) {
         && !$itemtypes->{$itm->{'itype'}}->{notforloan}
         && $itm->{'itemnumber'};
 
-    $allow_onshelf_holds = C4::Reserves::OnShelfHoldsAllowed( $itm, ( $patron ? $patron->unblessed : {} ) )
+    $allow_onshelf_holds = Koha::IssuingRules->get_onshelfholds_policy( { item => $item, patron => $patron } )
       unless $allow_onshelf_holds;
 }
 
+if( $allow_onshelf_holds || CountItemsIssued($biblionumber) || $biblio->has_items_waiting_or_intransit ) {
+    $template->param( ReservableItems => 1 );
+}
+
 $template->param(
     RequestOnOpac       => C4::Context->preference("RequestOnOpac"),
-    AllowOnShelfHolds   => $allow_onshelf_holds,
     norequests   => $norequests,
     ISBD         => $res,
     biblio       => $biblio,
@@ -213,4 +217,11 @@ if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){
     $template->param('OPACSearchForTitleIn' => $search_for_title);
 }
 
+if( C4::Context->preference('ArticleRequests') ) {
+    my $artreqpossible = $patron
+        ? $biblio->can_article_request( $patron )
+        : Koha::ItemTypes->find($biblio->itemtype)->may_article_request;
+    $template->param( artreqpossible => $artreqpossible );
+}
+
 output_html_with_http_headers $query, $cookie, $template->output;