Translation updates for 3.14.07 release
Bug 9823: Refactor return from GetReservesFromBiblionumber

The return from GetReservesFromBiblionumber contains an unnecessary
extra variable. In scalar context an array returns its element count.
Maintaining a separate count can lead to unforeseen bugs
and imposes ugly constructions on the subroutine's users.

Remove the useless count variable from the return

This patch also changes the parameters: now the routine takes a hashref.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Placed biblio holds, future holds and item holds. Works as expected.
Tested Holds.t and Reserves.t. Pass.
Tested /cgi-bin/koha/ilsdi.pl?service=GetRecords&id=999 with two holds on
one item. Fine.
C4/SIP/ILS/Item.pm: Looked for "whatever" and "arrayref" and could not find
them anymore. Looks good.
Handled a few unneeded calls in QA follow-up.
Left only one point to-do for serials/routing-preview.pl. See Bugzilla.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit 8b685c1e80db99f24d3ee965b8f8d2badb243153)

Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 9823: QA follow-up for GetReservesFromBiblionumber calls

The template params holds and holdcount are not used in the ISBD template.
Removed the associated code from catalogue/ISBDdetail.pl.
Same applies for catalogue/MARCdetail.pl and labeledMARCdetail.pl.
Same applies also for catalogue/imageviewer.pl.
Same applies also for catalogue/moredetail.pl.

In catalogue detail.tt only the number of holds is used. Removed the code
that passed the holds array to the template.

For consistency opac-detail should also incorporate future holds into its
holds count; added the all_dates parameter for that reason.

The Reserves module is no longer needed in moredetail. Removed it. Checked
the other scripts also.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit e536fd087d540065d2ccbe12925695bb770d4314)

Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 9823: (follow-up) improve POD for C4::Reserves::GetReservesFromBiblionumber

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit 7b58255028da6a9cc4652b32913b01b47e651f1f)

Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 11829: fix JavaScript error on staff client biblio details pages if template variables are undefined

The JavaScript included in cat-toolbar.inc expects several variables to
be passed to the template for use in calculations. Several scripts
do not pass the required variables to the template, leading to a JS
error.

This patch re-adds (See Bug 9823) hold count calculation to the required
scripts and copies the acquisitions-related count calculation from
detail.pl into related bibliographic detail scripts so that the
commonly-included cat-toolbar.inc can receive correct values.

To test, locate a bibliographic record which has no holds and is not
used in a current or deleted order, but which has a local cover image
attached. Check the following views to confirm there is no JavaScript
error:

- Normal
- MARC
- Labeled MARC
- ISBD
- Items
- Images (from the Images tab on the "Normal" detail page)

Next, locate a bibliographic record with no items attached which is used
in an Acquisitions order. On each of the pages listed above, choose
"Delete record" from the Edit menu. This should trigger a warning that
the record is used in an order. Cancel the deletion.

Finally, delete the order which references the bibliographic record. On
each of the pages listed above, choose "Delete record" again. This
should trigger a warning that the record is used in a deleted order.
Cancel the deletion.

I went through the test plan, everything works OK.
It resolves Bug 11831 as well.

Signed-off-by: Marc Véron <veron@veron.ch>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
- Printing from MARC and ISBD view works again
- No more Javascript errors found
- Deleting a record with attached order gives the correct warning,
  both for ordered and cancelled.

Passes all tests and QA script.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit 63d7386ed00f73be837a57aeb12d75c6893ca0bd)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 11798: fix problems with column sorting and row visibility in invoices table

1) Sorting on "Billing date" (functionality introduced by bug 10794)
doesn't work properly any longer after bug 10401 was pushed (another
side-effect being that "Vendor" column is currently not sortable
at all).
2) Only "top ten" invoices are always displayed in the table, and it's
not possible to change that without missing top/bottom DataTables
pagination bars.

