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

(-)a/Koha/IllbatchStatus.pm (+162 lines)
Line 0 Link Here
1
package Koha::IllbatchStatus;
2
3
# Copyright PTFS Europe 2022
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 Koha::Database;
22
use Koha::Illrequest::Logger;
23
use Koha::Illbatch;
24
use JSON qw( to_json );
25
use base qw(Koha::Object);
26
27
=head1 NAME
28
29
Koha::IllbatchStatus - Koha IllbatchStatus Object class
30
31
=head2 Class methods
32
33
=head3 create_and_log
34
35
    $status->create_and_log;
36
37
Log batch status creation following storage
38
39
=cut
40
41
sub create_and_log {
42
    my ( $self ) = @_;
43
44
    # Ensure code is uppercase and contains only word characters
45
    my $fixed_code = uc $self->code;
46
    $fixed_code =~ s/\W/_/;
47
48
    # Ensure this status doesn't already exist
49
    my $status = Koha::IllbatchStatuses->find({ code => $fixed_code });
50
    if ($status) {
51
        return {
52
            error => "Duplicate status found"
53
        };
54
    }
55
56
    # Ensure system statuses can't be created
57
    $self->set({
58
        code      => $fixed_code,
59
        is_system => 0
60
    })->store;
61
62
    my $logger = Koha::Illrequest::Logger->new;
63
64
    $logger->log_something({
65
        modulename   => 'ILL',
66
        actionname   => 'batch_status_create',
67
        objectnumber => $self->id,
68
        infos        => to_json({})
69
    });
70
}
71
72
=head3 update_and_log
73
74
    $status->update_and_log;
75
76
Log batch status update following storage
77
78
=cut
79
80
sub update_and_log {
81
    my ( $self, $params ) = @_;
82
83
    my $before = {
84
        name => $self->name
85
    };
86
87
    # Ensure only the name can be changed
88
    $self->set({
89
        name => $params->{name}
90
    });
91
    my $update = $self->store;
92
93
    my $after = {
94
        name => $self->name
95
    };
96
97
    my $logger = Koha::Illrequest::Logger->new;
98
99
    $logger->log_something({
100
        modulename   => 'ILL',
101
        actionname  => 'batch_status_update',
102
        objectnumber => $self->id,
103
        infos        => to_json({
104
            before => $before,
105
            after  => $after
106
        })
107
    });
108
}
109
110
=head3 delete_and_log
111
112
    $batch->delete_and_log;
113
114
Log batch status delete
115
116
=cut
117
118
sub delete_and_log {
119
    my ( $self ) = @_;
120
121
    # Don't permit deletion of system statuses
122
    if ($self->is_system) {
123
        return;
124
    }
125
126
    # Update all batches that use this status to have status UNKNOWN
127
    my $affected = Koha::Illbatches->search({ statuscode => $self->code });
128
    $affected->update({ statuscode => 'UNKNOWN'});
129
130
    my $logger = Koha::Illrequest::Logger->new;
131
132
    $logger->log_something({
133
        modulename   => 'ILL',
134
        actionname   => 'batch_status_delete',
135
        objectnumber => $self->id,
136
        infos        => to_json({})
137
    });
138
139
    $self->delete;
140
}
141
142
=head2 Internal methods
143
144
=head3 _type
145
146
    my $type = Koha::IllbatchStatus->_type;
147
148
Return this object's type
149
150
=cut
151
152
sub _type {
153
    return 'IllbatchStatus';
154
}
155
156
=head1 AUTHOR
157
158
Andrew Isherwood <andrew.isherwood@ptfs-europe.com>
159
160
=cut
161
162
1;
(-)a/Koha/IllbatchStatuses.pm (+61 lines)
Line 0 Link Here
1
package Koha::IllbatchStatuses;
2
3
# Copyright PTFS Europe 2022
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 Koha::Database;
22
use Koha::IllbatchStatus;
23
use base qw(Koha::Objects);
24
25
=head1 NAME
26
27
Koha::IllbatchStatuses - Koha IllbatchStatuses Object class
28
29
=head2 Internal methods
30
31
=head3 _type
32
33
    my $type = Koha::IllbatchStatuses->_type;
