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

(-)a/admin/smart-rules.pl (-30 / +207 lines)
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);
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-35 / +49 lines)
Lines 91-103 Link Here
91
            <thead>
91
            <thead>
92
            <tr>
92
            <tr>
93
                <th>&nbsp;</th>
93
                <th>&nbsp;</th>
94
                <th class="fixed_sort">On-site checkout</th>
94
                <th class="fixed_sort">Patron category</th>
95
                <th class="fixed_sort">Patron category</th>
95
                <th>&nbsp;</th>
96
                <th>&nbsp;</th>
96
                <th class="fixed_sort">Item type</th>
97
                <th class="fixed_sort">Item type</th>
97
                <th>Actions</th>
98
                <th>Actions</th>
98
                <th>Note</th>
99
                <th>Note</th>
99
                <th>Current checkouts allowed</th>
100
                <th>Current checkouts allowed</th>
100
                <th>Current on-site checkouts allowed</th>
101
                <th>Loan period</th>
101
                <th>Loan period</th>
102
                <th>Days mode</th>
102
                <th>Days mode</th>
103
                <th>Unit</th>
103
                <th>Unit</th>
Lines 133-145 Link Here
133
            </thead>
133
            </thead>
134
            <tbody>
134
            <tbody>
135
                [% SET row_count = 0 %]
135
                [% SET row_count = 0 %]
136
                [% FOREACH osc IN [ undef, 0, 1 ] %]
136
                [% FOREACH c IN categorycodes %]
137
                [% FOREACH c IN categorycodes %]
137
                    [% SET c = '' UNLESS c.defined %]
138
                    [% SET c = '' UNLESS c.defined %]
138
                    [% FOREACH i IN itemtypes %]
139
                    [% FOREACH i IN itemtypes %]
139
                        [% SET i = '' UNLESS i.defined %]
140
                        [% SET i = '' UNLESS i.defined %]
141
                        [% SET osc = '' UNLESS osc.defined %]
140
                        [% SET note = all_rules.$c.$i.note %]
142
                        [% SET note = all_rules.$c.$i.note %]
141
                        [% SET maxissueqty = all_rules.$c.$i.maxissueqty %]
143
                        [% SET maxissueqty = all_rules.$c.$i.maxissueqty %]
142
                        [% SET maxonsiteissueqty = all_rules.$c.$i.maxonsiteissueqty %]
143
                        [% SET issuelength = all_rules.$c.$i.issuelength %]
144
                        [% SET issuelength = all_rules.$c.$i.issuelength %]
144
                        [% SET daysmode = all_rules.$c.$i.daysmode %]
145
                        [% SET daysmode = all_rules.$c.$i.daysmode %]
145
                        [% SET lengthunit = all_rules.$c.$i.lengthunit %]
146
                        [% SET lengthunit = all_rules.$c.$i.lengthunit %]
Lines 170-180 Link Here
170
                        [% SET rentaldiscount = all_rules.$c.$i.rentaldiscount %]
171
                        [% SET rentaldiscount = all_rules.$c.$i.rentaldiscount %]
171
                        [% SET decreaseloanholds = all_rules.$c.$i.decreaseloanholds %]
172
                        [% SET decreaseloanholds = all_rules.$c.$i.decreaseloanholds %]
172
173
173
                        [% 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 || 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 %]
174
                        [% SET show_rule = note || maxissueqty || 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 || 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 %]
174
                        [% IF show_rule %]
175
                        [% IF show_rule %]
175
                            [% SET row_count = row_count + 1 %]
176
                            [% SET row_count = row_count + 1 %]
176
                            <tr row_countd="row_[% row_count | html %]">
177
                            <tr row_countd="row_[% row_count | html %]">
177
                                    <td>[% IF ( c == undef ) %]1[% ELSE %]0[% END %]</td>
178
                                    <td>[% IF ( c == undef ) %]1[% ELSE %]0[% END %]</td>
179
                                    <td>
180
                                        [% IF osc == undef %]
181
                                            <em>All</em>
182
                                        [% ELSE %]
183
                                            [% IF osc == 0 %]
184
                                                <em>No</em>
185
                                            [% ELSIF osc == 1 %]
186
                                                <em>On-site</em>
187
                                            [% END %]
188
                                        [% END %]
189
                                    </td>
178
                                    <td>
190
                                    <td>
