(bug #3058) show items that are excluded of loan in search results
authorNahuel ANGELINETTI <nahuel.angelinetti@biblibre.com>
Wed, 25 Mar 2009 16:34:31 +0000 (17:34 +0100)
committerHenri-Damien LAURENT <henridamien.laurent@biblibre.com>
Tue, 26 May 2009 19:15:24 +0000 (21:15 +0200)
This patchs show all items that are available for reading to the library but excluded of loan.
And don't show them as same way as "damaged" or other "not for loan" status.

C4/Search.pm
koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tmpl
koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tmpl

index 513a7f8..988a7a2 100644 (file)
@@ -1349,15 +1349,18 @@ s/\[(.?.?.?.?)$tagsubf(.*?)]/$1$subfieldvalue$2\[$1$tagsubf$2]/g;
         # Setting item statuses for display
         my @available_items_loop;
         my @onloan_items_loop;
+        my @notforloan_items_loop;
         my @other_items_loop;
 
         my $available_items;
         my $onloan_items;
+        my $notforloan_items;
         my $other_items;
 
         my $ordered_count         = 0;
         my $available_count       = 0;
         my $onloan_count          = 0;
+        my $notforloan_count      = 0;
         my $longoverdue_count     = 0;
         my $other_count           = 0;
         my $wthdrawn_count        = 0;
@@ -1456,18 +1459,37 @@ s/\[(.?.?.?.?)$tagsubf(.*?)]/$1$subfieldvalue$2\[$1$tagsubf$2]/g;
                     $itemdamaged_count++     if $item->{damaged};
                     $item_in_transit_count++ if $transfertwhen ne '';
                     $item->{status} = $item->{wthdrawn} . "-" . $item->{itemlost} . "-" . $item->{damaged} . "-" . $item->{notforloan};
-                    $other_count++;
 
                                        my $key = $prefix . $item->{status};
+                                       
                                        foreach (qw(wthdrawn itemlost damaged branchname itemcallnumber)) {
-                       $other_items->{$key}->{$_} = $item->{$_};
+                                           if($item->{notforloan} == 1){
+                                               $notforloan_items->{$key}->{$_} = $item->{$_};
+                                           }else{
+                          $other_items->{$key}->{$_} = $item->{$_};
+                                           }
                                        }
-                    $other_items->{$key}->{intransit} = ($transfertwhen ne '') ? 1 : 0;
-                                       $other_items->{$key}->{notforloan} = GetAuthorisedValueDesc('','',$item->{notforloan},'','',$notforloan_authorised_value) if $notforloan_authorised_value;
-                                       $other_items->{$key}->{count}++ if $item->{$hbranch};
-                                       $other_items->{$key}->{location} = $shelflocations->{ $item->{location} };
-                                       $other_items->{$key}->{imageurl} = getitemtypeimagelocation( 'opac', $itemtypes{ $item->{itype} }->{imageurl} );
-                                       $other_items->{$key}->{barcode} = $item->{barcode};
+
+                                       if($item->{notforloan} == 1){
+                        $notforloan_count++;
+
+                        $notforloan_items->{$key}->{intransit} = ($transfertwhen ne '') ? 1 : 0;
+                                       $notforloan_items->{$key}->{notforloan} = GetAuthorisedValueDesc('','',$item->{notforloan},'','',$notforloan_authorised_value) if $notforloan_authorised_value;
+                                       $notforloan_items->{$key}->{count}++ if $item->{$hbranch};
+                                       $notforloan_items->{$key}->{location} = $shelflocations->{ $item->{location} };
+                                       $notforloan_items->{$key}->{imageurl} = getitemtypeimagelocation( 'opac', $itemtypes{ $item->{itype} }->{imageurl} );
+                                       $notforloan_items->{$key}->{barcode} = $item->{barcode};
+                    }else{
+                        $other_count++;
+                                       
+                        $other_items->{$key}->{intransit} = ($transfertwhen ne '') ? 1 : 0;
+                                       $other_items->{$key}->{notforloan} = GetAuthorisedValueDesc('','',$item->{notforloan},'','',$notforloan_authorised_value) if $notforloan_authorised_value;
+                                       $other_items->{$key}->{count}++ if $item->{$hbranch};
+                                       $other_items->{$key}->{location} = $shelflocations->{ $item->{location} };
+                                       $other_items->{$key}->{imageurl} = getitemtypeimagelocation( 'opac', $itemtypes{ $item->{itype} }->{imageurl} );
+                                       $other_items->{$key}->{barcode} = $item->{barcode};
+                    }
+
                 }
                 # item is available
                 else {
@@ -1482,7 +1504,7 @@ s/\[(.?.?.?.?)$tagsubf(.*?)]/$1$subfieldvalue$2\[$1$tagsubf$2]/g;
                 }
             }
         }    # notforloan, item level and biblioitem level
