Bug 11628: add missing staffaccess permission to French userflags.sql file

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
This permission exists in other installer files (for all other languages).

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit 1b08f924513daadaff1258659e17d5caf0a53ea4)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 11764 - Move repeatedly redefined function toUC() into staff-global.js

toUC() is repeatedly declared on many administration templates. This
function, used to transform user input to uppercase, can be added to
staff-global.js to prevent repetition.

To test, confirm that transformation to uppercase is working on the
following Administration pages when text is entered in a form field and
focus is moved to the next field:

- Authority types -> New: Test the "Authority type" field.
- MARC bibliographic framework -> New framework: Test the "Framework
  code" field.
- Patron types and categories -> New category: Test the "Category code"
  field.
- Currencies and exchange rates -> New currency: Test the "Currency"
  field.
- Item types -> New item type: Test the "Item type" field.
- Z39.50 client targets -> New Z39.50 server: Test the "Z39.50 server"
  field.

The following pages do not call the toUC function despite the fact that
they included it:

auth_tag_structure.tt
printers.tt
roadtype.tt
stopwords.tt
systempreferences.tt

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
tools/letter.tt declares this js function and don't use it.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit 3c7edd1cbef811de89d6ee0b54cd690dd36d6ff4)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 11765 - Remove unused function isDate from templates

Several administration templates declare but do not use the JavaScript
function isDate(). This patch removes the declarations.

To test, apply the patch and search for instances of "isDate" in Koha
templates, includes, and JavaScript files. There should be no results.

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
I'm not sure this function has ever been used.
This patch removes the toUC in tools/letter.tt too.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit 1aeb1d7e0b4c027b0277f5f5878a3b047abd4b82)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 11773: fix crash in sco-main.pl if no active currency is set

If no currency is defined as active and a patron with debts tries to
check out in welf checkout moduel, sco-main.pl crashes with:

Software error:
Can't use an undefined value as a HASH reference at /usr/share/kohaclone/opac/sco/sco-main.pl line 190.

This patch tests for active currency and simply does not display a
currency symbol if appropriate.

Test plan:

1) Make sure you have a patron with debts and no currency defined as
   active.  (Home › Administration › Currencies & Exchange rates
   › Currencies )
2) Go to Self checkout module and try to checkout an item to this patron
   Result: Crash with error message "Can't use an undefined value as a
   HASH..."
3) Apply patch
4) Reload and try to checkout again
   Expected result: Message "You owe the library..." without currency
   symbol
5) Define a currency as active and try to checkout again
   Expected result: Message "You owe..." with currency symbol

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit 1db56c834b297eb7fd968691f66ef3517771cba5)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 11743 - Remove unused DataTables plugin from OPAC theme directories

The Bootstrap and CCSR theme directories contain older copies of the
DataTables plugin which is no longer in use. This patch removes them
both.

To test, apply the patch and confirm that DataTables still work on the
following pages in both the Bootstrap and CCSR OPAC themes:

- The Cart. Add items to the Cart, open it and confirm that the table is
  sorted correctly.

- The detail page: View the detail page for a title (opac-detail.pl)
  with multiple items and confirm that the table of items is sorted
  correctly.

- A subscription's "full history" page: Navigate to the detail page of a
  subscription in your catalog which has received multiple issues. From
  the subscriptions tab click the "More details" link, then the "Full
  history" link. Confirm that the table of issues is sorted correctly.

- Search history: Enable the EnableOpacSearchHistory system
  preference. Perform a few searches so that your current session
  will record them. View the search history page and confirm that the
  tables of current and past searches are sorted correctly.

- Suggestions (enable 'suggestion' system pref if necessary)
- Tags (enable TagsEnabled if necessary)
- Most popular (enable OpacTopissue if necessary)

- User summary (opac-user.pl): Checkouts, overdues, and holds tables
  should all sort correctly.
- Self checkout: Enable WebBasedSelfCheck if necessary. Check out as a
  patron who has multiple existing checkouts. Confirm that the table is
  sorted correctly.

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Existing uses of datatables.min.js don't point to the theme directory.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit d3c565f12c5c9136588a17e6497d860f6c5e95ed)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 10789: Remove unnecessary calls to $sth->finish in C4::Acquisitions

