Bug 9088: if there is only one active order, pre-select it when creating new orderings

This patch makes the following changes to the template:

[1] If you add an order line, and you have one active fund (and zero or
    more inactive funds), the only active fund is preselected.
[2] If you modify an order line while its fund is inactive, it now shows
    the label (inactive) behind the fund name. (Note that other inactive funds
    may come up when clicking 'Show all' as they did before.)
[3] Corrected some indentation in this template part.

Test plan:

[1] Add an order line while having one active fund. Is it selected?
[2] Add an order line while having two or more active funds. No fund
    should be preselected.
[3] Modify an order line with an active fund. Is it still selected?
[4] Modify an order line with an inactive fund F2 (while having one active
    fund F1; note that this test explicitly wants F1 to be before F2).
    Check if F2 is selected and is labeled inactive.
[5] (Bonus points:) Modify an order line that refers to a deleted fund.
    If you edit this order, the fund combo should say: Select a fund.
    (Note: if you delete a fund, the budget_id in aqorders remains.)

Signed-off-by: Paola Rossi <paola.rossi@cineca.it>
I test against master 3.15.00.051
I test against all the three options of the AcqCreateItem:
placing an order
receiving an order
cataloging the record
All is OK.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 12110: Display the order vendor note in basket and basketgroup CSV and PDF

This bug adds the "vendor note" for each order in the PDF for
basketgroups.  The note is displayed only if it exists, just under the
bibliographic information.

I added a separation line "--------" between bibliographic information
and the note, so that it could be visible at 1st glance.

It also replaces the internal note with the vendor in the CSV for basket
and basketgroup.  It is more logical and useful for libraries to export
the note made for vendor, as those files are destined to be sent to the
vendor.

Test plan :
- fill a basket with some orders, some with internal notes, some with
  vendor notes
- export the basket in CSV : only the vendor notes should be present
- put the basket in a basketgroup
- export the basketgroup in CSV : only the vendor notes should be
  present
- Select "English-2 pages" template for basketgroups in Sysprefs
- export the basket in PDF : the vendor notes should be present under
  the bibliographic information
- Select "English-3 pages" template for basketgroups in Sysprefs
- export the basket in PDF : the vendor notes should be present under
  the bibliographic information

Signed-off-by: Paola Rossi <paola.rossi@cineca.it>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 12110: (follow-up) add French and German translation

This followup
- translates "vendor note" in French and German.
- replaces "Notes for vendor" with "Note for vendor" in English template
  (as there can only be 1 note)
- fixes a typo in French template (Qte => Qté, for "Quantité")

Test plan :
[1] set OrderPdfFormat preference to "French 3-pages"
[2] Print a basketgroup containing an order with a vendornote, and check
    the note is displayed and introduced by "Notes pour le fournisseur"
[3] set OrderPdfFormat preference to "German 2-pages"
[4] Print a basketgroup containing an order with a vendornote, and check
    the note is displayed and introduced by "Lieferantennotiz"

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 12110: (follow-up) improve whitespace

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 3050 - Add an option to upload scanned invoices #1/3

(part #1: new module w/ UT + script + template)

New feature, adds an ability to attach arbitrary files to
acquisition records (currently: to the invoices - but it can
be extended to baskets, basketgroups, budgets etc.).

Note: this code is (heavily) based on "Bug 8130 - attach PDF
files to a patron record" by Kale M Hall, main difference being
that new table (misc_files) and new module (Koha/Misc/Files.pm)
are intended to be a little more generic solution - they allow to
store and manage files associated with great many kinds of records,
from arbitrary tables.

Test plan:
1) Apply patch[es]
2) Run installer/data/mysql/updatedatabase.pl
3) Enable system preference 'AcqEnableFiles' in acquisition
4) New option 'Manage invoice files' appears in the invoice
detail page
5) Upload/view/download/delete some files for some invoices
6) Try to delete invoice with files attached (files should
get deleted as well)
7) Try to merge 2+ invoices with files attached; after merge,
all files previously attached to individual invoices being
merged should be attached to resulting invoice (merge destination)
8) prove t/db_dependent/Koha_Misc_Files.t
9) Ensure there are no regressions of any kind in invoice detail
page (acqui/invoice.pl).

Signed-off-by: Paola Rossi <paola.rossi@cineca.it>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 3050 - Add an option to upload scanned invoices #2/3

