use Modern::Perl;
use CGI qw ( -utf8 );
use C4::Context;
-use C4::Output;
-use C4::Auth;
-use C4::Koha;
-use C4::Debug;
-use Koha::DateUtils;
+use C4::Output qw( output_html_with_http_headers );
+use C4::Auth qw( get_template_and_user );
+use Koha::Exception;
+use Koha::DateUtils qw( dt_from_string output_pref );
use Koha::Database;
use Koha::Logger;
use Koha::Libraries;
query => $input,
type => "intranet",
flagsrequired => {parameters => 'manage_circ_rules'},
- debug => 1,
});
my $type=$input->param('type');
if ($op eq 'delete') {
my $itemtype = $input->param('itemtype');
my $categorycode = $input->param('categorycode');
- $debug and warn "deleting $1 $2 $branch";
Koha::CirculationRules->set_rules(
{
hardduedate => undef,
hardduedatecompare => undef,
renewalsallowed => undef,
+ unseen_renewals_allowed => undef,
renewalperiod => undef,
norenewalbefore => undef,
auto_renew => undef,
cap_fine_to_replacement_price => undef,
article_requests => undef,
note => undef,
+ recalls_allowed => undef,
+ recalls_per_record => undef,
+ on_shelf_recalls => undef,
+ recall_due_date_interval => undef,
+ recall_overdue_fine => undef,
+ recall_shelf_time => undef,
}
}
);
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 $renewalperiod = $input->param('renewalperiod');
my $norenewalbefore = $input->param('norenewalbefore');
$norenewalbefore = '' if $norenewalbefore =~ /^\s*$/;
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');
- $debug and warn "Adding $br, $bor, $itemtype, $fine, $maxissueqty, $maxonsiteissueqty, $cap_fine_to_replacement_price";
+ my $decreaseloanholds = $input->param('decreaseloanholds') || undef;
+ my $recalls_allowed = $input->param('recalls_allowed');
+ my $recalls_per_record = $input->param('recalls_per_record');
+ my $on_shelf_recalls = $input->param('on_shelf_recalls');
+ my $recall_due_date_interval = $input->param('recall_due_date_interval');
+ my $recall_overdue_fine = $input->param('recall_overdue_fine');
+ my $recall_shelf_time = $input->param('recall_shelf_time');
my $rules = {
maxissueqty => $maxissueqty,
hardduedate => $hardduedate,
hardduedatecompare => $hardduedatecompare,
renewalsallowed => $renewalsallowed,
+ unseen_renewals_allowed => $unseen_renewals_allowed,
renewalperiod => $renewalperiod,
norenewalbefore => $norenewalbefore,
auto_renew => $auto_renew,
cap_fine_to_replacement_price => $cap_fine_to_replacement_price,
article_requests => $article_requests,
note => $note,
+ decreaseloanholds => $decreaseloanholds,
+ recalls_allowed => $recalls_allowed,
+ recalls_per_record => $recalls_per_record,
+ on_shelf_recalls => $on_shelf_recalls,
+ recall_due_date_interval => $recall_due_date_interval,
+ recall_overdue_fine => $recall_overdue_fine,
+ recall_shelf_time => $recall_shelf_time,
};
Koha::CirculationRules->set_rules(
);
}
}
+elsif ( $op eq "add-open-article-requests-limit" ) {
+ my $categorycode = $input->param('categorycode');
+ my $open_article_requests_limit = strip_non_numeric( scalar $input->param('open_article_requests_limit') );
+
+ Koha::Exception->throw("No value passed for article request limit")
+ if not defined $open_article_requests_limit # There is a JS check for that
+ || $open_article_requests_limit eq '';
+
+ if ( $branch eq "*" ) {
+ if ( $categorycode eq "*" ) {
+ Koha::CirculationRules->set_rules(
+ { categorycode => undef,
+ branchcode => undef,
+ rules => { open_article_requests_limit => $open_article_requests_limit, }
+ }
+ );
+ } else {
+ Koha::CirculationRules->set_rules(
+ { categorycode => $categorycode,
+ branchcode => undef,
+ rules => { open_article_requests_limit => $open_article_requests_limit, }
+ }
+ );
+ }
+ } elsif ( $categorycode eq "*" ) {
+ Koha::CirculationRules->set_rules(
+ { categorycode => undef,
+ branchcode => $branch,
+ rules => { open_article_requests_limit => $open_article_requests_limit, }
+ }
+ );
+ } else {
+ Koha::CirculationRules->set_rules(
+ { categorycode => $categorycode,
+ branchcode => $branch,
+ rules => { open_article_requests_limit => $open_article_requests_limit, }
+ }
+ );
+ }
+} elsif ( $op eq 'del-open-article-requests-limit' ) {
+ my $categorycode = $input->param('categorycode');
+ if ( $branch eq "*" ) {
+ if ( $categorycode eq "*" ) {
+ Koha::CirculationRules->set_rules(
+ { branchcode => undef,
+ categorycode => undef,
+ rules => { open_article_requests_limit => undef, }
+ }
+ );
+ } else {
+ Koha::CirculationRules->set_rules(
+ { categorycode => $categorycode,
+ branchcode => undef,
+ rules => { open_article_requests_limit => undef, }
+ }
+ );
+ }
+ } elsif ( $categorycode eq "*" ) {
+ Koha::CirculationRules->set_rules(
+ { branchcode => $branch,
+ categorycode => undef,
+ rules => { open_article_requests_limit => undef, }
+ }
+ );
+ } else {
+ Koha::CirculationRules->set_rules(
+ { categorycode => $categorycode,
+ branchcode => $branch,
+ rules => { open_article_requests_limit => undef, }
+ }
+ );
+ }
+}
+elsif ( $op eq "set-article-request-fee" ) {
+
+ my $category = $input->param('article_request_fee_category');
+ my $fee = strip_non_numeric( scalar $input->param('article_request_fee') );
+
+ Koha::Exception->throw("No value passed for article request fee")
+ if not defined $fee # There is a JS check for that
+ || $fee eq '';
+
+ Koha::CirculationRules->set_rules(
+ { categorycode => ( $category eq '*' ) ? undef : $category,
+ branchcode => ( $branch eq '*' ) ? undef : $branch,
+ rules => { article_request_fee => $fee },
+ }
+ );
+
+} elsif ( $op eq 'del-article-request-fee' ) {
+
+ my $category = $input->param('article_request_fee_category');
+
+ Koha::CirculationRules->set_rules(
+ { categorycode => ( $category eq '*' ) ? undef : $category,
+ branchcode => ( $branch eq '*' ) ? undef : $branch,
+ rules => { article_request_fee => undef },
+ }
+ );
+}
elsif ($op eq "add-branch-item") {
my $itemtype = $input->param('itemtype');
my $holdallowed = $input->param('holdallowed');
my $hold_fulfillment_policy = $input->param('hold_fulfillment_policy');
my $returnbranch = $input->param('returnbranch');
- $holdallowed =~ s/\s//g;
- $holdallowed = undef if $holdallowed !~ /^\d+/;
-
if ($branch eq "*") {
if ($itemtype eq "*") {
Koha::CirculationRules->set_rules(
}
elsif ( $op eq 'mod-refund-lost-item-fee-rule' ) {
- my $refund = $input->param('refund');
+ my $lostreturn = $input->param('lostreturn');
- if ( $refund eq '*' ) {
+ if ( $lostreturn eq '*' ) {
if ( $branch ne '*' ) {
- # only do something for $refund eq '*' if branch-specific
+ # only do something for $lostreturn eq '*' if branch-specific
Koha::CirculationRules->set_rules(
{
branchcode => $branch,
rules => {
- refund => undef
+ lostreturn => undef
}
}
);
{
branchcode => $branch,
rules => {
- refund => $refund
+ lostreturn => $lostreturn
}
}
);
}
}
-my $refundLostItemFeeRule = Koha::CirculationRules->find({ branchcode => ($branch eq '*') ? undef : $branch, rule_name => 'refund' });
-my $defaultLostItemFeeRule = Koha::CirculationRules->find({ branchcode => undef, rule_name => 'refund' });
+my $refundLostItemFeeRule = Koha::CirculationRules->find({ branchcode => ($branch eq '*') ? undef : $branch, rule_name => 'lostreturn' });
+my $defaultLostItemFeeRule = Koha::CirculationRules->find({ branchcode => undef, rule_name => 'lostreturn' });
$template->param(
refundLostItemFeeRule => $refundLostItemFeeRule,
- defaultRefundRule => $defaultLostItemFeeRule ? $defaultLostItemFeeRule->rule_value : 1
+ defaultRefundRule => $defaultLostItemFeeRule ? $defaultLostItemFeeRule->rule_value : 'refund'
);
my $patron_categories = Koha::Patron::Categories->search({}, { order_by => ['description'] });