Bugzilla – Attachment 36600 Details for
Bug 13364
Add a call number browser to add item page
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 13364 - Add a call number browser in item edition page
Bug-13364---Add-a-call-number-browser-in-item-edit.patch (text/plain), 9.39 KB, created by
Magnus Enger
on 2015-03-05 13:45:37 UTC
(
hide
)
Description:
Bug 13364 - Add a call number browser in item edition page
Filename:
MIME Type:
Creator:
Magnus Enger
Created:
2015-03-05 13:45:37 UTC
Size:
9.39 KB
patch
obsolete
>From b4443a5eb9b44ebe5e8bad519504f72b2c1fea96 Mon Sep 17 00:00:00 2001 >From: simith <simith@inlibro.com> >Date: Fri, 27 Feb 2015 08:09:09 -0500 >Subject: [PATCH] Bug 13364 - Add a call number browser in item edition page >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >When editing an item, the call number browser search for existing call number. If it shows a line is green between two calli numbers, the call numbers searched is available. If the call number is highlighted in red, it means that it already exists. This can be used to avoid repeated call numbers in your collection. > >The call number browser also shows its position relative to the rest of the collection. > >Sponsored-by: CCSR > >To test : > > 1) Go to MARC bibliographic framework > Home ⺠Administration ⺠MARC frameworks > 2) Click in MARC structure (Default framework) > 3) Search field 952 and click in subfields > 4) Edit subfield o (Full call number) > 5) Click Display more constraints > 6) In Others Options, Plugin, Choose cn_browser.pl and save changes > 7) Search a record and edit its items > Validate : three points (â¦) beside Full call number input > 8) Click in ⦠> Validate : if it can not find the given call number, a green line is shown. Otherwise, the given call number is highlighted in red. > >Followed test plan. Works as expected. >Signed-off-by: Marc Véron <veron@veron.ch> > >Signed-off-by: Magnus <magnus@enger.priv.no> >Works as advertised. QA scripts pass. >--- > cataloguing/value_builder/cn_browser.pl | 166 +++++++++++++++++++++ > .../intranet-tmpl/prog/en/css/staff-global.css | 5 + > .../prog/en/modules/tools/cn_browser.tt | 61 ++++++++ > 3 files changed, 232 insertions(+) > create mode 100755 cataloguing/value_builder/cn_browser.pl > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/tools/cn_browser.tt > >diff --git a/cataloguing/value_builder/cn_browser.pl b/cataloguing/value_builder/cn_browser.pl >new file mode 100755 >index 0000000..a6ece26 >--- /dev/null >+++ b/cataloguing/value_builder/cn_browser.pl >@@ -0,0 +1,166 @@ >+#!/usr/bin/perl >+ >+use strict; >+use warnings; >+no warnings 'redefine'; >+ >+use CGI; >+use C4::Auth; >+use C4::Output; >+use POSIX; >+use C4::ClassSource; >+use URI::Escape; >+use Data::Dumper; >+ >+sub plugin_parameters { >+my ($dbh,$record,$tagslib,$i,$tabloop) = @_; >+return ""; >+} >+ >+sub plugin_javascript { >+my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_; >+my $function_name= "328".(int(rand(100000))+1); >+my $res=" >+<script type=\"text/javascript\"> >+//<![CDATA[ >+ >+function Focus$function_name(subfield_managed) { >+return 1; >+} >+ >+function Blur$function_name(subfield_managed) { >+ return 1; >+} >+ >+function Clic$function_name(i) { >+ q = document.getElementById('$field_number'); >+ window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=cn_browser.pl&popup&q=\"+q.value,\"cnbrowser\",\"width=500,height=400,toolbar=false,scrollbars=yes\"); >+ >+} >+ >+//]]> >+</script> >+"; >+ >+return ($function_name,$res); >+} >+ >+ >+sub plugin { >+ my ($input) = @_; >+ my $cgi = new CGI; >+ my $params = $cgi->Vars; >+ my $results_per_page = 30; >+ my $current_page = $cgi->param('page') || 1; >+ >+ my ( $template, $loggedinuser, $cookie ) = get_template_and_user({ >+ template_name => "tools/cn_browser.tt", >+ query => $cgi, >+ type => "intranet", >+ authnotrequired => 0, >+ flagsrequired => { tools => 'cn_browser', catalogue => 1 }, >+ }); >+ >+ my $cn_sort; >+ >+ my $dbh = C4::Context->dbh; >+ my $sth; >+ my @cn; >+ my $query; >+ my $real_limit = $results_per_page / 2; >+ my $rows_lt = 999; >+ my $rows_gt = 999; >+ my $search; >+ my $lt = ''; >+ my $gt = ''; >+ my $q; >+ >+ if ($q = $cgi->param('q')) { >+ $search = $q; >+ } >+ if ($cgi->param('lt')) { >+ $lt = $cgi->param('lt'); >+ $search = $lt; >+ } >+ if ($cgi->param('gt')) { >+ $gt = $cgi->param('gt'); >+ $search = $gt; >+ } >+ >+ #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 $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 >+ FROM items AS i >+ JOIN biblio AS b USING (biblionumber) >+ LEFT OUTER JOIN branches ON (branches.branchcode = homebranch) >+ WHERE cn_sort < '$cn_sort' >+ AND itemcallnumber != '' >+ ORDER BY cn_sort DESC, itemnumber >+ LIMIT $real_limit;"; >+ $sth = $dbh->prepare($query); >+ $sth->execute(); >+ while ( my $data = $sth->fetchrow_hashref ) { >+ if ($data->{itemcallnumber} eq $q) { >+ $data->{background} = 'red'; >+ $red = 1; >+ } >+ elsif (($data->{cn_sort} lt $cn_sort_q) && !$green && !$red) { >+ if ($#cn != -1) { >+ unshift @cn, {'background' => 'green'}; >+ } >+ $green = 1; >+ } >+ unshift @cn, $data; >+ } >+ $rows_lt = $sth->rows; >+ $sth->finish; >+ } >+ >+ if ($search ne $lt) { >+ my $green = 0; >+ #Results after the cn_sort >+ $query = "SELECT b.title, itemcallnumber, biblionumber, i.cn_sort, branchname, author >+ FROM items AS i >+ JOIN biblio AS b USING (biblionumber) >+ LEFT OUTER JOIN branches ON (branches.branchcode = homebranch) >+ WHERE i.cn_sort >= '$cn_sort' >+ AND itemcallnumber != '' >+ ORDER BY cn_sort, itemnumber >+ LIMIT $real_limit"; >+ $sth = $dbh->prepare($query); >+ $sth->execute(); >+ while ( my $data = $sth->fetchrow_hashref ) { >+ if ($data->{itemcallnumber} eq $q) { >+ $data->{background} = 'red'; >+ $red = 1; >+ } >+ elsif (($data->{cn_sort} gt $cn_sort_q) && !$green && !$red) { >+ push @cn, {'background' => 'green'}; >+ $green = 1; >+ } >+ push @cn, $data; >+ } >+ $rows_gt = $sth->rows; >+ if ($rows_gt == 0 && !$green && !$red){ >+ push @cn, {'background' => 'green'}; >+ } >+ >+ $sth->finish; >+ } >+ >+ $template->param('q' => $q); >+ $template->param('cn_loop' => \@cn) if $#cn != -1; >+ $template->param('popup' => defined($cgi->param('popup'))); >+ >+ >+ output_html_with_http_headers $cgi, $cookie, $template->output; >+} >+ >+1; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css >index 1759f46..15eeca5 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css >+++ b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css >@@ -2780,3 +2780,8 @@ span.onsite_checkout { > .branchselector { > display: table; > } >+ >+div#course_reserves_wrapper > table#course_reserves { >+ margin: auto; >+ width:90%; >+} >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/cn_browser.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/cn_browser.tt >new file mode 100644 >index 0000000..1c4d5e2 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/cn_browser.tt >@@ -0,0 +1,61 @@ >+[% INCLUDE 'doc-head-open.inc' %] >+<title>Koha › Tools</title> >+<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" /> >+[% INCLUDE 'doc-head-close.inc' %] >+</head> >+<body> >+[% UNLESS ( popup ) %] >+[% INCLUDE 'header.inc' %] >+[% INCLUDE 'cat-search.inc' %] >+[% END %] >+ >+<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.dataTables.min.js"></script> >+<script language="JavaScript"> >+$(document).ready(function() >+{ >+ $("#course_reserves").DataTable({"paging": false, "bFilter": false, "info": false}); >+ $("#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> >+ >+<h1 style="text-align:center">Call numbers browser</h1> >+ >+<div style="margin:auto;text-align:center;"> >+ <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 %]" /> >+ <input id="cn_browser_submit" type="submit" value="Search" /> >+ </form> >+</div> >+<br /> >+ >+<table id="course_reserves"> >+ <thead><tr> >+ <th>Call Number</th> >+ <th>Title</th> >+ <th>Branch</th> >+ </tr></thead> >+ <tbody> >+[% FOREACH cn_loo IN cn_loop %] >+ <tr> >+ <td style="background:[% cn_loo.background %];">[% cn_loo.itemcallnumber %]</td> >+ <td style="background:[% cn_loo.background %];"> >+ <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% cn_loo.biblionumber %]"> >+ [% cn_loo.title %] [% cn_loo.subtitle %] [% cn_loo.subtitle2 %] >+ [% IF ( cn_loo.author ) %] >+ <span>by</span> [% cn_loo.author %] >+ [% END %] >+ </a> >+ </td> >+ <td style="background:[% cn_loo.background %];">[% cn_loo.branchname %]</td> >+ </tr> >+[% END %] >+ </tbody> >+</table> >+ >+<br /> >-- >1.9.1
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 13364
:
34041
|
34108
|
34109
|
34476
|
34540
|
34541
|
34542
|
34543
|
34586
|
34587
|
34588
|
34589
|
35067
|
35549
|
36194
|
36235
|
36249
|
36431
|
36596
|
36597
|
36598
|
36599
|
36600
|
36601
|
36723
|
36782
|
37192
|
37193
|
37194
|
37195
|
38010
|
38011
|
38018
|
38019
|
38894