[Koha-patches] [PATCH][3.0.x] (bug #3058) show items that are excluded of loan in search results
Nahuel ANGELINETTI
nahuel.angelinetti at biblibre.com
Thu Mar 26 11:47:01 CET 2009
Hi,
this is not really well, I think i'm a little tired(and
C4::Search::searchResults() is a very ugly thing).
This patch activate the view of "not for loan" items in opac, but
disable the view of all statuses "not for loan" in staff.
I'll send a follow up.
Le Wed, 25 Mar 2009 17:47:09 +0100,
Nahuel ANGELINETTI <nahuel.angelinetti at biblibre.com> a écrit :
> 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 | 49
> +++++++++++++++---- .../prog/en/modules/catalogue/results.tmpl
> | 16 ++++++ .../opac-tmpl/prog/en/modules/opac-results.tmpl |
> 25 ++++++++++ 3 files changed, 79 insertions(+), 11 deletions(-)
>
> diff --git a/C4/Search.pm b/C4/Search.pm
> index 26022b5..6b3c632 100644
> --- a/C4/Search.pm
> +++ b/C4/Search.pm
> @@ -1338,15 +1338,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;
> @@ -1447,18 +1450,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 {
> @@ -1473,7 +1495,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
> @@ -1486,6 +1508,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}
> @@ -1498,18 +1524,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;
> diff --git
> a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tmpl
> b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tmpl
> index 0c881ee..201fb76 100644 ---
> a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tmpl +++
> b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tmpl @@
> -341,6 +341,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> diff --git
> a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tmpl
> b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tmpl index
> e4a7148..c283cd6 100644 ---
> a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tmpl +++
> b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tmpl @@ -259,6
> +259,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 -->
--
Nahuel ANGELINETTI
More information about the Koha-patches
mailing list