From 71f5ef96135416c7c924a7ebdd4c347a6d43a056 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Fri, 21 Sep 2012 11:36:44 +0200 Subject: [PATCH] Bug 7674: Separate items in two tabs (opac/opac-detail.pl) Two tabs: "My holdings" / "Other holdings" "My holdings" tab contains items whose homebranch is the current branch. "Other holdings" tab contains all other items. If current branch is not set (connected with mysql user, or not logged in), the display is unchanged (1 tab "Holdings") --- koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt | 34 ++++++++++++++----- opac/opac-detail.pl | 35 +++++++++++++++----- 2 files changed, 51 insertions(+), 18 deletions(-) diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt index f740488..04fa783 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt @@ -643,9 +643,12 @@ YAHOO.util.Event.onContentReady("furtherm", function () {
[% END %] -
-[% IF ( count ) %] - [% IF ( lotsofitems ) %] -

This record has many physical items. Click here to view them all.

- [% ELSE %] +[% BLOCK items_table %] [% IF ( item_level_itypes ) %][% END %] @@ -757,7 +756,7 @@ YAHOO.util.Event.onContentReady("furtherm", function () { [% END %] - [% FOREACH ITEM_RESULT IN ITEM_RESULTS %] + [% FOREACH ITEM_RESULT IN items %] [% IF ( item_level_itypes ) %][% END %] [% END %]
Item typeItem hold queue priority
[% UNLESS ( noItemTypeImages ) %][% IF ( ITEM_RESULT.imageurl ) %][% ITEM_RESULT.description %][% END %][% END %] [% ITEM_RESULT.description %] [% UNLESS ( singleBranchMode ) %] @@ -796,6 +795,14 @@ YAHOO.util.Event.onContentReady("furtherm", function () {
+[% END %][%# end of items_table block %] + +
+[% IF ( itemloop.size ) %] + [% IF ( lotsofitems ) %] +

This record has many physical items. Click here to view them all.

+ [% ELSE %] + [% PROCESS items_table items=itemloop %] [% END %] [% IF holds_count.defined || priority %]
@@ -880,6 +887,15 @@ YAHOO.util.Event.onContentReady("furtherm", function () {
+[% IF (SeparateHoldings) %] +
+ [% IF (otheritemloop.size) %] + [% PROCESS items_table items=otheritemloop %] + [% ELSE %] + No other items. + [% END %] +
+[% END %]
diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index cdb4a5a..b075efe 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -481,13 +481,6 @@ foreach my $subscription (@subscriptions) { $dat->{'count'} = scalar(@items); -# If there is a lot of items, and the user has not decided -# to view them all yet, we first warn him -# TODO: The limit of 50 could be a syspref -my $viewallitems = $query->param('viewallitems'); -if ($dat->{'count'} >= 50 && !$viewallitems) { - $template->param('lotsofitems' => 1); -} my $biblio_authorised_value_images = C4::Items::get_authorised_value_images( C4::Biblio::get_biblio_authorised_values( $biblionumber, $record ) ); @@ -516,6 +509,11 @@ $template->param( show_priority => $has_hold ) ; my $norequests = 1; my $branches = GetBranches(); my %itemfields; +my (@itemloop, @otheritemloop); +my $currentbranch = C4::Context->userenv ? C4::Context->userenv->{branch} : undef; +if ($currentbranch) { + $template->param(SeparateHoldings => 1); +} for my $itm (@items) { $itm->{holds_count} = $item_reserves{ $itm->{itemnumber} }; $itm->{priority} = $priority{ $itm->{itemnumber} }; @@ -566,6 +564,24 @@ for my $itm (@items) { $itm->{transfertfrom} = $branches->{$transfertfrom}{branchname}; $itm->{transfertto} = $branches->{$transfertto}{branchname}; } + my $homebranch = $itm->{homebranch}; + if ($currentbranch) { + if ($homebranch and $homebranch eq $currentbranch) { + push @itemloop, $itm; + } else { + push @otheritemloop, $itm; + } + } else { + push @itemloop, $itm; + } +} + +# If there is a lot of items, and the user has not decided +# to view them all yet, we first warn him +# TODO: The limit of 50 could be a syspref +my $viewallitems = $query->param('viewallitems'); +if (scalar(@itemloop) >= 50 && !$viewallitems) { + $template->param('lotsofitems' => 1); } ## get notes and subjects from MARC record @@ -694,7 +710,8 @@ if(C4::Context->preference("ISBD")) { } $template->param( - ITEM_RESULTS => \@items, + itemloop => \@itemloop, + otheritemloop => \@otheritemloop, subscriptionsnumber => $subscriptionsnumber, biblionumber => $biblionumber, subscriptions => \@subs, @@ -957,7 +974,7 @@ my $defaulttab = ? 'subscriptions' : $opac_serial_default eq 'serialcollection' && @serialcollections > 0 ? 'serialcollection' : - $opac_serial_default eq 'holdings' && $dat->{'count'} > 0 + $opac_serial_default eq 'holdings' && scalar (@itemloop) > 0 ? 'holdings' : $subscriptionsnumber ? 'subscriptions' : -- 1.7.10.4