Bug 27947: (follow-up) Add OPAC cancellation as new reason too
[koha.git] / installer / data / mysql / atomicupdate / bug_27947.pl
1 use Modern::Perl;
2
3 return {
4     bug_number => "27947",
5     description => "Add authorised values list in article requests cancellation",
6     up => sub {
7         my ($args) = @_;
8         my ($dbh, $out) = @$args{qw(dbh out column_exists)};
9         $dbh->do(q{
10             INSERT IGNORE INTO authorised_value_categories( category_name, is_system )
11             VALUES ('AR_CANCELLATION', 0)
12         });
13         say $out "Add AR_CANCELLATION category for authorised values";
14
15         $dbh->do(q{
16             INSERT IGNORE INTO authorised_values (category, authorised_value, lib) VALUES
17                 ('AR_CANCELLATION','NOT_FOUND','Item could not be located on shelves'),
18                 ('AR_CANCELLATION','DAMAGED','Item was found to be too damaged to fill article request'),
19                 ('AR_CANCELLATION','OPAC','Cancelled from the OPAC user page')
20         });
21         say $out "Add AR_CANCELLATION authorised values";
22
23         $dbh->do(q{
24             ALTER TABLE `article_requests` ADD COLUMN `cancellation_reason` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'optional authorised value AR_CANCELLATION' AFTER `urls`
25         }) unless column_exists('article_requests', 'cancellation_reason');
26         say $out "Add cancellation_reason column in article_requests table";
27
28         $dbh->do(q{
29             UPDATE letter SET content=REPLACE(content, '<<article_requests.notes>>', '<<reason>>')
30             WHERE module = 'circulation' AND code = 'AR_CANCELED'
31         });
32         say $out "Replace notes by reason in notice AR_CANCELED";
33     },
34 }