Bug 10240 - Offline circulation using HTML5 and IndexedDB
Summary: Offline circulation using HTML5 and IndexedDB
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Circulation (show other bugs)
Version: master
Hardware: All All
: P5 - low new feature (vote)
Assignee: Jared Camins-Esakov
QA Contact: Jonathan Druart
URL:
Keywords: rel_3_14_candidate
Depends on:
Blocks:
 
Reported: 2013-05-13 23:26 UTC by Jared Camins-Esakov
Modified: 2014-12-07 20:02 UTC (History)
12 users (show)

See Also:
Change sponsored?: Sponsored
Patch complexity: Medium patch
Who signed the patch off:
Text to go in the release notes:
Version(s) released in:


Attachments
Work-in-progress patch for: (77.59 KB, patch)
2013-05-26 22:06 UTC, Jared Camins-Esakov
Details | Diff | Splinter Review
Bug 10240: Offline circulation using HTML5 and IndexedDB (70.09 KB, patch)
2013-05-29 00:40 UTC, Jared Camins-Esakov
Details | Diff | Splinter Review
Bug 10240: Offline circulation using HTML5 and IndexedDB (70.04 KB, patch)
2013-06-14 12:51 UTC, Jared Camins-Esakov
Details | Diff | Splinter Review
Bug 10240: Offline circulation using HTML5 and IndexedDB (69.97 KB, patch)
2013-06-17 11:30 UTC, Jared Camins-Esakov
Details | Diff | Splinter Review
Bug 10240: Offline circulation using HTML5 and IndexedDB (70.02 KB, patch)
2013-06-24 09:43 UTC, Chris Cormack
Details | Diff | Splinter Review
Bug 10240 QA follow-up (28.61 KB, patch)
2013-07-01 21:47 UTC, Jared Camins-Esakov
Details | Diff | Splinter Review
Bug 10240 QA follow-up (28.78 KB, patch)
2013-07-02 14:21 UTC, Jared Camins-Esakov
Details | Diff | Splinter Review
Bug 10240 QA follow-up (28.84 KB, patch)
2013-07-02 14:32 UTC, Jared Camins-Esakov
Details | Diff | Splinter Review
Bug 10240 QA follow-up (34.56 KB, patch)
2013-07-02 19:08 UTC, Jared Camins-Esakov
Details | Diff | Splinter Review
Bug 10240 follow-up: don't delete transactions if auth fails (2.56 KB, patch)
2013-07-10 19:53 UTC, Jared Camins-Esakov
Details | Diff | Splinter Review
Bug 10240: Offline circulation using HTML5 and IndexedDB (70.15 KB, patch)
2013-08-22 14:08 UTC, Jared Camins-Esakov
Details | Diff | Splinter Review
Bug 10240 QA follow-up (34.56 KB, patch)
2013-08-22 14:08 UTC, Jared Camins-Esakov
Details | Diff | Splinter Review
Bug 10240 follow-up: don't delete transactions if auth fails (2.56 KB, patch)
2013-08-22 14:08 UTC, Jared Camins-Esakov
Details | Diff | Splinter Review
Bug 10240 follow-up: fix display (2.22 KB, patch)
2013-09-03 01:27 UTC, Jared Camins-Esakov
Details | Diff | Splinter Review
Bug 10240 follow-up: disable logout/set library (1.23 KB, patch)
2013-09-11 22:15 UTC, Jared Camins-Esakov
Details | Diff | Splinter Review
Bug 10240: Offline circulation using HTML5 and IndexedDB (70.14 KB, patch)
2013-09-18 10:18 UTC, Chris Cormack
Details | Diff | Splinter Review
Bug 10240 QA follow-up (34.56 KB, patch)
2013-09-18 10:18 UTC, Chris Cormack
Details | Diff | Splinter Review
Bug 10240 follow-up: don't delete transactions if auth fails (2.56 KB, patch)
2013-09-18 10:19 UTC, Chris Cormack
Details | Diff | Splinter Review
Bug 10240 follow-up: fix display (2.22 KB, patch)
2013-09-18 10:19 UTC, Chris Cormack
Details | Diff | Splinter Review
Bug 10240 follow-up: disable logout/set library (1.23 KB, patch)
2013-09-18 10:19 UTC, Chris Cormack
Details | Diff | Splinter Review
Bug 10240: Offline circulation using HTML5 and IndexedDB (70.15 KB, patch)
2013-09-26 18:02 UTC, Jared Camins-Esakov
Details | Diff | Splinter Review
Bug 10240 QA follow-up (34.56 KB, patch)
2013-09-26 18:02 UTC, Jared Camins-Esakov
Details | Diff | Splinter Review
Bug 10240 follow-up: don't delete transactions if auth fails (2.56 KB, patch)
2013-09-26 18:02 UTC, Jared Camins-Esakov
Details | Diff | Splinter Review
Bug 10240 follow-up: fix display (2.22 KB, patch)
2013-09-26 18:02 UTC, Jared Camins-Esakov
Details | Diff | Splinter Review
Bug 10240 follow-up: disable logout/set library (1.23 KB, patch)
2013-09-26 18:02 UTC, Jared Camins-Esakov
Details | Diff | Splinter Review
Bug 10240: warn when patron's card is expired (2.94 KB, patch)
2013-09-26 18:02 UTC, Jared Camins-Esakov
Details | Diff | Splinter Review
Bug 10240 follow-up: make sure datepicker icons are available offline (1.07 KB, patch)
2013-09-28 21:53 UTC, Jared Camins-Esakov
Details | Diff | Splinter Review
Bug 10240 follow-up: make sure datepicker icons are available offline (1.14 KB, patch)
2013-09-28 22:29 UTC, Jared Camins-Esakov
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 10240: Offline circulation using HTML5 and IndexedDB (70.65 KB, patch)
2013-09-28 22:42 UTC, Bernardo Gonzalez Kriegel
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 10240 QA follow-up (34.64 KB, patch)
2013-09-28 22:42 UTC, Bernardo Gonzalez Kriegel
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 10240 follow-up: don't delete transactions if auth fails (2.63 KB, patch)
2013-09-28 22:42 UTC, Bernardo Gonzalez Kriegel
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 10240 follow-up: fix display (2.30 KB, patch)
2013-09-28 22:43 UTC, Bernardo Gonzalez Kriegel
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 10240 follow-up: disable logout/set library (1.30 KB, patch)
2013-09-28 22:43 UTC, Bernardo Gonzalez Kriegel
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 10240: warn when patron's card is expired (3.02 KB, patch)
2013-09-28 22:43 UTC, Bernardo Gonzalez Kriegel
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 10240 follow-up: make sure datepicker icons are available offline (1.21 KB, patch)
2013-09-28 22:43 UTC, Bernardo Gonzalez Kriegel
Details | Diff | Splinter Review
Bug 10240: Offline circulation using HTML5 and IndexedDB (70.68 KB, patch)
2013-09-29 05:24 UTC, Chris Cormack
Details | Diff | Splinter Review
Bug 10240 QA follow-up (34.68 KB, patch)
2013-09-29 05:25 UTC, Chris Cormack
Details | Diff | Splinter Review
Bug 10240 follow-up: don't delete transactions if auth fails (2.68 KB, patch)
2013-09-29 05:25 UTC, Chris Cormack
Details | Diff | Splinter Review
Bug 10240 follow-up: fix display (2.34 KB, patch)
2013-09-29 05:25 UTC, Chris Cormack
Details | Diff | Splinter Review
Bug 10240 follow-up: disable logout/set library (1.35 KB, patch)
2013-09-29 05:25 UTC, Chris Cormack
Details | Diff | Splinter Review
Bug 10240: warn when patron's card is expired (3.06 KB, patch)
2013-09-29 05:26 UTC, Chris Cormack
Details | Diff | Splinter Review
Bug 10240 follow-up: make sure datepicker icons are available offline (1.26 KB, patch)
2013-09-29 05:26 UTC, Chris Cormack
Details | Diff | Splinter Review
Bug 10240 QA follow-up: correctly record fines and fix label (2.71 KB, patch)
2013-10-02 15:03 UTC, Jared Camins-Esakov
Details | Diff | Splinter Review
Bug 10240: Offline circulation using HTML5 and IndexedDB (70.75 KB, patch)
2013-10-02 15:28 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 10240 QA follow-up (34.74 KB, patch)
2013-10-02 15:28 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 10240 follow-up: don't delete transactions if auth fails (2.74 KB, patch)
2013-10-02 15:28 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 10240 follow-up: fix display (2.41 KB, patch)
2013-10-02 15:28 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 10240 follow-up: disable logout/set library (1.41 KB, patch)
2013-10-02 15:28 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 10240: warn when patron's card is expired (3.12 KB, patch)
2013-10-02 15:28 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 10240 follow-up: make sure datepicker icons are available offline (1.32 KB, patch)
2013-10-02 15:29 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 10240 QA follow-up: correctly record fines and fix label (2.78 KB, patch)
2013-10-02 15:29 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Jared Camins-Esakov 2013-05-13 23:26:34 UTC
Modern web standards make it possible to make a stripped down version of Koha's circulation module function even when offline, and to seamlessly switch to offline functionality if the server or connection goes out. We should take advantage of this!
Comment 1 Jared Camins-Esakov 2013-05-26 22:06:51 UTC Comment hidden (obsolete)
Comment 2 Jared Camins-Esakov 2013-05-29 00:40:50 UTC Comment hidden (obsolete)
Comment 3 Kyle M Hall 2013-06-14 12:29:08 UTC
I'm getting stuck on step 4. I've tried both stopping apache on my dev server, and physically unplugging my ethernet cable. Either way, I get standard browser error messages in both Chrome and Firefox. Any suggestions?
Comment 4 Jared Camins-Esakov 2013-06-14 12:30:17 UTC
(In reply to comment #3)
> I'm getting stuck on step 4. I've tried both stopping apache on my dev
> server, and physically unplugging my ethernet cable. Either way, I get
> standard browser error messages in both Chrome and Firefox. Any suggestions?

Magnus reported having problems as well. I will test, and make sure I didn't miss adding a file to the patch.
Comment 5 Jared Camins-Esakov 2013-06-14 12:51:33 UTC Comment hidden (obsolete)
Comment 6 Frédéric Demians 2013-06-17 06:29:52 UTC
Great idea and implementation!

The patch doesn't apply anymore on HEAD. Their is a conflict on
staff-global.css.

Reading the code, I have one question and one remark:

(1) How does IndexedDB scale? Your synchronization stores locally
patrons and issues (if I understand correctly). So is there a limit to
the borrowers and issues Koha tables size?

(2) Few lines in offline.tt won't be translatable:

item.title = item.title || "(Unknown)";
item.author = item.author || "(Unknown)";

$('#alerts').append('<div class="dialog alert"><h3>Check in message</h3></div>');

$(".loading-overlay div").text(_("Loading page " + page + ", please wait..."));

$('#alerts').append('<div class="dialog alert"><h3>Check out message</h3></div>');
alert("You are offline and therefore cannot sync your database");
Comment 7 Jared Camins-Esakov 2013-06-17 11:30:05 UTC Comment hidden (obsolete)
Comment 8 Jared Camins-Esakov 2013-06-17 11:36:09 UTC
(In reply to comment #6)
> Great idea and implementation!
> 
> The patch doesn't apply anymore on HEAD. Their is a conflict on
> staff-global.css.

Rebased on latest master.

> Reading the code, I have one question and one remark:
> 
> (1) How does IndexedDB scale? Your synchronization stores locally
> patrons and issues (if I understand correctly). So is there a limit to
> the borrowers and issues Koha tables size?

There is not really a limit that I was able to identify. Downloading naturally takes longer the more records you have, but modern web browsers will just ask the user if they are willing to allow the application to increase the size of the IndexedDB database for that particular site, and the consensus online is that you can easily store a few million records in IndexedDB without it showing any performance issues.

> (2) Few lines in offline.tt won't be translatable:

I fixed those (and a couple others). Thanks for spotting that.
Comment 9 Viktor Sarge 2013-06-18 15:38:38 UTC
Interesting! I'm not skilled enough to apply the patch to a test server of my own, but I'll give some input for the wishlist. It would be useful if it was possible for the offline module to poll the remote server in the background and signal when the system gets up online again.
Comment 10 Jared Camins-Esakov 2013-06-18 15:46:15 UTC
Viktor,

(In reply to comment #9)
> Interesting! I'm not skilled enough to apply the patch to a test server of
> my own, but I'll give some input for the wishlist. It would be useful if it
> was possible for the offline module to poll the remote server in the
> background and signal when the system gets up online again.

I'll be doing at least one follow-up bug after this gets in, and I like that idea, so I'll plan to include it in the follow-up.
Comment 11 Viktor Sarge 2013-06-18 15:56:21 UTC
(In reply to comment #10)
> I'll be doing at least one follow-up bug after this gets in, and I like that
> idea, so I'll plan to include it in the follow-up.

Yay! Glad to hear. Thanks for the work you put in.
Comment 12 Chris Cormack 2013-06-24 09:43:02 UTC Comment hidden (obsolete)
Comment 13 Jonathan Druart 2013-06-25 10:09:17 UTC
QA comment:

I did not completely test this feature, but I have some comments:

As Kyle said (in comment 3), I stop Apache but the browser redirects me to a standard error page after clicking on the bookmark. So I tested with a page which has been loaded when the service was running.

I think I found a bug but it is weird that Chris did not raise that: When back to online, I upload transactions and delete all of them (or process them - the problem appears in both cases).
Back to offline, check in 1 item and go online. I upload the transaction. I expect to have 1 pending offline action, but I get back all previous ones (Though I deleted them). What did I miss?

Regarding at the code:
1/ there are minor qa issues:
 FAIL	koha-tmpl/intranet-tmpl/prog/en/modules/circ/offline-mf.tt
   FAIL	  forbidden patterns
		forbidden pattern: intranet-tmpl should certainly replaced with [% interface %] (line 24)
                [...]
		forbidden pattern: intranet-tmpl should certainly replaced with [% interface %] (line 25)
   OK	  tt_valid
   OK	  valid_template

 FAIL	koha-tmpl/intranet-tmpl/prog/en/modules/circ/offline.tt
   FAIL	  forbidden patterns
		forbidden pattern: intranet-tmpl should certainly replaced with [% interface %] (line 509)
		forbidden pattern: intranet-tmpl should certainly replaced with [% interface %] (line 508)
		forbidden pattern: intranet-tmpl should certainly replaced with [% interface %] (line 10)
		forbidden pattern: intranet-tmpl should certainly replaced with [% interface %] (line 9)
   FAIL	  tt_valid
		lines 5, 5

2/ Maybe it could be great to pass perltidy on new scripts.
3/ download.pl could return data.finished = 1 if number of returned data < 5000 (avoid 1 ajax call)
4/ qq{} around sql queries should be replaced with q{}

Possible improvements:
1/ it seems it is not possible to show local actions.
2/ add datatable on the tables.
3/ add a message on check in (currently the input becomes empty but the user is not informed).
4/ maybe a menu on the left with all links could help users (this would avoid to go back on the offline home page).

I don't switch to Failed QA, like that another QAer could test deeper.
Comment 14 Jared Camins-Esakov 2013-06-25 14:33:07 UTC
I'd like to implement some of Jonathan's suggestions in the follow-up, so I am setting this back to assigned for the moment.
Comment 15 Magnus Enger 2013-06-25 17:30:08 UTC
I started testing this, but never got very far. Here are a couple of observations, though:

- After clicking on "Built-in offline circulation interface" for the very first time I get:

  You have records in the offline circulation database on this computer, but they may not be current:
    Patron records were last synced on: (never)
    Item records were last synced on: (never)
    Circulation records were last synced on: (never)
  You have transactions in the offline circulation database on this computer that have not been uploaded.

which seems to indicate I have used these features before, which I have not. 

- Should the "Synchronize (must be online)" link be on the right of the screen, under a heading called "online actions" or similar? Now there are online actions in both columns, and the "heading" "Note: You must be online to use these options." seems potentially confusing.
Comment 16 Jonathan Druart 2013-06-26 06:50:32 UTC
(In reply to Magnus Enger from comment #15)
> I started testing this, but never got very far. Here are a couple of
> observations, though:
> 
> - After clicking on "Built-in offline circulation interface" for the very
> first time I get:
> 
>   You have records in the offline circulation database on this computer, but
> they may not be current:
>     Patron records were last synced on: (never)
>     Item records were last synced on: (never)
>     Circulation records were last synced on: (never)
>   You have transactions in the offline circulation database on this computer
> that have not been uploaded.
> 
> which seems to indicate I have used these features before, which I have not. 

I confirm I got this message for the first time too!
Comment 17 Jared Camins-Esakov 2013-07-01 21:47:37 UTC Comment hidden (obsolete)
Comment 18 Jared Camins-Esakov 2013-07-01 21:53:23 UTC
I addressed the five QA issues Jonathan described in comment 13, and implemented suggested improvement 3.

The other three:
> 1/ it seems it is not possible to show local actions.

That's a good point, and something I think I would like to add, but I will need to think about how to do it.

> 2/ add datatable on the tables.

I thought about doing this, but was concerned about the size of the app cache. I think the total size is still under 5MB, but I am not 100% certain, so I decided to leave this for the future.

> 4/ maybe a menu on the left with all links could help users (this would avoid to go back on the offline home page).

I wasn't happy with the result when I tried this. I added a link to the pending circulation actions from the synchronize page, which I presume is what you had in mind, particularly.
Comment 19 Jonathan Druart 2013-07-02 13:30:28 UTC
Jared,

I get a blank page on the check out page (circ/offline.pl#offline-circulation).
The "Checked in item." message text never disappear (even if I go on the offline home page (circ/offline.pl#offline-home)).

Marked as Failed QA.
Comment 20 Jared Camins-Esakov 2013-07-02 13:37:10 UTC
Jonathan,

I forgot to post one part of the test plan, sorry. It turns out that in Firefox you have to *empty* the app cache and system cache when the code is updated frequently in a short period of time because shift-refresh does not reload pages that have an HTML5 manifest, and Firefox does not seem to follow the Application Cache specification's instruction that the web browser is supposed to check for new versions of pages whenever the manifest changes. Could you try again after clearing the cache and then shift-refreshing?
Comment 21 Jonathan Druart 2013-07-02 14:11:37 UTC
I removed all my browsing data (clear cache and clear data from hosted apps), shift-refresh, used another browser, etc. But I still get a "blank" page (with "blank" I mean there is no content into the id="doc3" div element).
Comment 22 Jared Camins-Esakov 2013-07-02 14:21:44 UTC Comment hidden (obsolete)
Comment 23 Jared Camins-Esakov 2013-07-02 14:32:33 UTC Comment hidden (obsolete)
Comment 24 Jonathan Druart 2013-07-02 15:17:32 UTC
> I get a blank page on the check out page
> (circ/offline.pl#offline-circulation).

The last patch fixes that, switch back to Needs Signoff

I found some others small problems:
- The tab of checkouts always shows "*0* Checkouts"
- If I try to check in a nonexistent barcode, I get a warning message but the line is added to the table (maybe not a bug but a feature?)
- If I am not well-educated, I click on the "Check out" link on the offline home page, I enter a barcode, click on "Check out" and I get a js error (without user message): "TypeError: curpatron is undefined" (with chromium I get: Numeric transaction modes are deprecated in IDBDatabase.transaction. Use "readonly" or "readwrite").
- There is a "border-right" css rule on the h5.patron-title. It is display when there is no patron selected) [really minor!].
- tables are displayed even if there is no data
- The "Clear screen" link (X) points to an old script: circ/offline-circulation.pl
- There is a warning when clicking on the "Synchronize" link when the user is offline, but not for the "Pending offline circulation actions" link.
- Still exists:
> The "Checked in item." message text never disappear (even if I go on the
> offline home page (circ/offline.pl#offline-home)).

No blocker for testing.
Comment 25 Jared Camins-Esakov 2013-07-02 19:08:12 UTC Comment hidden (obsolete)
Comment 26 Jared Camins-Esakov 2013-07-10 19:53:53 UTC Comment hidden (obsolete)
Comment 27 Jared Camins-Esakov 2013-08-22 14:08:02 UTC Comment hidden (obsolete)
Comment 28 Jared Camins-Esakov 2013-08-22 14:08:09 UTC Comment hidden (obsolete)
Comment 29 Jared Camins-Esakov 2013-08-22 14:08:19 UTC Comment hidden (obsolete)
Comment 30 Campbell Reid-Tait 2013-08-29 03:38:33 UTC
Some Problems i have found.

1) After paying a fine when offline the fine amount becomes NaN. 

2) For previous checkouts for a pratron the title and barcode fields have the wrong infomation in them (ie they have been swapped.)
Comment 31 Jared Camins-Esakov 2013-09-03 01:27:32 UTC Comment hidden (obsolete)
Comment 32 Jared Camins-Esakov 2013-09-11 22:15:46 UTC Comment hidden (obsolete)
Comment 33 I'm just a bot 2013-09-18 10:05:44 UTC
Applying: Bug 10240: Offline circulation using HTML5 and IndexedDB
Using index info to reconstruct a base tree...
M	installer/data/mysql/sysprefs.sql
M	installer/data/mysql/updatedatabase.pl
M	koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css
M	koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref
Falling back to patching base and 3-way merge...
Auto-merging koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref
Auto-merging koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css
Auto-merging installer/data/mysql/updatedatabase.pl
CONFLICT (content): Merge conflict in installer/data/mysql/updatedatabase.pl
Auto-merging installer/data/mysql/sysprefs.sql
Patch failed at 0001 Bug 10240: Offline circulation using HTML5 and IndexedDB
The copy of the patch that failed is found in:
   /home/christopher/git/koha/.git/rebase-apply/patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Comment 34 Chris Cormack 2013-09-18 10:18:37 UTC Comment hidden (obsolete)
Comment 35 Chris Cormack 2013-09-18 10:18:58 UTC Comment hidden (obsolete)
Comment 36 Chris Cormack 2013-09-18 10:19:13 UTC Comment hidden (obsolete)
Comment 37 Chris Cormack 2013-09-18 10:19:25 UTC Comment hidden (obsolete)
Comment 38 Chris Cormack 2013-09-18 10:19:39 UTC Comment hidden (obsolete)
Comment 39 Jared Camins-Esakov 2013-09-26 18:02:26 UTC Comment hidden (obsolete)
Comment 40 Jared Camins-Esakov 2013-09-26 18:02:35 UTC Comment hidden (obsolete)
Comment 41 Jared Camins-Esakov 2013-09-26 18:02:41 UTC Comment hidden (obsolete)
Comment 42 Jared Camins-Esakov 2013-09-26 18:02:46 UTC Comment hidden (obsolete)
Comment 43 Jared Camins-Esakov 2013-09-26 18:02:51 UTC Comment hidden (obsolete)
Comment 44 Jared Camins-Esakov 2013-09-26 18:02:58 UTC Comment hidden (obsolete)
Comment 45 Bernardo Gonzalez Kriegel 2013-09-28 20:47:37 UTC
Tested and works, with Firefox 24.0.

Questions
1) At first I have problems with diacritics, title an author showed funny chars in position of accented letters on checkout/in pages. To test more I loaded arabic records and then all was fine. Don't know how that was fixed. I have screen captures

2) I can checkin many times one title, that was no problem un re-sycronize, only states that the item is not checked-out

3) I can checkout many times a title to the same patron. On synchronization all seems fine, but fines/charges are computed for every checkout, so I ended up owing for more than one item
Comment 46 Jared Camins-Esakov 2013-09-28 21:06:25 UTC
(In reply to Bernardo Gonzalez Kriegel from comment #45)
> Tested and works, with Firefox 24.0.
> 
> Questions
> 1) At first I have problems with diacritics, title an author showed funny
> chars in position of accented letters on checkout/in pages. To test more I
> loaded arabic records and then all was fine. Don't know how that was fixed.
> I have screen captures

Could you please e-mail them to me? I don't have problems with accents on my installation.

> 2) I can checkin many times one title, that was no problem un re-sycronize,
> only states that the item is not checked-out
> 
> 3) I can checkout many times a title to the same patron. On synchronization
> all seems fine, but fines/charges are computed for every checkout, so I
> ended up owing for more than one item

That's by design. If you use hourly loans, you could check out a book to a person several times before going back online.
Comment 47 Jared Camins-Esakov 2013-09-28 21:53:17 UTC Comment hidden (obsolete)
Comment 48 Jared Camins-Esakov 2013-09-28 22:29:20 UTC Comment hidden (obsolete)
Comment 49 Bernardo Gonzalez Kriegel 2013-09-28 22:42:29 UTC Comment hidden (obsolete)
Comment 50 Bernardo Gonzalez Kriegel 2013-09-28 22:42:43 UTC Comment hidden (obsolete)
Comment 51 Bernardo Gonzalez Kriegel 2013-09-28 22:42:54 UTC Comment hidden (obsolete)
Comment 52 Bernardo Gonzalez Kriegel 2013-09-28 22:43:07 UTC Comment hidden (obsolete)
Comment 53 Bernardo Gonzalez Kriegel 2013-09-28 22:43:21 UTC Comment hidden (obsolete)
Comment 54 Bernardo Gonzalez Kriegel 2013-09-28 22:43:32 UTC Comment hidden (obsolete)
Comment 55 Bernardo Gonzalez Kriegel 2013-09-28 22:43:43 UTC Comment hidden (obsolete)
Comment 56 Chris Cormack 2013-09-29 05:24:32 UTC Comment hidden (obsolete)
Comment 57 Chris Cormack 2013-09-29 05:25:07 UTC Comment hidden (obsolete)
Comment 58 Chris Cormack 2013-09-29 05:25:27 UTC Comment hidden (obsolete)
Comment 59 Chris Cormack 2013-09-29 05:25:41 UTC Comment hidden (obsolete)
Comment 60 Chris Cormack 2013-09-29 05:25:55 UTC Comment hidden (obsolete)
Comment 61 Chris Cormack 2013-09-29 05:26:12 UTC Comment hidden (obsolete)
Comment 62 Chris Cormack 2013-09-29 05:26:27 UTC Comment hidden (obsolete)
Comment 63 Jonathan Druart 2013-10-02 14:32:29 UTC
Jared,
I really would like to mark this feature as passed qa but I think I found 2 potential blocker things:
1/ I am under the impression that the payment don't work
To reproduce:
online: checkout/checkin an item in order to produce a fine
offline: the alert appears, I make the payment, upload the transaction, execute the action.
In the payment list, there is a new line:
Payment,thanks  		0.00 	0.00

2/ Why don't you block a checkout to a restricted user?

Minor: The search by partial name does not work, only a checkout using a cardnumber works (contrary to what it is displayed).

For discussion.
Comment 64 Jared Camins-Esakov 2013-10-02 14:50:43 UTC
(In reply to Jonathan Druart from comment #63)
> Jared,
> I really would like to mark this feature as passed qa but I think I found 2
> potential blocker things:
> 1/ I am under the impression that the payment don't work
> To reproduce:
> online: checkout/checkin an item in order to produce a fine
> offline: the alert appears, I make the payment, upload the transaction,
> execute the action.
> In the payment list, there is a new line:
> Payment,thanks  		0.00 	0.00

I will check this.

> 2/ Why don't you block a checkout to a restricted user?

If the offline database is out-of-date (because, for example, you're using offline circ due to an unplanned outage), you don't want to be blocking people from checking out. Same reason an incorrect barcode can't block circ: it could be a new book.

> Minor: The search by partial name does not work, only a checkout using a
> cardnumber works (contrary to what it is displayed).

Good point. I'll change that label. I never even thought about it, since it's generated elsewhere in Koha.
Comment 65 Jared Camins-Esakov 2013-10-02 15:03:53 UTC Comment hidden (obsolete)
Comment 66 Jonathan Druart 2013-10-02 15:27:54 UTC
Thanks Jared for your quick patch!

QA comment:

I follow this feature from the beginning and all detected issues have been taken into consideration.

Further improvement: displays the list of checkout and payment for a patron. At the moment, if a librarian go back on the checkout page, the previous (but not processed!) offline operations are not shown).

Marked as Passed QA.
Comment 67 Jonathan Druart 2013-10-02 15:28:23 UTC
Created attachment 21719 [details] [review]
Bug 10240: Offline circulation using HTML5 and IndexedDB

This patch adds an HTML5-based offline mode to Koha's existing
circulation module, allowing librarians to check out items using a
basically familiar interface. The feature will be implemented using
the Application Cache and IndexedDB features of the HTML5 specification,
both of which are fully supported on Firefox 10+ and Chrome 23+, with
limited support going back to Firefox 4 and Chrome 11. The basic
workflow enabled by this patch is as follows:

Part 1: While connected to the Internet
1. Enable offline functionality by turning on the
   "AllowOfflineCirculation" system preference.
2. Sync the offline circulation database on the computer that will be
   used for offline circulation by following the "Offline circulation
   interface" link on the Circulation home page, choosing "Synchronize (must be online)",
   and clicking the "Download records" button. This process may take a while.
3. Bookmark /cgi-bin/koha/circ/offline.pl (the page you are currently
   on) for easy access when offline.

Part 2: While disconnected from the Internet
4. Navigate to /cgi-bin/koha/circ/offline.pl using the bookmark you
   created while online.
5. Start checking books in by scanning the barcode of an item that has
   been returned into the box in the "Check in" tab.
6. Scan the barcodes of any additional items that have been returned.
7. Start checking out books to a patron by scanning the patron's barcode
   in the box in the "Check out" tab.
8. Set a due date (the "Remember for session" box will be checked by
   default, since circulation rules are not computed during offline
   transactions and therefore a due date must be specified by the
   librarian).
9. Scan an item barcode (if you did not set a due date, it will prompt
   you) to check the item out to the patron.
10. If a patron has a fine you can see the total amount (current to when
    the offline module was synced), and record a payment. Unlike when in
    online mode, there will be no breakdown of what item(s) fines are
    for, and you will only be able to record the payment amount and not
    associate it with a particular item.

Part 3: While connected to the Internet
11. Click the "Synchronize" link and choose "Upload transactions" to
    upload the transactions recorded during the offline circulation
    session.
12. Navigate to /cgi-bin/koha/offline_circ/list.pl (there will be a
    link from the Offline circulation page) and review the
    transactions, as described in the documentation for the Firefox
    Offline circulation plugin:
    http://wiki.koha-community.org/wiki/Offline_circulation_firefox_plugin

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>

Comment: Works very well, no koha-qa errors

Test with Firefox 24.0
1) did some checkouts pre sync
2) synchronize database (Download)
3) go offline
4) Proceed to checkin some items from patron
5) Proceed to checkout items to patrons, setting date
6) Proceed to checkout to expired patron, warning appears
7) go online
8) Upload records
9) go to review transacctions and proceed
10) verified on patrons that checkin/out are done

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Comment 68 Jonathan Druart 2013-10-02 15:28:29 UTC
Created attachment 21720 [details] [review]
Bug 10240 QA follow-up

