Bugzilla – Attachment 40012 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), 12.03 KB, created by
Alex Arnaud
on 2015-06-09 08:09:56 UTC
(
hide
)
Description:
Bug 9223: Multiple values of AdvancedSearchTypes in suggestions
Filename:
MIME Type:
Creator:
Alex Arnaud
Created:
2015-06-09 08:09:56 UTC
Size:
12.03 KB
patch
obsolete
>From 4419c927f0a3bc9d7dcb75c904e0e39ef0046f54 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 > >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 > >Signed-off-by: Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> >--- > C4/Koha.pm | 90 +++++++++----------- > .../prog/en/modules/suggestion/suggestion.tt | 10 +-- > .../bootstrap/en/modules/opac-suggestions.tt | 12 +-- > opac/opac-suggestions.pl | 2 +- > suggestion/suggestion.pl | 8 +- > 5 files changed, 55 insertions(+), 67 deletions(-) > >diff --git a/C4/Koha.pm b/C4/Koha.pm >index 4f54a3b..20049e5 100644 >--- a/C4/Koha.pm >+++ b/C4/Koha.pm >@@ -27,6 +27,7 @@ use C4::Context; > use C4::Branch qw(GetBranchesCount); > use Koha::Cache; > use Koha::DateUtils qw(dt_from_string); >+use C4::ItemType; > use DateTime::Format::MySQL; > use Business::ISBN; > use autouse 'Data::Dumper' => qw(Dumper); >@@ -130,84 +131,71 @@ 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 > > <select name="itemtype" id="itemtype"> >- <option value=""></option> > [% FOREACH itemtypeloo IN itemtypeloop %] > [% IF ( itemtypeloo.selected ) %] >- <option value="[% itemtypeloo.itemtype %]" selected="selected">[% itemtypeloo.description %]</option> >+ <option value="[% itemtypeloo.code %]" selected="selected">[% itemtypeloo.description %]</option> > [% ELSE %] >- <option value="[% itemtypeloo.itemtype %]">[% itemtypeloo.description %]</option> >+ <option value="[% itemtypeloo.code %]">[% itemtypeloo.description %]</option> > [% END %] > [% END %] > </select> > > =cut > >-sub GetSupportList{ >- my $advanced_search_types = C4::Context->preference("AdvancedSearchTypes"); >- if (!$advanced_search_types or $advanced_search_types =~ /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 4bd3908..ca70e09 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt >@@ -213,8 +213,8 @@ h4.local_collapse a { font-size : 80%; text-decoration: none; } fieldset.brief o > <li><span class="label">Publication place:</span>[% place |html %]</li> > <li><span class="label">Collection title:</span>[% collectiontitle |html %]</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 ) %] >@@ -337,9 +337,9 @@ h4.local_collapse a { font-size : 80%; text-decoration: none; } fieldset.brief o > <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/bootstrap/en/modules/opac-suggestions.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt >index 8ae9214..c88b902 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt >@@ -41,16 +41,16 @@ > <li><label for="publishercode">Publisher:</label><input type="text" id="publishercode" name="publishercode" class="span6" maxlength="80" /></li> > <li><label for="collectiontitle">Collection title:</label><input type="text" id="collectiontitle" name="collectiontitle" class="span6" maxlength="80" /></li> > <li><label for="place">Publication place:</label><input type="text" id="place" name="place" maxlength="80" /></li> >- <li><label for="itemtype">Item type:</label> >+ <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"> >+ [% FOREACH supports_loo IN supports_loop %] >+ [% IF ( supports_loo.selected ) %] >+ <option value="[% supports_loo.itemtype %]" selected="selected"> > [% ELSE %] >- <option value="[% itemtypeloo.itemtype %]"> >+ <option value="[% supports_loo.itemtype %]"> > [% END %] >- [% itemtypeloo.description %] >+ [% supports_loo.description %] > </option> > [% END %] > </select> >diff --git a/opac/opac-suggestions.pl b/opac/opac-suggestions.pl >index 0fa7812..83ae033 100755 >--- a/opac/opac-suggestions.pl >+++ b/opac/opac-suggestions.pl >@@ -169,7 +169,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 43834f6..f87af87 100755 >--- a/suggestion/suggestion.pl >+++ b/suggestion/suggestion.pl >@@ -328,16 +328,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.10.4
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