X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=admin%2Fsmart-rules.pl;h=5b19313da5cec452f91007d1a319df7291c22dec;hb=8cc5b3452eb9b5d06505192a5cabdcd1bb28a084;hp=3c77f9389315b7f3b9278076b775b5be2f9b83e7;hpb=fb4aec265f4790f6db7139419282f784e5bdd8bf;p=koha.git diff --git a/admin/smart-rules.pl b/admin/smart-rules.pl index 3c77f93893..5b19313da5 100755 --- a/admin/smart-rules.pl +++ b/admin/smart-rules.pl @@ -100,9 +100,9 @@ elsif ($op eq 'delete-branch-item') { } # save the values entered elsif ($op eq 'add') { - my $sth_search = $dbh->prepare("SELECT COUNT(*) AS total FROM issuingrules WHERE branchcode=? AND categorycode=? AND itemtype=?"); - my $sth_insert = $dbh->prepare("INSERT INTO issuingrules (branchcode, categorycode, itemtype, maxissueqty, renewalsallowed, reservesallowed, issuelength, hardduedate, hardduedatecompare, fine, finedays, firstremind, chargeperiod,rentaldiscount) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); - my $sth_update=$dbh->prepare("UPDATE issuingrules SET fine=?, finedays=?, firstremind=?, chargeperiod=?, maxissueqty=?, renewalsallowed=?, reservesallowed=?, issuelength=?, hardduedate=?, hardduedatecompare=?, rentaldiscount=? WHERE branchcode=? AND categorycode=? AND itemtype=?"); + my $sth_search = $dbh->prepare('SELECT COUNT(*) AS total FROM issuingrules WHERE branchcode=? AND categorycode=? AND itemtype=?'); + my $sth_insert = $dbh->prepare('INSERT INTO issuingrules (branchcode, categorycode, itemtype, maxissueqty, renewalsallowed, reservesallowed, issuelength, lengthunit, hardduedate, hardduedatecompare, fine, finedays, firstremind, chargeperiod,rentaldiscount) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)'); + my $sth_update=$dbh->prepare("UPDATE issuingrules SET fine=?, finedays=?, firstremind=?, chargeperiod=?, maxissueqty=?, renewalsallowed=?, reservesallowed=?, issuelength=?, lengthunit = ?, hardduedate=?, hardduedatecompare=?, rentaldiscount=? WHERE branchcode=? AND categorycode=? AND itemtype=?"); my $br = $branch; # branch my $bor = $input->param('categorycode'); # borrower category @@ -117,6 +117,7 @@ elsif ($op eq 'add') { $maxissueqty =~ s/\s//g; $maxissueqty = undef if $maxissueqty !~ /^\d+/; my $issuelength = $input->param('issuelength'); + my $lengthunit = $input->param('lengthunit'); my $hardduedate = $input->param('hardduedate'); $hardduedate = format_date_in_iso($hardduedate); my $hardduedatecompare = $input->param('hardduedatecompare'); @@ -126,9 +127,9 @@ elsif ($op eq 'add') { $sth_search->execute($br,$bor,$cat); my $res = $sth_search->fetchrow_hashref(); if ($res->{total}) { - $sth_update->execute($fine, $finedays,$firstremind, $chargeperiod, $maxissueqty, $renewalsallowed,$reservesallowed, $issuelength,$hardduedate,$hardduedatecompare,$rentaldiscount, $br,$bor,$cat); + $sth_update->execute($fine, $finedays,$firstremind, $chargeperiod, $maxissueqty, $renewalsallowed,$reservesallowed, $issuelength,$lengthunit, $hardduedate,$hardduedatecompare,$rentaldiscount, $br,$bor,$cat); } else { - $sth_insert->execute($br,$bor,$cat,$maxissueqty,$renewalsallowed,$reservesallowed,$issuelength,$hardduedate,$hardduedatecompare,$fine,$finedays,$firstremind,$chargeperiod,$rentaldiscount); + $sth_insert->execute($br,$bor,$cat,$maxissueqty,$renewalsallowed,$reservesallowed,$issuelength,$lengthunit,$hardduedate,$hardduedatecompare,$fine,$finedays,$firstremind,$chargeperiod,$rentaldiscount); } } elsif ($op eq "set-branch-defaults") { @@ -339,12 +340,11 @@ elsif ($op eq "add-branch-item") { my $branches = GetBranches(); my @branchloop; for my $thisbranch (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %$branches) { - my $selected = 1 if $thisbranch eq $branch; - my %row =(value => $thisbranch, - selected => $selected, - branchname => $branches->{$thisbranch}->{'branchname'}, - ); - push @branchloop, \%row; + push @branchloop, { + value => $thisbranch, + selected => $thisbranch eq $branch, + branchname => $branches->{$thisbranch}->{'branchname'}, + }; } my $sth=$dbh->prepare("SELECT description,categorycode FROM categories ORDER BY description"); @@ -376,6 +376,7 @@ my $sth2 = $dbh->prepare(" $sth2->execute($branch); while (my $row = $sth2->fetchrow_hashref) { + $row->{'current_branch'} ||= $row->{'branchcode'}; $row->{'humanitemtype'} ||= $row->{'itemtype'}; $row->{'default_humanitemtype'} = 1 if $row->{'humanitemtype'} eq '*'; $row->{'humancategorycode'} ||= $row->{'categorycode'}; @@ -425,7 +426,7 @@ foreach my $entry (@sorted_branch_cat_rules, @sorted_row_loop) { $entry->{unlimited_maxissueqty} = 1 unless defined($entry->{maxissueqty}); } -my @sorted_row_loop = sort by_category_and_itemtype @row_loop; +@sorted_row_loop = sort by_category_and_itemtype @row_loop; my $sth_branch_item; if ($branch eq "*") {