34
35
Return this object's type
36
37
=cut
38
39
sub _type {
40
    return 'IllbatchStatus';
41
}
42
43
=head3 object_class
44
45
    my $class = Koha::IllbatchStatuses->object_class;
46
47
Return this object's class name
48
49
=cut
50
51
sub object_class {
52
    return 'Koha::IllbatchStatus';
53
}
54
55
=head1 AUTHOR
56
57
Andrew Isherwood <andrew.isherwood@ptfs-europe.com>
58
59
=cut
60
61
1;
(-)a/Koha/REST/V1/IllbatchStatuses.pm (+167 lines)
Line 0 Link Here
1
package Koha::REST::V1::IllbatchStatuses;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use Mojo::Base 'Mojolicious::Controller';
21
22
use Koha::IllbatchStatuses;
23
24
=head1 NAME
25
26
Koha::REST::V1::IllbatchStatuses
27
28
=head2 Operations
29
30
=head3 list
31
32
Return a list of available ILL batch statuses
33
34
=cut
35
36
sub list {
37
    my $c = shift->openapi->valid_input;
38
39
    my @statuses = Koha::IllbatchStatuses->search()->as_list;
40
41
    return $c->render( status => 200, openapi => \@statuses );
42
}
43
44
=head3 get
45
46
Get one batch statuses
47
48
=cut
49
50
sub get {
51
    my $c = shift->openapi->valid_input;
52
53
    my $status_code = $c->validation->param('illbatchstatus_code');
54
55
    my $status = Koha::IllbatchStatuses->find({ code => $status_code });
56
57
    if (not defined $status) {
58
        return $c->render(
59
            status => 404,
60
            openapi => { error => "ILL batch status not found" }
61
        );
62
    }
63
64
    return $c->render(
65
        status => 200,
66
        openapi => {
67
            %{$status->unblessed}
68
        }
69
    );
70
}
71
72
=head3 add
73
74
Add a new batch status
75
76
=cut
77
78
sub add {
79
    my $c = shift->openapi->valid_input or return;
80
81
    my $body = $c->validation->param('body');
82
83
    my $status = Koha::IllbatchStatus->new( $body );
84
85
    return try {
86
        my $return = $status->create_and_log;
87
        if ($return && $return->{error}) {
88
            return $c->render(
89
                status  => 500,
90
                openapi => $return
91
            );
92
        } else {
93
            return $c->render(
94
                status  => 201,
95
                openapi => $status
96
            );
97
        }
98
    }
99
    catch {
100
        $c->unhandled_exception($_);
101
    };
102
}
103
104
=head3 update
105
106
Update a batch status
107
108
=cut
109
110
sub update {
111
    my $c = shift->openapi->valid_input or return;
112
113
    my $status = Koha::IllbatchStatuses->find({ code => $c->validation->param('illbatchstatus_code') });
114
115
    if ( not defined $status ) {
116
        return $c->render(
117
            status  => 404,
118
            openapi => { error => "ILL batch status not found" }
119
        );
120
    }
121
122
    my $params = $c->req->json;
123
124
    return try {
125
        # Only permit updating of name
126
        $status->update_and_log({ name => $params->{name} });
127
128
        return $c->render(
129
            status  => 200,
130
            openapi => $status
131
        );
132
    }
133
    catch {
134
        $c->unhandled_exception($_);
135
    };
136
}
137
138
=head3 delete
139
140
Delete a batch status
141
142
=cut
143
144
sub delete {
145
146
    my $c = shift->openapi->valid_input or return;
147
148
    my $status = Koha::IllbatchStatuses->find({ code => $c->validation->param( 'illbatchstatus_code' ) });
149
150
    if ( not defined $status ) {
151
        return $c->render( status => 404, openapi => { errors => [ { message => "ILL batch status not found" } ] } );
152
    }
153
154
    if ( $status->is_system) {
155
        return $c->render( status => 400, openapi => { errors => [ { message => "ILL batch status cannot be deleted" } ] } );
156
    }
157
158
    return try {
159
        $status->delete_and_log;
160
        return $c->render( status => 204, openapi => '');
161
    }
162
    catch {
163
        $c->unhandled_exception($_);
164
    };
165
}
166
167
1;
(-)a/admin/ill_batch_statuses.pl (+102 lines)
Line 0 Link Here
1
#! /usr/bin/perl
2
3
# Copyright 2019 Koha Development Team
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 Try::Tiny qw( catch try );
23
24
use C4::Context;
25
use C4::Auth qw( get_template_and_user );
26
use C4::Output qw( output_html_with_http_headers );
27
28
use Koha::IllbatchStatus;
29
use Koha::IllbatchStatuses;
30
31
my $input = CGI->new;
32
my $code  = $input->param('code');
33
my $op    = $input->param('op') || 'list';
34
my @messages;
35
36
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
37
    {
38
        template_name   => "admin/ill_batch_statuses.tt",
39
        query           => $input,
40
        type            => "intranet",
41
        flagsrequired   => { parameters => 'ill' },
42
    }
