From 5a14940f808b3c460b4ed50efae2c81c1e8bff99 Mon Sep 17 00:00:00 2001 From: Paul Poulain Date: Fri, 21 Sep 2012 10:36:56 +0200 Subject: [PATCH] Bug 7674: Separate items in two tabs on biblio detail page (staff+opac) Two tabs: " holdings" / "Other holdings" " 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 (opac)), the display is unchanged (1 tab "Holdings") Signed-off-by: Kyle M Hall Signed-off-by: Katrin Fischer Signed-off-by: Jared Camins-Esakov --- catalogue/detail.pl | 18 +- installer/data/mysql/sysprefs.sql | 2 + installer/data/mysql/updatedatabase.pl | 15 + .../admin/preferences/cataloguing.pref | 13 +- .../prog/en/modules/catalogue/detail.tt | 291 ++++++++++-------- .../opac-tmpl/prog/en/modules/opac-detail.tt | 34 +- opac/opac-detail.pl | 35 ++- 7 files changed, 260 insertions(+), 148 deletions(-) diff --git a/catalogue/detail.pl b/catalogue/detail.pl index 162530f1be..204fea381b 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -177,15 +177,20 @@ $dat->{'hiddencount'} = scalar @all_items + @hostitems - scalar @items; my $shelflocations = GetKohaAuthorisedValues('items.location', $fw); my $collections = GetKohaAuthorisedValues('items.ccode' , $fw); my $copynumbers = GetKohaAuthorisedValues('items.copynumber', $fw); -my (@itemloop, %itemfields); +my (@itemloop, @otheritemloop, %itemfields); my $norequests = 1; my $authvalcode_items_itemlost = GetAuthValCode('items.itemlost',$fw); my $authvalcode_items_damaged = GetAuthValCode('items.damaged', $fw); my $analytics_flag; my $materials_flag; # set this if the items have anything in the materials field +my $currentbranch = C4::Context->userenv ? C4::Context->userenv->{branch} : undef; +if ($currentbranch and C4::Context->preference('SeparateHoldings')) { + $template->param(SeparateHoldings => 1); +} foreach my $item (@items) { + my $homebranchcode = $item->{homebranch}; $item->{homebranch} = GetBranchName($item->{homebranch}); # can place holds defaults to yes @@ -267,8 +272,16 @@ foreach my $item (@items) { } if (defined($item->{'materials'}) && $item->{'materials'} =~ /\S/){ $materials_flag = 1; + + if ($currentbranch and $currentbranch ne "NO_LIBRARY_SET" and C4::Context->preference('SeparateHoldings')) { + if ($homebranchcode and $homebranchcode eq $currentbranch) { + push @itemloop, $item; + } else { + push @otheritemloop, $item; + } + } else { + push @itemloop, $item; } - push @itemloop, $item; } $template->param( norequests => $norequests ); @@ -332,6 +345,7 @@ foreach ( keys %{$dat} ) { $template->param( AmazonTld => get_amazon_tld() ) if ( C4::Context->preference("AmazonCoverImages")); $template->param( itemloop => \@itemloop, + otheritemloop => \@otheritemloop, biblionumber => $biblionumber, ($analyze? 'analyze':'detailview') =>1, subscriptions => \@subs, diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 2fb5bd450c..ad53759c29 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -395,3 +395,5 @@ INSERT INTO systempreferences (`variable`, `value`, `options`, `explanation`, `t ('PatronSelfRegistrationExpireTemporaryAccountsDelay', '0', NULL, 'If PatronSelfRegistrationDefaultCategory is enabled, this system preference controls how long a patron can have a temporary status before the account is deleted automatically. It is an integer value representing a number of days to wait before deleting a temporary patron account. Setting it to 0 disables the deleting of temporary accounts.', 'Integer'), ('PatronSelfRegistrationBorrowerMandatoryField', 'surname|firstname', NULL , 'Choose the mandatory fields for a patron''s account, when registering via the OPAC.', 'free'), ('PatronSelfRegistrationBorrowerUnwantedField', '', NULL , 'Name the fields you don''t want to display when registering a new patron via the OPAC.', 'free'); +INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('SeparateHoldings', '0', 'Separate current branch holdings from other holdings', NULL, 'YesNo'); +INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacSeparateHoldings', '0', 'Separate current branch holdings from other holdings (OPAC)', NULL, 'YesNo'); diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index cdc53cb49e..8d1b88dbd9 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -5927,6 +5927,21 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion ($DBversion); } +$DBversion = "XXX"; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do(" + INSERT INTO systempreferences (variable,value,explanation,options,type) + VALUES('SeparateHoldings', '0', 'Separate current branch holdings from other holdings', NULL, 'YesNo'); + "); + $dbh->do(" + INSERT INTO systempreferences (variable,value,explanation,options,type) + VALUES('OpacSeparateHoldings', '0', 'Separate current branch holdings from other holdings (OPAC)', NULL, 'YesNo'); + "); + + print "Upgrade to $DBversion done (Add systempreferences SeparateHoldings and OpacSeparateHoldings) \n"; + SetVersion ($DBversion); +} + $DBversion = "3.09.00.053"; if (C4::Context->preference("Version") < TransformToNum($DBversion)) { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref index 91f15c3e2e..098f498ff5 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref @@ -156,4 +156,15 @@ Cataloging: - pref: OpacSuppressionByIPRange class: short - (Leave blank if not used. Define a range like 192.168..) - + - + - pref: SeparateHoldings + choices: + yes: "Separate" + no: "Don't separate" + - current branch holdings from other holdings at staff interface. + - + - pref: OpacSeparateHoldings + choices: + yes: "Separate" + no: "Don't separate" + - current branch holdings from other holdings at OPAC. diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt index bf7ec07242..6722a05bc8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -261,18 +261,22 @@ function verify_images() {
-
    -
  • Holdings
  • + -
    -[% IF ( count ) %] - [% IF ( showncount ) %] - +[% BLOCK items_table %] +
    + [% IF ( item_level_itypes ) %][% END %] @@ -287,148 +291,171 @@ function verify_images() { [% IF ( itemdata_copynumber ) %][% END %] [% IF materials %][% END %] [% IF ( itemdata_itemnotes ) %][% END %] - [% IF ( SpineLabelShowPrintOnBibDetails ) %][% END %] - [% IF ( hostrecords ) %][% END %] - [% IF ( analyze ) %][% END %] + [% IF ( SpineLabelShowPrintOnBibDetails ) %][% END %] + [% IF ( hostrecords ) %][% END %] + [% IF ( analyze ) %][% END %] - [% FOREACH itemloo IN itemloop %] + + + [% FOREACH item IN items %] [% IF ( item_level_itypes ) %] - + [% END %] - - - [% IF ( itemdata_ccode ) %][% END %] - + + + [% IF ( itemdata_ccode ) %][% END %] + - - - [% IF ( volinfo ) %] [% END %] - [% IF ( itemdata_uri ) %] - - [% END %] - [% IF ( itemdata_copynumber ) %] - - [% END %] - [% IF materials %] - - [% END %] - [% IF ( itemdata_itemnotes ) %][% END %] - [% IF ( SpineLabelShowPrintOnBibDetails ) %] - - [% END %] - [% IF ( hostrecords ) %] - - [% END %] - [% IF ( analyze ) %] - [% END %] - [% IF ( analyze ) %] - - [% END %] + + + [% IF ( volinfo ) %] + + [% END %] + [% IF ( itemdata_uri ) %] + + [% END %] + [% IF ( itemdata_copynumber ) %] + + [% END %] + [% IF materials %] + + [% END %] + [% IF ( itemdata_itemnotes ) %] + + [% END %] + [% IF ( SpineLabelShowPrintOnBibDetails ) %] + + [% END %] + [% IF ( hostrecords ) %] + + [% END %] + [% IF ( analyze ) %] + + [% END %] + [% IF ( analyze ) %] + + [% END %] [% END %] -
    Item typeCurrent locationCopy no.Materials specifiedPublic notesSpine labelHost recordsUsed inSpine labelHost recordsUsed in
    - [% IF !noItemTypeImages && itemloo.imageurl %] - [% itemloo.description %] - [% END %] - [% itemloo.description %] - + [% IF !noItemTypeImages && item.imageurl %] + [% item.description %] + [% END %] + [% item.description %] + [% UNLESS ( singlebranchmode ) %][% itemloo.branchname %] [% END %][% itemloo.homebranch %][% itemloo.location %] [% itemloo.ccode %][% IF ( itemloo.itemcallnumber ) %] [% itemloo.itemcallnumber %][% END %][% UNLESS ( singlebranchmode ) %][% item.branchname %] [% END %][% item.homebranch %][% item.location %] [% item.ccode %][% IF ( item.itemcallnumber ) %] [% item.itemcallnumber %][% END %] - [% IF ( itemloo.datedue ) %] - Checked out - [% UNLESS ( itemloo.NOTSAMEBRANCH ) %] - to - [% IF ( itemloo.hidepatronname ) %] - [% itemloo.cardnumber %] - [% ELSE %] - [% itemloo.firstname %] [% itemloo.surname %] - [% END %] - - [% END %] - : due [% itemloo.datedue %] - - [% ELSIF ( itemloo.transfertwhen ) %] - In transit from [% itemloo.transfertfrom %], - to [% itemloo.transfertto %], since [% itemloo.transfertwhen %] - - [% END %] + [% IF ( item.datedue ) %] + Checked out + [% UNLESS ( item.NOTSAMEBRANCH ) %] + to + [% IF ( item.hidepatronname ) %] + [% item.cardnumber %] + [% ELSE %] + [% item.firstname %] [% item.surname %] + [% END %] + + [% END %] + : due [% item.datedue %] + + [% ELSIF ( item.transfertwhen ) %] + In transit from [% item.transfertfrom %], + to [% item.transfertto %], since [% item.transfertwhen %] + + [% END %] - [% IF ( itemloo.itemlost ) %] - [% IF ( itemloo.itemlostloop ) %] - [% FOREACH itemlostloo IN itemloo.itemlostloop %] - [% IF ( itemlostloo.selected ) %] + [% IF ( item.itemlost ) %] + [% IF ( item.itemlostloop ) %] + [% FOREACH itemlostloo IN item.itemlostloop %] + [% IF ( itemlostloo.selected ) %] [% itemlostloo.lib %] + [% END %] + [% END %] + [% ELSE %] + Unavailable (lost or missing) + [% END %] [% END %] - [% END %] - [% ELSE %] - Unavailable (lost or missing) - [% END %] - [% END %] - [% IF ( itemloo.wthdrawn ) %] - Withdrawn - [% END %] + [% IF ( item.wthdrawn ) %] + Withdrawn + [% END %] - [% IF ( itemloo.damaged ) %] - [% IF ( itemloo.itemdamagedloop ) %] - [% FOREACH itemdamagedloo IN itemloo.itemdamagedloop %] - [% IF ( itemdamagedloo.selected ) %] + [% IF ( item.damaged ) %] + [% IF ( item.itemdamagedloop ) %] + [% FOREACH itemdamagedloo IN item.itemdamagedloop %] + [% IF ( itemdamagedloo.selected ) %] [% itemdamagedloo.lib %] + [% END %] + [% END %] + [% ELSE %] + Damaged + [% END %] [% END %] + + [% IF ( item.itemnotforloan ) %] + Not for loan + [% IF ( item.notforloanvalue ) %] + ([% item.notforloanvalue %]) + [% END %] [% END %] - [% ELSE %] - Damaged - [% END %] - [% END %] - [% IF ( itemloo.itemnotforloan ) %] - Not for loan - [% IF ( itemloo.notforloanvalue ) %] - ([% itemloo.notforloanvalue %]) - [% END %] - [% END %] + [% IF ( item.reservedate ) %] + [% IF ( item.waitingdate ) %] + Waiting + [% ELSE %] + Item-level hold + [% END %] + [% IF ( canreservefromotherbranches ) %] + for + [% IF ( item.hidepatronname ) %] + [% item.Reservedcardnumber %] + [% ELSE %] + [% item.ReservedForFirstname %] [% item.ReservedForSurname %] + [% END %] + + [% END %] + [% IF ( item.waitingdate ) %] + at[% ELSE %]for delivery at + [% END %] + [% item.ExpectedAtLibrary %] + [% IF ( item.waitingdate ) %] + since [% item.waitingdate %] + [% ELSE %] + [% IF ( item.reservedate ) %] + (placed [% item.reservedate %]) + [% END %] + [% END %] + [% END %] + [% UNLESS ( item.itemnotforloan or item.onloan or item.itemlost or item.wthdrawn or item.damaged or item.transfertwhen or item.reservedate ) %] + Available + [% END %] - - [% IF ( itemloo.reservedate ) %] - [% IF ( itemloo.waitingdate ) %] - Waiting - [% ELSE %] - Item-level hold - [% END %] - [% IF ( canreservefromotherbranches ) %]for - [% IF ( itemloo.hidepatronname ) %] - [% itemloo.Reservedcardnumber %] - [% ELSE %] - [% itemloo.ReservedForFirstname %] [% itemloo.ReservedForSurname %] - [% END %] - [% END %] - [% IF ( itemloo.waitingdate ) %] - at[% ELSE %]for delivery at - [% END %] [% itemloo.ExpectedAtLibrary %] - [% IF ( itemloo.waitingdate ) %] - since [% itemloo.waitingdate %] - [% ELSE %] - [% IF ( itemloo.reservedate ) %](placed [% itemloo.reservedate %])[% END %] - [% END %] - [% END %] - [% UNLESS ( itemloo.itemnotforloan ) %][% UNLESS ( itemloo.onloan ) %][% UNLESS ( itemloo.itemlost ) %][% UNLESS ( itemloo.wthdrawn ) %][% UNLESS ( itemloo.damaged ) %][% UNLESS ( itemloo.transfertwhen ) %][% UNLESS ( itemloo.reservedate ) %] - Available - [% END %][% END %][% END %][% END %][% END %][% END %][% END %] + [% IF ( item.restricted ) %] + ([% item.restricted %]) + [% END %] - [% IF ( itemloo.restricted ) %]([% itemloo.restricted %])[% END %] - [% itemloo.datelastseen %][% itemloo.barcode %] - [% IF ( itemdata_enumchron ) %] - [% IF ( itemloo.enumchron ) %] - [% itemloo.enumchron %][% IF ( itemloo.serialseq ) %] -- [% END %] - [% END %] - [% itemloo.serialseq %][% IF ( itemloo.publisheddate ) %] ([% itemloo.publisheddate %])[% END %] - [% END %] - [% itemloo.uri %][% itemloo.copynumber %] [% itemloo.materials %]
    [% itemloo.itemnotes %]
    Print label[% IF ( itemloo.hostbiblionumber) %][% itemloo.hosttitle %][% END %] - [% IF ( itemloo.countanalytics ) %] - [% itemloo.countanalytics %] analytics - [% END %]Create analytics[% item.datelastseen %][% item.barcode %] + [% IF ( itemdata_enumchron ) %] + [% IF ( item.enumchron ) %] + [% item.enumchron %] + [% IF ( item.serialseq ) %] -- [% END %] + [% END %] + [% item.serialseq %] + [% IF ( item.publisheddate ) %] ([% item.publisheddate %])[% END %] + [% END %] + [% item.uri %][% item.copynumber %] [% item.materials %]
    [% item.itemnotes %]
    Print label[% IF ( item.hostbiblionumber) %][% item.hosttitle %][% END %] + [% IF ( item.countanalytics ) %] + [% item.countanalytics %] analytics + [% END %] + Create analytics
    + + +[% END %][%# end of block items_table %] + +
    +[% IF ( count ) %] + [% IF ( showncount ) %] + [% PROCESS items_table items=itemloop %] [% END %] [% IF ( hiddencount ) %]

    Show all items ([% hiddencount %] hidden) @@ -451,6 +478,16 @@ function verify_images() { [% END %] [% END %]

    + +[% IF (SeparateHoldings) %] +
    + [% IF (otheritemloop.size) %] + [% PROCESS items_table items=otheritemloop %] + [% ELSE %] + No other items. + [% END %] +
    +[% END %]
    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 1753cce512..218e549c30 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt @@ -654,9 +654,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 %] @@ -764,7 +763,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 ) %] @@ -803,6 +802,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 %]
    @@ -887,6 +894,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 5e432e1756..6730163253 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -484,13 +484,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 ) ); @@ -519,6 +512,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 and C4::Context->preference('OpacSeparateHoldings')) { + $template->param(SeparateHoldings => 1); +} for my $itm (@items) { $itm->{holds_count} = $item_reserves{ $itm->{itemnumber} }; $itm->{priority} = $priority{ $itm->{itemnumber} }; @@ -569,6 +567,24 @@ for my $itm (@items) { $itm->{transfertfrom} = $branches->{$transfertfrom}{branchname}; $itm->{transfertto} = $branches->{$transfertto}{branchname}; } + my $homebranch = $itm->{homebranch}; + if ($currentbranch and C4::Context->preference('OpacSeparateHoldings')) { + 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 @@ -697,7 +713,8 @@ if(C4::Context->preference("ISBD")) { } $template->param( - ITEM_RESULTS => \@items, + itemloop => \@itemloop, + otheritemloop => \@otheritemloop, subscriptionsnumber => $subscriptionsnumber, biblionumber => $biblionumber, subscriptions => \@subs, @@ -960,7 +977,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' : -- 2.39.5