(part #2: changes to existing acqui scripts & templates)

Signed-off-by: Paola Rossi <paola.rossi@cineca.it>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 3050 - Add an option to upload scanned invoices #3/3

(part #3: DB updates + new syspref)

Signed-off-by: Paola Rossi <paola.rossi@cineca.it>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 3050: QA follow-up

1/ Use the usual way for ordering dates in table
2/ Add a confirmation dialog box on deleting a file
3/ Add some UTs

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 3050: DBRev 3.17.00.002

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 3050: (follow-up) update DBIC schema classes

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 8970 - fix MARC import under plack

There were database handles being shared between a parent and a child
process, which is a big no-no, and was leading to crazy crashes. Fine
under CGI, but not in a persistent environment. This causes the child to
make a new database handle to use. Also some small cleanups.

To test:
* In a plack environment,
* Tools -> stage MARC records for import
* Use a reasonable size file (but not too big as it all goes into RAM -
  I made one about 40MB.)
* Make sure that it works, and that the progress bars progress.

Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Tested with a 55M file, I reproduced the error and I confirm this patch
fixes it.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 7825: Changed OPACItemHolds syspref to be no|yes|force choice

Currently, the Koha system preference OPACItemHolds allows a library
system to choose to allow patrons to place bib and item level holds from
the OPAC, or to allow patrons only to place bib level holds only from
the OPAC.

This patch set adds a third option, "force", which *requires* that
patrons place item level holds from the opac, with no option of making a
bib level hold.

This patch modifies the system preference OPACItemHolds to be of the
type "Choice", with the choices being "no", "yes", "force". The patch
does not alter the currently set value of OPACItemHolds for database
updates, only adding the additional option.

Test Plan:
1) Set OPACItemHolds to "no". Check that OPAC holds behave as it is now
(no "Place On" column, no "Select a specific copy" table, making a
reserve is successful)
2) Set OPACItemHolds to "yes". Check that OPAC holds behave as it is now
( "Place On" column is there, "Select a specific copy" table shows when
"A specific copy" is selected, making a reserve is successful)
3) Set OPACItemHolds to "force". Check that OPAC holds behave as follows:
  -  no "Place On" column is present
  -  "Select a specific copy" table is opened
  -  making a reserve is successful

This patch is a squashed patch of the 3 following patches:

Amended opac-reserve.tt accordingly

Signed-off-by: Delaye Stephane <stephane.delaye@biblibre.com>

Bug 7825: Followup prevent submission without choosing an item

+ Fix some ergonomic issues in opac-reserve

Signed-off-by: Delaye Stephane <stephane.delaye@biblibre.com>

Bug 7825: Updatedatabase should only change the type and options values.

The value field should not be changed. We have to keep '1' for 'yes' and ''
for 'no'.

Original patch is from Srdjan Jankovic.

Signed-off-by: Koha team AMU <koha.aixmarseille@gmail.com>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Testing notes on 4th patch.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 7825: Changed OPACItemHolds syspref to be no|yes|force choice - bootstrap

Same test plan as previous patch but with the bootstrap theme set.

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 7825: (follow-up) clarify the yes and no values

The value of the pref should be '1' (for yes) or '0' (for no).
The options could be kept as 'yes' and 'no': since the ImplicitTyping is
set, yes/no would become '1/0'. But I think it is preferable not to use
the yes/no value in order not to introduce a bug here if ImplicitTyping
is unset later.

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 7825: (follow-up) fix the force value for the bootstrap theme

If the pref was set to 'force', the item selection was not shown.
.copiesrow should be hidden before showing specific #copiesrow_ID

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Passes all tests and QA script.

Works on template level, tested with Boostrap and Prog theme
with all 3 possible seetings of OPACItemHolds:

1) no = offer only title level holds
2) yes = offer both title and item level holds
3) force = offer only item level holds

Also ran some additional tests on the Boostrap theme with
deactivated Javascript.

Note: I like this, but I think when "force" is selected the
item list needs to be shown by default. I am also not happy about
preselecting the first item.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 7825: (follow-up) do not preselect item when OpacItemHolds is 'force'

This patch changes the default behavior for the 'force' value.
If the pref is set to force, no item is preselected and the item list is
shown.

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 7825: (follow-up) do not preselect item when OpacItemHolds is 'force' - bootstrap

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Passes all tests and QA script.
Retested with all 3 themes, works as expected.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 7825: DBrev 3.17.00.003

Signed-off-by: Galen Charlton <gmc@esilibrary.com>