43
);
44
45
my $status;
46
if ($code) {
47
    $status = Koha::IllbatchStatuses->find({ code => $code });
48
}
49
50
if ( $op eq 'add_form' ) {
51
    if ($status) {
52
        $template->param(
53
            status => $status
54
        );
55
    }
56
}
57
elsif ( $op eq 'add_validate' ) {
58
    my $name = $input->param('name');
59
    my $code = $input->param('code');
60
61
    if ( not defined $status ) {
62
        $status = Koha::IllbatchStatus->new( {
63
            name => $name,
64
            code => $code
65
        } );
66
    }
67
68
    try {
69
        if ($status->id) {
70
            $status->update_and_log({ name => $name });
71
        } else {
72
            $status->create_and_log;
73
        }
74
        push @messages, { type => 'message', code => 'success_on_saving' };
75
    }
76
    catch {
77
        push @messages, { type => 'error', code => 'error_on_saving' };
78
    };
79
    $op = 'list';
80
}
81
elsif ( $op eq 'delete' ) {
82
    try {
83
        $status->delete_and_log;
84
        push @messages, { code => 'success_on_delete', type => 'message' };
85
    }
86
    catch {
87
        push @messages, { code => 'error_on_delete', type => 'alert' };
88
89
    };
90
    $op = 'list';
91
}
92
if ( $op eq 'list' ) {
93
    my $statuses = Koha::IllbatchStatuses->search();
94
    $template->param( statuses => $statuses );
95
}
96
97
$template->param(
98
    messages => \@messages,
99
    op       => $op,
100
);
101
102
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/api/v1/swagger/definitions/illbatchstatus.yaml (+20 lines)
Line 0 Link Here
1
---
2
type: object
3
properties:
4
  id:
5
    type: string
6
    description: Internal ILL batch status identifier
7
  name:
8
    type: string
9
    description: Status name
10
  code:
11
    type: string
12
    description: Unique, immutable status code
13
  is_system:
14
    type: string
15
    description: Is this status required for system operation
16
additionalProperties: false
17
required:
18
  - name
19
  - code
20
  - is_system
(-)a/api/v1/swagger/definitions/illbatchstatuses.yaml (+5 lines)
Line 0 Link Here
1
---
2
type: array
3
items:
4
  $ref: "illbatchstatus.yaml"
5
additionalProperties: false
(-)a/api/v1/swagger/paths/illbatchstatuses.yaml (+232 lines)
Line 0 Link Here
1
---
2
/illbatchstatuses:
3
  get:
4
    x-mojo-to: IllbatchStatuses#list
5
    operationId: listIllbatchstatuses
6
    tags:
7
      - illbatchstatuses
8
    summary: List ILL batch statuses
9
    parameters: []
10
    produces:
11
      - application/json
12
    responses:
13
      "200":
14
        description: A list of ILL batch statuses
