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

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