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