Address the following issues:
    1/ Address minor qa issues with the templates:
     FAIL    koha-tmpl/intranet-tmpl/prog/en/modules/circ/offline-mf.tt
      FAIL      forbidden patterns
                forbidden pattern: intranet-tmpl should certainly
                replaced with [% interface %] (line 24)
                [etc.]
     OK      tt_valid
     OK      valid_template

    FAIL    koha-tmpl/intranet-tmpl/prog/en/modules/circ/offline.tt
     FAIL      forbidden patterns
               forbidden pattern: intranet-tmpl should certainly
               replaced with [% interface %] (line 509)
               [etc.]
    FAIL      tt_valid
        lines 5, 5
    2/ Run perltidy on new scripts
    3/ download.pl returns data.finished = 1 if number of returned
       data < 5000 (avoids 1 ajax call)
    4/ Replace qq{} around sql queries with q{}

Also, a race condition existed that resulted in pending transactions
only getting deleted from the local database in certain circumstances
(fast connections under Chrome, mostly). This patch fixes that so that
successfully-uploaded transactions are always deleted.

This patch also addresses Jonathan's suggestion:
3/ add a message on check in (currently the input becomes empty but the
   user is not informed).

... and Magnus's suggestion about moving the Synchronize link to the
right on the homepage.

