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 $onsite_checkout = $input->param('onsite_checkout') eq '' ? undef : $input->param('onsite_checkout'); |
77 |
|
76 |
$debug and warn "deleting $1 $2 $branch"; |
78 |
$debug and warn "deleting $1 $2 $branch"; |
77 |
|
79 |
|
78 |
Koha::CirculationRules->set_rules( |
80 |
Koha::CirculationRules->set_rules( |
Lines 80-88
if ($op eq 'delete') {
Link Here
|
80 |
categorycode => $categorycode eq '*' ? undef : $categorycode, |
82 |
categorycode => $categorycode eq '*' ? undef : $categorycode, |
81 |
branchcode => $branch eq '*' ? undef : $branch, |
83 |
branchcode => $branch eq '*' ? undef : $branch, |
82 |
itemtype => $itemtype eq '*' ? undef : $itemtype, |
84 |
itemtype => $itemtype eq '*' ? undef : $itemtype, |
|
|
85 |
rules => { |
86 |
reservesallowed => undef, |
87 |
holds_per_record => undef, |
88 |
holds_per_day => undef, |
89 |
onshelfholds => undef, |
90 |
opacitemholds => undef, |
91 |
article_requests => undef, |
92 |
} |
93 |
} |
94 |
); |
95 |
Koha::CirculationRules->set_rules( |
96 |
{ |
97 |
categorycode => $categorycode eq '*' ? undef : $categorycode, |
98 |
branchcode => $branch eq '*' ? undef : $branch, |
99 |
itemtype => $itemtype eq '*' ? undef : $itemtype, |
100 |
onsite_checkout => $onsite_checkout eq '*' ? undef : $onsite_checkout, |
83 |
rules => { |
101 |
rules => { |
84 |
maxissueqty => undef, |
102 |
maxissueqty => undef, |
85 |
maxonsiteissueqty => undef, |
|
|
86 |
rentaldiscount => undef, |
103 |
rentaldiscount => undef, |
87 |
fine => undef, |
104 |
fine => undef, |
88 |
finedays => undef, |
105 |
finedays => undef, |
Lines 103-116
if ($op eq 'delete') {
Link Here
|
103 |
auto_renew => undef, |
120 |
auto_renew => undef, |
104 |
no_auto_renewal_after => undef, |
121 |
no_auto_renewal_after => undef, |
105 |
no_auto_renewal_after_hard_limit => undef, |
122 |
no_auto_renewal_after_hard_limit => undef, |
106 |
reservesallowed => undef, |
|
|
107 |
holds_per_record => undef, |
108 |
holds_per_day => undef, |
109 |
onshelfholds => undef, |
110 |
opacitemholds => undef, |
111 |
overduefinescap => undef, |
123 |
overduefinescap => undef, |
112 |
cap_fine_to_replacement_price => undef, |
124 |
cap_fine_to_replacement_price => undef, |
113 |
article_requests => undef, |
|
|
114 |
note => undef, |
125 |
note => undef, |
115 |
} |
126 |
} |
116 |
} |
127 |
} |
Lines 126-133
elsif ($op eq 'delete-branch-cat') {
Link Here
|
126 |
categorycode => undef, |
137 |
categorycode => undef, |
127 |
rules => { |
138 |
rules => { |
128 |
max_holds => undef, |
139 |
max_holds => undef, |
129 |
patron_maxissueqty => undef, |
140 |
} |
130 |
patron_maxonsiteissueqty => undef, |
141 |
} |
|
|
142 |
); |
143 |
Koha::CirculationRules->set_rules( |
144 |
{ |
145 |
branchcode => undef, |
146 |
categorycode => undef, |
147 |
onsite_checkout => 0, |
148 |
rules => { |
149 |
patron_maxissueqty => undef, |
150 |
} |
151 |
} |
152 |
); |
153 |
Koha::CirculationRules->set_rules( |
154 |
{ |
155 |
branchcode => undef, |
156 |
categorycode => undef, |
157 |
onsite_checkout => 1, |
158 |
rules => { |
159 |
patron_maxissueqty => undef, |
131 |
} |
160 |
} |
132 |
} |
161 |
} |
133 |
); |
162 |
); |
Lines 149-156
elsif ($op eq 'delete-branch-cat') {
Link Here
|
149 |
branchcode => undef, |
178 |
branchcode => undef, |
150 |
rules => { |
179 |
rules => { |
151 |
max_holds => undef, |
180 |
max_holds => undef, |
|
|
181 |
} |
182 |
} |
183 |
); |
184 |
Koha::CirculationRules->set_rules( |
185 |
{ |
186 |
categorycode => $categorycode, |
187 |
branchcode => undef, |
188 |
onsite_checkout => 0, |
189 |
rules => { |
190 |
patron_maxissueqty => undef, |
191 |
} |
192 |
} |
193 |
); |
194 |
Koha::CirculationRules->set_rules( |
195 |
{ |
196 |
categorycode => $categorycode, |
197 |
branchcode => undef, |
198 |
onsite_checkout => 1, |
199 |
rules => { |
152 |
patron_maxissueqty => undef, |
200 |
patron_maxissueqty => undef, |
153 |
patron_maxonsiteissueqty => undef, |
|
|
154 |
} |
201 |
} |
155 |
} |
202 |
} |
156 |
); |
203 |
); |
Lines 160-169
elsif ($op eq 'delete-branch-cat') {
Link Here
|
160 |
{ |
207 |
{ |
161 |
branchcode => $branch, |
208 |
branchcode => $branch, |
162 |
categorycode => undef, |
209 |
categorycode => undef, |
|
|
210 |
onsite_checkout => 0, |
211 |
rules => { |
212 |
patron_maxissueqty => undef, |
213 |
} |
214 |
} |
215 |
); |
216 |
Koha::CirculationRules->set_rules( |
217 |
{ |
218 |
branchcode => $branch, |
219 |
categorycode => undef, |
220 |
onsite_checkout => 1, |
163 |
rules => { |
221 |
rules => { |
164 |
max_holds => undef, |
222 |
max_holds => undef, |
165 |
patron_maxissueqty => undef, |
223 |
patron_maxissueqty => undef, |
166 |
patron_maxonsiteissueqty => undef, |
|
|
167 |
} |
224 |
} |
168 |
} |
225 |
} |
169 |
); |
226 |
); |
Lines 185-192
elsif ($op eq 'delete-branch-cat') {
Link Here
|
185 |
branchcode => $branch, |
242 |
branchcode => $branch, |
186 |
rules => { |
243 |
rules => { |
187 |
max_holds => undef, |
244 |
max_holds => undef, |
188 |
patron_maxissueqty => undef, |
245 |
} |
189 |
patron_maxonsiteissueqty => undef, |
246 |
} |
|
|
247 |
); |
248 |
Koha::CirculationRules->set_rules( |
249 |
{ |
250 |
categorycode => $categorycode, |
251 |
branchcode => $branch, |
252 |
onsite_checkout => 0, |
253 |
rules => { |
254 |
patron_maxissueqty => undef, |
255 |
} |
256 |
} |
257 |
); |
258 |
Koha::CirculationRules->set_rules( |
259 |
{ |
260 |
categorycode => $categorycode, |
261 |
branchcode => $branch, |
262 |
onsite_checkout => 1, |
263 |
rules => { |
264 |
patron_maxissueqty => undef, |
190 |
} |
265 |
} |
191 |
} |
266 |
} |
192 |
); |
267 |
); |
Lines 251-256
elsif ($op eq 'add') {
Link Here
|
251 |
my $br = $branch; # branch |
326 |
my $br = $branch; # branch |
252 |
my $bor = $input->param('categorycode'); # borrower category |
327 |
my $bor = $input->param('categorycode'); # borrower category |
253 |
my $itemtype = $input->param('itemtype'); # item type |
328 |
my $itemtype = $input->param('itemtype'); # item type |
|
|
329 |
my $onsite_checkout = $input->param('onsite_checkout'); |
254 |
my $fine = $input->param('fine'); |
330 |
my $fine = $input->param('fine'); |
255 |
my $finedays = $input->param('finedays'); |
331 |
my $finedays = $input->param('finedays'); |
256 |
my $maxsuspensiondays = $input->param('maxsuspensiondays') || ''; |
332 |
my $maxsuspensiondays = $input->param('maxsuspensiondays') || ''; |
Lines 259-265
elsif ($op eq 'add') {
Link Here
|
259 |
my $chargeperiod = $input->param('chargeperiod'); |
335 |
my $chargeperiod = $input->param('chargeperiod'); |
260 |
my $chargeperiod_charge_at = $input->param('chargeperiod_charge_at'); |
336 |
my $chargeperiod_charge_at = $input->param('chargeperiod_charge_at'); |
261 |
my $maxissueqty = strip_non_numeric( scalar $input->param('maxissueqty') ); |
337 |
my $maxissueqty = strip_non_numeric( scalar $input->param('maxissueqty') ); |
262 |
my $maxonsiteissueqty = strip_non_numeric( scalar $input->param('maxonsiteissueqty') ); |
|
|
263 |
my $renewalsallowed = $input->param('renewalsallowed'); |
338 |
my $renewalsallowed = $input->param('renewalsallowed'); |
264 |
my $unseen_renewals_allowed = $input->param('unseen_renewals_allowed'); |
339 |
my $unseen_renewals_allowed = $input->param('unseen_renewals_allowed'); |
265 |
my $renewalperiod = $input->param('renewalperiod'); |
340 |
my $renewalperiod = $input->param('renewalperiod'); |
Lines 290-300
elsif ($op eq 'add') {
Link Here
|
290 |
my $cap_fine_to_replacement_price = ($input->param('cap_fine_to_replacement_price') || '') eq 'on'; |
365 |
my $cap_fine_to_replacement_price = ($input->param('cap_fine_to_replacement_price') || '') eq 'on'; |
291 |
my $note = $input->param('note'); |
366 |
my $note = $input->param('note'); |
292 |
my $decreaseloanholds = $input->param('decreaseloanholds') || undef; |
367 |
my $decreaseloanholds = $input->param('decreaseloanholds') || undef; |
293 |
$debug and warn "Adding $br, $bor, $itemtype, $fine, $maxissueqty, $maxonsiteissueqty, $cap_fine_to_replacement_price"; |
368 |
$debug and warn "Adding $br, $bor, $itemtype, $fine, $maxissueqty, $cap_fine_to_replacement_price"; |
294 |
|
369 |
|
295 |
my $rules = { |
370 |
my $rules = { |
296 |
maxissueqty => $maxissueqty, |
371 |
maxissueqty => $maxissueqty, |
297 |
maxonsiteissueqty => $maxonsiteissueqty, |
|
|
298 |
rentaldiscount => $rentaldiscount, |
372 |
rentaldiscount => $rentaldiscount, |
299 |
fine => $fine, |
373 |
fine => $fine, |
300 |
finedays => $finedays, |
374 |
finedays => $finedays, |
Lines 315-329
elsif ($op eq 'add') {
Link Here
|
315 |
auto_renew => $auto_renew, |
389 |
auto_renew => $auto_renew, |
316 |
no_auto_renewal_after => $no_auto_renewal_after, |
390 |
no_auto_renewal_after => $no_auto_renewal_after, |
317 |
no_auto_renewal_after_hard_limit => $no_auto_renewal_after_hard_limit, |
391 |
no_auto_renewal_after_hard_limit => $no_auto_renewal_after_hard_limit, |
|
|
392 |
overduefinescap => $overduefinescap, |
393 |
cap_fine_to_replacement_price => $cap_fine_to_replacement_price, |
394 |
note => $note, |
395 |
}; |
396 |
|
397 |
Koha::CirculationRules->set_rules( |
398 |
{ |
399 |
categorycode => $bor eq '*' ? undef : $bor, |
400 |
itemtype => $itemtype eq '*' ? undef : $itemtype, |
401 |
branchcode => $br eq '*' ? undef : $br, |
402 |
onsite_checkout => $onsite_checkout eq '*' ? undef : $onsite_checkout, |
403 |
rules => $rules, |
404 |
} |
405 |
); |
406 |
|
407 |
$rules = { |
318 |
reservesallowed => $reservesallowed, |
408 |
reservesallowed => $reservesallowed, |
319 |
holds_per_record => $holds_per_record, |
409 |
holds_per_record => $holds_per_record, |
320 |
holds_per_day => $holds_per_day, |
410 |
holds_per_day => $holds_per_day, |
321 |
onshelfholds => $onshelfholds, |
411 |
onshelfholds => $onshelfholds, |
322 |
opacitemholds => $opacitemholds, |
412 |
opacitemholds => $opacitemholds, |
323 |
overduefinescap => $overduefinescap, |
|
|
324 |
cap_fine_to_replacement_price => $cap_fine_to_replacement_price, |
325 |
article_requests => $article_requests, |
413 |
article_requests => $article_requests, |
326 |
note => $note, |
|
|
327 |
decreaseloanholds => $decreaseloanholds, |
414 |
decreaseloanholds => $decreaseloanholds, |
328 |
}; |
415 |
}; |
329 |
|
416 |
|
Lines 340-347
elsif ($op eq 'add') {
Link Here
|
340 |
elsif ($op eq "set-branch-defaults") { |
427 |
elsif ($op eq "set-branch-defaults") { |
341 |
my $categorycode = $input->param('categorycode'); |
428 |
my $categorycode = $input->param('categorycode'); |
342 |
my $patron_maxissueqty = strip_non_numeric( scalar $input->param('patron_maxissueqty') ); |
429 |
my $patron_maxissueqty = strip_non_numeric( scalar $input->param('patron_maxissueqty') ); |
343 |
my $patron_maxonsiteissueqty = $input->param('patron_maxonsiteissueqty'); |
430 |
my $patron_maxonsiteissueqty = strip_non_numeric( scalar $input->param('patron_maxonsiteissueqty') ); |
344 |
$patron_maxonsiteissueqty = strip_non_numeric($patron_maxonsiteissueqty); |
|
|
345 |
my $holdallowed = $input->param('holdallowed'); |
431 |
my $holdallowed = $input->param('holdallowed'); |
346 |
my $hold_fulfillment_policy = $input->param('hold_fulfillment_policy'); |
432 |
my $hold_fulfillment_policy = $input->param('hold_fulfillment_policy'); |
347 |
my $returnbranch = $input->param('returnbranch'); |
433 |
my $returnbranch = $input->param('returnbranch'); |
Lines 363-371
elsif ($op eq "set-branch-defaults") {
Link Here
|
363 |
{ |
449 |
{ |
364 |
categorycode => undef, |
450 |
categorycode => undef, |
365 |
branchcode => undef, |
451 |
branchcode => undef, |
|
|
452 |
onsite_checkout => 0, |
366 |
rules => { |
453 |
rules => { |
367 |
patron_maxissueqty => $patron_maxissueqty, |
454 |
patron_maxissueqty => $patron_maxissueqty, |
368 |
patron_maxonsiteissueqty => $patron_maxonsiteissueqty, |
455 |
} |
|
|
456 |
} |
457 |
); |
458 |
Koha::CirculationRules->set_rules( |
459 |
{ |
460 |
categorycode => undef, |
461 |
branchcode => undef, |
462 |
onsite_checkout => 1, |
463 |
rules => { |
464 |
patron_maxissueqty => $patron_maxonsiteissueqty, |
369 |
} |
465 |
} |
370 |
} |
466 |
} |
371 |
); |
467 |
); |
Lines 385-393
elsif ($op eq "set-branch-defaults") {
Link Here
|
385 |
{ |
481 |
{ |
386 |
categorycode => undef, |
482 |
categorycode => undef, |
387 |
branchcode => $branch, |
483 |
branchcode => $branch, |
|
|
484 |
onsite_checkout => 0, |
388 |
rules => { |
485 |
rules => { |
389 |
patron_maxissueqty => $patron_maxissueqty, |
486 |
patron_maxissueqty => $patron_maxissueqty, |
390 |
patron_maxonsiteissueqty => $patron_maxonsiteissueqty, |
487 |
} |
|
|
488 |
} |
489 |
); |
490 |
Koha::CirculationRules->set_rules( |
491 |
{ |
492 |
categorycode => undef, |
493 |
branchcode => $branch, |
494 |
onsite_checkout => 1, |
495 |
rules => { |
496 |
patron_maxissueqty => $patron_maxonsiteissueqty, |
391 |
} |
497 |
} |
392 |
} |
498 |
} |
393 |
); |
499 |
); |
Lines 404-411
elsif ($op eq "set-branch-defaults") {
Link Here
|
404 |
elsif ($op eq "add-branch-cat") { |
510 |
elsif ($op eq "add-branch-cat") { |
405 |
my $categorycode = $input->param('categorycode'); |
511 |
my $categorycode = $input->param('categorycode'); |
406 |
my $patron_maxissueqty = strip_non_numeric( scalar $input->param('patron_maxissueqty') ); |
512 |
my $patron_maxissueqty = strip_non_numeric( scalar $input->param('patron_maxissueqty') ); |
407 |
my $patron_maxonsiteissueqty = $input->param('patron_maxonsiteissueqty'); |
513 |
my $patron_maxonsiteissueqty = strip_non_numeric( scalar $input->param('patron_maxonsiteissueqty') ); |
408 |
$patron_maxonsiteissueqty = strip_non_numeric($patron_maxonsiteissueqty); |
|
|
409 |
my $max_holds = $input->param('max_holds'); |
514 |
my $max_holds = $input->param('max_holds'); |
410 |
$max_holds =~ s/\s//g; |
515 |
$max_holds =~ s/\s//g; |
411 |
$max_holds = undef if $max_holds !~ /^\d+/; |
516 |
$max_holds = undef if $max_holds !~ /^\d+/; |
Lines 418-425
elsif ($op eq "add-branch-cat") {
Link Here
|
418 |
branchcode => undef, |
523 |
branchcode => undef, |
419 |
rules => { |
524 |
rules => { |
420 |
max_holds => $max_holds, |
525 |
max_holds => $max_holds, |
|
|
526 |
} |
527 |
} |
528 |
); |
529 |
Koha::CirculationRules->set_rules( |
530 |
{ |
531 |
categorycode => undef, |
532 |
branchcode => undef, |
533 |
onsite_checkout => 0, |
534 |
rules => { |
421 |
patron_maxissueqty => $patron_maxissueqty, |
535 |
patron_maxissueqty => $patron_maxissueqty, |
422 |
patron_maxonsiteissueqty => $patron_maxonsiteissueqty, |
536 |
} |
|
|
537 |
} |
538 |
); |
539 |
Koha::CirculationRules->set_rules( |
540 |
{ |
541 |
categorycode => undef, |
542 |
branchcode => undef, |
543 |
onsite_checkout => 1, |
544 |
rules => { |
545 |
patron_maxissueqty => $patron_maxonsiteissueqty, |
423 |
} |
546 |
} |
424 |
} |
547 |
} |
425 |
); |
548 |
); |
Lines 430-437
elsif ($op eq "add-branch-cat") {
Link Here
|
430 |
branchcode => undef, |
553 |
branchcode => undef, |
431 |
rules => { |
554 |
rules => { |
432 |
max_holds => $max_holds, |
555 |
max_holds => $max_holds, |
|
|
556 |
} |
557 |
} |
558 |
); |
559 |
Koha::CirculationRules->set_rules( |
560 |
{ |
561 |
categorycode => $categorycode, |
562 |
branchcode => undef, |
563 |
onsite_checkout => 0, |
564 |
rules => { |
433 |
patron_maxissueqty => $patron_maxissueqty, |
565 |
patron_maxissueqty => $patron_maxissueqty, |
434 |
patron_maxonsiteissueqty => $patron_maxonsiteissueqty, |
566 |
} |
|
|
567 |
} |
568 |
); |
569 |
Koha::CirculationRules->set_rules( |
570 |
{ |
571 |
categorycode => $categorycode, |
572 |
branchcode => undef, |
573 |
onsite_checkout => 1, |
574 |
rules => { |
575 |
patron_maxissueqty => $patron_maxonsiteissueqty, |
435 |
} |
576 |
} |
436 |
} |
577 |
} |
437 |
); |
578 |
); |
Lines 443-450
elsif ($op eq "add-branch-cat") {
Link Here
|
443 |
branchcode => $branch, |
584 |
branchcode => $branch, |
444 |
rules => { |
585 |
rules => { |
445 |
max_holds => $max_holds, |
586 |
max_holds => $max_holds, |
|
|
587 |
} |
588 |
} |
589 |
); |
590 |
Koha::CirculationRules->set_rules( |
591 |
{ |
592 |
categorycode => undef, |
593 |
branchcode => $branch, |
594 |
onsite_checkout => 0, |
595 |
rules => { |
446 |
patron_maxissueqty => $patron_maxissueqty, |
596 |
patron_maxissueqty => $patron_maxissueqty, |
447 |
patron_maxonsiteissueqty => $patron_maxonsiteissueqty, |
597 |
} |
|
|
598 |
} |
599 |
); |
600 |
Koha::CirculationRules->set_rules( |
601 |
{ |
602 |
categorycode => undef, |
603 |
branchcode => $branch, |
604 |
onsite_checkout => 1, |
605 |
rules => { |
606 |
patron_maxissueqty => $patron_maxonsiteissueqty, |
448 |
} |
607 |
} |
449 |
} |
608 |
} |
450 |
); |
609 |
); |
Lines 455-462
elsif ($op eq "add-branch-cat") {
Link Here
|
455 |
branchcode => $branch, |
614 |
branchcode => $branch, |
456 |
rules => { |
615 |
rules => { |
457 |
max_holds => $max_holds, |
616 |
max_holds => $max_holds, |
|
|
617 |
} |
618 |
} |
619 |
); |
620 |
Koha::CirculationRules->set_rules( |
621 |
{ |
622 |
categorycode => $categorycode, |
623 |
branchcode => $branch, |
624 |
onsite_checkout => 0, |
625 |
rules => { |
458 |
patron_maxissueqty => $patron_maxissueqty, |
626 |
patron_maxissueqty => $patron_maxissueqty, |
459 |
patron_maxonsiteissueqty => $patron_maxonsiteissueqty, |
627 |
} |
|
|
628 |
} |
629 |
); |
630 |
Koha::CirculationRules->set_rules( |
631 |
{ |
632 |
categorycode => $categorycode, |
633 |
branchcode => $branch, |
634 |
onsite_checkout => 1, |
635 |
rules => { |
636 |
patron_maxissueqty => $patron_maxonsiteissueqty, |
460 |
} |
637 |
} |
461 |
} |
638 |
} |
462 |
); |
639 |
); |
Lines 567-573
my $definedbranch = $all_rules->count ? 1 : 0;
Link Here
|
567 |
my $rules = {}; |
744 |
my $rules = {}; |
568 |
while ( my $r = $all_rules->next ) { |
745 |
while ( my $r = $all_rules->next ) { |
569 |
$r = $r->unblessed; |
746 |
$r = $r->unblessed; |
570 |
$rules->{ $r->{categorycode} // '' }->{ $r->{itemtype} // '' }->{ $r->{rule_name} } = $r->{rule_value}; |
747 |
$rules->{ $r->{onsite_checkout} // '' }->{ $r->{categorycode} // '' }->{ $r->{itemtype} // '' }->{ $r->{rule_name} } = $r->{rule_value}; |
571 |
} |
748 |
} |
572 |
|
749 |
|
573 |
$template->param(show_branch_cat_rule_form => 1); |
750 |
$template->param(show_branch_cat_rule_form => 1); |