179
                                        [% IF c == undef %]
191
                                        [% IF c == undef %]
180
                                            <em>All</em>
192
                                            <em>All</em>
Lines 192-198 Link Here
192
                                    </td>
204
                                    </td>
193
                                    <td class="actions">
205
                                    <td class="actions">
194
                                      <a href="#" class="editrule btn btn-default btn-xs"><i class="fa fa-pencil"></i> Edit</a>
206
                                      <a href="#" class="editrule btn btn-default btn-xs"><i class="fa fa-pencil"></i> Edit</a>
195
                                      <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete&amp;itemtype=[% i || '*' | html %]&amp;categorycode=[% c || '*' | html %]&amp;branch=[% current_branch | html %]"><i class="fa fa-trash"></i> Delete</a>
207
                                      <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete&amp;onsite_checkout=[% osc.defined ? osc : '*' | html %]&amp;itemtype=[% i || '*' | html %]&amp;categorycode=[% c || '*' | html %]&amp;branch=[% current_branch | html %]"><i class="fa fa-trash"></i> Delete</a>
196
                                    </td>
208
                                    </td>
197
                                    <td>
209
                                    <td>
198
                                        [% IF note.defined && note != '' %]
210
                                        [% IF note.defined && note != '' %]
Lines 206-218 Link Here
206
                                            <span>Unlimited</span>
218
                                            <span>Unlimited</span>
207
                                        [% END %]
219
                                        [% END %]
208
                                    </td>
220
                                    </td>
209
                                    <td>
210
                                        [% IF maxonsiteissueqty.defined && maxonsiteissueqty != ''  %]
211
                                            [% maxonsiteissueqty | html %]
212
                                        [% ELSE %]
213
                                            <span>Unlimited</span>
214
                                        [% END %]
215
                                    </td>
216
                                    <td>[% issuelength | html %]</td>
221
                                    <td>[% issuelength | html %]</td>
217
                                    <td>
222
                                    <td>
218
                                        [% SWITCH daysmode %]
223
                                        [% SWITCH daysmode %]
Lines 332-345 Link Here
332
                                    <td>[% rentaldiscount | html %]</td>
337
                                    <td>[% rentaldiscount | html %]</td>
333
                                    <td class="actions">
338
                                    <td class="actions">
334
                                      <a href="#" class="editrule btn btn-default btn-xs"><i class="fa fa-pencil"></i> Edit</a>
339
                                      <a href="#" class="editrule btn btn-default btn-xs"><i class="fa fa-pencil"></i> Edit</a>
335
                                      <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete&amp;itemtype=[% i || '*' | uri %]&amp;categorycode=[% c || '*' | uri %]&amp;branch=[% current_branch | uri %]"><i class="fa fa-trash"></i> Delete</a>
340
                                      <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete&amp;onsite_checkout=[% osc.defined ? osc : '*' | uri %]&amp;itemtype=[% i || '*' | uri %]&amp;categorycode=[% c || '*' | uri %]&amp;branch=[% current_branch | uri %]"><i class="fa fa-trash"></i> Delete</a>
336
                                    </td>
341
                                    </td>
337
                            </tr>
342
                            </tr>
338
                        [% END %]
343
                        [% END %]
344
                        [% END %]
339
                    [% END %]
345
                    [% END %]
340
                [% END %]
346
                [% END %]
341
                <tr id="edit_row">
347
                <tr id="edit_row">
342
                    <td>2</td>
348
                    <td>2</td>
349
                    <td>
350
                        <select name="onsite_checkout" id="matrixonsite_checkout" style="width:13em;">
351
                            <option value="*">All</option>
352
                            <option value="0">No</option>
353
                            <option value="1">On-site</option>
354
                        </select>
355
                    </td>
343
                    <td>
356
                    <td>
344
                        <select name="categorycode" id="categorycode">
357
                        <select name="categorycode" id="categorycode">
345
                            <option value="*">All</option>
358
                            <option value="*">All</option>
Lines 375-381 Link Here
375
                    </td>
388
                    </td>
376
                    <td><input type="text" name="note" id="note" size="15" value="" maxlength="100"></td>
389
                    <td><input type="text" name="note" id="note" size="15" value="" maxlength="100"></td>
377
                    <td><input type="text" name="maxissueqty" id="maxissueqty" size="3" /></td>
