From 50877291b26b316eacdf0fdca759d9e8c3004a77 Mon Sep 17 00:00:00 2001 From: Katrin Fischer Date: Thu, 27 Aug 2020 10:38:25 +0000 Subject: [PATCH] Bug 25776: Add a 'last updated' column for notices This add an 'udated_on' column to the letter table and displays the information in 'slips and notices'. To test: - Apply patch - Run updatedatabase Note: the existing letters will all be set to the currnet date). - Go to Tools > Notices and slips - Verify there is a new column "Last updated" in the table Note: The table will always display the newest change date of the different message transport types. - Edit any notice - Verify the "Last updated" is shown for any transport type with an existing notice definition - Edit and add a notice - Verify the dates are correctly stored - Test the column configuration for the new column works correctly Signed-off-by: David Nind Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart --- admin/columns_settings.yml | 2 ++ .../atomicupdate/bug-25776-letter_updated_on.perl | 12 ++++++++++++ installer/data/mysql/kohastructure.sql | 1 + .../intranet-tmpl/prog/en/modules/tools/letter.tt | 9 +++++++++ tools/letter.pl | 3 ++- 5 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 installer/data/mysql/atomicupdate/bug-25776-letter_updated_on.perl diff --git a/admin/columns_settings.yml b/admin/columns_settings.yml index f010bedc11..f8d92d2e08 100644 --- a/admin/columns_settings.yml +++ b/admin/columns_settings.yml @@ -1438,6 +1438,8 @@ modules: columnname: code - columnname: name + - + columnname: updated_on - columnname: copy_notice - diff --git a/installer/data/mysql/atomicupdate/bug-25776-letter_updated_on.perl b/installer/data/mysql/atomicupdate/bug-25776-letter_updated_on.perl new file mode 100644 index 0000000000..802cb55f05 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug-25776-letter_updated_on.perl @@ -0,0 +1,12 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + unless ( column_exists('letter', 'updated_on') ) { + $dbh->do( + qq{ + ALTER TABLE letter ADD COLUMN updated_on timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP AFTER lang + } + ); + } + NewVersion( $DBversion, 25776, "Add letter.updated_on"); + +} diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 7c6d0302c5..7bc8a4dd96 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -2493,6 +2493,7 @@ CREATE TABLE `letter` ( -- table for all notice templates in Koha `content` MEDIUMTEXT, -- body text for the notice or slip `message_transport_type` varchar(20) NOT NULL DEFAULT 'email', -- transport type for this notice `lang` varchar(25) NOT NULL DEFAULT 'default', -- lang of the notice + `updated_on` timestamp NOT NULL default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, -- last modification PRIMARY KEY (`module`,`code`, `branchcode`, `message_transport_type`, `lang`), CONSTRAINT `message_transport_type_fk` FOREIGN KEY (`message_transport_type`) REFERENCES `message_transport_types` (`message_transport_type`) ON DELETE CASCADE ON UPDATE CASCADE diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt index e51e719aba..3e830e9c2d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt @@ -1,6 +1,7 @@ [% USE raw %] [% USE Asset %] [% USE Koha %] +[% USE KohaDates %] [% USE Branches %] [% USE TablesSettings %] [% SET footerjs = 1 %] @@ -142,6 +143,7 @@ Module Code Name + Last updated Copy notice Actions @@ -175,6 +177,7 @@ [% lette.code | html %] [% lette.name | html %] + [% lette.updated_on | $KohaDates with_hours = 1 %] [% IF !independant_branch || !lette.branchcode %]
@@ -417,6 +420,12 @@
[% END %]
    + [% IF ( letter.updated_on ) %] +
  1. + + [% letter.updated_on | $KohaDates with_hours = 1 %] +
  2. + [% END %]
  3. diff --git a/tools/letter.pl b/tools/letter.pl index eb2cd98e63..7af71dda2a 100755 --- a/tools/letter.pl +++ b/tools/letter.pl @@ -207,6 +207,7 @@ sub add_form { $letters{ $lang }{templates}{$mtt} = { message_transport_type => $letter->{message_transport_type}, is_html => $letter->{is_html}, + updated_on => $letter->{updated_on}, title => $letter->{title}, content => $letter->{content} // '', }; @@ -367,7 +368,7 @@ sub retrieve_letters { my $dbh = C4::Context->dbh; my ($sql, @where, @args); - $sql = "SELECT branchcode, module, code, name, branchname + $sql = "SELECT branchcode, module, code, name, branchname, MAX(updated_on) as updated_on FROM letter LEFT OUTER JOIN branches USING (branchcode) "; -- 2.39.5