Bugzilla – Attachment 158590 Details for
Bug 31041
Cashup summary modal printing issue
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31041: (follow-up) Clean up and generalise
Bug-31041-follow-up-Clean-up-and-generalise.patch (text/plain), 8.91 KB, created by
Martin Renvoize (ashimema)
on 2023-11-07 11:38:40 UTC
(
hide
)
Description:
Bug 31041: (follow-up) Clean up and generalise
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2023-11-07 11:38:40 UTC
Size:
8.91 KB
patch
obsolete
>From ff5409f41005e86471efb82fab506c9c010a2fd8 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Tue, 7 Nov 2023 11:35:22 +0000 >Subject: [PATCH] Bug 31041: (follow-up) Clean up and generalise > >This patch cleans out the print media css rules that were originally >added for modalprinting. The window.open method is simpler to maintain >and will more reliably print modal content as expected. > >We factor out the printer code into it's own JS asset that we can apply >to other printable modals and then use it in the two existing places >where such modals have been defined already (cashup summary and bundle >confirmation). > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > .../prog/css/src/staff-global.scss | 33 ---------- > .../prog/en/modules/circ/returns.tt | 17 +---- > .../prog/en/modules/pos/register.tt | 1 + > .../intranet-tmpl/prog/js/cashup_modal.js | 56 ----------------- > .../intranet-tmpl/prog/js/modal_printer.js | 63 +++++++++++++++++++ > 5 files changed, 65 insertions(+), 105 deletions(-) > create mode 100644 koha-tmpl/intranet-tmpl/prog/js/modal_printer.js > >diff --git a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss >index bd29b8762da..51dbcbd69f5 100644 >--- a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss >+++ b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss >@@ -4684,36 +4684,3 @@ div .suggestion_note { > border-bottom-right-radius: 5px; > } > } >- >-@media print { >- body.modalprinter * { >- visibility: hidden; >- } >- >- body.modalprinter .modal-dialog.focused { >- left: 0; >- margin: 0; >- padding: 0; >- position: absolute; >- top: 0; >- } >- >- body.modalprinter .modal-dialog.focused .modal-content { >- border-width: 0; >- } >- >- body.modalprinter .modal-dialog.focused .modal-content .modal-header .modal-title, >- body.modalprinter .modal-dialog.focused .modal-content .modal-body, >- body.modalprinter .modal-dialog.focused .modal-content .modal-body * { >- visibility: visible; >- } >- >- body.modalprinter .modal-dialog.focused .modal-content .modal-header, >- body.modalprinter .modal-dialog.focused .modal-content .modal-body { >- padding: 0; >- } >- >- body.modalprinter .modal-dialog.focused .modal-content .modal-header .modal-title { >- margin-bottom: 20px; >- } >-} >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt >index 5154b71b0b1..da493f261e8 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt >@@ -1638,22 +1638,6 @@ > "order": [[ 1, 'asc' ], [ 0, 'asc' ]] > })); > >- // print modals >- $('.modal.printable').on('shown.bs.modal', function() { >- $('.modal-dialog', this).addClass('focused'); >- $('body').addClass('modalprinter'); >- >- if ($(this).hasClass('autoprint')) { >- window.print(); >- } >- }).on('hidden.bs.modal', function() { >- $('.modal-dialog', this).removeClass('focused'); >- $('body').removeClass('modalprinter'); >- }); >- >- $('.printModal').click(function() { >- window.print(); >- }); > [% IF ( !(Koha.Preference('TransfersBlockCirc')) && Koha.Preference('AutomaticConfirmTransfer') ) %] > $("#wrong-transfer-modal").on('hidden.bs.modal',function(){ > $("#wrongtransferform").submit(); >@@ -1665,6 +1649,7 @@ > [% END %] > [% END %] > }); >+ [% Asset.js("js/modal_printer.js") | $raw %] > </script> > > [% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt >index bb00da9cc2c..b61702d6154 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt >@@ -352,6 +352,7 @@ > [% INCLUDE 'format_price.inc' %] > [% INCLUDE 'js-date-format.inc' %] > [% Asset.js("js/cashup_modal.js") | $raw %] >+ [% Asset.js("js/modal_printer.js") | $raw %] > [% INCLUDE 'calendar.inc' %] > <script> > var sales_table = $("#sales").dataTable($.extend(true, {}, dataTablesDefaults, { >diff --git a/koha-tmpl/intranet-tmpl/prog/js/cashup_modal.js b/koha-tmpl/intranet-tmpl/prog/js/cashup_modal.js >index dceca2f07bf..a28e32a8ffd 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/cashup_modal.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/cashup_modal.js >@@ -41,60 +41,4 @@ $(document).ready(function() { > } > }); > }); >- >- $('.modal.printable').on('shown.bs.modal', function() { >- $('.modal-dialog', this).addClass('focused'); >- $('body').addClass('modalprinter'); >- >- if ($(this).hasClass('autoprint')) { >- window.print(); >- } >- }).on('hidden.bs.modal', function() { >- $('.modal-dialog', this).removeClass('focused'); >- $('body').removeClass('modalprinter'); >- }); >- >- $('.printModal').click(function() { >- >- let contents = $('#cashupSummaryModal .modal-body').html(); >- let win = window.open('',''); >- win.document.write(` >- <style> >- table { >- background-color: #FFFFFF; >- border-bottom: 1px solid #CCCCCC; >- border-collapse: collapse; >- border-left: 1px solid #CCCCCC; >- margin: 3px 0 5px 0; >- padding: 0; >- width: 99%; >- } >- >- td { >- background-color: #FFF; >- border-bottom: 1px solid #CCCCCC; >- border-left: 0; >- border-right: 1px solid #CCCCCC; >- border-top: 0; >- font-size: 12px; >- padding: 5px 5px 5px 5px; >- } >- >- th { >- background-color: #E9E9E9; >- border-bottom: 1px solid #CCCCCC; >- border-left: 0; >- border-right: 1px solid #CCCCCC; >- border-top: 0; >- font-size: 14px; >- font-weight: bold; >- padding: 5px 5px 5px 5px; >- text-align: left; >- } >- </style> >- `) >- win.document.write( contents ); >- win.print(); >- win.close(); >- }); > }); >diff --git a/koha-tmpl/intranet-tmpl/prog/js/modal_printer.js b/koha-tmpl/intranet-tmpl/prog/js/modal_printer.js >new file mode 100644 >index 00000000000..ee64d4e98d4 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/js/modal_printer.js >@@ -0,0 +1,63 @@ >+$(document).ready(function() { >+ >+ function modalPrint() { >+ let title = $('.modal-dialog.focused .modal-title').html(); >+ let contents = $('.modal-dialog.focused .modal-body').html(); >+ let win = window.open('',''); >+ win.document.write(` >+ <style> >+ table { >+ background-color: #FFFFFF; >+ border-bottom: 1px solid #CCCCCC; >+ border-collapse: collapse; >+ border-left: 1px solid #CCCCCC; >+ margin: 3px 0 5px 0; >+ padding: 0; >+ width: 99%; >+ } >+ >+ td { >+ background-color: #FFF; >+ border-bottom: 1px solid #CCCCCC; >+ border-left: 0; >+ border-right: 1px solid #CCCCCC; >+ border-top: 0; >+ font-size: 12px; >+ padding: 5px 5px 5px 5px; >+ } >+ >+ th { >+ background-color: #E9E9E9; >+ border-bottom: 1px solid #CCCCCC; >+ border-left: 0; >+ border-right: 1px solid #CCCCCC; >+ border-top: 0; >+ font-size: 14px; >+ font-weight: bold; >+ padding: 5px 5px 5px 5px; >+ text-align: left; >+ } >+ </style> >+ `) >+ win.document.write( title ); >+ win.document.write( contents ); >+ win.print(); >+ win.close(); >+ } >+ >+ // Set focused on printable modals on open and autoprint if required >+ $('.modal.printable').on('shown.bs.modal', function() { >+ $('.modal-dialog', this).addClass('focused'); >+ >+ if ($(this).hasClass('autoprint')) { >+ modalPrint(); >+ } >+ }).on('hidden.bs.modal', function() { >+ $('.modal-dialog', this).removeClass('focused'); >+ }); >+ >+ // Trigger print on button click >+ $('.printModal').click(function() { >+ modalPrint(); >+ }); >+}); >-- >2.41.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 31041
:
158283
|
158342
|
158589
|
158590
|
158591
|
158592
|
158636
|
158644
|
158645
|
158646
|
158647