From 7d9149852d91b241b0ba16acea0c2b9c2dd03e43 Mon Sep 17 00:00:00 2001 From: berick Date: Fri, 11 Feb 2011 11:18:28 -0500 Subject: [PATCH] use dojo dialog + iframe for receipt printing instead of window.open to avoid popup blockers; automatically print receipt after payment --- Open-ILS/web/opac/skin/kcls/js/myopac.js | 55 +++++++++++++++------- .../opac/skin/kcls/xml/myopac/myopac_summary.xml | 11 +++++ 2 files changed, 49 insertions(+), 17 deletions(-) diff --git a/Open-ILS/web/opac/skin/kcls/js/myopac.js b/Open-ILS/web/opac/skin/kcls/js/myopac.js index e50e2ef235..af91e05028 100644 --- a/Open-ILS/web/opac/skin/kcls/js/myopac.js +++ b/Open-ILS/web/opac/skin/kcls/js/myopac.js @@ -1433,7 +1433,13 @@ function _myopacDrawPayments(r) { ); } -function emailPaymentReceipt(paymentIds) { +function emailPaymentReceipt(paymentIds, callback) { + + if(!G.user.email()) { + if(callback) callback(); + return; + } + progressDialog.show(true); fieldmapper.standardRequest( @@ -1444,7 +1450,7 @@ function emailPaymentReceipt(paymentIds) { oncomplete : function(r) { progressDialog.hide(); openils.Util.readResponse(r); - alert('Email will be delivered shortly...'); + if(callback) callback(); } } ); @@ -1549,6 +1555,7 @@ function showPaymentForm() { G.user.last_xact_id(resp.last_xact_id); // update to match latest from server $('cc-payment-error-message').innerHTML = 'Payment Successful\nTRANSACTION ID: '+resp.last_xact_id; printPaymentReceipt(resp.payments); + emailPaymentReceipt(resp.payments); hideMe($('pay_fines_now'));unHideMe($('acct_sum')); finesShown = false; myOPACShowFines(); @@ -2140,21 +2147,35 @@ function sortCheckedHist(by) { } function printData(data, numItems, callback) { - var win = window.open('', '', 'resizable,width=350,height=250,scrollbars=1'); - win.document.body.innerHTML = data; - win.print(); - - var sleepTime = 1000; - if(numItems > 0) - sleepTime += (numItems / 2) * 1000; - - setTimeout( - function() { - win.close(); // close the print window - if(callback) callback(); // fire optional post-print callback - }, - sleepTime - ); + + //unHideMe($('receipt-print-frame-wrapper')); + receiptPrintDialog.show(); + + var frame = window["receipt-frame"]; + frame.document.body.innerHTML = data; + + var cancel = $('receipt-view-print-cancel'); + cancel.onclick = function() { + frame.document.body.innerHTML = ''; + // hideMe($('receipt-print-frame-wrapper')); + receiptPrintDialog.hide(); + } + + $('receipt-view-print-button').onclick = function() { + frame.focus(); + frame.print(); + var sleepTime = 1000; + if(numItems > 0) + sleepTime += (numItems / 2) * 1000; + + setTimeout( + function() { + cancel.onclick(); + if(callback) callback(); // fire optional post-print callback + }, + sleepTime + ); + }; } diff --git a/Open-ILS/web/opac/skin/kcls/xml/myopac/myopac_summary.xml b/Open-ILS/web/opac/skin/kcls/xml/myopac/myopac_summary.xml index bf442c86bf..375bdaf187 100644 --- a/Open-ILS/web/opac/skin/kcls/xml/myopac/myopac_summary.xml +++ b/Open-ILS/web/opac/skin/kcls/xml/myopac/myopac_summary.xml @@ -170,6 +170,17 @@ + +
+
+ + +
+ +
+
-- 2.11.0