@@ -, +, @@ --- koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt | 34 ++++++++++++++----- opac/opac-detail.pl | 35 +++++++++++++++----- 2 files changed, 51 insertions(+), 18 deletions(-) --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt +++ a/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 %]
--- a/opac/opac-detail.pl +++ a/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' : --