|
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-350
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 |
$holdallowed =~ s/\s//g; |
355 |
$holdallowed =~ s/\s//g; |
| 349 |
$holdallowed = undef if $holdallowed !~ /^\d+/; |
356 |
$holdallowed = undef if $holdallowed !~ /^\d+/; |
| 350 |
|
357 |
|
|
Lines 353-358
elsif ($op eq "set-branch-defaults") {
Link Here
|
| 353 |
{ |
360 |
{ |
| 354 |
itemtype => undef, |
361 |
itemtype => undef, |
| 355 |
branchcode => undef, |
362 |
branchcode => undef, |
|
|
363 |
has_priority => $has_priority, |
| 356 |
rules => { |
364 |
rules => { |
| 357 |
holdallowed => $holdallowed, |
365 |
holdallowed => $holdallowed, |
| 358 |
hold_fulfillment_policy => $hold_fulfillment_policy, |
366 |
hold_fulfillment_policy => $hold_fulfillment_policy, |
|
Lines 364-372
elsif ($op eq "set-branch-defaults") {
Link Here
|
| 364 |
{ |
372 |
{ |
| 365 |
categorycode => undef, |
373 |
categorycode => undef, |
| 366 |
branchcode => undef, |
374 |
branchcode => undef, |
|
|
375 |
has_priority => $has_priority, |
| 367 |
rules => { |
376 |
rules => { |
| 368 |
patron_maxissueqty => $patron_maxissueqty, |
377 |
patron_maxissueqty => $patron_maxissueqty, |
| 369 |
patron_maxonsiteissueqty => $patron_maxonsiteissueqty, |
378 |
patron_maxonsiteissueqty => $patron_maxonsiteissueqty, |
|
|
379 |
patron_has_priority => $has_priority, |
| 370 |
} |
380 |
} |
| 371 |
} |
381 |
} |
| 372 |
); |
382 |
); |
|
Lines 375-380
elsif ($op eq "set-branch-defaults") {
Link Here
|
| 375 |
{ |
385 |
{ |
| 376 |
itemtype => undef, |
386 |
itemtype => undef, |
| 377 |
branchcode => $branch, |
387 |
branchcode => $branch, |
|
|
388 |
has_priority => $has_priority, |
| 378 |
rules => { |
389 |
rules => { |
| 379 |
holdallowed => $holdallowed, |
390 |
holdallowed => $holdallowed, |
| 380 |
hold_fulfillment_policy => $hold_fulfillment_policy, |
391 |
hold_fulfillment_policy => $hold_fulfillment_policy, |
|
Lines 386-391
elsif ($op eq "set-branch-defaults") {
Link Here
|
| 386 |
{ |
397 |
{ |
| 387 |
categorycode => undef, |
398 |
categorycode => undef, |
| 388 |
branchcode => $branch, |
399 |
branchcode => $branch, |
|
|
400 |
has_priority => $has_priority, |
| 389 |
rules => { |
401 |
rules => { |
| 390 |
patron_maxissueqty => $patron_maxissueqty, |
402 |
patron_maxissueqty => $patron_maxissueqty, |
| 391 |
patron_maxonsiteissueqty => $patron_maxonsiteissueqty, |
403 |
patron_maxonsiteissueqty => $patron_maxonsiteissueqty, |
|
Lines 410-417
elsif ($op eq "add-branch-cat") {
Link Here
|
| 410 |
my $max_holds = $input->param('max_holds'); |
422 |
my $max_holds = $input->param('max_holds'); |
| 411 |
$max_holds =~ s/\s//g; |
423 |
$max_holds =~ s/\s//g; |
| 412 |
$max_holds = undef if $max_holds !~ /^\d+/; |
424 |
$max_holds = undef if $max_holds !~ /^\d+/; |
| 413 |
my $has_priority = $input->param('has_priority'); |
425 |
my $has_priority = $input->param('has_priority') ? 1 : undef; |
| 414 |
$has_priority = $has_priority ? 1 : 0; |
|
|
| 415 |
|
426 |
|
| 416 |
if ($branch eq "*") { |
427 |
if ($branch eq "*") { |
| 417 |
if ($categorycode eq "*") { |
428 |
if ($categorycode eq "*") { |
|
Lines 419-424
elsif ($op eq "add-branch-cat") {
Link Here
|
| 419 |
{ |
430 |
{ |
| 420 |
categorycode => undef, |
431 |
categorycode => undef, |
| 421 |
branchcode => undef, |
432 |
branchcode => undef, |
|
|
433 |
has_priority => $has_priority, |
| 422 |
rules => { |
434 |
rules => { |
| 423 |
max_holds => $max_holds, |
435 |
max_holds => $max_holds, |
| 424 |
patron_maxissueqty => $patron_maxissueqty, |
436 |
patron_maxissueqty => $patron_maxissueqty, |
|
Lines 432-442
elsif ($op eq "add-branch-cat") {
Link Here
|
| 432 |
{ |
444 |
{ |
| 433 |
categorycode => $categorycode, |
445 |
categorycode => $categorycode, |
| 434 |
branchcode => undef, |
446 |
branchcode => undef, |
|
|
447 |
has_priority => $has_priority, |
| 435 |
rules => { |
448 |
rules => { |
| 436 |
max_holds => $max_holds, |
449 |
max_holds => $max_holds, |
| 437 |
patron_maxissueqty => $patron_maxissueqty, |
450 |
patron_maxissueqty => $patron_maxissueqty, |
| 438 |
patron_maxonsiteissueqty => $patron_maxonsiteissueqty, |
451 |
patron_maxonsiteissueqty => $patron_maxonsiteissueqty, |
| 439 |
has_priority => $has_priority, |
|
|
| 440 |
} |
452 |
} |
| 441 |
} |
453 |
} |
| 442 |
); |
454 |
); |
|
Lines 446-456
elsif ($op eq "add-branch-cat") {
Link Here
|
| 446 |
{ |
458 |
{ |
| 447 |
categorycode => undef, |
459 |
categorycode => undef, |
| 448 |
branchcode => $branch, |
460 |
branchcode => $branch, |
|
|
461 |
has_priority => $has_priority, |
| 449 |
rules => { |
462 |
rules => { |
| 450 |
max_holds => $max_holds, |
463 |
max_holds => $max_holds, |
| 451 |
patron_maxissueqty => $patron_maxissueqty, |
464 |
patron_maxissueqty => $patron_maxissueqty, |
| 452 |
patron_maxonsiteissueqty => $patron_maxonsiteissueqty, |
465 |
patron_maxonsiteissueqty => $patron_maxonsiteissueqty, |
| 453 |
has_priority => $has_priority, |
|
|
| 454 |
} |
466 |
} |
| 455 |
} |
467 |
} |
| 456 |
); |
468 |
); |
|
Lines 459-469
elsif ($op eq "add-branch-cat") {
Link Here
|
| 459 |
{ |
471 |
{ |
| 460 |
categorycode => $categorycode, |
472 |
categorycode => $categorycode, |
| 461 |
branchcode => $branch, |
473 |
branchcode => $branch, |
|
|
474 |
has_priority => $has_priority, |
| 462 |
rules => { |
475 |
rules => { |
| 463 |
max_holds => $max_holds, |
476 |
max_holds => $max_holds, |
| 464 |
patron_maxissueqty => $patron_maxissueqty, |
477 |
patron_maxissueqty => $patron_maxissueqty, |
| 465 |
patron_maxonsiteissueqty => $patron_maxonsiteissueqty, |
478 |
patron_maxonsiteissueqty => $patron_maxonsiteissueqty, |
| 466 |
has_priority => $has_priority, |
|
|
| 467 |
} |
479 |
} |
| 468 |
} |
480 |
} |
| 469 |
); |
481 |
); |
|
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); |