|
Line 0
Link Here
|
| 0 |
- |
1 |
use Modern::Perl; |
|
|
2 |
|
| 3 |
return { |
| 4 |
bug_number => "25393", |
| 5 |
description => "Create separate 'no automatic renewal before' rule", |
| 6 |
up => sub { |
| 7 |
my ($args) = @_; |
| 8 |
my ( $dbh, $out ) = @$args{qw(dbh out)}; |
| 9 |
|
| 10 |
my $rules = $dbh->selectall_arrayref( |
| 11 |
q|SELECT * FROM circulation_rules WHERE rule_name = "noautorenewalbefore"|, |
| 12 |
{ Slice => {} } |
| 13 |
); |
| 14 |
|
| 15 |
if(!scalar @{$rules}){ |
| 16 |
my $existing_rules = $dbh->selectall_arrayref( |
| 17 |
q|SELECT * FROM circulation_rules WHERE rule_name = "norenewalbefore"|, |
| 18 |
{ Slice => {} } |
| 19 |
); |
| 20 |
|
| 21 |
my $insert_sth = $dbh->prepare( |
| 22 |
q{INSERT INTO circulation_rules ( branchcode, categorycode, itemtype, rule_name, rule_value ) VALUES (?, ?, ?, ?, ?)} |
| 23 |
); |
| 24 |
|
| 25 |
for my $existing_rule ( @{$existing_rules} ) { |
| 26 |
$insert_sth->execute( |
| 27 |
$existing_rule->{branchcode}, |
| 28 |
$existing_rule->{categorycode}, |
| 29 |
$existing_rule->{itemtype}, |
| 30 |
'noautorenewalbefore', |
| 31 |
$existing_rule->{rule_value} |
| 32 |
); |
| 33 |
} |
| 34 |
say $out "Bug 25939: New circulation rule 'noautorenewalbefore' has been added. Defaulting value to 'norenewalbefore'."; |
| 35 |
}else{ |
| 36 |
say $out "Bug 25939: Circulation rule 'noautorenewalbefore' found. Skipping update."; |
| 37 |
} |
| 38 |
|
| 39 |
}, |
| 40 |
}; |