From f1c6cd61889e55064ef2592b2933e038478d3b43 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 19 Dec 2014 06:27:27 -0500 Subject: [PATCH] [PASSED QA] Bug 5786 [QA Followup] Signed-off-by: Kyle M Hall --- C4/Reserves.pm | 2 +- Koha/Schema/Result/Issuingrule.pm | 21 +++++++++++++- admin/smart-rules.pl | 53 ++++++++++++++++++++++++++++--------- opac/opac-detail.pl | 2 +- 4 files changed, 61 insertions(+), 17 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 8006309..3c2ee77 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -1551,7 +1551,7 @@ sub IsAvailableForItemLevelRequest { $notforloan_per_itemtype || $item->{itemlost} || $item->{notforloan} > 0 || - $item->{wthdrawn} || + $item->{withdrawn} || ($item->{damaged} && !C4::Context->preference('AllowHoldsOnDamagedItems')); diff --git a/Koha/Schema/Result/Issuingrule.pm b/Koha/Schema/Result/Issuingrule.pm index a8cf014..438c23b 100644 --- a/Koha/Schema/Result/Issuingrule.pm +++ b/Koha/Schema/Result/Issuingrule.pm @@ -161,6 +161,19 @@ __PACKAGE__->table("issuingrules"); is_nullable: 1 size: [28,6] +=head2 onshelfholds + + data_type: 'tinyint' + default_value: 0 + is_nullable: 0 + +=head2 opacitemholds + + data_type: 'char' + default_value: 'N' + is_nullable: 0 + size: 1 + =cut __PACKAGE__->add_columns( @@ -217,6 +230,10 @@ __PACKAGE__->add_columns( { data_type => "varchar", default_value => "", is_nullable => 0, size => 10 }, "overduefinescap", { data_type => "decimal", is_nullable => 1, size => [28, 6] }, + "onshelfholds", + { data_type => "tinyint", default_value => 0, is_nullable => 0 }, + "opacitemholds", + { data_type => "char", default_value => "N", is_nullable => 0, size => 1 }, ); =head1 PRIMARY KEY @@ -236,8 +253,8 @@ __PACKAGE__->add_columns( __PACKAGE__->set_primary_key("branchcode", "categorycode", "itemtype"); -# Created by DBIx::Class::Schema::Loader v0.07039 @ 2014-09-17 21:06:58 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:vmlv13CeQ99RO0VsviRABg +# Created by DBIx::Class::Schema::Loader v0.07040 @ 2014-12-19 07:00:40 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:CE8yuYC5QgPHI2GOjiT28w # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/admin/smart-rules.pl b/admin/smart-rules.pl index 4ab349f..f73436f 100755 --- a/admin/smart-rules.pl +++ b/admin/smart-rules.pl @@ -27,6 +27,7 @@ use C4::Koha; use C4::Debug; use C4::Branch; # GetBranches use C4::Dates qw/format_date format_date_in_iso/; +use Koha::Database; my $input = CGI->new; my $dbh = C4::Context->dbh; @@ -100,10 +101,6 @@ 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, norenewalbefore, auto_renew, reservesallowed, issuelength, lengthunit, hardduedate, hardduedatecompare, fine, finedays, maxsuspensiondays, firstremind, chargeperiod,rentaldiscount, onshelfholds, opacitemholds, overduefinescap) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)'); - my $sth_update=$dbh->prepare("UPDATE issuingrules SET fine=?, finedays=?, maxsuspensiondays=?, firstremind=?, chargeperiod=?, maxissueqty=?, renewalsallowed=?, renewalperiod=?, norenewalbefore=?, auto_renew=?, reservesallowed=?, issuelength=?, lengthunit=?, hardduedate=?, hardduedatecompare=?, rentaldiscount=?, onshelfholds=?, opacitemholds=?, overduefinescap=? WHERE branchcode=? AND categorycode=? AND itemtype=?"); - my $br = $branch; # branch my $bor = $input->param('categorycode'); # borrower category my $itemtype = $input->param('itemtype'); # item type @@ -133,14 +130,44 @@ elsif ($op eq 'add') { my $overduefinescap = $input->param('overduefinescap') || undef; $debug and warn "Adding $br, $bor, $itemtype, $fine, $maxissueqty"; - $sth_search->execute($br,$bor,$itemtype); - my $res = $sth_search->fetchrow_hashref(); - if ($res->{total}) { - $sth_update->execute($fine, $finedays, $maxsuspensiondays, $firstremind, $chargeperiod, $maxissueqty, $renewalsallowed, $renewalperiod, $norenewalbefore, $auto_renew, $reservesallowed, $issuelength,$lengthunit, $hardduedate,$hardduedatecompare,$rentaldiscount, $onshelfholds, $opacitemholds, $overduefinescap, $br,$bor,$itemtype); - } else { - $sth_insert->execute($br,$bor,$itemtype,$maxissueqty,$renewalsallowed, $renewalperiod, $norenewalbefore, $auto_renew, $reservesallowed,$issuelength,$lengthunit,$hardduedate,$hardduedatecompare,$fine,$finedays, $maxsuspensiondays, $firstremind,$chargeperiod,$rentaldiscount,$onshelfholds,$opacitemholds,$overduefinescap); + my $schema = Koha::Database->new()->schema(); + my $rs = $schema->resultset('Issuingrule'); + + my $params = { + fine => $fine, + finedays => $finedays, + maxsuspensiondays => $maxsuspensiondays, + firstremind => $firstremind, + chargeperiod => $chargeperiod, + maxissueqty => $maxissueqty, + renewalsallowed => $renewalsallowed, + renewalperiod => $renewalperiod, + norenewalbefore => $norenewalbefore, + auto_renew => $auto_renew, + reservesallowed => $reservesallowed, + issuelength => $issuelength, + lengthunit => $lengthunit, + hardduedate => $hardduedate, + hardduedatecompare => $hardduedatecompare, + rentaldiscount => $rentaldiscount, + onshelfholds => $onshelfholds, + opacitemholds => $opacitemholds, + overduefinescap => $overduefinescap, + }; + + my $rule = $rs->single( { branchcode => $br, categorycode => $bor, itemtype => $itemtype } ); + + if ($rule) { + $rule->update($params); + } + else { + $params->{branchcode} = $br; + $params->{categorycode} = $bor; + $params->{itemtype} = $itemtype; + $rs->create( $params ); } -} + +} elsif ($op eq "set-branch-defaults") { my $categorycode = $input->param('categorycode'); my $maxissueqty = $input->param('maxissueqty'); @@ -413,7 +440,7 @@ if ($branch eq "*") { SELECT default_borrower_circ_rules.*, categories.description AS humancategorycode FROM default_borrower_circ_rules JOIN categories USING (categorycode) - + "); $sth_branch_cat->execute(); } else { @@ -507,7 +534,7 @@ $template->param(categoryloop => \@category_loop, branchloop => \@branchloop, humanbranch => ($branch ne '*' ? $branches->{$branch}->{branchname} : ''), current_branch => $branch, - definedbranch => scalar(@sorted_row_loop)>0 + definedbranch => scalar(@sorted_row_loop)>0 ); output_html_with_http_headers $input, $cookie, $template->output; diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index 55fb621..75b7f26 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -635,7 +635,7 @@ if ( not $viewallitems and @items > $max_items_to_display ) { && !$itemtypes->{$itm->{'itype'}}->{notforloan} && $itm->{'itemnumber'}; - $allow_onshelf_holds = C4::Reserves::OnShelfHoldsAllowed($itm, $borrower) + $allow_onshelf_holds = C4::Reserves::OnShelfHoldsAllowed( $itm, $borrower ) unless $allow_onshelf_holds; # get collection code description, too -- 1.7.2.5