15
        schema:
16
          $ref: "../swagger.yaml#/definitions/illbatchstatuses"
17
      "401":
18
        description: Authentication required
19
        schema:
20
          $ref: "../swagger.yaml#/definitions/error"
21
      "403":
22
        description: Access forbidden
23
        schema:
24
          $ref: "../swagger.yaml#/definitions/error"
25
      "404":
26
        description: ILL batch statuses not found
27
        schema:
28
          $ref: "../swagger.yaml#/definitions/error"
29
      "500":
30
        description: |
31
          Internal server error. Possible `error_code` attribute values:
32
33
          * `internal_server_error`
34
        schema:
35
          $ref: "../swagger.yaml#/definitions/error"
36
      "503":
37
        description: Under maintenance
38
        schema:
39
          $ref: "../swagger.yaml#/definitions/error"
40
    x-koha-authorization:
41
      permissions:
42
        ill: "1"
43
  post:
44
    x-mojo-to: IllbatchStatuses#add
45
    operationId: addIllbatchstatus
46
    tags:
47
      - illbatchstatuses
48
    summary: Add ILL batch status
49
    parameters:
50
      - name: body
51
        in: body
52
        description: A JSON object containing informations about the new batch status
53
        required: true
54
        schema:
55
          $ref: "../swagger.yaml#/definitions/illbatchstatus"
56
    produces:
57
      - application/json
58
    responses:
59
      "201":
60
        description: Batch status added
61
        schema:
62
          $ref: "../swagger.yaml#/definitions/illbatchstatus"
63
      "400":
64
        description: Bad request
65
        schema:
66
          $ref: "../swagger.yaml#/definitions/error"
67
      "401":
68
        description: Authentication required
69
        schema:
70
          $ref: "../swagger.yaml#/definitions/error"
71
      "403":
72
        description: Access forbidden
73
        schema:
74
          $ref: "../swagger.yaml#/definitions/error"
75
      "409":
76
        description: Conflict in creating resource
77
        schema:
78
          $ref: "../swagger.yaml#/definitions/error"
79
      "500":
80
        description: |
81
          Internal server error. Possible `error_code` attribute values:
82
83
          * `internal_server_error`
84
        schema:
85
          $ref: "../swagger.yaml#/definitions/error"
86
      "503":
87
        description: Under maintenance
88
        schema:
89
          $ref: "../swagger.yaml#/definitions/error"
90
    x-koha-authorization:
91
      permissions:
92
        ill: "1"
93
"/illbatchstatuses/{illbatchstatus_code}":
94
  get:
95
    x-mojo-to: IllbatchStatuses#get
96
    operationId: getIllbatchstatuses
97
    tags:
98
      - illbatchstatuses
99
    summary: Get ILL batch status
100
    parameters:
101
      - name: illbatchstatus_code
102
        in: path
103
        description: ILL batch status
104
        required: true
105
        type: string
106
    produces:
107
      - application/json
108
    responses:
109
      "200":
110
        description: An ILL batch status
111
        schema:
112
          $ref: "../swagger.yaml#/definitions/illbatchstatus"
113
      "401":
114
        description: Authentication required
115
        schema:
116
          $ref: "../swagger.yaml#/definitions/error"
117
      "403":
118
        description: Access forbidden
119
        schema:
120
          $ref: "../swagger.yaml#/definitions/error"
121
      "404":
122
        description: ILL batch status not found
123
        schema:
124
          $ref: "../swagger.yaml#/definitions/error"
125
      "500":
126
        description: |
127
          Internal server error. Possible `error_code` attribute values:
128
129
          * `internal_server_error`
130
        schema:
131
          $ref: "../swagger.yaml#/definitions/error"
132
      "503":
133
        description: Under maintenance
134
        schema:
135
          $ref: "../swagger.yaml#/definitions/error"
136
    x-koha-authorization:
137
      permissions:
138
        ill: "1"
139
  put:
140
    x-mojo-to: IllbatchStatuses#update
141
    operationId: updateIllBatchstatus
