Bugzilla – Attachment 14427 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]
Proposed patch (main)
0001-Bug-9223-Multiple-values-of-AdvancedSearchTypes-in-s.patch (text/plain), 11.94 KB, created by
Fridolin Somers
on 2013-01-04 16:57:01 UTC
(
hide
)
Description:
Proposed patch (main)
Filename:
MIME Type:
Creator:
Fridolin Somers
Created:
2013-01-04 16:57:01 UTC
Size:
11.94 KB
patch
obsolete
>From 0a1d5b87b306944f39b4576bb8963c6fb1d0d0d6 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 1/2] 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 >--- > C4/Koha.pm | 105 +++++++++----------- > .../prog/en/modules/suggestion/suggestion.tt | 12 +-- > .../opac-tmpl/prog/en/modules/opac-suggestions.tt | 6 +- > opac/opac-suggestions.pl | 2 +- > suggestion/suggestion.pl | 8 +- > 5 files changed, 61 insertions(+), 72 deletions(-) > >diff --git a/C4/Koha.pm b/C4/Koha.pm >index 3892468..f954c33 100644 >--- a/C4/Koha.pm >+++ b/C4/Koha.pm >@@ -25,6 +25,7 @@ use strict; > > use C4::Context; > use C4::Branch qw(GetBranchesCount); >+use C4::ItemType; > use Memoize; > use DateTime; > use DateTime::Format::MySQL; >@@ -124,84 +125,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(); >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 fb73fd1..e8d8825 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt >@@ -176,8 +176,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 ) %] >@@ -276,9 +276,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> >@@ -481,7 +481,7 @@ $(document).ready(function() { calcNewsuggTotal(); }); > <select name="displayby" id="displayby" style="width:auto;"> > <option value="STATUS">Status</option> > <option value="branchcode">Library</option> >- <option value="itemtype">Item type</option> >+ <option value="itemtype">Document type</option> > <option value="managedby">Managed by</option> > <option value="acceptedby">Accepted by</option> > </select> <input type="submit" value="Go" /></li></ol></fieldset> >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 3c62e55..04c5bbc 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-suggestions.tt >+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-suggestions.tt >@@ -110,10 +110,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 ( branch_loop ) %] >diff --git a/opac/opac-suggestions.pl b/opac/opac-suggestions.pl >index eddcd26..3e507f8 100755 >--- a/opac/opac-suggestions.pl >+++ b/opac/opac-suggestions.pl >@@ -137,7 +137,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 99f38eb..5da8370 100755 >--- a/suggestion/suggestion.pl >+++ b/suggestion/suggestion.pl >@@ -289,16 +289,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