390
                    <td><input type="text" name="maxissueqty" id="maxissueqty" size="3" /></td>
378
                    <td><input type="text" name="maxonsiteissueqty" id="maxonsiteissueqty" size="3" /></td>
379
                    <td><input type="text" name="issuelength" id="issuelength" size="3" /> </td>
391
                    <td><input type="text" name="issuelength" id="issuelength" size="3" /> </td>
380
                    <td>
392
                    <td>
381
                        <select name="daysmode" id="daysmode">
393
                        <select name="daysmode" id="daysmode">
Lines 468-480 Link Here
468
                <tfoot>
480
                <tfoot>
469
                    <tr>
481
                    <tr>
470
                      <th>&nbsp;</th>
482
                      <th>&nbsp;</th>
483
                      <th>On-site checkout</th>
471
                      <th>Patron category</th>
484
                      <th>Patron category</th>
472
                      <th>&nbsp;</th>
485
                      <th>&nbsp;</th>
473
                      <th>Item type</th>
486
                      <th>Item type</th>
474
                      <th>&nbsp;</th>
487
                      <th>&nbsp;</th>
475
                      <th>Note</th>
488
                      <th>Note</th>
476
                      <th>Current checkouts allowed</th>
489
                      <th>Current checkouts allowed</th>
477
                      <th>Current on-site checkouts allowed</th>
478
                      <th>Loan period</th>
490
                      <th>Loan period</th>
479
                      <th>Days mode</th>
491
                      <th>Days mode</th>
480
                      <th>Unit</th>
492
                      <th>Unit</th>
Lines 532-551 Link Here
532
                <tr>
544
                <tr>
533
                    <td><em>Defaults</em></td>
545
                    <td><em>Defaults</em></td>
534
                    <td>
546
                    <td>
535
                        [% SET patron_maxissueqty = CirculationRules.Search( current_branch, undef, undef, 'patron_maxissueqty' ) %]
547
                        [% SET patron_maxissueqty = CirculationRules.Search( current_branch, 0, undef, undef, 'patron_maxissueqty' ) %]
536
                        <input type="text" name="patron_maxissueqty" size="3" value="[% patron_maxissueqty | html %]"/>
548
                        <input type="text" name="patron_maxissueqty" size="3" value="[% patron_maxissueqty | html %]"/>
537
                    </td>
549
                    </td>
538
                    <td>
550
                    <td>
539
                        [% SET patron_maxonsiteissueqty = CirculationRules.Search( current_branch, undef, undef, 'patron_maxonsiteissueqty' ) %]
551
                        [% SET patron_maxissueqty = CirculationRules.Search( current_branch, 1, undef, undef, 'patron_maxissueqty' ) %]
540
                        <input type="text" name="patron_maxonsiteissueqty" size="3" value="[% patron_maxonsiteissueqty | html %]"/>
552
                        <input type="text" name="patron_maxonsiteissueqty" size="3" value="[% patron_maxissueqty | html %]"/>
541
                    </td>
553
                    </td>
542
                    <td>
554
                    <td>
543
                        [% SET rule_value = CirculationRules.Search( current_branch, undef , undef, 'max_holds' ) %]
555
                        [% SET rule_value = CirculationRules.Search( current_branch, undef, undef, undef, 'max_holds' ) %]
544
                        <input name="max_holds" size="3" value="[% rule_value | html %]" />
556
                        <input name="max_holds" size="3" value="[% rule_value | html %]" />
545
                    </td>
557
                    </td>
546
                    <td>
558
                    <td>
547
                        <select name="holdallowed">
559
                        <select name="holdallowed">
548
                            [% SET holdallowed = CirculationRules.Search( current_branch, undef, undef, 'holdallowed' ) %]
560
                            [% SET holdallowed = CirculationRules.Search( current_branch, undef, undef, undef, 'holdallowed' ) %]
549
                            <option value="">
561
                            <option value="">
550
                                Not set
562
                                Not set
551
                            </option>
563
                            </option>
Lines 585-591 Link Here
585
                    </td>
597
                    </td>
586
                    <td>
598
                    <td>
587
                        <select name="hold_fulfillment_policy">
599
                        <select name="hold_fulfillment_policy">
588
                            [% SET hold_fulfillment_policy = CirculationRules.Search( current_branch, undef, undef, 'hold_fulfillment_policy' ) %]
