TPAC: Invalid due dates cause 500 server error

CStore appears to return dates with leading 0s (such as '0212-10-08
23:59:59-05:17:32') with the leading 0s stripped off, resulting in
cases with 1-digit or 3-digit years for which DateTime::Format::ISO8601
returns an error.

We can protect against this problem by adding some defensive code to the
TPAC utility method to add the 0s back to the start of the year. We can
also log the problem when it occurs so that administrators can fix the
problem dates in the database.

Signed-off-by: Dan Scott <dan@coffeecode.net>
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Checkout: further validation of due date override

The check_past() function failed if given a date that was not strictly
in YYYY-mm-dd format; interestingly, a common transposition typo such
as "0212-10-20" results in "212-10-20" getting passed to check_past(),
and therefore generating an invalid date. Throw an exception in
check_past() rather than returning true, because we are not in fact
stating that the due date is in the past - and catch the exception and
flag the due date override box accordingly in the checkout screen.

We could bubble the exception up to the user, but hopefully highlighting
the checkout box as being in an invalid state will catch the attention
of the users.

[LFW: Slightly amended a comment in OpenILS/WWW/EGCatLoader/Util.pm]

Signed-off-by: Dan Scott <dan@coffeecode.net>
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Be more strict about dates we generate

ISO-8601 dates must have a 4-character year component, however strftime does
not left-pad years to 4 characters when the century is one character long even
though the man page for strftime(3) suggests otherwise:

       %F     Equivalent to %Y-%m-%d (the ISO 8601 date format). (C99)

This makes stricter ISO-8601 parsers, such as Perl's DateTime module, unhappy.
So, we'll do it ourselves using the glibc extensions available to strftime for
specifying a padding character and desired length.

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Remove C compiler warning for writeAuditInfo

The C compiler was throwing the following warning:

oils_sql.c: In function 'writeAuditInfo':
oils_sql.c:7244:1: warning: control reaches end of non-void function
[-Wreturn-type]

By shifting the "return 0" to the end of the function, outside of the if
statements, we can ensure that we always return an int value.

Signed-off-by: Dan Scott <dscott@laurentian.ca>
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
LP#1007020: Using checkout, last activity shows as unset

Added usr_activity to $fields for flesh_user function.

Signed-off-by: Mark Cooper <markchristophercooper@gmail.com>
Signed-off-by: Ben Shum <bshum@biblio.org>
Fix autosuggest when in no-vis-check mode

When autosuggest is configured to avoid visiblity checking, it sends a
special org unit id of -1 to the database as a signal.  However, the stored
procedure is expecting a NULL instead.  This allows either by transforming
-1 to NULL within the stored procedure.

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>

Conflicts:

	Open-ILS/src/sql/Pg/002.schema.config.sql
Use current fiscal year for PO creation (API)

When creating a PO, if no fiscal_year is specified by the caller, use
the current fiscal year of the ordering agency.  This change primarily
affects the Open-ILS/src/support-scripts/acq_order_reader.pl script (and
any other direct API callers) which does not offer the user a chance to
set the fiscal year manually.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Serials: Don't force a Receive Unit Template in Alt Serials Control

Mary Llewellyn reported that she used to be able to use serials and
perform copy-less receiving without any value in this field.

The requirement that a value be set in the Receive Unit Template field
of serial distributions was added (by me) in 2.1 to the alternate serials
control interface, but is not enforced at lower levels.

I now believe that requiring a value here must have been a ham-handed
way to avoid a difficult-to-troubleshoot issue in copy-FUL receiving,
but copy-LESS serials receiving workflows indeed don't need this, so
this commit removes the requirement.

Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Signed-off-by: Ben Shum <bshum@biblio.org>
TPAC: Respect location visibility for result copies

Robert Soulliere noted in LP# 1062502 that copies in a location marked
"opac_visible = FALSE" were erroneously being displayed in search
results. This would occur if at least one copy on a record was in a
visible location, but other copies were in an invisible location.

This commit prevents copies in hidden locations from being displayed,
and also adds guards for the visibility of the copy status and the
circulation library.

Signed-off-by: Dan Scott <dscott@laurentian.ca>
Signed-off-by: Robert Soulliere <robert.soulliere@mohawkcollege.ca>
Adding a WHERE clause to prevent timeout of juv-to-adult function

Signed-off-by: Chris Sharp <csharp@georgialibraries.org>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
trivial whitespace cleanup

Locally consistent, globally all over the map in this file.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Added a check for the money.collections_tracker table when using the open-ils.collections.users_of_interest.warning_penalty.retrieve API call.

Users that are already entered into the money.collections_tracker table should not be recalled from the open-ils.collections.users_of_interest.warning_penalty.retrieve API. This change will check for the existance of the user in the money.colletions_tracker table.

Signed-off-by: Steven Callender <stevecallender@esilibrary.com>
Signed-off-by: Bill Erickson <berick@esilibrary.com>
TPAC: Make facet display work as in JSPAC

Namely, this means:
    - You see five facets per category by default, not ten.
    - You can click a link to see all the facets in a category
        (before this it was impossible to display more than ten).
    - When viewing all the facets in a category, you can click a link
        to reduce the list back to five.
    - This number five I'm talking about is configurable in config.tt2.
    - Alphabetical sorting of facets grouped by the same numbers of
      results is restored.

This addresses LP #1065109.

Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>

Conflicts:

	Open-ILS/src/templates/opac/css/style.css.tt2
Enable maintain_control_number() to handle new OCLCnums

In July 2013, per LP# 1049171, OCLC will begin generating control
numbers beginning with the "on" prefix.

Signed-off-by: Dan Scott <dscott@laurentian.ca>
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>

Conflicts:

	Open-ILS/src/sql/Pg/002.schema.config.sql
Merge remote-tracking branch 'upstream/rel_2_2' into rel_2_2