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

(-)a/admin/clone-rules.pl (-102 lines)
Lines 1-102 Link Here
1
#!/usr/bin/perl
2
# vim: et ts=4 sw=4
3
# Copyright BibLibre 
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
21
# This script clones issuing rules from a library to another
22
# parameters : 
23
#  - frombranch : the branch we want to clone issuing rules from
24
#  - tobranch   : the branch we want to clone issuing rules to
25
#
26
# The script can be called with one of the parameters, both or none
27
28
use strict;
29
#use warnings; FIXME - Bug 2505
30
use CGI qw ( -utf8 );
31
use C4::Context;
32
use C4::Output;
33
use C4::Auth;
34
use C4::Koha;
35
use C4::Debug;
36
37
my $input = new CGI;
38
my $dbh = C4::Context->dbh;
39
40
my ($template, $loggedinuser, $cookie)
41
    = get_template_and_user({template_name => "admin/clone-rules.tt",
42
                            query => $input,
43
                            type => "intranet",
44
                            authnotrequired => 0,
45
                            flagsrequired => {parameters => 'parameters_remaining_permissions'},
46
                            debug => 1,
47
                            });
48
49
my $frombranch = $input->param("frombranch");
50
my $tobranch   = $input->param("tobranch");
51
52
$template->param(frombranch     => $frombranch)                if ($frombranch);
53
$template->param(tobranch       => $tobranch)                  if ($tobranch);
54
55
if ($frombranch && $tobranch) {
56
57
    my $error;	
58
59
    # First, we create a temporary table with the rules we want to clone
60
    my $query = "CREATE TEMPORARY TABLE tmpissuingrules ENGINE=memory SELECT * FROM issuingrules WHERE branchcode=?";
61
    my $sth = $dbh->prepare($query);
62
    my $res = $sth->execute($frombranch);
63
    $error = 1 unless ($res);
64
65
    if (!$error) {
66
	# We modify these rules according to the new branchcode
67
	$query = "UPDATE tmpissuingrules SET branchcode=? WHERE branchcode=?";
68
	$sth = $dbh->prepare($query);
69
	$res = $sth->execute($tobranch, $frombranch);
70
	$error = 1 unless ($res);
71
    }
72
73
    if (!$error) {
74
	# We delete the rules for the existing branchode
75
	$query = "DELETE FROM issuingrules WHERE branchcode=?";
76
	$sth = $dbh->prepare($query);
77
	$res = $sth->execute($tobranch);
78
	$error = 1 unless ($res);
79
    }
80
81
82
    if (!$error) {
83
	# We insert the new rules from our temporary table
84
	$query = "INSERT INTO issuingrules SELECT * FROM tmpissuingrules WHERE branchcode=?";
85
	$sth = $dbh->prepare($query);
86
	$res = $sth->execute($tobranch);
87
	$error = 1 unless ($res);
88
    }
89
90
    # Finally, we delete our temporary table
91
    $query = "DROP TABLE tmpissuingrules";
92
    $sth = $dbh->prepare($query);
93
    $res = $sth->execute();
94
95
    $template->param(result => "1");
96
    $template->param(error  => $error);
97
}
98
99
100
101
output_html_with_http_headers $input, $cookie, $template->output;
102
(-)a/admin/smart-rules.pl (-602 lines)
Lines 1-602 Link Here
1
#!/usr/bin/perl
2
# Copyright 2000-2002 Katipo Communications
3
# copyright 2010 BibLibre
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use strict;
21
use warnings;
22
use CGI qw ( -utf8 );
23
use C4::Context;
24
use C4::Output;
25
use C4::Auth;
26
use C4::Koha;
27
use C4::Debug;
28
use Koha::DateUtils;
29
use Koha::Database;
30
use Koha::Logger;
31
use Koha::RefundLostItemFeeRules;
32
use Koha::Libraries;
33
use Koha::Patron::Categories;
34
use Koha::Patrons;
35
use Koha::CirculationRules;
36
37
my $input = CGI->new;
38
my $dbh = C4::Context->dbh;
39
40
# my $flagsrequired;
41
# $flagsrequired->{circulation}=1;
42
my ($template, $loggedinuser, $cookie)
43
    = get_template_and_user({template_name => "admin/smart-rules.tt",
44
                            query => $input,
45
                            type => "intranet",
46
                            authnotrequired => 0,
47
                            flagsrequired => {parameters => 'manage_circ_rules'},
48
                            debug => 1,
49
                            });