600
                            [% SET hold_fulfillment_policy = CirculationRules.Search( current_branch, undef, undef, undef, 'hold_fulfillment_policy' ) %]
589
601
590
                            <option value="">
602
                            <option value="">
591
                                Not set
603
                                Not set
Lines 644-650 Link Here
644
                    </td>
656
                    </td>
645
                    <td>
657
                    <td>
646
                        <select name="returnbranch">
658
                        <select name="returnbranch">
647
                            [% SET returnbranch = CirculationRules.Search( current_branch, undef, undef, 'returnbranch' ) %]
659
                            [% SET returnbranch = CirculationRules.Search( current_branch, undef, undef, undef, 'returnbranch' ) %]
648
660
649
                            <option value="">
661
                            <option value="">
650
                                Not set
662
                                Not set
Lines 703-711 Link Here
703
                </tr>
715
                </tr>
704
                [% FOREACH c IN categorycodes %]
716
                [% FOREACH c IN categorycodes %]
705
                    [% NEXT UNLESS c %]
717
                    [% NEXT UNLESS c %]
706
                    [% SET patron_maxissueqty = CirculationRules.Search( branchcode, c, undef, 'patron_maxissueqty' ) %]
718
                    [% SET patron_maxissueqty = CirculationRules.Search( branchcode, 0, c, undef, 'patron_maxissueqty' ) %]
707
                    [% SET patron_maxonsiteissueqty = CirculationRules.Search( branchcode, c, undef, 'patron_maxonsiteissueqty' ) %]
719
                    [% SET patron_maxonsiteissueqty = CirculationRules.Search( branchcode, 1, c, undef, 'patron_maxissueqty' ) %]
708
                    [% SET max_holds = CirculationRules.Search( branchcode, c, undef, 'max_holds' ) %]
720
                    [% SET max_holds = CirculationRules.Search( branchcode, undef, c, undef, 'max_holds' ) %]
709
721
710
                    [% IF  ( patron_maxissueqty.defined && patron_maxissueqty != '' ) || ( patron_maxonsiteissueqty.defined && patron_maxonsiteissueqty != '' ) || ( max_holds.defined && max_holds != '' ) %]
722
                    [% IF  ( patron_maxissueqty.defined && patron_maxissueqty != '' ) || ( patron_maxonsiteissueqty.defined && patron_maxonsiteissueqty != '' ) || ( max_holds.defined && max_holds != '' ) %]
711
                    <tr>
723
                    <tr>
Lines 898-906 Link Here
898
                    <th>&nbsp;</th>
910
                    <th>&nbsp;</th>
899
                </tr>
911
                </tr>
900
                [% FOREACH i IN itemtypeloop %]
912
                [% FOREACH i IN itemtypeloop %]
901
                    [% SET holdallowed = CirculationRules.Search( branchcode, undef, i.itemtype, 'holdallowed' ) %]
913
                    [% SET holdallowed = CirculationRules.Search( branchcode, undef, i.itemtype, undef, 'holdallowed' ) %]
902
                    [% SET hold_fulfillment_policy = CirculationRules.Search( branchcode, undef, i.itemtype, 'hold_fulfillment_policy' ) %]
914
                    [% SET hold_fulfillment_policy = CirculationRules.Search( branchcode, undef, i.itemtype, undef, 'hold_fulfillment_policy' ) %]
903
                    [% SET returnbranch = CirculationRules.Search( branchcode, undef, i.itemtype, 'returnbranch' ) %]
915
                    [% SET returnbranch = CirculationRules.Search( branchcode, undef, i.itemtype, undef, 'returnbranch' ) %]
904
916
905
                    [% IF holdallowed || hold_fulfillment_policy || returnbranch %]
917
                    [% IF holdallowed || hold_fulfillment_policy || returnbranch %]
906
                        <tr>
918
                        <tr>
