From 1969d3ac016f8e39201fdb7afe86e939dd42743c Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Tue, 18 Apr 2023 04:52:46 +0000 Subject: [PATCH] Bug 33478: Add formatting columns to letter table --- .../bug_33478-add_letter_columns.pl | 138 ++++++++++++++++++ installer/data/mysql/kohastructure.sql | 16 ++ 2 files changed, 154 insertions(+) create mode 100644 installer/data/mysql/atomicupdate/bug_33478-add_letter_columns.pl diff --git a/installer/data/mysql/atomicupdate/bug_33478-add_letter_columns.pl b/installer/data/mysql/atomicupdate/bug_33478-add_letter_columns.pl new file mode 100644 index 00000000000..125146472dc --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_33478-add_letter_columns.pl @@ -0,0 +1,138 @@ +use Modern::Perl; + +return { + bug_number => "33478", + description => "Customise the format of notices when they are printed", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + + if( !column_exists( 'letter', 'font' ) ) { + $dbh->do(q{ + ALTER TABLE letter ADD COLUMN `font` char(10) NOT NULL DEFAULT 'TR' AFTER `updated_on` + }); + + say $out "Added column 'letter.font'"; + } + + if( !column_exists( 'letter', 'font_size' ) ) { + $dbh->do(q{ + ALTER TABLE letter ADD COLUMN `font_size` int(4) NOT NULL DEFAULT 10 AFTER `font` + }); + + say $out "Added column 'letter.font_size'"; + } + + if( !column_exists( 'letter', 'text_justify' ) ) { + $dbh->do(q{ + ALTER TABLE letter ADD COLUMN `text_justify` char(1) NOT NULL DEFAULT 'L' AFTER `font_size` + }); + + say $out "Added column 'letter.text_justify'"; + } + + if( !column_exists( 'letter', 'units' ) ) { + $dbh->do(q{ + ALTER TABLE letter ADD COLUMN `units` char(20) NOT NULL DEFAULT 'INCH' AFTER `text_justify` + }); + + say $out "Added column 'letter.units'"; + } + + if( !column_exists( 'letter', 'notice_width' ) ) { + $dbh->do(q{ + ALTER TABLE letter ADD COLUMN `notice_width` float NOT NULL DEFAULT 8.5 AFTER `units` + }); + + say $out "Added column 'letter.notice_width'"; + } + + if( !column_exists( 'letter', 'notice_length' ) ) { + $dbh->do(q{ + ALTER TABLE letter ADD COLUMN `notice_length` float NOT NULL DEFAULT 11 AFTER `notice_width` + }); + + say $out "Added column 'letter.notice_length'"; + } + + if( !column_exists( 'letter', 'page_width' ) ) { + $dbh->do(q{ + ALTER TABLE letter ADD COLUMN `page_width` float NOT NULL DEFAULT 8.5 AFTER `notice_width` + }); + + say $out "Added column 'letter.page_width'"; + } + + if( !column_exists( 'letter', 'page_length' ) ) { + $dbh->do(q{ + ALTER TABLE letter ADD COLUMN `page_length` float NOT NULL DEFAULT 11 AFTER `page_width` + }); + + say $out "Added column 'letter.page_length'"; + } + + if( !column_exists( 'letter', 'top_text_margin' ) ) { + $dbh->do(q{ + ALTER TABLE letter ADD COLUMN `top_text_margin` float NOT NULL DEFAULT 0 AFTER `page_length` + }); + + say $out "Added column 'letter.top_text_margin'"; + } + + if( !column_exists( 'letter', 'left_text_margin' ) ) { + $dbh->do(q{ + ALTER TABLE letter ADD COLUMN `left_text_margin` float NOT NULL DEFAULT 0 AFTER `top_text_margin` + }); + + say $out "Added column 'letter.left_text_margin'"; + } + + if( !column_exists( 'letter', 'top_margin' ) ) { + $dbh->do(q{ + ALTER TABLE letter ADD COLUMN `top_margin` float NOT NULL DEFAULT 0.5 AFTER `left_text_margin` + }); + + say $out "Added column 'letter.top_margin'"; + } + + if( !column_exists( 'letter', 'left_margin' ) ) { + $dbh->do(q{ + ALTER TABLE letter ADD COLUMN `left_margin` float NOT NULL DEFAULT 0.5 AFTER `top_margin` + }); + + say $out "Added column 'letter.left_margin'"; + } + + if( !column_exists( 'letter', 'cols' ) ) { + $dbh->do(q{ + ALTER TABLE letter ADD COLUMN `cols` float NOT NULL DEFAULT 1 AFTER `left_margin` + }); + + say $out "Added column 'letter.cols'"; + } + + if( !column_exists( 'letter', 'rows' ) ) { + $dbh->do(q{ + ALTER TABLE letter ADD COLUMN `rows` float NOT NULL DEFAULT 1 AFTER `cols` + }); + + say $out "Added column 'letter.rows'"; + } + + if( !column_exists( 'letter', 'col_gap' ) ) { + $dbh->do(q{ + ALTER TABLE letter ADD COLUMN `col_gap` float NOT NULL DEFAULT 0 AFTER `rows` + }); + + say $out "Added column 'letter.col_gap'"; + } + + if( !column_exists( 'letter', 'row_gap' ) ) { + $dbh->do(q{ + ALTER TABLE letter ADD COLUMN `row_gap` float NOT NULL DEFAULT 0 AFTER `col_gap` + }); + + say $out "Added column 'letter.row_gap'"; + } + }, +}; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index cba889d5e0f..cad6df880e5 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -3856,6 +3856,22 @@ CREATE TABLE `letter` ( `message_transport_type` varchar(20) NOT NULL DEFAULT 'email' COMMENT 'transport type for this notice', `lang` varchar(25) NOT NULL DEFAULT 'default' COMMENT 'lang of the notice', `updated_on` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'last modification', + `font` char(10) NOT NULL DEFAULT 'TR' COMMENT 'font used when notice is printed', + `font_size` int(4) NOT NULL DEFAULT 10 COMMENT 'font size used when notice is printed', + `text_justify` char(1) NOT NULL DEFAULT 'L' COMMENT 'text justification used when notice is printed', + `units` char(20) NOT NULL DEFAULT 'INCH' COMMENT 'units to use for print measurements', + `notice_width` float NOT NULL DEFAULT 8.5 COMMENT 'width of individual notice', + `notice_length` float NOT NULL DEFAULT 11 COMMENT 'length of individual notice', + `page_width` float NOT NULL DEFAULT 8.5 COMMENT 'width of printer page', + `page_length` float NOT NULL DEFAULT 11 COMMENT 'length of printer page', + `top_text_margin` float NOT NULL DEFAULT 0 COMMENT 'top margin for notice text', + `left_text_margin` float NOT NULL DEFAULT 0 COMMENT 'left margin for notice text', + `top_margin` float NOT NULL DEFAULT 0.5 COMMENT 'top margin for page', + `left_margin` float NOT NULL DEFAULT 0.5 COMMENT 'left margin for page', + `cols` float NOT NULL DEFAULT 1 COMMENT 'number of notices to print across the width of the page', + `rows` float NOT NULL DEFAULT 1 COMMENT 'number of notices to print down the length of the page', + `col_gap` float NOT NULL DEFAULT 0 COMMENT 'padding between notices across the width of the page', + `row_gap` float NOT NULL DEFAULT 0 COMMENT 'padding between notices down the length of the page', PRIMARY KEY (`id`), UNIQUE KEY `letter_uniq_1` (`module`,`code`,`branchcode`,`message_transport_type`,`lang`), KEY `message_transport_type_fk` (`message_transport_type`), -- 2.30.2