Bug 8211: Add exploded search options

When working with hierarchical subject headings, it is sometimes helpful
to do a search for all records with a specific subject, plus
broader/narrower/related subjects. This patch adds support for these
"exploded" subject searches to Koha.

To test:
1) Make sure you have a bunch of hierarchical subjects. I created
   geographical subjects for "Arizona," "United States," and "Phoenix,"
   and linked them together using 551s, and made sure I had a half
   dozen records linking to each (but not all to all three).
2) Do a search for su-br:Arizona (or choose "Subject and broader terms"
   on the advanced search screen with "more options" displayed), and
   check that you get the records with the subject "Arizona" and the
   records with the subject "United States"
3) Do a search for su-na:Arizona (or choose "Subject and narrower terms"
   on the advanced search screen with "more options" displayed), and
   check that you get the records with the subject "Arizona" and the
   records with the subject "Phoenix"
4) Do a search for su-rl:Arizona (or choose "Subject and related terms"
   on the advanced search screen with "more options" displayed), and
   check that you get the records with the subject "Arizona," the
   records with the subject "United States," and the records with the
   subject "Phoenix"
5) Ensure that other searches still work (keyword, subject, ccl,
   whatever)
6) Sign off

Technical details:
This patch adds a shim in front of C4::Search::buildQuery in order to
preprocess the query and call the _handle_exploding_search callback.
This shim will allow us to gradually offload query parsing to a new
query parser module.

Signed-off-by: wajasu <matted-34813@mypacks.net>
Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
Bug 8210: add links to authorities to headings in OPAC

At the moment, there is no way to get to an authority record from a bib
record that uses it other than doing a new search on the authority file.
This patch adds a link (a cute little magnifying glass) to linked
authority records on the OPAC detail view for MARC21 and NORMARC
with XSLT enabled. A follow-up patch will add the link to regular mode.
Because UNIMARC handles authorities differently, the link is not added
to the XSLT.

Test plan:
1) Set OPACXSLTDetailsDisplay to 'default'
2) View a record that has some headings that are linked to authority
   records in the OPAC (easiest way to find a record like that is to
   edit a record and add some headings using the thesaurus plugin)
3) Observe the cute little magnifying glass links to the authority.

Revised version of the patch adds a space between the heading and the
magnifying glass.

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Patch works nicely.

If a library does not like to see the
magnifying glass/link to the authority, it's easy to disable it
by adding the line .authlink {display:none;} to OpacUserCSS.
Bug 8210: add links to authorities in normal mode headings

Cherry-picked from BibLibre's work on bug 5888:
opac-detail subject/author links improvements

Added a link to opac-authoritiesdetail.pl when possible.

Only affects 'Normal view'. Does not affect XSLT display.

Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
Bug 7993: Save reports with Group/Subgroup hierarchy

This should make saved reports more manageable.
Group/Subgroup hierarchy is stored in authorised_values,
categories REPORT_GROUP and REPORT_SUBGROUP, connected by
REPORT_SUBGROUP.lib_opac -> REPORT_GROUP.authorised_value

Database changes:
* authorised_values: expanded category to 16 chars
* created default set of REPORT_GROUP authorised values to match
  hardcoded report areas
* reports_dictionary: replaced area int with report_area text, converted
  values
* saved_sql: added report_area, report_group and report_subgroup;
  report_area is not currently used, saved for the record

C4/Reports/Guided.pm:
* Replaced Area numeric values with the mnemonic codes
* get_report_areas(): returns hardcoded areas list
* created get_report_areas(): returns full hierarchy (groups with belonging
  subgroups)
* save_report(): changed iterface, accepts fields hashref as input
* update_sql(): changed iterface, accepts id and fields hashref as input
* get_saved_reports():]
- join to authorised_values to pick group and subgroup name
- accept group and subgroup filter params
* get_saved_report():
- changed iterface, return record hashref
- join to authorised_values to pick group and subgroup name
* build_authorised_value_list(): new sub, moved code from
  reports/guided_reports.pl
* Updated interfaces in:
cronjobs/runreport.pl, svc/report, opac/svc/report: get_saved_report()
reports/dictionary.pl: get_report_areas()
reports/guided_reports.pl

reports/guided_reports_start.tt:
* Reports list:
- added group/subgroup filter
- display area/group/subgroup for the reports
* Create report wizard:
- carry area to the end
- select group and subgroup when saving the report; group defaults to area,
  useful when report groups match areas
* Update report and Create from SQL: added group/subgroup
* Amended reports/guided_reports.pl accordingly

Conflicts:

    C4/Reports/Guided.pm
    admin/authorised_values.pl
    installer/data/mysql/kohastructure.sql
    installer/data/mysql/updatedatabase.pl
    koha-tmpl/intranet-tmpl/prog/en/modules/reports/dictionary.tmpl
    koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tmpl
    misc/cronjobs/runreport.pl
    reports/dictionary.pl
    reports/guided_reports.pl

Signed-off-by: Delaye Stephane <stephane.delaye@biblibre.com>
Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
Bug 7993 follow-up DBRev number
Bug 7751: Decrease Loans for Items in Demand for Holds

Rebase and merge based on Mark Gavillet's patch to reduce
the loan period given to items on renewal when they are
in high demand for holds

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Bug 5357: Adds a new page for searching subscriptions

Test plan:
- go on the serial module
- click on the 'Advanced search' link (right of subscriptions search in
the header)
- Search subscriptions (by ISSN, title, EAN, Publisher, Supplier and/or
  Branch)
- Check results are correct

Signed-off-by: Corinne HAYET <corinne.hayet@bulac.fr>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
Bug 5357: Follow-up - layout and EAN search

1) EAN search should be hidden if marcflavour is not UNIMARC
2) Fixes layout to match the advanced search in acquisitions
- labels in front of the fields instead of separate lines
- adds a legend to the form and moves the toggle for the search form to it

To test:
- EAN search field should only show up when marcflavour system preference
  is set to UNIMARC
- Check layout is consistent and you like it
- Check toggle for advanced search still behaves the same

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>