View | Details | Raw Unified | Return to bug 41268
Collapse All | Expand All

(-)a/admin/smart-rules.pl (-225 / +71 lines)
Lines 341-398 elsif ( $op eq 'cud-add' ) { Link Here
341
    my $returnbranch            = $input->param('returnbranch');
341
    my $returnbranch            = $input->param('returnbranch');
342
    my $max_holds               = strip_non_numeric( scalar $input->param('max_holds') );
342
    my $max_holds               = strip_non_numeric( scalar $input->param('max_holds') );
343
343
344
    if ( $branch eq "*" ) {
344
    my $rule_branch = $branch eq '*' ? undef : $branch;
345
        Koha::CirculationRules->set_rules(
345
346
            {
346
    Koha::CirculationRules->set_rules(
347
                itemtype   => undef,
347
        {
348
                branchcode => undef,
348
            itemtype   => undef,
349
                rules      => {
349
            branchcode => $rule_branch,
350
                    holdallowed             => $holdallowed,
350
            rules      => {
351
                    hold_fulfillment_policy => $hold_fulfillment_policy,
351
                holdallowed             => $holdallowed,
352
                    bookings_lead_period    => $bookings_lead_period,
352
                hold_fulfillment_policy => $hold_fulfillment_policy,
353
                    bookings_trail_period   => $bookings_trail_period,
353
                bookings_lead_period    => $bookings_lead_period,
354
                    returnbranch            => $returnbranch,
354
                bookings_trail_period   => $bookings_trail_period,
355
                }
355
                returnbranch            => $returnbranch,
356
            }
357
        );
358
        Koha::CirculationRules->set_rules(
359
            {
360
                categorycode => undef,
361
                branchcode   => undef,
362
                rules        => {
363
                    patron_maxissueqty       => $patron_maxissueqty,
364
                    patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
365
                }
366
            }
367
        );
368
    } else {
369
        Koha::CirculationRules->set_rules(
370
            {
371
                itemtype   => undef,
372
                branchcode => $branch,
373
                rules      => {
374
                    holdallowed             => $holdallowed,
375
                    hold_fulfillment_policy => $hold_fulfillment_policy,
376
                    bookings_lead_period    => $bookings_lead_period,
377
                    bookings_trail_period   => $bookings_trail_period,
378
                    returnbranch            => $returnbranch,
379
                }
380
            }
356
            }
381
        );
357
        }
382
        Koha::CirculationRules->set_rules(
358
    );
383
            {
359
    Koha::CirculationRules->set_rules(
384
                categorycode => undef,
360
        {
385
                branchcode   => $branch,
361
            categorycode => undef,
386
                rules        => {
362
            branchcode   => $rule_branch,
387
                    patron_maxissueqty       => $patron_maxissueqty,
363
            rules        => {
388
                    patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
364
                patron_maxissueqty       => $patron_maxissueqty,
389
                }
365
                patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
390
            }
366
            }
391
        );
367
        }
392
    }
368
    );
393
    Koha::CirculationRules->set_rule(
369
    Koha::CirculationRules->set_rule(
394
        {
370
        {
395
            branchcode   => $branch,
371
            branchcode   => $rule_branch,
396
            categorycode => undef,
372
            categorycode => undef,
397
            rule_name    => 'max_holds',
373
            rule_name    => 'max_holds',
398
            rule_value   => $max_holds,
374
            rule_value   => $max_holds,
Lines 406-462 elsif ( $op eq 'cud-add' ) { Link Here
406
    my $max_holds = $input->param('max_holds');
382
    my $max_holds = $input->param('max_holds');
407
    $max_holds = strip_non_numeric($max_holds);
383
    $max_holds = strip_non_numeric($max_holds);
408
384
409
    if ( $branch eq "*" ) {
385
    my $rule_branch       = $branch eq '*'       ? undef : $branch;
410
        if ( $categorycode eq "*" ) {
386
    my $rule_categorycode = $categorycode eq '*' ? undef : $categorycode;
411
            Koha::CirculationRules->set_rules(
387
412
                {
388
    Koha::CirculationRules->set_rules(
413
                    categorycode => undef,
389
        {
414
                    branchcode   => undef,
390
            categorycode => $rule_categorycode,
415
                    rules        => {
391
            branchcode   => $rule_branch,
416
                        max_holds                => $max_holds,
392
            rules        => {
417
                        patron_maxissueqty       => $patron_maxissueqty,
393
                max_holds                => $max_holds,
418
                        patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
394
                patron_maxissueqty       => $patron_maxissueqty,
419
                    }
395
                patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
420
                }
421
            );
422
        } else {
423
            Koha::CirculationRules->set_rules(
424
                {
425
                    categorycode => $categorycode,
426
                    branchcode   => undef,
427
                    rules        => {
428
                        max_holds                => $max_holds,
429
                        patron_maxissueqty       => $patron_maxissueqty,
430
                        patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
431
                    }
432
                }
433
            );
434
        }
435
    } elsif ( $categorycode eq "*" ) {
436
        Koha::CirculationRules->set_rules(
437
            {
438
                categorycode => undef,
439
                branchcode   => $branch,
440
                rules        => {
441
                    max_holds                => $max_holds,
442
                    patron_maxissueqty       => $patron_maxissueqty,
443
                    patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
444
                }
445
            }
446
        );
447
    } else {
448
        Koha::CirculationRules->set_rules(
449
            {
450
                categorycode => $categorycode,
451
                branchcode   => $branch,
452
                rules        => {
453
                    max_holds                => $max_holds,
454
                    patron_maxissueqty       => $patron_maxissueqty,
455
                    patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
456
                }
457
            }
396
            }
458
        );
397
        }
459
    }
398
    );
460
} elsif ( $op eq "cud-add-open-article-requests-limit" ) {
399
} elsif ( $op eq "cud-add-open-article-requests-limit" ) {
461
    my $categorycode                = $input->param('categorycode');
400
    my $categorycode                = $input->param('categorycode');
462
    my $open_article_requests_limit = strip_non_numeric( scalar $input->param('open_article_requests_limit') );
401
    my $open_article_requests_limit = strip_non_numeric( scalar $input->param('open_article_requests_limit') );
Lines 465-542 elsif ( $op eq 'cud-add' ) { Link Here
465
        if not defined $open_article_requests_limit    # There is a JS check for that
404
        if not defined $open_article_requests_limit    # There is a JS check for that
466
        || $open_article_requests_limit eq q{};
405
        || $open_article_requests_limit eq q{};
467
406
468
    if ( $branch eq "*" ) {
407
    my $rule_branch       = $branch eq '*'       ? undef : $branch;
469
        if ( $categorycode eq "*" ) {
408
    my $rule_categorycode = $categorycode eq '*' ? undef : $categorycode;
470
            Koha::CirculationRules->set_rules(
409
471
                {
410
    Koha::CirculationRules->set_rules(
472
                    categorycode => undef,
411
        {
473
                    branchcode   => undef,
412
            categorycode => $rule_categorycode,
474
                    rules        => { open_article_requests_limit => $open_article_requests_limit, }
413
            branchcode   => $rule_branch,
475
                }
414
            rules        => { open_article_requests_limit => $open_article_requests_limit, }
476
            );
477
        } else {
478
            Koha::CirculationRules->set_rules(
479
                {
480
                    categorycode => $categorycode,
481
                    branchcode   => undef,
482
                    rules        => { open_article_requests_limit => $open_article_requests_limit, }
483
                }
484
            );
485
        }
415
        }
486
    } elsif ( $categorycode eq "*" ) {
416
    );
487
        Koha::CirculationRules->set_rules(
488
            {
489
                categorycode => undef,
490
                branchcode   => $branch,
491
                rules        => { open_article_requests_limit => $open_article_requests_limit, }
492
            }
493
        );
494
    } else {
495
        Koha::CirculationRules->set_rules(
496
            {
497
                categorycode => $categorycode,
498
                branchcode   => $branch,
499
                rules        => { open_article_requests_limit => $open_article_requests_limit, }
500
            }
501
        );
502
    }
503
} elsif ( $op eq 'cud-del-open-article-requests-limit' ) {
417
} elsif ( $op eq 'cud-del-open-article-requests-limit' ) {
504
    my $categorycode = $input->param('categorycode');
418
    my $categorycode = $input->param('categorycode');
505
    if ( $branch eq "*" ) {
419
506
        if ( $categorycode eq "*" ) {
420
    my $rule_branch       = $branch eq '*'       ? undef : $branch;
507
            Koha::CirculationRules->set_rules(
421
    my $rule_categorycode = $categorycode eq '*' ? undef : $categorycode;
508
                {
422
509
                    branchcode   => undef,
423
    Koha::CirculationRules->set_rules(
510
                    categorycode => undef,
424
        {
511
                    rules        => { open_article_requests_limit => undef, }
425
            branchcode   => $rule_branch,
512
                }
426
            categorycode => $rule_categorycode,
513
            );
427
            rules        => { open_article_requests_limit => undef, }
514
        } else {
515
            Koha::CirculationRules->set_rules(
516
                {
517
                    categorycode => $categorycode,
518
                    branchcode   => undef,
519
                    rules        => { open_article_requests_limit => undef, }
520
                }
521
            );
522
        }
428
        }
523
    } elsif ( $categorycode eq "*" ) {
429
    );
524
        Koha::CirculationRules->set_rules(
525
            {
526
                branchcode   => $branch,
527
                categorycode => undef,
528
                rules        => { open_article_requests_limit => undef, }
529
            }
530
        );
531
    } else {
532
        Koha::CirculationRules->set_rules(
533
            {
534
                categorycode => $categorycode,
535
                branchcode   => $branch,
536
                rules        => { open_article_requests_limit => undef, }
537
            }
538
        );
539
    }
540
} elsif ( $op eq "cud-set-article-request-fee" ) {
430
} elsif ( $op eq "cud-set-article-request-fee" ) {
541
431
542
    my $category = $input->param('article_request_fee_category');
432
    my $category = $input->param('article_request_fee_category');
Lines 573-637 elsif ( $op eq 'cud-add' ) { Link Here
573
    my $bookings_trail_period   = $input->param('bookings_trail_period');
463
    my $bookings_trail_period   = $input->param('bookings_trail_period');
574
    my $returnbranch            = $input->param('returnbranch');
464
    my $returnbranch            = $input->param('returnbranch');
575
465
576
    if ( $branch eq "*" ) {
466
    my $rule_branch   = $branch eq '*'   ? undef : $branch;
577
        if ( $itemtype eq "*" ) {
467
    my $rule_itemtype = $itemtype eq '*' ? undef : $itemtype;
578
            Koha::CirculationRules->set_rules(
468
579
                {
469
    Koha::CirculationRules->set_rules(
580
                    itemtype   => undef,
470
        {
581
                    branchcode => undef,
471
            itemtype   => $rule_itemtype,
582
                    rules      => {
472
            branchcode => $rule_branch,
583
                        holdallowed             => $holdallowed,
473
            rules      => {
584
                        hold_fulfillment_policy => $hold_fulfillment_policy,
474
                holdallowed             => $holdallowed,
585
                        bookings_lead_period    => $bookings_lead_period,
475
                hold_fulfillment_policy => $hold_fulfillment_policy,
586
                        bookings_trail_period   => $bookings_trail_period,
476
                bookings_lead_period    => $bookings_lead_period,
587
                        returnbranch            => $returnbranch,
477
                bookings_trail_period   => $bookings_trail_period,
588
                    }
478
                returnbranch            => $returnbranch,
589
                }
590
            );
591
        } else {
592
            Koha::CirculationRules->set_rules(
593
                {
594
                    itemtype   => $itemtype,
595
                    branchcode => undef,
596
                    rules      => {
597
                        holdallowed             => $holdallowed,
598
                        hold_fulfillment_policy => $hold_fulfillment_policy,
599
                        bookings_lead_period    => $bookings_lead_period,
600
                        bookings_trail_period   => $bookings_trail_period,
601
                        returnbranch            => $returnbranch,
602
                    }
603
                }
604
            );
605
        }
606
    } elsif ( $itemtype eq "*" ) {
607
        Koha::CirculationRules->set_rules(
608
            {
609
                itemtype   => undef,
610
                branchcode => $branch,
611
                rules      => {
612
                    holdallowed             => $holdallowed,
613
                    hold_fulfillment_policy => $hold_fulfillment_policy,
614
                    bookings_lead_period    => $bookings_lead_period,
615
                    bookings_trail_period   => $bookings_trail_period,
616
                    returnbranch            => $returnbranch,
617
                }
618
            }
619
        );
620
    } else {
621
        Koha::CirculationRules->set_rules(
622
            {
623
                itemtype   => $itemtype,
624
                branchcode => $branch,
625
                rules      => {
626
                    holdallowed             => $holdallowed,
627
                    hold_fulfillment_policy => $hold_fulfillment_policy,
628
                    bookings_lead_period    => $bookings_lead_period,
629
                    bookings_trail_period   => $bookings_trail_period,
630
                    returnbranch            => $returnbranch,
631
                }
632
            }
479
            }
633
        );
480
        }
634
    }
481
    );
635
} elsif ( $op eq 'cud-mod-refund-lost-item-fee-rule' ) {
482
} elsif ( $op eq 'cud-mod-refund-lost-item-fee-rule' ) {
636
483
637
    my $lostreturn = $input->param('lostreturn');
484
    my $lostreturn = $input->param('lostreturn');
638
- 

Return to bug 41268