From 435f4c70b3ea5ad1d15a2e8992d30df29be9a6ca Mon Sep 17 00:00:00 2001 From: David Cook Date: Mon, 28 Jul 2025 03:26:43 +0000 Subject: [PATCH] Bug 40524: [24.11.x] Update print format to use built-in formatter This change updates the print format to use the built-in formatter for operations like trim, strip HTML, strip newlines, and not decoding entities. Test plan: 0. Apply the patch 1. Go to http://localhost:8081/cgi-bin/koha/acqui/basket.pl?basketno=1 2. Click "add to basket" 3. Type "test" next to "From an existing record" and click "Submit" 4. On the "Gairm" row, click "Add order" 5. Fill in the required fields 6. In the "Internal note" put the following: abc123 7. Click "Save" 8. In the Orders table, click "Export" and then "Print" 9. Note that the print page loads correctly, you can see the internal note, and you cannot see lines for "Add internal note", "Edit internal note", or "Add vendor note" Signed-off-by: Brendan Lawlor Signed-off-by: Marcel de Rooy --- koha-tmpl/intranet-tmpl/prog/js/datatables.js | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js index 57a0a00541e..4af6726e48e 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js +++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js @@ -702,6 +702,26 @@ function _dt_buttons(params){ } } + const export_format_print = { + body: function (data, row, column, node) { + const newnode = node.cloneNode(true); + const no_export_nodes = newnode.querySelectorAll(".no-export"); + no_export_nodes.forEach(child => { + child.parentNode.removeChild(child); + }); + //Note: innerHTML is the same thing as the data variable, + //minus the ".no-export" nodes that we've removed + //Note: See dataTables.buttons.js for original function usage + const str = DataTable.Buttons.stripData(newnode.innerHTML, { + decodeEntities: false, + stripHtml: true, + stripNewlines: true, + trim: true, + }); + return str; + }, + }; + var export_format = { body: function ( data, row, column, node ) { var newnode = $(node); @@ -741,7 +761,7 @@ function _dt_buttons(params){ extend: 'print', exportOptions: { columns: exportColumns, - format: export_format + format: export_format_print, }, } ]; -- 2.39.5