142
    tags:
143
      - illbatchstatuses
144
    summary: Update batch status
145
    parameters:
146
      - $ref: "../swagger.yaml#/parameters/illbatchstatus_code_pp"
147
      - name: body
148
        in: body
149
        description: A JSON object containing information on the batch status
150
        required: true
151
        schema:
152
          $ref: "../swagger.yaml#/definitions/illbatchstatus"
153
    consumes:
154
      - application/json
155
    produces:
156
      - application/json
157
    responses:
158
      "200":
159
        description: An ILL batch status
160
        schema:
161
          $ref: "../swagger.yaml#/definitions/illbatchstatus"
162
      "400":
163
        description: Bad request
164
        schema:
165
          $ref: "../swagger.yaml#/definitions/error"
166
      "401":
167
        description: Authentication required
168
        schema:
169
          $ref: "../swagger.yaml#/definitions/error"
170
      "403":
171
        description: Access forbidden
172
        schema:
173
          $ref: "../swagger.yaml#/definitions/error"
174
      "404":
175
        description: ILL batch status not found
176
        schema:
177
          $ref: "../swagger.yaml#/definitions/error"
178
      "500":
179
        description: |
180
          Internal server error. Possible `error_code` attribute values:
181
182
          * `internal_server_error`
183
        schema:
184
          $ref: "../swagger.yaml#/definitions/error"
185
      "503":
186
        description: Under maintenance
187
        schema:
188
          $ref: "../swagger.yaml#/definitions/error"
189
    x-koha-authorization:
190
      permissions:
191
        ill: "1"
192
  delete:
193
    x-mojo-to: IllbatchStatuses#delete
194
    operationId: deleteBatchstatus
195
    tags:
196
      - illbatchstatuses
197
    summary: Delete ILL batch status
198
    parameters:
199
      - $ref: "../swagger.yaml#/parameters/illbatchstatus_code_pp"
200
    produces:
201
      - application/json
202
    responses:
203
      "204":
204
        description: ILL batch status deleted
205
        schema:
206
          type: string
207
      "401":
208
        description: Authentication required
209
        schema:
210
          $ref: "../swagger.yaml#/definitions/error"
211
      "403":
212
        description: Access forbidden
213
        schema:
214
          $ref: "../swagger.yaml#/definitions/error"
215
      "404":
216
        description: ILL batch status not found
217
        schema:
218
          $ref: "../swagger.yaml#/definitions/error"
219
      "500":
220
        description: |
221
          Internal server error. Possible `error_code` attribute values:
222
223
          * `internal_server_error`
224
        schema:
225
          $ref: "../swagger.yaml#/definitions/error"
226
      "503":
227
        description: Under maintenance
228
        schema:
229
          $ref: "../swagger.yaml#/definitions/error"
230
    x-koha-authorization:
231
      permissions:
232
        ill: "1"
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc (+3 lines)
Lines 177-182 Link Here
177
            [% IF ( Koha.Preference('EnableAdvancedCatalogingEditor') && CAN_user_parameters_manage_keyboard_shortcuts ) %]
177
            [% IF ( Koha.Preference('EnableAdvancedCatalogingEditor') && CAN_user_parameters_manage_keyboard_shortcuts ) %]
178
                <li><a href="/cgi-bin/koha/admin/adveditorshortcuts.pl">Keyboard shortcuts</a></li>
178
                <li><a href="/cgi-bin/koha/admin/adveditorshortcuts.pl">Keyboard shortcuts</a></li>
179
            [% END %]
179
            [% END %]
180
            [% IF Koha.Preference('ILLModule ') && CAN_user_ill %]
181
                <li><a href="/cgi-bin/koha/admin/ill_batch_statuses.pl">Interlibrary Loan batch statuses</a></li>
182
            [% END %]
180
        </ul>
183
        </ul>
181
    [% END %]
184
    [% END %]
182
</div>
185
</div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt (+4 lines)
Lines 282-287 Link Here
282
                        <dt><a href="/cgi-bin/koha/admin/adveditorshortcuts.pl">Keyboard shortcuts</a></dt>
