<div id='oils-selfck-circ-info-div'>
<div id='oils-selfck-info-nav'>
<span><a id='oils-selfck-nav-home' href='javascript:void(0);' class='selected'><button type="button" class="self-button">[% l('Home') %]</button></a></span>
- <span><a id='oils-selfck-nav-logout-print' href='javascript:void(0);'><button type="button" class="self-button">[% l('Logout') %]</button></a></span>
- <span><a id='oils-selfck-nav-logout' href='javascript:void(0);'><button type="button" class="self-button">[% l('Logout (No Receipt)') %]</button></a></span>
+ <span><a id='oils-selfck-nav-logout' href='javascript:void(0);'><button type="button" class="self-button">[% l('Logout') %]</button></a></span>
+ </div>
+ <div id='oils-selfck-info-nav'>
+ <span for='oils-selfck-nav-receipt'>[% l('Receipt:') %] </span>
+ <span class="hidden"><input type="radio" name="receipt_type" id='oils-selfck-receipt-email' value="email"/><label for="oils-selfck-receipt-email"> [% l('Email') %]</label></span>
+ <span><input type="radio" name="receipt_type" id='oils-selfck-receipt-print' value="email" checked/><label for="oils-selfck-receipt-print"> [% l('Print') %]</label></span>
+ <span><input type="radio" name="receipt_type" id='oils-selfck-receipt-none' value="email"/><label for="oils-selfck-receipt-none"> [% l('None') %]</label></span>
</div>
<fieldset>
<legend>[% l('Items Checked Out') %]</legend>
);
},
'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(); }
}
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) {
}
/**
+ * 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
*/
SelfCheckManager.prototype.printSessionReceipt = function(callback) {
}
+
/**
* Print a receipt for this user's items out
*/
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;
}