View | Details | Raw Unified | Return to bug 10240
Collapse All | Expand All

(-)a/circ/offline-mf.pl (-9 / +12 lines)
Lines 1-10 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
# Copyright 2013 C & P Bibliography Services
3
# This file is part of Koha.
4
# This file is part of Koha.
4
#
5
#
5
# Koha is free software; you can redistribute it and/or modify it under the
6
# Koha is free software; you can redistribute it and/or modify it under the
6
# terms of the GNU General Public License as published by the Free Software
7
# terms of the GNU General Public License as published by the Free Software
7
# Foundation; either version 2 of the License, or (at your option) any later
8
# Foundation; either version 3 of the License, or (at your option) any later
8
# version.
9
# version.
9
#
10
#
10
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
Lines 21-34 use CGI; Link Here
21
use C4::Auth;
22
use C4::Auth;
22
23
23
my $query = new CGI;
24
my $query = new CGI;
24
my ($template, $loggedinuser, $cookie, $flags)
25
my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
25
= get_template_and_user({template_name => "circ/offline-mf.tt",
26
    {
26
                query => $query,
27
        template_name   => "circ/offline-mf.tt",
27
                type => "intranet",
28
        query           => $query,
28
                authnotrequired => 0,
29
        type            => "intranet",
29
                flagsrequired => {circulate => "circulate_remaining_permissions"},
30
        authnotrequired => 0,
30
                });
31
        flagsrequired   => { circulate => "circulate_remaining_permissions" },
32
    }
33
);
31
34
32
$template->{'VARS'}->{'cookie'} = $cookie;
35
$template->{'VARS'}->{'cookie'} = $cookie;
33
print $query->header(-type => 'text/cache-manifest', cookie => $cookie);
36
print $query->header( -type => 'text/cache-manifest', cookie => $cookie );
34
print $template->output;
37
print $template->output;
(-)a/circ/offline.pl (-10 / +15 lines)
Lines 1-10 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
# Copyright 2013 C & P Bibliography Services
3
# This file is part of Koha.
4
# This file is part of Koha.
4
#
5
#
5
# Koha is free software; you can redistribute it and/or modify it under the
6
# Koha is free software; you can redistribute it and/or modify it under the
6
# terms of the GNU General Public License as published by the Free Software
7
# terms of the GNU General Public License as published by the Free Software
7
# Foundation; either version 2 of the License, or (at your option) any later
8
# Foundation; either version 3 of the License, or (at your option) any later
8
# version.
9
# version.
9
#
10
#
10
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
Lines 23-36 use C4::Output; Link Here
23
use C4::Context;
24
use C4::Context;
24
25
25
my $query = new CGI;
26
my $query = new CGI;
26
my ($template, $loggedinuser, $cookie, $flags)
27
my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
27
= get_template_and_user({template_name => "circ/offline.tt",
28
    {
28
                query => $query,
29
        template_name   => "circ/offline.tt",
29
                type => "intranet",
30
        query           => $query,
30
                authnotrequired => 0,
31
        type            => "intranet",
31
                flagsrequired => {circulate => "circulate_remaining_permissions"},
32
        authnotrequired => 0,
32
                });
33
        flagsrequired   => { circulate => "circulate_remaining_permissions" },
34
    }
35
);
33
36
34
$template->{'VARS'}->{'AllowOfflineCirculation'} = C4::Context->preference('AllowOfflineCirculation');
37
$template->{'VARS'}->{'AllowOfflineCirculation'} =
35
$template->{'VARS'}->{'maxoutstanding'} = C4::Context->preference('maxoutstanding') || 0;
38
  C4::Context->preference('AllowOfflineCirculation');
39
$template->{'VARS'}->{'maxoutstanding'} =
40
  C4::Context->preference('maxoutstanding') || 0;
