From 5908f5af4bce844d3cb84b5de64e46d923d2ece9 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 8 Nov 2018 12:22:02 -0500 Subject: [PATCH] JBAS-2101 Lost payment forces print dialog, uses default context Temporarily clear the silent print option when printing a lost/paid reciept. Send lost/paid receipts to the 'default' printer. Signed-off-by: Bill Erickson --- Open-ILS/xul/staff_client/server/patron/bill2.js | 35 +++++++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/Open-ILS/xul/staff_client/server/patron/bill2.js b/Open-ILS/xul/staff_client/server/patron/bill2.js index 73831cac70..915acc3a4e 100644 --- a/Open-ILS/xul/staff_client/server/patron/bill2.js +++ b/Open-ILS/xul/staff_client/server/patron/bill2.js @@ -938,8 +938,9 @@ function handle_printlostpaid() { var print = new util.print('mail'); print.simple(html , { - no_prompt: false, // always prompt for lost payment receipts - content_type: 'text/html' + no_prompt: false, + content_type: 'text/html', + context: 'default' }); } } @@ -1319,11 +1320,37 @@ function print_refundable_payments_receipt(mrp_ids) { } var html = receipt.template_output().data(); - JSAN.use('util.print'); var print = new util.print('mail'); + JSAN.use('util.print'); + var print = new util.print('mail'); + + // Temporarily override the forced silent print option for lost & + // paid receipts where we /always/ want to show the print dialog. + var prefs = Components.classes['@mozilla.org/preferences-service;1'] + .getService(Components.interfaces['nsIPrefBranch']); + + var silentPrintApplied = ( + prefs.prefHasUserValue('print.always_print_silent') + && prefs.getBoolPref('print.always_print_silent') + ); + + if (silentPrintApplied) { + // Note setting the value to 'false' does not work. + prefs.clearUserPref('print.always_print_silent'); + } + print.simple(html , { no_prompt: false, // always prompt for lost payment receipts - content_type: 'text/html' + content_type: 'text/html', + context: 'default' }); + + if (silentPrintApplied) { + // Re-apply the silent print preference after the + // current thread is done. + setTimeout(function() { + prefs.setBoolPref('print.always_print_silent', true); + }); + } } } -- 2.11.0