Lines 75-80
$cache->clear_from_cache( Koha::CirculationRules::GUESSED_ITEMTYPES_KEY );
Link Here
|
75 |
if ($op eq 'delete') { |
75 |
if ($op eq 'delete') { |
76 |
my $itemtype = $input->param('itemtype'); |
76 |
my $itemtype = $input->param('itemtype'); |
77 |
my $categorycode = $input->param('categorycode'); |
77 |
my $categorycode = $input->param('categorycode'); |
|
|
78 |
my $has_priority = $input->param('has_priority') ? 1 : undef; |
78 |
$debug and warn "deleting $1 $2 $branch"; |
79 |
$debug and warn "deleting $1 $2 $branch"; |
79 |
|
80 |
|
80 |
Koha::CirculationRules->set_rules( |
81 |
Koha::CirculationRules->set_rules( |
Lines 82-87
if ($op eq 'delete') {
Link Here
|
82 |
categorycode => $categorycode eq '*' ? undef : $categorycode, |
83 |
categorycode => $categorycode eq '*' ? undef : $categorycode, |
83 |
branchcode => $branch eq '*' ? undef : $branch, |
84 |
branchcode => $branch eq '*' ? undef : $branch, |
84 |
itemtype => $itemtype eq '*' ? undef : $itemtype, |
85 |
itemtype => $itemtype eq '*' ? undef : $itemtype, |
|
|
86 |
has_priority => $has_priority, |
85 |
rules => { |
87 |
rules => { |
86 |
maxissueqty => undef, |
88 |
maxissueqty => undef, |
87 |
maxonsiteissueqty => undef, |
89 |
maxonsiteissueqty => undef, |
Lines 119-130
if ($op eq 'delete') {
Link Here
|
119 |
} |
121 |
} |
120 |
elsif ($op eq 'delete-branch-cat') { |
122 |
elsif ($op eq 'delete-branch-cat') { |
121 |
my $categorycode = $input->param('categorycode'); |
123 |
my $categorycode = $input->param('categorycode'); |
|
|
124 |
my $has_priority = $input->param('has_priority') ? 1 : undef; |
122 |
if ($branch eq "*") { |
125 |
if ($branch eq "*") { |
123 |
if ($categorycode eq "*") { |
126 |
if ($categorycode eq "*") { |
124 |
Koha::CirculationRules->set_rules( |
127 |
Koha::CirculationRules->set_rules( |
125 |
{ |
128 |
{ |
126 |
branchcode => undef, |
129 |
branchcode => undef, |
127 |
categorycode => undef, |
130 |
categorycode => undef, |
|
|
131 |
has_priority => $has_priority, |
128 |
rules => { |
132 |
rules => { |
129 |
max_holds => undef, |
133 |
max_holds => undef, |
130 |
patron_maxissueqty => undef, |
134 |
patron_maxissueqty => undef, |
Lines 148-153
elsif ($op eq 'delete-branch-cat') {
Link Here
|
148 |
{ |
152 |
{ |
149 |
categorycode => $categorycode, |
153 |
categorycode => $categorycode, |
150 |
branchcode => undef, |
154 |
branchcode => undef, |
|
|
155 |
has_priority => $has_priority, |
151 |
rules => { |
156 |
rules => { |
152 |
max_holds => undef, |
157 |
max_holds => undef, |
153 |
patron_maxissueqty => undef, |
158 |
patron_maxissueqty => undef, |
Lines 161-166
elsif ($op eq 'delete-branch-cat') {
Link Here
|
161 |
{ |
166 |
{ |
162 |
branchcode => $branch, |
167 |
branchcode => $branch, |
163 |
categorycode => undef, |
168 |
categorycode => undef, |
|
|
169 |
has_priority => $has_priority, |
164 |
rules => { |
170 |
rules => { |
165 |
max_holds => undef, |
171 |
max_holds => undef, |
166 |
patron_maxissueqty => undef, |
172 |
patron_maxissueqty => undef, |
Lines 184-189
elsif ($op eq 'delete-branch-cat') {
Link Here
|
184 |
{ |
190 |
{ |
185 |
categorycode => $categorycode, |
191 |
categorycode => $categorycode, |
186 |
branchcode => $branch, |
192 |
branchcode => $branch, |
|
|
193 |
has_priority => $has_priority, |
187 |
rules => { |
194 |
rules => { |
188 |
max_holds => undef, |
195 |
max_holds => undef, |
189 |
patron_maxissueqty => undef, |
196 |
patron_maxissueqty => undef, |
Lines 252-258
elsif ($op eq 'add') {
Link Here
|
252 |
my $br = $branch; # branch |
259 |
my $br = $branch; # branch |
253 |
my $bor = $input->param('categorycode'); # borrower category |
260 |
my $bor = $input->param('categorycode'); # borrower category |
254 |
my $itemtype = $input->param('itemtype'); # item type |
261 |
my $itemtype = $input->param('itemtype'); # item type |
255 |
my $has_priority = $input->param('has_priority') ? 1 : 0; |
262 |
my $has_priority = $input->param('has_priority') ? 1 : undef; |
256 |
my $fine = $input->param('fine'); |
263 |
my $fine = $input->param('fine'); |
257 |
my $finedays = $input->param('finedays'); |
264 |
my $finedays = $input->param('finedays'); |
258 |
my $maxsuspensiondays = $input->param('maxsuspensiondays') || ''; |
265 |
my $maxsuspensiondays = $input->param('maxsuspensiondays') || ''; |
Lines 297-303
elsif ($op eq 'add') {
Link Here
|
297 |
maxissueqty => $maxissueqty, |
304 |
maxissueqty => $maxissueqty, |
298 |
maxonsiteissueqty => $maxonsiteissueqty, |
305 |
maxonsiteissueqty => $maxonsiteissueqty, |
299 |
rentaldiscount => $rentaldiscount, |
306 |
rentaldiscount => $rentaldiscount, |
300 |
has_priority => $has_priority, |
|
|
301 |
fine => $fine, |
307 |
fine => $fine, |
302 |
finedays => $finedays, |
308 |
finedays => $finedays, |
303 |
maxsuspensiondays => $maxsuspensiondays, |
309 |
maxsuspensiondays => $maxsuspensiondays, |
Lines 332-338
elsif ($op eq 'add') {
Link Here
|
332 |
categorycode => $bor eq '*' ? undef : $bor, |
338 |
categorycode => $bor eq '*' ? undef : $bor, |
333 |
itemtype => $itemtype eq '*' ? undef : $itemtype, |
339 |
itemtype => $itemtype eq '*' ? undef : $itemtype, |
334 |
branchcode => $br eq '*' ? undef : $br, |
340 |
branchcode => $br eq '*' ? undef : $br, |
335 |
has_priority => $has_priority, |
341 |
has_priority => $has_priority, |
336 |
rules => $rules, |
342 |
rules => $rules, |
337 |
} |
343 |
} |
338 |
); |
344 |
); |
Lines 347-352
elsif ($op eq "set-branch-defaults") {
Link Here
|
347 |
my $hold_fulfillment_policy = $input->param('hold_fulfillment_policy'); |
353 |
my $hold_fulfillment_policy = $input->param('hold_fulfillment_policy'); |
348 |
my $returnbranch = $input->param('returnbranch'); |
354 |
my $returnbranch = $input->param('returnbranch'); |
349 |
my $max_holds = strip_non_numeric( scalar $input->param('max_holds') ); |
355 |
my $max_holds = strip_non_numeric( scalar $input->param('max_holds') ); |
|
|
356 |
my $has_priority = $input->param('has_priority') ? 1 : undef; |
350 |
$holdallowed =~ s/\s//g; |
357 |
$holdallowed =~ s/\s//g; |
351 |
$holdallowed = undef if $holdallowed !~ /^\d+/; |
358 |
$holdallowed = undef if $holdallowed !~ /^\d+/; |
352 |
|
359 |
|
Lines 355-360
elsif ($op eq "set-branch-defaults") {
Link Here
|
355 |
{ |
362 |
{ |
356 |
itemtype => undef, |
363 |
itemtype => undef, |
357 |
branchcode => undef, |
364 |
branchcode => undef, |
|
|
365 |
has_priority => $has_priority, |
358 |
rules => { |
366 |
rules => { |
359 |
holdallowed => $holdallowed, |
367 |
holdallowed => $holdallowed, |
360 |
hold_fulfillment_policy => $hold_fulfillment_policy, |
368 |
hold_fulfillment_policy => $hold_fulfillment_policy, |
Lines 366-374
elsif ($op eq "set-branch-defaults") {
Link Here
|
366 |
{ |
374 |
{ |
367 |
categorycode => undef, |
375 |
categorycode => undef, |
368 |
branchcode => undef, |
376 |
branchcode => undef, |
|
|
377 |
has_priority => $has_priority, |
369 |
rules => { |
378 |
rules => { |
370 |
patron_maxissueqty => $patron_maxissueqty, |
379 |
patron_maxissueqty => $patron_maxissueqty, |
371 |
patron_maxonsiteissueqty => $patron_maxonsiteissueqty, |
380 |
patron_maxonsiteissueqty => $patron_maxonsiteissueqty, |
|
|
381 |
patron_has_priority => $has_priority, |
372 |
} |
382 |
} |
373 |
} |
383 |
} |
374 |
); |
384 |
); |
Lines 377-382
elsif ($op eq "set-branch-defaults") {
Link Here
|
377 |
{ |
387 |
{ |
378 |
itemtype => undef, |
388 |
itemtype => undef, |
379 |
branchcode => $branch, |
389 |
branchcode => $branch, |
|
|
390 |
has_priority => $has_priority, |
380 |
rules => { |
391 |
rules => { |
381 |
holdallowed => $holdallowed, |
392 |
holdallowed => $holdallowed, |
382 |
hold_fulfillment_policy => $hold_fulfillment_policy, |
393 |
hold_fulfillment_policy => $hold_fulfillment_policy, |
Lines 388-393
elsif ($op eq "set-branch-defaults") {
Link Here
|
388 |
{ |
399 |
{ |
389 |
categorycode => undef, |
400 |
categorycode => undef, |
390 |
branchcode => $branch, |
401 |
branchcode => $branch, |
|
|
402 |
has_priority => $has_priority, |
391 |
rules => { |
403 |
rules => { |
392 |
patron_maxissueqty => $patron_maxissueqty, |
404 |
patron_maxissueqty => $patron_maxissueqty, |
393 |
patron_maxonsiteissueqty => $patron_maxonsiteissueqty, |
405 |
patron_maxonsiteissueqty => $patron_maxonsiteissueqty, |
Lines 412-419
elsif ($op eq "add-branch-cat") {
Link Here
|
412 |
my $max_holds = $input->param('max_holds'); |
424 |
my $max_holds = $input->param('max_holds'); |
413 |
$max_holds =~ s/\s//g; |
425 |
$max_holds =~ s/\s//g; |
414 |
$max_holds = undef if $max_holds !~ /^\d+/; |
426 |
$max_holds = undef if $max_holds !~ /^\d+/; |
415 |
my $has_priority = $input->param('has_priority'); |
427 |
my $has_priority = $input->param('has_priority') ? 1 : undef; |
416 |
$has_priority = $has_priority ? 1 : 0; |
|
|
417 |
|
428 |
|
418 |
if ($branch eq "*") { |
429 |
if ($branch eq "*") { |
419 |
if ($categorycode eq "*") { |
430 |
if ($categorycode eq "*") { |
Lines 421-426
elsif ($op eq "add-branch-cat") {
Link Here
|
421 |
{ |
432 |
{ |
422 |
categorycode => undef, |
433 |
categorycode => undef, |
423 |
branchcode => undef, |
434 |
branchcode => undef, |
|
|
435 |
has_priority => $has_priority, |
424 |
rules => { |
436 |
rules => { |
425 |
max_holds => $max_holds, |
437 |
max_holds => $max_holds, |
426 |
patron_maxissueqty => $patron_maxissueqty, |
438 |
patron_maxissueqty => $patron_maxissueqty, |
Lines 434-444
elsif ($op eq "add-branch-cat") {
Link Here
|
434 |
{ |
446 |
{ |
435 |
categorycode => $categorycode, |
447 |
categorycode => $categorycode, |
436 |
branchcode => undef, |
448 |
branchcode => undef, |
|
|
449 |
has_priority => $has_priority, |
437 |
rules => { |
450 |
rules => { |
438 |
max_holds => $max_holds, |
451 |
max_holds => $max_holds, |
439 |
patron_maxissueqty => $patron_maxissueqty, |
452 |
patron_maxissueqty => $patron_maxissueqty, |
440 |
patron_maxonsiteissueqty => $patron_maxonsiteissueqty, |
453 |
patron_maxonsiteissueqty => $patron_maxonsiteissueqty, |
441 |
has_priority => $has_priority, |
|
|
442 |
} |
454 |
} |
443 |
} |
455 |
} |
444 |
); |
456 |
); |
Lines 448-458
elsif ($op eq "add-branch-cat") {
Link Here
|
448 |
{ |
460 |
{ |
449 |
categorycode => undef, |
461 |
categorycode => undef, |
450 |
branchcode => $branch, |
462 |
branchcode => $branch, |
|
|
463 |
has_priority => $has_priority, |
451 |
rules => { |
464 |
rules => { |
452 |
max_holds => $max_holds, |
465 |
max_holds => $max_holds, |
453 |
patron_maxissueqty => $patron_maxissueqty, |
466 |
patron_maxissueqty => $patron_maxissueqty, |
454 |
patron_maxonsiteissueqty => $patron_maxonsiteissueqty, |
467 |
patron_maxonsiteissueqty => $patron_maxonsiteissueqty, |
455 |
has_priority => $has_priority, |
|
|
456 |
} |
468 |
} |
457 |
} |
469 |
} |
458 |
); |
470 |
); |
Lines 461-471
elsif ($op eq "add-branch-cat") {
Link Here
|
461 |
{ |
473 |
{ |
462 |
categorycode => $categorycode, |
474 |
categorycode => $categorycode, |
463 |
branchcode => $branch, |
475 |
branchcode => $branch, |
|
|
476 |
has_priority => $has_priority, |
464 |
rules => { |
477 |
rules => { |
465 |
max_holds => $max_holds, |
478 |
max_holds => $max_holds, |
466 |
patron_maxissueqty => $patron_maxissueqty, |
479 |
patron_maxissueqty => $patron_maxissueqty, |
467 |
patron_maxonsiteissueqty => $patron_maxonsiteissueqty, |
480 |
patron_maxonsiteissueqty => $patron_maxonsiteissueqty, |
468 |
has_priority => $has_priority, |
|
|
469 |
} |
481 |
} |
470 |
} |
482 |
} |
471 |
); |
483 |
); |
Lines 579-584
my $rules = {};
Link Here
|
579 |
while ( my $r = $all_rules->next ) { |
591 |
while ( my $r = $all_rules->next ) { |
580 |
$r = $r->unblessed; |
592 |
$r = $r->unblessed; |
581 |
$rules->{ $r->{categorycode} // '' }->{ $r->{itemtype} // '' }->{ $r->{rule_name} } = $r->{rule_value}; |
593 |
$rules->{ $r->{categorycode} // '' }->{ $r->{itemtype} // '' }->{ $r->{rule_name} } = $r->{rule_value}; |
|
|
594 |
$rules->{ $r->{categorycode} // '' }->{ $r->{itemtype} // '' }->{ 'has_priority' } = $r->{has_priority}; |
582 |
} |
595 |
} |
583 |
|
596 |
|
584 |
$template->param(show_branch_cat_rule_form => 1); |
597 |
$template->param(show_branch_cat_rule_form => 1); |