Browse Source

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

Signed-off-by: Myka Kennedy Stephens <mkstephens@lancasterseminary.edu>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
20.05.x
Nick Clemens 4 years ago
committed by Martin Renvoize
parent
commit
6b6a68525c
Signed by: martin.renvoize GPG Key ID: 422B469130441A0F
  1. 21
      cataloguing/value_builder/cn_browser.pl
  2. 33
      koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/cn_browser.tt

21
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;
};

33
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 %]

Loading…
Cancel
Save