50
51
my $type=$input->param('type');
52
53
my $branch = $input->param('branch');
54
unless ( $branch ) {
55
    if ( C4::Context->preference('DefaultToLoggedInLibraryCircRules') ) {
56
        $branch = Koha::Libraries->search->count() == 1 ? undef : C4::Context::mybranch();
57
    }
58
    else {
59
        $branch = C4::Context::only_my_library() ? ( C4::Context::mybranch() || '*' ) : '*';
60
    }
61
}
62
63
my $uid = Koha::Patrons->find( $loggedinuser )->userid;
64
my $restricted_to_own_library = $uid && haspermission( $uid, { parameters => 'manage_circ_rules_restricted' }, { no_inherit => 1 } );
65
$template->param( restricted_to_own_library => $restricted_to_own_library );
66
$branch = C4::Context::mybranch() if $restricted_to_own_library;
67
68
$branch = '*' if $branch eq 'NO_LIBRARY_SET';
69
70
my $op = $input->param('op') || q{};
71
my $language = C4::Languages::getlanguage();
72
73
if ($op eq 'delete') {
74
    my $itemtype     = $input->param('itemtype');
75
    my $categorycode = $input->param('categorycode');
76
    $debug and warn "deleting $1 $2 $branch";
77
78
    Koha::CirculationRules->set_rules(
79
        {
80
            categorycode => $categorycode eq '*' ? undef : $categorycode,
81
            branchcode   => $branch eq '*' ? undef : $branch,
82
            itemtype     => $itemtype eq '*' ? undef : $itemtype,
83
            rules        => {
84
                restrictedtype                   => undef,
85
                rentaldiscount                   => undef,
86
                fine                             => undef,
87
                finedays                         => undef,
88
                maxsuspensiondays                => undef,
89
                firstremind                      => undef,
90
                chargeperiod                     => undef,
91
                chargeperiod_charge_at           => undef,
92
                accountsent                      => undef,
93
                issuelength                      => undef,
94
                lengthunit                       => undef,
95
                hardduedate                      => undef,
96
                hardduedatecompare               => undef,
97
                renewalsallowed                  => undef,
98
                renewalperiod                    => undef,
99
                norenewalbefore                  => undef,
100
                auto_renew                       => undef,
101
                no_auto_renewal_after            => undef,
102
                no_auto_renewal_after_hard_limit => undef,
103
                reservesallowed                  => undef,
104
                holds_per_record                 => undef,
105
                overduefinescap                  => undef,
106
                cap_fine_to_replacement_price    => undef,
107
                onshelfholds                     => undef,
108
                opacitemholds                    => undef,
109
                article_requests                 => undef,
110
            }
111
        }
112
    );
113
}
114
elsif ($op eq 'delete-branch-cat') {
115
    my $categorycode  = $input->param('categorycode');
116
    if ($branch eq "*") {
117
        if ($categorycode eq "*") {
118
            Koha::CirculationRules->set_rules(
119
                {
120
                    branchcode   => undef,
121
                    categorycode => undef,
122
                    rules        => {
123
                        patron_maxissueqty             => undef,
124
                        patron_maxonsiteissueqty       => undef,
125
                    }
126
                }
127
            );
128
            Koha::CirculationRules->set_rules(
129
                {
130
                    branchcode   => undef,
131
                    itemtype     => undef,
132
                    rules        => {
133
                        holdallowed             => undef,
134
                        hold_fulfillment_policy => undef,
135
                        returnbranch            => undef,
136
                    }
137
                }
138
            );
139
        } else {
140
            Koha::CirculationRules->set_rules(
141
                {
142
                    categorycode => $categorycode,
143
                    branchcode   => undef,
144
                    rules        => {
145
                        max_holds         => undef,
146
                        patron_maxissueqty       => undef,
147
                        patron_maxonsiteissueqty => undef,
148
                    }
149
                }
150
            );
151
        }
152
    } elsif ($categorycode eq "*") {
153
        Koha::CirculationRules->set_rules(
154
            {
155
                branchcode   => $branch,
156
                categorycode => undef,
157
                rules        => {
158
                    patron_maxissueqty       => undef,
159
                    patron_maxonsiteissueqty => undef,
160
                }
161
            }
162
        );
163
        Koha::CirculationRules->set_rules(
164
            {
165
                branchcode   => $branch,
166
                rules        => {
167
                    holdallowed             => undef,
168
                    hold_fulfillment_policy => undef,
169
                    returnbranch            => undef,
170
                }
171
            }
172
        );
173
    } else {
174
        Koha::CirculationRules->set_rules(
175
            {
176
                categorycode => $categorycode,
177
                branchcode   => $branch,
178
                rules        => {
179
                    max_holds         => undef,
180
                    maxissueqty       => undef,
181
                    maxonsiteissueqty => undef,
182
                }
183
            }
184
        );
185
    }
186
}
187
elsif ($op eq 'delete-branch-item') {
188
    my $itemtype  = $input->param('itemtype');
189
    if ($branch eq "*") {
190
        if ($itemtype eq "*") {
191
            Koha::CirculationRules->set_rules(
192
                {
193
                    branchcode   => undef,
194
                    itemtype     => undef,
195
                    rules        => {
196
                        holdallowed             => undef,
197
                        hold_fulfillment_policy => undef,
198
                        returnbranch            => undef,
199
                    }
200
                }
201
            );
202
        } else {
203
            Koha::CirculationRules->set_rules(
204
                {
205
                    branchcode   => undef,
206
                    itemtype     => $itemtype,
207
                    rules        => {
208
                        holdallowed             => undef,
209
                        hold_fulfillment_policy => undef,
210
                        returnbranch            => undef,
211
                    }
212
                }
213
            );
214
        }
215
    } elsif ($itemtype eq "*") {
216
        Koha::CirculationRules->set_rules(
217
            {
218
                branchcode   => $branch,
219
                itemtype     => undef,
220
                rules        => {
221
                    holdallowed             => undef,
222
                    hold_fulfillment_policy => undef,
223
                    returnbranch            => undef,
224
                }
225
            }
226
        );
227
    } else {
228
        Koha::CirculationRules->set_rules(
229
            {
230
                branchcode   => $branch,
231
                itemtype     => $itemtype,
232
                rules        => {
233
                    holdallowed             => undef,
234
                    hold_fulfillment_policy => undef,
235
                    returnbranch            => undef,
236
                }
237
            }
238
        );
239
    }
240
}
241
# save the values entered
242
elsif ($op eq 'add') {
243
    my $br = $branch; # branch
244
    my $bor  = $input->param('categorycode'); # borrower category
245
    my $itemtype  = $input->param('itemtype');     # item type
246
    my $fine = $input->param('fine');
247
    my $finedays     = $input->param('finedays');
248
    my $maxsuspensiondays = $input->param('maxsuspensiondays');
249
    $maxsuspensiondays = undef if $maxsuspensiondays eq q||;
250
    my $firstremind  = $input->param('firstremind');
251
    my $chargeperiod = $input->param('chargeperiod');
252
    my $chargeperiod_charge_at = $input->param('chargeperiod_charge_at');
253
    my $maxissueqty  = $input->param('maxissueqty');
254
    my $maxonsiteissueqty  = $input->param('maxonsiteissueqty');
255
    my $renewalsallowed  = $input->param('renewalsallowed');
256
    my $renewalperiod    = $input->param('renewalperiod');
257
    my $norenewalbefore  = $input->param('norenewalbefore');
258
    $norenewalbefore = undef if $norenewalbefore =~ /^\s*$/;
259
    my $auto_renew = $input->param('auto_renew') eq 'yes' ? 1 : 0;
260
    my $no_auto_renewal_after = $input->param('no_auto_renewal_after');
261
    $no_auto_renewal_after = undef if $no_auto_renewal_after =~ /^\s*$/;
262
    my $no_auto_renewal_after_hard_limit = $input->param('no_auto_renewal_after_hard_limit') || undef;
263
    $no_auto_renewal_after_hard_limit = eval { dt_from_string( $input->param('no_auto_renewal_after_hard_limit') ) } if ( $no_auto_renewal_after_hard_limit );
264
    $no_auto_renewal_after_hard_limit = output_pref( { dt => $no_auto_renewal_after_hard_limit, dateonly => 1, dateformat => 'iso' } ) if ( $no_auto_renewal_after_hard_limit );
265
    my $reservesallowed  = $input->param('reservesallowed');
266
    my $holds_per_record  = $input->param('holds_per_record');
267
    my $onshelfholds     = $input->param('onshelfholds') || 0;
268
    $maxissueqty =~ s/\s//g;
269
    $maxissueqty = undef if $maxissueqty !~ /^\d+/;
270
    $maxonsiteissueqty =~ s/\s//g;
271
    $maxonsiteissueqty = undef if $maxonsiteissueqty !~ /^\d+/;
272
    my $issuelength  = $input->param('issuelength');
273
    $issuelength = $issuelength eq q{} ? undef : $issuelength;
274
    my $lengthunit  = $input->param('lengthunit');
275
    my $hardduedate = $input->param('hardduedate') || undef;
276
    $hardduedate = eval { dt_from_string( $input->param('hardduedate') ) } if ( $hardduedate );
277
    $hardduedate = output_pref( { dt => $hardduedate, dateonly => 1, dateformat => 'iso' } ) if ( $hardduedate );
278
    my $hardduedatecompare = $input->param('hardduedatecompare');
279
    my $rentaldiscount = $input->param('rentaldiscount');
280
    my $opacitemholds = $input->param('opacitemholds') || 0;
281
    my $article_requests = $input->param('article_requests') || 'no';
282
    my $overduefinescap = $input->param('overduefinescap') || undef;
283
    my $cap_fine_to_replacement_price = $input->param('cap_fine_to_replacement_price') eq 'on';
284
    warn "Adding $br, $bor, $itemtype, $fine, $maxissueqty, $maxonsiteissueqty, $cap_fine_to_replacement_price";
285
286
    my $params = {
287
        fine                          => $fine,
288
        finedays                      => $finedays,
289
        maxsuspensiondays             => $maxsuspensiondays,
290
        firstremind                   => $firstremind,
291
        chargeperiod                  => $chargeperiod,
292
        chargeperiod_charge_at        => $chargeperiod_charge_at,
293
        renewalsallowed               => $renewalsallowed,
294
        renewalperiod                 => $renewalperiod,
295
        norenewalbefore               => $norenewalbefore,
296
        auto_renew                    => $auto_renew,
297
        no_auto_renewal_after         => $no_auto_renewal_after,
298
        no_auto_renewal_after_hard_limit => $no_auto_renewal_after_hard_limit,
299
        reservesallowed               => $reservesallowed,
300
        holds_per_record              => $holds_per_record,
301
        issuelength                   => $issuelength,
302
        lengthunit                    => $lengthunit,
303
        hardduedate                   => $hardduedate,
304
        hardduedatecompare            => $hardduedatecompare,
305
        rentaldiscount                => $rentaldiscount,
306
        onshelfholds                  => $onshelfholds,
307
        opacitemholds                 => $opacitemholds,
308
        overduefinescap               => $overduefinescap,
309
        cap_fine_to_replacement_price => $cap_fine_to_replacement_price,
310
        article_requests              => $article_requests,
311
    };
312
313
    Koha::CirculationRules->set_rules(
314
        {
315
            categorycode => $bor eq '*' ? undef : $bor,
316
            itemtype     => $itemtype eq '*' ? undef : $itemtype,
317
            branchcode   => $br eq '*' ? undef : $br,
318
            rules        => {
319
                maxissueqty       => $maxissueqty,
320
                maxonsiteissueqty => $maxonsiteissueqty,
321
                %$params,
322
            }
323
        }
324
    );
325
326
}
327
elsif ($op eq "set-branch-defaults") {
328
    my $categorycode  = $input->param('categorycode');
329
    my $patron_maxissueqty   = $input->param('patron_maxissueqty');
330
    my $patron_maxonsiteissueqty = $input->param('patron_maxonsiteissueqty');
331
    my $holdallowed   = $input->param('holdallowed');
332
    my $hold_fulfillment_policy = $input->param('hold_fulfillment_policy');
333
    my $returnbranch  = $input->param('returnbranch');
334
    my $max_holds = $input->param('max_holds');
335
    $patron_maxissueqty =~ s/\s//g;
336
    $patron_maxissueqty = undef if $patron_maxissueqty !~ /^\d+/;
337
    $patron_maxonsiteissueqty =~ s/\s//g;
338
    $patron_maxonsiteissueqty = undef if $patron_maxonsiteissueqty !~ /^\d+/;
339
    $holdallowed =~ s/\s//g;
340
    $holdallowed = undef if $holdallowed !~ /^\d+/;
341
    $max_holds =~ s/\s//g;
342
    $max_holds = undef if $max_holds !~ /^\d+/;
343
344
    if ($branch eq "*") {
345
        Koha::CirculationRules->set_rules(
346
            {
347
                itemtype     => undef,
348
                branchcode   => undef,
349
                rules        => {
350
                    holdallowed             => $holdallowed,
351
                    hold_fulfillment_policy => $hold_fulfillment_policy,
352
                    returnbranch            => $returnbranch,
353
                }
354
            }
355
        );
356
        Koha::CirculationRules->set_rules(
357
            {
358
                categorycode => undef,
359
                branchcode   => undef,
360
                rules        => {
361
                    patron_maxissueqty             => $patron_maxissueqty,
362
                    patron_maxonsiteissueqty       => $patron_maxonsiteissueqty,
363
                }
364
            }
365
        );
366
    } else {
367
        Koha::CirculationRules->set_rules(
368
            {
369
                itemtype     => undef,
370
                branchcode   => $branch,
371
                rules        => {
372
                    holdallowed             => $holdallowed,
373
                    hold_fulfillment_policy => $hold_fulfillment_policy,
374
                    returnbranch            => $returnbranch,
375
                }
376
            }
377
        );
378
        Koha::CirculationRules->set_rules(
379
            {
380
                categorycode => undef,
381
                branchcode   => $branch,
382
                rules        => {
383
                    patron_maxissueqty             => $patron_maxissueqty,
384
                    patron_maxonsiteissueqty       => $patron_maxonsiteissueqty,
385
                }
386
            }
387
        );
388
    }
389
    Koha::CirculationRules->set_rule(
390
        {
391
            branchcode   => $branch,
392
            categorycode => '*',
393
            itemtype     => undef,
394
            rule_name    => 'max_holds',
395
            rule_value   => $max_holds,
396
        }
397
    );
398
}
399
elsif ($op eq "add-branch-cat") {
400
    my $categorycode  = $input->param('categorycode');
401
    my $patron_maxissueqty   = $input->param('patron_maxissueqty');
402
    my $patron_maxonsiteissueqty = $input->param('patron_maxonsiteissueqty');
403
    my $max_holds = $input->param('max_holds');
404
    $patron_maxissueqty =~ s/\s//g;
405
    $patron_maxissueqty = undef if $patron_maxissueqty !~ /^\d+/;
406
    $patron_maxonsiteissueqty =~ s/\s//g;
407
    $patron_maxonsiteissueqty = undef if $patron_maxonsiteissueqty !~ /^\d+/;
408
    $max_holds =~ s/\s//g;
409
    $max_holds = undef if $max_holds !~ /^\d+/;
410
411
    if ($branch eq "*") {
412
        if ($categorycode eq "*") {
413
            Koha::CirculationRules->set_rules(
414
                {
415
                    categorycode => undef,
416
                    branchcode   => undef,
417
                    rules        => {
418
                        max_holds         => $max_holds,
419
                        patron_maxissueqty       => $patron_maxissueqty,
420
                        patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
421
                    }
422
                }
423
            );
424
        } else {
425
            Koha::CirculationRules->set_rules(
426
                {
427
                    categorycode => $categorycode,
428
                    branchcode   => undef,
429
                    rules        => {
430
                        max_holds         => $max_holds,
431
                        patron_maxissueqty       => $patron_maxissueqty,
432
                        patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
433
                    }
434
                }
435
            );
436
        }
437
    } elsif ($categorycode eq "*") {
438
        Koha::CirculationRules->set_rules(
439
            {
440
                categorycode => undef,
441
                branchcode   => $branch,
442
                rules        => {
443
                    max_holds         => $max_holds,
444
                    patron_maxissueqty       => $patron_maxissueqty,
445
                    patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
446
                }
447
            }
448
        );
449
    } else {
450
        Koha::CirculationRules->set_rules(
451
            {
452
                categorycode => $categorycode,
453
                branchcode   => $branch,
454
                rules        => {
455
                    max_holds         => $max_holds,
456
                    patron_maxissueqty       => $patron_maxissueqty,
457
                    patron_maxonsiteissueqty => $patron_maxonsiteissueqty,
458
                }
459
            }
460
        );
461
    }
462
}
463
elsif ($op eq "add-branch-item") {
464
    my $itemtype                = $input->param('itemtype');
465
    my $holdallowed             = $input->param('holdallowed');
466
    my $hold_fulfillment_policy = $input->param('hold_fulfillment_policy');
467
    my $returnbranch            = $input->param('returnbranch');
468
469
    $holdallowed =~ s/\s//g;
470
    $holdallowed = undef if $holdallowed !~ /^\d+/;
471
472
    if ($branch eq "*") {
473
        if ($itemtype eq "*") {
474
            Koha::CirculationRules->set_rules(
475
                {
476
                    itemtype     => undef,
477
                    branchcode   => undef,
478
                    rules        => {
479
                        holdallowed             => $holdallowed,
480
                        hold_fulfillment_policy => $hold_fulfillment_policy,
481
                        returnbranch            => $returnbranch,
482
                    }
483
                }
484
            );
485
        } else {
486
            Koha::CirculationRules->set_rules(
487
                {
488
                    itemtype     => $itemtype,
489
                    branchcode   => undef,
490
                    rules        => {
491
                        holdallowed             => $holdallowed,
492
                        hold_fulfillment_policy => $hold_fulfillment_policy,
493
                        returnbranch            => $returnbranch,
494
                    }
495
                }
496
            );
497
        }
498
    } elsif ($itemtype eq "*") {
499
            Koha::CirculationRules->set_rules(
500
                {
501
                    itemtype     => undef,
502
                    branchcode   => $branch,
503
                    rules        => {
504
                        holdallowed             => $holdallowed,
505
                        hold_fulfillment_policy => $hold_fulfillment_policy,
506
                        returnbranch            => $returnbranch,
507
                    }
508
                }
509
            );
510
    } else {
511
        Koha::CirculationRules->set_rules(
512
            {
513
                itemtype     => $itemtype,
514
                branchcode   => $branch,
515
                rules        => {
516
                    holdallowed             => $holdallowed,
517
                    hold_fulfillment_policy => $hold_fulfillment_policy,
518
                    returnbranch            => $returnbranch,
519
                }
520
            }
521
        );
522
    }
523
}
524
elsif ( $op eq 'mod-refund-lost-item-fee-rule' ) {
525
526
    my $refund = $input->param('refund');
527
528
    if ( $refund eq '*' ) {
529
        if ( $branch ne '*' ) {
530
            # only do something for $refund eq '*' if branch-specific
531
            Koha::CirculationRules->set_rules(
532
                {
533
                    branchcode   => $branch,
534
                    rules        => {
535
                        refund => undef
536
                    }
537
                }
538
            );
539
        }
540
    } else {
541
        Koha::CirculationRules->set_rules(
542
            {
543
                branchcode   => undef,
544
                rules        => {
545
                    refund => $refund
546
                }
547
            }
548
        );
549
    }
550
}
551
552
my $refundLostItemFeeRule = Koha::RefundLostItemFeeRules->find({ branchcode => $branch eq '*' ? undef : $branch });
553
$template->param(
554
    refundLostItemFeeRule => $refundLostItemFeeRule,
555
    defaultRefundRule     => Koha::RefundLostItemFeeRules->_default_rule
556
);
557
558
my $patron_categories = Koha::Patron::Categories->search({}, { order_by => ['description'] });
559
560
my $itemtypes = Koha::ItemTypes->search_with_localization;
561
562
$template->param(show_branch_cat_rule_form => 1);
563
564
$template->param(
565
    patron_categories => $patron_categories,
566
    itemtypeloop      => $itemtypes,
567
    humanbranch       => ( $branch ne '*' ? $branch : undef ),
568
    current_branch    => $branch,
569
);
570
output_html_with_http_headers $input, $cookie, $template->output;
571
572
exit 0;
573
574
# sort by patron category, then item type, putting
575
# default entries at the bottom
576
sub by_category_and_itemtype {
577
    unless (by_category($a, $b)) {
578
        return by_itemtype($a, $b);
579
    }
580
}
581
582
sub by_category {
583
    my ($a, $b) = @_;
584
    if ($a->{'default_humancategorycode'}) {
585
        return ($b->{'default_humancategorycode'} ? 0 : 1);
586
    } elsif ($b->{'default_humancategorycode'}) {
587
        return -1;
588
    } else {
589
        return $a->{'humancategorycode'} cmp $b->{'humancategorycode'};
590
    }
591
}
592
593
sub by_itemtype {
594
    my ($a, $b) = @_;
595
    if ($a->{default_translated_description}) {
596
        return ($b->{'default_translated_description'} ? 0 : 1);
597
    } elsif ($b->{'default_translated_description'}) {
598
        return -1;
599
    } else {
600
        return lc $a->{'translated_description'} cmp lc $b->{'translated_description'};
601
    }
602
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc (-1 / +1 lines)
Lines 31-37 Link Here
31
<h5>Patrons and circulation</h5>
31
<h5>Patrons and circulation</h5>
32
<ul>
32
<ul>
33
    <li><a href="/cgi-bin/koha/admin/categories.pl">Patron categories</a></li>
33
    <li><a href="/cgi-bin/koha/admin/categories.pl">Patron categories</a></li>
34
    <li><a href="/cgi-bin/koha/admin/smart-rules.pl">Circulation and fines rules</a></li>
34
    <li><a href="/cgi-bin/koha/admin/policy.pl">Circulation, fines, and holds rules</a></li>
35
    <li><a href="/cgi-bin/koha/admin/patron-attr-types.pl">Patron attribute types</a></li>
35
    <li><a href="/cgi-bin/koha/admin/patron-attr-types.pl">Patron attribute types</a></li>
36
    <li><a href="/cgi-bin/koha/admin/branch_transfer_limits.pl">Library transfer limits</a></li>
36
    <li><a href="/cgi-bin/koha/admin/branch_transfer_limits.pl">Library transfer limits</a></li>
37
    <li><a href="/cgi-bin/koha/admin/transport-cost-matrix.pl">Transport cost matrix</a></li>
37
    <li><a href="/cgi-bin/koha/admin/transport-cost-matrix.pl">Transport cost matrix</a></li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt (-2 / +2 lines)
Lines 42-49 Link Here
42
                    <dt><a href="/cgi-bin/koha/admin/categories.pl">Patron categories</a></dt>
42
                    <dt><a href="/cgi-bin/koha/admin/categories.pl">Patron categories</a></dt>
43
                    <dd>Define patron categories.</dd>
43
                    <dd>Define patron categories.</dd>
44
                [% IF CAN_user_parameters_manage_circ_rules %]
44
                [% IF CAN_user_parameters_manage_circ_rules %]
45
                    <dt><a href="/cgi-bin/koha/admin/smart-rules.pl">Circulation and fines rules</a></dt>
45
                    <dt><a href="/cgi-bin/koha/admin/policy.pl">Circulation, fines, and holds rules</a></dt>
46
                    <dd>Define circulation and fines rules for combinations of libraries, patron categories, and item types</dd>
46
                    <dd>Define circulation, fines, and holds rules for combinations of libraries, patron categories, and item types</dd>
47
                [% END %]
47
                [% END %]
48
                    <dt><a href="/cgi-bin/koha/admin/patron-attr-types.pl">Patron attribute types</a></dt>
48
                    <dt><a href="/cgi-bin/koha/admin/patron-attr-types.pl">Patron attribute types</a></dt>
49
                    <dd>Define extended attributes (identifiers and statistical categories) for patron records</dd>
49
                    <dd>Define extended attributes (identifiers and statistical categories) for patron records</dd>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/clone-rules.tt (-67 lines)
Lines 1-67 Link Here
1
[% USE Branches %]
2
[% INCLUDE 'doc-head-open.inc' %]
3
<title>Koha &rsaquo; Administration &rsaquo; Circulation and fine rules &rsaquo; Clone circulation and fine rules</title>
4
[% INCLUDE 'doc-head-close.inc' %]
5
</head>
6
<body id="admin_clone-rules" class="admin">
7
[% INCLUDE 'header.inc' %]
8
[% INCLUDE 'prefs-admin-search.inc' %]
9
10
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo; <a href="/cgi-bin/koha/admin/smart-rules.pl">Circulation and fine rules</a> &rsaquo; Clone circulation and fine rules</div>
11
12
<div id="doc3" class="yui-t1">
13
14
<div id="bd">
15
    <div id="yui-main">
16
    <div class="yui-b">
17
    <h2>Cloning circulation and fine rules
18
        [% IF frombranch %] from "[% Branches.GetName( frombranch ) %]"[% END %]
19
        [% IF tobranch %] to "[% Branches.GetName( tobranch ) %]"[% END %]
20
    </h2>
21
22
    [% IF ( result ) %]
23
	[% IF ( error ) %]
24
        <div class="dialog alert">Cloning of circulation and fine rules failed!</div>
25
	[% ELSE %]
26
	    <div class="dialog message"><p>The rules have been cloned.</p></div>
27
	[% END %]
28
    <a href="/cgi-bin/koha/admin/smart-rules.pl">Return to circulation and fine rules</a>
29
    [% ELSE %]
30
31
    <p class="help">Use carefully! If the destination library already has circulation and fine rules, they will be deleted without warning!</p>
32
    <form action="/cgi-bin/koha/admin/clone-rules.pl" method="post">
33
        [% UNLESS ( frombranch ) %]
34
            <fieldset>
35
                <legend>Please choose a library to clone rules from:</legend>
36
                <label for="frombranch">Source library:</label>
37
                <select name="frombranch" id="frombranch">
38
                    <option value="">Default</option>
39
                    [% PROCESS options_for_libraries libraries => Branches.all() %]
40
                </select>
41
                [% IF ( tobranch ) %]<input type="hidden" name="tobranch" value="[% tobranch %]" />[% END %]
42
            </fieldset>
43
        [% END %]
44
45
        [% UNLESS ( tobranch ) %]
46
            <fieldset>
47
            <legend>Please choose the library to clone the rules to:</legend>
48
            <label for="tobranch">Destination library:</label>
49
            <select name="tobranch" id="tobranch">
50
                <option value="">Default</option>
51
                [% PROCESS options_for_libraries libraries => Branches.all() %]
52
            </select>
53
            [% IF ( frombranch ) %]<input type="hidden" name="frombranch" value="[% frombranch %]" />[% END %]
54
            </fieldset>
55
        [% END %]
56
        <input type="submit" value="Submit" />
57
    </form>
58
59
    [% END %]
60
    </div>
61
62
</div>
63
<div class="yui-b">
64
[% INCLUDE 'admin-menu.inc' %]
65
</div>
66
</div>
67
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/policy.tt (-2 / +2 lines)
Lines 9-20 Link Here
9
[% INCLUDE 'doc-head-close.inc' %]
9
[% INCLUDE 'doc-head-close.inc' %]
10
<link rel="stylesheet" href="[% interface %]/[% theme %]/css/admin/policy.css" />
10
<link rel="stylesheet" href="[% interface %]/[% theme %]/css/admin/policy.css" />
11
</head>
11
</head>
12
<body id="admin_smart-rules" class="admin">
12
<body id="admin_policy" class="admin">
13
[% INCLUDE 'header.inc' %]
13
[% INCLUDE 'header.inc' %]
14
[% INCLUDE 'calendar.inc' %]
14
[% INCLUDE 'calendar.inc' %]
15
[% INCLUDE 'prefs-admin-search.inc' %]
15
[% INCLUDE 'prefs-admin-search.inc' %]
16
16
17
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo; Policy</div>
17
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo; Circulation, fines and holds rules</div>
18
18
19
<div id="doc3" class="yui-t1">
19
<div id="doc3" class="yui-t1">
20
20
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-928 lines)
Lines 1-928 Link Here
1
[% USE KohaDates %]
2
[% USE Branches %]
3
[% USE Categories %]
4
[% USE ItemTypes %]
5
[% USE CirculationRules %]
6
7
[% SET branchcode = humanbranch || undef %]
8
9
[% SET categorycodes = [] %]
10
[% FOREACH pc IN patron_categories %]
11
    [% categorycodes.push( pc.id ) %]
