Bugzilla – Attachment 98531 Details for
Bug 18499
Make 'Call number browser' on edit items screen use the correct item specific classification scheme
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18499: Use items cn_source in cn_browser.pl
Bug-18499-Use-items-cnsource-in-cnbrowserpl.patch (text/plain), 7.22 KB, created by
Nick Clemens (kidclamp)
on 2020-02-06 13:20:58 UTC
(
hide
)
Description:
Bug 18499: Use items cn_source in cn_browser.pl
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2020-02-06 13:20:58 UTC
Size:
7.22 KB
patch
obsolete
>From 97b36bc32af1296e62451306223f4619f04b4a99 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Thu, 6 Feb 2020 13:14:30 +0000 >Subject: [PATCH] Bug 18499: Use items cn_source in cn_browser.pl > >This does a few things: > * We fetch the cn_sort from the DB and use this rather than calculating based on DefaultClassificationSource > We were already pulling based on the items source, so this should not change things > * Rather than using JS to submit the form, it submits via html > * Fix subtitle display and add barcode (it was retrieved in one query but not used) > * Add option to apply different classification scheme to the search > >To test: > 1 - Add cn_browser.pl to the 'plugin' field in a framework for 952$o > 2 - Edit an item on a record in that framework > 3 - Enter an itemcallnumber > 4 - Click the two dots to launch the callnumber browser > 5 - Note the results > 6 - Apply patch > 7 - Repeat > 8 - Note subtitles and barcodes are displayed in results > 9 - Note callnumbers are appropriate >10 - Try changing the class source used >11 - Try this with differing dewey,lcc, and other callnumbers >12 - Ensure results are as expected >--- > cataloguing/value_builder/cn_browser.pl | 21 ++++++++------ > .../cataloguing/value_builder/cn_browser.tt | 33 ++++++++++++---------- > 2 files changed, 31 insertions(+), 23 deletions(-) > >diff --git a/cataloguing/value_builder/cn_browser.pl b/cataloguing/value_builder/cn_browser.pl >index 51767a92f3..f6277e359c 100755 >--- a/cataloguing/value_builder/cn_browser.pl >+++ b/cataloguing/value_builder/cn_browser.pl >@@ -26,6 +26,8 @@ use C4::Auth; > use C4::ClassSource; > use C4::Output; > >+use Koha::ClassSources; >+ > my $builder = sub { > my ( $params ) = @_; > my $function_name = $params->{id}; >@@ -59,8 +61,6 @@ my $launcher = sub { > } > ); > >- my $cn_sort; >- > my $dbh = C4::Context->dbh; > my $sth; > my @cn; >@@ -86,17 +86,19 @@ my $launcher = sub { > $search = $gt; > } > >+ my $cn_source = $cgi->param('cn_source') || C4::Context->preference("DefaultClassificationSource"); >+ my @class_sources = Koha::ClassSources->search({ used => 1}); >+ > #Don't show half the results of show lt or gt > $real_limit = $results_per_page if $search ne $q; >- $cn_sort = GetClassSort( undef, undef, $search ); >- my $cn_sort_q = GetClassSort( undef, undef, $q ); >+ my $cn_sort = GetClassSort( $cn_source, undef, $search ); > > my $red = 0; > if ( $search ne $gt ) { > my $green = 0; > > #Results before the cn_sort >- $query = "SELECT b.title, itemcallnumber, biblionumber, barcode, cn_sort, branchname, author >+ $query = "SELECT b.title, b.subtitle, itemcallnumber, biblionumber, barcode, cn_sort, branchname, author > FROM items AS i > JOIN biblio AS b USING (biblionumber) > LEFT OUTER JOIN branches ON (branches.branchcode = homebranch) >@@ -110,7 +112,7 @@ my $launcher = sub { > if ( $data->{itemcallnumber} eq $q ) { > $data->{background} = 'red'; > $red = 1; >- } elsif ( ( GetClassSort( undef, undef, $data->{itemcallnumber} ) lt $cn_sort_q ) && !$green && !$red ) { >+ } elsif ( $data->{cn_sort} lt $cn_sort && !$green && !$red ) { > if ( $#cn != -1 ) { > unshift @cn, { 'background' => 'green' }; > $globalGreen = 1; >@@ -126,7 +128,7 @@ my $launcher = sub { > my $green = 0; > > #Results after the cn_sort >- $query = "SELECT b.title, itemcallnumber, biblionumber, i.cn_sort, branchname, author >+ $query = "SELECT b.title, b.subtitle, itemcallnumber, biblionumber, barcode, cn_sort, branchname, author > FROM items AS i > JOIN biblio AS b USING (biblionumber) > LEFT OUTER JOIN branches ON (branches.branchcode = homebranch) >@@ -141,7 +143,7 @@ my $launcher = sub { > if ( $data->{itemcallnumber} eq $q ) { > $data->{background} = 'red'; > $red = 1; >- } elsif ( ( GetClassSort( undef, undef, $data->{itemcallnumber} ) gt $cn_sort_q ) && !$green && !$red && !$globalGreen ) { >+ } elsif ( $data->{cn_sort} gt $cn_sort && !$green && !$red && !$globalGreen ) { > push @cn, { 'background' => 'green' }; > $green = 1; > } >@@ -159,6 +161,9 @@ my $launcher = sub { > $template->param( 'q' => $q ); > $template->param( 'cn_loop' => \@cn ) if $#cn != -1; > $template->param( 'popup' => defined( $cgi->param('popup') ) ); >+ $template->param( 'cn_source' => $cn_source ) if $cn_source; >+ $template->param( 'class_sources' => \@class_sources ); >+ > > output_html_with_http_headers $cgi, $cookie, $template->output; > }; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/cn_browser.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/cn_browser.tt >index 4e7dcc4a6a..629ac874a2 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/cn_browser.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/cn_browser.tt >@@ -15,10 +15,23 @@ > <h1>Call number browser</h1> > > <div> >- <form method="get" action="cn_browser.pl"> >- <label for="searchcn">Search call number:</label> >- <input type="text" id="cn_browser_input" name="q" value="[% q | html %]" /> >- <input id="cn_browser_submit" type="submit" value="Search" /> >+ <form id="cn_browser" method="get" action="/cgi-bin/koha/cataloguing/plugin_launcher.pl"> >+ <label for="searchcn">Search call number:</label> >+ <input type="text" id="cn_browser_input" name="q" value="[% q | html %]" /> >+ <input id="cn_browser_submit" type="submit" value="Search" /> >+ <input name="plugin_name" type="hidden" value="cn_browser.pl"/> >+ <input name="popup" type="hidden" value="[% popup %]"/> >+ </br> >+ <label for="cn_source">Callnumber classification scheme</label> >+ <select name="cn_source" form="cn_browser"> >+ [% FOREACH class_source IN class_sources %] >+ [% IF class_source.cn_source == cn_source %] >+ <option value="[% class_source.cn_source | html %]" selected="selected">[% class_source.description | html %]</option> >+ [% ELSE %] >+ <option value="[% class_source.cn_source | html %]">[% class_source.description | html %]</option> >+ [% END %] >+ [% END %] >+ </select> > </form> > </div> > <br /> >@@ -39,6 +52,7 @@ > [% IF ( cn_loo.author ) %] > <span>by</span> [% cn_loo.author | html %] > [% END %] >+ [% IF ( cn_loo.barcode ) %] ([% cn_loo.barcode %])[% END %] > </a> > </td> > <td style="background:[% cn_loo.background | html %];">[% cn_loo.branchname | html %]</td> >@@ -47,15 +61,4 @@ > </tbody> > </table> > >-[% MACRO jsinclude BLOCK %] >- <script> >- $(document).ready(function(){ >- $("#cn_browser_submit").click(function(){ >- window.location.href='/cgi-bin/koha/cataloguing/plugin_launcher.pl?plugin_name=cn_browser.pl&popup&q='+$("#cn_browser_input").val(); >- return false; >- }); >- }); >- </script> >-[% END %] >- > [% INCLUDE 'intranet-bottom.inc' popup_window=1 %] >-- >2.11.0
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 18499
:
98531
|
98737
|
99000
|
99057
|
99058
|
99059
|
103029