Koha/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt
Jonathan Druart 65c4d8019e Bug 15836: Add the ability to defined custom methods to split call number in labels
Currently the call number splitting seems to be mostly implemented for
DDC and LC classifications.
Those are both not very common in some countries.
A lot of libraries use their own custom classification schemes so the call number
plitting is something that should be individually configurable.

This enhancement adds the ability to define custom splitting rules based
on regular expressions.

How does it work so far?
From C4/Labels/Label.pm there are 3 differents splitting methods defined, depending on items.cn_source.
  if cn_source is "lcc' or 'nlm' we split using Library::CallNumber::LC
  if cn_source is 'ddc' we split using a in-house method
Finally there is a fallback method to split on space
And nothing else is done for other cn_source

The idea of this patch is to mimick what was done for the "filing rules" and add
the ability to define "splitting rules" that will be used by the "Classification sources".
A classification source will then have:
  * a filing rule used to sort items by callnumbers
  * a splitting rule used to print labels

To acchieve this goal this enhancement will do the following
modifications at DB level:
* New table class_split_rules
* New column class_sources.class_split_rule

Test plan:
* Execute the update database entry to create the new table and
column.
I. UI Changes
a) Create/modify/delete a filing rule
b) Create/modify/delete a splitting rule
c) Create/modify/delete a classification source
=> A filing rule or splitting rule cannot be removed if used by a
classification source

II. Splitting rule using regular expressions
a) Create a splitting rule using the "Splitting routine" "RegEx"
b) Define several regular expressions, they will be applied one after
the other in the same order you define them.
Something like:
  s/\s/\n/g         # Break on spaces
  s/(\s?=)/\n=/g    # Break on = (unless it's done already)
  s/^(J|K)\n/$1 /   # Remove the first break if callnumber starts with J or K
c) You can test the regular expressions using filling the textarea with
a list of callnumbers. Then click "Test" and confirm the callnumbers are
split how you expected.
d) Finally create a new classification source that will use this new
splitting rule.

III. Print the label!
a) Create a layout. It should have the "Split call numbers" checkbox
ticked, and display itemcallnumber
b) Use this layout to export labels, use items with different
classification source ('lcc', 'ddc', but also the new one you have
create)
=> The callnumbers should have been split according to the regex you
defined earlier!

Notes:
* The update database entry fill the class_sources.class_split_rule
with the value of class_sources.class_sort_rule
If default rules exist it will not work, we should add a note in the
release notes (would be enough?)
* C4::ClassSplitRoutine::* should be moved to Koha::ClassSplitRule,
but it sounded better to keep the same pattern as ClassSortRoutines
* Should not we use a LONGTEXT for class_split_rules.split_regex instead
of VARCHAR(255)?

* class_sources.sql should be filled for other languages before pushed
to master!