12
[% END %]
13
[% categorycodes.push(undef) %]
14
15
[% SET itemtypes = [] %]
16
[% FOREACH i IN itemtypeloop %]
17
    [% itemtypes.push( i.itemtype ) %]
18
[% END %]
19
[% itemtypes.push(undef) %]
20
21
[% INCLUDE 'doc-head-open.inc' %]
22
<title>Koha &rsaquo; Administration &rsaquo; Circulation and fine rules</title>
23
[% INCLUDE 'doc-head-close.inc' %]
24
[% INCLUDE 'calendar.inc' %]
25
<script type="text/javascript">
26
//<![CDATA[
27
28
function clear_edit(){
29
    var cancel = confirm(_("Are you sure you want to cancel your changes?"));
30
    if ( !cancel ) return;
31
    $('#default-circulation-rules td').removeClass('highlighted-row');
32
    var edit_row = $("#edit_row");
33
    $(edit_row).find("input").each(function(){
34
        var type = $(this).attr("type");
35
        if (type != "button" && type != "submit" ) {
36
            $(this).val("");
37
            $(this).prop('disabled', false);
38
        }
39
        if ( type == "checkbox" ) {
40
            $(this).prop('checked', false);
41
        }
42
    });
43
    $(edit_row).find("select").prop('disabled', false);
44
    $(edit_row).find("select option:first").attr("selected", "selected");
45
    $(edit_row).find("td:last input[name='clear']").remove();
46
}
47
48
var MSG_CONFIRM_DELETE = _("Are you sure you want to delete this rule? This cannot be undone.");
49
50
$(document).ready(function() {
51
    $(".delete").on("click",function(){
52
        return confirmDelete(MSG_CONFIRM_DELETE);
53
    });
54
55
        $('#cap_fine_to_replacement_price').on('change', function(){
56
            $('#overduefinescap').prop('disabled', $(this).is(':checked') );
57
        });
58
        $('#selectlibrary').find("input:submit").hide();
59
        $('#branch').change(function() {
60
                $('#selectlibrary').submit();
61
        });
62
        $(".editrule").click(function(){
63
            if ( $("#edit_row").find("input[type='text']").filter(function(){return this.value.length > 0 }).length > 0 ) {
64
                var edit = confirm(_("Are you sure you want to edit another rule?"));
65
                if (!edit) return false;
66
            }
67
            $('#default-circulation-rules td').removeClass('highlighted-row');
68
            $(this).parent().parent().find("td").each(function (i) {
69
                $(this).addClass('highlighted-row');
70
                itm = $(this).text();
71
                itm = itm.replace(/^\s*|\s*$/g,'');
72
                var current_column = $("#edit_row td:eq("+i+")");
73
                if ( i == 6 ) {
74
                    // specific processing for the Hard due date column
75
                    var select_value = $(this).find("input[type='hidden'][name='hardduedatecomparebackup']").val();
76
                    var input_value = '';
77
                    if (typeof select_value === 'undefined'){
78
                        select_value = '-1';
79
                    }else {
80
                        input_value = itm.split(' ')[1];
81
                    }
82
                    $(current_column).find("input[type='text']").val(input_value);
83
                    $(current_column).find("select").val(select_value);
84
                } else if ( i == 12 ) {
85
                    // specific processing for cap_fine_to_replacement_price
86
                    var cap_fine_to_replacement_price = $(this).find("input[type='checkbox']");
87
                    $('#cap_fine_to_replacement_price').prop('checked', cap_fine_to_replacement_price.is(':checked') );
88
                    $('#overduefinescap').prop('disabled', cap_fine_to_replacement_price.is(':checked') );
89
                } else {
90
                    $(current_column).find("input[type='text']").val(itm);
91
                    // select the corresponding option
92
                    $(current_column).find("select option").each(function(){
93
                        opt = $(this).text().toLowerCase();
94
                        opt = opt.replace(/^\s*|\s*$/g,'');
95
                        if ( opt == itm.toLowerCase() ) {
96
                            $(this).attr('selected', 'selected');
97
                        }
98
                    });
99
                    if ( i == 0 || i == 1 ) {
100
                        // Disable the 2 first columns, we cannot update them.
101
                        var val = $(current_column).find("select option:selected").val();
102
                        var name = "categorycode";
103
                        if ( i == 1 ) {
104
                            name="itemtype";
105
                        }
106
                        // Remove potential previous input added
107
                        $(current_column).find("input").remove();
108
                        $(current_column).append("<input type='hidden' name='"+name+"' value='"+val+"' />");
109
                    } else if ( i == 2 || i == 3 ) {
110
                        // If the value is not an integer for "Current checkouts allowed" or "Current on-site checkouts allowed"
111
                        // The value is "Unlimited" (or an equivalent translated string)
112
                        // an it should be set to an empty string
113
                        if( !((parseFloat(itm) == parseInt(itm)) && !isNaN(itm)) ) {
114
                            $(current_column).find("input[type='text']").val("");
115
                        }
116
                    }
117
                }
118
            });
119
            $("#default-circulation-rules tr:last td:eq(0) select").prop('disabled', true);
120
            $("#default-circulation-rules tr:last td:eq(1) select").prop('disabled', true);
121
            return false;
122
        });
123
        $(".clear_edit").on("click",function(e){
124
            e.preventDefault();
125
            clear_edit();
126
        });
127
});
128
//]]>
129
</script>
130
</head>
131
<body id="admin_smart-rules" class="admin">
132
[% INCLUDE 'header.inc' %]
133
[% INCLUDE 'prefs-admin-search.inc' %]
134
135
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo; Circulation and fine rules</div>
136
137
<div id="doc3" class="yui-t1">
138
139
<div id="bd">
140
    <div id="yui-main">