C4::Acquisitions contained a number of unnecessary calls to
$sth->finish. Removed these and the associated variables introduced to
cache query results between fetch and the return

Where finish was the end of the routine I have added an
explicit return to document that no data is returned.

A number of places made query calls and fetched a single
row. Such a case could require an explicit finish.
These assume that they are looking up with a unique key.
To remove assumptions and isolate the code from future changes
I've switched these to fetching all and returning the
first row. I have commented these cases.

For fuller explanation see perldoc DBI

What I tested:
Edit existing basket, chnged name
Modify order line, change vendor price
Create new basket and add order
Delet this order
Delte this basket
New Basket, new order, user added, user removed
Add contract to vendor, change details, delete contract
Search order biblio
Create basket group, add basket to group, remove basket from group
Delete basket group
Receive order

Everything behaved as I expected

Signed-off-by: Marc Veron <veron@veron.ch>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit 2fac9a76450835337b015956a6f3150586aa5a17)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 10789: Follow-up: Fix typo "infermation"

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit 201af593f885ecb11c76d02baa6e27ef5e744e30)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 10789: Follow-up: restored second SQL parameter in GetLastOrderReceivedFromSubscriptionid

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit e27ea08887a0332692c37b05b15021b14b1bef78)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 11730: ensure that C4::Charset loads C4::Context

C4::Charset::SetMarcUnicodeFlag() fetches system preference
values, so since it invokes routines in C4::Context, it should
load the module.

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit b9d2a832db6d2a75d6466a349b769e8285d1f0c8)

Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 11756: improve default sorting on hold ratios report

The DataTables plugin doesn't by default take multiple columns into
account when sorting. The hold ratios report presents a situation where
it makes sense to sort by default based on two columns: hold count and
title, since there are likely to be many titles with the same hold
count.

This patch adds sorting by default on holds (descending) and title
(ascending). It also modifies the configuration of the title sort to
exclude articles when sorting.

To test, view the hold ratios report. If necessary use the filter form
to reduce the minimum hold ratio and generate more results. Confirm that
the correct columns can be sorted.

Note that by default one can manually trigger sorting on two columns by
shift-clicking the second column header.

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit 7514dc897cc49683915112229667ec1f654873ae)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 11771 - Use validation plugin when creating new MARC framework tag

The page for adding a new tag to a MARC framework includes some
custom form validation JavaScript which can be removed in favor of HTML5
validation attributes and Koha's built-in validation plugin. This patch
does so.

The patch also moves some tag markup creation out of the script and into
the template where it belongs.

To test, apply the patch and go to Administration -> MARC bibliographic
framework -> MARC structure -> New tag. Try submitting the form without
entering a tag number. This should trigger a validation warning.

Submission of the form with valid data should work correctly. Editing an
existing tag should also work correctly.

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Great improvement! Before this patch, I got a JS alert but the form was
submitted anyway.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit d90b4b6a08aa946fd40d1c1a45d1cc4ad64c30e5)
Bug 11749 - Remove unused jQuery plugin jquery.hoverIntent.minified.js from the staff client

The jQuery plugin jquery.hoverIntent.minified.js is used only in the
OPAC, not the staff client. This patch removes it from the staff client.

To test, apply the patch and search for instances of "hoverIntent." Only
references in OPAC templates should be returned.

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit 6fd26558894869c0e80666007cab3b9edb090008)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 11766 - Use validation plugin when creating new authority type

The new authority type entry form uses custom form validation
JavaScript. This patch removes it in favor of using HTML5 validation
attributes and Koha's built-in validation plugin.

To test, go to Administration -> Authority types and click "New
authority type." Try submitting the form without entering any data. You
should see a warning about required fields. Upon entering text in those
fields the warning should disappear.

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit ac9d872fefc867d4f068d425bcfcb929435809bd)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 11767 - Use validation plugin when creating new authority framework tag

The page for adding a new tag to an authority framework includes some
custom form validation JavaScript which can be removed in favor of HTML5
validation attributes and Koha's built-in validation plugin. This patch
does so.

The patch also moves some tag markup out of the script and into the
template where it belongs.

