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

(-)a/admin/smart-rules.pl (-24 / +192 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');
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
            onsite_checkout => $onsite_checkout eq '*' ? undef : $onsite_checkout,
83
            rules        => {
86
            rules        => {
84
                maxissueqty                      => undef,
87
                maxissueqty                      => undef,
85
                maxonsiteissueqty                => undef,
86
                rentaldiscount                   => undef,
88
                rentaldiscount                   => undef,
87
                fine                             => undef,
89
                fine                             => undef,
88
                finedays                         => undef,
90
                finedays                         => undef,
Lines 125-132 elsif ($op eq 'delete-branch-cat') { Link Here
125
                    categorycode => undef,
127
                    categorycode => undef,
126
                    rules        => {
128
                    rules        => {
127
                        max_holds                      => undef,
129
                        max_holds                      => undef,
128
                        patron_maxissueqty             => undef,
130
                    }
129
                        patron_maxonsiteissueqty       => undef,
131
                }
132
            );
133
            Koha::CirculationRules->set_rules(
134
                {
135
                    branchcode   => undef,
136
                    categorycode => undef,
137
                    onsite_checkout => 0,
138
                    rules        => {
139
                        patron_maxissueqty                      => undef,
140
                    }
141
                }
142
            );
143
            Koha::CirculationRules->set_rules(
144
                {
145
                    branchcode   => undef,
146
                    categorycode => undef,
147
                    onsite_checkout => 1,
148
                    rules        => {
149
                        patron_maxissueqty       => undef,
130
                    }
150
                    }
131
                }
151
                }
132
            );
152
            );
Lines 148-155 elsif ($op eq 'delete-branch-cat') { Link Here
148
                    branchcode   => undef,
168
                    branchcode   => undef,
149
                    rules        => {
169
                    rules        => {
150
                        max_holds                => undef,
170
                        max_holds                => undef,
171
                    }
172
                }
173
            );
174
            Koha::CirculationRules->set_rules(
175
                {
176
                    categorycode => $categorycode,
177
                    branchcode   => undef,
178
                    onsite_checkout => 0,
179
                    rules        => {
180
                        patron_maxissueqty       => undef,
181
                    }
182
                }
183
            );
184
            Koha::CirculationRules->set_rules(
185
                {
186
                    categorycode => $categorycode,
187
                    branchcode   => undef,
188
                    onsite_checkout => 1,
189
                    rules        => {
151
                        patron_maxissueqty       => undef,
190
                        patron_maxissueqty       => undef,
152
                        patron_maxonsiteissueqty => undef,
153
                    }
191
                    }
154
                }
192
                }
155
            );
193
            );
Lines 159-168 elsif ($op eq 'delete-branch-cat') { Link Here
159
            {
197
            {
160
                branchcode   => $branch,
198
                branchcode   => $branch,
161
                categorycode => undef,
199
                categorycode => undef,
200
                onsite_checkout => 0,
201
                rules        => {
202
                    patron_maxissueqty       => undef,
203
                }
204
            }
205
        );
206
        Koha::CirculationRules->set_rules(
207
            {
208
                branchcode   => $branch,
209
                categorycode => undef,
210
                onsite_checkout => 1,
162
                rules        => {
211
                rules        => {
163
                    max_holds                => undef,
212
                    max_holds                => undef,
164
                    patron_maxissueqty       => undef,
213
                    patron_maxissueqty       => undef,
165
                    patron_maxonsiteissueqty => undef,
166
                }
214
                }
167
            }
215
            }
168
        );
216
        );
Lines 184-191 elsif ($op eq 'delete-branch-cat') { Link Here
184
                branchcode   => $branch,
232
                branchcode   => $branch,
185
                rules        => {
233
                rules        => {
186
                    max_holds         => undef,
234
                    max_holds         => undef,
187
                    patron_maxissueqty       => undef,
235
                }
188
                    patron_maxonsiteissueqty => undef,
236
            }
237
        );
238
        Koha::CirculationRules->set_rules(
239
            {
240
                categorycode => $categorycode,
241
                branchcode   => $branch,
242
                onsite_checkout => 0,
243
                rules        => {
244
                    patron_maxissueqty => undef,
245
                }
246
            }
247
        );
248
        Koha::CirculationRules->set_rules(
249
            {
250
                categorycode => $categorycode,
251
                branchcode   => $branch,
252
                onsite_checkout => 1,
253
                rules        => {
254
                    patron_maxissueqty => undef,
189
                }
255
                }
190
            }
256
            }
191
        );
257
        );
