TPAC: suppress warning about splice() when the array in question is too short

Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Signed-off-by: Dan Scott <dan@coffeecode.net>
TPAC: Tiny fix for + instead of _ string cat operator

Quiet down, Apache logs.

Signed-off-by: Dan Scott <dan@coffeecode.net>
.gitignore update - ignore more built files

Signed-off-by: Dan Scott <dan@coffeecode.net>
TPac: Circulation history CSV export

This adds a new "Download CSV" button to the TPac circulation history
interface.  The CSV is generated from a new Action/Trigger event
definition.

Signed-off-by: Bill Erickson <berick@esilibrary.com>

Conflicts:

	Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm
	Open-ILS/src/sql/Pg/950.data.seed-values.sql

Signed-off-by: Dan Scott <dan@coffeecode.net>
Wrap upgrade script for CSV circ history export

Thanks, Bill!

Signed-off-by: Dan Scott <dscott@laurentian.ca>
Tpac: record detail print and email

Implements Print and Email actions (as links below add-to-list) in the
tpac record detail page.

The existing bib record print/email A/T seed templates were also updated
like so:

* Instead of using the reporter tables, bib data is fetched and
extracted via unapi, which allows access to SVF data (etc) and is more
consistent with the tpac.

* A number of unused A/T evnironment entries for the seed templates were
removed.

* The delay for the email template was explicitly set to 00:00:00
instead of the default 5 minutes to get the emails out quicker.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Wrap upgrade script for bib record email / print actions

Thanks again to Bill Erickson for another nice piece o' functionality.

Signed-off-by: Dan Scott <dscott@laurentian.ca>
Support per-class sub-object limit/offset

Change the signature for in-db unapi functions so that the limit /
offset arguments become HSTORE values, rather than plain INTEGER values.
This gives you the ability to specify limits and offsets at both the
volume and copy level, via the likes of 'acp=>5, acn=>10' to
specify 5 copies and 10 volumes.

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Dan Scott <dan@coffeecode.net>
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Add per-class limit support to the tag URI parser; correct location/org thinko

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Dan Scott <dan@coffeecode.net>
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
TPAC / unapi: Overhaul copy and located URI display

In unauthenticated mode, sort returned copies in the following order:

1. Search library proximity
2. Search library name
3. (Search results only) Call number, by most available copy status
4. Call number label
5. Copy status availability

Also return & display the copy counts ("x of y copies are available")
for the search library and each of its parents.

We can also determine "preferred library" as follows, taking the first
match:

1. A new GET param, "plib", specifying the number of the OU
2. If authenticated, the user's "search library" preference setting;
3. If authenticated, the user's home library;
4. Physical location in which the search is being issued (if any)

Given a preferred library:

1. Promote the copies (if any) for the preferred library to the top of
   the copy display list.
2. Include the copy count for the preferred library if it is outside of
   the scope of the search library;
3. In record details, give users the ability to jump to their preferred
   library scope via "Show preferred library" beside the preferred
   library copy count, if applicable. If your search library is located
   beneath your pref library in the org hierarchy, then you'll get just
   the "copy depth" link instead.

Also, untangle the located URIs from physical call numbers in
in-database unapi.

We had been facing the limitation of URIs being limited by the maximum
number of call numbers, with the result that URIs may or may not have
been displayed. Now, we take the bold tack of returning all URIs that
are in scope for both the search library and the preferred library. No
limiting is currently possible, but in the realistic worst case scenario
of both search lib and pref lib being set to an OU at depth 4, we'll get
a maximum of 8 different URIs back to display. (More realistically, it's
unlikely that a different URI will be set for each level of the
hierarchy.)

Some of the more granular code changes are as follows:

* Add attributes to in-db unapi acp, sunit, holdings_xml

This gives us more flexibility in displaying due dates within search
results or other contexts in which holdings are displayed. The
age_protect, copy_id, and vol_id attributes are required by the record
summary display.

* Enable TPAC to display records via HSTORE-based unapi

Now that unapi requires HSTORE-based LIMIT and OFFSET arguments, take
the simplest possible approach to get get_records_and_facets() working
again.

In search results, we want to limit both the number of copies we get
back (defaulting to a maximum of 5 copies per call number) and the
number of call numbers we get back (defaulting to a maximum of 5 call
numbers), so that we don't get 50 call numbers each with 5 copies back
and wind up grinding Evergreen's performance down to a halt.

Rough thought is that the caller can filter through the (maximum) 25
hits that are returned to present their preferred results. For example,
a site could opt to show 5 different call numbers with just one copy per
call number, or 5 different copies for a single call number, or all 25.

* Avoid deleted call numbers, copies, and sunits

