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 117-128
if ($op eq 'delete') {
Link Here
|
117 |
} |
119 |
} |
118 |
elsif ($op eq 'delete-branch-cat') { |
120 |
elsif ($op eq 'delete-branch-cat') { |
119 |
my $categorycode = $input->param('categorycode'); |
121 |
my $categorycode = $input->param('categorycode'); |
|
|
122 |
my $has_priority = $input->param('has_priority') ? 1 : undef; |
120 |
if ($branch eq "*") { |
123 |
if ($branch eq "*") { |
121 |
if ($categorycode eq "*") { |
124 |
if ($categorycode eq "*") { |
122 |
Koha::CirculationRules->set_rules( |
125 |
Koha::CirculationRules->set_rules( |
123 |
{ |
126 |
{ |
124 |
branchcode => undef, |
127 |
branchcode => undef, |
125 |
categorycode => undef, |
128 |
categorycode => undef, |
|
|
129 |
has_priority => $has_priority, |
126 |
rules => { |
130 |
rules => { |
127 |
max_holds => undef, |
131 |
max_holds => undef, |
128 |
patron_maxissueqty => undef, |
132 |
patron_maxissueqty => undef, |
Lines 146-151
elsif ($op eq 'delete-branch-cat') {
Link Here
|
146 |
{ |
150 |
{ |
147 |
categorycode => $categorycode, |
151 |
categorycode => $categorycode, |
148 |
branchcode => undef, |
152 |
branchcode => undef, |
|
|
153 |
has_priority => $has_priority, |
149 |
rules => { |
154 |
rules => { |
150 |
max_holds => undef, |
155 |
max_holds => undef, |
151 |
patron_maxissueqty => undef, |
156 |
patron_maxissueqty => undef, |
Lines 159-164
elsif ($op eq 'delete-branch-cat') {
Link Here
|
159 |
{ |
164 |
{ |
160 |
branchcode => $branch, |
165 |
branchcode => $branch, |
161 |
categorycode => undef, |
166 |
categorycode => undef, |
|
|
167 |
has_priority => $has_priority, |
162 |
rules => { |
168 |
rules => { |
163 |
max_holds => undef, |
169 |
max_holds => undef, |
164 |
patron_maxissueqty => undef, |
170 |
patron_maxissueqty => undef, |
Lines 182-187
elsif ($op eq 'delete-branch-cat') {
Link Here
|
182 |
{ |
188 |
{ |
183 |
categorycode => $categorycode, |
189 |
categorycode => $categorycode, |
184 |
branchcode => $branch, |
190 |
branchcode => $branch, |
|
|
191 |
has_priority => $has_priority, |
185 |
rules => { |
192 |
rules => { |
186 |
max_holds => undef, |
193 |
max_holds => undef, |
187 |
patron_maxissueqty => undef, |
194 |
patron_maxissueqty => undef, |
Lines 250-256
elsif ($op eq 'add') {
Link Here
|
250 |
my $br = $branch; # branch |
257 |
my $br = $branch; # branch |
251 |
my $bor = $input->param('categorycode'); # borrower category |
258 |
my $bor = $input->param('categorycode'); # borrower category |
252 |
my $itemtype = $input->param('itemtype'); # item type |
259 |
my $itemtype = $input->param('itemtype'); # item type |
253 |
my $has_priority = $input->param('has_priority') ? 1 : 0; |
260 |
my $has_priority = $input->param('has_priority') ? 1 : undef; |
254 |
my $fine = $input->param('fine'); |
261 |
my $fine = $input->param('fine'); |
255 |
my $finedays = $input->param('finedays'); |
262 |
my $finedays = $input->param('finedays'); |
256 |
my $maxsuspensiondays = $input->param('maxsuspensiondays') || ''; |
263 |
my $maxsuspensiondays = $input->param('maxsuspensiondays') || ''; |
Lines 295-301
elsif ($op eq 'add') {
Link Here
|
295 |
maxissueqty => $maxissueqty, |
302 |
maxissueqty => $maxissueqty, |
296 |
maxonsiteissueqty => $maxonsiteissueqty, |
303 |
maxonsiteissueqty => $maxonsiteissueqty, |
297 |
rentaldiscount => $rentaldiscount, |
304 |
rentaldiscount => $rentaldiscount, |
298 |
has_priority => $has_priority, |
|
|
299 |
fine => $fine, |
305 |
fine => $fine, |
300 |
finedays => $finedays, |
306 |
finedays => $finedays, |
301 |
maxsuspensiondays => $maxsuspensiondays, |
307 |
maxsuspensiondays => $maxsuspensiondays, |
Lines 330-336
elsif ($op eq 'add') {
Link Here
|
330 |
categorycode => $bor eq '*' ? undef : $bor, |
336 |
categorycode => $bor eq '*' ? undef : $bor, |
331 |
itemtype => $itemtype eq '*' ? undef : $itemtype, |
337 |
itemtype => $itemtype eq '*' ? undef : $itemtype, |
332 |
branchcode => $br eq '*' ? undef : $br, |
338 |
branchcode => $br eq '*' ? undef : $br, |
333 |
has_priority => $has_priority, |
339 |
has_priority => $has_priority, |
334 |
rules => $rules, |
340 |
rules => $rules, |
335 |
} |
341 |
} |
336 |
); |
342 |
); |
Lines 345-356
elsif ($op eq "set-branch-defaults") {
Link Here
|
345 |
my $hold_fulfillment_policy = $input->param('hold_fulfillment_policy'); |
351 |
my $hold_fulfillment_policy = $input->param('hold_fulfillment_policy'); |
346 |
my $returnbranch = $input->param('returnbranch'); |
352 |
my $returnbranch = $input->param('returnbranch'); |
347 |
my $max_holds = strip_non_numeric( scalar $input->param('max_holds') ); |
353 |
my $max_holds = strip_non_numeric( scalar $input->param('max_holds') ); |
|
|
354 |
my $has_priority = $input->param('has_priority') ? 1 : undef; |
348 |
|
355 |
|
349 |
if ($branch eq "*") { |
356 |
if ($branch eq "*") { |
350 |
Koha::CirculationRules->set_rules( |
357 |
Koha::CirculationRules->set_rules( |
351 |
{ |
358 |
{ |
352 |
itemtype => undef, |
359 |
itemtype => undef, |
353 |
branchcode => undef, |
360 |
branchcode => undef, |
|
|
361 |
has_priority => $has_priority, |
354 |
rules => { |
362 |
rules => { |
355 |
holdallowed => $holdallowed, |
363 |
holdallowed => $holdallowed, |
356 |
hold_fulfillment_policy => $hold_fulfillment_policy, |
364 |
hold_fulfillment_policy => $hold_fulfillment_policy, |
Lines 362-370
elsif ($op eq "set-branch-defaults") {
Link Here
|
362 |
{ |
370 |
{ |
363 |
categorycode => undef, |
371 |
categorycode => undef, |
364 |
branchcode => undef, |
372 |
branchcode => undef, |
|
|
373 |
has_priority => $has_priority, |
365 |
rules => { |
374 |
rules => { |
366 |
patron_maxissueqty => $patron_maxissueqty, |
375 |
patron_maxissueqty => $patron_maxissueqty, |
367 |
patron_maxonsiteissueqty => $patron_maxonsiteissueqty, |
376 |
patron_maxonsiteissueqty => $patron_maxonsiteissueqty, |
|
|
377 |
patron_has_priority => $has_priority, |
368 |
} |
378 |
} |
369 |
} |
379 |
} |
370 |
); |
380 |
); |
Lines 373-378
elsif ($op eq "set-branch-defaults") {
Link Here
|
373 |
{ |
383 |
{ |
374 |
itemtype => undef, |
384 |
itemtype => undef, |
375 |
branchcode => $branch, |
385 |
branchcode => $branch, |
|
|
386 |
has_priority => $has_priority, |
376 |
rules => { |
387 |
rules => { |
377 |
holdallowed => $holdallowed, |
388 |
holdallowed => $holdallowed, |
378 |
hold_fulfillment_policy => $hold_fulfillment_policy, |
389 |
hold_fulfillment_policy => $hold_fulfillment_policy, |
Lines 384-389
elsif ($op eq "set-branch-defaults") {
Link Here
|
384 |
{ |
395 |
{ |
385 |
categorycode => undef, |
396 |
categorycode => undef, |
386 |
branchcode => $branch, |
397 |
branchcode => $branch, |
|
|
398 |
has_priority => $has_priority, |
387 |
rules => { |
399 |
rules => { |
388 |
patron_maxissueqty => $patron_maxissueqty, |
400 |
patron_maxissueqty => $patron_maxissueqty, |
389 |
patron_maxonsiteissueqty => $patron_maxonsiteissueqty, |
401 |
patron_maxonsiteissueqty => $patron_maxonsiteissueqty, |
Lines 408-415
elsif ($op eq "add-branch-cat") {
Link Here
|
408 |
my $max_holds = $input->param('max_holds'); |
420 |
my $max_holds = $input->param('max_holds'); |
409 |
$max_holds =~ s/\s//g; |
421 |
$max_holds =~ s/\s//g; |
410 |
$max_holds = undef if $max_holds !~ /^\d+/; |
422 |
$max_holds = undef if $max_holds !~ /^\d+/; |
411 |
my $has_priority = $input->param('has_priority'); |
423 |
my $has_priority = $input->param('has_priority') ? 1 : undef; |
412 |
$has_priority = $has_priority ? 1 : 0; |
|
|
413 |
|
424 |
|
414 |
if ($branch eq "*") { |
425 |
if ($branch eq "*") { |
415 |
if ($categorycode eq "*") { |
426 |
if ($categorycode eq "*") { |
Lines 417-422
elsif ($op eq "add-branch-cat") {
Link Here
|
417 |
{ |
428 |
{ |
418 |
categorycode => undef, |
429 |
categorycode => undef, |
419 |
branchcode => undef, |
430 |
branchcode => undef, |
|
|
431 |
has_priority => $has_priority, |
420 |
rules => { |
432 |
rules => { |
421 |
max_holds => $max_holds, |
433 |
max_holds => $max_holds, |
422 |
patron_maxissueqty => $patron_maxissueqty, |
434 |
patron_maxissueqty => $patron_maxissueqty, |
Lines 430-440
elsif ($op eq "add-branch-cat") {
Link Here
|
430 |
{ |
442 |
{ |
431 |
categorycode => $categorycode, |
443 |
categorycode => $categorycode, |
432 |
branchcode => undef, |
444 |
branchcode => undef, |
|
|
445 |
has_priority => $has_priority, |
433 |
rules => { |
446 |
rules => { |
434 |
max_holds => $max_holds, |
447 |
max_holds => $max_holds, |
435 |
patron_maxissueqty => $patron_maxissueqty, |
448 |
patron_maxissueqty => $patron_maxissueqty, |
436 |
patron_maxonsiteissueqty => $patron_maxonsiteissueqty, |
449 |
patron_maxonsiteissueqty => $patron_maxonsiteissueqty, |
437 |
has_priority => $has_priority, |
|
|
438 |
} |
450 |
} |
439 |
} |
451 |
} |
440 |
); |
452 |
); |
Lines 444-454
elsif ($op eq "add-branch-cat") {
Link Here
|
444 |
{ |
456 |
{ |
445 |
categorycode => undef, |
457 |
categorycode => undef, |
446 |
branchcode => $branch, |
458 |
branchcode => $branch, |
|
|
459 |
has_priority => $has_priority, |
447 |
rules => { |
460 |
rules => { |
448 |
max_holds => $max_holds, |
461 |
max_holds => $max_holds, |
449 |
patron_maxissueqty => $patron_maxissueqty, |
462 |
patron_maxissueqty => $patron_maxissueqty, |
450 |
patron_maxonsiteissueqty => $patron_maxonsiteissueqty, |
463 |
patron_maxonsiteissueqty => $patron_maxonsiteissueqty, |
451 |
has_priority => $has_priority, |
|
|
452 |
} |
464 |
} |
453 |
} |
465 |
} |
454 |
); |
466 |
); |
Lines 457-467
elsif ($op eq "add-branch-cat") {
Link Here
|
457 |
{ |
469 |
{ |
458 |
categorycode => $categorycode, |
470 |
categorycode => $categorycode, |
459 |
branchcode => $branch, |
471 |
branchcode => $branch, |
|
|
472 |
has_priority => $has_priority, |
460 |
rules => { |
473 |
rules => { |
461 |
max_holds => $max_holds, |
474 |
max_holds => $max_holds, |
462 |
patron_maxissueqty => $patron_maxissueqty, |
475 |
patron_maxissueqty => $patron_maxissueqty, |
463 |
patron_maxonsiteissueqty => $patron_maxonsiteissueqty, |
476 |
patron_maxonsiteissueqty => $patron_maxonsiteissueqty, |
464 |
has_priority => $has_priority, |
|
|
465 |
} |
477 |
} |
466 |
} |
478 |
} |
467 |
); |
479 |
); |
Lines 573-578
my $rules = {};
Link Here
|
573 |
while ( my $r = $all_rules->next ) { |
585 |
while ( my $r = $all_rules->next ) { |
574 |
$r = $r->unblessed; |
586 |
$r = $r->unblessed; |
575 |
$rules->{ $r->{categorycode} // '' }->{ $r->{itemtype} // '' }->{ $r->{rule_name} } = $r->{rule_value}; |
587 |
$rules->{ $r->{categorycode} // '' }->{ $r->{itemtype} // '' }->{ $r->{rule_name} } = $r->{rule_value}; |
|
|
588 |
$rules->{ $r->{categorycode} // '' }->{ $r->{itemtype} // '' }->{ 'has_priority' } = $r->{has_priority}; |
576 |
} |
589 |
} |
577 |
|
590 |
|
578 |
$template->param(show_branch_cat_rule_form => 1); |
591 |
$template->param(show_branch_cat_rule_form => 1); |