Lines 250-255 elsif ($op eq 'add') { Link Here
250
    my $br = $branch; # branch
316
    my $br = $branch; # branch
251
    my $bor  = $input->param('categorycode'); # borrower category
317
    my $bor  = $input->param('categorycode'); # borrower category
252
    my $itemtype  = $input->param('itemtype');     # item type
318
    my $itemtype  = $input->param('itemtype');     # item type
319
    my $onsite_checkout = $input->param('onsite_checkout');
253
    my $fine = $input->param('fine');
320
    my $fine = $input->param('fine');
254
    my $finedays     = $input->param('finedays');
321
    my $finedays     = $input->param('finedays');
255
    my $maxsuspensiondays = $input->param('maxsuspensiondays') || '';
322
    my $maxsuspensiondays = $input->param('maxsuspensiondays') || '';
Lines 258-264 elsif ($op eq 'add') { Link Here
258
    my $chargeperiod = $input->param('chargeperiod');
325
    my $chargeperiod = $input->param('chargeperiod');
259
    my $chargeperiod_charge_at = $input->param('chargeperiod_charge_at');
326
    my $chargeperiod_charge_at = $input->param('chargeperiod_charge_at');
260
    my $maxissueqty = strip_non_numeric( scalar $input->param('maxissueqty') );
327
    my $maxissueqty = strip_non_numeric( scalar $input->param('maxissueqty') );
261
    my $maxonsiteissueqty = strip_non_numeric( scalar $input->param('maxonsiteissueqty') );
262
    my $renewalsallowed  = $input->param('renewalsallowed');
328
    my $renewalsallowed  = $input->param('renewalsallowed');
263
    my $renewalperiod    = $input->param('renewalperiod');
329
    my $renewalperiod    = $input->param('renewalperiod');
264
    my $norenewalbefore  = $input->param('norenewalbefore');
330
    my $norenewalbefore  = $input->param('norenewalbefore');
Lines 287-297 elsif ($op eq 'add') { Link Here
287
    my $overduefinescap = $input->param('overduefinescap') || '';
353
    my $overduefinescap = $input->param('overduefinescap') || '';
288
    my $cap_fine_to_replacement_price = ($input->param('cap_fine_to_replacement_price') || '') eq 'on';
354
    my $cap_fine_to_replacement_price = ($input->param('cap_fine_to_replacement_price') || '') eq 'on';
289
    my $note = $input->param('note');
355
    my $note = $input->param('note');
290
    $debug and warn "Adding $br, $bor, $itemtype, $fine, $maxissueqty, $maxonsiteissueqty, $cap_fine_to_replacement_price";
356
    $debug and warn "Adding $br, $bor, $itemtype, $fine, $maxissueqty, $cap_fine_to_replacement_price";
291
357
292
    my $rules = {
358
    my $rules = {
293
        maxissueqty                   => $maxissueqty,
359
        maxissueqty                   => $maxissueqty,
294
        maxonsiteissueqty             => $maxonsiteissueqty,
295
        rentaldiscount                => $rentaldiscount,
360
        rentaldiscount                => $rentaldiscount,
296
        fine                          => $fine,
361
        fine                          => $fine,
297
        finedays                      => $finedays,
362
        finedays                      => $finedays,
Lines 311-325 elsif ($op eq 'add') { Link Here
311
        auto_renew                    => $auto_renew,
376
        auto_renew                    => $auto_renew,
312
        no_auto_renewal_after         => $no_auto_renewal_after,
377
        no_auto_renewal_after         => $no_auto_renewal_after,
313
        no_auto_renewal_after_hard_limit => $no_auto_renewal_after_hard_limit,
378
        no_auto_renewal_after_hard_limit => $no_auto_renewal_after_hard_limit,
379
        overduefinescap               => $overduefinescap,
380
        cap_fine_to_replacement_price => $cap_fine_to_replacement_price,
381
        note                          => $note,
382
    };
383
384
    Koha::CirculationRules->set_rules(
385
        {
386
            categorycode => $bor eq '*' ? undef : $bor,
387
            itemtype     => $itemtype eq '*' ? undef : $itemtype,
388
            branchcode   => $br eq '*' ? undef : $br,
389
            onsite_checkout => $onsite_checkout eq '*' ? undef : $onsite_checkout,
390
            rules        => $rules,
391
        }
392
    );
393
394
    $rules = {
314
        reservesallowed               => $reservesallowed,
395
        reservesallowed               => $reservesallowed,
315
        holds_per_record              => $holds_per_record,
396
        holds_per_record              => $holds_per_record,
316
        holds_per_day                 => $holds_per_day,
397
        holds_per_day                 => $holds_per_day,
317
        onshelfholds                  => $onshelfholds,
398
        onshelfholds                  => $onshelfholds,
318
        opacitemholds                 => $opacitemholds,
399
        opacitemholds                 => $opacitemholds,
319
        overduefinescap               => $overduefinescap,
320
        cap_fine_to_replacement_price => $cap_fine_to_replacement_price,
321
        article_requests              => $article_requests,
400
        article_requests              => $article_requests,
322
        note                          => $note,
323
    };
401
    };
324
402
325
    Koha::CirculationRules->set_rules(
403
    Koha::CirculationRules->set_rules(
Lines 335-342 elsif ($op eq 'add') { Link Here
335
elsif ($op eq "set-branch-defaults") {
413
elsif ($op eq "set-branch-defaults") {
336
    my $categorycode  = $input->param('categorycode');
414
    my $categorycode  = $input->param('categorycode');
337
    my $patron_maxissueqty = strip_non_numeric( scalar $input->param('patron_maxissueqty') );
415
    my $patron_maxissueqty = strip_non_numeric( scalar $input->param('patron_maxissueqty') );
338
    my $patron_maxonsiteissueqty = $input->param('patron_maxonsiteissueqty');
416
    my $patron_maxonsiteissueqty   = strip_non_numeric( scalar $input->param('patron_maxonsiteissueqty') );
339
    $patron_maxonsiteissueqty = strip_non_numeric($patron_maxonsiteissueqty);
340
    my $holdallowed   = $input->param('holdallowed');
417
    my $holdallowed   = $input->param('holdallowed');
341
    my $hold_fulfillment_policy = $input->param('hold_fulfillment_policy');
418
    my $hold_fulfillment_policy = $input->param('hold_fulfillment_policy');
342
    my $returnbranch  = $input->param('returnbranch');
419
    my $returnbranch  = $input->param('returnbranch');
Lines 358-366 elsif ($op eq "set-branch-defaults") { Link Here
358
            {
435
            {
359
                categorycode => undef,
436
                categorycode => undef,
360
                branchcode   => undef,
437
                branchcode   => undef,
438
                onsite_checkout => 0,
361
                rules        => {
439
                rules        => {
362
                    patron_maxissueqty             => $patron_maxissueqty,
440
                    patron_maxissueqty             => $patron_maxissueqty,
363
                    patron_maxonsiteissueqty       => $patron_maxonsiteissueqty,
441
                }
442
            }
443
        );
444
        Koha::CirculationRules->set_rules(
445
            {
446
                categorycode => undef,
447
                branchcode   => undef,
448
                onsite_checkout => 1,
449
                rules        => {
450
                    patron_maxissueqty             => $patron_maxonsiteissueqty,
364
                }
451
                }
365
            }
452
            }
366
        );
453
        );
Lines 380-388 elsif ($op eq "set-branch-defaults") { Link Here
380
            {
467
            {
381
                categorycode => undef,
468
                categorycode => undef,
382
                branchcode   => $branch,
469
                branchcode   => $branch,
470
                onsite_checkout => 0,
383
                rules        => {
471
                rules        => {
384
                    patron_maxissueqty             => $patron_maxissueqty,
472
                    patron_maxissueqty             => $patron_maxissueqty,
385
                    patron_maxonsiteissueqty       => $patron_maxonsiteissueqty,
473
                }
474
            }
475
        );
476
        Koha::CirculationRules->set_rules(
477
            {
478
                categorycode => undef,
479
                branchcode   => $branch,
480
                onsite_checkout => 1,
481
                rules        => {
482
                    patron_maxissueqty             => $patron_maxonsiteissueqty,
386
                }
483
                }
387
            }
484
            }
388
        );
485
        );
Lines 399-406 elsif ($op eq "set-branch-defaults") { Link Here
399
elsif ($op eq "add-branch-cat") {
496
elsif ($op eq "add-branch-cat") {
400
    my $categorycode  = $input->param('categorycode');
497
    my $categorycode  = $input->param('categorycode');
401
    my $patron_maxissueqty = strip_non_numeric( scalar $input->param('patron_maxissueqty') );
498
    my $patron_maxissueqty = strip_non_numeric( scalar $input->param('patron_maxissueqty') );
402
    my $patron_maxonsiteissueqty = $input->param('patron_maxonsiteissueqty');
499
    my $patron_maxonsiteissueqty = strip_non_numeric( scalar $input->param('patron_maxonsiteissueqty') );
403
    $patron_maxonsiteissueqty = strip_non_numeric($patron_maxonsiteissueqty);
404
    my $max_holds = $input->param('max_holds');
500
    my $max_holds = $input->param('max_holds');
405
    $max_holds =~ s/\s//g;
501
    $max_holds =~ s/\s//g;
406
    $max_holds = undef if $max_holds !~ /^\d+/;
502
    $max_holds = undef if $max_holds !~ /^\d+/;
Lines 413-420 elsif ($op eq "add-branch-cat") { Link Here
413
                    branchcode   => undef,
509
                    branchcode   => undef,
414
                    rules        => {
510
                    rules        => {
415
                        max_holds         => $max_holds,
511
                        max_holds         => $max_holds,
512
                    }
513
                }
514
            );
515
            Koha::CirculationRules->set_rules(
516
                {
517
                    categorycode => undef,
518
                    branchcode   => undef,
519
                    onsite_checkout => 0,
520
                    rules        => {
416
                        patron_maxissueqty       => $patron_maxissueqty,
521
                        patron_maxissueqty       => $patron_maxissueqty,
417
                        patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
522
                    }
523
                }
524
            );
525
            Koha::CirculationRules->set_rules(
526
                {
527
                    categorycode => undef,
528
                    branchcode   => undef,
529
                    onsite_checkout => 1,
530
                    rules        => {
531
                        patron_maxissueqty       => $patron_maxonsiteissueqty,
418
                    }
532
                    }
419
                }
533
                }
420
            );
534
            );
Lines 425-432 elsif ($op eq "add-branch-cat") { Link Here
425
                    branchcode   => undef,
539
                    branchcode   => undef,
426
                    rules        => {
540
                    rules        => {
427
                        max_holds         => $max_holds,
541
                        max_holds         => $max_holds,
542
                    }
543
                }
544
            );
545
            Koha::CirculationRules->set_rules(
546
                {
547
                    categorycode => $categorycode,
548
                    branchcode   => undef,
549
                    onsite_checkout => 0,
550
                    rules        => {
428
                        patron_maxissueqty       => $patron_maxissueqty,
551
                        patron_maxissueqty       => $patron_maxissueqty,
429
                        patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
552
                    }
553
                }
554
            );
555
            Koha::CirculationRules->set_rules(
556
                {
557
                    categorycode => $categorycode,
558
                    branchcode   => undef,
559
                    onsite_checkout => 1,
560
                    rules        => {
561
                        patron_maxissueqty       => $patron_maxonsiteissueqty,
430
                    }
562
                    }
431
                }
563
                }
432
            );
564
            );
Lines 438-445 elsif ($op eq "add-branch-cat") { Link Here
438
                branchcode   => $branch,
570
                branchcode   => $branch,
439
                rules        => {
571
                rules        => {
440
                    max_holds         => $max_holds,
572
                    max_holds         => $max_holds,
573
                }
574
            }
575
        );
576
        Koha::CirculationRules->set_rules(
577
            {
578
                categorycode => undef,
579
                branchcode   => $branch,
580
                onsite_checkout => 0,
581
                rules        => {
441
                    patron_maxissueqty       => $patron_maxissueqty,
582
                    patron_maxissueqty       => $patron_maxissueqty,
442
                    patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
583
                }
584
            }
585
        );
586
        Koha::CirculationRules->set_rules(
587
            {
588
                categorycode => undef,
589
                branchcode   => $branch,
590
                onsite_checkout => 1,
591
                rules        => {
592
                    patron_maxissueqty       => $patron_maxonsiteissueqty,
443
                }
593
                }
444
            }
594
            }
445
        );
595
        );
Lines 450-457 elsif ($op eq "add-branch-cat") { Link Here
450
                branchcode   => $branch,
600
                branchcode   => $branch,
451
                rules        => {
601
                rules        => {
452
                    max_holds         => $max_holds,
602
                    max_holds         => $max_holds,
603
                }
604
            }
605
        );
606
        Koha::CirculationRules->set_rules(
607
            {
608
                categorycode => $categorycode,
609
                branchcode   => $branch,
610
                onsite_checkout => 0,
611
                rules        => {
453
                    patron_maxissueqty       => $patron_maxissueqty,
612
                    patron_maxissueqty       => $patron_maxissueqty,
454
                    patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
613
                }
614
            }
615
        );
616
        Koha::CirculationRules->set_rules(
617
            {
618
                categorycode => $categorycode,
619
                branchcode   => $branch,
620
                onsite_checkout => 1,
621
                rules        => {
622
                    patron_maxissueqty       => $patron_maxonsiteissueqty,
455
                }
623
                }
456
            }
624
            }