The rewrite of unapi removed the filters for deleted call numbers that
were added to master in LP# 893315 / commit hash 47a16f516d. Fix this
to prevent returning pages of results that would show nothing in the
TPAC because all of the call numbers were deleted.

* Display multiple URIs correctly

We weren't clearing the hash each time that we added it to the list of
URIs, and that ended up duplicating the URI rather than adding distinct
URIs.

* Take copy availability into account for copy order

This is most important in the LIMITed list of copies returned to the
TPAC search results page, but also useful on the record details page.

This commit adds "copy status ranking" into the result ordering, such
that more available copies will be returned first in the list (and thus,
in the case of search results where call numbers and copies are
typically limited (currently to 5 of 5), ensuring that the most
available copies are likely to be seen by users).

The "availability" ranking for a copy is defined by a new function,
evergreen.rank_cp_status(), that takes criteria from the
config.copy_status table and ranks it in three tiers, as follows:

1. Most available =  opac_visible and copy_active are both TRUE
2. Almost available = holdable and opac_visible are TRUE, but
   copy_active is FALSE, or status ID = 1 ("Checked out")
3. Unavailable = anything else.

Thus, changing copy availability ranking (such as demoting "On holds
shelf" from the "most available" status to "almost available"), is
simply a matter of tweaking the evergreen.rank_cp_status() function.

* unapi database functions: mark STABLE

Thomas Berezansky suggested marking one of the new database functions in
the in-database unapi suite as STABLE to help the optimizer, which lead
to us realizing that everything can be marked as stable. This should
enable the planner to generate better plans than if left to the default
pessimistic level of VOLATILE.

Signed-off-by: Dan Scott <dan@coffeecode.net>
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
TPAC: Fix filtering of org units in record details

The syntax for the filtering clause isn't quite right for the
non-opac-visible org units; remove the braces and win.

Signed-off-by: Dan Scott <dan@coffeecode.net>
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
TPAC: Sort copies from preferred library first

This commit makes copies from the preferred library (if any) sort first
in the displayed copy list in search results and record details, even
if the search scope would otherwise not include the preferred library's
copies at all.

Signed-off-by: Dan Scott <dan@coffeecode.net>
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
TPAC: Show preferred library copies only in consortial scope

A refinement of the preferred library display: only when the user is at
the consortial scope should the preferred library copies float to the
top. At all other scopes, the preferred library copies will appear in
their proper place in the org unit hierarchy (or not at all if outside
of the chosen scope).

Signed-off-by: Dan Scott <dan@coffeecode.net>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Stamping upgrade script for in-db unAPI + TPAC cleanup from Dan Scott

Signed-off-by: Mike Rylander <mrylander@gmail.com>
PermaCrud.js flesh support

Now that open-ils.pcrud supports fleshing, allow flesh params to pass
through PermaCrud.js

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
AutoFieldWidget single-object cache repairs

Caching single objects linked off the context object was failing in most
cases as it was caching under the display name instead of the true value
(pkey) for the linked object.  This fixes that by always caching the
linked object by its true value, so that future cache lookups will be
looking in the right place.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Acq: improve General Search's ability to find invoices

Invoices in Evergreen have complex relationships with other items.  They
can be related to lineitems (and ultimately POs and selection lists) by
invoice *entries*, or to PO items (and ultimately etc etc) by invoice
*items*, or directly to purchase orders by either of the above mentioned
acq.invoice_{entry,item} objects.

This should make general search more able to find invoices related to
other objects whose fields you might search against in Acquistions
General search.

Here's a diagram that I created to help me think about how to write
these joins:

https://docs.google.com/drawings/d/15ExkiYvq0skfobbocvPWxwdZkb7aykEZpLGfbP9PL04/edit

At Bill Erickson's suggestion, I wound up putting the joins into an IDL view
("acqus") rather than trying to express them in JSON query, which was turning
into a real time sink.

To prevent this change from making Acq General Search slower than it
was, I've also added indices on all the foreign keys used in the IDL
view, so that the joins should be as fast as possible.

Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
PO Invoice link search by PO instead of Lineitem

The button which allows the user to jump from the PO to linked invoices
now retrieves invoices directly based on the PO ID and instead of
jumping though the lineitem, which only works for POs that have
lineitems (invoiced).

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Stamping upgrade script for ACQ search improvements

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Reload the OPAC via Holdings Maintenance

Makes reloading a page wrapped in util.browser more accessible to foreign
window contexts.  Gives all the interfaces hanging off the chrome OPAC wrapper
the ability to reload the OPAC frame via xulG.reload_opac().  Have Holdings
Maintenance do this whenever its list is refreshed.  And "Add Volumes", whether
invoked from Actions for this Record, or from the click link in the record
summary pane.

Signed-off-by: Jason Etheridge <jason@esilibrary.com>
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>