Bugzilla – Attachment 58589 Details for
Bug 17847
Move C4::Koha::GetAuthvalueDropbox to Koha::AuthorisedValues
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17847: Replace C4::Koha::GetAuthvalueDropbox with Koha::AuthorisedValues
Bug-17847-Replace-C4KohaGetAuthvalueDropbox-with-K.patch (text/plain), 6.88 KB, created by
Jonathan Druart
on 2017-01-04 14:41:58 UTC
(
hide
)
Description:
Bug 17847: Replace C4::Koha::GetAuthvalueDropbox with Koha::AuthorisedValues
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2017-01-04 14:41:58 UTC
Size:
6.88 KB
patch
obsolete
>From 871f499dc5a957df4361aea8b42603c23d058e4b Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 4 Jan 2017 13:43:27 +0100 >Subject: [PATCH] Bug 17847: Replace C4::Koha::GetAuthvalueDropbox with > Koha::AuthorisedValues > >The C4::Koha::GetAuthvalueDropbox subroutine does the same job as >Koha::AuthorisedValues->search >We should then replace the different calls to this subroutine to finally >remove it. >There were 2 calls to this subroutine: >- from the AuthorisedValues TT plugin (called from av-build-dropbox.inc >and members/housebound.tt) >- from the acqui/ajax-getauthvaluedropbox.pl ajax script > >To make sure that this patchset does not introduce regressions, we will have >to test that the TT plugin and the ajax script still behave as before. > >Test plan: >1/ Test acqui/ajax-getauthvaluedropbox.pl >- Link a fund to an authorised value category >- Create a new order >=> When you select a fund linked to AV category, the sort1 (and/or >sort2, depending on what you set) should be replaced with a dropdown >list populated with the authorised values >2/ Test av-build-dropbox.inc >- Create some authorised values for Bsort1 >- Edit a patron >=> The sort1 should be a dropdown list populated with the Bsort1 AV >3/ Test members/housebound.tt >- Enable the housebound module (pref HouseboundModule) >- On the patron detail page, click on the "Housebound" tab >=> The frequency dropdown list should be populated with the different >HSBND_FREQ AV >--- > Koha/Template/Plugin/AuthorisedValues.pm | 14 +++++++++-- > acqui/ajax-getauthvaluedropbox.pl | 28 +++++++++++++++------- > .../prog/en/includes/av-build-dropbox.inc | 8 +++---- > .../prog/en/modules/members/housebound.tt | 6 ++--- > 4 files changed, 38 insertions(+), 18 deletions(-) > >diff --git a/Koha/Template/Plugin/AuthorisedValues.pm b/Koha/Template/Plugin/AuthorisedValues.pm >index 39ec785..05c27b8 100644 >--- a/Koha/Template/Plugin/AuthorisedValues.pm >+++ b/Koha/Template/Plugin/AuthorisedValues.pm >@@ -40,8 +40,18 @@ sub Get { > } > > sub GetAuthValueDropbox { >- my ( $self, $category, $default ) = @_; >- return C4::Koha::GetAuthvalueDropbox($category, $default); >+ my ( $self, $category ) = @_; >+ my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{"branch"} : ""; >+ return Koha::AuthorisedValues->search( >+ { >+ branchcode => $branch_limit, >+ category => $category, >+ }, >+ { >+ group_by => 'lib', >+ order_by => [ 'category', 'lib', 'lib_opac' ], >+ } >+ ); > } > > sub GetCategories { >diff --git a/acqui/ajax-getauthvaluedropbox.pl b/acqui/ajax-getauthvaluedropbox.pl >index fb0e5e5..f5852d4 100755 >--- a/acqui/ajax-getauthvaluedropbox.pl >+++ b/acqui/ajax-getauthvaluedropbox.pl >@@ -48,9 +48,9 @@ Default value for the dropbox. > use Modern::Perl; > > use CGI qw ( -utf8 ); >-use C4::Koha; > use C4::Charset; > use C4::Auth qw/check_api_auth/; >+use Koha::AuthorisedValues; > > my $query = CGI->new(); > binmode STDOUT, ':encoding(UTF-8)'; >@@ -67,18 +67,28 @@ my $name = $input->param('name'); > my $category = $input->param('category'); > my $default = $input->param('default'); > $default = C4::Charset::NormalizeString($default); >- >-binmode STDOUT, ':encoding(UTF-8)'; >-print $input->header(-type => 'text/plain', -charset => 'UTF-8'); >-my $avs = C4::Koha::GetAuthvalueDropbox($category, $default); >+my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{"branch"} : ""; >+ >+my $avs = Koha::AuthorisedValues->search( >+ { >+ branchcode => $branch_limit, >+ category => $category, >+ }, >+ { >+ group_by => 'lib', >+ order_by => [ 'category', 'lib', 'lib_opac' ], >+ } >+); > my $html = qq|<select id="$name" name="$name">|; >-for my $av ( @$avs ) { >- if ( $av->{default} ) { >- $html .= qq|<option value="$av->{value}" selected="selected">$av->{label}</option>|; >+while ( my $av = $avs->next ) { >+ if ( $av->authorised_value eq $default ) { >+ $html .= q|<option value="| . $av->authorised_value . q|" selected="selected">| . $av->lib . q|</option>|; > } else { >- $html .= qq|<option value="$av->{value}">$av->{label}</option>|; >+ $html .= q|<option value="| . $av->authorised_value . q|">| . $av->lib . q|</option>|; > } > } > $html .= qq|</select>|; > >+binmode STDOUT, ':encoding(UTF-8)'; >+print $input->header(-type => 'text/plain', -charset => 'UTF-8'); > print $html; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/av-build-dropbox.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/av-build-dropbox.inc >index adc9a17..8aaf8ef 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/av-build-dropbox.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/av-build-dropbox.inc >@@ -9,7 +9,7 @@ > all: add a "All" entry > %] > >-[% SET avs = AuthorisedValues.GetAuthValueDropbox( category, default ) %] >+[% SET avs = AuthorisedValues.GetAuthValueDropbox( category ) %] > [% DEFAULT > class = '' > size = 20 >@@ -19,10 +19,10 @@ > <select id="[% name %]" name="[% name %]" class="[% class %]" > > [% IF all %]<option value="">All</option>[% END %] > [% FOR av IN avs %] >- [% IF av.default %] >- <option value="[% av.value %]" selected="selected">[% av.label | html_entity %]</option> >+ [% IF av.authorised_value == default %] >+ <option value="[% av.authorised_value %]" selected="selected">[% av.lib | html_entity %]</option> > [% ELSE %] >- <option value="[% av.value %]">[% av.label | html_entity %]</option> >+ <option value="[% av.authorised_value %]">[% av.lib | html_entity %]</option> > [% END %] > [% END %] > </select> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/housebound.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/housebound.tt >index 74c90f4..855cd43 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/housebound.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/housebound.tt >@@ -141,10 +141,10 @@ > <select id="frequency" name="frequency" class="required" required="required"> > <option value="">Select a frequency</option> > [% FOREACH frequency IN AuthorisedValues.GetAuthValueDropbox('HSBND_FREQ') %] >- [% IF housebound_profile.frequency == frequency.value %] >- <option value="[% frequency.value %]" selected="selected">[% frequency.label %]</option> >+ [% IF housebound_profile.frequency == frequency.authorised_value %] >+ <option value="[% frequency.authorised_value %]" selected="selected">[% frequency.lib %]</option> > [% ELSE %] >- <option value="[% frequency.value %]">[% frequency.label %]</option> >+ <option value="[% frequency.authorised_value %]">[% frequency.lib %]</option> > [% END %] > [% END %] > </select> >-- >2.9.3
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 17847
:
58589
|
58590
|
60019
|
60020
|
60982
|
60983