use Koha::RefundLostItemFeeRule;
use Koha::RefundLostItemFeeRules;
use Koha::Libraries;
+use Koha::CirculationRules;
use Koha::Patron::Categories;
+use Koha::Caches;
my $input = CGI->new;
my $dbh = C4::Context->dbh;
my $op = $input->param('op') || q{};
my $language = C4::Languages::getlanguage();
+my $cache = Koha::Caches->get_instance;
+$cache->clear_from_cache( Koha::IssuingRules::GUESSED_ITEMTYPES_KEY );
+
if ($op eq 'delete') {
my $itemtype = $input->param('itemtype');
my $categorycode = $input->param('categorycode');
AND categorycode = ?");
$sth_delete->execute($branch, $categorycode);
}
+ Koha::CirculationRules->set_rule(
+ {
+ branchcode => $branch,
+ categorycode => $categorycode,
+ itemtype => undef,
+ rule_name => 'max_holds',
+ rule_value => undef,
+ }
+ );
}
elsif ($op eq 'delete-branch-item') {
my $itemtype = $input->param('itemtype');
my $finedays = $input->param('finedays');
my $maxsuspensiondays = $input->param('maxsuspensiondays');
$maxsuspensiondays = undef if $maxsuspensiondays eq q||;
+ my $suspension_chargeperiod = $input->param('suspension_chargeperiod') || 1;
my $firstremind = $input->param('firstremind');
my $chargeperiod = $input->param('chargeperiod');
my $chargeperiod_charge_at = $input->param('chargeperiod_charge_at');
fine => $fine,
finedays => $finedays,
maxsuspensiondays => $maxsuspensiondays,
+ suspension_chargeperiod => $suspension_chargeperiod,
firstremind => $firstremind,
chargeperiod => $chargeperiod,
chargeperiod_charge_at => $chargeperiod_charge_at,
my $categorycode = $input->param('categorycode');
my $maxissueqty = $input->param('maxissueqty');
my $maxonsiteissueqty = $input->param('maxonsiteissueqty');
+ my $max_holds = $input->param('max_holds');
$maxissueqty =~ s/\s//g;
$maxissueqty = undef if $maxissueqty !~ /^\d+/;
$maxonsiteissueqty =~ s/\s//g;
$maxonsiteissueqty = undef if $maxonsiteissueqty !~ /^\d+/;
+ $max_holds =~ s/\s//g;
+ $max_holds = undef if $max_holds !~ /^\d+/;
if ($branch eq "*") {
if ($categorycode eq "*") {
FROM default_circ_rules");
my $sth_insert = $dbh->prepare(q|
INSERT INTO default_circ_rules
- (maxissueqty, maxonsiteissueqty)
- VALUES (?, ?)
+ (maxissueqty, maxonsiteissueqty, max_holds)
+ VALUES (?, ?, ?)
|);
my $sth_update = $dbh->prepare(q|
UPDATE default_circ_rules
SET maxissueqty = ?,
- maxonsiteissueqty = ?
+ maxonsiteissueqty = ?,
+ max_holds = ?
|);
$sth_search->execute();
my $res = $sth_search->fetchrow_hashref();
if ($res->{total}) {
- $sth_update->execute($maxissueqty, $maxonsiteissueqty);
+ $sth_update->execute( $maxissueqty, $maxonsiteissueqty );
} else {
- $sth_insert->execute($maxissueqty, $maxonsiteissueqty);
+ $sth_insert->execute( $maxissueqty, $maxonsiteissueqty );
}
+
+ Koha::CirculationRules->set_rule(
+ {
+ branchcode => undef,
+ categorycode => undef,
+ itemtype => undef,
+ rule_name => 'max_holds',
+ rule_value => $max_holds,
+ }
+ );
} else {
my $sth_search = $dbh->prepare("SELECT count(*) AS total
FROM default_borrower_circ_rules
WHERE categorycode = ?");
my $sth_insert = $dbh->prepare(q|
INSERT INTO default_borrower_circ_rules
- (categorycode, maxissueqty, maxonsiteissueqty)
- VALUES (?, ?, ?)
+ (categorycode, maxissueqty, maxonsiteissueqty, max_holds)
+ VALUES (?, ?, ?, ?)
|);
my $sth_update = $dbh->prepare(q|
UPDATE default_borrower_circ_rules
SET maxissueqty = ?,
- maxonsiteissueqty = ?
+ maxonsiteissueqty = ?,
+ max_holds = ?
WHERE categorycode = ?
|);
$sth_search->execute($categorycode);
my $res = $sth_search->fetchrow_hashref();
if ($res->{total}) {
- $sth_update->execute($maxissueqty, $maxonsiteissueqty, $categorycode);
+ $sth_update->execute( $maxissueqty, $maxonsiteissueqty, $categorycode );
} else {
- $sth_insert->execute($categorycode, $maxissueqty, $maxonsiteissueqty);
+ $sth_insert->execute( $categorycode, $maxissueqty, $maxonsiteissueqty );
}
+
+ Koha::CirculationRules->set_rule(
+ {
+ branchcode => undef,
+ categorycode => $categorycode,
+ itemtype => undef,
+ rule_name => 'max_holds',
+ rule_value => $max_holds,
+ }
+ );
}
} elsif ($categorycode eq "*") {
my $sth_search = $dbh->prepare("SELECT count(*) AS total
AND categorycode = ?");
my $sth_insert = $dbh->prepare(q|
INSERT INTO branch_borrower_circ_rules
- (branchcode, categorycode, maxissueqty, maxonsiteissueqty)
- VALUES (?, ?, ?, ?)
+ (branchcode, categorycode, maxissueqty, maxonsiteissueqty, max_holds)
+ VALUES (?, ?, ?, ?, ?)
|);
my $sth_update = $dbh->prepare(q|
UPDATE branch_borrower_circ_rules
SET maxissueqty = ?,
maxonsiteissueqty = ?
+ max_holds = ?
WHERE branchcode = ?
AND categorycode = ?
|);
$sth_search->execute($branch, $categorycode);
my $res = $sth_search->fetchrow_hashref();
if ($res->{total}) {
- $sth_update->execute($maxissueqty, $maxonsiteissueqty, $branch, $categorycode);
+ $sth_update->execute($maxissueqty, $maxonsiteissueqty, $max_holds, $branch, $categorycode);
} else {
- $sth_insert->execute($branch, $categorycode, $maxissueqty, $maxonsiteissueqty);
+ $sth_insert->execute($branch, $categorycode, $maxissueqty, $maxonsiteissueqty, $max_holds);
}
+
+ Koha::CirculationRules->set_rule(
+ {
+ branchcode => $branch,
+ categorycode => $categorycode,
+ itemtype => undef,
+ rule_name => 'max_holds',
+ rule_value => $max_holds,
+ }
+ );
}
}
elsif ($op eq "add-branch-item") {
foreach my $entry (@sorted_branch_cat_rules, @sorted_row_loop) {
$entry->{unlimited_maxissueqty} = 1 unless defined($entry->{maxissueqty});
$entry->{unlimited_maxonsiteissueqty} = 1 unless defined($entry->{maxonsiteissueqty});
+ $entry->{unlimited_max_holds} = 1 unless defined($entry->{max_holds});
}
@sorted_row_loop = sort by_category_and_itemtype @row_loop;