141
    <div class="yui-b">
142
    <h1 class="parameters">
143
        [% IF humanbranch %]
144
            Defining circulation and fine rules for "[% Branches.GetName( humanbranch ) %]"
145
        [% ELSE %]
146
            Defining circulation and fine rules for all libraries
147
        [% END %]
148
    </h1>
149
    <div class="help">
150
        <p>The rules are applied from most specific to less specific, using the first found in this order:</p>
151
        <ul>
152
            <li>same library, same patron category, same item type</li>
153
            <li>same library, same patron category, all item types</li>
154
            <li>same library, all patron categories, same item type</li>
155
            <li>same library, all patron categories, all item types</li>
156
            <li>default (all libraries), same patron category, same item type</li>
157
            <li>default (all libraries), same patron category, all item types</li>
158
            <li>default (all libraries), all patron categories, same item type</li>
159
            <li>default (all libraries), all patron categories, all item types</li>
160
        </ul>
161
        <p>To modify a rule, create a new one with the same patron category and item type.</p>
162
    </div>
163
    <div>
164
        [% UNLESS restricted_to_own_library %]
165
            <form method="get" action="/cgi-bin/koha/admin/smart-rules.pl" id="selectlibrary">
166
            Select a library :
167
                <select name="branch" id="branch" style="width:20em;">
