From 92f1bdb26d0027b52b3b3db84ff3d52104d6b1fe Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Thu, 4 Aug 2016 10:38:48 -0400 Subject: [PATCH] LP#1356477: update selfcheck interface This patch replaces the Logout and Logout with Receipt buttons in the selfcheck interface with a single Logout button and a set of radio buttons (whose labels are clickable) that allow the user to specify whether they want an email receipt, a print receipt, or no receipt upon logging out. If the user has no email address, the option to select email receipts will not be presented to them. Signed-off-by: Mike Rylander Signed-off-by: Galen Charlton --- .../src/templates/circ/selfcheck/summary.tt2 | 9 ++- .../js/ui/default/circ/selfcheck/selfcheck.js | 77 +++++++++++++++++-- 2 files changed, 77 insertions(+), 9 deletions(-) diff --git a/Open-ILS/src/templates/circ/selfcheck/summary.tt2 b/Open-ILS/src/templates/circ/selfcheck/summary.tt2 index 237c345677..7b1487c60b 100644 --- a/Open-ILS/src/templates/circ/selfcheck/summary.tt2 +++ b/Open-ILS/src/templates/circ/selfcheck/summary.tt2 @@ -1,8 +1,13 @@
+
+ [% l('Receipt:') %] + + +
[% l('Items Checked Out') %] diff --git a/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js b/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js index 03f9dfa629..3959fbca07 100644 --- a/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js +++ b/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js @@ -202,8 +202,7 @@ SelfCheckManager.prototype.init = function() { ); }, 'oils-selfck-nav-home' : function() { self.drawCircPage(); }, - 'oils-selfck-nav-logout' : function() { self.logoutPatron(); }, - 'oils-selfck-nav-logout-print' : function() { self.logoutPatron(true); }, + 'oils-selfck-nav-logout' : function() { self.logoutPatron(true); }, 'oils-selfck-items-out-details-link' : function() { self.drawItemsOutPage(); }, 'oils-selfck-print-list-link' : function() { self.printList(); } } @@ -466,10 +465,28 @@ SelfCheckManager.prototype.fetchPatron = function(barcode, usrname) { this.handleAlert('', false, 'login-success'); dojo.byId('oils-selfck-user-banner').innerHTML = dojo.string.substitute(localeStrings.WELCOME_BANNER, [this.patron.first_given_name()]); + + if (this.patron.email() && // they have an email address set and ... + this.patron.email().match(/.*@.*/).length > 0 // it sorta looks like an email address + ) { + openils.Util.removeCSSClass( dojo.byId('oils-selfck-receipt-email').parentNode, 'hidden' ); + if (user_setting_value(this.patron, 'circ.send_email_checkout_receipts') == 'true') // their selected default + dojo.byId('oils-selfck-receipt-email').checked = true; + } + this.drawCircPage(); } } +function user_setting_value (user, setting) { + if (user) { + var list = user.settings().filter(function(s){ + return s.name() == setting; + }); + + if (list.length) return list[0].value(); + } +} SelfCheckManager.prototype.handleAlert = function(message, shouldPopup, sound) { @@ -1310,6 +1327,40 @@ SelfCheckManager.prototype.initPrinter = function() { } } +/** + * Email a receipt for this session's checkouts + */ +SelfCheckManager.prototype.emailSessionReceipt = function(callback) { + + var circIds = []; + + // collect the circs and failure info + dojo.forEach( + this.checkouts, + function(blob) { + circIds.push(blob.circ); + } + ); + + var params = [ + this.authtoken, + this.patron.id(), + circIds + ]; + + var self = this; + fieldmapper.standardRequest( + ['open-ils.circ', 'open-ils.circ.checkout.batch_notify.session.atomic'], + { + async : true, + params : params, + oncomplete : function() { + if (callback) callback(); // fire and forget + } + } + ); +} + /** * Print a receipt for this session's checkouts */ @@ -1388,6 +1439,7 @@ SelfCheckManager.prototype.printData = function(data, numItems, callback) { } + /** * Print a receipt for this user's items out */ @@ -1585,11 +1637,22 @@ SelfCheckManager.prototype.printFinesReceipt = function(callback) { SelfCheckManager.prototype.logoutPatron = function(print) { progressDialog.show(true); // prevent patron from clicking logout link twice if(print && this.checkouts.length) { - this.printSessionReceipt( - function() { - location.href = location.href; - } - ); + if (dojo.byId('oils-selfck-receipt-print').checked) { + this.printSessionReceipt( + function() { + location.href = location.href; + } + ); + } else if (dojo.byId('oils-selfck-receipt-email').checked) { + this.emailSessionReceipt( + function() { + location.href = location.href; + } + ); + } else { + // user elected to get no receipt + location.href = location.href; + } } else { location.href = location.href; } -- 2.43.2