457
        );
625
        );
Lines 562-568 my $definedbranch = $all_rules->count ? 1 : 0; Link Here
562
my $rules = {};
730
my $rules = {};
563
while ( my $r = $all_rules->next ) {
731
while ( my $r = $all_rules->next ) {
564
    $r = $r->unblessed;
732
    $r = $r->unblessed;
565
    $rules->{ $r->{categorycode} // '' }->{ $r->{itemtype} // '' }->{ $r->{rule_name} } = $r->{rule_value};
733
    $rules->{ $r->{onsite_checkout} // '' }->{ $r->{categorycode} // '' }->{ $r->{itemtype} // '' }->{ $r->{rule_name} } = $r->{rule_value};
566
}
734
}
567
735
568
$template->param(show_branch_cat_rule_form => 1);
736
$template->param(show_branch_cat_rule_form => 1);
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-36 / +50 lines)
Lines 91-103 Link Here
91
            <thead>
91
            <thead>
92
            <tr>
92
            <tr>
93
                <th>&nbsp;</th>
93
                <th>&nbsp;</th>
94
                <th>On-site checkout</th>
94
                <th>Patron category</th>
95
                <th>Patron category</th>
95
                <th>&nbsp;</th>
96
                <th>&nbsp;</th>
96
                <th>Item type</th>
97
                <th>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 129-141 Link Here
129
            </thead>
129
            </thead>
130
            <tbody>
130
            <tbody>
131
                [% SET row_count = 0 %]
131
                [% SET row_count = 0 %]
132
                [% FOREACH c IN categorycodes %]
132
                [% FOREACH osc IN [ undef, 0, 1 ] %]
133
                    [% SET c = '' UNLESS c.defined %]
133
                    [% FOREACH c IN categorycodes %]
134
                    [% FOREACH i IN itemtypes %]
134
                        [% SET c = '' UNLESS c.defined %]
135
                        [% FOREACH i IN itemtypes %]
135
                        [% SET i = '' UNLESS i.defined %]
136
                        [% SET i = '' UNLESS i.defined %]
137
                        [% SET osc = '' UNLESS osc.defined %]
136
                        [% SET note = all_rules.$c.$i.note %]
138
                        [% SET note = all_rules.$c.$i.note %]
137
                        [% SET maxissueqty = all_rules.$c.$i.maxissueqty %]
139
                        [% SET maxissueqty = all_rules.$c.$i.maxissueqty %]
138
                        [% SET maxonsiteissueqty = all_rules.$c.$i.maxonsiteissueqty %]
139
                        [% SET issuelength = all_rules.$c.$i.issuelength %]
140
                        [% SET issuelength = all_rules.$c.$i.issuelength %]
140
                        [% SET daysmode = all_rules.$c.$i.daysmode %]
141
                        [% SET daysmode = all_rules.$c.$i.daysmode %]
141
                        [% SET lengthunit = all_rules.$c.$i.lengthunit %]
142
                        [% SET lengthunit = all_rules.$c.$i.lengthunit %]
Lines 164-174 Link Here
164
                        [% SET article_requests = all_rules.$c.$i.article_requests %]
165
                        [% SET article_requests = all_rules.$c.$i.article_requests %]
165
                        [% SET rentaldiscount = all_rules.$c.$i.rentaldiscount %]
166
                        [% SET rentaldiscount = all_rules.$c.$i.rentaldiscount %]
166
167
167
                        [% 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 || 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 %]
168
                        [% 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 || 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 %]
168
                        [% IF show_rule %]
169
                        [% IF show_rule %]
169
                            [% SET row_count = row_count + 1 %]
170
                            [% SET row_count = row_count + 1 %]
170
                            <tr row_countd="row_[% row_count | html %]">
171
                            <tr row_countd="row_[% row_count | html %]">
171
                                    <td>[% IF ( c == undef ) %]1[% ELSE %]0[% END %]</td>
172
                                    <td>[% IF ( c == undef ) %]1[% ELSE %]0[% END %]</td>
173
                                    <td>
174
                                        [% IF osc == undef %]
175
                                            <em>All</em>
176
                                        [% ELSE %]
177
                                            [% IF osc == 0 %]
178
                                                <em>No</em>
179
                                            [% ELSIF osc == 1 %]
180
                                                <em>On-site</em>
181
                                            [% END %]
182
                                        [% END %]
183
                                    </td>
172
                                    <td>
184
                                    <td>
173
                                        [% IF c == undef %]
185
                                        [% IF c == undef %]
174
                                            <em>All</em>
186
                                            <em>All</em>
Lines 186-192 Link Here
186
                                    </td>
198
                                    </td>
187
                                    <td class="actions">
199
                                    <td class="actions">
188
                                      <a href="#" class="editrule btn btn-default btn-xs"><i class="fa fa-pencil"></i> Edit</a>
200
                                      <a href="#" class="editrule btn btn-default btn-xs"><i class="fa fa-pencil"></i> Edit</a>
189
                                      <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>
201
                                      <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete&amp;onsite_checkout=[% ct || '*' | html %]&amp;itemtype=[% i || '*' | html %]&amp;categorycode=[% c || '*' | html %]&amp;branch=[% current_branch | html %]"><i class="fa fa-trash"></i> Delete</a>
190
                                    </td>
202
                                    </td>
191
                                    <td>
203
                                    <td>
192
                                        [% IF note.defined && note != '' %]
204
                                        [% IF note.defined && note != '' %]
Lines 200-212 Link Here
200
                                            <span>Unlimited</span>
212
                                            <span>Unlimited</span>
201
                                        [% END %]
213
                                        [% END %]
202
                                    </td>
214
                                    </td>
203
                                    <td>
204
                                        [% IF maxonsiteissueqty.defined && maxonsiteissueqty != ''  %]
205
                                            [% maxonsiteissueqty | html %]
206
                                        [% ELSE %]
207
                                            <span>Unlimited</span>
208
                                        [% END %]
209
                                    </td>
210
                                    <td>[% issuelength | html %]</td>
215
                                    <td>[% issuelength | html %]</td>
211
                                    <td>
216
                                    <td>
212
                                        [% SWITCH daysmode %]
217
                                        [% SWITCH daysmode %]
Lines 326-335 Link Here
326
                                    </td>
331
                                    </td>
327
                            </tr>
332
                            </tr>
328
                        [% END %]
333
                        [% END %]
334
                        [% END %]
329
                    [% END %]
335
                    [% END %]
330
                [% END %]
336
                [% END %]
331
                <tr id="edit_row">
337
                <tr id="edit_row">
332
                    <td>2</td>
338
                    <td>2</td>
339
                    <td>
340
                        <select name="onsite_checkout" id="matrixonsite_checkout" style="width:13em;">
341
                            <option value="*">All</option>
342
                            <option value="0">No</option>
343
                            <option value="1">On-site</option>
344
                        </select>
345
                    </td>
333
                    <td>
346
                    <td>
334
                        <select name="categorycode" id="categorycode">
347
                        <select name="categorycode" id="categorycode">
335
                            <option value="*">All</option>
348
                            <option value="*">All</option>
Lines 365-371 Link Here
365
                    </td>
378
                    </td>
366
                    <td><input type="text" name="note" id="note" size="15" value="" maxlength="100"></td>
379
                    <td><input type="text" name="note" id="note" size="15" value="" maxlength="100"></td>
367
                    <td><input type="text" name="maxissueqty" id="maxissueqty" size="3" /></td>
380
                    <td><input type="text" name="maxissueqty" id="maxissueqty" size="3" /></td>
368
                    <td><input type="text" name="maxonsiteissueqty" id="maxonsiteissueqty" size="3" /></td>
369
                    <td><input type="text" name="issuelength" id="issuelength" size="3" /> </td>
381
                    <td><input type="text" name="issuelength" id="issuelength" size="3" /> </td>
370
                    <td>
382
                    <td>
371
                        <select name="daysmode" id="daysmode">
383
                        <select name="daysmode" id="daysmode">
Lines 454-466 Link Here
454
                <tfoot>
466
                <tfoot>
455
                    <tr>
467
                    <tr>
456
                      <th>&nbsp;</th>
468
                      <th>&nbsp;</th>
469
                      <th>On-site checkout</th>
457
                      <th>Patron category</th>
470
                      <th>Patron category</th>
458
                      <th>&nbsp;</th>
471
                      <th>&nbsp;</th>
459
                      <th>Item type</th>
472
                      <th>Item type</th>
460
                      <th>&nbsp;</th>
473
                      <th>&nbsp;</th>
461
                      <th>Note</th>
474
                      <th>Note</th>
462
                      <th>Current checkouts allowed</th>
475
                      <th>Current checkouts allowed</th>
463
                      <th>Current on-site checkouts allowed</th>
464
                      <th>Loan period</th>
476
                      <th>Loan period</th>
465
                      <th>Days mode</th>
477
                      <th>Days mode</th>
466
                      <th>Unit</th>
478
                      <th>Unit</th>
Lines 514-533 Link Here
514
                <tr>
526
                <tr>
515
                    <td><em>Defaults</em></td>
527
                    <td><em>Defaults</em></td>
516
                    <td>
528
                    <td>
517
                        [% SET patron_maxissueqty = CirculationRules.Search( current_branch, undef, undef, 'patron_maxissueqty' ) %]
529
                        [% SET patron_maxissueqty = CirculationRules.Search( current_branch, 0, undef, undef, 'patron_maxissueqty' ) %]
518
                        <input type="text" name="patron_maxissueqty" size="3" value="[% patron_maxissueqty | html %]"/>
530
                        <input type="text" name="patron_maxissueqty" size="3" value="[% patron_maxissueqty | html %]"/>
519
                    </td>
531
                    </td>
520
                    <td>
532
                    <td>
521
                        [% SET patron_maxonsiteissueqty = CirculationRules.Search( current_branch, undef, undef, 'patron_maxonsiteissueqty' ) %]
533
                        [% SET patron_maxissueqty = CirculationRules.Search( current_branch, 1, undef, undef, 'patron_maxissueqty' ) %]
522
                        <input type="text" name="patron_maxonsiteissueqty" size="3" value="[% patron_maxonsiteissueqty | html %]"/>
534
                        <input type="text" name="patron_maxonsiteissueqty" size="3" value="[% patron_maxissueqty | html %]"/>
523
                    </td>
535
                    </td>
524
                    <td>
536
                    <td>
525
                        [% SET rule_value = CirculationRules.Search( current_branch, undef , undef, 'max_holds' ) %]
537
                        [% SET rule_value = CirculationRules.Search( current_branch, undef, undef, undef, 'max_holds' ) %]
526
                        <input name="max_holds" size="3" value="[% rule_value | html %]" />
538
                        <input name="max_holds" size="3" value="[% rule_value | html %]" />
527
                    </td>
539
                    </td>
528
                    <td>
540
                    <td>
529
                        <select name="holdallowed">
541
                        <select name="holdallowed">
530
                            [% SET holdallowed = CirculationRules.Search( current_branch, undef, undef, 'holdallowed' ) %]
542
                            [% SET holdallowed = CirculationRules.Search( current_branch, undef, undef, undef, 'holdallowed' ) %]
531
                            <option value="">
543
                            <option value="">
532
                                Not set
544
                                Not set
533
                            </option>
545
                            </option>
Lines 567-573 Link Here
567
                    </td>
579
                    </td>
568
                    <td>
580
                    <td>
569
                        <select name="hold_fulfillment_policy">
581
                        <select name="hold_fulfillment_policy">
570
                            [% SET hold_fulfillment_policy = CirculationRules.Search( current_branch, undef, undef, 'hold_fulfillment_policy' ) %]
582
                            [% SET hold_fulfillment_policy = CirculationRules.Search( current_branch, undef, undef, undef, 'hold_fulfillment_policy' ) %]
571
583
572
                            <option value="">
584
                            <option value="">
573
                                Not set
585
                                Not set
Lines 626-632 Link Here
626
                    </td>
638
                    </td>
627
                    <td>
639
                    <td>
628
                        <select name="returnbranch">
640
                        <select name="returnbranch">
629
                            [% SET returnbranch = CirculationRules.Search( current_branch, undef, undef, 'returnbranch' ) %]
641
                            [% SET returnbranch = CirculationRules.Search( current_branch, undef, undef, undef, 'returnbranch' ) %]
630
642
631
                            <option value="">
643
                            <option value="">
632
                                Not set
644
                                Not set
Lines 685-693 Link Here
685
                </tr>
697
                </tr>
686
                [% FOREACH c IN categorycodes %]
698
                [% FOREACH c IN categorycodes %]
687
                    [% NEXT UNLESS c %]
699
                    [% NEXT UNLESS c %]
688
                    [% SET patron_maxissueqty = CirculationRules.Search( branchcode, c, undef, 'patron_maxissueqty' ) %]
700
                    [% SET patron_maxissueqty = CirculationRules.Search( branchcode, 0, c, undef, 'patron_maxissueqty' ) %]
689
                    [% SET patron_maxonsiteissueqty = CirculationRules.Search( branchcode, c, undef, 'patron_maxonsiteissueqty' ) %]
701
                    [% SET patron_maxonsiteissueqty = CirculationRules.Search( branchcode, 1, c, undef, 'patron_maxissueqty' ) %]
690
                    [% SET max_holds = CirculationRules.Search( branchcode, c, undef, 'max_holds' ) %]
702
                    [% SET max_holds = CirculationRules.Search( branchcode, undef, c, undef, 'max_holds' ) %]
691
703
692
                    [% IF  ( patron_maxissueqty.defined && patron_maxissueqty != '' ) || ( patron_maxonsiteissueqty.defined && patron_maxonsiteissueqty != '' ) || ( max_holds.defined && max_holds != '' ) %]
704
                    [% IF  ( patron_maxissueqty.defined && patron_maxissueqty != '' ) || ( patron_maxonsiteissueqty.defined && patron_maxonsiteissueqty != '' ) || ( max_holds.defined && max_holds != '' ) %]
693
                    <tr>
705
                    <tr>
Lines 855-863 Link Here
855
                    <th>&nbsp;</th>
867
                    <th>&nbsp;</th>
856
                </tr>
868
                </tr>
857
                [% FOREACH i IN itemtypeloop %]
869
                [% FOREACH i IN itemtypeloop %]
858
                    [% SET holdallowed = CirculationRules.Search( branchcode, undef, i.itemtype, 'holdallowed' ) %]
870
                    [% SET holdallowed = CirculationRules.Search( branchcode, undef, i.itemtype, undef, 'holdallowed' ) %]
859
                    [% SET hold_fulfillment_policy = CirculationRules.Search( branchcode, undef, i.itemtype, 'hold_fulfillment_policy' ) %]
871
                    [% SET hold_fulfillment_policy = CirculationRules.Search( branchcode, undef, i.itemtype, undef, 'hold_fulfillment_policy' ) %]
860
                    [% SET returnbranch = CirculationRules.Search( branchcode, undef, i.itemtype, 'returnbranch' ) %]
872
                    [% SET returnbranch = CirculationRules.Search( branchcode, undef, i.itemtype, undef, 'returnbranch' ) %]
861
873
862
                    [% IF holdallowed || hold_fulfillment_policy || returnbranch %]
874
                    [% IF holdallowed || hold_fulfillment_policy || returnbranch %]
863
                        <tr>
875
                        <tr>
Lines 972-981 Link Here
972
        $(document).ready(function() {
984
        $(document).ready(function() {
973
            $("#default-circulation-rules").dataTable($.extend(true,{},dataTablesDefaults, {
985
            $("#default-circulation-rules").dataTable($.extend(true,{},dataTablesDefaults, {
974
                "aoColumnDefs": [
986
                "aoColumnDefs": [
975
                    { "bVisible": false, "aTargets": [ 0,2 ] },
987
                    { "bVisible": false, "aTargets": [ 0,3 ] },
976
                    { "bSortable": false, "aTargets": ["_all"] }
988
                    { "bSortable": false, "aTargets": ["_all"] }
977
                ],
989
                ],
978
                "aaSortingFixed": [ [0,'asc'], [1,'asc'], [2,'asc'], [3,'asc'] ],
990
                "aaSortingFixed": [ [0,'asc'], [1,'asc'], [2,'asc'], [3,'asc'], [4,'asc'] ],
979
                "bPaginate": false,
991
                "bPaginate": false,
980
                "bAutoWidth": false
992
                "bAutoWidth": false
981
            }));
993
            }));
Lines 1040-1046 Link Here
1040
                    itm = $(this).text();
1052
                    itm = $(this).text();
1041
                    itm = itm.replace(/^\s*|\s*$/g,'');
1053
                    itm = itm.replace(/^\s*|\s*$/g,'');
1042
                    var current_column = $("#edit_row td:eq("+i+")");
1054
                    var current_column = $("#edit_row td:eq("+i+")");
1043
                    if ( i == 3 ) {
1055
                    if ( i == 4 ) {
1044
                        // specific processing for the Note column
1056
                        // specific processing for the Note column
1045
                        var note = $(this).find("a[name='viewnote']").data("content");
1057
                        var note = $(this).find("a[name='viewnote']").data("content");
1046
                        $(current_column).find("input[type='text']").val(note);
1058
                        $(current_column).find("input[type='text']").val(note);
Lines 1071-1090 Link Here
1071
                                $(this).attr('selected', 'selected');
1083
                                $(this).attr('selected', 'selected');
1072
                            }
1084
                            }
1073
                        });
1085
                        });
1074
                        if ( i == 0 || i == 1 ) {
1086
                        if ( i == 0 || i == 1 || i == 2 ) {
1075
                            // Disable the 2 first columns, we cannot update them.
1087
                            // Disable the 2 first columns, we cannot update them.
1076
                            var val = $(current_column).find("select option:selected").val();
1088
                            var val = $(current_column).find("select option:selected").val();
1077
                            var name = "categorycode";
1089
                            var name = "categorycode";
1078
                            if ( i == 1 ) {
1090
                            if ( i == 1 ) {
1079
                                name="itemtype";
1091
                                name="itemtype";
1080
                            }
1092
                            }
1093
                            if ( i == 2 ) {
1094
                                name="onsite_checkout";
1095
                            }
1081
                            // Remove potential previous input added
1096
                            // Remove potential previous input added
1082
                            $(current_column).find("input").remove();
1097
                            $(current_column).find("input").remove();
1083
                            $(current_column).append("<input type='hidden' name='"+name+"' value='"+val+"' />");
1098
                            $(current_column).append("<input type='hidden' name='"+name+"' value='"+val+"' />");
1084
                        } else if ( i == 5 || i == 6 || i == 25 || i == 26 || i == 27 ) {
1099
                        } else if ( i == 6 || i == 25 || i == 26 || i == 27 ) {
1085
                            // If the value is not an integer for
1100
                            // If the value is not an integer for
1086
                            //     - "Current checkouts allowed"
1101
                            //     - "Current checkouts allowed"
1087
                            //     - "Current on-site checkouts allowed"
1088
                            //     - "Holds allowed (total)"
1102
                            //     - "Holds allowed (total)"
1089
                            //     - "Holds allowed (daily)"
1103
                            //     - "Holds allowed (daily)"
1090
                            //     - "Holds per record (count)"
1104
                            //     - "Holds per record (count)"
Lines 1098-1103 Link Here
1098
                });
1112
                });
1099
                $("#default-circulation-rules tr:last td:eq(0) select").prop('disabled', true);
1113
                $("#default-circulation-rules tr:last td:eq(0) select").prop('disabled', true);
1100
                $("#default-circulation-rules tr:last td:eq(1) select").prop('disabled', true);
1114
                $("#default-circulation-rules tr:last td:eq(1) select").prop('disabled', true);
1115
                $("#default-circulation-rules tr:last td:eq(2) select").prop('disabled', true);
1101
                return false;
1116
                return false;
1102
            });
1117
            });
1103
            $(".clear_edit").on("click",function(e){
1118
            $(".clear_edit").on("click",function(e){
1104
- 

Return to bug 26814