168
                    <option value="*">Standard rules for all libraries</option>
169
                    [% PROCESS options_for_libraries libraries => Branches.all( selected => current_branch, unfiltered => 1 ) %]
170
                </select>
171
            </form>
172
            [% IF ( definedbranch ) %]
173
                <form action="/cgi-bin/koha/admin/clone-rules.pl" method="post">
174
                    <label for="tobranch"><strong>Clone these rules to:</strong></label>
175
                    <input type="hidden" name="frombranch" value="[% current_branch %]" />
176
                    <select name="tobranch" id="tobranch">
177
                        [% PROCESS options_for_libraries libraries => Branches.all( unfiltered => 1 ) %]
178
                    </select>
179
                    <input type="submit" value="Clone" />
180
                </form>
181
            [% END %]
182
        [% END %]
183
184
        <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
185
            <input type="hidden" name="op" value="add" />
186
            <input type="hidden" name="branch" value="[% current_branch %]"/>
187
            <table id="default-circulation-rules">
188
            <thead>
189
            <tr>
190
                <th>Patron category</th>
191
                <th>Item type</th>
192
                <th>Actions</th>
193
                <th>Current checkouts allowed</th>
194
                <th>Current on-site checkouts allowed</th>
195
                <th>Loan period</th>
196
                <th>Unit</th>
197
                <th>Hard due date</th>
198
                <th>Fine amount</th>
199
                <th>Fine charging interval</th>
200
                <th>When to charge</th>
201
                <th>Fine grace period</th>
202
                <th>Overdue fines cap (amount)</th>
203
                <th>Cap fine at replacement price</th>
204
                <th>Suspension in days (day)</th>
205
                <th>Max. suspension duration (day)</th>
206
                <th>Renewals allowed (count)</th>
207
                <th>Renewal period</th>
208
                <th>No renewal before</th>
209
                <th>Automatic renewal</th>
210
                <th>No automatic renewal after</th>
211
                <th>No automatic renewal after (hard limit)</th>
212
                <th>Holds allowed (count)</th>
213
                <th>Holds per record (count)</th>
214
                <th>On shelf holds allowed</th>
215
                <th>Item level holds</th>
216
                <th>Article requests</th>
217
                <th>Rental discount (%)</th>
218
                <th>Actions</th>
219
            </tr>
220
            </thead>
221
            <tbody>
222
                [% SET row_count = 0 %]
223
                [% FOREACH c IN categorycodes %]
224
                    [% FOREACH i IN itemtypes %]
225
                        [% SET maxissueqty = CirculationRules.Get( branchcode, c, i, 'maxissueqty' ) %]
226
                        [% SET maxonsiteissueqty = CirculationRules.Get( branchcode, c, i, 'maxonsiteissueqty' ) %]
227
                        [% SET issuelength = CirculationRules.Get( branchcode, c, i, 'issuelength' ) %]
228
                        [% SET lengthunit = CirculationRules.Get( branchcode, c, i, 'lengthunit' ) %]
229
                        [% SET hardduedate = CirculationRules.Get( branchcode, c, i, 'hardduedate' ) %]
230
                        [% SET hardduedatecompare = CirculationRules.Get( branchcode, c, i, 'hardduedatecompare' ) %]
231
                        [% SET fine = CirculationRules.Get( branchcode, c, i, 'fine' ) %]
232
                        [% SET chargeperiod = CirculationRules.Get( branchcode, c, i, 'chargeperiod' ) %]
233
                        [% SET chargeperiod_charge_at = CirculationRules.Get( branchcode, c, i, 'chargeperiod_charge_at' ) %]
234
                        [% SET firstremind = CirculationRules.Get( branchcode, c, i, 'firstremind' ) %]
235
                        [% SET overduefinescap = CirculationRules.Get( branchcode, c, i, 'overduefinescap' ) %]
236
                        [% SET cap_fine_to_replacement_price = CirculationRules.Get( branchcode, c, i, 'cap_fine_to_replacement_price' ) %]
237
                        [% SET finedays = CirculationRules.Get( branchcode, c, i, 'finedays' ) %]
238
                        [% SET maxsuspensiondays = CirculationRules.Get( branchcode, c, i, 'maxsuspensiondays' ) %]
239
                        [% SET renewalsallowed = CirculationRules.Get( branchcode, c, i, 'renewalsallowed' ) %]
240
                        [% SET renewalperiod = CirculationRules.Get( branchcode, c, i, 'renewalperiod' ) %]
241
                        [% SET norenewalbefore = CirculationRules.Get( branchcode, c, i, 'norenewalbefore' ) %]
242
                        [% SET auto_renew = CirculationRules.Get( branchcode, c, i, 'auto_renew' ) %]
243
                        [% SET no_auto_renewal_after = CirculationRules.Get( branchcode, c, i, 'no_auto_renewal_after' ) %]
244
                        [% SET no_auto_renewal_after_hard_limit = CirculationRules.Get( branchcode, c, i, 'no_auto_renewal_after_hard_limit' ) %]
245
                        [% SET reservesallowed = CirculationRules.Get( branchcode, c, i, 'reservesallowed' ) %]
246
                        [% SET holds_per_record = CirculationRules.Get( branchcode, c, i, 'holds_per_record' ) %]
247
                        [% SET onshelfholds = CirculationRules.Get( branchcode, c, i, 'onshelfholds' ) %]
248
                        [% SET opacitemholds = CirculationRules.Get( branchcode, c, i, 'opacitemholds' ) %]
249
                        [% SET article_requests = CirculationRules.Get( branchcode, c, i, 'article_requests' ) %]
250
                        [% SET rentaldiscount = CirculationRules.Get( branchcode, c, i, 'rentaldiscount' ) %]
251
252
                        [% SET show_rule = maxissueqty || maxonsiteissueqty || issuelength || lengthunit || hardduedate || hardduedatebefore || hardduedateexact || fine || chargeperiod
253
                                        || chargeperiod_charge_at || firstremind || overduefinescap || cap_fine_to_replacement_price || finedays || maxsuspensiondays || renewalsallowed
254
                                        || renewalsallowed || norenewalbefore || auto_renew || no_auto_renewal_after || no_auto_renewal_after_hard_limit || reservesallowed
255
                                        || holds_per_record || onshelfholds || opacitemholds || article_requests || article_requests %]
256
                        [% IF show_rule %]
257
                            [% SET row_count = row_count + 1 %]
258
                            <tr row_countd="row_[% row_count %]">
259
                                    <td>
260
                                        [% IF c == undef %]
261
                                            <em>All</em>
262
                                        [% ELSE %]
263
                                            [% Categories.GetName(c) %]
264
                                        [% END %]
265
                                    </td>
266
                                    <td>
267
                                        [% IF i == undef %]
268
                                            <em>All</em>
269
                                        [% ELSE %]
270
                                            [% ItemTypes.GetDescription(i) %]
271
                                        [% END %]
272
                                    </td>
273
                                    <td class="actions">
274
                                      <a href="#" class="editrule btn btn-default btn-xs"><i class="fa fa-pencil"></i> Edit</a>
