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/css/staff-global.css (+4 lines)
Lines 451-456 div.patroninfo h5 { Link Here
451
	padding-bottom : .5em;
451
	padding-bottom : .5em;
452
}
452
}
453
453
454
div.patroninfo h5:empty {
455
    border-right: none;
456
}
457
454
div.patroninfo ul {
458
div.patroninfo ul {
455
	border : 0;
459
	border : 0;
456
    border-right:1px solid #b9d8d9;
460
    border-right:1px solid #b9d8d9;
(-)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 (-36 / +103 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-circulation-instructions').hide();
61
    $('.offline-returns').show();
53
    kohadb.recordTransaction(trans, function () {
62
    kohadb.recordTransaction(trans, function () {
63
        $('#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>');
64
        $('#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) {
65
        if (alerts.length > 0) {
56
            $('#alerts').append('<div class="dialog alert"><h3>' + _("Check in message") + '</h3></div>');
66
            $('#alerts').append('<div class="dialog alert"><h3>' + _("Check in message") + '</h3></div>');
57
            for (var msg in alerts) {
67
            for (var msg in alerts) {
58
                $('#alerts .dialog').append('<p>' + alerts[msg] + '</p');
68
                $('#alerts .dialog').append('<p>' + alerts[msg] + '</p');
59
            }
69
            }
70
        } else {
71
            $('#alerts').append('<div class="dialog"><h3>' + ALERT_SUCCESSFUL_CHECKIN + '</h3></div>');
60
        }
72
        }
61
    });
73
    });
74
    setTimeout(function() { $('#checkin-barcode').trigger('focus'), 1 });
62
}
75
}
63
76
64
function checkAlerts(barcode, item) {
77
function checkAlerts(barcode, item) {
Lines 73-94 function checkAlerts(barcode, item) { Link Here
73
    return alerts;
86
    return alerts;
74
}
87
}
75
88
76
function synchronize() {
89
function showSyncInfo() {
77
    kohadb.saveSetting("userid", "[% loggedinusername %]");
78
    kohadb.saveSetting("branchcode", "[% LoginBranchcode %]");
79
    kohadb.loadSetting("item-timestamp", showTimestamp);
90
    kohadb.loadSetting("item-timestamp", showTimestamp);
80
    kohadb.loadSetting("patron-timestamp", showTimestamp);
91
    kohadb.loadSetting("patron-timestamp", showTimestamp);
81
    kohadb.loadSetting("issue-timestamp", showTimestamp);
92
    kohadb.loadSetting("issue-timestamp", showTimestamp);
93
    kohadb.loadSetting("dirty", function (key, val) {
94
        if (val) {
95
            $('#upload-message').text(UPLOAD_PENDING_MESSAGE);
96
        } else {
97
            $('#upload-message').text(NO_UPLOAD_PENDING_MESSAGE);
98
        }
99
    });
100
}
101
102
function synchronize() {
103
    kohadb.saveSetting("userid", "[% loggedinusername %]");
104
    kohadb.saveSetting("branchcode", "[% LoginBranchcode %]");
105
    showSyncInfo();
82
    [% UNLESS (AllowOfflineCirculation) %]
106
    [% UNLESS (AllowOfflineCirculation) %]
83
        reloadRecords();
107
        reloadRecords();
84
    [% END %]
108
    [% END %]
109
    showSyncInfo();
85
    $('#download-records').click(reloadRecords);
110
    $('#download-records').click(reloadRecords);
86
    $('#upload-transactions').click(function () {
111
    $('#upload-transactions').click(function () {
87
        $('.loading-overlay div').text(_("Uploading transactions, please wait..."));
112
        $('.loading-overlay div').text(_("Uploading transactions, please wait..."));
88
        $('.loading-overlay').show();
113
        $('.loading-overlay').show();
89
        var uploadIter = $.indexedDB("koha").objectStore("transactions").each(uploadTransaction);
114
        var uploadIter = $.indexedDB("koha").objectStore("transactions").each(uploadTransaction);
90
        uploadIter.done(function() {
115
        uploadIter.done(function() {
116
            $.indexedDB("koha").transaction(["transactions"]).then(function(){
117
            }, function(err, e){
118
            }, function(transaction){
119
                transaction.objectStore("transactions").clear();
120
            });
91
            $('.loading-overlay').hide();
121
            $('.loading-overlay').hide();
122
            kohadb.saveSetting("dirty", false);
123
            $('#upload-message').text(NO_UPLOAD_PENDING_MESSAGE);
92
        });
124
        });
93
    });
125
    });
94
126
Lines 122-128 function reloadRecords(ev) { Link Here
122
154
123
function uploadTransaction(transaction) {
155
function uploadTransaction(transaction) {
124
    $.ajax({
156
    $.ajax({
125
        type: "GET",
157
        type: "POST",
126
        url: "/cgi-bin/koha/offline_circ/service.pl",
158
        url: "/cgi-bin/koha/offline_circ/service.pl",
127
        data: { "userid" : kohadb.settings.userid,
159
        data: { "userid" : kohadb.settings.userid,
128
                "branchcode" : kohadb.settings.branchcode,
160
                "branchcode" : kohadb.settings.branchcode,
Lines 132-140 function uploadTransaction(transaction) { Link Here
132
                "cardnumber" : transaction.value.cardnumber,
164
                "cardnumber" : transaction.value.cardnumber,
133
                "pending" : true,
165
                "pending" : true,
134
              },
166
              },
135
    }).done(function () {
136
        transaction.delete();
137
    });
167
    });
168
    return undefined, true;
138
}
169
}
139
170
140
function finishedLoading() {
171
function finishedLoading() {
Lines 160-166 function loadRecords(page) { Link Here
160
        dataType: "json",
191
        dataType: "json",
161
    }).done(function (data) {
192
    }).done(function (data) {
162
        $.indexedDB("koha").transaction(["patrons", "items", "issues"]).then(function(){
193
        $.indexedDB("koha").transaction(["patrons", "items", "issues"]).then(function(){
163
            if ($.isEmptyObject(data.patrons) && $.isEmptyObject(data.items)) {
194
            if (data.finished) {
164
                finishedLoading();
195
                finishedLoading();
165
            } else {
196
            } else {
166
                setTimeout(function () { loadRecords(page + 1); }, 200);
197
                setTimeout(function () { loadRecords(page + 1); }, 200);
Lines 202-208 function validate1(date) { Link Here
202
function loadPatron(barcode) {
233
function loadPatron(barcode) {
203
    $('#oldissues').hide();
234
    $('#oldissues').hide();
204
    $('#session-issues').hide();
235
    $('#session-issues').hide();
236
    $('#issuest tbody').empty();
205
    $('#session-payments').hide();
237
    $('#session-payments').hide();
238
    $('.checkout-count').text(0);
206
    $.indexedDB("koha").transaction(["patrons", "issues"]).then(function() {
239
    $.indexedDB("koha").transaction(["patrons", "issues"]).then(function() {
207
    }, function(err, e){
240
    }, function(err, e){
208
    }, function(transaction){
241
    }, function(transaction){
Lines 215-220 function loadPatron(barcode) { Link Here
215
        issuesidx.each(function (item) {
248
        issuesidx.each(function (item) {
216
            $('#oldissues').show();
249
            $('#oldissues').show();
217
            $('#oldissuest tbody').append("<tr><td>" + item.value.date_due + "</td><td>" + item.value.barcode + "</td><td>" + item.value.title + "</td><td>" + item.value.itype + "</td><td>" + item.value.issuedate + "</td><td>" + item.value.issuebranch + "</td><td>" + item.value.callnumber + "</td><td>" + "" + "</td></tr>");
250
            $('#oldissuest tbody').append("<tr><td>" + item.value.date_due + "</td><td>" + item.value.barcode + "</td><td>" + item.value.title + "</td><td>" + item.value.itype + "</td><td>" + item.value.issuedate + "</td><td>" + item.value.issuebranch + "</td><td>" + item.value.callnumber + "</td><td>" + "" + "</td></tr>");
251
            $('.checkout-count').text(parseInt($('.checkout-count').text()) + 1);
218
        }, barcode);
252
        }, barcode);
219
    });
253
    });
220
}
254
}
Lines 232-238 function checkout(barcode, item, error) { Link Here
232
    item.itemtype = item.itemtype || "";
266
    item.itemtype = item.itemtype || "";
233
    if ($('#duedatespec').val().length === 0) {
267
    if ($('#duedatespec').val().length === 0) {
234
        alert(_("You must set a due date in order to use offline circulation!"));
268
        alert(_("You must set a due date in order to use offline circulation!"));
235
        $('#duedatespec').focus();
269
        setTimeout(function() { $('#duedatespec').trigger('focus'), 1 });
236
        return;
270
        return;
237
    }
271
    }
238
    var date_due = new Date($('#duedatespec').datepicker('getDate'));
272
    var date_due = new Date($('#duedatespec').datepicker('getDate'));
Lines 246-257 function checkout(barcode, item, error) { Link Here
246
    kohadb.recordTransaction(trans, function () {
280
    kohadb.recordTransaction(trans, function () {
247
        $('#session-issues').show();
281
        $('#session-issues').show();
248
        $('#issuest tbody').prepend('<tr><td>' + $.datepicker.formatDate(dateformat, date_due) + date_due.toTimeString() + '</td><td>' + item.title + '</td><td>' + barcode + '</td><td>' + item.itemtype + '</td><td>' + $.datepicker.formatDate(dateformat, new Date()) + '</td><td>' + kohadb.settings.branchcode + '</td><td>' + item.callnumber + '</td><td></td></tr>');
282
        $('#issuest tbody').prepend('<tr><td>' + $.datepicker.formatDate(dateformat, date_due) + date_due.toTimeString() + '</td><td>' + item.title + '</td><td>' + barcode + '</td><td>' + item.itemtype + '</td><td>' + $.datepicker.formatDate(dateformat, new Date()) + '</td><td>' + kohadb.settings.branchcode + '</td><td>' + item.callnumber + '</td><td></td></tr>');
283
        $('.checkout-count').text(parseInt($('.checkout-count').text()) + 1);
249
        if (alerts.length > 0) {
284
        if (alerts.length > 0) {
250
            $('#alerts').append('<div class="dialog alert"><h3>' + _("Check out message") + '</h3></div>');
285
            $('#alerts').append('<div class="dialog alert"><h3>' + _("Check out message") + '</h3></div>');
251
            for (var msg in alerts) {
286
            for (var msg in alerts) {
252
                $('#alerts .dialog').append('<p>' + alerts[msg] + '</p');
287
                $('#alerts .dialog').append('<p>' + alerts[msg] + '</p');
253
            }
288
            }
254
        }
289
        }
290
        $('#checkout-barcode').val('');
255
    });
291
    });
256
}
292
}
257
293
Lines 265-270 function recordFine(amount) { Link Here
265
    kohadb.recordTransaction(trans, function () {
301
    kohadb.recordTransaction(trans, function () {
266
        $('#session-payments').show();
302
        $('#session-payments').show();
267
        $('#session-payments tbody').prepend('<tr><td>' + amount + '</td><td>' + $.datepicker.formatDate(dateformat, timestamp) + timestamp.toTimeString() + '</td></tr>');
303
        $('#session-payments tbody').prepend('<tr><td>' + amount + '</td><td>' + $.datepicker.formatDate(dateformat, timestamp) + timestamp.toTimeString() + '</td></tr>');
304
        $('.fine-amount').text(parseInt($('.fine-amount').text) - amount);
268
    });
305
    });
269
}
306
}
270
307
Lines 364-375 function showPatron(barcode, patron, error) { Link Here
364
    if (alerts.length > 0) {
401
    if (alerts.length > 0) {
365
        $('#alerts').append('<div class="dialog alert"><h3>' + _("Check out message") + '</h3></div>');
402
        $('#alerts').append('<div class="dialog alert"><h3>' + _("Check out message") + '</h3></div>');
366
        for (var msg in alerts) {
403
        for (var msg in alerts) {
367
            $('#alerts .dialog').append('<p>' + alerts[msg] + '</p');
404
            $('#alerts .dialog').append('<p>' + alerts[msg] + '</p>');
368
        }
405
        }
369
    }
406
    }
370
    curpatron = patron;
407
    curpatron = patron;
371
    $('#yui-main').show();
408
    $('#yui-main').show();
372
    $('#barcode').focus();
409
    setTimeout(function() { $('#checkout-barcode').trigger('focus'), 1 });
373
}
410
}
374
411
375
// This next bit of code is to deal with the updated session issue
412
// This next bit of code is to deal with the updated session issue
Lines 408-437 $(document).ready(function () { Link Here
408
    });
445
    });
409
446
410
    $('#go-to-home').click(function () {
447
    $('#go-to-home').click(function () {
448
        $('#alerts').empty();
411
        $('.offline-sync').hide();
449
        $('.offline-sync').hide();
412
        $('.offline-circulation').hide();
450
        $('.offline-circulation').hide();
413
        $('.offline-returns').hide();
451
        $('.offline-returns').hide();
452
        $('.offline-circulation-instructions').hide();
414
        $('.offline-home').show();
453
        $('.offline-home').show();
415
    });
454
    });
416
455
417
    $('#go-to-returns').click(function () {
456
    $('#go-to-returns').click(function () {
457
        $('#alerts').empty();
418
        $('.offline-home').hide();
458
        $('.offline-home').hide();
419
        $('.offline-sync').hide();
459
        $('.offline-sync').hide();
420
        $('.offline-circulation').hide();
460
        $('.offline-circulation').hide();
461
        $('.offline-circulation-instructions').hide();
421
        $('.offline-returns').show();
462
        $('.offline-returns').show();
422
        $('#checkin-form input[name="barcode"]').focus();
463
        setTimeout(function() { $('#checkin-form input[name="barcode"]').trigger('focus'), 1 });
423
    });
464
    });
424
465
425
    $('#go-to-circ').click(function () {
466
    $('#go-to-circ').click(function () {
467
        $('#alerts').empty();
426
        $('.offline-home').hide();
468
        $('.offline-home').hide();
427
        $('.offline-sync').hide();
469
        $('.offline-sync').hide();
428
        $('.offline-returns').hide();
470
        $('.offline-returns').hide();
429
        $('.offline-circulation').hide();
471
        $('.offline-circulation').hide();
472
        $('.offline-circulation-instructions').show();
430
        $('#header_search').tabs("option", "active", 0);
473
        $('#header_search').tabs("option", "active", 0);
431
        $('#circ_search input[name="findborrower"]').focus();
474
        setTimeout(function() { $('#circ_search input[name="findborrower"]').trigger('focus'), 1 });
432
    });
475
    });
433
476
434
    $('#go-to-sync').click(function () {
477
    $('#go-to-sync').click(function () {
478
        $('#alerts').empty();
479
        showSyncInfo();
435
        $.ajax({
480
        $.ajax({
436
            type: "GET",
481
            type: "GET",
437
            url: "/cgi-bin/koha/offline_circ/list.pl",
482
            url: "/cgi-bin/koha/offline_circ/list.pl",
Lines 439-444 $(document).ready(function () { Link Here
439
                $('.offline-home').hide();
484
                $('.offline-home').hide();
440
                $('.offline-returns').hide();
485
                $('.offline-returns').hide();
441
                $('.offline-circulation').hide();
486
                $('.offline-circulation').hide();
487
                $('.offline-circulation-instructions').hide();
442
                $('.offline-sync').show();
488
                $('.offline-sync').show();
443
                synchronize();
489
                synchronize();
444
            },
490
            },
Lines 448-462 $(document).ready(function () { Link Here
448
        });
494
        });
449
    });
495
    });
450
496
497
    $('#go-to-pending').click(function (ev) {
498
        $('#alerts').empty();
499
        ev.preventDefault();
500
        $.ajax({
501
            type: "GET",
502
            url: "/cgi-bin/koha/offline_circ/list.pl",
503
            success: function () {
504
                window.location = '/cgi-bin/koha/offline_circ/list.pl';
505
            },
506
            error: function () {
507
                alert(_("You are offline and therefore cannot process pending operations"));
508
            }
509
        });
510
    });
511
451
    $('#patronsearch').submit(function (event) {
512
    $('#patronsearch').submit(function (event) {
452
        event.preventDefault();
513
        event.preventDefault();
453
        loadPatron($('#findborrower').val());
514
        loadPatron($('#findborrower').val());
454
        $('.offline-home').hide();
515
        $('.offline-home').hide();
455
        $('.offline-returns').hide();
516
        $('.offline-returns').hide();
456
        $('.offline-sync').hide();
517
        $('.offline-sync').hide();
518
        $('.offline-circulation-instructions').hide();
457
        $('.offline-circulation').show();
519
        $('.offline-circulation').show();
458
        $('#findborrower').val('');
520
        $('#findborrower').val('');
459
        $('#barcode').focus();
521
        setTimeout(function() { $('#checkout-barcode').trigger('focus'), 1 });
460
    });
522
    });
461
523
462
    $('#pay-fine').click(function (event) {
524
    $('#pay-fine').click(function (event) {
Lines 472-484 $(document).ready(function () { Link Here
472
        minute: 59
534
        minute: 59
473
    });
535
    });
474
    $("#duedatespec").datetimepicker({
536
    $("#duedatespec").datetimepicker({
475
        onClose: function(dateText, inst) { $("#barcode").focus(); },
537
        onClose: function(dateText, inst) { setTimeout(function() { $('#checkout-barcode').trigger('focus'), 1 }); },
476
        hour: 23,
538
        hour: 23,
477
        minute: 59
539
        minute: 59
478
    });
540
    });
479
    $('#mainform').submit(function (event) {
541
    $('#mainform').submit(function (event) {
480
        event.preventDefault();
542
        event.preventDefault();
481
        var barcode = $('#barcode').val();
543
        var barcode = $('#checkout-barcode').val();
482
        $.indexedDB("koha").transaction(["items"]).then(function() {
544
        $.indexedDB("koha").transaction(["items"]).then(function() {
483
        }, function(err, e){
545
        }, function(err, e){
484
        }, function(transaction){
546
        }, function(transaction){
Lines 505-512 $(document).ready(function () { Link Here
505
567
506
    <div id="bd">
568
    <div id="bd">
507
        <div id="yui-main">
569
        <div id="yui-main">
508
            <audio id="alert_sound" src="/intranet-tmpl/prog/sound/critical.ogg" autobuffer="autobuffer"></audio>
570
            <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>
571
            <audio id="success_sound" src="[% interface %]/prog/sound/beep.ogg" autobuffer="autobuffer"></audio>
510
572
511
            <div id="alerts" class="yui-b">
573
            <div id="alerts" class="yui-b">
512
            </div>
574
            </div>
Lines 523-536 $(document).ready(function () { Link Here
523
                        <ul>
585
                        <ul>
524
                            <li><a id="go-to-circ" href="#offline-circulation">Check out</a></li>
586
                            <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>
587
                            <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>
588
                        </ul>
528
                    </div>
589
                    </div>
529
590
530
                    <div class="yui-u">
591
                    <div class="yui-u">
531
                        <p><strong>Note:</strong> You must be online to use these options.</p>
592
                        <p><strong>Note:</strong> You must be online to use these options.</p>
532
                        <ul>
593
                        <ul>
533
                            <li><a href="/cgi-bin/koha/offline_circ/list.pl">Pending offline circulation actions</a>
594
                            <li><a id="go-to-sync" href="#offline-sync">Synchronize</a></li>
595
                            <li><a id="go-to-pending" href="/cgi-bin/koha/offline_circ/list.pl">Pending offline circulation actions</a>
534
                        </ul>
596
                        </ul>
535
                    </div>
597
                    </div>
536
                </div>
598
                </div>
Lines 547-554 $(document).ready(function () { Link Here
547
                    <h1>Offline circulation</h1>
609
                    <h1>Offline circulation</h1>
548
                    <div class="yui-u first">
610
                    <div class="yui-u first">
549
                        <div id="download-message">
611
                        <div id="download-message">
550
                            You have records in the offline circulation database on this
612
                            In order for offline circulation to work on this computer,
551
                            computer, but they may not be current:
613
                            your library's records must be up-to-date on this computer:
552
                            <ul>
614
                            <ul>
553
                                <li>Patron records were last synced on: <span id="patron-timestamp">(checking)</span></li>
615
                                <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>
616
                                <li>Item records were last synced on: <span id="item-timestamp">(checking)</span></li>
Lines 558-567 $(document).ready(function () { Link Here
558
                    </div>
620
                    </div>
559
621
560
                    <div class="yui-u">
622
                    <div class="yui-u">
561
                        <div id="upload-message">You have transactions in the offline
623
                        <div id="upload-message">
562
                            circulation database on this computer that have not been
563
                            uploaded.
564
                        </div>
624
                        </div>
625
                        <div>View <a href="/cgi-bin/koha/offline_circ/list.pl">pending offline circulation actions</a></div>
565
                    </div>
626
                    </div>
566
                </div>
627
                </div>
567
            </div>
628
            </div>
Lines 572-579 $(document).ready(function () { Link Here
572
                        <div class="yui-u first">
633
                        <div class="yui-u first">
573
                            <fieldset>
634
                            <fieldset>
574
                                <legend>Check In</legend>
635
                                <legend>Check In</legend>
575
                                <label for="barcode">Enter item barcode: </label>
636
                                <label for="checkin-barcode">Enter item barcode: </label>
576
                                <input name="barcode" id="barcode" size="14" class="focus"/>
637
                                <input name="barcode" id="checkin-barcode" size="14" class="focus"/>
577
                                <input type="submit" class="submit" value="Submit" />
638
                                <input type="submit" class="submit" value="Submit" />
578
                            </fieldset>
639
                            </fieldset>
579
                        </div>
640
                        </div>
Lines 592-605 $(document).ready(function () { Link Here
592
                </div>
653
                </div>
593
            </div>
654
            </div>
594
655
656
            <div style="display: none;" class="yui-b offline-circulation-instructions">
657
                <div class="yui-g">
658
                    Scan a patron barcode to start.
659
                </div>
660
            </div>
661
595
            <div id="offline-circulation" style="display: none;" class="yui-b offline-circulation">
662
            <div id="offline-circulation" style="display: none;" class="yui-b offline-circulation">
596
                <div class="yui-g">
663
                <div class="yui-g">
597
                    <form method="post" action="/cgi-bin/koha/circ/offline-circulation.pl" id="mainform" name="mainform" autocomplete="off">
664
                    <form method="post" action="/cgi-bin/koha/circ/offline.pl" id="mainform" name="mainform" autocomplete="off">
598
                        <fieldset id="circ_circulation_issue">
665
                        <fieldset id="circ_circulation_issue">
599
                            <span id="clearscreen"><a href="/cgi-bin/koha/circ/offline-circulation.pl" title="Clear screen">x</a></span>
666
                            <span id="clearscreen"><a href="/cgi-bin/koha/circ/offline.pl" title="Clear screen">x</a></span>
600
                            <label for="barcode">Checking out to <span class="patron-title"></span></label>
667
                            <label for="checkout-barcode">Checking out to <span class="patron-title"></span></label>
601
                            <div class="hint">Enter item barcode:</div>
668
                            <div class="hint">Enter item barcode:</div>
602
                            <input type="text" name="barcode" id="barcode" class="barcode focus" size="14" />
669
                            <input type="text" name="barcode" id="checkout-barcode" class="barcode focus" size="14" />
603
                            <input type="submit" value="Check Out" />
670
                            <input type="submit" value="Check Out" />
604
671
605
                            <div class="date-select">
672
                            <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