This patch fixes sorting for "Billing date" &  "Vendor" columns
in invoices table and restores the ability to see all table
rows/search results (not just "top ten").

Test plan (you'll need to have 11+ invoices with various billing
dates entered in the system):
1) apply patch,
2) view the Acquisitions invoices page (acqui/invoices.pl), do some
search (= as broad search as possible) and confirm that "Billing
date" and "Vendor" columns now do sort correctly,
3) in situations when there are more than 10 search results, they
should all be visible in the invoices table.

NOTE: Generating invoices is a painfully convoluted mess.
      All my "Billing date" entries were blank, so was not
      able to confirm Billing date issues. However, Vendor
      sorting issues, seeing more than 10, and in my bizarre
      initial case the non-visible checkboxes were all fixed.

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit 4ce0848fe35814f2324a8e3d59b3c04f061a858b)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 11078: Add locking to rebuild_zebra

This patch adds locking to rebuild_zebra.pl to ensure that simultaneous
changes are prevented (as one is likely to overwrite the other).
Incremental updates in daemon mode will skipped if the lock is busy
and they will be picked up on the next pass.  Non-daemon mode
invocations will also exit immediately if they cannot get the lock
unless the new flag -wait-for-lock is specified, in which case they
will wait until the get the lock and then proceed.

Supporting changes made to Makefile.PL and templates for the new
locking directory (paralleling the other zebra lock directories).
We stash the zebra_lockdir in koha-conf.xml so rebuild_zebra.pl
can find it.

To address earlier QA concerns we:
1. added code to check if flock is available and ignore locking if
it's missing (from M. de Rooy)

2. changed default for adhoc invocations to abort if they cannot
obtain the lock.  Added option -wait-for-lock if the user prefers
to wait until the lock is free, and then continue processing.

3. added missing entry to t/db_dependent/zebra_config.pl

4. added a fallback locking directory of /tmp

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Doug merged the original patch with the QA changes.
Just for the record, noting here that the original patch was tested
extensively too by Martin Renvoize.
I have added a followup for some exceptional cases.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit 88e7faf8600b64884649f8c02104bf848df37a9b)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 11078: QA Follow-up for missing file permissions on lockfile

The original patch creates a lockfile in the ZEBRA_LOCKDIR.
It can fall back to /var/lock or even /tmp.
If the create fails, it dies. This can be considered as very
exceptional.

This followup adjusts the fallback location in /var/lock or /tmp
slightly.  It appends the database name to the folder in order to
prevent interfering between multiple Koha instances. Creation of the
lockfile has been moved to a subroutine extending directory and file
creation testing.

In the very unlikely case that we cannot create the lockfile (after
three separate tries), this follow-up allows you to continue instead
of die.  This is just as we did before we had file locking here. Every
time skipping a reindex could cause more harm than continuing and
having the race condition once in a while.

Test plan:
Test adding and removing lockdir from your koha-conf.xml. Check fallback.
Note that fallback in /var/lock or /tmp must contain database name.
Remove the lockdir config line and remove permissions from fallback. In
this case the reindex should continue but with a warning.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Tested with daemon and one-off invocation simultaneously.
Tested new wait parameter.
Tried all variations of lock directory (changing permissions etc.)

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit 07de37f0e5ea8685573794ff6a84ab30e32f1973)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 11078: (follow-up) tidy code

- fix a couple typos in comments
- make replace a "$i" with a more descriptive variable name
- style some of the new code

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit 160c44d4e9f529fc6e6ecbdab23ffab6bce5630e)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 7234: koha-common Debian package now includes koha-sites.conf

This patch adds a sample koha-sites.conf file, which will be
included by the koha-common package in /etc/koha (where it belongs).

It is fixed to include the current defaults (DOM indexing for both
biblios and authorities, disabled use of memcached, and good defaults
for a normal setup if enabled).

All options are commented for ease of use by average users.

To test
- verify that the defaults are sane (let me know if it needs to be
  fixed).
