Bugzilla – Attachment 62006 Details for
Bug 18394
Add an option to item search to export a barcodes file
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF] Bug 18394: Remove useless code from item search
SIGNED-OFF-Bug-18394-Remove-useless-code-from-item.patch (text/plain), 11.94 KB, created by
Owen Leonard
on 2017-04-10 15:52:51 UTC
(
hide
)
Description:
[SIGNED-OFF] Bug 18394: Remove useless code from item search
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2017-04-10 15:52:51 UTC
Size:
11.94 KB
patch
obsolete
>From 63237d1e4cfb9cf026bfcfe5644658a6295177dd Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Thu, 6 Apr 2017 14:26:08 +0200 >Subject: [PATCH] [SIGNED-OFF] Bug 18394: Remove useless code from item search > >The item search was originally designed to work even with JS disabled. >Since bug 15111, the staff interface does not work at all without JS, so some >parts of this code are useless and should be removed > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> >--- > catalogue/itemsearch.pl | 147 +++++++++------------ > .../prog/en/includes/catalogue/itemsearch_item.inc | 24 ---- > .../en/includes/catalogue/itemsearch_items.inc | 49 ------- > .../prog/en/modules/catalogue/itemsearch.tt | 19 +-- > 4 files changed, 66 insertions(+), 173 deletions(-) > delete mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.inc > delete mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_items.inc > >diff --git a/catalogue/itemsearch.pl b/catalogue/itemsearch.pl >index fa6b357..66a9cf7 100755 >--- a/catalogue/itemsearch.pl >+++ b/catalogue/itemsearch.pl >@@ -36,10 +36,10 @@ my $cgi = new CGI; > my %params = $cgi->Vars; > > my $format = $cgi->param('format'); >-my ($template_name, $content_type); >+my $template_name = 'catalogue/itemsearch.tt'; >+ > if (defined $format and $format eq 'json') { > $template_name = 'catalogue/itemsearch_json.tt'; >- $content_type = 'json'; > > # Map DataTables parameters with 'regular' parameters > $cgi->param('rows', scalar $cgi->param('iDisplayLength')); >@@ -75,10 +75,8 @@ if (defined $format and $format eq 'json') { > > # Retrieve all results > $cgi->param('rows', 0); >-} else { >- $format = 'html'; >- $template_name = 'catalogue/itemsearch.tt'; >- $content_type = 'html'; >+} elsif (defined $format) { >+ die "Unsupported format $format"; > } > > my ($template, $borrowernumber, $cookie) = get_template_and_user({ >@@ -226,93 +224,78 @@ if (scalar keys %params > 0) { > search_params => $search_params, > results => $results, > total_rows => $total_rows, >- search_done => 1, > ); > >- if ($format eq 'html') { >- # Build pagination bar >- my $url = '/cgi-bin/koha/catalogue/itemsearch.pl'; >- my @params; >- foreach my $p (keys %params) { >- my @v = $cgi->multi_param($p); >- push @params, map { "$p=" . $_ } @v; >- } >- $url .= '?' . join ('&', @params); >- my $nb_pages = 1 + int($total_rows / $search_params->{rows}); >- my $current_page = $search_params->{page}; >- my $pagination_bar = pagination_bar($url, $nb_pages, $current_page, 'page'); >+ if ($format eq 'csv') { >+ print $cgi->header({ >+ type => 'text/csv', >+ attachment => 'items.csv', >+ }); > >- $template->param(pagination_bar => $pagination_bar); >+ for my $line ( split '\n', $template->output ) { >+ print "$line\n" unless $line =~ m|^\s*$|; >+ } >+ } elsif ($format eq 'json') { >+ output_with_http_headers $cgi, $cookie, $template->output, 'json'; > } >-} > >-if ($format eq 'html') { >- # Retrieve data required for the form. >- >- my @branches = map { value => $_->branchcode, label => $_->branchname }, Koha::Libraries->search( {}, { order_by => 'branchname' } ); >- my @locations; >- foreach my $location (@$location_values) { >- push @locations, { >- value => $location->{authorised_value}, >- label => $location->{lib} // $location->{authorised_value}, >- }; >- } >- my @itemtypes; >- foreach my $itemtype ( Koha::ItemTypes->search ) { >- push @itemtypes, { >- value => $itemtype->itemtype, >- label => $itemtype->translated_description, >- }; >- } >+ exit; >+} > >- my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => 'items.ccode', authorised_value => { not => undef } }); >- my $ccode_avcode = $mss->count ? $mss->next->authorised_value : 'CCODE'; >- my $ccodes = GetAuthorisedValues($ccode_avcode); >- my @ccodes; >- foreach my $ccode (@$ccodes) { >- push @ccodes, { >- value => $ccode->{authorised_value}, >- label => $ccode->{lib}, >- }; >- } >+# Display the search form > >- my @notforloans; >- foreach my $value (@$notforloan_values) { >- push @notforloans, { >- value => $value->{authorised_value}, >- label => $value->{lib}, >- }; >- } >- >- my @items_search_fields = GetItemSearchFields(); >+my @branches = map { value => $_->branchcode, label => $_->branchname }, Koha::Libraries->search( {}, { order_by => 'branchname' } ); >+my @locations; >+foreach my $location (@$location_values) { >+ push @locations, { >+ value => $location->{authorised_value}, >+ label => $location->{lib} // $location->{authorised_value}, >+ }; >+} >+my @itemtypes; >+foreach my $itemtype ( Koha::ItemTypes->search ) { >+ push @itemtypes, { >+ value => $itemtype->itemtype, >+ label => $itemtype->translated_description, >+ }; >+} > >- my $authorised_values = {}; >- foreach my $field (@items_search_fields) { >- if (my $category = ($field->{authorised_values_category})) { >- $authorised_values->{$category} = GetAuthorisedValues($category); >- } >- } >+$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => 'items.ccode', authorised_value => { not => undef } }); >+my $ccode_avcode = $mss->count ? $mss->next->authorised_value : 'CCODE'; >+my $ccodes = GetAuthorisedValues($ccode_avcode); >+my @ccodes; >+foreach my $ccode (@$ccodes) { >+ push @ccodes, { >+ value => $ccode->{authorised_value}, >+ label => $ccode->{lib}, >+ }; >+} > >- $template->param( >- branches => \@branches, >- locations => \@locations, >- itemtypes => \@itemtypes, >- ccodes => \@ccodes, >- notforloans => \@notforloans, >- items_search_fields => \@items_search_fields, >- authorised_values_json => to_json($authorised_values), >- ); >+my @notforloans; >+foreach my $value (@$notforloan_values) { >+ push @notforloans, { >+ value => $value->{authorised_value}, >+ label => $value->{lib}, >+ }; > } > >-if ($format eq 'csv') { >- print $cgi->header({ >- type => 'text/csv', >- attachment => 'items.csv', >- }); >+my @items_search_fields = GetItemSearchFields(); > >- for my $line ( split '\n', $template->output ) { >- print "$line\n" unless $line =~ m|^\s*$|; >+my $authorised_values = {}; >+foreach my $field (@items_search_fields) { >+ if (my $category = ($field->{authorised_values_category})) { >+ $authorised_values->{$category} = GetAuthorisedValues($category); > } >-} else { >- output_with_http_headers $cgi, $cookie, $template->output, $content_type; > } >+ >+$template->param( >+ branches => \@branches, >+ locations => \@locations, >+ itemtypes => \@itemtypes, >+ ccodes => \@ccodes, >+ notforloans => \@notforloans, >+ items_search_fields => \@items_search_fields, >+ authorised_values_json => to_json($authorised_values), >+); >+ >+output_html_with_http_headers $cgi, $cookie, $template->output; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.inc >deleted file mode 100644 >index 8f65913..0000000 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.inc >+++ /dev/null >@@ -1,24 +0,0 @@ >-[%- USE Branches -%] >-[%- USE Koha -%] >-[% biblio = item.biblio %] >-[% biblioitem = item.biblioitem %] >-<tr> >- <td> >- <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblio.biblionumber %]" title="Go to record detail page">[% biblio.title %]</a> >- [% IF ( Koha.Preference( 'marcflavour' ) == 'UNIMARC' && biblio.author ) %] by[% END %] [% biblio.author |html %] >- </td> >- <td>[% biblioitem.publicationyear || biblio.copyrightdate %]</td> >- <td>[% biblioitem.publishercode %]</td> >- <td>[% biblioitem.collectiontitle %]</td> >- <td> >- <a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% biblio.biblionumber %]#item[% item.itemnumber %]" title="Go to item details">[% item.barcode %]</a> >- </td> >- <td>[% item.itemcallnumber %]</td> >- <td>[% Branches.GetName(item.homebranch) %]</td> >- <td>[% Branches.GetName(item.holdingbranch) %]</td> >- <td>[% item.location %]</td> >- <td>[% item.stocknumber %]</td> >- <td>[% item.status %]</td> >- <td>[% item.issues || 0 %]</td> >- <td><a href="/cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber=[% item.biblionumber %]&itemnumber=[% item.itemnumber %]">Edit</a></td> >-</tr> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_items.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_items.inc >deleted file mode 100644 >index 33aa9de..0000000 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_items.inc >+++ /dev/null >@@ -1,49 +0,0 @@ >-[% names = CGI.param() %] >-[% params = [] %] >-[% FOREACH name IN names %] >- [% IF name != 'sortby' AND name != 'sortorder' %] >- [% params.push(name _ "=" _ CGI.param(name)) %] >- [% END %] >-[% END %] >-[% base_url = "/cgi-bin/koha/catalogue/itemsearch.pl?" _ params.join('&') %] >- >-[% BLOCK itemsearch_header %] >- [% sortorder = 'asc' %] >- [% classes = [] %] >- [% IF CGI.param('sortby') == name %] >- [% classes.push('active') %] >- [% classes.push('sort-' _ CGI.param('sortorder')) %] >- [% IF CGI.param('sortorder') == 'asc' %] >- [% sortorder = 'desc' %] >- [% END %] >- [% END %] >- [% url = base_url _ '&sortby=' _ name _ '&sortorder=' _ sortorder %] >- <th class="[% classes.join(' ') %]"> >- <a href="[% url %]" title="Sort on [% label %] ([% sortorder %])">[% text %]</a> >- </th> >-[% END %] >- >-<table> >- <thead> >- <tr> >- [% INCLUDE itemsearch_header name='title' label='title' text='Title' %] >- [% INCLUDE itemsearch_header name='publicationyear' label='publication date' text='Publication date' %] >- [% INCLUDE itemsearch_header name='publishercode' label='publisher' text='Publisher' %] >- [% INCLUDE itemsearch_header name='collectiontitle' label='collection' text='Collection' %] >- [% INCLUDE itemsearch_header name='barcode' label='barcode' text='Barcode' %] >- [% INCLUDE itemsearch_header name='itemcallnumber' label='callnumber' text='Call number' %] >- [% INCLUDE itemsearch_header name='homebranch' label='home branch' text='Home library' %] >- [% INCLUDE itemsearch_header name='holdingbranch' label='holding branch' text='Current location' %] >- [% INCLUDE itemsearch_header name='location' label='location' text='Shelving location' %] >- [% INCLUDE itemsearch_header name='stocknumber' label='inventory number' text='Inventory number' %] >- [% INCLUDE itemsearch_header name='notforloan' label='status' text='Status' %] >- [% INCLUDE itemsearch_header name='issues' label='issues' text='Checkouts' %] >- <th></th> >- </tr> >- </thead> >- <tbody> >- [% FOREACH item IN items %] >- [% INCLUDE 'catalogue/itemsearch_item.inc' item = item %] >- [% END %] >- </tbody> >-</table> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt >index e88d774..a904146 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt >@@ -487,23 +487,6 @@ > </div> > </div> > <div id="doc3" class="yui-t7"> >- <div id="results-wrapper"> >- [% IF search_done %] >- [% IF total_rows > 0 %] >- <p>Found [% total_rows %] results.</p> >- [% ELSE %] >- <p>No results found.</p> >- [% END %] >- >- [% IF results %] >- [% INCLUDE 'catalogue/itemsearch_items.inc' items = results %] >- [% END %] >- >- <div class="pages"> >- [% pagination_bar %] >- </div> >- >- [% END %] >- </div> >+ <div id="results-wrapper"></div> > > [% INCLUDE 'intranet-bottom.inc' %] >-- >2.1.4
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 18394
:
61937
|
61938
|
62006
|
62007
|
62068
|
62069