Bug 12550 - Add ability to delay loading of patron's checkouts in circulation and patron details

Now that a patron's checkouts are loaded asynchronously, we can further
improve Koha's performance by not loading the checkouts table when it is
not needed. For example, if a librarian is checking out 5 items to a
patron, we really don't need to load the table during the scanning of
items 1 to 4, just for item 5. Another example would be browsing to the
patron details table in order to change a patron's password.

Test Plan:
1) Apply this patch
2) Browse to circulation.pl for a patron
3) Note the table is not loaded automatically
4) Click the "Show checkouts" button
5) Note the checkouts table loads
6) Check the "Always show checkouts immediately" checkbox
7) Reload the page, the checkouts should now load immediately
8) Repeat steps 3-7 for the patron details page ( moremember.pl )

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Amended patch: remove trailing spaces.
Note: I am not sure the checkbox is at the best place, but I don't have
a better suggestion.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
Bug 12550 [QA Followup] - Make checking the checkbox load the table of checkouts

Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
Bug 13020 - Checkouts table default ordering is incorrect

The checkouts table is no longer keeping "today's checkouts" in the
order they were scanned.

Test Plan:
1) Create 3 records "Test 1", "Test 2" and "Test 3" each with one item
2) Check out the items to a patron in the order "Test 2", "Test 1", "Test 3".
3) Note the order is incorrect.
4) Apply this patch
5) Refresh the page
6) Note the order is now correct

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Note that the bug already exists before bug 12550. I checked on a 3.14.x
branch (without the ajax circ stuff), and the order is the same as with
this patch.

Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
Bug 13035: Overdue notices send notices for due date in future.

Overdue notices, script uses method days_between which returns always
positive value of days, no mater if due_date is higher or lower from
date_to_run. This causes overdue notices to be send for real overdue and
for checkouts with due date in future, which have same days_between as
in notice triggers.

To reproduce:
1. Set up overdue notice triggers for eg. 2 day.
2. Checkout items for 2 borrowers first gets item with due date 2 days
in past and second gets 2 days in future.
3. run ./misc/cronjobs/overdue_notices.pl -n -t
4. watch that notices was generated for both of them.

To test:
1. Repeat steps 1,2
2. Apply patch
3. run ./misc/cronjobs/overdue_notices.pl -n -t
4. should be 1 notice for borrower with overdue item.

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Passes tests and QA script, just adds an additional test.

Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
Bug 8687 - Overdues: Add utf-8 support to HTML and additional fields to CSV output

This patch contains small improvements made in the overdue_notices.pl script.

- UTF-8 support in the HTML output
- Add the phone, cardnumber, branchname and letternumber columns
  to the csv output

Testing:

I) Create an issue overdue (intranet):
0) Enter in a patron account, add some characters like
   ユーザー別サイト in his address
1) Check if in Patron category administration the overdue column
   is YES for his code
2) In Tools -> Notice triggers define first delay = 7, letter
   Overdue notice. Nothing for second ni third
3) Check if Tools -> Notices and slips, code overdue is available
4) checkout a book with a retard more than 7 days.
5) Check if Adminstration -> Defining circulation and fine rules
   for all libraries has fine rules for his patron category,
   item type book.

II) Before applying the patch
0) Run misc/cronjobs/overdue_notices.pl -n -html .
1) Open the file notices_"date".html in a brower
2) Validate the characters are not correct

III) After applying the patch
0) Run misc/cronjobs/overdue_notices.pl -n -html .
1) Open the file notices_"date".html in a brower
2) Validate the characters are correct
3) Run misc/cronjobs/overdue_notices.pl -n -csv temp.csv
4) Validate phone, cardnumber, branchname and letternumber
   columns and values

Sponsored-by: CCSR

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Passes tests and QA script.
Works as described, no problems found.

Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
Added the Sponsored-by line.