From 5deb868e02bc747dfc3d0878ce04cc7bf368e67c Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Wed, 12 May 2021 12:00:31 +0200 Subject: [PATCH] Bug 28327: System preference CSVdelimiter special case for tabulation System preference 'CSVdelimiter' has a special case for tabulation. Preference value contains string 'tabulation' but string '\t' must be used in CSV file. This is OK in many places, for exemple Bug 17590. This patch fixed when preference is fetch in template. Test plan : 1) Set system preference 'CSVdelimiter' = 'tabs'. 2) Create CSV export in impacted pages 3) Check columns are separated by tabulation character and not string 'tabulation' --- Koha/Template/Plugin/Koha.pm | 7 +++++++ .../prog/en/includes/catalogue/itemsearch_item.csv.inc | 2 +- .../prog/en/includes/csv_headers/acqui/basket.tt | 2 +- .../prog/en/includes/csv_headers/acqui/basketgroup.tt | 2 +- .../prog/en/includes/csv_headers/acqui/lateorders.tt | 2 +- .../prog/en/includes/csv_headers/catalogue/itemsearch.tt | 2 +- .../intranet-tmpl/prog/en/modules/acqui/csv/basket.tt | 2 +- .../intranet-tmpl/prog/en/modules/acqui/csv/basketgroup.tt | 2 +- .../intranet-tmpl/prog/en/modules/acqui/csv/lateorders.tt | 2 +- 9 files changed, 15 insertions(+), 8 deletions(-) diff --git a/Koha/Template/Plugin/Koha.pm b/Koha/Template/Plugin/Koha.pm index 5ed58a95ad..2d34af0cc2 100644 --- a/Koha/Template/Plugin/Koha.pm +++ b/Koha/Template/Plugin/Koha.pm @@ -55,6 +55,13 @@ sub Preference { return C4::Context->preference( $pref ); } +sub CSVDelimiter { + my ( $self, $val ) = @_; + my $sep = $val || C4::Context->preference('CSVDelimiter') || ','; + $sep = "\t" if $sep eq 'tabulation'; + return $sep; +} + sub Version { my $version_string = Koha::version(); my ( $major, $minor, $maintenance, $development ) = split( '\.', $version_string ); diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.csv.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.csv.inc index 739c145cb5..4582603b1e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.csv.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.csv.inc @@ -5,7 +5,7 @@ [%- USE AuthorisedValues -%] [%- SET biblio = item.biblio -%] [%- SET biblioitem = item.biblioitem -%] -[%- SET delimiter = Koha.Preference( 'CSVDelimiter' ) || ',' -%] +[%- SET delimiter = Koha.CSVDelimiter() -%] "[% biblio.title | replace('"', '""') | $raw %] [% IF ( Koha.Preference( 'marcflavour' ) == 'UNIMARC' && biblio.author ) %]by [% END %][% biblio.author | replace('"', '""') | $raw %]" [%- delimiter | $raw -%] "[% (biblioitem.publicationyear || biblio.copyrightdate) | replace('"', '""') | $raw %]" diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/csv_headers/acqui/basket.tt b/koha-tmpl/intranet-tmpl/prog/en/includes/csv_headers/acqui/basket.tt index 75d246c26e..bf408307f1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/csv_headers/acqui/basket.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/csv_headers/acqui/basket.tt @@ -1,4 +1,4 @@ [%- USE Koha -%] -[%- SET delimiter = Koha.Preference( 'CSVDelimiter' ) || ',' -%] +[%- SET delimiter = Koha.CSVDelimiter() -%] [%- BLOCK -%]Contract name[% delimiter | html %]Order number[% delimiter | html %]Entry date[% delimiter | html %]ISBN[% delimiter | html %]Author[% delimiter | html %]Title[% delimiter | html %]Publication year[% delimiter | html %]Publisher[% delimiter | html %]Collection title[% delimiter | html %]Note for vendor[% delimiter | html %]Quantity[% delimiter | html %]RRP[% delimiter | html %]Delivery place[% delimiter | html %]Billing place[%- END -%] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/csv_headers/acqui/basketgroup.tt b/koha-tmpl/intranet-tmpl/prog/en/includes/csv_headers/acqui/basketgroup.tt index 63cc1ceb14..be05cb98b4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/csv_headers/acqui/basketgroup.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/csv_headers/acqui/basketgroup.tt @@ -1,4 +1,4 @@ [%- USE Koha -%] -[%- SET delimiter = Koha.Preference( 'CSVDelimiter' ) || ',' -%] +[%- SET delimiter = Koha.CSVDelimiter() -%] [%- BLOCK -%]Account number[% delimiter | html %]Basket name[% delimiter | html %]Order number[% delimiter | html %]Author[% delimiter | html %]Title[% delimiter | html %]Publisher[% delimiter | html %]Publication year[% delimiter | html %]Collection title[% delimiter | html %]ISBN[% delimiter | html %]Quantity[% delimiter | html %]RRP tax included[% delimiter | html %]RRP tax excluded[% delimiter | html %]Discount[% delimiter | html %]Estimated cost tax included[% delimiter | html %]Estimated cost tax excluded[% delimiter | html %]Note for vendor[% delimiter | html %]Entry date[% delimiter | html %]Bookseller name[% delimiter | html %]Bookseller physical address[% delimiter | html %]Bookseller postal address[% delimiter | html %]Contract number[% delimiter | html %]Contract name[% delimiter | html %]Basket group delivery place[% delimiter | html %]Basket group billing place[% delimiter | html %]Basket delivery place[% delimiter | html %]Basket billing place[%- END -%] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/csv_headers/acqui/lateorders.tt b/koha-tmpl/intranet-tmpl/prog/en/includes/csv_headers/acqui/lateorders.tt index 5bda385df0..bc02b07306 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/csv_headers/acqui/lateorders.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/csv_headers/acqui/lateorders.tt @@ -1,4 +1,4 @@ [%- USE Koha -%] -[%- SET delimiter = Koha.Preference('CSVDelimiter') || ',' -%] +[%- SET delimiter = Koha.CSVDelimiter() -%] [%- BLOCK -%]ORDER DATE[%- delimiter | html -%]ESTIMATED DELIVERY DATE[%- delimiter | html -%]VENDOR[%- delimiter | html -%]INFORMATION[%- delimiter | html -%]TOTAL COST[%- delimiter | html -%]BASKET[%- delimiter | html -%]CLAIMS COUNT[%- delimiter | html -%]CLAIMED DATE[%- delimiter | html -%]INTERNAL NOTE[%- delimiter | html -%]VENDOR NOTE[%- delimiter | html -%]ISBN[%- END -%] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/csv_headers/catalogue/itemsearch.tt b/koha-tmpl/intranet-tmpl/prog/en/includes/csv_headers/catalogue/itemsearch.tt index eccba14468..e4e0d00033 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/csv_headers/catalogue/itemsearch.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/csv_headers/catalogue/itemsearch.tt @@ -1,6 +1,6 @@ [%- USE raw -%] [%- USE Koha -%] -[%- SET delimiter = Koha.Preference('CSVDelimiter') || ',' -%] +[%- SET delimiter = Koha.CSVDelimiter() -%] [%- BLOCK -%] "Title" [%- delimiter | $raw -%] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/csv/basket.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/csv/basket.tt index ebc67b91c9..9987cd35cf 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/csv/basket.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/csv/basket.tt @@ -1,5 +1,5 @@ [%- USE Koha -%] -[%- SET delimiter = Koha.Preference( 'CSVDelimiter' ) || ',' -%] +[%- SET delimiter = Koha.CSVDelimiter() -%] [%- INCLUDE csv_headers/acqui/basket.tt -%] [%- INCLUDE empty_line.inc -%] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/csv/basketgroup.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/csv/basketgroup.tt index c005cd67c0..84df7f7538 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/csv/basketgroup.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/csv/basketgroup.tt @@ -1,5 +1,5 @@ [%- USE Koha -%] -[%- SET delimiter = Koha.Preference( 'CSVDelimiter' ) || ',' -%] +[%- SET delimiter = Koha.CSVDelimiter() -%] [%- USE Price -%] [%- INCLUDE csv_headers/acqui/basketgroup.tt -%] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/csv/lateorders.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/csv/lateorders.tt index 7bef44ee43..dd753bd95e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/csv/lateorders.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/csv/lateorders.tt @@ -1,5 +1,5 @@ [%- USE Koha -%] -[%- SET delimiter = Koha.Preference( 'CSVDelimiter' ) || ',' -%] +[%- SET delimiter = Koha.CSVDelimiter() -%] [%- USE KohaDates -%] [%- INCLUDE csv_headers/acqui/lateorders.tt -%] -- 2.30.2