Koha/koha-tmpl/intranet-tmpl/prog/en/modules/admin/items_search_fields.tt
Julian Maurice 7c2ff7940e Bug 11425: Add item search form in staff interface
Item search is available at catalogue/itemsearch.pl (link is in
catalogue/search.pl)
It only uses SQL (not Zebra)
* Use DataTables and server-side processing to be able to filter on
  individual columns after the first search is done.
* Allow to export results in CSV
* With Javascript disabled, search form still works (and CSV export too)

There is the possibility to define "Custom search fields" in a new admin
page admin/items_search_fields.pl (link is in admin/admin-home.pl)
A custom item search field is defined by:
* a name: its unique identifier
* a label: the text displayed to the user
* a MARC field/subfield: the field/subfield to query (it uses
  ExtractValue)
* an authorised values list (optional): if defined the list is displayed
  in the search form

New Perl dependency: Template::Plugin::JSON::Escape

Test plan:
1/ Apply the patch and run updatedatabase.pl
2/ Go to advanced search (staff interface), then click on "Go to item
search"
3/ Play with the search form! :)
In the 3rd fieldset you can add as many fields as you want and combine them with
boolean operators (AND, OR). You can use SQL jokers characters (%, _)
You can output to screen (in a DataTables table) or to a CSV file.
4/ In the DataTables table, play with filters and try sorting columns.
5/ Disable Javascript (with Firefox: extensions NoScript or YesScript,
or in about:config 'javascript.enabled' = false
6/ Reload the search page and do some searches on screen output. (there
is no sorting or filtering features, but there is still pagination)
7/ Try again CSV output.
8/ You can re-enable Javascript.
9/ Go to Administration > Items search fields
10/ Add a new field. Example for title (in UNIMARC):
  Name: title
  Label: Title
  MARC field: 200
  MARC subfield: a
  Authorised values category: None
(add another field with an authorised values category to see the
difference).
11/ As you are there try to update and delete some fields.
12/ Go back to items search form. You can see in the 3rd fieldset that
your fields have appeared in the selects.
13/ Try searching on them.
14/ I think you're done :)

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Work as described. Good new option.
No koha-qa errors

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2014-11-04 19:08:12 -03:00

95 lines
3.4 KiB
Text

[% INCLUDE 'doc-head-open.inc' %]
<title>Koha &rsaquo; Administration &rsaquo; Items search fields</title>
[% INCLUDE 'doc-head-close.inc' %]
</head>
<body id="admin_itemssearchfields" class="admin">
[% INCLUDE 'header.inc' %]
[% INCLUDE 'cat-search.inc' %]
<div id="breadcrumbs">
<a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
<a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo;
Items search fields
</div>
<div id="doc3" class="yui-t2">
<div id="bd">
<div id="yui-main">
<div class="yui-b">
[% IF field_added %]
<div class="dialog">
Field successfully added: [% field_added.label %]
</div>
[% ELSIF field_not_added %]
<div class="alert">
<p>Failed to add field. Please check if the field name doesn't already exist.</p>
<p>Check logs for more details.</p>
</div>
[% ELSIF field_deleted %]
<div class="dialog">
Field successfully deleted.
</div>
[% ELSIF field_not_deleted %]
<div class="alert">
<p>Failed to delete field.</p>
<p>Check logs for more details.</p>
</div>
[% ELSIF field_updated %]
<div class="dialog">
Field successfully updated: [% field_updated.label %]
</div>
[% ELSIF field_not_updated %]
<div class="alert">
<p>Failed to update field.</p>
<p>Check logs for more details.</p>
</div>
[% END %]
<h1>Items search fields</h1>
[% IF fields.size %]
<table>
<thead>
<tr>
<th>Name</th>
<th>Label</th>
<th>MARC field</th>
<th>MARC subfield</th>
<th>Authorised values category</th>
<th>Operations</th>
</tr>
</thead>
<tbody>
[% FOREACH field IN fields %]
<tr>
<td>[% field.name %]</td>
<td>[% field.label %]</td>
<td>[% field.tagfield %]</td>
<td>[% field.tagsubfield %]</td>
<td>[% field.authorised_values_category %]</td>
<td>
<a href="/cgi-bin/koha/admin/items_search_field.pl?name=[% field.name %]" title="Edit [% field.name %] field">Edit</a>
<a href="/cgi-bin/koha/admin/items_search_fields.pl?op=del&name=[% field.name %]" title="Delete [% field.name %] field">Delete</a>
</td>
</tr>
[% END %]
</tbody>
</table>
[% END %]
<form action="" method="POST">
<fieldset class="rows">
<legend>Add a new field</legend>
[% INCLUDE 'admin-items-search-field-form.inc' field=undef %]
<div>
<input type="hidden" name="op" value="add" />
</div>
<fieldset class="action">
<input type="submit" value="Add this field" />
</fieldset>
</fieldset>
</form>
</div>
</div>
<div class="yui-b">
[% INCLUDE 'admin-menu.inc' %]
</div>
</div>
[% INCLUDE 'intranet-bottom.inc' %]