282
                        <dt><a href="/cgi-bin/koha/admin/adveditorshortcuts.pl">Keyboard shortcuts</a></dt>
283
                        <dd>Define which keys trigger actions in the advanced cataloging editor</dd>
283
                        <dd>Define which keys trigger actions in the advanced cataloging editor</dd>
284
                    [% END %]
284
                    [% END %]
285
                    [% IF Koha.Preference('ILLModule') && CAN_user_ill %]
286
                        <dt><a href="/cgi-bin/koha/admin/ill_batch_statuses.pl">Interlibrary Loan batch statuses</a></dt>
287
                        <dd>Manage the statuses that can be assigned to Interlibrary Loan batches</dd>
288
                    [% END %]
285
                </dl>
289
                </dl>
286
            [% END %]
290
            [% END %]
287
            </div>
291
            </div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/ill_batch_statuses.tt (-1 / +168 lines)
Line 0 Link Here
0
- 
1
[% USE raw %]
2
[% USE Asset %]
3
[% USE Branches %]
4
[% USE Price %]
5
[% SET footerjs = 1 %]
6
[% INCLUDE 'doc-head-open.inc' %]
7
<title>
8
    [% IF op =='add_form' %]
9
       [% IF status.id %]
10
           Modify batch status
11
       [% ELSE %]
12
           New batch status
13
       [% END %] &rsaquo; [% END %]
14
    Interlibrary Loan batch statuses &rsaquo; Administration &rsaquo; Koha
15
</title>
16
[% INCLUDE 'doc-head-close.inc' %]
17
</head>
18
19
<body id="admin_ill_batch_statuses" class="admin">
20
[% INCLUDE 'header.inc' %]
21
[% INCLUDE 'prefs-admin-search.inc' %]
22
23
<nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
24
    <ol>
25
        <li>
26
            <a href="/cgi-bin/koha/mainpage.pl">Home</a>
27
        </li>
28
        <li>
29
            <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
30
        </li>
31
32
        [% IF op == 'add_form' %]
33
            <li>
34
                <a href="/cgi-bin/koha/admin/ill_batch_statuses.pl">Interlibrary Loan batch statuses</a>
35
            </li>
36
            <li>
37
                <a href="#" aria-current="page">
38
                    [% IF status.id %]
39
                        Modify
40
                    [% ELSE %]
41
                        New
42
                    [% END %] batch status
43
                </a>
44
            </li>
45
46
        [% ELSE %]
47
            <li>
48
                <a href="#" aria-current="page">
49
                    Interlibrary Loan batch statuses
50
                </a>
51
            </li>
52
        [% END %]
53
    </ol>
54
</nav>
55
56
<div class="main container-fluid">
57
    <div class="row">
58
        <div class="col-sm-10 col-sm-push-2">
59
            <main>
60
61
                [% FOREACH m IN messages %]
62
                <div class="dialog [% m.type | html %]">
63
                    [% SWITCH m.code %]
64
                    [% CASE 'success_on_saving' %]
65
                        <span>Batch status saved successfully</span>
66
                    [% CASE 'success_on_delete' %]
67
                        <span>Batch status deleted successfully</span>
68
                    [% CASE 'error_on_saving' %]
69
                        <span>An error occurred when saving this batch status</span>
70
                    [% CASE 'error_on_delete' %]
71
                        <span>An error occurred when deleting this batch status</span>
72
                    [% CASE %]
73
                        <span>[% m.code | html %]</span>
74
                    [% END %]
75
                </div>
76
                [% END %]
77
78
                [% IF op == 'add_form' %]
79
                    [% IF status %]
80
                        <h1>Modify a batch status</h1>
81
                    [% ELSE %]
82
                        <h1>New batch status</h1>
83
                    [% END %]
84
85
                    <form action="/cgi-bin/koha/admin/ill_batch_statuses.pl" name="Aform" method="post" class="validated">
86
                        <input type="hidden" name="op" value="add_validate" />