Also, this addresses the further issues Jonathan noted:

- The tab of checkouts always shows "*0* Checkouts"
- If I am not well-educated, I click on the "Check out" link on the
  offline home page, I enter a barcode, click on "Check out" and I get a
  js error (without user message): "TypeError: curpatron is undefined"
  (with chromium I get: Numeric transaction modes are deprecated in
  IDBDatabase.transaction. Use "readonly" or "readwrite").
- There is a "border-right" css rule on the h5.patron-title. It is
  display when there is no patron selected) [really minor!].
- tables are displayed even if there is no data
- The "Clear screen" link (X) points to an old script:
  circ/offline-circulation.pl
- There is a warning when clicking on the "Synchronize" link when the
  user is offline, but not for the "Pending offline circulation actions"
  link.
- Still exists:
> The "Checked in item." message text never disappear (even if I go on the
> offline home page (circ/offline.pl#offline-home)).

Finally, this patch adds a link to the Pending offline operations page
on the synchronize page for easier navigation.

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Comment 69 Jonathan Druart 2013-10-02 15:28:35 UTC
Created attachment 21721 [details] [review]
Bug 10240 follow-up: don't delete transactions if auth fails

When uploading transactions, we were not checking that authentication
had succeeded before deleting the transactions from the local database.
That was bad. With this patch, we check. That is good.

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Comment 70 Jonathan Druart 2013-10-02 15:28:42 UTC
Created attachment 21722 [details] [review]
Bug 10240 follow-up: fix display

Fix the following two issues:
1) After paying a fine when offline the fine amount becomes NaN.
2) For previous checkouts for a pratron the title and barcode
   fields have the wrong infomation in them (i.e. they have been swapped)

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Comment 71 Jonathan Druart 2013-10-02 15:28:48 UTC
Created attachment 21723 [details] [review]
Bug 10240 follow-up: disable logout/set library