Lines 1015-1024 Link Here
1015
         $(document).ready(function() {
1027
         $(document).ready(function() {
1016
            $("#default-circulation-rules").dataTable($.extend(true,{},dataTablesDefaults, {
1028
            $("#default-circulation-rules").dataTable($.extend(true,{},dataTablesDefaults, {
1017
                "aoColumnDefs": [
1029
                "aoColumnDefs": [
1018
                    { "bVisible": false, "aTargets": [ 0,2 ] },
1030
                    { "bVisible": false, "aTargets": [ 0,3 ] },
1019
                    { "bSortable": false, "aTargets": ["_all"] }
1031
                    { "bSortable": false, "aTargets": ["_all"] }
1020
                ],
1032
                ],
1021
                "aaSortingFixed": [ [0,'asc'], [1,'asc'], [2,'asc'], [3,'asc'] ],
1033
                "aaSortingFixed": [ [0,'asc'], [1,'asc'], [2,'asc'], [3,'asc'], [4,'asc'] ],
1022
                "bPaginate": false,
1034
                "bPaginate": false,
1023
                "bAutoWidth": false
1035
                "bAutoWidth": false
1024
            }));
1036
            }));
Lines 1083-1089 Link Here
1083
                    itm = $(this).text();
1095
                    itm = $(this).text();
1084
                    itm = itm.replace(/^\s*|\s*$/g,'');
1096
                    itm = itm.replace(/^\s*|\s*$/g,'');
1085
                    var current_column = $("#edit_row td:eq("+i+")");
1097
                    var current_column = $("#edit_row td:eq("+i+")");
1086
                    if ( i == 3 ) {
1098
                    if ( i == 4 ) {
1087
                        // specific processing for the Note column
1099
                        // specific processing for the Note column
1088
                        var note = $(this).find("a[name='viewnote']").data("content");
1100
                        var note = $(this).find("a[name='viewnote']").data("content");
1089
                        $(current_column).find("input[type='text']").val(note);
1101
                        $(current_column).find("input[type='text']").val(note);
Lines 1114-1133 Link Here
1114
                                $(this).attr('selected', 'selected');
1126
                                $(this).attr('selected', 'selected');
1115
                            }
1127
                            }
1116
                        });
1128
                        });
1117
                        if ( i == 0 || i == 1 ) {
1129
                        if ( i == 0 || i == 1 || i == 2 ) {
1118
                            // Disable the 2 first columns, we cannot update them.
1130
                            // Disable the 2 first columns, we cannot update them.
1119
                            var val = $(current_column).find("select option:selected").val();
1131
                            var val = $(current_column).find("select option:selected").val();
1120
                            var name = "categorycode";
1132
                            var name = "onsite_checkout";
1121
                            if ( i == 1 ) {
1133
                            if ( i == 1 ) {
1134
                                name="categorycode";
1135
                            }
1136
                            if ( i == 2 ) {
1122
                                name="itemtype";
1137
                                name="itemtype";
1123
                            }
1138
                            }
1124
                            // Remove potential previous input added
1139
                            // Remove potential previous input added
1125
                            $(current_column).find("input").remove();
1140
                            $(current_column).find("input").remove();
1126
                            $(current_column).append("<input type='hidden' name='"+name+"' value='"+val+"' />");
1141
                            $(current_column).append("<input type='hidden' name='"+name+"' value='"+val+"' />");
1127
                        } else if ( i == 5 || i == 6 || i == 26 || i == 27 || i == 28 ) {
1142
                        } else if ( i == 6 || i == 26 || i == 27 || i == 28 ) {
1128
                            // If the value is not an integer for
1143
                            // If the value is not an integer for
1129
                            //     - "Current checkouts allowed"
1144
                            //     - "Current checkouts allowed"
1130
                            //     - "Current on-site checkouts allowed"
1131
                            //     - "Holds allowed (total)"
1145
                            //     - "Holds allowed (total)"
1132
                            //     - "Holds allowed (daily)"
1146
                            //     - "Holds allowed (daily)"
1133
                            //     - "Holds per record (count)"
1147
                            //     - "Holds per record (count)"
Lines 1141-1146 Link Here
1141
                });
1155
                });
1142
                $("#default-circulation-rules tr:last td:eq(0) select").prop('disabled', true);
1156
                $("#default-circulation-rules tr:last td:eq(0) select").prop('disabled', true);
1143
                $("#default-circulation-rules tr:last td:eq(1) select").prop('disabled', true);
1157
                $("#default-circulation-rules tr:last td:eq(1) select").prop('disabled', true);
1158
                $("#default-circulation-rules tr:last td:eq(2) select").prop('disabled', true);
1144
                return false;
1159
                return false;
1145
            });
1160
            });
1146
            $(".clear_edit").on("click",function(e){
1161
            $(".clear_edit").on("click",function(e){
1147
- 

Return to bug 26814