87
                        <fieldset class="rows">
88
                            <ol>
89
                                <li>
90
                                    <label for="name" class="required">Name: </label>
91
                                    <input type="text" name="name" id="name" size="80" maxlength="100" class="required focus" required="required" value="[% status.name | html %]"><span class="required">Required. Maximum length is 100 letters</span>
92
                                </li>
93
                                <li>
94
                                    <label for="code">Code: </label>
95
                                    [% IF status %]
96
                                        <strong>[% status.code | html %]</strong>
97
                                        <input type="hidden" name="code" value="[% status.code | html %]" />
98
                                    [% ELSE %]
99
                                    <input type="text" name="code" id="code" size="80" maxlength="20" class="required" required="required" value="[% status.code | html %]"><span class="required">Required, specify UPPERCASE LETTERS. Maximum length is 20 letters</span>
100
                                    [% END %]
101
                                </li>
102
                                <li>
103
                                    <label for="is_system">Is a system status: </label>
104
                                    <strong>[% status.is_system ? "Yes" : "No" | html %]</strong>
105
                                    <input type="hidden" name="is_system" value="[% status.is_system | html %]" />
106
                                </li>
107
                            </ol>
108
                        </fieldset>
109
110
                        <fieldset class="action">
111
                            <button id="save_batch_status" class="btn btn-default">Save</button>
112
                            <a class="cancel" href="/cgi-bin/koha/admin/ill_batch_statuses.pl">Cancel</a>
113
                        </fieldset>
114
                    </form>
115
                [% END %]
116
117
                [% IF op == 'list' %]
118
                    <div id="toolbar" class="btn-toolbar">
119
                        <a class="btn btn-default" id="newillbatchstatus" href="/cgi-bin/koha/admin/ill_batch_statuses.pl?op=add_form"><i class="fa fa-plus"></i> New batch status</a>
120
                    </div>
121
122
                    <h1>Interlibrary Loan batch statuses</h1>
123
                    [% IF statuses.count %]
124
                        <table id="table_batch_statuses">
125
                            <thead>
126
                                <th>Name</th>
127
                                <th>Code</th>
128
                                <th>Is system</th>
129
                                <th class="noExport">Actions</th>
130
                            </thead>
131
                            <tbody>
132
                                [% FOREACH status IN statuses %]
133
                                <tr>
134
                                    <td>[% status.name | html %]</td>
135
                                    <td>[% status.code | html %]</td>
136
                                    <td>[% status.is_system ? "Yes" : "No" | html %]</td>
137
                                    <td class="actions">
138
                                        <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/ill_batch_statuses.pl?op=add_form&amp;code=[% status.code | uri %]"><i class="fa fa-pencil"></i> Edit</a>
139
                                        [% IF !status.is_system %]
140
                                        <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/ill_batch_statuses.pl?op=delete&amp;code=[% status.code | uri %]"><i class="fa fa-delete"></i> Delete</a>
141
                                        [% END %]
142
                                    </td>
143
                                </tr>
144
                                [% END %]
145
                            </tbody>
146
                        </table>
147
                    [% ELSE %]
148
                        <div class="dialog message">
149
                            There are no batch statuses defined. <a href="/cgi-bin/koha/admin/ill_batch_statuses.pl?op=add_form">Create new batch status</a>
150
                        </div>
151
                    [% END %]
152
                [% END %]
153
            </main>
154
        </div> <!-- /.col-sm-10.col-sm-push-2 -->
155
156
        <div class="col-sm-2 col-sm-pull-10">
157
            <aside>
158
                [% INCLUDE 'admin-menu.inc' %]
159
            </aside>
160
        </div> <!-- /.col-sm-2.col-sm-pull-10 -->
161
    </div> <!-- /.row -->
162
163
[% MACRO jsinclude BLOCK %]
164
    [% Asset.js("js/admin-menu.js") | $raw %]
165
    [% INCLUDE 'datatables.inc' %]
166
[% END %]
167
168
[% INCLUDE 'intranet-bottom.inc' %]

Return to bug 30719