From 713bc6c870723f7dbe7ac16bd0b4d4ff058a22d6 Mon Sep 17 00:00:00 2001 From: Maryse Simard Date: Thu, 20 Oct 2022 16:48:12 -0400 Subject: [PATCH] Bug 17015: Add description field --- Koha/DiscreteCalendar.pm | 49 +++++++++++-------- Koha/Schema/Result/DiscreteCalendar.pm | 12 ++++- ..._17015_part1_create_discrete_calendar.perl | 1 + .../bug_17015_part4_add_description.perl | 8 +++ .../en/modules/tools/discrete_calendar.tt | 23 +++++++-- tools/discrete_calendar.pl | 2 + 6 files changed, 70 insertions(+), 25 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_17015_part4_add_description.perl diff --git a/Koha/DiscreteCalendar.pm b/Koha/DiscreteCalendar.pm index 9ee432e6ad..303ed502a7 100644 --- a/Koha/DiscreteCalendar.pm +++ b/Koha/DiscreteCalendar.pm @@ -136,7 +136,7 @@ sub get_dates_info { { select => [ 'date', { DATE => 'date' } ], as => [qw/ date date /], - columns =>[ qw/ holiday_type open_hour close_hour note/] + columns =>[ qw/ holiday_type open_hour close_hour note description/] }, ); @@ -149,7 +149,8 @@ sub get_dates_info { holiday_type => $date->holiday_type() , open_hour => $date->open_hour(), close_hour => $date->close_hour(), - note => $date->note() + note => $date->note(), + description => $date->description(), }; } @@ -255,7 +256,7 @@ sub get_date_info { select => [ 'date', { DATE => 'date' } ], as => [qw/ date date /], where => \['DATE(?) = date', $date_string ], - columns =>[ qw/ branchcode holiday_type open_hour close_hour note/] + columns =>[ qw/ branchcode holiday_type open_hour close_hour note description/] }, ); my $dateDTO; @@ -266,7 +267,8 @@ sub get_date_info { holiday_type => $date->holiday_type() , open_hour => $date->open_hour(), close_hour => $date->close_hour(), - note => $date->note() + note => $date->note(), + description => $date->description(), }; } @@ -346,8 +348,8 @@ sub get_unique_holidays { holiday_type => $HOLIDAYS->{EXCEPTION} }, { - select => [{ DATE => 'date' }, 'note' ], - as => [qw/ date note/], + select => [{ DATE => 'date' }, 'note', 'description' ], + as => [qw/ date note description/], where => ($exclude_past ? \[' date >= CURRENT_DATE()'] : {} ), } ); @@ -357,7 +359,8 @@ sub get_unique_holidays { push @unique_holidays, { date => $date->date(), outputdate => $outputdate, - note => $date->note() + note => $date->note(), + description => $date->description(), } } @@ -385,8 +388,8 @@ sub get_float_holidays { holiday_type => $HOLIDAYS->{FLOAT} }, { - select => [{ DATE => 'date' }, 'note' ], - as => [qw/ date note/], + select => [{ DATE => 'date' }, 'note', 'description' ], + as => [qw/ date note description/], where => ($exclude_past ? \[' date >= CURRENT_DATE()'] : {} ), } ); @@ -396,7 +399,8 @@ sub get_float_holidays { push @float_holidays, { date => $date->date(), outputdate => $outputdate, - note => $date->note() + note => $date->note(), + description => $date->description(), } } @@ -424,8 +428,8 @@ sub get_need_validation_holidays { holiday_type => $HOLIDAYS->{NEED_VALIDATION} }, { - select => [{ DATE => 'date' }, 'note' ], - as => [qw/ date note/], + select => [{ DATE => 'date' }, 'note', 'description' ], + as => [qw/ date note description/], where => ($exclude_past ? \[' date >= CURRENT_DATE()'] : {} ), } ); @@ -435,7 +439,8 @@ sub get_need_validation_holidays { push @need_validation_holidays, { date => $date->date(), outputdate => $outputdate, - note => $date->note() + note => $date->note(), + description => $date->description(), } } @@ -464,8 +469,8 @@ sub get_repeatable_holidays { }, { - select => \[ 'distinct DAY(date), MONTH(date), note'], - as => [qw/ day month note/], + select => \[ 'distinct DAY(date), MONTH(date), note, description'], + as => [qw/ day month note description/], where => ($exclude_past ? \[' date >= CURRENT_DATE()'] : {} ), } ); @@ -474,7 +479,8 @@ sub get_repeatable_holidays { push @repeatable_holidays, { day => $date->get_column('day'), month => $date->get_column('month'), - note => $date->note() + note => $date->note(), + description => $date->description(), }; } @@ -502,8 +508,8 @@ sub get_week_days_holidays { branchcode => $branchcode, }, { - select => \[ 'distinct DAYOFWEEK(date), note'], - as => [qw/ weekday note /], + select => \[ 'distinct DAYOFWEEK(date), note, description'], + as => [qw/ weekday note description /], where => ($exclude_past ? \[' date >= CURRENT_DATE()'] : {} ), } ); @@ -511,7 +517,8 @@ sub get_week_days_holidays { while (my $date = $rs->next()) { push @week_days, { weekday => ($date->get_column('weekday') -1), - note => $date->note() + note => $date->note(), + description => $date->description(), }; } @@ -547,6 +554,7 @@ sub edit_holiday { my ($params) = @_; my $title = $params->{title}; + my $description = $params->{description}; my $weekday = $params->{weekday} || ''; my $holiday_type = $params->{holiday_type}; @@ -577,6 +585,7 @@ sub edit_holiday { my %updateValues = ( is_opened => 0, note => $title, + description => $description, holiday_type => $holiday_type, ); $updateValues{open_hour} = $open_hour if $open_hour ne ''; @@ -938,7 +947,7 @@ sub copy_holiday { { select => [{ DAYOFWEEK => 'date' }], as => [qw/ weekday /], - columns =>[ qw/ holiday_type note open_hour close_hour note/] + columns =>[ qw/ holiday_type note open_hour close_hour note description/] } ); my $copyDate = $fromDate->next(); diff --git a/Koha/Schema/Result/DiscreteCalendar.pm b/Koha/Schema/Result/DiscreteCalendar.pm index 6db32c892e..777ac4952d 100644 --- a/Koha/Schema/Result/DiscreteCalendar.pm +++ b/Koha/Schema/Result/DiscreteCalendar.pm @@ -55,6 +55,12 @@ __PACKAGE__->table("discrete_calendar"); is_nullable: 1 size: 30 +=head2 description + + data_type: 'mediumtext' + default_value: '''' + is_nullable: 1 + =head2 open_hour data_type: 'time' @@ -82,6 +88,8 @@ __PACKAGE__->add_columns( { data_type => "varchar", default_value => "", is_nullable => 1, size => 1 }, "note", { data_type => "varchar", default_value => "", is_nullable => 1, size => 30 }, + "description", + { data_type => "mediumtext", default_value => "''", is_nullable => 1 }, "open_hour", { data_type => "time", is_nullable => 0 }, "close_hour", @@ -103,8 +111,8 @@ __PACKAGE__->add_columns( __PACKAGE__->set_primary_key("branchcode", "date"); -# Created by DBIx::Class::Schema::Loader v0.07045 @ 2017-04-19 10:07:41 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:wtctW8ZzCkyCZFZmmavFEw +# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-10-20 11:37:37 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:/w9T8ShNcZsKRpeGaePHoA # You can replace this text with custom code or comments, and it will be preserved on regeneration diff --git a/installer/data/mysql/atomicupdate/bug_17015_part1_create_discrete_calendar.perl b/installer/data/mysql/atomicupdate/bug_17015_part1_create_discrete_calendar.perl index 0e5d16ed65..f276da11a3 100644 --- a/installer/data/mysql/atomicupdate/bug_17015_part1_create_discrete_calendar.perl +++ b/installer/data/mysql/atomicupdate/bug_17015_part1_create_discrete_calendar.perl @@ -8,6 +8,7 @@ if( CheckVersion( $DBversion ) ) { `is_opened` tinyint(1) DEFAULT 1, `holiday_type` varchar(1) DEFAULT '', `note` varchar(30) DEFAULT '', + `description` mediumtext DEFAULT '', `open_hour` time NOT NULL, `close_hour` time NOT NULL, PRIMARY KEY (`branchcode`,`date`) diff --git a/installer/data/mysql/atomicupdate/bug_17015_part4_add_description.perl b/installer/data/mysql/atomicupdate/bug_17015_part4_add_description.perl new file mode 100644 index 0000000000..89b0516c67 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_17015_part4_add_description.perl @@ -0,0 +1,8 @@ +$DBversion = 'XXX'; +if( CheckVersion( $DBversion ) ) { + if ( !column_exists( 'discrete_calendar', 'description' ) ) { + $dbh->do( "ALTER TABLE `discrete_calendar` ADD COLUMN `description` mediumtext default '' AFTER `note`;" ); + } + + NewVersion( $DBversion, 17015, "New koha calendar Part 4 - Add description field"); +} diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/discrete_calendar.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/discrete_calendar.tt index 636578b78f..75acc57204 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/discrete_calendar.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/discrete_calendar.tt @@ -116,6 +116,10 @@ +
  • + + +