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

(-)a/C4/Circulation.pm (-6 / +83 lines)
Lines 461-466 sub TooMany { Link Here
461
        }
461
        }
462
    );
462
    );
463
463
464
    my $maxissueqty_priority_rule = Koha::CirculationRules->get_effective_rule(
465
        {
466
            categorycode => $cat_borrower,
467
            itemtype     => $type,
468
            rule_name    => 'maxissueqty',
469
            has_priority => 1,
470
        }
471
    );
472
473
    my $maxonsiteissueqty_priority_rule = Koha::CirculationRules->get_effective_rule(
474
        {
475
            categorycode => $cat_borrower,
476
            itemtype     => $type,
477
            rule_name    => 'maxonsiteissueqty',
478
            has_priority => 1,
479
        }
480
    );
481
482
    # Override checkouts quantity rules if priority rules exist
483
    $maxissueqty_rule = $maxissueqty_priority_rule ? $maxissueqty_priority_rule : $maxissueqty_rule;
484
    $maxonsiteissueqty_rule = $maxonsiteissueqty_priority_rule ? $maxonsiteissueqty_priority_rule : $maxonsiteissueqty_rule;
485
486
    my $default_priority_no_branch_no_cat_patron_maxissueqty = Koha::CirculationRules->get_effective_rule(
487
        {
488
            rule_name    => 'patron_maxissueqty',
489
            has_priority => 1,
490
        }
491
    );
492
    my $default_priority_no_branch_patron_maxissueqty = Koha::CirculationRules->get_effective_rule(
493
        {
494
            categorycode => $cat_borrower,
495
            rule_name    => 'patron_maxissueqty',
496
            has_priority => 1,
497
        }
498
    );
499
500
    my $default_priority_patron_maxissueqty = $default_priority_no_branch_patron_maxissueqty // $default_priority_no_branch_no_cat_patron_maxissueqty;
501
502
    $maxissueqty_rule = $default_priority_patron_maxissueqty ? $default_priority_patron_maxissueqty : $maxissueqty_rule;
503
504
    my $default_priority_no_branch_no_cat_patron_maxonsiteissueqty = Koha::CirculationRules->get_effective_rule(
505
        {
506
            rule_name    => 'patron_maxonsiteissueqty',
507
            has_priority => 1,
508
        }
509
    );
510
    my $default_priority_no_branch_patron_maxonsiteissueqty = Koha::CirculationRules->get_effective_rule(
511
        {
512
            categorycode => $cat_borrower,
513
            rule_name    => 'patron_maxonsiteissueqty',
514
            has_priority => 1,
515
        }
516
    );
517
518
    my $default_priority_patron_maxonsiteissueqty = $default_priority_no_branch_patron_maxonsiteissueqty // $default_priority_no_branch_no_cat_patron_maxonsiteissueqty;
519
464
    # if a rule is found and has a loan limit set, count
520
    # if a rule is found and has a loan limit set, count
465
    # how many loans the patron already has that meet that
521
    # how many loans the patron already has that meet that
466
    # rule
522
    # rule