275
                                      <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete&amp;itemtype=[% rule.itemtype || '*' %]&amp;categorycode=[% rule.categorycode || '*' %]&amp;branch=[% current_branch %]"><i class="fa fa-trash"></i> Delete</a>
276
                                    </td>
277
                                    <td>
278
                                        [% IF maxissueqty  %]
279
                                            [% maxissueqty %]
280
                                        [% ELSE %]
281
                                            Unlimited
282
                                        [% END %]
283
                                    </td>
284
                                    <td>
285
                                        [% IF maxonsiteissueqty  %]
286
                                            [% maxonsiteissueqty %]
287
                                        [% ELSE %]
288
                                            Unlimited
289
                                        [% END %]
290
                                    </td>
291
                                    <td>[% issuelength %]</td>
292
                                    <td>
293
                                        [% lengthunit %]
294
                                    </td>
295
                                    <td>
296
                                      [% IF ( hardduedate ) %]
297
                                        [% IF ( hardduedatecompare == '-1' ) %]
298
                                          before [% hardduedate | $KohaDates %]
299
                                          <input type="hidden" name="hardduedatecomparebackup" value="-1" />
300
                                        [% ELSIF ( hardduedatecompare == '0' ) %]
301
                                          on [% hardduedate | $KohaDates %]
302
                                          <input type="hidden" name="hardduedatecomparebackup" value="0" />
303
                                        [% ELSIF ( hardduedatecompare == '1' ) %]
304
                                          after [% hardduedate | $KohaDates %]
305
                                          <input type="hidden" name="hardduedatecomparebackup" value="1" />
306
                                        [% END %]
307
                                      [% ELSE %]
308
                                        None defined
309
                                      [% END %]
310
                                    </td>
311
                                    <td>[% fine %]</td>
312
                                    <td>[% chargeperiod %]</td>
313
                                    <td>[% IF chargeperiod_charge_at %]Start of interval[% ELSE %]End of interval[% END %]</td>
314
                                    <td>[% firstremind %]</td>
315
                                    <td>[% overduefinescap FILTER format("%.2f") %]</td>
316
                                    <td>
317
                                        [% IF cap_fine_to_replacement_price %]
318
                                            <input type="checkbox" checked="checked" disabled="disabled" />
319
                                        [% ELSE %]
320
                                            <input type="checkbox" disabled="disabled" />
321
                                        [% END %]
322
                                    </td>
323
                                    <td>[% finedays %]</td>
324
                                    <td>[% maxsuspensiondays %]</td>
325
                                    <td>[% renewalsallowed %]</td>
326
                                    <td>[% renewalperiod %]</td>
327
                                    <td>[% norenewalbefore %]</td>
328
                                    <td>
329
                                        [% IF auto_renew %]
330
                                            Yes
331
                                        [% ELSE %]
332
                                            No
333
                                        [% END %]
334
                                    </td>
335
                                    <td>[% no_auto_renewal_after %]</td>
336
                                    <td>[% no_auto_renewal_after_hard_limit %]</td>
337
                                    <td>[% reservesallowed %]</td>
338
                                    <td>[% holds_per_record %]</td>
339
                                    <td>
340
                                        [% IF onshelfholds == 1 %]
341
                                            Yes
342
                                        [% ELSIF onshelfholds == 2 %]
343
                                            If all unavailable
344
                                        [% ELSE %]
345
                                            If any unavailable
346
                                        [% END %]
347
                                    </td>
348
                                    <td>[% IF opacitemholds == 'F'%]Force[% ELSIF opacitemholds == 'Y'%]Allow[% ELSE %]Don't allow[% END %]</td>
349
                                    <td>
350
                                        [% IF article_requests == 'no' %]
351
                                            No
352
                                        [% ELSIF article_requests == 'yes' %]
353
                                            Yes
354
                                        [% ELSIF article_requests == 'bib_only' %]
355
                                            Record only
356
                                        [% ELSIF article_requests == 'item_only' %]
357
                                            Item only
358
                                        [% END %]
359
                                    </td>
360
                                    <td>[% rentaldiscount %]</td>
361
                                    <td class="actions">
362
                                      <a href="#" class="editrule btn btn-default btn-xs"><i class="fa fa-pencil"></i> Edit</a>
363
                                      <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete&amp;itemtype=[% rule.itemtype || '*' %]&amp;categorycode=[% rule.categorycode || '*' %]&amp;branch=[% current_branch %]"><i class="fa fa-trash"></i> Delete</a>
364
                                    </td>
365
                            </tr>
366
                        [% END %]
367
                    [% END %]
368
            	[% END %]
369
                <tr id="edit_row">
370
                    <td>
371
                        <select name="categorycode" id="categorycode">
372
                            <option value="*">All</option>
373
                        [% FOREACH patron_category IN patron_categories%]
374
                            <option value="[% patron_category.categorycode %]">[% patron_category.description %]</option>
375
                        [% END %]
376
                        </select>
377
                    </td>
378
                    <td>
379
                        <select name="itemtype" id="matrixitemtype" style="width:13em;">
380
                            <option value="*">All</option>
381
                        [% FOREACH itemtypeloo IN itemtypeloop %]
382
                            <option value="[% itemtypeloo.itemtype %]">[% itemtypeloo.translated_description %]</option>
383
                        [% END %]
384
                        </select>
385
                    </td>
386
                    <td class="actions">
387
                        <input type="hidden" name="branch" value="[% current_branch %]"/>
388
                        <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-save"></i> Save</button>
389
                        <button name="cancel" class="clear_edit btn btn-default btn-xs"><i class="fa fa-undo"></i> Clear</button>
390
                    </td>
391
                    <td><input type="text" name="maxissueqty" id="maxissueqty" size="3" /></td>
392
                    <td><input type="text" name="maxonsiteissueqty" id="maxonsiteissueqty" size="3" /></td>
393
                    <td><input type="text" name="issuelength" id="issuelength" size="3" /> </td>
394
                    <td>
395
                      <select name="lengthunit" id="lengthunit">
396
                        <option value="days" selected="selected">Days</option>
397
                        <option value="hours">Hours</option>
398
                      </select>
399
                    </td>
400
                    <td>
401
                        <select name="hardduedatecompare" id="hardduedatecompare">
402
                           <option value="-1">Before</option>
403
                           <option value="0">Exactly on</option>
404
                           <option value="1">After</option>
405
                        </select>
406
                        <input type="text" size="10" id="hardduedate" name="hardduedate" value="[% hardduedate %]" class="datepicker" />
407
                        <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
408
                    </td>
409
                    <td><input type="text" name="fine" id="fine" size="4" /></td>
410
                    <td><input type="text" name="chargeperiod" id="chargeperiod" size="2" /></td>
411
                    <td>
412
                        <select name="chargeperiod_charge_at" id="chargeperiod_charge_at">
413
                           <option value="0">End of interval</option>
414
                           <option value="1">Start of interval</option>
415
                        </select>
416
                    </td>
417
                    <td><input type="text" name="firstremind" id="firstremind" size="2" /> </td>
418
                    <td><input type="text" name="overduefinescap" id="overduefinescap" size="6" /> </td>
419
                    <td><input type="checkbox" name="cap_fine_to_replacement_price" id="cap_fine_to_replacement_price" /></td>
420
                    <td><input type="text" name="finedays" id="fined" size="3" /> </td>
421
                    <td><input type="text" name="maxsuspensiondays" id="maxsuspensiondays" size="3" /> </td>
422
                    <td><input type="text" name="renewalsallowed" id="renewalsallowed" size="2" /></td>
423
                    <td><input type="text" name="renewalperiod" id="renewalperiod" size="3" /></td>
424
                    <td><input type="text" name="norenewalbefore" id="norenewalbefore" size="3" /></td>
425
                    <td>
426
                        <select name="auto_renew" id="auto_renew">
427
                            <option value="no" selected>No</option>
428
                            <option value="yes">Yes</option>
429
                        </select>
430
                    </td>
431
                    <td><input type="text" name="no_auto_renewal_after" id="no_auto_renewal_after" size="3" /></td>
432
                    <td>
433
                        <input type="text" size="10" name="no_auto_renewal_after_hard_limit" id="no_auto_renewal_after_hard_limit" value="[% no_auto_renewal_after_hard_limit %]" class="datepicker"/>
434
                        <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
435
                    </td>
436
                    <td><input type="text" name="reservesallowed" id="reservesallowed" size="2" /></td>
437
                    <td><input type="text" name="holds_per_record" id="holds_per_record" size="2" /></td>
438
                    <td>
439
                        <select name="onshelfholds" id="onshelfholds">
440
                            <option value="1">Yes</option>
441
                            <option value="0">If any unavailable</option>
442
                            <option value="2">If all unavailable</option>
443
                        </select>
444
                    </td>
445
                    <td>
446
                        <select id="opacitemholds" name="opacitemholds">
447
                            <option value="N">Don't allow</option>
448
                            <option value="Y">Allow</option>
449
                            <option value="F">Force</option>
450
                        </select>
451
                    </td>
452
                    <td>
453
                        <select id="article_requests" name="article_requests">
454
                            <option value="no">No</option>
455
                            <option value="yes">Yes</option>
456
                            <option value="bib_only">Record only</option>
457
                            <option value="item_only">Item only</option>
458
                        </select>
459
                    </td>
460
                    <td><input type="text" name="rentaldiscount" id="rentaldiscount" size="2" /></td>
461
                    <td class="actions">
462
                        <input type="hidden" name="branch" value="[% current_branch %]"/>
463
                        <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-save"></i> Save</button>