IMPORTANT NOTES: The regular expressions are stored as it, and eval is
used to evaluate it (perlcritic raises a warning about it (Expression
form of "eval"). It can lead to serious security issues (execution of
arbitrary code on the server), especially if the modifier 'e' is used.
We could then remedy the situation with one of these following points:
- Assume that this DB data is safe (We can add a new permission?)
- Assume that the data is not safe and deal with possible attack
Cons: how be sure we are exhaustive? Making sure it matches ^s///[^e/]*$
would be enough?
- Use Template Toolkit syntax instead (Really safer?)
  [% callnumber.replace('\s', '\n').replace ... %]
- Cut the regex parts: find, replace, modifiers
like we already do for Marc modification template. Cons: we are going to
have escape problems, the "find" and "replace" parts should not be
handle the same way (think "\n", "\\n", "\1", "\s", etc.)
I did not manage to implement this one easily.

Sponsored-by: Goethe-Institut

Signed-off-by: Christian Stelzenmüller <christian.stelzenmueller@bsz-bw.de>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-11-13 15:18:22 +00:00

197 lines
13 KiB
Text

[% USE Koha %]
[% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha &rsaquo; Administration</title>
[% INCLUDE 'doc-head-close.inc' %]
</head>
<body id="admin_admin-home" class="admin">
[% INCLUDE 'header.inc' %]
[% INCLUDE 'prefs-admin-search.inc' %]
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; Administration</div>
<div class="main container-fluid">
<div class="row">
<div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
<h1>Koha administration</h1>
<div class="row">
<div class="col-md-6 sysprefs">
[% IF ( CAN_user_parameters_manage_sysprefs ) %]
<form action="/cgi-bin/koha/admin/preferences.pl" method="post">
<fieldset>
<h4><a href="/cgi-bin/koha/admin/preferences.pl">Global system preferences</a></h4>
<p>Manage global system preferences like MARC flavor, date format, administrator email, and templates.</p>
<input type="hidden" name="op" value="search" />
<input type="text" name="searchfield" value="[% searchfield | html %]" />
<input type="submit" name="ok" class="submit" value="Search" />
</fieldset>
</form>
[% END %]
[% IF ( CAN_user_parameters_manage_libraries || CAN_user_parameters_manage_itemtypes || CAN_user_parameters_manage_auth_values ) %]
<div class="hint"><h4>Hint:</h4><p>Configure these parameters in the order they appear.</p></div>
<h3>Basic parameters</h3>
<dl>
[% IF ( CAN_user_parameters_manage_libraries ) %]
<dt><a href="/cgi-bin/koha/admin/branches.pl">Libraries</a></dt>
<dd>Define libraries.</dd>
<dt><a href="/cgi-bin/koha/admin/library_groups.pl">Library groups</a></dt>
<dd>Define hierarchical library groups.</dd>
[% END %]
[% IF ( CAN_user_parameters_manage_itemtypes ) %]
<dt><a href="/cgi-bin/koha/admin/itemtypes.pl">Item types</a></dt>
<dd>Define item types used for circulation rules.</dd>
[% END %]
[% IF ( CAN_user_parameters_manage_auth_values ) %]
<dt><a href="/cgi-bin/koha/admin/authorised_values.pl">Authorized values</a></dt>
<dd>Define categories and authorized values for them.</dd>
[% END %]
</dl>
[% END %]
[% IF ( CAN_user_parameters_manage_patron_categories || CAN_user_parameters_manage_circ_rules || CAN_user_parameters_manage_patron_attributes || CAN_user_parameters_manage_transfers || CAN_user_parameters_manage_item_circ_alerts || CAN_user_parameters_manage_cities ) %]
<h3>Patrons and circulation</h3>
<dl>
[% IF ( CAN_user_parameters_manage_patron_categories ) %]
<dt><a href="/cgi-bin/koha/admin/categories.pl">Patron categories</a></dt>
<dd>Define patron categories.</dd>
[% END %]
[% IF ( CAN_user_parameters_manage_circ_rules ) %]
<dt><a href="/cgi-bin/koha/admin/smart-rules.pl">Circulation and fines rules</a></dt>
<dd>Define circulation and fines rules for combinations of libraries, patron categories, and item types</dd>
[% END %]
[% IF ( CAN_user_parameters_manage_patron_attributes ) %]
<dt><a href="/cgi-bin/koha/admin/patron-attr-types.pl">Patron attribute types</a></dt>
<dd>Define extended attributes (identifiers and statistical categories) for patron records</dd>
[% END %]
[% IF ( CAN_user_parameters_manage_transfers ) %]
<dt><a href="/cgi-bin/koha/admin/branch_transfer_limits.pl">Library transfer limits</a></dt>
<dd>Limit the ability to transfer items between libraries based on the library sending, the library receiving, and the item type involved. These rules only go into effect if the preference UseBranchTransferLimits is set to ON.</dd>
<dt><a href="/cgi-bin/koha/admin/transport-cost-matrix.pl">Transport cost matrix</a></dt>
<dd>Define transport costs between branches</dd>
[% END %]
[% IF ( CAN_user_parameters_manage_item_circ_alerts ) %]
<dt><a href="/cgi-bin/koha/admin/item_circulation_alerts.pl">Item circulation alerts</a></dt>
<dd>Define rules for check-in and checkout notifications for combinations of libraries, patron categories, and item types</dd>
[% END %]
[% IF ( CAN_user_parameters_manage_cities ) %]
<dt><a href="/cgi-bin/koha/admin/cities.pl">Cities and towns</a></dt>
<dd>Define cities and towns that your patrons live in.</dd>
[% END %]
</dl>
[% END %]
[% IF CAN_user_plugins && plugins_enabled %]
<h3>Plugins</h3>
<dl>
<dt><a href="/cgi-bin/koha/plugins/plugins-home.pl">Manage plugins</a></dt>
<dd>View, manage, configure and run plugins.</dd>
</dl>
[% END %]
</div>
<div class="col-md-6 sysprefs">
[% IF ( CAN_user_parameters_manage_keywords2koha_mappings || CAN_user_parameters_manage_marc_frameworks || CAN_user_parameters_manage_classifications || CAN_user_parameters_manage_matching_rules || CAN_user_parameters_manage_oai_sets || CAN_user_parameters_manage_item_search_fields || (Koha.Preference('SearchEngine') == 'Elasticsearch' && CAN_user_parameters_manage_search_engine_config) ) %]
<h3>Catalog</h3>
<dl>
[% IF ( CAN_user_parameters_manage_marc_frameworks ) %]
<dt><a href="/cgi-bin/koha/admin/biblio_framework.pl">MARC bibliographic framework</a></dt>
<dd>Create and manage Bibliographic frameworks that define the characteristics of your MARC Records (field and subfield definitions) as well as templates for the MARC editor.</dd>
<dt><a href="/cgi-bin/koha/admin/koha2marclinks.pl">Koha to MARC mapping</a></dt>
<dd>Define the mapping between the Koha transactional database (SQL) and the MARC Bibliographic records.</dd>
[% END %]
[% IF ( CAN_user_parameters_manage_keywords2koha_mappings ) %]
<dt><a href="/cgi-bin/koha/admin/fieldmapping.pl">Keywords to MARC mapping</a></dt>
<dd>Define the mapping between keywords and MARC fields. The keywords are used to find some data independently of the framework.</dd>
[% END %]
[% IF ( CAN_user_parameters_manage_marc_frameworks ) %]
<dt><a href="/cgi-bin/koha/admin/checkmarc.pl">MARC Bibliographic framework test</a></dt>
<dd>Checks the MARC structure. If you change your MARC Bibliographic framework it's recommended that you run this tool to test for errors in your definition.</dd>
<dt><a href="/cgi-bin/koha/admin/authtypes.pl">Authority types</a></dt>
<dd>Create and manage Authorities frameworks that define the characteristics of your MARC Records (field and subfield definitions).</dd>
[% END %]
[% IF ( CAN_user_parameters_manage_classifications ) %]
<dt><a href="/cgi-bin/koha/admin/classsources.pl">Classification sources</a></dt>
<dd>Define classification sources (i.e., call number schemes) used by your collection. Also define filing rules used for sorting call numbers and splitting rules for splitting them.</dd>
[% END %]
[% IF ( CAN_user_parameters_manage_matching_rules ) %]
<dt><a href="/cgi-bin/koha/admin/matching-rules.pl">Record matching rules</a></dt>
<dd>Manage rules for automatically matching MARC records during record imports.</dd>
[% END %]
[% IF ( CAN_user_parameters_manage_oai_sets ) %]
<dt><a href="/cgi-bin/koha/admin/oai_sets.pl">OAI sets configuration</a></dt>
<dd>Manage OAI Sets</dd>
[% END %]
[% IF ( CAN_user_parameters_manage_item_search_fields ) %]
<dt><a href="/cgi-bin/koha/admin/items_search_fields.pl">Item search fields</a></dt>
<dd>Manage custom fields for item search.</dd>
[% END %]
[% IF ( Koha.Preference('SearchEngine') == 'Elasticsearch' && CAN_user_parameters_manage_search_engine_config ) %]
<dt><a href="/cgi-bin/koha/admin/searchengine/elasticsearch/mappings.pl">Search engine configuration</a></dt>
<dd>Manage indexes, facets, and their mappings to MARC fields and subfields.</dd>
[% END %]
</dl>
[% END %]
[% IF ( CAN_user_acquisition_currencies_manage || CAN_user_acquisition_period_manage || CAN_user_acquisition_budget_manage || CAN_user_acquisition_edi_manage ) %]
<h3>Acquisition parameters</h3>
<dl>
[% IF ( CAN_user_acquisition_currencies_manage ) %]
<dt><a href="/cgi-bin/koha/admin/currency.pl">Currencies and exchange rates</a></dt>
<dd>Define currencies and exchange rates used for acquisitions.</dd>
[% END %]
[% IF ( CAN_user_acquisition_period_manage ) %]
<dt><a href="/cgi-bin/koha/admin/aqbudgetperiods.pl">Budgets</a></dt>
<dd>Define your budgets</dd>
[% END %]
[% IF ( CAN_user_acquisition_budget_manage ) %]
<dt><a href="/cgi-bin/koha/admin/aqbudgets.pl">Funds</a></dt>
<dd>Define funds within your budgets</dd>
[% END %]
[% IF ( CAN_user_acquisition_edi_manage ) %]
<dt><a href="/cgi-bin/koha/admin/edi_accounts.pl">EDI accounts</a></dt>
<dd>Manage vendor EDI accounts for import/export</dd>
<dt><a href="/cgi-bin/koha/admin/edi_ean_accounts.pl">Library EANs</a></dt>
<dd>Manage library EDI EANs</dd>
[% END %]
</dl>
[% END %]
[% IF ( ( CAN_user_parameters_manage_search_targets || CAN_user_parameters_manage_didyoumean || CAN_user_parameters_manage_column_config || CAN_user_parameters_manage_audio_alerts || CAN_user_parameters_manage_sms_providers && Koha.Preference('SMSSendDriver') == 'Email' ) || CAN_user_parameters_manage_usage_stats ) %]
<h3>Additional parameters</h3>
<dl>
<!-- <dt><a href="/cgi-bin/koha/admin/printers.pl">Network Printers</a></dt>
<dd>Printers (UNIX paths).</dd> -->
[% IF ( CAN_user_parameters_manage_search_targets ) %]
<dt><a href="/cgi-bin/koha/admin/z3950servers.pl">Z39.50/SRU servers</a></dt>
<dd>Define which external servers to query for MARC data.</dd>
[% END %]
[% IF ( CAN_user_parameters_manage_didyoumean ) %]
<dt><a href="/cgi-bin/koha/admin/didyoumean.pl">Did you mean?</a></dt>
<dd>Choose which plugins to use to suggest searches to patrons and staff.</dd>
[% END %]
[% IF ( CAN_user_parameters_manage_column_config ) %]
<dt><a href="/cgi-bin/koha/admin/columns_settings.pl">Configure columns</a></dt>
<dd>Hide or show columns for tables.</dd>
[% END %]
[% IF ( CAN_user_parameters_manage_audio_alerts ) %]
<dt><a href="/cgi-bin/koha/admin/audio_alerts.pl">Audio alerts</a></dt>
<dd>Define which events trigger which sounds</dd>
[% END %]
[% IF ( CAN_user_parameters_manage_sms_providers && Koha.Preference('SMSSendDriver') == 'Email' ) %]
<dt><a href="/cgi-bin/koha/admin/sms_providers.pl">SMS cellular providers</a></dt>
<dd>Define a list of cellular providers for sending SMS messages via email.</dd>
[% END %]
[% IF ( CAN_user_parameters_manage_usage_stats ) %]
<dt><a href="/cgi-bin/koha/admin/usage_statistics.pl">Share your usage statistics</a></dt>
<dd>Share with the Koha community the usage statistics of your Koha installation.</dd>
[% END %]
</dl>
[% END %]
</div>
</div>
</div>
</div>
[% INCLUDE 'intranet-bottom.inc' %]