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

(-)a/Koha/Template/Plugin/Categories.pm (+4 lines)
Lines 25-31 use Koha::Patron::Categories; Link Here
25
25
26
sub all {
26
sub all {
27
    my ( $self, $params ) = @_;
27
    my ( $self, $params ) = @_;
28
    my $unfiltered = delete $params->{unfiltered} || 0;
28
    return Koha::Patron::Categories->search_limited($params);
29
    return Koha::Patron::Categories->search_limited($params);
30
    return $unfiltered
31
      ? Koha::Patron::Categories->search( $params )
32
      : Koha::Patron::Categories->search_limited( $params )
29
}
33
}
30
34
31
sub GetName {
35
sub GetName {
(-)a/Koha/Template/Plugin/To.pm (-1 / +1 lines)
Lines 28-34 our $DYNAMIC = 1; Link Here
28
sub json {
28
sub json {
29
    my ( $self, $value ) = @_;
29
    my ( $self, $value ) = @_;
30
30
31
    my $json = JSON->new->allow_nonref(1);
31
    my $json = JSON->new->allow_nonref(1)->convert_blessed(1);
32
    $json = $json->encode($value);
32
    $json = $json->encode($value);
33
    $json =~ s/^"|"$//g; # Remove quotes around the strings
33
    $json =~ s/^"|"$//g; # Remove quotes around the strings
34
    $json =~ s/\\r/\\\\r/g; # Convert newlines to escaped newline characters
34
    $json =~ s/\\r/\\\\r/g; # Convert newlines to escaped newline characters
(-)a/admin/policy.pl (+47 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Copyright (C) 2017 Jesse Weaver
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
use Modern::Perl;
22
23
use C4::Auth;
24
use C4::Context;
25
use C4::Output;
26
27
use Koha::Patrons;
28
29
use CGI qw( -utf8 );
30
31
my $query = new CGI;
32
33
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
34
    {   template_name   => "admin/policy.tt",
35
        authnotrequired => 0,
36
        flagsrequired   => { parameters => 'manage_circ_rules' },
37
        query           => $query,
38
        type            => "intranet",
39
        debug           => 1,
40
    }
41
);
42
43
my $uid = Koha::Patrons->find( $borrowernumber )->userid;
44
my $restricted_to_own_library = !( $uid && haspermission( $uid, { parameters => 'manage_circ_rules_from_any_libraries' } ) );
45
$template->param( restricted_to_library => $restricted_to_own_library ? C4::Context::mybranch() : "" );
46
47
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc (-1 / +1 lines)
Lines 36-42 Link Here
36
                <li><a href="/cgi-bin/koha/admin/categories.pl">Patron categories</a></li>
36
                <li><a href="/cgi-bin/koha/admin/categories.pl">Patron categories</a></li>
37
            [% END %]
37
            [% END %]
38
            [% IF ( CAN_user_parameters_manage_circ_rules ) %]
38
            [% IF ( CAN_user_parameters_manage_circ_rules ) %]
39
                <li><a href="/cgi-bin/koha/admin/smart-rules.pl">Circulation and fines rules</a></li>
39
                <li><a href="/cgi-bin/koha/admin/policy.pl">Circulation, fines, and holds rules</a></li>
40
            [% END %]
40
            [% END %]
41
            [% IF ( CAN_user_parameters_manage_patron_attributes ) %]
41
            [% IF ( CAN_user_parameters_manage_patron_attributes ) %]
42
                <li><a href="/cgi-bin/koha/admin/patron-attr-types.pl">Patron attribute types</a></li>
42
                <li><a href="/cgi-bin/koha/admin/patron-attr-types.pl">Patron attribute types</a></li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt (-2 / +2 lines)
Lines 83-90 Link Here
83
                    <dd>Define patron categories.</dd>
83
                    <dd>Define patron categories.</dd>
84
                [% END %]
84
                [% END %]
85
                [% IF CAN_user_parameters_manage_circ_rules %]
85
                [% IF CAN_user_parameters_manage_circ_rules %]
86
                    <dt><a href="/cgi-bin/koha/admin/smart-rules.pl">Circulation and fines rules</a></dt>
86
                    <dt><a href="/cgi-bin/koha/admin/policy.pl">Circulation, fines, and holds rules</a></dt>
87
                    <dd>Define circulation and fines rules for combinations of libraries, patron categories, and item types</dd>
87
                    <dd>Define circulation, fines, and holds rules for combinations of libraries, patron categories, and item types</dd>
88
                [% END %]
88
                [% END %]
89
                [% IF ( CAN_user_parameters_manage_patron_attributes ) %]
89
                [% IF ( CAN_user_parameters_manage_patron_attributes ) %]
90
                    <dt><a href="/cgi-bin/koha/admin/patron-attr-types.pl">Patron attribute types</a></dt>
90
                    <dt><a href="/cgi-bin/koha/admin/patron-attr-types.pl">Patron attribute types</a></dt>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/policy.tt (-1 / +70 lines)
Line 0 Link Here
0
- 
1
[% USE raw %]
2
[% USE Asset %]
3
[% USE Branches %]
4
[% USE Categories %]
5
[% USE ItemTypes %]
6
[% USE Koha %]
7
[% USE To %]
8
[% SET footerjs = 1 %]
9
10
[% INCLUDE 'doc-head-open.inc' %]
11
<title>Koha &rsaquo; Administration &rsaquo; Policy</title>
12
[% INCLUDE 'doc-head-close.inc' %]
13
<link rel="stylesheet" href="[% interface %]/[% theme %]/css/admin/policy.css" />
14
</head>
15
<body id="admin_policy" class="admin">
16
[% INCLUDE 'header.inc' %]
17
[% INCLUDE 'prefs-admin-search.inc' %]
18
19
<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>
20
21
<div class="main container-fluid">
22
    <div class="row">
23
        <div class="col-sm-10 col-sm-push-2">
24
            <main>
25
                <div id="vue-base">
26
                    <h1>Loading, please wait...</h1>
27
                </div>
28
            </main>
29
        </div>
30
        <div class="col-sm-2 col-sm-pull-10">
31
            <aside>
32
                [% INCLUDE 'admin-menu.inc' %]
33
            </aside>
34
        </div> <!-- /.col-sm-2.col-sm-pull-10 -->
35
     </div> <!-- /.row -->
36
37
[% MACRO jsinclude BLOCK %]
38
    [% Asset.js("js/admin-menu.js") | $raw %]
39
    [% Asset.js("lib/hc-sticky.js") | $raw %]
40
    [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %]
41
    [% INCLUDE 'calendar.inc' %]
42
43
    <script>
44
    var restricted_to_library = "[% restricted_to_library %]";
45
46
    Koha.Preferences = {
47
        "dateformat": "[% Koha.Preference( 'dateformat' ) %]",
48
    };
49
50
    Koha.BRANCHES = {
51
        [% FOREACH branch IN Branches.all( unfiltered => 1 ) %]
52
            "[% branch.branchcode %]": [% To.json( branch ) %],
53
        [% END %]
54
    };
55
    // TODO: Account for branch category limits
56
    Koha.PATRON_CATEGORIES = {
57
        [% FOREACH category IN Categories.all( unfiltered => 1 ) %]
58
            "[% category.categorycode %]": [% To.json( category ) %],
59
        [% END %]
60
    };
61
    Koha.ITEM_TYPES = {
62
        [% FOREACH itemtype IN ItemTypes.Get() %]
63
            "[% itemtype.itemtype %]": [% To.json( itemtype ) %],
64
        [% END %]
65
    };
66
    </script>
67
    [% Asset.js("js/built/admin/policy/main.js") | $raw %]
68
[% END %]
69
<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/humanmsg.css" />
70
[% INCLUDE 'intranet-bottom.inc' %]

Return to bug 15522