Bug 11221: ensure that SQLHelper uses NULL rather than 0000-00-00 as default date value

The default values for date fields is undef, so if a date field contains
an empty string, we should insert NULL in the DB, not 0000-00-00.
The format_date_in_iso routine should be only called if a date is
defined, is not equal to an empty string and does not match the iso
regex.

This patch fixes a bug where editing or creating a patron record
without setting the birth date results in 0000-00-00 rather than null
being set as the dateofbirth value.

Partial test plan:
1. Create a new patron. Leave dateofbirth empty.
2. Save the record.
3. Open the record for editing.
4. Save the record without making changes.
5. Koha gives no error.

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Passes all tests and QA script.
Now when no date is given NULL is saved to the database.

Tested:
- Adding a patron without date of birth
- Editing the patron, entering a date of birth
- Editing the patron, deleting date of birth
All worked as expected.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 11221: (follow-up) add unit test to test handling empty strings as dates

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
All tests pass.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 11221: (follow-up) test for NULL rather than empty string

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Merge branch 'new/bug11221' into 3.14.x
bug 8854: fix some invoice search filters

Fix the supplier, shipment date, and library filters
on the invoice search.  An invoice's library is
(in parallel with order search) defined as the library
of the staff member that approved the basket.  Before this
patch, the code was referring to an aqorders.branchcode
column that doesn't exist.

This patch also improves the author, title, ISBN/EAN/ISSN,
publisher, and publication year filters to no longer require
exact matches; substring matches now suffice.

Finally, this patch considers biblio.copyrightdate in addition
to biblioitems.publicationyear for publication date searches, as
the MARC21 frameworks use the former column but not the latter.

This patch also fixes the current test cases for invoices
so that they pass and adds regression tests.

Test plan:

[1] Create two invoices for different vendors.
[2] Do an invoice search and filter on shipment
    date.  Verify that the expected invoice(s)
    are returned.
[3] Do an invoice search and filter on branch
    (of the staff member that approved the basket).
    Verify that the expected invoice(s) are returned.
[4] Do an invoice search and filter on supplier.
    Verify that the expected invoice(s) are returned.
[5] Do invoice searches on author, title, ISBN/EAN/ISSN,
    publisher, and publication year and verify that the
    results are as expected.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>

Patch passes all tests, test plan and QA script.

(Adding from Katrin notes early) I agree with
Possible improvements:
- Document the behaviour of the library search as there are
  lots of branches all over acquisitions with different meaning.
- Add the shipment date to the results list table
- Change label ISBN/EAN/ISSN to not include EAN for MARC21
  installations

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Merge branch 'new/bug8854' into 3.14.x
Bug 11269: fix incorrect use of MARC::Field->subfield()

MARC::Record 2.0.6+ enables the warnings pragma, and as a
consequence, started logging cases where a routine in
C4::Search was calling MARC::Field->subfield() with an undef
subfield label.  This patch removes the log noise.

To test:
- Run prove -v t/db_dependent/Search.t
- There will be warnings about
  "Use of uninitialized value $code_wanted in string" in MARC::Field.
- Apply the patch.
- Those warnings are gone.

Signed-off-by: Liz Rea <liz@catalyst.net.nz>
Tests now pass

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Merge branch 'new/bug11269' into 3.14.x