- build the package and verify that the file gets installed.

Sponsored-by: Universidad Nacional de Cordoba

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Signed-off-by: Robin Sheat <robin@catalyst.net.nz>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit 9ca12df4a006901b1f4710f364e3acc0259e46a1)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 11866: do not require special permissions to view course reserves in staff interface

A librarian with no course reserves permissions cannot view course
reserves from the staff intranet, yet can from the OPAC. This doesn't
make much sense. Librarians should not require any course reserves
permissions to view courses and reserves from the staff intranet.

Test Plan:
1) Log into staff intranet as a librarian with no course reserves
   permissions
2) Note you cannot view course reserves
3) Apply this patch
4) Note you can now view course reserves
5) Verify you cannot modify courses or course reserves

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Bug 11866 [Follow-up] Staff side course reserves too restrictive

This follow-up patch adds a check for the "UseCourseReserves" system
preference to the display of the Course reserves menu item in the
header.

To test, view the "More" menu with the "UseCourseReserves" system
preference on and off. The menu item should appear and disappear
accordingly.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit 9e5fcb0d5dd230946719ee4825a3d41bd18effe7)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 11866: (follow-up) ensure that empty toolbar is not displayed

If a user does not have course_reserve permission, a an empty toolbar is
displayed.

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit e2de21a943afabc1e9025266d8f1b95df4e57160)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 11866: (follow-up) repair security issue introduced by main patch

The main patch allows /any/ user with an account on the Koha system
to view the staff-side course-reserves home page -- including ordinary
patrons.  This patch repairs the oversight.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit e9903d760e41410bf871053ccccf00c3a037862d)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 11328 - Show local cover images in staff client search results

Local cover images do not appear in staff client search results. This
patch adds them.

To test, enable the LocalCoverImages system preference and add at least
one cover image to a title. Perform a search which will return results
that include your title. Confirm that the local cover image is
displayed.

Search results should also display correctly with and without
AmazonCoverImages enabled as well as with LocalCoverImages disabled.

Signed-off-by: wajasu <matted-34813@mypacks.net>
Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit 9ce9eea2dbb35be4f3f28314cb90f4edb624c31c)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 11794 - restore functioning of opacSerialDefaultTab

The opacSerialDefaultTab system preference should control whether to
show the holdings or subscriptions tab by default on the detail page for
a serial. This behavior was broken when we last updated jQueryUI because
of a change in the jQueryUI active tab class name.

This patch corrects the class on the detail page and removes the old
class from the authorities detail page (where it was unnecessary
anyway).

To test, view a serial record in the OPAC under various settings of the
opacSerialDefaultTab preference. The default tab should correctly follow
the preference.

Test in prog and Bootstrap themes.

Edit: Rebased on current master. Note that the change to
opac-auth-detail.tt is because the page never has more than one tab,
hence doesn't need the "active" designation.

Signed-off-by: Jesse Maseto <jesse@bywatersolutions.com>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Tested in prog and bootstrap.
All tests and QA script pass.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit 15ad3061b2fb11df6ecf5601d5b7d49d7792ba9f)

Conflicts:
	koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt
Bug 11253: tools/inventory.pl: fix handling of inventory date

This patch fixes a stray call to output_pref() that had not been
updated by the patch for 10380, which caused a crash when uploading
a barcode file when the dd/mm/yyyy dateformat is in use.

TEST PLAN
---------
Set I18N/L10N system preference of dateformat to dd/mm/yyyy.
Go to inventory/stocktaking tool.
Browse for the barcode file.
Select the branch (i.e. not All libraries) to match.
Click submit
KABOOM!