-        my ( $availableitemscount, $onloanitemscount, $otheritemscount );
+        my ( $availableitemscount, $onloanitemscount, $notforloanitemscount,$otheritemscount );
         $maxitems =
           ( C4::Context->preference('maxItemsinSearchResults') )
           ? C4::Context->preference('maxItemsinSearchResults') - 1
@@ -1495,6 +1517,10 @@ s/\[(.?.?.?.?)$tagsubf(.*?)]/$1$subfieldvalue$2\[$1$tagsubf$2]/g;
             (++$otheritemscount > $maxitems) and last;
             push @other_items_loop, $other_items->{$key};
         }
+        for my $key ( sort keys %$notforloan_items ) {
+            (++$notforloanitemscount > $maxitems) and last;
+            push @notforloan_items_loop, $notforloan_items->{$key};
+        }
         for my $key ( sort keys %$available_items ) {
             (++$availableitemscount > $maxitems) and last;
             push @available_items_loop, $available_items->{$key}
@@ -1507,18 +1533,19 @@ s/\[(.?.?.?.?)$tagsubf(.*?)]/$1$subfieldvalue$2\[$1$tagsubf$2]/g;
         }
 
         # last check for norequest : if itemtype is notforloan, it can't be reserved either, whatever the items
-        $can_place_holds = 0
-          if $itemtypes{ $oldbiblio->{itemtype} }->{notforloan};
+        $can_place_holds = 0 if $itemtypes{ $oldbiblio->{itemtype} }->{notforloan};
         $oldbiblio->{norequests} = 1 unless $can_place_holds;
         $oldbiblio->{itemsplural}          = 1 if $items_count > 1;
         $oldbiblio->{items_count}          = $items_count;
         $oldbiblio->{available_items_loop} = \@available_items_loop;
+        $oldbiblio->{notforloan_items_loop}= \@notforloan_items_loop;
         $oldbiblio->{onloan_items_loop}    = \@onloan_items_loop;
         $oldbiblio->{other_items_loop}     = \@other_items_loop;
         $oldbiblio->{availablecount}       = $available_count;
         $oldbiblio->{availableplural}      = 1 if $available_count > 1;
         $oldbiblio->{onloancount}          = $onloan_count;
         $oldbiblio->{onloanplural}         = 1 if $onloan_count > 1;
+        $oldbiblio->{notforloancount}      = $notforloan_count;
         $oldbiblio->{othercount}           = $other_count;
         $oldbiblio->{otherplural}          = 1 if $other_count > 1;
         $oldbiblio->{wthdrawncount}        = $wthdrawn_count;