464
                        <button name="cancel" class="clear_edit btn btn-default btn-xs"><i class="fa fa-undo"></i> Clear</button>
465
                    </td>
466
                </tr>
467
                <tfoot>
468
                    <tr>
469
                      <th>Patron category</th>
470
                      <th>Item type</th>
471
                      <th>&nbsp;</th>
472
                      <th>Current checkouts allowed</th>
473
                      <th>Current on-site checkouts allowed</th>
474
                      <th>Loan period</th>
475
                      <th>Unit</th>
476
                      <th>Hard due date</th>
477
                      <th>Fine amount</th>
478
                      <th>Fine charging interval</th>
479
                      <th>Charge when?</th>
480
                      <th>Fine grace period</th>
481
                      <th>Overdue fines cap (amount)</th>
482
                      <th>Cap fine at replacement price</th>
483
                      <th>Suspension in days (day)</th>
484
                      <th>Max. suspension duration (day)</th>
485
                      <th>Renewals allowed (count)</th>
486
                      <th>Renewal period</th>
487
                      <th>No renewal before</th>
488
                      <th>Automatic renewal</th>
489
                      <th>No automatic renewal after</th>
490
                       <th>No automatic renewal after (hard limit)</th>
491
                      <th>Holds allowed (count)</th>
492
                      <th>Holds per record (count)</th>
493
                      <th>On shelf holds allowed</th>
494
                      <th>Item level holds</th>
495
                      <th>Article requests</th>
496
                      <th>Rental discount (%)</th>
497
                      <th>&nbsp;</th>
498
                    </tr>
499
                  </tfoot>
500
                </tbody>
501
            </table>
502
        </form>
503
    </div>
504
    <div id="defaults-for-this-library" class="container">
505
    <h3>Default checkout, hold and return policy[% IF humanbranch %] for [% Branches.GetName( humanbranch ) %][% END %]</h3>
506
        <p>You can set a default maximum number of checkouts, hold policy and return policy that will be used if none is defined below for a particular item type or category.</p>
507
        <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
508
            <input type="hidden" name="op" value="set-branch-defaults" />
509
            <input type="hidden" name="branch" value="[% current_branch %]"/>
510
            <table>
511
                <tr>
512
                    <th>&nbsp;</th>
513
                    <th>Total current checkouts allowed</th>
514
                    <th>Total current on-site checkouts allowed</th>
515
                    <th>Maximum total holds allowed (count)</th>
516
                    <th>Hold policy</th>
517
                    <th>Hold pickup library match</th>
518
                    <th>Return policy</th>
519
                    <th>Actions</th>
520
                </tr>
521
                <tr>
522
                    <td><em>Defaults</em></td>
523
                    <td>
524
                        [% SET patron_maxissueqty = CirculationRules.Get( branchcode, undef, undef, 'patron_maxissueqty' ) %]
525
                        <input type="text" name="patron_maxissueqty" size="3" value="[% patron_maxissueqty %]"/>
526
                    </td>
527
                    <td>
528
                        [% SET patron_maxonsiteissueqty = CirculationRules.Get( branchcode, undef, undef, 'patron_maxonsiteissueqty' ) %]
529
                        <input type="text" name="patron_maxonsiteissueqty" size="3" value="[% patron_maxonsiteissueqty %]"/>
530
                    </td>
531
                    <td>
532
                        [% SET rule_value = CirculationRules.Get( current_branch, '*', undef, 'max_holds' ) %]
533
                        <input name="max_holds" size="3" value="[% rule_value %]" />
534
                    </td>
535
                    <td>
536
                        <select name="holdallowed">
537
                            [% SET holdallowed = CirculationRules.Get( branchcode, undef, undef, 'holdallowed' ) %]
538
                            <option value="">
539
                                Not set
540
                            </option>
541
542
                            [% IF holdallowed == 2 %]
543
                                <option value="2" selected="selected">
544
                            [% ELSE %]
545
                                <option value="2">
546
                            [% END %]
547
                                From any library
548
                            </option>
549
550
                            [% IF holdallowed == 1 %]
551
                                <option value="1" selected="selected">
552
                            [% ELSE %]
553
                                <option value="1">
554
                            [% END %]
555
                                From home library
556
                            </option>
557
558
                            [% IF holdallowed == 0 %]
559
                                <option value="0" selected="selected">
560
                            [% ELSE %]
561
                                <option value="0">
562
                            [% END %]
563
                                No holds allowed
564
                            </option>
565
566
                        </select>
567
                    </td>
568
                    <td>
569
                        <select name="hold_fulfillment_policy">
570
                            [% SET hold_fulfillment_policy = CirculationRules.Get( branchcode, undef, undef, 'hold_fulfillment_policy' ) %]
571
572
                            <option value="">
573
                                Not set
574
                            </option>
575
576
                            [% IF hold_fulfillment_policy == 'any' %]
577
                                <option value="any" selected="selected">
578
                                    any library
579
                                </option>
580
                            [% ELSE %]
581
                                <option value="any">
582
                                    any library
583
                                </option>
584
                            [% END %]
585
586
                            [% IF hold_fulfillment_policy == 'homebranch' %]
587
                                <option value="homebranch" selected="selected">
588
                                    item's home library
589
                                </option>
590
                            [% ELSE %]
591
                                <option value="homebranch">
592
                                    item's home library
593
                                </option>
594
                            [% END %]
595
596
                            [% IF hold_fulfillment_policy == 'holdingbranch' %]
597
                                <option value="holdingbranch" selected="selected">
598
                                    item's holding library
599
                                </option>
600
                            [% ELSE %]
601
                                <option value="holdingbranch">
602
                                    item's holding library
603
                                </option>
604
                            [% END %]
605
                        </select>
606
                    </td>
607
                    <td>
608
                        <select name="returnbranch">
609
                            [% SET returnbranch = CirculationRules.Get( branchcode, undef, undef, 'returnbranch' ) %]
610
611
                            <option value="">
612
                                Not set
613
                            </option>
614
615
                            [% IF returnbranch == 'homebranch' %]
616
                            <option value="homebranch" selected="selected">
617
                            [% ELSE %]
618
                            <option value="homebranch">
619
                            [% END %]
620
                                Item returns home
621
                            </option>
622
                            [% IF returnbranch == 'holdingbranch' %]
623
                            <option value="holdingbranch" selected="selected">
624
                            [% ELSE %]
625
                            <option value="holdingbranch">
626
                            [% END %]
627
                                Item returns to issuing library
628
                            </option>
629
                            [% IF returnbranch == 'noreturn' %]
630
                            <option value="noreturn" selected="selected">
631
                            [% ELSE %]
632
                            <option value="noreturn">
633
                            [% END %]
634
                                Item floats
635
                            </option>
636
                        </select>
637
                    </td>
638
                    <td class="actions">
639
                        <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-save"></i> Save</button>
640
                        <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-branch-cat&amp;categorycode=*&amp;branch=[% current_branch %]" id="unset"><i class="fa fa-undo"></i> Unset</a>
641
                    </td>
642
                </tr>
643
            </table>
644
        </form>
645
    </div>
646
    [% IF ( show_branch_cat_rule_form ) %]
647
    <div id="holds-policy-by-patron-category" class="container">
648
    <h3>[% IF humanbranch %]Checkout limit by patron category for [% Branches.GetName( humanbranch ) %][% ELSE %]Default checkout limit by patron category[% END %]</h3>
649
        <p>For this library, you can specify the maximum number of loans that
650
            a patron of a given category can make, regardless of the item type.
651
        </p>
652
        <p>If the total amount loanable for a given patron category is left blank,
653
           no limit applies, except possibly for a limit you define for a specific item type.
654
        </p>
655
        <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
656
            <input type="hidden" name="op" value="add-branch-cat" />
657
            <input type="hidden" name="branch" value="[% current_branch %]"/>
658
            <table>
659
                <tr>
660
                    <th>Patron category</th>
661
                    <th>Total current checkouts allowed</th>
662
                    <th>Total current on-site checkouts allowed</th>
663
                    <th>Maximum total holds allowed (count)</th>
664
                    <th>&nbsp;</th>
665
                </tr>
666
                [% FOREACH c IN categorycodes %]
667
                    [% NEXT UNLESS c %]
668
                    [% SET patron_maxissueqty = CirculationRules.Get( branchcode, c, undef, 'patron_maxissueqty' ) %]
669
                    [% SET patron_maxonsiteissueqty = CirculationRules.Get( branchcode, c, undef, 'patron_maxonsiteissueqty' ) %]
670
                    [% SET max_holds = CirculationRules.Get( branchcode, c, undef, 'max_holds' ) %]
671
672
                    [% IF patron_maxissueqty || patron_maxonsiteissueqty || max_holds %]
673
                    <tr>
674
                        <td>
675
                            [% IF c == undef %]
676
                                <em>Default</em>
677
                            [% ELSE %]
678
                                [% Categories.GetName(c) %]
679
                            [% END %]
680
                        </td>
681
                        <td>
682
                            [% IF patron_maxissueqty  %]
683
                                [% patron_maxissueqty %]
684
                            [% ELSE %]
685
                                Unlimited
686
                            [% END %]
687
                        </td>
688
                        <td>
689
                            [% IF patron_maxonsiteissueqty  %]
690
                                [% patron_maxonsiteissueqty %]
691
                            [% ELSE %]
692
                                Unlimited
693
                            [% END %]
694
                        </td>
695
                        <td>
696
                            [% IF max_holds  %]
697
                                [% max_holds %]
