Line 0
Link Here
|
|
|
1 |
use Modern::Perl; |
2 |
use Koha::Installer::Output qw(say_warning say_success say_info); |
3 |
|
4 |
return { |
5 |
bug_number => "41029", |
6 |
description => "Add 'add_to_basket' source option for MARC overlay rules", |
7 |
up => sub { |
8 |
my ($args) = @_; |
9 |
my ( $dbh, $out ) = @$args{qw(dbh out)}; |
10 |
|
11 |
my $existing_batchimport_rules_count = ( |
12 |
$dbh->selectrow_array( |
13 |
'SELECT COUNT(*) FROM marc_overlay_rules WHERE module="source" and filter="batchimport"', undef |
14 |
) |
15 |
)[0]; |
16 |
my $existing_add_to_basket_rules_count = ( |
17 |
$dbh->selectrow_array( |
18 |
'SELECT COUNT(*) FROM marc_overlay_rules WHERE module="source" and filter="add_to_basket"', undef |
19 |
) |
20 |
)[0]; |
21 |
if ( $existing_batchimport_rules_count > 0 && $existing_add_to_basket_rules_count == 0 ) { |
22 |
say_info( $out, "Existing batchimport marc_overlay_rules found and no add_to_basket rules found" ); |
23 |
$dbh->do( |
24 |
q{ |
25 |
INSERT INTO marc_overlay_rules (`tag`, `module`, `filter`, `add`, `append`, `remove`, `delete`) |
26 |
SELECT `tag`, `module`, "add_to_basket", `add`, `append`, `remove`, `delete` |
27 |
FROM marc_overlay_rules |
28 |
WHERE module = 'source' AND filter = 'batchimport' |
29 |
} |
30 |
); |
31 |
say $out "Added existing batchimport overlay rules as add_to_basket rules"; |
32 |
} else { |
33 |
say_info( |
34 |
$out, |
35 |
"No existing batchimport marc_overlay_rules found or existing add_to_basket rules found, not updating" |
36 |
); |
37 |
} |
38 |
|
39 |
}, |
40 |
}; |