36
output_html_with_http_headers $query, $cookie, $template->output;
41
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/koha-tmpl/intranet-tmpl/prog/en/js/offlinecirc.js (-1 / +5 lines)
Lines 52-57 Link Here
52
    kohadb.loadSetting = function (key, callback) {
52
    kohadb.loadSetting = function (key, callback) {
53
        $.indexedDB("koha").transaction(["offline_settings"]).then(function(){
53
        $.indexedDB("koha").transaction(["offline_settings"]).then(function(){
54
        }, function(err, e){
54
        }, function(err, e){
55
            if (typeof callback === 'function') {
56
                callback(key, undefined);
57
            }
55
        }, function(transaction){
58
        }, function(transaction){
56
            var settings = transaction.objectStore("offline_settings");
59
            var settings = transaction.objectStore("offline_settings");
57
            settings.get(key).done(function (item, error) {
60
            settings.get(key).done(function (item, error) {
Lines 80-88 Link Here
80
        }, function(dbtransaction) {
83
        }, function(dbtransaction) {
81
            var transactions = dbtransaction.objectStore("transactions");
84
            var transactions = dbtransaction.objectStore("transactions");
82
            transactions.put(newtrans);
85
            transactions.put(newtrans);
86
            kohadb.saveSetting('dirty', true);
83
        });
87
        });
84
    };
88
    };
85
}( window.kohadb = window.bndb || {}, jQuery ));
89
}( window.kohadb = window.kohadb || {}, jQuery ));
86
90
87
if ( !Date.prototype.toMySQLString ) {
91
if ( !Date.prototype.toMySQLString ) {
88
  ( function() {
92
  ( function() {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/offline-mf.tt (-31 / +29 lines)
Lines 4-43 CACHE MANIFEST Link Here
4
# Explicitly cached 'master entries'.
4
# Explicitly cached 'master entries'.
5
CACHE:
5
CACHE:
6
/cgi-bin/koha/circ/offline.pl
6
/cgi-bin/koha/circ/offline.pl
7
/intranet-tmpl/lib/bootstrap/bootstrap.min.css
7
[% interface %]/lib/bootstrap/bootstrap.min.css
8
/intranet-tmpl/lib/bootstrap/bootstrap.min.js
8
[% interface %]/lib/bootstrap/bootstrap.min.js
9
/intranet-tmpl/lib/jquery/jquery-ui.css
9
[% interface %]/lib/jquery/jquery-ui.css
10
/intranet-tmpl/lib/jquery/jquery-ui.js
10
[% interface %]/lib/jquery/jquery-ui.js
11
/intranet-tmpl/lib/jquery/jquery.js
11
[% interface %]/lib/jquery/jquery.js
12
/intranet-tmpl/lib/jquery/plugins/jquery.cookie.min.js
12
[% interface %]/lib/jquery/plugins/jquery.cookie.min.js
13
/intranet-tmpl/lib/jquery/plugins/jquery.highlight-3.js
13
[% interface %]/lib/jquery/plugins/jquery.highlight-3.js
14
/intranet-tmpl/lib/jquery/plugins/jquery.hotkeys.min.js
14
[% interface %]/lib/jquery/plugins/jquery.hotkeys.min.js
15
/intranet-tmpl/lib/jquery/plugins/jquery.indexeddb.js
15
[% interface %]/lib/jquery/plugins/jquery.indexeddb.js
16
/intranet-tmpl/lib/jquery/plugins/jquery.validate.min.js
16
[% interface %]/lib/jquery/plugins/jquery.validate.min.js
17
/intranet-tmpl/prog/en/css/print.css
17
[% themelang %]/css/print.css
18
/intranet-tmpl/prog/en/css/staff-global.css
18
[% themelang %]/css/staff-global.css
19
/intranet-tmpl/prog/en/js/basket.js
19
[% themelang %]/js/basket.js
20
/intranet-tmpl/prog/en/js/offlinecirc.js
20
[% themelang %]/js/offlinecirc.js
21
/intranet-tmpl/prog/en/js/staff-global.js
21
[% themelang %]/js/staff-global.js
22
/intranet-tmpl/prog/en/lib/jquery/plugins/jquery-ui-timepicker-addon.js
22
[% themelang %]/lib/jquery/plugins/jquery-ui-timepicker-addon.js
23
/intranet-tmpl/prog/en/lib/yui/button/button-min.js
23
[% themelang %]/lib/yui/button/button-min.js
24
/intranet-tmpl/prog/en/lib/yui/container/container_core-min.js
24
[% themelang %]/lib/yui/container/container_core-min.js
25
/intranet-tmpl/prog/en/lib/yui/menu/menu-min.js
25
[% themelang %]/lib/yui/menu/menu-min.js
26
/intranet-tmpl/prog/en/lib/yui/reset-fonts-grids.css
26
[% themelang %]/lib/yui/reset-fonts-grids.css
27
/intranet-tmpl/prog/en/lib/yui/skin.css
27
[% themelang %]/lib/yui/skin.css
28
/intranet-tmpl/prog/en/lib/yui/utilities/utilities.js
28
[% themelang %]/lib/yui/utilities/utilities.js
29
/intranet-tmpl/prog/img/cart-small.gif
29
[% interface %]/prog/img/cart-small.gif
30
/intranet-tmpl/prog/img/glyphicons-halflings-koha.png
30
[% interface %]/prog/img/glyphicons-halflings-koha.png
31
/intranet-tmpl/prog/img/koha-logo-medium.gif
31
[% interface %]/prog/img/koha-logo-medium.gif
32
/intranet-tmpl/prog/img/loading.gif
32
[% interface %]/prog/img/loading.gif
33
/intranet-tmpl/prog/sound/beep.ogg
33
[% interface %]/prog/sound/beep.ogg
34
/intranet-tmpl/prog/sound/critical.ogg
34
[% interface %]/prog/sound/critical.ogg
35
35
36
# Resources that require the user to be online.
36
# Resources that require the user to be online.
37
NETWORK:
37
NETWORK:
38
*
38
*
39
39
40
# static.html will be served if main.py is inaccessible
40
# Resources that can be substituted if the user is offline
41
# offline.jpg will be served in place of all images in images/large/
42
# offline.html will be served in place of all other .html files
43
FALLBACK:
41
FALLBACK:
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/offline.tt (-33 / +65 lines)
Lines 2-23 Link Here
2
[% IF (AllowOfflineCirculation) %]
2
[% IF (AllowOfflineCirculation) %]
3
[% SET manifestattr = 'manifest="/cgi-bin/koha/circ/offline-mf.pl"' %]
3
[% SET manifestattr = 'manifest="/cgi-bin/koha/circ/offline-mf.pl"' %]
4
[% END %]
4
[% END %]
5
[% IF ( bidi ) %]<html lang="[% lang %]" dir="[% bidi %]" [% manifestattr %]>[% ELSE %]<html lang="[% lang %]" [% manifestattr %]>[% END %]
5
[% IF ( bidi && AllowOfflineCirculation ) %]<html lang="[% lang %]" dir="[% bidi %]" manifest="/cgi-bin/koha/circ/offline-mf.pl">
6
[% ELSIF ( bidi ) %]<html lang="[% lang %]" dir="[% bidi %]">
7
[% ELSIF ( AllowOfflineCirculation ) %]<html lang="[% lang %]" manifest="/cgi-bin/koha/circ/offline-mf.pl">
8
[% ELSE %]<html lang="[% lang %]">[% END %]
6
<head>
9
<head>
7
<title>Koha &rsaquo; Circulation</title>
10
<title>Koha &rsaquo; Circulation</title>
8
[% INCLUDE 'doc-head-close.inc' %]
11
[% INCLUDE 'doc-head-close.inc' %]
9
<script type="text/javascript" src="/intranet-tmpl/lib/jquery/plugins/jquery.indexeddb.js"></script>
12
<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.indexeddb.js"></script>
10
<script type="text/javascript" src="/intranet-tmpl/prog/en/js/offlinecirc.js"></script>
13
<script type="text/javascript" src="[% interface %]/prog/en/js/offlinecirc.js"></script>
11
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery-ui-timepicker-addon.js"></script>
14
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery-ui-timepicker-addon.js"></script>
12
<script type="text/javascript">
15
<script type="text/javascript">
13
//<![CDATA[
16
//<![CDATA[
17
var ALERT_SUCCESSFUL_CHECKIN = _("Checked in item.");
14
var ALERT_MATERIALS = _("Note about the accompanying materials: ");
18
var ALERT_MATERIALS = _("Note about the accompanying materials: ");
15
var ALERT_RESTRICTED = _("Patron is RESTRICTED");
19
var ALERT_RESTRICTED = _("Patron is RESTRICTED");
16
var ALERT_NO_MATCHING_ITEM = _("No item with barcode in offline database (transaction recorded anyway): ");
20
var ALERT_NO_MATCHING_ITEM = _("No item with barcode in offline database (transaction recorded anyway): ");
17
var ALERT_NOT_CHECKED_OUT = _("Item not listed as checked out in offline database (transaction recorded anyway)");
21
var ALERT_NOT_CHECKED_OUT = _("Item not listed as checked out in offline database (transaction recorded anyway)");
18
var ALERT_ITEM_WITHDRAWN = _("Item has been withdrawn (transaction recorded anyway)");
22
var ALERT_ITEM_WITHDRAWN = _("Item has been withdrawn (transaction recorded anyway)");
19
var ALERT_ITEM_RESTRICTED = _("Item is restricted (transaction recorded anyway)");
23
var ALERT_ITEM_RESTRICTED = _("Item is restricted (transaction recorded anyway)");
20
var ALERT_ITEM_LOST = _("Item is has been lost (transaction recorded anyway)");
24
var ALERT_ITEM_LOST = _("Item has been lost (transaction recorded anyway)");
21
var ALERT_NO_MATCHING_PATRON = _("No patron cardnumber in offline database (proceeding anyway): ");
25
var ALERT_NO_MATCHING_PATRON = _("No patron cardnumber in offline database (proceeding anyway): ");
22
var ALERT_PATRON_GONE_NO_ADDRESS = _("Patron's address is in doubt (transaction recorded anyway)");
26
var ALERT_PATRON_GONE_NO_ADDRESS = _("Patron's address is in doubt (transaction recorded anyway)");
23
var ALERT_PATRON_CARD_LOST = _("Patron's card is lost");
27
var ALERT_PATRON_CARD_LOST = _("Patron's card is lost");
Lines 26-31 var ALERT_PATRON_BLOCKED_TEMPORARY = _("Patron has had overdue items and is rest Link Here
26
var ALERT_PATRON_RESTRICTED = _("Patron is restricted");
30
var ALERT_PATRON_RESTRICTED = _("Patron is restricted");
27
var ALERT_PATRON_FINE = _("Patron has outstanding fines: ");
31
var ALERT_PATRON_FINE = _("Patron has outstanding fines: ");
28
var ALERT_PATRON_FINE_OVER_LIMIT = _("Patron fines are over limit: ");
32
var ALERT_PATRON_FINE_OVER_LIMIT = _("Patron fines are over limit: ");
33
var UPLOAD_PENDING_MESSAGE = _("You have transactions in the offline circulation database on this computer that have not been uploaded.");
34
var NO_UPLOAD_PENDING_MESSAGE = _("You do not have any pending transactions in the offline circulation database on this computer.");
29
35
30
var start;
36
var start;
31
37
Lines 48-64 function checkin(barcode, item, error) { Link Here
48
                  "action" : "return"
54
                  "action" : "return"
49
                };
55
                };
50
    $('#alerts').empty();
56
    $('#alerts').empty();
51
    $('#offline-home').hide();
57
    $('.offline-home').hide();
52
    $('#offline-returns').show();
58
    $('.offline-sync').hide();
59
    $('.offline-circulation').hide();
60
    $('.offline-returns').show();
53
    kohadb.recordTransaction(trans, function () {
61
    kohadb.recordTransaction(trans, function () {
62
        $('#session-returned').show();
54
        $('#already-checked-in tbody').prepend('<tr><td>' + item.title + '</td><td>' + item.author + '</td><td>' + barcode + '</td><td>' + item.homebranch + '</td><td>' + item.holdingbranch + '</td><td></td><td>' + item.callnumber + '</td><td>' + item.itemtype + '</td></tr>');
63
        $('#already-checked-in tbody').prepend('<tr><td>' + item.title + '</td><td>' + item.author + '</td><td>' + barcode + '</td><td>' + item.homebranch + '</td><td>' + item.holdingbranch + '</td><td></td><td>' + item.callnumber + '</td><td>' + item.itemtype + '</td></tr>');
55
        if (alerts.length > 0) {
64
        if (alerts.length > 0) {
56
            $('#alerts').append('<div class="dialog alert"><h3>' + _("Check in message") + '</h3></div>');
65
            $('#alerts').append('<div class="dialog alert"><h3>' + _("Check in message") + '</h3></div>');
57
            for (var msg in alerts) {
66
            for (var msg in alerts) {
58
                $('#alerts .dialog').append('<p>' + alerts[msg] + '</p');
67
                $('#alerts .dialog').append('<p>' + alerts[msg] + '</p');
59
            }
68
            }
69
        } else {
70
            $('#alerts').append('<div class="dialog"><h3>' + ALERT_SUCCESSFUL_CHECKIN + '</h3></div>');
60
        }
71
        }
61
    });
72
    });
73
    setTimeout(function() { $('#checkin-barcode').trigger('focus'), 1 });
62
}
74
}
63
75
64
function checkAlerts(barcode, item) {
76
function checkAlerts(barcode, item) {
Lines 73-94 function checkAlerts(barcode, item) { Link Here
73
    return alerts;
85
    return alerts;
74
}
86
}
75
87
76
function synchronize() {
88
function showSyncInfo() {
77
    kohadb.saveSetting("userid", "[% loggedinusername %]");
78
    kohadb.saveSetting("branchcode", "[% LoginBranchcode %]");
79
    kohadb.loadSetting("item-timestamp", showTimestamp);
89
    kohadb.loadSetting("item-timestamp", showTimestamp);
80
    kohadb.loadSetting("patron-timestamp", showTimestamp);
90
    kohadb.loadSetting("patron-timestamp", showTimestamp);
81
    kohadb.loadSetting("issue-timestamp", showTimestamp);
91
    kohadb.loadSetting("issue-timestamp", showTimestamp);
92
    kohadb.loadSetting("dirty", function (key, val) {
93
        if (val) {
94
            $('#upload-message').text(UPLOAD_PENDING_MESSAGE);
95
        } else {
96
            $('#upload-message').text(NO_UPLOAD_PENDING_MESSAGE);
97
        }
98
    });
99
}
100
101
function synchronize() {
102
    kohadb.saveSetting("userid", "[% loggedinusername %]");
103
    kohadb.saveSetting("branchcode", "[% LoginBranchcode %]");
104
    showSyncInfo();
82
    [% UNLESS (AllowOfflineCirculation) %]
105
    [% UNLESS (AllowOfflineCirculation) %]
83
        reloadRecords();
106
        reloadRecords();
84
    [% END %]
107
    [% END %]
108
    showSyncInfo();
85
    $('#download-records').click(reloadRecords);
109
    $('#download-records').click(reloadRecords);
86
    $('#upload-transactions').click(function () {
110
    $('#upload-transactions').click(function () {
87
        $('.loading-overlay div').text(_("Uploading transactions, please wait..."));
111
        $('.loading-overlay div').text(_("Uploading transactions, please wait..."));
88
        $('.loading-overlay').show();
112
        $('.loading-overlay').show();
89
        var uploadIter = $.indexedDB("koha").objectStore("transactions").each(uploadTransaction);
113
        var uploadIter = $.indexedDB("koha").objectStore("transactions").each(uploadTransaction);
90
        uploadIter.done(function() {
114
        uploadIter.done(function() {
115
            $.indexedDB("koha").transaction(["transactions"]).then(function(){
116
            }, function(err, e){
117
            }, function(transaction){
118
                transaction.objectStore("transactions").clear();
119
            });
91
            $('.loading-overlay').hide();
120
            $('.loading-overlay').hide();
121
            kohadb.saveSetting("dirty", false);
122
            $('#upload-message').text(NO_UPLOAD_PENDING_MESSAGE);
92
        });
123
        });
93
    });
124
    });
94
125
Lines 122-128 function reloadRecords(ev) { Link Here
122
153
123
function uploadTransaction(transaction) {
154
function uploadTransaction(transaction) {
124
    $.ajax({
155
    $.ajax({
125
        type: "GET",
156
        type: "POST",
126
        url: "/cgi-bin/koha/offline_circ/service.pl",
157
        url: "/cgi-bin/koha/offline_circ/service.pl",
127
        data: { "userid" : kohadb.settings.userid,
158
        data: { "userid" : kohadb.settings.userid,
128
                "branchcode" : kohadb.settings.branchcode,
159
                "branchcode" : kohadb.settings.branchcode,
Lines 132-140 function uploadTransaction(transaction) { Link Here
132
                "cardnumber" : transaction.value.cardnumber,
163
                "cardnumber" : transaction.value.cardnumber,
133
                "pending" : true,
164
                "pending" : true,
134
              },
165
              },
135
    }).done(function () {
136
        transaction.delete();
137
    });
166
    });
167
    return undefined, true;
138
}
168
}
139
169
140
function finishedLoading() {
170
function finishedLoading() {
Lines 160-166 function loadRecords(page) { Link Here
160
        dataType: "json",
190
        dataType: "json",
161
    }).done(function (data) {
191
    }).done(function (data) {
162
        $.indexedDB("koha").transaction(["patrons", "items", "issues"]).then(function(){
192
        $.indexedDB("koha").transaction(["patrons", "items", "issues"]).then(function(){
163
            if ($.isEmptyObject(data.patrons) && $.isEmptyObject(data.items)) {
193
            if (data.finished) {
164
                finishedLoading();
194
                finishedLoading();
165
            } else {
195
            } else {
166
                setTimeout(function () { loadRecords(page + 1); }, 200);
196
                setTimeout(function () { loadRecords(page + 1); }, 200);
Lines 202-207 function validate1(date) { Link Here
202
function loadPatron(barcode) {
232
function loadPatron(barcode) {
203
    $('#oldissues').hide();
233
    $('#oldissues').hide();
204
    $('#session-issues').hide();
234
    $('#session-issues').hide();
235
    $('#issuest tbody').empty();
205
    $('#session-payments').hide();
236
    $('#session-payments').hide();
206
    $.indexedDB("koha").transaction(["patrons", "issues"]).then(function() {
237
    $.indexedDB("koha").transaction(["patrons", "issues"]).then(function() {
207
    }, function(err, e){
238
    }, function(err, e){
Lines 232-238 function checkout(barcode, item, error) { Link Here
232
    item.itemtype = item.itemtype || "";
263
    item.itemtype = item.itemtype || "";
233
    if ($('#duedatespec').val().length === 0) {
264
    if ($('#duedatespec').val().length === 0) {
234
        alert(_("You must set a due date in order to use offline circulation!"));
265
        alert(_("You must set a due date in order to use offline circulation!"));
235
        $('#duedatespec').focus();
266
        setTimeout(function() { $('#duedatespec').trigger('focus'), 1 });
236
        return;
267
        return;
237
    }
268
    }
238
    var date_due = new Date($('#duedatespec').datepicker('getDate'));
269
    var date_due = new Date($('#duedatespec').datepicker('getDate'));
Lines 252-257 function checkout(barcode, item, error) { Link Here
252
                $('#alerts .dialog').append('<p>' + alerts[msg] + '</p');
283
                $('#alerts .dialog').append('<p>' + alerts[msg] + '</p');
253
            }
284
            }
254
        }
285
        }
286
        $('#checkout-barcode').val('');
255
    });
287
    });
256
}
288
}
257
289
Lines 364-375 function showPatron(barcode, patron, error) { Link Here
364
    if (alerts.length > 0) {
396
    if (alerts.length > 0) {
365
        $('#alerts').append('<div class="dialog alert"><h3>' + _("Check out message") + '</h3></div>');
397
        $('#alerts').append('<div class="dialog alert"><h3>' + _("Check out message") + '</h3></div>');
366
        for (var msg in alerts) {
398
        for (var msg in alerts) {
367
            $('#alerts .dialog').append('<p>' + alerts[msg] + '</p');
399
            $('#alerts .dialog').append('<p>' + alerts[msg] + '</p>');
368
        }
400
        }
369
    }
401
    }
370
    curpatron = patron;
402
    curpatron = patron;
371
    $('#yui-main').show();
403
    $('#yui-main').show();
372
    $('#barcode').focus();
404
    setTimeout(function() { $('#checkout-barcode').trigger('focus'), 1 });
373
}
405
}
374
406
375
// This next bit of code is to deal with the updated session issue
407
// This next bit of code is to deal with the updated session issue
Lines 419-425 $(document).ready(function () { Link Here
419
        $('.offline-sync').hide();
451
        $('.offline-sync').hide();
420
        $('.offline-circulation').hide();
452
        $('.offline-circulation').hide();
421
        $('.offline-returns').show();
453
        $('.offline-returns').show();
422
        $('#checkin-form input[name="barcode"]').focus();
454
        setTimeout(function() { $('#checkin-form input[name="barcode"]').trigger('focus'), 1 });
423
    });
455
    });
424
456
425
    $('#go-to-circ').click(function () {
457
    $('#go-to-circ').click(function () {
Lines 428-437 $(document).ready(function () { Link Here
428
        $('.offline-returns').hide();
460
        $('.offline-returns').hide();
429
        $('.offline-circulation').hide();
461
        $('.offline-circulation').hide();
430
        $('#header_search').tabs("option", "active", 0);
462
        $('#header_search').tabs("option", "active", 0);
431
        $('#circ_search input[name="findborrower"]').focus();
463
        setTimeout(function() { $('#circ_search input[name="findborrower"]').trigger('focus'), 1 });
432
    });
464
    });
433
465
434
    $('#go-to-sync').click(function () {
466
    $('#go-to-sync').click(function () {
467
        showSyncInfo();
435
        $.ajax({
468
        $.ajax({
436
            type: "GET",
469
            type: "GET",
437
            url: "/cgi-bin/koha/offline_circ/list.pl",
470
            url: "/cgi-bin/koha/offline_circ/list.pl",
Lines 456-462 $(document).ready(function () { Link Here
456
        $('.offline-sync').hide();
489
        $('.offline-sync').hide();
457
        $('.offline-circulation').show();
490
        $('.offline-circulation').show();
458
        $('#findborrower').val('');
491
        $('#findborrower').val('');
459
        $('#barcode').focus();
492
        setTimeout(function() { $('#checkout-barcode').trigger('focus'), 1 });
460
    });
493
    });
461
494
462
    $('#pay-fine').click(function (event) {
495
    $('#pay-fine').click(function (event) {
Lines 472-484 $(document).ready(function () { Link Here
472
        minute: 59
505
        minute: 59
473
    });
506
    });
474
    $("#duedatespec").datetimepicker({
507
    $("#duedatespec").datetimepicker({
475
        onClose: function(dateText, inst) { $("#barcode").focus(); },
508
        onClose: function(dateText, inst) { setTimeout(function() { $('#checkout-barcode').trigger('focus'), 1 }); },
476
        hour: 23,
509
        hour: 23,
477
        minute: 59
510
        minute: 59
478
    });
511
    });
479
    $('#mainform').submit(function (event) {
512
    $('#mainform').submit(function (event) {
480
        event.preventDefault();
513
        event.preventDefault();
481
        var barcode = $('#barcode').val();
514
        var barcode = $('#checkout-barcode').val();
482
        $.indexedDB("koha").transaction(["items"]).then(function() {
515
        $.indexedDB("koha").transaction(["items"]).then(function() {
483
        }, function(err, e){
516
        }, function(err, e){
484
        }, function(transaction){
517
        }, function(transaction){
Lines 505-512 $(document).ready(function () { Link Here
505
538
506
    <div id="bd">
539
    <div id="bd">
507
        <div id="yui-main">
540
        <div id="yui-main">
508
            <audio id="alert_sound" src="/intranet-tmpl/prog/sound/critical.ogg" autobuffer="autobuffer"></audio>
541
            <audio id="alert_sound" src="[% interface %]/prog/sound/critical.ogg" autobuffer="autobuffer"></audio>
509
            <audio id="success_sound" src="/intranet-tmpl/prog/sound/beep.ogg" autobuffer="autobuffer"></audio>
542
            <audio id="success_sound" src="[% interface %]/prog/sound/beep.ogg" autobuffer="autobuffer"></audio>
510
543
511
            <div id="alerts" class="yui-b">
544
            <div id="alerts" class="yui-b">
512
            </div>
545
            </div>
Lines 523-535 $(document).ready(function () { Link Here
523
                        <ul>
556
                        <ul>
524
                            <li><a id="go-to-circ" href="#offline-circulation">Check out</a></li>
557
                            <li><a id="go-to-circ" href="#offline-circulation">Check out</a></li>
525
                            <li><a id="go-to-returns" href="#offline-returns">Check in</a></li>
558
                            <li><a id="go-to-returns" href="#offline-returns">Check in</a></li>
526
                            <li><a id="go-to-sync" href="#offline-sync">Synchronize (must be online)</a></li>
527
                        </ul>
559
                        </ul>
528
                    </div>
560
                    </div>
529
561
530
                    <div class="yui-u">
562
                    <div class="yui-u">
531
                        <p><strong>Note:</strong> You must be online to use these options.</p>
563
                        <p><strong>Note:</strong> You must be online to use these options.</p>
532
                        <ul>
564
                        <ul>
565
                            <li><a id="go-to-sync" href="#offline-sync">Synchronize</a></li>
533
                            <li><a href="/cgi-bin/koha/offline_circ/list.pl">Pending offline circulation actions</a>
566
                            <li><a href="/cgi-bin/koha/offline_circ/list.pl">Pending offline circulation actions</a>
534
                        </ul>
567
                        </ul>
535
                    </div>
568
                    </div>
Lines 547-554 $(document).ready(function () { Link Here
547
                    <h1>Offline circulation</h1>
580
                    <h1>Offline circulation</h1>
548
                    <div class="yui-u first">
581
                    <div class="yui-u first">
549
                        <div id="download-message">
582
                        <div id="download-message">
550
                            You have records in the offline circulation database on this
583
                            In order for offline circulation to work on this computer,
551
                            computer, but they may not be current:
584
                            your library's records must be up-to-date on this computer:
552
                            <ul>
585
                            <ul>
553
                                <li>Patron records were last synced on: <span id="patron-timestamp">(checking)</span></li>
586
                                <li>Patron records were last synced on: <span id="patron-timestamp">(checking)</span></li>
554
                                <li>Item records were last synced on: <span id="item-timestamp">(checking)</span></li>
587
                                <li>Item records were last synced on: <span id="item-timestamp">(checking)</span></li>
Lines 558-567 $(document).ready(function () { Link Here
558
                    </div>
591
                    </div>
559
592
560
                    <div class="yui-u">
593
                    <div class="yui-u">
561
                        <div id="upload-message">You have transactions in the offline
594
                        <div id="upload-message">
562
                            circulation database on this computer that have not been
563
                            uploaded.
564
                        </div>
595
                        </div>
596
                        <div>View <a href="/cgi-bin/koha/offline_circ/list.pl">pending offline circulation actions</a></div>
565
                    </div>
597
                    </div>
566
                </div>
598
                </div>
567
            </div>
599
            </div>
Lines 572-579 $(document).ready(function () { Link Here
572
                        <div class="yui-u first">
604
                        <div class="yui-u first">
573
                            <fieldset>
605
                            <fieldset>
574
                                <legend>Check In</legend>
606
                                <legend>Check In</legend>
575
                                <label for="barcode">Enter item barcode: </label>
607
                                <label for="checkin-barcode">Enter item barcode: </label>
576
                                <input name="barcode" id="barcode" size="14" class="focus"/>
608
                                <input name="barcode" id="checkin-barcode" size="14" class="focus"/>
577
                                <input type="submit" class="submit" value="Submit" />
609
                                <input type="submit" class="submit" value="Submit" />
578
                            </fieldset>
610
                            </fieldset>
579
                        </div>
611
                        </div>
Lines 597-605 $(document).ready(function () { Link Here
597
                    <form method="post" action="/cgi-bin/koha/circ/offline-circulation.pl" id="mainform" name="mainform" autocomplete="off">
629
                    <form method="post" action="/cgi-bin/koha/circ/offline-circulation.pl" id="mainform" name="mainform" autocomplete="off">
598
                        <fieldset id="circ_circulation_issue">
630
                        <fieldset id="circ_circulation_issue">
599
                            <span id="clearscreen"><a href="/cgi-bin/koha/circ/offline-circulation.pl" title="Clear screen">x</a></span>
631
                            <span id="clearscreen"><a href="/cgi-bin/koha/circ/offline-circulation.pl" title="Clear screen">x</a></span>
600
                            <label for="barcode">Checking out to <span class="patron-title"></span></label>
632
                            <label for="checkout-barcode">Checking out to <span class="patron-title"></span></label>
601
                            <div class="hint">Enter item barcode:</div>
633
                            <div class="hint">Enter item barcode:</div>
602
                            <input type="text" name="barcode" id="barcode" class="barcode focus" size="14" />
634
                            <input type="text" name="barcode" id="checkout-barcode" class="barcode focus" size="14" />
603
                            <input type="submit" value="Check Out" />
635
                            <input type="submit" value="Check Out" />
604
636
605
                            <div class="date-select">
637
                            <div class="date-select">
(-)a/offline_circ/download.pl (-27 / +27 lines)
Lines 35-41 my $page = $query->param('page') || 0; Link Here
35
my $startrec = int($page) * 5000;
35
my $startrec = int($page) * 5000;
36
my $req_data = $query->param('data') || '';
36
my $req_data = $query->param('data') || '';
37
37
38
my $patrons_query = qq{SELECT
38
my $patrons_query = q{SELECT
39
    borrowers.borrowernumber, cardnumber, surname, firstname, title,
39
    borrowers.borrowernumber, cardnumber, surname, firstname, title,
40
    othernames, initials, streetnumber, streettype, address, address2, city,
40
    othernames, initials, streetnumber, streettype, address, address2, city,
41
    state, zipcode, country, email, phone, mobile, fax, dateofbirth, branchcode,
41
    state, zipcode, country, email, phone, mobile, fax, dateofbirth, branchcode,
Lines 43-54 my $patrons_query = qq{SELECT Link Here
43
    debarredcomment, SUM(accountlines.amountoutstanding) AS fine
43
    debarredcomment, SUM(accountlines.amountoutstanding) AS fine
44
    FROM borrowers
44
    FROM borrowers
45
    LEFT JOIN accountlines ON borrowers.borrowernumber=accountlines.borrowernumber
45
    LEFT JOIN accountlines ON borrowers.borrowernumber=accountlines.borrowernumber
46
    WHERE cardnumber IS NOT NULL
46
    GROUP BY borrowers.borrowernumber
47
    GROUP BY borrowers.borrowernumber
47
    LIMIT $startrec, 5000;
48
    LIMIT ?, 5000;
48
    };
49
    };
49
50
50
# NOTE: we can't fit very long titles on the interface so there isn't really any point in transferring them
51
# NOTE: we can't fit very long titles on the interface so there isn't really any point in transferring them
51
my $items_query = qq{SELECT
52
my $items_query = q{SELECT
52
    items.barcode AS barcode, items.itemnumber AS itemnumber,
53
    items.barcode AS barcode, items.itemnumber AS itemnumber,
53
    items.itemcallnumber AS callnumber, items.homebranch AS homebranch,
54
    items.itemcallnumber AS callnumber, items.homebranch AS homebranch,
54
    items.holdingbranch AS holdingbranch, items.itype AS itemtype,
55
    items.holdingbranch AS holdingbranch, items.itype AS itemtype,
Lines 56-65 my $items_query = qq{SELECT Link Here
56
    biblio.author AS author, biblio.biblionumber AS biblionumber
57
    biblio.author AS author, biblio.biblionumber AS biblionumber
57
    FROM items
58
    FROM items
58
    JOIN biblio ON biblio.biblionumber = items.biblionumber
59
    JOIN biblio ON biblio.biblionumber = items.biblionumber
59
    LIMIT $startrec, 5000;
60
    WHERE barcode IS NOT NULL
61
    LIMIT ?, 5000;
60
    };
62
    };
61
63
62
my $issues_query = qq{SELECT
64
my $issues_query = q{SELECT
63
    biblio.title AS title,
65
    biblio.title AS title,
64
    items.barcode AS barcode,
66
    items.barcode AS barcode,
65
    items.itemcallnumber AS callnumber,
67
    items.itemcallnumber AS callnumber,
Lines 72-107 my $issues_query = qq{SELECT Link Here
72
    JOIN items ON items.itemnumber = issues.itemnumber
74
    JOIN items ON items.itemnumber = issues.itemnumber
73
    JOIN biblio ON biblio.biblionumber = items.biblionumber
75
    JOIN biblio ON biblio.biblionumber = items.biblionumber
74
    JOIN borrowers ON borrowers.borrowernumber = issues.borrowernumber
76
    JOIN borrowers ON borrowers.borrowernumber = issues.borrowernumber
75
    LIMIT $startrec, 5000;
77
    WHERE barcode IS NOT NULL
78
    LIMIT ?, 5000;
76
    };
79
    };
77
80
78
if ( $req_data eq 'all' ) {
81
my %results;
79
    print $query->header( -type => 'application/json', -charset => 'utf-8' );
82
my $finished = 1;
80
    print to_json(
83
if ( $req_data eq 'patrons' || $req_data eq 'all' ) {
81
        {
84
    $results{'patrons'} = get_data( $patrons_query, 'cardnumber', $startrec );
82
            'patrons' => get_data( $patrons_query, 'cardnumber' ),
83
            'items'   => get_data( $items_query,   'barcode' ),
84
            'issues'  => get_data( $issues_query,  'barcode' ),
85
        }
86
    );
87
}
85
}
88
elsif ( $req_data eq 'patrons' ) {
86
if ( $req_data eq 'items' || $req_data eq 'all' ) {
89
    print $query->header( -type => 'application/json', -charset => 'utf-8' );
87
    $results{'items'} = get_data( $items_query, 'barcode', $startrec );
90
    print to_json( { 'patrons' => get_data( $patrons_query, 'cardnumber' ), } );
91
}
88
}
92
elsif ( $req_data eq 'items' ) {
89
if ( $req_data eq 'issues' || $req_data eq 'all' ) {
93
    print $query->header( -type => 'application/json', -charset => 'utf-8' );
90
    $results{'issues'} = get_data( $issues_query, 'barcode', $startrec );
94
    print to_json( { 'items' => get_data( $items_query, 'barcode' ), } );
95
}
91
}
96
elsif ( $req_data eq 'issues' ) {
92
97
    print $query->header( -type => 'application/json', -charset => 'utf-8' );
93
foreach my $key ( keys %results ) {
98
    print to_json( { 'issues' => get_data( $issues_query, 'barcode' ), } );
94
    $finished = 0 if keys %{ $results{$key} } == 5000;
99
}
95
}
96
$results{'finished'} = $finished;
97
98
print $query->header( -type => 'application/json', -charset => 'utf-8' );
99
print to_json( \%results );
100
100
101
sub get_data {
101
sub get_data {
102
    my ( $sql, $key ) = @_;
102
    my ( $sql, $key, $start ) = @_;
103
    $start ||= 0;
103
    my $dbh = C4::Context->dbh;
104
    my $dbh = C4::Context->dbh;
104
    my $sth = $dbh->prepare($sql);
105
    my $sth = $dbh->prepare($sql);
105
    $sth->execute();
106
    $sth->execute($start);
106
    return $sth->fetchall_hashref($key);
107
    return $sth->fetchall_hashref($key);
107
}
108
}
108
- 

Return to bug 10240