698
                            [% ELSE %]
699
                                Unlimited
700
                            [% END %]
701
                        </td>
702
703
                        <td class="actions">
704
                            <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-branch-cat&amp;categorycode=[% c %]&amp;branch=[% current_branch %]"><i class="fa fa-trash"></i> Delete</a>
705
                        </td>
706
                    </tr>
707
                    [% END %]
708
                [% END %]
709
                <tr>
710
                    <td>
711
                        <select name="categorycode">
712
                        [% FOREACH patron_category IN patron_categories%]
713
                            <option value="[% patron_category.categorycode %]">[% patron_category.description %]</option>
714
                        [% END %]
715
                        </select>
716
                    </td>
717
                    <td><input name="patron_maxissueqty" size="3" /></td>
718
                    <td><input name="patron_maxonsiteissueqty" size="3" /></td>
719
                    <td><input name="max_holds" size="3" /></td>
720
                    <td class="actions"><button type="submit" class="btn btn-default btn-xs"><i class="fa fa-plus"></i> Add</td>
721
                </tr>
722
            </table>
723
        </form>
724
    </div>
725
    [% END %]
726
727
    <div id="refund-lost-item-fee-on-return" class="container">
728
  [% IF current_branch == '*' %]
729
    <h3>Default lost item fee refund on return policy</h3>
730
  [% ELSE %]
731
    <h3>Lost item fee refund on return policy for [% Branches.GetName(current_branch) %]</h3>
732
  [% END %]
733
        <p>Specify the default policy for lost item fees on return.
734
        </p>
735
        <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
736
            <input type="hidden" name="op" value="mod-refund-lost-item-fee-rule" />
737
            <input type="hidden" name="branch" value="[% current_branch %]" />
738
            <table>
739
                <tr>
740
                    <th>Refund lost item fee</th>
741
                    <th>&nbsp;</th>
742
                </tr>
743
                <tr>
744
                    <td>
745
                        <select name="refund">
746
                          [#% Default branch %#]
747
                          [% IF ( current_branch == '*' ) %]
748
                            [% IF ( refundLostItemFeeRule.rule_value ) %]
749
                            <option value="1" selected="selected">
750
                            [% ELSE %]
751
                            <option value="1">
752
                            [% END %]
753
                                Yes
754
                            </option>
755
                            [% IF ( not refundLostItemFeeRule.rule_value ) %]
756
                            <option value="0" selected="selected">
757
                            [% ELSE %]
758
                            <option value="0">
759
                            [% END %]
760
                                No
761
                            </option>
762
                          [% ELSE %]
763
                          [#% Branch-specific %#]
764
                            [% IF ( not refundLostItemFeeRule ) %]
765
                                <option value="*" selected="selected">
766
                            [% ELSE %]
767
                                <option value="*">
768
                            [% END %]
769
                              [% IF defaultRefundRule %]
770
                                Use default (Yes)
771
                              [% ELSE %]
772
                                Use default (No)
773
                              [% END %]
774
                                </option>
775
                            [% IF ( not refundLostItemFeeRule ) %]
776
                                <option value="1">Yes</option>
777
                                <option value="0">No</option>
778
                            [% ELSE %]
779
                                [% IF ( refundLostItemFeeRule.rule_value ) %]
780
                                <option value="1" selected="selected">
781
                                [% ELSE %]
782
                                <option value="1">
783
                                [% END %]
784
                                    Yes
785
                                </option>
786
                                [% IF ( not refundLostItemFeeRule.rule_value ) %]
787
                                <option value="0" selected="selected">
788
                                [% ELSE %]
789
                                <option value="0">
790
                                [% END %]
791
                                    No
792
                                </option>
793
                            [% END %]
794
                          [% END %]
795
                        </select>
796
                    </td>
797
                    <td class="actions">
798
                        <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-save"></i> Save</button>
799
                    </td>
800
                    </td>
801
                </tr>
802
            </table>
803
        </form>
804
    </div>
805
806
    <div id="holds-policy-by-item-type" class="container">
807
    <h3>[% IF humanbranch %]Holds policy by item type for [% Branches.GetName( humanbranch ) %][% ELSE %]Default holds policy by item type[% END %]</h3>
808
        <p>
809
            For this library, you can edit rules for given itemtypes, regardless
810
            of the patron's category.
811
        </p>
812
        <p>
813
            Currently, this means hold policies.
814
            The various policies have the following effects:
815
        </p>
816
        <ul>
817
            <li><strong>From any library:</strong> Patrons from any library may put this item on hold. <cite>(default if none is defined)</cite></li>
818
            <li><strong>From home library:</strong> Only patrons from the item's home library may put this book on hold.</li>
819
            <li><strong>No holds allowed:</strong> No patron may put this book on hold.</li>
820
        </ul>
821
        <p><strong>Note: </strong>If the system preference 'AllowHoldPolicyOverride' is enabled, these policies can be overridden by your circulation staff.</br />
822
            <strong>Important: </strong>The policies are based on the patron's home library, not the library where the hold is being placed.
823
        </p>
824
825
        <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
826
            <input type="hidden" name="op" value="add-branch-item" />
827
            <input type="hidden" name="branch" value="[% current_branch %]"/>
828
            <table>
829
                <tr>
830
                    <th>Item type</th>
831
                    <th>Hold policy</th>
832
                    <th>Hold pickup library match</th>
833
                    <th>Return policy</th>
834
                    <th>&nbsp;</th>
835
                </tr>
836
                [% FOREACH i IN itemtypeloop %]
837
                    [% SET holdallowed = CirculationRules.Get( branchcode, undef, i.itemtype, 'holdallowed' ) %]
838
                    [% SET hold_fulfillment_policy = CirculationRules.Get( branchcode, undef, i.itemtype, 'hold_fulfillment_policy' ) %]
839
                    [% SET returnbranch = CirculationRules.Get( branchcode, undef, i.itemtype, 'returnbranch' ) %]
840
841
                    [% IF holdallowed || hold_fulfillment_policy || returnbranch %]
842
                        <tr>
843
                            <td>
844
                                [% i.translated_description %]
845
                            </td>
846
                            <td>
847
                                [% IF holdallowed == 2 %]
848
                                    From any library
849
                                [% ELSIF holdallowed == 1 %]
850
                                    From home library
851
                                [% ELSE %]
852
                                    No holds allowed
853
                                [% END %]
854
                            </td>
855
                            <td>
856
                                [% IF hold_fulfillment_policy == 'any' %]
857
                                    any library
858
                                [% ELSIF hold_fulfillment_policy == 'homebranch' %]
859
                                    item's home library
860
                                [% ELSIF hold_fulfillment_policy == 'holdingbranch' %]
861
                                    item's holding library
862
                                [% END %]
863
                            </td>
864
                            <td>
865
                                [% IF returnbranch == 'homebranch' %]
866
                                    Item returns home
867
                                [% ELSIF returnbranch == 'holdingbranch' %]
868
                                    Item returns to issuing branch
869
                                [% ELSIF returnbranch == 'noreturn' %]
870
                                    Item floats
871
                                [% END %]
872
                            </td>
873
                            <td class="actions">
874
                                <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-branch-item&amp;itemtype=[% i.itemtype %]&amp;branch=[% current_branch %]"><i class="fa fa-trash"></i> Delete</a>
875
                            </td>
876
                        </tr>
877
                    [% END %]
878
                [% END %]
879
                <tr>
880
                    <td>
881
                        <select name="itemtype">
882
                        [% FOREACH itemtypeloo IN itemtypeloop %]
883
                            <option value="[% itemtypeloo.itemtype %]">[% itemtypeloo.translated_description %]</option>
884
                        [% END %]
885
                        </select>
886
                    </td>
887
                    <td>
888
                        <select name="holdallowed">
889
                            <option value="2">From any library</option>
890
                            <option value="1">From home library</option>
891
                            <option value="0">No holds allowed</option>
892
                        </select>
893
                    </td>
894
                    <td>
895
                        <select name="hold_fulfillment_policy">
896
                            <option value="any">
897
                                any library
898
                            </option>
899
900
                            <option value="homebranch">
901
                                item's home library
902
                            </option>
903
904
                            <option value="holdingbranch">
905
                                item's holding library
906
                            </option>
907
                        </select>
908
                    </td>
909
                    <td>
910
                        <select name="returnbranch">
911
                            <option value="homebranch">Item returns home</option>
912
                            <option value="holdingbranch">Item returns to issuing library</option>
913
                            <option value="noreturn">Item floats</option>
914
                        </select>
915
                    </td>
916
                    <td class="actions"><button type="submit" class="btn btn-default btn-xs"><i class="fa fa-plus"></i> Add</button></td>
917
                </tr>
918
            </table>
919
        </form>
920
    </div>
921
</div>
922
923
</div>
924
<div class="yui-b">
925
[% INCLUDE 'admin-menu.inc' %]
926
</div>
927
</div>
928
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/src/admin/policy/app.js (-2 / +1 lines)
Lines 212-218 export default class PolicyApp extends React.Component { Link Here
212
        }
212
        }
213
213
214
        return <section>
214
        return <section>
215
            <h1>{__( "Circulation, fine and hold policy" )}</h1>
215
            <h1>{__( "Circulation, fines and holds rules" )}</h1>
216
            <PolicyAppToolbar
216
            <PolicyAppToolbar
217
                branch={this.state.branch}
217
                branch={this.state.branch}
218
                group={this.state.kindGroup}
218
                group={this.state.kindGroup}
219
- 

Return to bug 15522