Apply patch
Go to inventory/stocktaking tool.
Browse for the barcode file.
Select the branch (i.e. not All libraries) to match.
Click submit
Table displays dates in "Unseen since" column.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Before the patch, I had this error when using dateformat=ddmmyy:
Template process failed: undef error - The 'day' parameter ("2014") to DateTime::new did not pass the 'an integer which is a possible valid day of month' callback at /usr/local/share/perl5/Params/Validate/PP.pm line 633.
This patch corrects the problem.

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Passes all tests and QA script.
Confirmed problem before applying the patch. Tested with the
patch all dateformat setting still work correctly.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit 536345c3b84ac91540b9f20f6e090a7e91343ec6)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 12115: follow-up fix for tools/inventory's output_pref issues

This should correct issues with the output_prefs in the
compareinv2bar logic section of tools/inventory.pl
It is a follow up to bug 11253.

TEST PLAN
---------
NOTE: There should be no distinguishable difference before and
      after the patch. This corrects a works by accident bug.

Back up DB.
Create a small barcode file from books in a given branch.

Set I18N/L10N system preference of dateformat to mm/dd/yyyy.
Go to inventory/stocktaking tool.
Browse for the barcode file.
Click submit just below the 'Use a barcode file' section.
All looks fine in mm/dd/yyyy format.

Set I18N/L10N system preference of dateformat to yyyy-mm-dd.
Go to inventory/stocktaking tool.
Browse for the barcode file.
Click submit just below the 'Use a barcode file' section.
All looks fine in yyyy-mm-dd format.

Set I18N/L10N system preference of dateformat to dd/mm/yyyy.
Go to inventory/stocktaking tool.
Browse for the barcode file.
Click submit just below the 'Use a barcode file' section.
All looks fine in dd/mm/yyyy format.

Apply patch
Restore DB (so results should be comparable to the first result)
Repeat the three testing blocks above.
There should be no visible difference.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit 40378d4a13e9d89bd84da90e9b6c0c5a237af1ef)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 8918: Fix reserve priority in ILS-DI

The priority of new hold requests was not calculated when using ILS-DI.

A new routine is added, C4::Reserves::CalculatePriority(), to calculate
the priority prior to placing a request.

A separate bug report, 11640, covers the changes in reserves to
use this new routine more generally.

This patch does therefore only affect ILS-DI.

Note: ILS-DI already allows you to generate multiple holds on a biblio or
item for the same patron. This patch does not change that behavior.

Test plan:
[1] Place multiple holds using ILS-DI HoldTitle service:
    /cgi-bin/koha/ilsdi.pl?service=HoldTitle&patron_id=BORROWERNUMBER&bib_id=BIBLIONUMBER&request_location=test
    Check the priority.
[2] Do the same using HoldItem service:
    /cgi-bin/koha/ilsdi.pl?service=HoldItem&patron_id=BORROWERNUMBER&bib_id=BIBLIONUMBER&item_id=ITEMNUMBER
    Check the priority again.
[3] Use a biblio with multiple items. Place item level holds on both.
    Check in one of these items in another branch. Confirm transfer.
    Check in the other item in the original branch. Confirm hold.
    Now you have a waiting and a transit hold.
    Test HoldTitle and HoldItem service again a few times.
[4] Enable AllowHoldDateInFuture and add a future hold.
    Now test HoldTitle and HoldItem again and check if these holds are
    inserted before the future hold (lower priority).

January 29, 2014: Rebased this patch and amended it to make a distinction
between fixing the ILS-DI bug and using the new routine.
Updated commit message and test plan (marcelr).

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit 3e344d7e0718e5a8ac810ca5235f68c1e6d3f370)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 8918: (follow-up) improve descriptions of two related sysprefs

Updating pref descriptions for ReservesNeedReturns and ILS-DI:AuthorizedIPs.
Just sideway related to this report, but not important enough to separate.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit 5372082724002476bc7565f7c66a7e6aaa06c24b)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 8918: Add a unit test for CalculatePriority

Rebased on January 29, 2014 (marcelr)
Added text on the two 'is'-statements.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit 52924e7b0ecddcceec8d22299e8fa4c5f04a991a)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>