From 418d8a074168f80432ada1009aec9f94ca2df3e0 Mon Sep 17 00:00:00 2001 From: mbeaulieu Date: Mon, 30 Jun 2014 14:07:41 -0400 Subject: [PATCH] Bug 10947 - Follow-up to: 'Review of attachment 28626' C4/Koha.pm: Perldoc has been updated to better describe subroutine behaviour and usage. itemtypes.tt: The 'IF/ELSE' was used to distiguish between the 'ADD' and 'MODIFY' screens. It has been removed and the same 'select' is now used for both cases. opac-advsearch.tt (both files): I've reformatted the code to improve readability. CURRENT TEST PLAN ------------------ 0) Back up database, so you can reset and retest easily. ;) 1) Apply the patch 2) Run Koha QA tool. 3) prove -v t/db_dependent/Koha.t -- all tests should pass. 4) run ./installer/data/mysql/updatedatabase.pl to add the two columns to itemtypes -- Does a meaningful message get printed? Are the columns added? "DESCRIBE itemtypes;" should list hideinopac and searchcategory. 5) You need to add a category to group your item types: a) In Intranet/Koha Admin/Authorized values, select DOCTYPECAT in the 'Show category:' dropdown i) If you do not have a DOCTYPECAT category, create one. b) Click button "New authorized value for DOCTYPECAT" c) Enter Authorized value: HARDWARE Description : Hardware Description (OPAC): Hardware 6) Group your items under that new category a) In Intranet/Koha Admin/Item types, choose (at least) two item types and for each: - Click action/Edit on the right column - Third row (below Description) is the Search category list box, select Hardware - click Save changes at the bottom 7) Select at least one item to be hidden in the OPAC search a) In Intranet/Koha Admin/Item types (again), choose a different item type: - Click action/Edit - Click the checkbox "Hide in OPAC" below the list of icons. 8) Go test your modifications a) Go to OPAC/Adv search. b) Validate that all items modified above (hidden or grouped) do not appear in Item type list c) Validate that new item type Hardware does appear instead. d) Select item Hardware, start Search. e) Validate returned items are the of the two types that were grouped into the Hardware category in step 4. Sponsored-by: Vanier college http://bugs.koha-community.org/show_bug.cgi?id=10937 --- C4/Koha.pm | 12 +++++++----- .../prog/en/modules/admin/itemtypes.tt | 14 -------------- .../bootstrap/en/modules/opac-advsearch.tt | 18 ++++++++++++++++-- .../opac-tmpl/prog/en/modules/opac-advsearch.tt | 18 ++++++++++++++++-- 4 files changed, 39 insertions(+), 23 deletions(-) diff --git a/C4/Koha.pm b/C4/Koha.pm index f577907..1b3efd6 100644 --- a/C4/Koha.pm +++ b/C4/Koha.pm @@ -278,14 +278,17 @@ sub GetItemTypes { =head2 GetItemTypesCategorized -Returns item types but grouped by category if available. + $categories = GetItemTypesCategorized(); + +Returns a hashref containing search categories. +A search category will be put in the hash if at least one of its itemtypes is visible in OPAC. The categories must be part of Authorized Values (DOCTYPECAT) =cut sub GetItemTypesCategorized { my $dbh = C4::Context->dbh; - # Order is important, so that partially hidden search + # Order is important, so that partially hidden (some items are not visible in OPAC) search # categories will be visible. hideinopac=0 must be last. my $query = qq| SELECT itemtype, description, imageurl, hideinopac, 0 as 'iscat' FROM itemtypes WHERE ISNULL(searchcategory) or length(searchcategory) = 0 @@ -313,15 +316,14 @@ sub GetItemTypesCategorized { while ( my $IT = $sth->fetchrow_hashref ) { $itemtypes{ $IT->{'itemtype'} } = $IT; } - return ( \%itemtypes ); } =head2 GetItemTypesByCategory - $category = category filter + @results = GetItemTypesByCategory( $searchcategory ); -Returns the itemtypes that are grouped into the category. +Returns the itemtype code of all itemtypes included in a searchcategory. =cut diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt index 2467902..7cce082 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt @@ -109,7 +109,6 @@ Item types administration [% END %]
  • Required
  • - [% IF ( itemtype ) %]
  • Search category (Options are defined as the authorized values for the DOCTYPECAT category)
  • - [% ELSE %] -
  • - Search category - -
  • - [% END %] [% IF ( noItemTypeImages ) %]
  • Image: Item type images are disabled. To enable them, turn off the noItemTypeImages system preference
  • diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt index f4f9fe0..11fde15 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt @@ -142,8 +142,22 @@
    [% FOREACH itemtypeloo IN advsearchloo.code_loop %] [% IF ((!itemtypeloo.searchcategory) AND (itemtypeloo.cat == 0)) OR (itemtypeloo.cat == 1) %] -
    +
    + + +
    [% IF ( loop.last ) %]
    [% ELSE %][% UNLESS ( loop.count % 4 ) %]
    [% END %][% END %] [% END %] [% END %] diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-advsearch.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-advsearch.tt index 8bf2dc0..55dc6b3 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-advsearch.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-advsearch.tt @@ -188,8 +188,22 @@ [% FOREACH itemtypeloo IN advsearchloo.code_loop %] [% IF ((!itemtypeloo.searchcategory) AND (itemtypeloo.cat == 0)) OR (itemtypeloo.cat == 1) %] - + + + + [% END %] [% IF ( loop.last ) %][% ELSE %][% UNLESS ( loop.count % 5 ) %][% END %][% END %] [% END %] -- 1.7.9.5