Bugzilla – Attachment 20015 Details for
Bug 9223
Multiple values of AdvancedSearchTypes in suggestions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 9223: Multiple values of AdvancedSearchTypes in suggestions
Bug-9223-Multiple-values-of-AdvancedSearchTypes-in.patch (text/plain), 11.49 KB, created by
Owen Leonard
on 2013-07-31 16:52:02 UTC
(
hide
)
Description:
Bug 9223: Multiple values of AdvancedSearchTypes in suggestions
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2013-07-31 16:52:02 UTC
Size:
11.49 KB
patch
obsolete
>From 17cd735ee5358a9c10fb4a039a48b4f5686f0bd6 Mon Sep 17 00:00:00 2001 >From: Fridolyn SOMERS <fridolyn.somers@biblibre.com> >Date: Fri, 4 Jan 2013 16:46:38 +0100 >Subject: [PATCH] Bug 9223: Multiple values of AdvancedSearchTypes in > suggestions >Content-Type: text/plain; charset="utf-8" > >Suggestion form uses C4::Koha::GetSupportList to get a list of supports that can come from itemtypes or authoritized values LOC or CCODE. C4::Koha::GetSupportList uses AdvancedSearchTypes syspref like it has only one value. But this syspref can contain several values separated by a pipe. > >This patch introduces a new syspref SupportsAuthorizedValues to select wich authorized values category that represents the physical support (itemtypes by default, loc or ccode). These authorized values will be used in suggestion management, known as 'document type'. >(Note that database field is still 'itemtype'). > >Test plan : >----------- >- Set SupportsAuthorizedValues with itemtypes or loc or ccode >- Get to suggestion form (OPAC or intranet) >- Look at "Document type" combobox, it must contains descriptions of selected authorized values >- Save the suggestion >- Get to intranet suggestions management >- Organize suggestions by document type >=> your suggestion must appear in a tab with its document type description > >http://bugs.koha-community.org/show_bug.cgi?id=6473 >--- > C4/Koha.pm | 105 +++++++++----------- > .../prog/en/modules/suggestion/suggestion.tt | 10 +- > .../opac-tmpl/prog/en/modules/opac-suggestions.tt | 6 +- > opac/opac-suggestions.pl | 2 +- > suggestion/suggestion.pl | 8 +- > 5 files changed, 60 insertions(+), 71 deletions(-) > >diff --git a/C4/Koha.pm b/C4/Koha.pm >index ea8c2a6..89da573 100644 >--- a/C4/Koha.pm >+++ b/C4/Koha.pm >@@ -26,6 +26,7 @@ use strict; > use C4::Context; > use C4::Branch qw(GetBranchesCount); > use Koha::DateUtils qw(dt_from_string); >+use C4::ItemType; > use Memoize; > use DateTime::Format::MySQL; > use autouse 'Data::Dumper' => qw(Dumper); >@@ -126,84 +127,72 @@ sub subfield_is_koha_internal_p { > > =head2 GetSupportName > >- $itemtypename = &GetSupportName($codestring); >+ $lib = &GetSupportName($authorised_value); > >-Returns a string with the name of the itemtype. >+Returns the name of the support corresponding to specified authorised value. > > =cut > >-sub GetSupportName{ >- my ($codestring)=@_; >- return if (! $codestring); >- my $resultstring; >- my $advanced_search_types = C4::Context->preference("AdvancedSearchTypes"); >- if (!$advanced_search_types or $advanced_search_types eq 'itemtypes') { >- my $query = qq| >- SELECT description >- FROM itemtypes >- WHERE itemtype=? >- order by description >- |; >- my $sth = C4::Context->dbh->prepare($query); >- $sth->execute($codestring); >- ($resultstring)=$sth->fetchrow; >- return $resultstring; >- } else { >- my $sth = >- C4::Context->dbh->prepare( >- "SELECT lib FROM authorised_values WHERE category = ? AND authorised_value = ?" >- ); >- $sth->execute( $advanced_search_types, $codestring ); >- my $data = $sth->fetchrow_hashref; >- return $$data{'lib'}; >- } >- >+sub GetSupportName { >+ my $authorised_value = shift; >+ return '' unless $authorised_value; >+ my $supports_av = C4::Context->preference("SupportsAuthorizedValues") || 'itemtypes'; >+ if ( $supports_av eq 'itemtypes' ) { >+ my $itemtype = getitemtypeinfo($authorised_value); >+ return $itemtype->{'description'} if $itemtype; >+ } >+ else { >+ my $lib = GetKohaAuthorisedValueLib( $supports_av, $authorised_value ); >+ return $lib if $lib; >+ } >+ return ''; > } >+ > =head2 GetSupportList > >- $itemtypes = &GetSupportList(); >+ $supports = &GetSupportList(); > >-Returns an array ref containing informations about Support (since itemtype is rather a circulation code when item-level-itypes is used). >+Returns an array ref containing informations about support : authorised_value, lib, imageurl > > build a HTML select with the following code : > > =head3 in PERL SCRIPT > >- my $itemtypes = GetSupportList(); >- $template->param(itemtypeloop => $itemtypes); >+ my $supports = GetSupportList(); >+ $template->param(supportsloop => $supports); > > =head3 in TEMPLATE > >- <form action='<!-- TMPL_VAR name="script_name" -->' method=post> >- <select name="itemtype"> >- <option value="">Default</option> >- <!-- TMPL_LOOP name="itemtypeloop" --> >- <option value="<!-- TMPL_VAR name="itemtype" -->" <!-- TMPL_IF name="selected" -->selected<!-- /TMPL_IF -->> <!--TMPL_IF Name="imageurl"--><img alt="<!-- TMPL_VAR name="description" -->" src="<!--TMPL_VAR Name="imageurl"-->><!--TMPL_ELSE-->"<!-- TMPL_VAR name="description" --><!--/TMPL_IF--></option> >- <!-- /TMPL_LOOP --> >- </select> >- <input type=text name=searchfield value="<!-- TMPL_VAR name="searchfield" -->"> >- <input type="submit" value="OK" class="button"> >- </form> >+ <select id="itemtype" name="itemtype" > >+ [% FOREACH itemtypeloo IN itemtypeloop %] >+ [% IF ( itemtypeloo.selected ) %] >+ <option value="[% itemtypeloo.code %]" selected="selected"> >+ [% ELSE %] >+ <option value="[% itemtypeloo.code %]"> >+ [% END %] >+ [% itemtypeloo.description %]</option> >+ [% END %] >+ </select> > > =cut > >-sub GetSupportList{ >- my $advanced_search_types = C4::Context->preference("AdvancedSearchTypes"); >- if (!$advanced_search_types or $advanced_search_types eq 'itemtypes') { >- my $query = qq| >- SELECT * >- FROM itemtypes >- order by description >- |; >- my $sth = C4::Context->dbh->prepare($query); >- $sth->execute; >- return $sth->fetchall_arrayref({}); >- } else { >- my $advsearchtypes = GetAuthorisedValues($advanced_search_types); >- my @results= map {{itemtype=>$$_{authorised_value},description=>$$_{lib},imageurl=>$$_{imageurl}}} @$advsearchtypes; >- return \@results; >- } >+sub GetSupportList { >+ my $supports_av = C4::Context->preference("SupportsAuthorizedValues") || 'itemtypes'; >+ if ( $supports_av eq 'itemtypes' ) { >+ my @supports = map { >+ { >+ authorised_value => $_->{'itemtype'}, >+ lib => $_->{'description'}, >+ imageurl => $_->{'imageurl'} >+ } >+ } C4::ItemType->all; >+ return \@supports; >+ } >+ else { >+ return GetAuthorisedValues($supports_av); >+ } > } >+ > =head2 GetItemTypes > > $itemtypes = &GetItemTypes( style => $style ); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt >index 0b4a4ab..ec737d3 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt >@@ -178,8 +178,8 @@ $(document).ready(function() { calcNewsuggTotal(); }); > <li><span class="label">Publication place:</span>[% place %]</li> > <li><span class="label">Collection title:</span>[% collectiontitle %]</li> > <li><span class="label">Document type:</span> >- [% FOREACH itemtypeloo IN itemtypeloop %] >- [% IF ( itemtypeloo.selected ) %][% itemtypeloo.description %][% END %] >+ [% FOREACH supports_loo IN supports_loop %] >+ [% IF ( supports_loo.selected ) %][% supports_loo.lib %][% END %] > [% END %] > </li> > [% IF ( patron_reason_loop ) %] >@@ -294,9 +294,9 @@ $(document).ready(function() { calcNewsuggTotal(); }); > <li><label for="collectiontitle">Collection title:</label><input type="text" id="collectiontitle" name="collectiontitle" size="50" maxlength="80" value="[% collectiontitle %]"/></li> > <li><label for="itemtype">Document type:</label> > <select id="itemtype" name="itemtype" > >- [% FOREACH itemtypeloo IN itemtypeloop %] >- [% IF ( itemtypeloo.selected ) %]<option selected="selected" value="[% itemtypeloo.itemtype %]">[% ELSE %]<option value="[% itemtypeloo.itemtype %]">[% END %] >- [% itemtypeloo.description %]</option> >+ [% FOREACH supports_loo IN supports_loop %] >+ [% IF ( supports_loo.selected ) %]<option selected="selected" value="[% supports_loo.authorised_value %]">[% ELSE %]<option value="[% supports_loo.authorised_value %]">[% END %] >+ [% supports_loo.lib %]</option> > [% END %] > </select> > </li> >diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-suggestions.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-suggestions.tt >index a17372f..2789573 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-suggestions.tt >+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-suggestions.tt >@@ -112,10 +112,10 @@ $.tablesorter.addParser({ > <li><label for="publishercode">Publisher:</label><input type="text" id="publishercode" name="publishercode" size="50" maxlength="80" /></li> > <li><label for="collectiontitle">Collection title:</label><input type="text" id="collectiontitle" name="collectiontitle" size="50" maxlength="80" /></li> > <li><label for="place">Publication place:</label><input type="text" id="place" name="place" size="50" maxlength="80" /></li> >- <li><label for="itemtype">Item type:</label><select name="itemtype" id="itemtype"> >+ <li><label for="itemtype">Document type:</label><select name="itemtype" id="itemtype"> > <option value="">Default</option> >- [% FOREACH itemtypeloo IN itemtypeloop %] >- [% IF ( itemtypeloo.selected ) %]<option value="[% itemtypeloo.itemtype %]" selected="selected"> [% ELSE %]<option value="[% itemtypeloo.itemtype %]"> [% END %] [% itemtypeloo.description %]</option> >+ [% FOREACH supports_loo IN supports_loop %] >+ [% IF ( supports_loo.selected ) %]<option value="[% supports_loo.authorised_value %]" selected="selected">[% ELSE %]<option value="[% supports_loo.authorised_value %]">[% END %][% supports_loo.lib %]</option> > [% END %] > </select> </li> > [% IF ( branchloop ) %] >diff --git a/opac/opac-suggestions.pl b/opac/opac-suggestions.pl >index 32b5c3d..106748f 100755 >--- a/opac/opac-suggestions.pl >+++ b/opac/opac-suggestions.pl >@@ -141,7 +141,7 @@ if ( C4::Context->preference("AllowPurchaseSuggestionBranchChoice") ) { > > $template->param( > %$suggestion, >- itemtypeloop=> $supportlist, >+ supports_loop => $supportlist, > suggestions_loop => $suggestions_loop, > patron_reason_loop => $patron_reason_loop, > showall => $allsuggestions, >diff --git a/suggestion/suggestion.pl b/suggestion/suggestion.pl >index fd9a9c2..21ad6c7 100755 >--- a/suggestion/suggestion.pl >+++ b/suggestion/suggestion.pl >@@ -303,16 +303,16 @@ $template->param( branchloop => \@branchloop, > my $supportlist = GetSupportList(); > > foreach my $support (@$supportlist) { >- $$support{'selected'} = (defined $$suggestion_ref{'itemtype'}) >- ? $$support{'itemtype'} eq $$suggestion_ref{'itemtype'} >- : 0; >+ if ( defined $$suggestion_ref{'itemtype'} && $support->{'authorised_value'} eq $$suggestion_ref{'itemtype'}) { >+ $$support{'selected'} = 1; >+ } > if ( $$support{'imageurl'} ) { > $$support{'imageurl'} = getitemtypeimagelocation( 'intranet', $$support{'imageurl'} ); > } else { > delete $$support{'imageurl'}; > } > } >-$template->param(itemtypeloop=>$supportlist); >+$template->param( supports_loop => $supportlist); > $template->param( returnsuggestedby => $returnsuggestedby ); > > my $patron_reason_loop = GetAuthorisedValues("OPAC_SUG",$$suggestion_ref{'patronreason'}); >-- >1.7.9.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 9223
:
13903
|
14427
|
14428
|
20015
|
20016
|
20017
|
35492
|
35493
|
35494
|
36178
|
36179
|
36702
|
36703
|
36704
|
40011
|
40012
|
40013
|
40014
|
40015
|
40016
|
42287
|
42288
|
42289
|
42290
|
42291
|
42336
|
42337
|
42338
|
42339
|
42340
|
44111
|
44113
|
44114
|
44115
|
44116
|
44117
|
44118