--- /dev/null
+-- Deploy kcls-evergreen:selfcheck-email-receipts to pg
+--requires 2.7-to-2.9-upgrade-part-2
+BEGIN;
+
+DO $$
+BEGIN
+ IF evergreen.insert_on_deploy() THEN
+ INSERT INTO action_trigger.hook (
+ key,
+ core_type,
+ description,
+ passive
+ ) VALUES (
+ 'email.selfcheck.checkout',
+ 'circ',
+ 'Formats circ objects for self-checkout email.',
+ TRUE
+ );
+
+ INSERT INTO action_trigger.event_definition (
+ active,
+ owner,
+ name,
+ hook,
+ validator,
+ reactor,
+ group_field,
+ template )
+ VALUES (
+ TRUE,
+ 1,
+ 'Email Self-Checkout Receipt',
+ 'email.selfcheck.checkout',
+ 'NOOP_True',
+ 'SendEmail',
+ 'usr',
+ $email_receipt_template$
+[%- USE date -%]
+[%- user = target.0.usr -%]
+To: [%- params.recipient_email || user.email %]
+From: [%- params.sender_email || helpers.get_org_setting(target.0.circ_lib.id, 'org.bounced_emails') || lib.email || default_sender %]
+ Subject: Checkout Receipt
+
+ Dear [% user.first_given_name %],
+
+ You checked out the following items:
+
+[% FOR circ IN target %]
+ [%- copy_details = helpers.get_copy_bib_basics(circ.target_copy.id) -%]
+ Title: [% copy_details.title %]
+ Author: [% copy_details.author %]
+ Call Number: [% circ.target_copy.call_number.label %]
+ Barcode: [% circ.target_copy.barcode %]
+ Due Date: [% date.format(helpers.format_date(circ.due_date), '%m/%d/%Y') %]
+ Library: [% circ.circ_lib.name %]
+
+ [% END %]
+ $email_receipt_template$);
+
+
+
+ INSERT INTO action_trigger.environment (
+ event_def,
+ path
+ ) VALUES (
+ currval('action_trigger.event_definition_id_seq'),
+ 'target_copy.call_number'
+ ), (
+ currval('action_trigger.event_definition_id_seq'),
+ 'target_copy.location'
+ ), (
+ currval('action_trigger.event_definition_id_seq'),
+ 'usr'
+ ), (
+ currval('action_trigger.event_definition_id_seq'),
+ 'circ_lib'
+ );
+
+
+ END IF;
+END $$;
+
+COMMIT;
+
+
+
console.log('Starting new login timer');
// do not show a warning dialog if the inactivity timeout
- // occurs during the login stage.
+ // occurs between entering a barcode and password.
selfckStartTimer(!Boolean(selfCheckManager.patron));
}
'oils-selfck-nav-logout-print' : function() { self.logoutPatron(true); },
'oils-selfck-items-out-details-link' : function() { self.drawItemsOutPage(); },
//'oils-selfck-print-list-link' : function() { self.printList(); }
+ 'oils-selfck-nav-logout-email' : function() { self.logoutPatronWithEmail(true); }
}
for(var id in linkHandlers) {
dojo.byId('oils-selfck-status-div2').innerHTML = '';
dojo.byId('oils-selfck-status-div3').innerHTML = '';
openils.Util.hide('back_to_login');
- this.drawCircPage();
+ if(this.patron.email() && this.patron.email().match(/.+@.+/) != null){
+ openils.Util.removeCSSClass( dojo.byId('oils-selfck-nav-logout-email'), 'hidden' );
}
+ this.drawCircPage();
+ }
}
oncomplete : function(r) {
var summary = openils.Util.readResponse(r);
var finesSum = dojo.byId('acct_fines');
- var bal = summary.balance_owed();
+ var bal = summary ? summary.balance_owed() : 0;
var bal2 = parseFloat(bal);
if(bal2>0) {finesSum.style.color="red"; openils.Util.show('oils-selfck-pay-fines-link');}
var self = this;
fieldmapper.standardRequest(
['open-ils.circ', 'open-ils.circ.fire_circ_trigger_events'],
- {
+ {
async : false,
params : params,
oncomplete : function(r) {
setTimeout(
function() {
win.close(); // close the print window
- if(callback) callback(); // fire optional post-print callback
+ if(callback) callback(); // fire callback to return to main page
},
sleepTime
);
}
);
}
+/**Send email receipt for this session's checkouts
+ */
+SelfCheckManager.prototype.emailSessionReceipt = function(callback) {
+
+ var circIds = [];
+ var circCtx = []; // circ context data. in this case, renewal_failure info
+
+ // collect the circs and failure info
+ dojo.forEach(
+ this.checkouts,
+ function(blob) {
+ circIds.push(blob.circ);
+ circCtx.push({renewal_failure:blob.renewal_failure});
+ }
+ );
+ var params = [
+ this.authtoken,
+ this.staff.ws_ou(),
+ null,
+ 'email.selfcheck.checkout',
+ 'print-on-demand',
+ circIds,
+ circCtx
+ ];
+
+ var self = this;
+ fieldmapper.standardRequest(
+ ['open-ils.circ', 'open-ils.circ.fire_circ_trigger_events'],
+ {
+ async : false,
+ params : params,
+ oncomplete : function(r) {
+ var resp = openils.Util.readResponse(r);
+ var output = resp.template_output();
+ if(output) {
+ if (callback) callback();
+ } else {
+ var error = resp.error_output();
+ if(error) {
+ throw new Error("Error creating receipt: " + error.data());
+ } else {
+ throw new Error("No receipt data returned from server");
+ }
+ }
+ }
+ }
+ );
+}
+
+
/**
* Print a receipt for this user's items out
);
}
+/**
+ * Logout the patron and return to the login page
+ */
+SelfCheckManager.prototype.logoutPatronWithEmail = function(email) {
+ var return_url = this.cgi.param('return-to') || location.href;
+ if(email && this.checkouts.length) {
+ this.emailSessionReceipt(
+ function() {
+ location.href = return_url;
+ }
+ );
+ } else {
+ location.href = return_url;
+ }
+}
/**
* Logout the patron and return to the login page
SelfCheckManager.prototype.logoutPatron = function(print) {
var return_url = this.cgi.param('return-to') || location.href;
-
progressDialog.show(true); // prevent patron from clicking logout link twice
if(print && this.checkouts.length) {
this.printSessionReceipt(
function() {
- location.href = return_url;
+ //also closes progress dialog
+ location.href = return_url;
}
);
} else {
selfCheckManager.init();
openils.Util.registerEnterHandler(dojo.byId('patron-login-username'), function(){checkLogin();});
openils.Util.registerEnterHandler(dojo.byId('patron-login-password'), function(){selfCheckMgr.loginPatron(dojo.byId('patron-login-username').value,dojo.byId('patron-login-password').value);});
-
- // If we have a return-to address, start the login timer
- // before the patron logs in, so we can revert back to
- // our return-to page if the patron never logs in.
- if (selfCheckManager.cgi.param('return-to')) {
- selfckResetTimer();
- }
}
);