Bug 12729 - Overdue items won't show as overdue in red in circulation
Summary: Overdue items won't show as overdue in red in circulation
Alias: None
Product: Koha
Classification: Unclassified
Component: Circulation (show other bugs)
Version: master
Hardware: All All
: P5 - low normal (vote)
Assignee: Bugs List
QA Contact: Testopia
Depends on: 11703
  Show dependency treegraph
Reported: 2014-08-07 12:18 UTC by Katrin Fischer
Modified: 2015-06-04 23:30 UTC (History)
7 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:

screenshot of list of checkouts (34.56 KB, image/png)
2014-08-07 12:18 UTC, Katrin Fischer
Screenshot of feature working as expected. (24.05 KB, image/png)
2014-08-25 14:36 UTC, Kyle M Hall
Bug 12729 - Overdue items won't show as overdue in red in circulation (2.54 KB, patch)
2014-09-04 13:23 UTC, Dobrica Pavlinusic
Details | Diff | Splinter Review
[SIGNED OFF] Bug 12729 - Overdue items won't show as overdue in red in circulation (2.70 KB, patch)
2014-09-14 19:51 UTC, Katrin Fischer
Details | Diff | Splinter Review
[PASSED QA] Bug 12729 - Overdue items won't show as overdue in red in circulation (2.76 KB, patch)
2014-09-15 11:38 UTC, Kyle M Hall
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Katrin Fischer 2014-08-07 12:18:53 UTC
Created attachment 30577 [details]
screenshot of list of checkouts

In master overdue items won't show in red when overdue. At the top of the screen, the red message indicating the overdues is still there, but in the checkout's table all items show the same.
Comment 1 Kyle M Hall 2014-08-25 14:36:53 UTC
Created attachment 31142 [details]
Screenshot of feature working as expected.

I can't reproduce the issue.
Comment 2 Katrin Fischer 2014-08-25 14:55:20 UTC
Hm, I have run into this multiple times on master by now. Did they 'age' naturally or did you check them out with a past due date?
Comment 3 Katrin Fischer 2014-08-25 22:02:26 UTC
I tested on master again - checked out an item with due date yesterday - the note right to the barcode form is showing, but the date is not red.

What could be the different? I can't figure it out. I tried various dateformat settings too.
Comment 4 Katrin Fischer 2014-08-25 22:12:11 UTC
Hm, only difference I can see is that the checkout date in my table doesn't show a time, but only a date now - on your screenshot it does?

This is the source code of my checked out item:

<tr id="group-id-issues-table_-strong-previous-checkouts-strong-">
<td class="group -strong-previous-checkouts-strong-" colspan="10">
<strong>Previous checkouts</strong>
<tr id="480-1" class="odd group-item group-item--strong-previous-checkouts-strong-" data-group="-strong-previous-checkouts-strong-">
<td class="">10/08/2014</td>
<td class="">
<span class="strong">
<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=30&itemnumber=480#480">transf</a>
<td class="">CF</td>
<td class="">25/08/2014</td>
<td class="">Midway</td>
<td class=""></td>
<td class="">0.00</td>
<td class="">0.00</td>
<td class="">
<span style="padding: 0 1em;">2</span>
<span class="renewals-disabled">Not renewable</span>
<span class="renewals-allowed" style="display: none">
<td class="">
<input id="checkin_480" class="checkin" type="checkbox" value="480" name="checkin">
Comment 5 Owen Leonard 2014-08-26 12:25:47 UTC
I see this problem in my test system too. Some of my checkouts are showing a date and time and some are showing just a date. Not sure if that is related, but is that a bug as well?
Comment 6 Dobrica Pavlinusic 2014-09-04 12:32:01 UTC
Kyle, I'm not quite sure why you are not seeing this bug, but I have some hints what is happening.

In koha-tmpl/intranet-tmpl/prog/en/js/checkouts.js (and probably other places) you are using

var due = new Date( oObj.date_due );

to create date. However, in my installation oObj.date_due is

"2012-08-30 00:00:00"

which doesn't parse in Firefox:

new Date("2014-08-06 00:00:00");
Invalid Date

but does parse in Chrome:

new Date("2014-08-06 00:00:00");
Wed Aug 06 2014 00:00:00 GMT+0200 (CEST)

Since we are suggesting Firefox as browser for Koha, this is a huge show-stopper.
However, Firefox is happy when space is replaced by T like this:

new Date("2014-08-06T00:00:00");
Date 2014-08-05T22:00:00.000Z

but as you can see above, without timezone it gets shifted by my timezone offset (which is +2 in my case).

So adding additional timezone at end:

new Date("2014-08-06T00:00:00Z");
Date 2014-08-06T00:00:00.000Z

However, you are then comparing this date with new Date(); which again creates GMT time instead of localtime:

new Date
Date 2014-09-04T12:30:02.556Z

(my current local time is 14:30:02, not 12:30!)

Dates and JavaScript is a mess. I would love to hear your feedback on this.
Comment 7 Dobrica Pavlinusic 2014-09-04 13:23:36 UTC Comment hidden (obsolete)
Comment 8 Katrin Fischer 2014-09-14 19:51:43 UTC Comment hidden (obsolete)
Comment 9 Kyle M Hall 2014-09-15 11:38:12 UTC
Created attachment 31597 [details] [review]
[PASSED QA] Bug 12729 - Overdue items won't show as overdue in red in circulation

It seems that Firefox date parser doesn't like our dates which are
formatted in ISO format like "2014-08-06 00:00:00". This results in
missing red color in overdue dates.

So intead of munching different date formats and JavaScript (and having
to support different browers) this patch moves check for overdue dates
back to mysql and just transfers boolean value to JavaScript so it can
show correct class for date_due.

Test scenario:
1. find borrower with overdue checkouts
2. verify that all dates are black (and are in ISO format)
3. apply this patch
4. reload page and verify that overdue dates turned red

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Tested with different due dates (hourly and not) and different date formats.
Passes tests and QA script.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 10 Tomás Cohen Arazi 2014-09-16 18:31:12 UTC
Patch pushed to master.

Thanks Dobrica!
Comment 11 Galen Charlton 2014-09-23 20:29:58 UTC
Pushed to 3.16.x for inclusion in 3.16.4.