Lines 534-548 sub TooMany { Link Here
534
        my $checkout_count = $sum_checkouts->{total} || 0;
590
        my $checkout_count = $sum_checkouts->{total} || 0;
535
        my $onsite_checkout_count = $sum_checkouts->{onsite_checkouts} || 0;
591
        my $onsite_checkout_count = $sum_checkouts->{onsite_checkouts} || 0;
536
592
593
        my $max_checkouts_allowed;
594
        my $max_onsite_checkouts_allowed;
595
        my $circulation_rule;
596
        my $onsite_circulation_rule;
597
598
       if ( $default_priority_patron_maxissueqty && $default_priority_patron_maxissueqty->rule_value ne "" ) {
599
            $max_checkouts_allowed = $default_priority_patron_maxissueqty->rule_value;
600
            $circulation_rule      = $default_priority_patron_maxissueqty;
601
        } elsif ( $maxissueqty_rule && $maxissueqty_rule->rule_value ne "" ) {
602
            $max_checkouts_allowed = $maxissueqty_rule->rule_value;
603
            $circulation_rule      = $maxissueqty_rule;
604
        }
605
606
        if ( $default_priority_patron_maxonsiteissueqty && $default_priority_patron_maxonsiteissueqty->rule_value ne "" ) {
607
            $max_onsite_checkouts_allowed = $default_priority_patron_maxonsiteissueqty->rule_value;
608
            $onsite_circulation_rule      = $default_priority_patron_maxonsiteissueqty;
609
        } elsif ( $maxonsiteissueqty_rule && $maxonsiteissueqty_rule->rule_value ne "" ) {
610
            $max_onsite_checkouts_allowed = $maxonsiteissueqty_rule->rule_value;
611
            $onsite_circulation_rule      = $maxonsiteissueqty_rule;
612
        }
613
537
        my $checkout_rules = {
614
        my $checkout_rules = {
538
            checkout_count               => $checkout_count,
615
            checkout_count               => $checkout_count,
539
            onsite_checkout_count        => $onsite_checkout_count,
616
            onsite_checkout_count        => $onsite_checkout_count,
540
            onsite_checkout              => $onsite_checkout,
617
            onsite_checkout              => $onsite_checkout,
541
            max_checkouts_allowed        => $maxissueqty_rule ? $maxissueqty_rule->rule_value : undef,
618
            max_checkouts_allowed        => $max_checkouts_allowed,
542
            max_onsite_checkouts_allowed => $maxonsiteissueqty_rule ? $maxonsiteissueqty_rule->rule_value : undef,
619
            max_onsite_checkouts_allowed => $max_onsite_checkouts_allowed,
543
            switch_onsite_checkout       => $switch_onsite_checkout,
620
            switch_onsite_checkout       => $switch_onsite_checkout,
544
            circulation_rule             => $maxissueqty_rule,
621
            circulation_rule             => $circulation_rule,
545
            onsite_circulation_rule      => $maxonsiteissueqty_rule,
622
            onsite_circulation_rule      => $onsite_circulation_rule,
546
        };
623
        };
547
        # If parent rules exists
624
        # If parent rules exists
548
        if ( defined($parent_maxissueqty_rule) and defined($parent_maxissueqty_rule->rule_value) ){
625
        if ( defined($parent_maxissueqty_rule) and defined($parent_maxissueqty_rule->rule_value) ){
Lines 581-588 sub TooMany { Link Here
581
658
582
        my $checkout_count = $checkouts->count;
659
        my $checkout_count = $checkouts->count;
583
        my $onsite_checkout_count = $checkouts->search({ onsite_checkout => 1 })->count;
660
        my $onsite_checkout_count = $checkouts->search({ onsite_checkout => 1 })->count;
584
        my $max_checkouts_allowed = $branch_borrower_circ_rule->{patron_maxissueqty};
661
        my $max_checkouts_allowed = $default_priority_patron_maxissueqty->rule_value ? $default_priority_patron_maxissueqty->rule_value : $branch_borrower_circ_rule->{patron_maxissueqty};
585
        my $max_onsite_checkouts_allowed = $branch_borrower_circ_rule->{patron_maxonsiteissueqty} || undef;
662
        my $max_onsite_checkouts_allowed = $default_priority_patron_maxonsiteissueqty->rule_value ? $default_priority_patron_maxonsiteissueqty->rule_value : $branch_borrower_circ_rule->{patron_maxonsiteissueqty};
586
663
587
        my $qty_over = _check_max_qty(
664
        my $qty_over = _check_max_qty(
588
            {
665
            {
(-)a/Koha/CirculationRules.pm (-5 / +22 lines)
Lines 216-221 our $RULE_KINDS = { Link Here
216
    holds_pickup_period => {
216
    holds_pickup_period => {
217
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
217
        scope => [ 'branchcode', 'categorycode', 'itemtype' ],
218
    },
218
    },
219
    has_priority => {
220
        scope => [ 'branchcode', 'categorycode' ],
221
    },
219
    # Not included (deprecated?):
222
    # Not included (deprecated?):
220
    #   * accountsent
223
    #   * accountsent
221
    #   * reservecharge
224
    #   * reservecharge
Lines 248-258 sub get_effective_rule { Link Here
248
    $params->{categorycode} //= undef;
251
    $params->{categorycode} //= undef;
249
    $params->{branchcode}   //= undef;
252
    $params->{branchcode}   //= undef;
250
    $params->{itemtype}     //= undef;
253
    $params->{itemtype}     //= undef;
254
    $params->{has_priority} //= undef;
251
255
252
    my $rule_name    = $params->{rule_name};
256
    my $rule_name    = $params->{rule_name};
253
    my $categorycode = $params->{categorycode};
257
    my $categorycode = $params->{categorycode};
254
    my $itemtype     = $params->{itemtype};
258
    my $itemtype     = $params->{itemtype};
255
    my $branchcode   = $params->{branchcode};
259
    my $branchcode   = $params->{branchcode};
260
    my $has_priority = $params->{has_priority};
256
261
257
    Koha::Exceptions::MissingParameter->throw(
262
    Koha::Exceptions::MissingParameter->throw(
258
        "Required parameter 'rule_name' missing")
263
        "Required parameter 'rule_name' missing")
Lines 271-276 sub get_effective_rule { Link Here
271
    $search_params->{categorycode} = defined $categorycode ? [ $categorycode, undef ] : undef;
276
    $search_params->{categorycode} = defined $categorycode ? [ $categorycode, undef ] : undef;
272
    $search_params->{itemtype}     = defined $itemtype     ? [ $itemtype, undef ] : undef;
277
    $search_params->{itemtype}     = defined $itemtype     ? [ $itemtype, undef ] : undef;
273
    $search_params->{branchcode}   = defined $branchcode   ? [ $branchcode,   undef ] : undef;
278
    $search_params->{branchcode}   = defined $branchcode   ? [ $branchcode,   undef ] : undef;
279
    $search_params->{has_priority} = defined $has_priority ? $has_priority : 0;
274
280
275
    my $rule = $self->search(
281
    my $rule = $self->search(
276
        $search_params,
282
        $search_params,
Lines 308-317 sub get_effective_rule_value { Link Here
308
    my $categorycode = $params->{categorycode};
314
    my $categorycode = $params->{categorycode};
309
    my $itemtype     = $params->{itemtype};
315
    my $itemtype     = $params->{itemtype};
310
    my $branchcode   = $params->{branchcode};
316
    my $branchcode   = $params->{branchcode};
311
317
    my $has_priority = $params->{has_priority};
312
    my $memory_cache = Koha::Cache::Memory::Lite->get_instance;
318
    my $memory_cache = Koha::Cache::Memory::Lite->get_instance;
313
    my $cache_key = sprintf "CircRules:%s:%s:%s:%s", $rule_name // q{},
319
    my $cache_key = sprintf "CircRules:%s:%s:%s:%s", $rule_name // q{},
314
      $categorycode // q{}, $branchcode // q{}, $itemtype // q{};
320
      $categorycode // q{}, $branchcode // q{}, $itemtype // q{} ,$has_priority // q{};
315
321
316
    my $cached       = $memory_cache->get_from_cache($cache_key);
322
    my $cached       = $memory_cache->get_from_cache($cache_key);
317
    return $cached if $cached;
323
    return $cached if $cached;
Lines 334-339 sub get_effective_rules { Link Here
334
    my $categorycode = $params->{categorycode};
340
    my $categorycode = $params->{categorycode};
335
    my $itemtype     = $params->{itemtype};
341
    my $itemtype     = $params->{itemtype};
336
    my $branchcode   = $params->{branchcode};
342
    my $branchcode   = $params->{branchcode};
343
    my $has_priority = $params->{has_priority};
337
344
338
    my $r;
345
    my $r;
339
    foreach my $rule (@$rules) {
346
    foreach my $rule (@$rules) {
Lines 343-348 sub get_effective_rules { Link Here
343
                categorycode => $categorycode,
350
                categorycode => $categorycode,
344
                itemtype     => $itemtype,
351
                itemtype     => $itemtype,
345
                branchcode   => $branchcode,
352
                branchcode   => $branchcode,
353
                has_priority => $has_priority,
346
            }
354
            }
347
        );
355
        );
348
356
Lines 386-391 sub set_rule { Link Here
386
    my $itemtype     = $params->{itemtype};
394
    my $itemtype     = $params->{itemtype};
387
    my $rule_name    = $params->{rule_name};
395
    my $rule_name    = $params->{rule_name};
388
    my $rule_value   = $params->{rule_value};
396
    my $rule_value   = $params->{rule_value};
397
    my $has_priority = $params->{has_priority};
398
389
    my $can_be_blank = defined $kind_info->{can_be_blank} ? $kind_info->{can_be_blank} : 1;
399
    my $can_be_blank = defined $kind_info->{can_be_blank} ? $kind_info->{can_be_blank} : 1;
390
    $rule_value = undef if defined $rule_value && $rule_value eq "" && !$can_be_blank;
400
    $rule_value = undef if defined $rule_value && $rule_value eq "" && !$can_be_blank;
391
    my $is_monetary = defined $kind_info->{is_monetary} ? $kind_info->{is_monetary} : 0;
401
    my $is_monetary = defined $kind_info->{is_monetary} ? $kind_info->{is_monetary} : 0;
Lines 407-412 sub set_rule { Link Here
407
    if ($rule) {
417
    if ($rule) {
408
        if ( defined $rule_value ) {
418
        if ( defined $rule_value ) {
409
            $rule->rule_value($rule_value);
419
            $rule->rule_value($rule_value);
420
            $rule->has_priority($has_priority);
410
            $rule->update();
421
            $rule->update();
411
        }
422
        }
412
        else {
423
        else {
Lines 422-427 sub set_rule { Link Here
422
                    itemtype     => $itemtype,
433
                    itemtype     => $itemtype,
423
                    rule_name    => $rule_name,
434
                    rule_name    => $rule_name,
424
                    rule_value   => $rule_value,
435
                    rule_value   => $rule_value,
436
                    has_priority => $has_priority,
425
                }
437
                }
426
            );
438
            );
427
            $rule->store();
439
            $rule->store();
Lines 444-453 sub set_rules { Link Here
444
    my ( $self, $params ) = @_;
456
    my ( $self, $params ) = @_;
445
457
446
    my %set_params;
458
    my %set_params;
447
    $set_params{branchcode} = $params->{branchcode} if exists $params->{branchcode};
459
    $set_params{branchcode} = $params->{branchcode}
448
    $set_params{categorycode} = $params->{categorycode} if exists $params->{categorycode};
460
      if exists $params->{branchcode};
461
    $set_params{categorycode} = $params->{categorycode}
462
      if exists $params->{categorycode};
449
    $set_params{itemtype} = $params->{itemtype} if exists $params->{itemtype};
463
    $set_params{itemtype} = $params->{itemtype} if exists $params->{itemtype};
450
    my $rules        = $params->{rules};
464
    $set_params{has_priority} = $params->{has_priority}
465
      if exists $params->{has_priority};
466
    my $rules = $params->{rules};
467
451
468
452
    my $rule_objects = [];
469
    my $rule_objects = [];
453
    while ( my ( $rule_name, $rule_value ) = each %$rules ) {
470
    while ( my ( $rule_name, $rule_value ) = each %$rules ) {
(-)a/admin/smart-rules.pl (-5 / +49 lines)
Lines 130-141 elsif ($op eq 'cud-delete-branch-cat') { Link Here
130
                    branchcode   => undef,
130
                    branchcode   => undef,
131
                    categorycode => undef,
131
                    categorycode => undef,
132
                    rules        => {
132
                    rules        => {
133
                        max_holds                      => undef,
133
                        has_priority                   => undef,
134
                        patron_maxissueqty             => undef,
134
                        patron_maxissueqty             => undef,
135
                        patron_maxonsiteissueqty       => undef,
135
                        patron_maxonsiteissueqty       => undef,
136
                    }
136
                    }
137
                }
137
                }
138
            );
138
            );
139
            Koha::CirculationRules->set_rules(
140
                {
141
                    branchcode   => undef,
142
                    categorycode => undef,
143
                    rules        => {
144
                        max_holds => undef,
145
                    }
146
                }
147
            );
139
            Koha::CirculationRules->set_rules(
148
            Koha::CirculationRules->set_rules(
140
                {
149
                {
141
                    branchcode   => undef,
150
                    branchcode   => undef,
Lines 153-164 elsif ($op eq 'cud-delete-branch-cat') { Link Here
153
                    categorycode => $categorycode,
162
                    categorycode => $categorycode,
154
                    branchcode   => undef,
163
                    branchcode   => undef,
155
                    rules        => {
164
                    rules        => {
156
                        max_holds                => undef,
165
                        has_priority             => undef,
157
                        patron_maxissueqty       => undef,
166
                        patron_maxissueqty       => undef,
158
                        patron_maxonsiteissueqty => undef,
167
                        patron_maxonsiteissueqty => undef,
159
                    }
168
                    }
160
                }
169
                }
161
            );
170
            );
171
            Koha::CirculationRules->set_rules(
172
                {
173
                    categorycode => $categorycode,
174
                    branchcode   => undef,
175
                    rules        => {
176
                        max_holds                => undef,
177
                    }
178
                }
179
            );
162
        }
180
        }
163
    } elsif ($categorycode eq "*") {
181
    } elsif ($categorycode eq "*") {
164
        Koha::CirculationRules->set_rules(
182
        Koha::CirculationRules->set_rules(
Lines 302-311 elsif ( $op eq 'cud-add' ) { Link Here
302
    my $recall_overdue_fine           = $input->param('recall_overdue_fine');
320
    my $recall_overdue_fine           = $input->param('recall_overdue_fine');
303
    my $recall_shelf_time             = $input->param('recall_shelf_time');
321
    my $recall_shelf_time             = $input->param('recall_shelf_time');
304
    my $holds_pickup_period           = strip_non_numeric( scalar $input->param('holds_pickup_period') );
322
    my $holds_pickup_period           = strip_non_numeric( scalar $input->param('holds_pickup_period') );
323
    my $has_priority                  = $input->param('has_priority_rule') ? 1 : 0;
305
324
306
    my $rules = {
325
    my $checkout_rules = {
307
        maxissueqty                      => $maxissueqty,
326
        maxissueqty                      => $maxissueqty,
308
        maxonsiteissueqty                => $maxonsiteissueqty,
327
        maxonsiteissueqty                => $maxonsiteissueqty,
328
    };
329
330
    my $rules = {
309
        rentaldiscount                   => $rentaldiscount,
331
        rentaldiscount                   => $rentaldiscount,
310
        fine                             => $fine,
332
        fine                             => $fine,
311
        finedays                         => $finedays,
333
        finedays                         => $finedays,
Lines 355-360 elsif ( $op eq 'cud-add' ) { Link Here
355
        }
377
        }
356
    );
378
    );
357
379
380
    Koha::CirculationRules->set_rules(
381
        {
382
            categorycode => $bor eq '*'      ? undef : $bor,
383
            itemtype     => $itemtype eq '*' ? undef : $itemtype,
384
            branchcode   => $br eq '*'       ? undef : $br,
385
            rules        => $checkout_rules,
386
            has_priority => $has_priority,
387
        }
388
    );
389
358
}
390
}
359
elsif ($op eq "cud-set-branch-defaults") {
391
elsif ($op eq "cud-set-branch-defaults") {
360
    my $categorycode  = $input->param('categorycode');
392
    my $categorycode  = $input->param('categorycode');
Lines 365-370 elsif ($op eq "cud-set-branch-defaults") { Link Here
365
    my $hold_fulfillment_policy = $input->param('hold_fulfillment_policy');
397
    my $hold_fulfillment_policy = $input->param('hold_fulfillment_policy');
366
    my $returnbranch  = $input->param('returnbranch');
398
    my $returnbranch  = $input->param('returnbranch');
367
    my $max_holds = strip_non_numeric( scalar $input->param('max_holds') );
399
    my $max_holds = strip_non_numeric( scalar $input->param('max_holds') );
400
    my $has_priority = $input->param('has_priority_defaults') ? 1 : 0;
368
401
369
    if ($branch eq "*") {
402
    if ($branch eq "*") {
370
        Koha::CirculationRules->set_rules(
403
        Koha::CirculationRules->set_rules(
Lines 382-387 elsif ($op eq "cud-set-branch-defaults") { Link Here
382
            {
415
            {
383
                categorycode => undef,
416
                categorycode => undef,
384
                branchcode   => undef,
417
                branchcode   => undef,
418
                has_priority => $has_priority,
385
                rules        => {
419
                rules        => {
386
                    patron_maxissueqty             => $patron_maxissueqty,
420
                    patron_maxissueqty             => $patron_maxissueqty,
387
                    patron_maxonsiteissueqty       => $patron_maxonsiteissueqty,
421
                    patron_maxonsiteissueqty       => $patron_maxonsiteissueqty,
Lines 404-409 elsif ($op eq "cud-set-branch-defaults") { Link Here
404
            {
438
            {
405
                categorycode => undef,
439
                categorycode => undef,
406
                branchcode   => $branch,
440
                branchcode   => $branch,
441
                has_priority => $has_priority,
407
                rules        => {
442
                rules        => {
408
                    patron_maxissueqty             => $patron_maxissueqty,
443
                    patron_maxissueqty             => $patron_maxissueqty,
409
                    patron_maxonsiteissueqty       => $patron_maxonsiteissueqty,
444
                    patron_maxonsiteissueqty       => $patron_maxonsiteissueqty,
Lines 427-432 elsif ($op eq "cud-add-branch-cat") { Link Here
427
    $patron_maxonsiteissueqty = strip_non_numeric($patron_maxonsiteissueqty);
462
    $patron_maxonsiteissueqty = strip_non_numeric($patron_maxonsiteissueqty);
428
    my $max_holds = $input->param('max_holds');
463
    my $max_holds = $input->param('max_holds');
429
    $max_holds = strip_non_numeric($max_holds);
464
    $max_holds = strip_non_numeric($max_holds);
465
    my $has_priority = $input->param('has_priority_by_cat') ? 1 : 0;
430
466
431
    if ($branch eq "*") {
467
    if ($branch eq "*") {
432
        if ($categorycode eq "*") {
468
        if ($categorycode eq "*") {
Lines 447-453 elsif ($op eq "cud-add-branch-cat") { Link Here
447
                    categorycode => $categorycode,
483
                    categorycode => $categorycode,
448
                    branchcode   => undef,
484
                    branchcode   => undef,
449
                    rules        => {
485
                    rules        => {
450
                        max_holds         => $max_holds,
486
                        max_holds => $max_holds,
487
                    }
488
                }
489
            );
490
            Koha::CirculationRules->set_rules(
491
                {
492
                    categorycode => $categorycode,
493
                    branchcode   => undef,
494
                    has_priority => $has_priority,
495
                    rules        => {
451
                        patron_maxissueqty       => $patron_maxissueqty,
496
                        patron_maxissueqty       => $patron_maxissueqty,
452
                        patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
497
                        patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
453
                    }
498
                    }
Lines 758-764 while ( my $r = $all_rules->next ) { Link Here
758
}
803
}
759
804
760
$template->param(show_branch_cat_rule_form => 1);
805
$template->param(show_branch_cat_rule_form => 1);
761
762
$template->param(
806
$template->param(
763
    used_categorycodes => \@used_categorycodes,
807
    used_categorycodes => \@used_categorycodes,
764
    used_itemtypes     => \@used_itemtypes,
808
    used_itemtypes     => \@used_itemtypes,
(-)a/installer/data/mysql/atomicupdate/Bug_8137-add-column-has_priority.pl (+13 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number  => "8137",
5
    description => "Add column has_priority",
6
    up          => sub {
7
        my ($args) = @_;
8
        my ( $dbh, $out ) = @$args{qw(dbh out)};
9
10
        $dbh->do('ALTER TABLE circulation_rules ADD IF NOT EXISTS has_priority INT(1) DEFAULT 0');
11
        say $out "Added column 'has_priority'";
12
    },
13
};
(-)a/installer/data/mysql/kohastructure.sql (+1 lines)
Lines 1863-1868 CREATE TABLE `circulation_rules` ( Link Here
1863
  `itemtype` varchar(10) DEFAULT NULL,
1863
  `itemtype` varchar(10) DEFAULT NULL,
1864
  `rule_name` varchar(32) NOT NULL,
1864
  `rule_name` varchar(32) NOT NULL,
1865
  `rule_value` varchar(32) NOT NULL,
1865
  `rule_value` varchar(32) NOT NULL,
1866
  `has_priority` tinyint(4) DEFAULT NULL,
1866
  PRIMARY KEY (`id`),
1867
  PRIMARY KEY (`id`),
1867
  UNIQUE KEY `branchcode` (`branchcode`,`categorycode`,`itemtype`,`rule_name`),
1868
  UNIQUE KEY `branchcode` (`branchcode`,`categorycode`,`itemtype`,`rule_name`),
1868
  KEY `circ_rules_ibfk_2` (`categorycode`),
1869
  KEY `circ_rules_ibfk_2` (`categorycode`),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-18 / +48 lines)
Lines 113-118 Link Here
113
                            <th>Note</th>
113
                            <th>Note</th>
114
                            <th>Current checkouts allowed</th>
114
                            <th>Current checkouts allowed</th>
115
                            <th>Current on-site checkouts allowed</th>
115
                            <th>Current on-site checkouts allowed</th>
116
                            <th class="hasPriority">Priority checkouts rule</th>
116
                            <th>Loan period</th>
117
                            <th>Loan period</th>
117
                            <th>Days mode</th>
118
                            <th>Days mode</th>
118
                            <th>Unit</th>
119
                            <th>Unit</th>
Lines 167-172 Link Here
167
                                    [% SET note = all_rules.$c.$i.note %]
168
                                    [% SET note = all_rules.$c.$i.note %]
168
                                    [% SET maxissueqty = all_rules.$c.$i.maxissueqty %]
169
                                    [% SET maxissueqty = all_rules.$c.$i.maxissueqty %]
169
                                    [% SET maxonsiteissueqty = all_rules.$c.$i.maxonsiteissueqty %]
170
                                    [% SET maxonsiteissueqty = all_rules.$c.$i.maxonsiteissueqty %]
171
                                    [% SET maxissueqty = CirculationRules.Search( current_branch, c, i, 'maxissueqty', { want_rule => 1 } ) %]
172
                                    [% SET maxonsiteissueqty = CirculationRules.Search( current_branch, c, i, 'maxonsiteissueqty', { want_rule => 1 } ) %]
170
                                    [% SET issuelength = all_rules.$c.$i.issuelength %]
173
                                    [% SET issuelength = all_rules.$c.$i.issuelength %]
171
                                    [% SET daysmode = all_rules.$c.$i.daysmode %]
174
                                    [% SET daysmode = all_rules.$c.$i.daysmode %]
172
                                    [% SET lengthunit = all_rules.$c.$i.lengthunit %]
175
                                    [% SET lengthunit = all_rules.$c.$i.lengthunit %]
Lines 204-211 Link Here
204
                                    [% SET recall_overdue_fine = all_rules.$c.$i.recall_overdue_fine %]
207
                                    [% SET recall_overdue_fine = all_rules.$c.$i.recall_overdue_fine %]
205
                                    [% SET recall_shelf_time = all_rules.$c.$i.recall_shelf_time %]
208
                                    [% SET recall_shelf_time = all_rules.$c.$i.recall_shelf_time %]
206
                                    [% SET holds_pickup_period = all_rules.$c.$i.holds_pickup_period %]
209
                                    [% SET holds_pickup_period = all_rules.$c.$i.holds_pickup_period %]
210
                                    [% SET has_priority_rule = maxissueqty.has_priority && maxonsiteissueqty.has_priority %]
207
211
208
                                    [% SET show_rule = note || maxissueqty || maxonsiteissueqty || issuelength || daysmode || lengthunit || hardduedate || hardduedatecompare || fine || chargeperiod || chargeperiod_charge_at || firstremind || overduefinescap || cap_fine_to_replacement_price || finedays || maxsuspensiondays || suspension_chargeperiod || renewalsallowed || unseenrenewalsallowed || renewalperiod || norenewalbefore || noautorenewalbefore || auto_renew || no_auto_renewal_after || no_auto_renewal_after_hard_limit || reservesallowed || holds_per_day || holds_per_record || onshelfholds || opacitemholds || article_requests || rentaldiscount || decreaseloanholds || recalls_allowed || recalls_per_record || on_shelf_recalls || recall_due_date_interval || recall_overdue_fine || recall_shelf_time || holds_pickup_period %]
212
                                    [% SET show_rule = note || maxissueqty.rule_value || maxonsiteissueqty.rule_value || issuelength || daysmode || lengthunit || hardduedate || hardduedatecompare || fine || chargeperiod || chargeperiod_charge_at || firstremind || overduefinescap || cap_fine_to_replacement_price || finedays || maxsuspensiondays || suspension_chargeperiod || renewalsallowed || unseenrenewalsallowed || renewalperiod || norenewalbefore || noautorenewalbefore || auto_renew || no_auto_renewal_after || no_auto_renewal_after_hard_limit || reservesallowed || holds_per_day || holds_per_record || onshelfholds || opacitemholds || article_requests || rentaldiscount || decreaseloanholds || recalls_allowed || recalls_per_record || on_shelf_recalls || recall_due_date_interval || recall_overdue_fine || recall_shelf_time || holds_pickup_period %]
209
                                    [% IF show_rule %]
213
                                    [% IF show_rule %]
210
                                        [% SET row_count = row_count + 1 %]
214
                                        [% SET row_count = row_count + 1 %]
211
                                        <tr row_countd="row_[% row_count | html %]">
215
                                        <tr row_countd="row_[% row_count | html %]">
Lines 243-261 Link Here
243
                                                    [% ELSE %]<span>&nbsp;</span>[% END %]
247
                                                    [% ELSE %]<span>&nbsp;</span>[% END %]
244
                                                </td>
248
                                                </td>
245
                                                <td>
249
                                                <td>
246
                                                    [% IF maxissueqty.defined && maxissueqty != '' %]
250
                                                    [% IF maxissueqty.rule_value && maxissueqty.rule_value != '' %]
247
                                                        [% maxissueqty | html %]
251
                                                        [% maxissueqty.rule_value | html %]
248
                                                    [% ELSE %]
252
                                                    [% ELSE %]
249
                                                        <span>Unlimited</span>
253
                                                        <span>Unlimited</span>
250
                                                    [% END %]
254
                                                    [% END %]
251
                                                </td>
255
                                                </td>
252
                                                <td>
256
                                                <td>
253
                                                    [% IF maxonsiteissueqty.defined && maxonsiteissueqty != ''  %]
257
                                                    [% IF maxonsiteissueqty.rule_value && maxonsiteissueqty.rule_value != ''  %]
254
                                                        [% maxonsiteissueqty | html %]
258
                                                        [% maxonsiteissueqty.rule_value | html %]
255
                                                    [% ELSE %]
259
                                                    [% ELSE %]
256
                                                        <span>Unlimited</span>
260
                                                        <span>Unlimited</span>
257
                                                    [% END %]
261
                                                    [% END %]
258
                                                </td>
262
                                                </td>
263
                                                <td class="hasPriority">
264
                                                    <input type="checkbox" name="has_priority_rule" [% IF has_priority_rule %]checked="checked"[% END %] disabled/>
265
                                                </td>
259
                                                <td>[% issuelength | html %]</td>
266
                                                <td>[% issuelength | html %]</td>
260
                                                <td data-code="[% daysmode | html %]">
267
                                                <td data-code="[% daysmode | html %]">
261
                                                    [% SWITCH daysmode %]
268
                                                    [% SWITCH daysmode %]
Lines 446-451 Link Here
446
                                <td><input type="text" name="note" id="note" size="15" value="" maxlength="100"></td>
453
                                <td><input type="text" name="note" id="note" size="15" value="" maxlength="100"></td>
447
                                <td><input type="text" name="maxissueqty" id="maxissueqty" size="3" /></td>
454
                                <td><input type="text" name="maxissueqty" id="maxissueqty" size="3" /></td>
448
                                <td><input type="text" name="maxonsiteissueqty" id="maxonsiteissueqty" size="3" /></td>
455
                                <td><input type="text" name="maxonsiteissueqty" id="maxonsiteissueqty" size="3" /></td>
456
                                <td class="hasPriority">
457
                                    <input type="checkbox" name="has_priority_rule"/>
458
                                </td>
449
                                <td><input type="text" name="issuelength" id="issuelength" size="3" /> </td>
459
                                <td><input type="text" name="issuelength" id="issuelength" size="3" /> </td>
450
                                <td>
460
                                <td>
451
                                    <select name="daysmode" id="daysmode">
461
                                    <select name="daysmode" id="daysmode">
Lines 563-568 Link Here
563
                                  <th>Note</th>
573
                                  <th>Note</th>
564
                                  <th>Current checkouts allowed</th>
574
                                  <th>Current checkouts allowed</th>
565
                                  <th>Current on-site checkouts allowed</th>
575
                                  <th>Current on-site checkouts allowed</th>
576
                                  <th class="hasPriority">Priority checkouts rule</th>
566
                                  <th>Loan period</th>
577
                                  <th>Loan period</th>
567
                                  <th>Days mode</th>
578
                                  <th>Days mode</th>
568
                                  <th>Unit</th>
579
                                  <th>Unit</th>
Lines 622-627 Link Here
622
                        <table>
633
                        <table>
623
                            <tr>
634
                            <tr>
624
                                <th>&nbsp;</th>
635
                                <th>&nbsp;</th>
636
                                <th class="hasPriority">Priority checkouts rule</th>
625
                                <th>Total current checkouts allowed</th>
637
                                <th>Total current checkouts allowed</th>
626
                                <th>Total current on-site checkouts allowed</th>
638
                                <th>Total current on-site checkouts allowed</th>
627
                                <th>Maximum total holds allowed (count)</th>
639
                                <th>Maximum total holds allowed (count)</th>
Lines 637-642 Link Here
637
                            [% SET hold_fulfillment_policy = CirculationRules.Search( current_branch, undef, undef, 'hold_fulfillment_policy', { want_rule => 1 }) %]
649
                            [% SET hold_fulfillment_policy = CirculationRules.Search( current_branch, undef, undef, 'hold_fulfillment_policy', { want_rule => 1 }) %]
638
                            [% SET returnbranch = CirculationRules.Search( current_branch, undef, undef, 'returnbranch', { want_rule => 1 }) %]
650
                            [% SET returnbranch = CirculationRules.Search( current_branch, undef, undef, 'returnbranch', { want_rule => 1 }) %]
639
                            [% SET default_checkout_hold_and_return_policy = ( patron_maxissueqty || patron_maxonsiteissueqty || rule_value || holdallowed || hold_fulfillment_policy || returnbranch ) %]
651
                            [% SET default_checkout_hold_and_return_policy = ( patron_maxissueqty || patron_maxonsiteissueqty || rule_value || holdallowed || hold_fulfillment_policy || returnbranch ) %]
652
                            [% SET has_priority_defaults = patron_maxissueqty.has_priority && patron_maxonsiteissueqty.has_priority %]
640
                            <tr>
653
                            <tr>
641
                                <td>
654
                                <td>
642
                                    [% IF ( default_checkout_hold_and_return_policy ) %]
655
                                    [% IF ( default_checkout_hold_and_return_policy ) %]
Lines 647-652 Link Here
647
                                        Not set
660
                                        Not set
648
                                    [% END %]
661
                                    [% END %]
649
                                </td>
662
                                </td>
663
                                <td class="hasPriority">
664
                                    <input type="checkbox" name="has_priority_defaults" [% IF has_priority_defaults %]checked="checked"[% END %]/>
665
                                </td>
650
                                <td>
666
                                <td>
651
                                    <input type="text" name="patron_maxissueqty" size="9" value="[% patron_maxissueqty.rule_value | html %]" placeholder="Unlimited"/>
667
                                    <input type="text" name="patron_maxissueqty" size="9" value="[% patron_maxissueqty.rule_value | html %]" placeholder="Unlimited"/>
652
                                </td>
668
                                </td>
Lines 817-822 Link Here
817
                        <table>
833
                        <table>
818
                            <tr>
834
                            <tr>
819
                                <th>Patron category</th>
835
                                <th>Patron category</th>
836
                                <th class="hasPriority">Priority checkouts rule</th>
820
                                <th>Total current checkouts allowed</th>
837
                                <th>Total current checkouts allowed</th>
821
                                <th>Total current on-site checkouts allowed</th>
838
                                <th>Total current on-site checkouts allowed</th>
822
                                <th>Total holds allowed</th>
839
                                <th>Total holds allowed</th>
Lines 825-835 Link Here
825
                            [% FOREACH c IN categorycodes %]
842
                            [% FOREACH c IN categorycodes %]
826
                                [% NEXT UNLESS c %]
843
                                [% NEXT UNLESS c %]
827
                                [% SET i = undef %]
844
                                [% SET i = undef %]
828
                                [% SET patron_maxissueqty = all_rules.$c.$i.patron_maxissueqty %]
845
                                [% SET patron_maxissueqty = CirculationRules.Search( current_branch, c, undef, 'patron_maxissueqty', { want_rule => 1 } ) %]
829
                                [% SET patron_maxonsiteissueqty = all_rules.$c.$i.patron_maxonsiteissueqty %]
846
                                [% SET patron_maxonsiteissueqty = CirculationRules.Search( current_branch, c, undef, 'patron_maxonsiteissueqty', { want_rule => 1 } ) %]
830
                                [% SET max_holds = all_rules.$c.$i.max_holds %]
847
                                [% SET max_holds = CirculationRules.Search( current_branch, c, undef, 'max_holds', { want_rule => 1 } ) %]
831
848
                                [% SET has_priority_by_cat = patron_maxissueqty.has_priority && patron_maxonsiteissueqty.has_priority %]
832
                                [% IF  ( patron_maxissueqty.defined && patron_maxissueqty != '' ) || ( patron_maxonsiteissueqty.defined && patron_maxonsiteissueqty != '' ) || ( max_holds.defined && max_holds != '' ) %]
849
                                [% IF  ( patron_maxissueqty.rule_value && patron_maxissueqty.rule_value != '' ) || ( patron_maxonsiteissueqty.rule_value && patron_maxonsiteissueqty.rule_value != '' ) || ( max_holds.rule_value && max_holds.rule_value != '' ) %]
833
                                <tr>
850
                                <tr>
834
                                    <td>
851
                                    <td>
835
                                        [% IF c == undef %]
852
                                        [% IF c == undef %]
Lines 838-865 Link Here
838
                                            [% Categories.GetName(c) | html %]
855
                                            [% Categories.GetName(c) | html %]
839
                                        [% END %]
856
                                        [% END %]
840
                                    </td>
857
                                    </td>
858
                                    <td class="hasPriority">
859
                                        <input type="checkbox" name="has_priority_by_cat" [% IF has_priority_by_cat %]checked="checked"[% END %] disabled/>
860
                                    </td>
841
                                    <td>
861
                                    <td>
842
                                        [% IF patron_maxissueqty.defined && patron_maxissueqty != '' %]
862
                                        [% IF patron_maxissueqty.rule_value && patron_maxissueqty.rule_value != '' %]
843
                                            [% patron_maxissueqty | html %]
863
                                            [% patron_maxissueqty.rule_value | html %]
844
                                        [% ELSE %]
864
                                        [% ELSE %]
845
                                            <span>Unlimited</span>
865
                                            <span>Unlimited</span>
846
                                        [% END %]
866
                                        [% END %]
847
                                    </td>
867
                                    </td>
848
                                    <td>
868
                                    <td>
849
                                        [% IF patron_maxonsiteissueqty.defined && patron_maxonsiteissueqty != '' %]
869
                                        [% IF patron_maxonsiteissueqty.rule_value && patron_maxonsiteissueqty.rule_value != '' %]
850
                                            [% patron_maxonsiteissueqty | html %]
870
                                            [% patron_maxonsiteissueqty.rule_value | html %]
851
                                        [% ELSE %]
871
                                        [% ELSE %]
852
                                            <span>Unlimited</span>
872
                                            <span>Unlimited</span>
853
                                        [% END %]
873
                                        [% END %]
854
                                    </td>
874
                                    </td>
855
                                    <td>
875
                                    <td>
856
                                        [% IF max_holds.defined && max_holds != '' %]
876
                                        [% IF max_holds.rule_value && max_holds.rule_value != '' %]
857
                                            [% max_holds | html %]
877
                                            [% max_holds.rule_value | html %]
858
                                        [% ELSE %]
878
                                        [% ELSE %]
859
                                            <span>Unlimited</span>
879
                                            <span>Unlimited</span>
860
                                        [% END %]
880
                                        [% END %]
861
                                    </td>
881
                                    </td>
862
863
                                    <td class="actions">
882
                                    <td class="actions">
864
                                        <a href="#" class="delete-branch-cat btn btn-default btn-xs" data-categorycode="[% c | html %]" data-branch="[% current_branch | html %]"><i class="fa fa-trash-can"></i> Delete</a>
883
                                        <a href="#" class="delete-branch-cat btn btn-default btn-xs" data-categorycode="[% c | html %]" data-branch="[% current_branch | html %]"><i class="fa fa-trash-can"></i> Delete</a>
865
                                    </td>
884
                                    </td>
Lines 874-879 Link Here
874
                                    [% END %]
893
                                    [% END %]
875
                                    </select>
894
                                    </select>
876
                                </td>
895
                                </td>
896
                                <td class="hasPriority">
897
                                    <input type="checkbox" name="has_priority_by_cat"/>
898
                                </td>
877
                                <td><input name="patron_maxissueqty" size="3" type="text" /></td>
899
                                <td><input name="patron_maxissueqty" size="3" type="text" /></td>
878
                                <td><input name="patron_maxonsiteissueqty" size="3" type="text" /></td>
900
                                <td><input name="patron_maxonsiteissueqty" size="3" type="text" /></td>
879
                                <td><input name="max_holds" size="3" type="text" /></td>
901
                                <td><input name="max_holds" size="3" type="text" /></td>
Lines 1577-1582 Link Here
1577
                                $(current_column).find("input[type='text']").val("");
1599
                                $(current_column).find("input[type='text']").val("");
1578
                            }
1600
                            }
1579
                        }
1601
                        }
1602
                        if($(current_column).hasClass('hasPriority')) {
1603
                            var has_priority_rule_checked = $(this).children("input[type='checkbox']").prop('checked');
1604
                            $(current_column).children("input[name='has_priority_rule']").prop('checked', has_priority_rule_checked);
1605
                        }
1580
                    }
1606
                    }
1581
                });
1607
                });
1582
                $("#default-circulation-rules tr:last td:eq(0) select").prop('disabled', true);
1608
                $("#default-circulation-rules tr:last td:eq(0) select").prop('disabled', true);
Lines 1678-1683 Link Here
1678
                return f.submit();
1704
                return f.submit();
1679
            });
1705
            });
1680
1706
1707
            if($("#branch").val() != '*') {
1708
                $(".hasPriority").each(function() {
1709
                    $(this).remove();
1710
                });
1711
            }
1681
        });
1712
        });
1682
    </script>
1713
    </script>
1683
[% END %]
1714
[% END %]
1684
- 

Return to bug 8137