index 4001dfe..dc75841 100644 (file)
@@ -310,6 +310,22 @@ $(window).load(function() {
                                     <span class="unavailable">No items available</span>
                                     <!-- /TMPL_IF -->
 
+                                                                       <!-- TMPL_IF NAME="notforloan_items_loop" -->
+                                                                               <!-- TMPL_IF name="notforloancount" -->
+                                                                                       <!-- TMPL_VAR name="notforloancount" --> not for loan:
+                                                                               <!-- /TMPL_IF -->
+                                                                               <ul>
+                                                                               <!-- TMPL_LOOP NAME="notforloan_items_loop" -->
+                                                                                       <!-- TMPL_IF NAME="noItemTypeImages" --><li><!-- TMPL_ELSE --><!-- TMPL_IF NAME="item-level_itypes" --><!-- TMPL_IF name="imageurl" --><li style="list-style: none; list-style-type: none;"><img src="<!-- TMPL_VAR name="imageurl" -->" title="<!-- TMPL_VAR NAME="description" -->"/><!-- TMPL_ELSE --><li><!-- /TMPL_IF --><!-- TMPL_ELSE --><li><!-- /TMPL_IF --><!-- /TMPL_IF -->
+                                               <!-- TMPL_IF NAME="branchname" --><!-- TMPL_VAR NAME="branchname" --><!-- /TMPL_IF -->
+                                               <!-- TMPL_IF NAME="location" --><!-- TMPL_VAR NAME="location" --><!-- /TMPL_IF -->
+                                               <!-- TMPL_IF NAME="itemcallnumber" -->[<a href="/cgi-bin/koha/catalogue/search.pl?q=callnum:<!-- TMPL_VAR NAME="itemcallnumber" ESCAPE="URL" -->"><!-- TMPL_VAR NAME="itemcallnumber" --></a>]<!-- /TMPL_IF -->
+                                               <!-- TMPL_IF NAME="barcode" -->(<!-- TMPL_VAR NAME="barcode" -->)<!-- /TMPL_IF -->
+                                               (<!-- TMPL_VAR NAME="count" -->)</li>
+                                                                               <!-- /TMPL_LOOP -->
+                                                                               </ul>
+                                                                       <!-- /TMPL_IF -->
+
                                    <!-- TMPL_IF NAME="onloan_items_loop" -->
                                    <span class="status"><!-- TMPL_IF NAME="onloancount" --><!-- TMPL_VAR NAME="onloancount" --><!-- /TMPL_IF --> on loan:</span>
                                     <ul>
index 0a7499d..93da70e 100644 (file)
@@ -272,6 +272,31 @@ $(document).ready(function(){
                     <!-- TMPL_IF NAME="orderedcount" --> On order (<!-- TMPL_VAR NAME="orderedcount" -->),<!-- /TMPL_IF -->
                     <!-- TMPL_IF NAME="intransitcount" --> In transit (<!-- TMPL_VAR NAME="intransitcount" -->),<!-- /TMPL_IF -->
                     </span>
+                    <!-- TMPL_IF NAME="notforloan_items_loop" --> 
+                            <br />
+                               <span class="unavailable"><strong>Not for loan :</strong></span>
+                               <span class="unavailable">
+                                       <!-- TMPL_LOOP NAME="notforloan_items_loop" -->
+                                               <!-- TMPL_IF name="OPACItemsResultsDisplay" -->
+                                                                               <!-- TMPL_IF NAME="singleBranchMode" -->
+                                                               <!-- TMPL_VAR NAME="location" -->
+                                                       <!-- TMPL_ELSE -->
+                                                               <!-- TMPL_VAR NAME="branchname" -->
+                                                       <!-- /TMPL_IF -->
+                                                                           <!-- TMPL_UNLESS NAME="singleBranchMode" -->
+                                                                               <!-- TMPL_VAR NAME="location" -->
+                                                                       <!-- /TMPL_UNLESS -->
+                                                       <!-- TMPL_IF NAME="itemcallnumber" -->
+                                                               [<a href="/cgi-bin/koha/opac-search.pl?q=callnum:<!-- TMPL_VAR NAME="itemcallnumber" ESCAPE="URL" -->">
+                                                               <!-- TMPL_VAR NAME="itemcallnumber" --></a>]
+                                                   <!-- /TMPL_IF -->
+                                       <!-- /TMPL_IF -->
+                                       (<!-- TMPL_VAR NAME="count" -->),
+                                   <!-- /TMPL_LOOP -->
+                            </span>
+                                       
+                       <!-- /TMPL_IF -->
+
                 </span>
 
                                <!-- /TMPL_IF -->