@@ -, +, @@ that weren't saved to the database - issuelength - hardduedate - unseenrenewalsallowed - rentaldiscount - decreaseloanholds Patron category: Teacher Itemtype: All Hard due date: (Today) Lona period: 10 Patron category: Teacher Itemtype: Books Hard due date: (leave blank) Loan period: 10 --- admin/smart-rules.pl | 10 +++--- .../data/mysql/atomicupdate/bug_29012.pl | 33 +++++++++++++++++++ 2 files changed, 38 insertions(+), 5 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug_29012.pl --- a/admin/smart-rules.pl +++ a/admin/smart-rules.pl @@ -258,7 +258,7 @@ elsif ($op eq 'add') { my $maxissueqty = strip_non_numeric( scalar $input->param('maxissueqty') ); my $maxonsiteissueqty = strip_non_numeric( scalar $input->param('maxonsiteissueqty') ); my $renewalsallowed = $input->param('renewalsallowed'); - my $unseen_renewals_allowed = $input->param('unseen_renewals_allowed'); + my $unseen_renewals_allowed = $input->param('unseen_renewals_allowed') || 0; my $renewalperiod = $input->param('renewalperiod'); my $norenewalbefore = $input->param('norenewalbefore'); $norenewalbefore = '' if $norenewalbefore =~ /^\s*$/; @@ -272,21 +272,21 @@ elsif ($op eq 'add') { my $holds_per_record = strip_non_numeric( scalar $input->param('holds_per_record') ); my $holds_per_day = strip_non_numeric( scalar $input->param('holds_per_day') ); my $onshelfholds = $input->param('onshelfholds') || 0; - my $issuelength = $input->param('issuelength'); + my $issuelength = $input->param('issuelength') || 0; $issuelength = $issuelength eq q{} ? undef : $issuelength; my $daysmode = $input->param('daysmode'); my $lengthunit = $input->param('lengthunit'); - my $hardduedate = $input->param('hardduedate') || undef; + my $hardduedate = $input->param('hardduedate') || ''; $hardduedate = eval { dt_from_string( scalar $hardduedate ) } if ( $hardduedate ); $hardduedate = output_pref( { dt => $hardduedate, dateonly => 1, dateformat => 'iso' } ) if ( $hardduedate ); my $hardduedatecompare = $input->param('hardduedatecompare'); - my $rentaldiscount = $input->param('rentaldiscount'); + my $rentaldiscount = $input->param('rentaldiscount') || 0; my $opacitemholds = $input->param('opacitemholds') || 0; my $article_requests = $input->param('article_requests') || 'no'; my $overduefinescap = $input->param('overduefinescap') || ''; my $cap_fine_to_replacement_price = ($input->param('cap_fine_to_replacement_price') || '') eq 'on'; my $note = $input->param('note'); - my $decreaseloanholds = $input->param('decreaseloanholds') || undef; + my $decreaseloanholds = $input->param('decreaseloanholds') || ''; my $rules = { maxissueqty => $maxissueqty, --- a/installer/data/mysql/atomicupdate/bug_29012.pl +++ a/installer/data/mysql/atomicupdate/bug_29012.pl @@ -0,0 +1,33 @@ +use Modern::Perl; + +return { + bug_number => "29012", + description => "Some rules are not saved when left blank while editing a 'rule' line in smart-rules.pl", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + my %default_rule_values = ( + issuelength => 0, + hardduedate => '', + unseenrenewalsallowed => 0, + rentaldiscount => 0, + decreaseloanholds => '', + ); + while (my ($rule_name, $rule_value) = each (%default_rule_values)) { + $dbh->do(q{ + INSERT IGNORE INTO circulation_rules (branchcode, categorycode, itemtype, rule_name, rule_value) + SELECT branchcode, categorycode, itemtype, ?, ? FROM circulation_rules cr + WHERE NOT EXISTS ( + SELECT * FROM circulation_rules cr2 + WHERE + cr2.rule_name=? + AND ( (cr2.branchcode=cr.branchcode) OR ( ISNULL(cr2.branchcode) AND ISNULL(cr.branchcode) ) ) + AND ( (cr2.categorycode=cr.categorycode) OR ( ISNULL(cr2.categorycode) AND ISNULL(cr.categorycode) ) ) + AND ( (cr2.itemtype=cr.itemtype) OR ( ISNULL(cr2.itemtype) AND ISNULL(cr.itemtype) ) ) + ) + GROUP BY branchcode, categorycode, itemtype + }, undef, $rule_name, $rule_value, $rule_name); + } + say $out "Add default values for blank circulation rules that weren't saved to the database"; + }, +} --