Logging out/setting the library does not work while using offline
mode, so it makes no sense to present those options to the user.
Much better is some sort of explanatory message informing them that
those two links don't work.

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Comment 72 Jonathan Druart 2013-10-02 15:28:55 UTC
Created attachment 21724 [details] [review]
Bug 10240: warn when patron's card is expired

This patch improves the alert messages to be slightly better English
and warns the librarian if a patron's card has expired. Like all alerts,
this is non-fatal since in the case of network failure there is no
particular reason to expect that the offline database is current.
To test this particular patch you can try checking something out to an
expired patron, otherwise test plan remains the same as above.

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Comment 73 Jonathan Druart 2013-10-02 15:29:01 UTC
Created attachment 21725 [details] [review]
Bug 10240 follow-up: make sure datepicker icons are available offline

The next month/previous month icons for the datepicker were not available
offline. With this patch they are.

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Comment 74 Jonathan Druart 2013-10-02 15:29:10 UTC
Created attachment 21726 [details] [review]
Bug 10240 QA follow-up: correctly record fines and fix label

At some point in rebasing I managed to remove the part of the code
that saved fine payments. This patch re-adds that feature. This patch
also corrects the label on the check out tab to not mention partial
names for checkouts when offline, and partial name searches are not
supported in offline circ.

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Comment 75 Galen Charlton 2013-10-11 02:05:41 UTC
Pushed to master.  Thanks, Jared!