To test, apply the patch and go to Administration -> Authority types ->
MARC structure -> New tag. Try submitting the form without entering a
tag number. This should trigger a validation warning.

Submission of the form with valid data should work correctly. Editing an
existing tag should also work correctly.

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit 5ee8268a8df6ac193aa0500f4b801a3d359c1838)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 11740 - Use new DataTables include in quotes upload template

Bug 10649 introduced a new include file for adding DataTables-related
JavaScript assets. This patch adds use of this include file to the
quotes upload page.

To test you need a CSV file of quotes to upload ( "source","text" ).
Go to Tools -> Quote editor and click the "Import quotes" button. Upload
the CSV file and confirm that the table which previews the import
results loads correctly. Sorting is not enabled, but pagination and
searching should work.

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
No regression found.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit 7d05394ff2b27f7e08e41b908b445a33414edc0e)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 11784 - fix displaying patron images in self checkout

I suppose this bug was introduced with Bug 10636 (patronimage should
have borrowernumber as PK, not cardnumber)

To test:
- Have a Patron with image. Configure everything to show image in SCO.
- Go to SCO and log in patron
- Image does not show up (broken link)
- Apply patch
- Test with prog, ccsr and bootstrap themes
- Image should display

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit 9d5fadb9831f03ab80489f9f18467a1796fc9447)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 11779: fix unexpected change in logged-in library when changing overdue notice triggers

Steps to reproduce:
1) Log into staff intranet
2) Set logged in branch
3) Browse to tools/overdue notice triggers
4) Select a branch from the pulldown that is not your logged in branch
5) use the "Check out" bar at the top of the page to search for a patron
to check out to
6) Once you have landed here, click the "check out" tab link again, or
   the Edit button ( any action really )
7) Note your logged in branch has now changed to the once selected
   when editing the notice/status triggers

This is due to the way the patron search passes the branchcode to be
used via the form. This form assumes the branchcode variable is
always the currently logged in branch, which may not and is not
always the case.

Test Plan:
1) Apply this patch
2) Repeat the steps to reproduce above
3) Note your logged in branch does not change

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Funny bug :) This patch fixes the described issue and should not
introduce regression.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit 858083c8e907bde4efa6842cd45ff91bf1f6e24f)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 11779: (follow-up) improve GetLoggedInBranchcode() and add test cases

This patch adjusts the new GetLoggedInBranchcode() template function so
that it returns the empty string rather than undef if there is no
active user environment.  That way, there won't be lots of undefined
value warnings if/when this function gets used in the OPAC.

This patch also adds test cases.

To test:

[1] Verify that there are no regressions in the main test
    plan for this bug.
[2] Verify that prove -v t/db_dependent/Koha_template_plugin_Branches.t
    passes.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit 065a3a5efa9b90723460a607ac85591c17945b00)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 11783: ensure CD field in SIP patron information response is populated

If a patron has a record-level hold that is unavailable, any patron
information request will send back an empty CD field when this field
should have an item barcode in it [RM note: this actually isn't
universally true -- the SIP2 standard is silent as to what is supposed
to go in the CD field. Some SIP2 devices do indeed want an item
barcode, but others are known to just want a display of the title
and author of the request in question.  Providing an option is the
topic of a new enhancement request, however.]

This is due to a minor error in ILS::Patron::_get_outstanding_holds
where GetItemnumbersForBiblio is assumed to return an array but in
reality returns an arrayref.

Test Plan:
1) Create a record level hold for a patron and record
2) Using SIP2, make a patron information request
3) Note the empty CD fields
4) Apply this patch, restart SIP server
5) Repeat step 2
6) Note the CD field now has a barcode

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
I did not test this patch but the following code shows me it is correct:
  use C4::Items;
  use Data::Dumper;
  my $biblionumber = 5035;
  my $itemnumber = (GetItemnumbersForBiblio($biblionumber))[0];
  say Dumper $itemnumber;
  $itemnumber = (GetItemnumbersForBiblio($biblionumber))->[0];
  say Dumper $itemnumber;

displays:

$VAR1 = [
          '23168',
          '23169',
          '23170',
          '23171',
          '23172'
        ];

$VAR1 = '23168';

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit 37a0e888199f1a1f8eefd38ad6ada786403fe034)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>