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

(-)a/Koha/Account/DebitType.pm (-1 / +1 lines)
Lines 22-28 use Modern::Perl; Link Here
22
use Koha::Database;
22
use Koha::Database;
23
use Koha::Exceptions;
23
use Koha::Exceptions;
24
24
25
use base qw(Koha::Object Koha::Object::Limit::Library);
25
use base qw(Koha::Object::Mixin::AdditionalFields Koha::Object Koha::Object::Limit::Library);
26
26
27
=head1 NAME
27
=head1 NAME
28
28
(-)a/Koha/Account/DebitTypes.pm (-1 / +1 lines)
Lines 22-28 use Modern::Perl; Link Here
22
use Koha::Database;
22
use Koha::Database;
23
use Koha::Account::DebitType;
23
use Koha::Account::DebitType;
24
24
25
use base qw(Koha::Objects Koha::Objects::Limit::Library);
25
use base qw(Koha::Objects::Mixin::AdditionalFields Koha::Objects Koha::Objects::Limit::Library);
26
26
27
=head1 NAME
27
=head1 NAME
28
28
(-)a/admin/debit_types.pl (-2 / +12 lines)
Lines 27-32 use C4::Output qw( output_html_with_http_headers ); Link Here
27
27
28
use Koha::Account::DebitType;
28
use Koha::Account::DebitType;
29
use Koha::Account::DebitTypes;
29
use Koha::Account::DebitTypes;
30
use Koha::AdditionalFields;
30
31
31
my $input = CGI->new;
32
my $input = CGI->new;
32
my $code  = $input->param('code');
33
my $code  = $input->param('code');
Lines 66-74 if ( $op eq 'add_form' ) { Link Here
66
            };
67
            };
67
    }
68
    }
68
69
70
    my @additional_fields       = Koha::AdditionalFields->search( { tablename => 'account_debit_types' } )->as_list;
71
    my @additional_field_values = $debit_type ? $debit_type->get_additional_field_values_for_template : ();
72
69
    $template->param(
73
    $template->param(
70
        debit_type    => $debit_type,
74
        debit_type              => $debit_type,
71
        branches_loop => \@branches_loop
75
        branches_loop           => \@branches_loop,
76
        additional_fields       => \@additional_fields,
77
        additional_field_values => @additional_field_values,
72
    );
78
    );
73
} elsif ( $op eq 'cud-add_validate' ) {
79
} elsif ( $op eq 'cud-add_validate' ) {
74
    my $description         = $input->param('description');
80
    my $description         = $input->param('description');
Lines 90-95 if ( $op eq 'add_form' ) { Link Here
90
    try {
96
    try {
91
        $debit_type->store;
97
        $debit_type->store;
92
        $debit_type->replace_library_limits( \@branches );
98
        $debit_type->replace_library_limits( \@branches );
99
100
        my @additional_fields = $debit_type->prepare_cgi_additional_field_values( $input, 'account_debit_types' );
101
        $debit_type->set_additional_fields( \@additional_fields );
102
93
        push @messages, { type => 'message', code => 'success_on_saving' };
103
        push @messages, { type => 'message', code => 'success_on_saving' };
94
    } catch {
104
    } catch {
95
        push @messages, { type => 'error', code => 'error_on_saving' };
105
        push @messages, { type => 'error', code => 'error_on_saving' };
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/additional-fields.tt (-84 / +104 lines)
Lines 5-26 Link Here
5
[% PROCESS 'i18n.inc' %]
5
[% PROCESS 'i18n.inc' %]
6
[% SET footerjs = 1 %]
6
[% SET footerjs = 1 %]
7
[% INCLUDE 'doc-head-open.inc' %]
7
[% INCLUDE 'doc-head-open.inc' %]
8
<title>[% FILTER collapse %]
8
<title
9
    [% SWITCH op %]
9
    >[% FILTER collapse %]
10
        [% SWITCH op %]
10
        [% CASE 'add_form' %]
11
        [% CASE 'add_form' %]
11
            [% IF field %]
12
            [% IF field %]
12
                [% tx("Modify field '{field_name}'", { field_name = field.name }) | html %] &rsaquo;
13
                [% tx("Modify field '{field_name}'", { field_name = field.name }) | html %]
14
                &rsaquo;
13
            [% ELSE %]
15
            [% ELSE %]
14
                [% t("New field") | html %] &rsaquo;
16
                [% t("New field") | html %]
17
                &rsaquo;
15
            [% END %]
18
            [% END %]
16
            [% tx("Table '{table_name}'", { table_name = tablename } ) | html %] &rsaquo;
19
            [% tx("Table '{table_name}'", { table_name = tablename } ) | html %]
20
            &rsaquo;
17
        [% CASE 'list' %]
21
        [% CASE 'list' %]
18
            [% tx("Table '{table_name}'", { table_name = tablename } ) | html %] &rsaquo;
22
            [% tx("Table '{table_name}'", { table_name = tablename } ) | html %]
19
    [% END %]
23
            &rsaquo;
20
    [% t("Additional fields") | html %] &rsaquo;
24
        [% END %]
21
    [% t("Administration") | html %] &rsaquo;
25
        [% t("Additional fields") | html %]
22
    [% t("Koha") | html %]
26
        &rsaquo; [% t("Administration") | html %] &rsaquo; [% t("Koha") | html %]
23
[% END %]</title>
27
    [% END %]</title
28
>
24
[% INCLUDE 'doc-head-close.inc' %]
29
[% INCLUDE 'doc-head-close.inc' %]
25
</head>
30
</head>
26
31
Lines 30-36 Link Here
30
[% show_searchable = searchable_tables.grep('^' _ tablename _ '$').size ? 1 : 0 %]
35
[% show_searchable = searchable_tables.grep('^' _ tablename _ '$').size ? 1 : 0 %]
31
36
32
<body id="ser_add_fields" class="ser">
37
<body id="ser_add_fields" class="ser">
33
    [% WRAPPER 'header.inc' %]
38
[% WRAPPER 'header.inc' %]
34
    [% INCLUDE 'cat-search.inc' %]
39
    [% INCLUDE 'cat-search.inc' %]
35
[% END %]
40
[% END %]
36
41
Lines 40-78 Link Here
40
            <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
45
            <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
41
        [% END %]
46
        [% END %]
42
        [% SWITCH op %]
47
        [% SWITCH op %]
43
            [% CASE 'add_form' %]
48
        [% CASE 'add_form' %]
49
            [% WRAPPER breadcrumb_item %]
50
                <a href="/cgi-bin/koha/admin/additional-fields.pl">Additional fields</a>
51
            [% END %]
52
            [% IF field %]
44
                [% WRAPPER breadcrumb_item %]
53
                [% WRAPPER breadcrumb_item %]
45
                    <a href="/cgi-bin/koha/admin/additional-fields.pl">Additional fields</a>
54
                    <a href="/cgi-bin/koha/admin/additional-fields.pl?tablename=[% tablename | uri %]">[% tx("Table '{table_name}'", { table_name = tablename } ) | html %]</a>
46
                [% END %]
55
                [% END %]
47
                [% IF field %]
56
                [% WRAPPER breadcrumb_item bc_active= 1 %]
48
                    [% WRAPPER breadcrumb_item %]
57
                    [% tx("Modify field '{field_name}'", { field_name = field.name }) | html %]
49
                        <a href="/cgi-bin/koha/admin/additional-fields.pl?tablename=[% tablename | uri %]">[% tx("Table '{table_name}'", { table_name = tablename } ) | html %]</a>
50
                    [% END %]
51
                    [% WRAPPER breadcrumb_item bc_active= 1 %]
52
                        [% tx("Modify field '{field_name}'", { field_name = field.name }) | html %]
53
                    [% END %]
54
                [% ELSE %]
55
                    [% WRAPPER breadcrumb_item %]
56
                        <a href="/cgi-bin/koha/admin/additional-fields.pl?tablename=[% tablename | uri %]">[% tx("Table '{table_name}'", { table_name = tablename } ) | html %]</a>
57
                    [% END %]
58
                    [% WRAPPER breadcrumb_item bc_active= 1 %]
59
                        [% t("New field" ) | html %]
60
                    [% END %]
61
                [% END %]
58
                [% END %]
62
59
            [% ELSE %]
63
            [% CASE 'list' %]
64
                [% WRAPPER breadcrumb_item %]
60
                [% WRAPPER breadcrumb_item %]
65
                    <a href="/cgi-bin/koha/admin/additional-fields.pl">Additional fields</a>
61
                    <a href="/cgi-bin/koha/admin/additional-fields.pl?tablename=[% tablename | uri %]">[% tx("Table '{table_name}'", { table_name = tablename } ) | html %]</a>
66
                [% END %]
62
                [% END %]
67
                [% WRAPPER breadcrumb_item bc_active= 1 %]
63
                [% WRAPPER breadcrumb_item bc_active= 1 %]
68
                    [% tx("Table '{table_name}'", { table_name = tablename } ) | html %]
64
                    [% t("New field" ) | html %]
69
                [% END %]
65
                [% END %]
70
66
            [% END %]
71
            [% CASE %]
67
        [% CASE 'list' %]
72
                [% WRAPPER breadcrumb_item bc_active= 1 %]
68
            [% WRAPPER breadcrumb_item %]
73
                    <span>Additional fields</span>
69
                <a href="/cgi-bin/koha/admin/additional-fields.pl">Additional fields</a>
74
                [% END %]
70
            [% END %]
75
71
            [% WRAPPER breadcrumb_item bc_active= 1 %]
72
                [% tx("Table '{table_name}'", { table_name = tablename } ) | html %]
73
            [% END %]
74
        [% CASE %]
75
            [% WRAPPER breadcrumb_item bc_active= 1 %]
76
                <span>Additional fields</span>
77
            [% END %]
76
        [% END %]
78
        [% END %]
77
    [% END #/ WRAPPER breadcrumbs %]
79
    [% END #/ WRAPPER breadcrumbs %]
78
[% END #/ WRAPPER sub-header.inc %]
80
[% END #/ WRAPPER sub-header.inc %]
Lines 111-122 Link Here
111
113
112
    [% IF op == 'list_tables' %]
114
    [% IF op == 'list_tables' %]
113
        [% IF CAN_user_acquisition_order_manage || CAN_user_serials_edit_subscription || CAN_user_updatecharges_remaining_permissions || CAN_user_erm %]
115
        [% IF CAN_user_acquisition_order_manage || CAN_user_serials_edit_subscription || CAN_user_updatecharges_remaining_permissions || CAN_user_erm %]
114
        <h1>Additional fields</h1>
116
            <h1>Additional fields</h1>
115
117
116
        <div class="page-section">
118
            <div class="page-section">
117
            [% BLOCK table_option %]
119
                [% BLOCK table_option %]
118
                <li><a href="?tablename=[% value | uri %]">[% content | $raw %] (<span class="ex">[% value | html %]</span>)</a></li>
120
                    <li
119
            [% END %]
121
                        ><a href="?tablename=[% value | uri %]">[% content | $raw %] (<span class="ex">[% value | html %]</span>)</a></li
122
                    >
123
                [% END %]
120
                [% IF CAN_user_acquisition_order_manage || CAN_user_acquisition_edit_invoices %]
124
                [% IF CAN_user_acquisition_order_manage || CAN_user_acquisition_edit_invoices %]
121
                    <h2>Acquisitions</h2>
125
                    <h2>Acquisitions</h2>
122
                    <ul>
126
                    <ul>
Lines 143-153 Link Here
143
                        [% WRAPPER table_option value="erm_packages" %]Packages[% END %]
147
                        [% WRAPPER table_option value="erm_packages" %]Packages[% END %]
144
                    </ul>
148
                    </ul>
145
                [% END %]
149
                [% END %]
146
                [% IF CAN_user_updatecharges_remaining_permissions %]
150
                [% IF CAN_user_updatecharges_remaining_permissions || CAN_user_parameters_manage_accounts %]
147
                    <h3>Patrons</h3>
151
                    <h3>Patrons</h3>
148
                    <ul>
152
                    <ul>
149
                        [% WRAPPER table_option value="accountlines:credit" %]Account lines (credit)[% END %]
153
                        [% IF CAN_user_updatecharges_remaining_permissions %]
150
                        [% WRAPPER table_option value="accountlines:debit" %]Account lines (debit)[% END %]
154
                            [% WRAPPER table_option value="accountlines:credit" %]Account lines (credit)[% END %]
155
                            [% WRAPPER table_option value="accountlines:debit" %]Account lines (debit)[% END %]
156
                        [% END %]
157
                        [% IF ( CAN_user_parameters_manage_accounts ) %]
158
                            [% WRAPPER table_option value="account_debit_types" %]Account debit types[% END %]
159
                        [% END %]
151
                    </ul>
160
                    </ul>
152
                [% END %]
161
                [% END %]
153
                [% IF CAN_user_serials_edit_subscription %]
162
                [% IF CAN_user_serials_edit_subscription %]
Lines 155-165 Link Here
155
                    <ul>
164
                    <ul>
156
                        [% WRAPPER table_option value="subscription" %]<span>Subscriptions</span>[% END %]
165
                        [% WRAPPER table_option value="subscription" %]<span>Subscriptions</span>[% END %]
157
                    </ul>
166
                    </ul>
158
                [% END %]
167
                [% END %] </div
159
        </div><!-- /.page-section -->
168
            ><!-- /.page-section -->
160
            [% ELSE %]
169
        [% ELSE %]
161
                Additional permissions are required for editing additional fields
170
            Additional permissions are required for editing additional fields
162
            [% END %]
171
        [% END %]
163
    [% ELSIF op == 'list' %]
172
    [% ELSIF op == 'list' %]
164
        <h1>Additional fields for '[% tablename | html %]'</h1>
173
        <h1>Additional fields for '[% tablename | html %]'</h1>
165
        [% IF fields %]
174
        [% IF fields %]
Lines 189-216 Link Here
189
                                    <td>[% field.marcfield | html %]</td>
198
                                    <td>[% field.marcfield | html %]</td>
190
                                    <td>
199
                                    <td>
191
                                        [% SWITCH field.marcfield_mode %]
200
                                        [% SWITCH field.marcfield_mode %]
192
                                            [% CASE 'get' %]Get value from MARC record
201
                                        [% CASE 'get' %]
193
                                            [% CASE 'set' %]Save value to MARC record
202
                                            Get value from MARC record
203
                                        [% CASE 'set' %]
204
                                            Save value to MARC record
194
                                        [% END %]
205
                                        [% END %]
195
                                    </td>
206
                                    </td>
196
                                [% END %]
207
                                [% END %]
197
                                [% IF show_searchable %]
208
                                [% IF show_searchable %]
198
                                    <td>
209
                                    <td> [% IF field.searchable %]Yes[% ELSE %]No[% END %] </td>
199
                                        [% IF field.searchable %]Yes[% ELSE %]No[% END %]
200
                                    </td>
201
                                [% END %]
210
                                [% END %]
202
                                    <td>
211
                                <td> [% IF field.repeatable %]Yes[% ELSE %]No[% END %] </td>
203
                                        [% IF field.repeatable %]Yes[% ELSE %]No[% END %]
204
                                    </td>
205
                                <td class="actions">
212
                                <td class="actions">
206
                                    <a class="btn btn-default btn-xs" href="?op=add_form&amp;field_id=[% field.id | html %]"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a>
213
                                    <a class="btn btn-default btn-xs" href="?op=add_form&amp;field_id=[% field.id | html %]"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a>
207
                                    <a class="submit-form-link btn btn-default btn-xs" href="#" data-action="additional-fields.pl" data-method="post" data-op="cud-delete" data-field_id="[% field.id | html %]" data-tablename="[% tablename | html %]" data-confirmation-msg="[% t('Are you sure you want to delete this field?') | html %]"><i class="fa fa-trash-can"></i> Delete</a>
214
                                    <a
215
                                        class="submit-form-link btn btn-default btn-xs"
216
                                        href="#"
217
                                        data-action="additional-fields.pl"
218
                                        data-method="post"
219
                                        data-op="cud-delete"
220
                                        data-field_id="[% field.id | html %]"
221
                                        data-tablename="[% tablename | html %]"
222
                                        data-confirmation-msg="[% t('Are you sure you want to delete this field?') | html %]"
223
                                        ><i class="fa fa-trash-can"></i> Delete</a
224
                                    >
208
                                </td>
225
                                </td>
209
                            </tr>
226
                            </tr>
210
                        [% END %]
227
                        [% END %]
211
                    </tbody>
228
                    </tbody>
212
                </table>
229
                </table> </div
213
            </div><!-- /.page-section -->
230
            ><!-- /.page-section -->
214
        [% ELSE %]
231
        [% ELSE %]
215
            [% IF tablename %]There are no additional fields defined for this table.[% END %]
232
            [% IF tablename %]There are no additional fields defined for this table.[% END %]
216
        [% END %]
233
        [% END %]
Lines 290-328 Link Here
290
            </fieldset>
307
            </fieldset>
291
        </form>
308
        </form>
292
    [% END %]
309
    [% END %]
293
294
[% END %]
310
[% END %]
295
311
296
[% MACRO jsinclude BLOCK %]
312
[% MACRO jsinclude BLOCK %]
297
    [% INCLUDE "datatables.inc" %]
313
    [% INCLUDE "datatables.inc" %]
298
    [% Asset.js("js/form-submit.js") | $raw %]
314
    [% Asset.js("js/form-submit.js") | $raw %]
299
    <script>
315
    <script>
300
        $(document).ready(function(){
316
        $(document).ready(function () {
301
            $('#selecttable').find(":submit").hide();
317
            $("#selecttable").find(":submit").hide();
302
            $('#selecttable select').change(function() {
318
            $("#selecttable select").change(function () {
303
                $('#selecttable').submit();
319
                $("#selecttable").submit();
304
            });
320
            });
305
321
306
            $("#fieldst").dataTable($.extend(true, {}, dataTablesDefaults, {
322
            $("#fieldst").dataTable(
307
                "autoWidth": false,
323
                $.extend(true, {}, dataTablesDefaults, {
308
                "dom": 't<"bottom pager"ilpf>',
324
                    autoWidth: false,
309
                "pagingType": 'full',
325
                    dom: 't<"bottom pager"ilpf>',
310
                "lengthMenu": [[10, 20, 50, 100, -1], [10, 20, 50, 100, "All"]],
326
                    pagingType: "full",
311
                "pageLength": 20,
327
                    lengthMenu: [
312
                "order": [[ 0, "asc" ]],
328
                        [10, 20, 50, 100, -1],
313
            }));
329
                        [10, 20, 50, 100, "All"],
330
                    ],
331
                    pageLength: 20,
332
                    order: [[0, "asc"]],
333
                })
334
            );
314
335
315
            $("#add_field").on('submit', function() {
336
            $("#add_field").on("submit", function () {
316
                if ( $("#marcfield").length && $("select[name='authorised_value_category']").length ) {
337
                if ($("#marcfield").length && $("select[name='authorised_value_category']").length) {
317
                    if ( $("#marcfield").val().length > 0
338
                    if ($("#marcfield").val().length > 0 && $("select[name='authorised_value_category']").val().length > 0) {
318
                        && $("select[name='authorised_value_category']" ).val().length > 0 ) {
339
                        alert(_("You cannot select an authorised value category and a MARC field"));
319
                        alert(_("You cannot select an authorised value category and a MARC field") );
320
                        return false;
340
                        return false;
321
                    }
341
                    }
322
                }
342
                }
323
                if ( $("#marcfield").length && $("#repeatable").length) {
343
                if ($("#marcfield").length && $("#repeatable").length) {
324
                    if ( $("#marcfield").val().length > 0 && $("#repeatable").prop('checked') == true ) {
344
                    if ($("#marcfield").val().length > 0 && $("#repeatable").prop("checked") == true) {
325
                        alert(_("You cannot set a MARC field as repeatable") );
345
                        alert(_("You cannot set a MARC field as repeatable"));
326
                        return false;
346
                        return false;
327
                    }
347
                    }
328
                }
348
                }
Lines 332-335 Link Here
332
    </script>
352
    </script>
333
[% END %]
353
[% END %]
334
354
335
[% INCLUDE 'intranet-bottom.inc' %]
355
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/debit_types.tt (-225 / +222 lines)
Lines 7-26 Link Here
7
[% SET footerjs = 1 %]
7
[% SET footerjs = 1 %]
8
[% PROCESS 'accounts.inc' %]
8
[% PROCESS 'accounts.inc' %]
9
[% INCLUDE 'doc-head-open.inc' %]
9
[% INCLUDE 'doc-head-open.inc' %]
10
<title
10
<title>[% FILTER collapse %]
11
    >[% FILTER collapse %]
11
    [% IF op =='add_form' %]
12
        [% IF op =='add_form' %]
12
       [% IF debit_type.code %]
13
            [% IF debit_type.code %]
13
           [% tx("Modify debit type '{debit_type}'", { debit_type = debit_type.code }) | html %]
14
                [% tx("Modify debit type '{debit_type}'", { debit_type = debit_type.code }) | html %]
14
       [% ELSE %]
15
            [% ELSE %]
15
           [% t("New debit type") | html %]
16
                [% t("New debit type") | html %]
16
       [% END %] &rsaquo;
17
            [% END %]
17
    [% END %]
18
            &rsaquo;
18
    [% t("Debit types") | html %] &rsaquo;
19
        [% END %]
19
    [% t("Administration") | html %] &rsaquo;
20
        [% t("Debit types") | html %]
20
    [% t("Koha") | html %]
21
        &rsaquo; [% t("Administration") | html %] &rsaquo; [% t("Koha") | html %]
21
[% END %]</title>
22
    [% END %]</title
23
>
24
[% INCLUDE 'doc-head-close.inc' %]
22
[% INCLUDE 'doc-head-close.inc' %]
25
</head>
23
</head>
26
24
Lines 46-51 Link Here
46
                    <span>New debit type</span>
44
                    <span>New debit type</span>
47
                [% END %]
45
                [% END %]
48
            [% END %]
46
            [% END %]
47
49
        [% ELSE %]
48
        [% ELSE %]
50
            [% WRAPPER breadcrumb_item bc_active= 1 %]
49
            [% WRAPPER breadcrumb_item bc_active= 1 %]
51
                <span>Debit types</span>
50
                <span>Debit types</span>
Lines 56-296 Link Here
56
55
57
[% WRAPPER 'main-container.inc' aside='admin-menu' %]
56
[% WRAPPER 'main-container.inc' aside='admin-menu' %]
58
57
59
    [% FOREACH m IN messages %]
58
                [% FOREACH m IN messages %]
60
        <div class="alert alert-[% m.type | html %]">
59
                <div class="alert alert-[% m.type | html %]">
61
            [% SWITCH m.code %]
60
                    [% SWITCH m.code %]
62
            [% CASE 'success_on_saving' %]
61
                    [% CASE 'success_on_saving' %]
63
                <span>Debit type saved successfully.</span>
62
                        <span>Debit type saved successfully.</span>
64
            [% CASE 'error_on_saving' %]
63
                    [% CASE 'error_on_saving' %]
65
                <span>An error occurred when saving this debit type. Check the logs for details.</span>
64
                        <span>An error occurred when saving this debit type. Check the logs for details.</span>
66
            [% CASE 'success_on_archive' %]
65
                    [% CASE 'success_on_archive' %]
67
                <span>Debit type archived successfully.</span>
66
                        <span>Debit type archived successfully.</span>
68
            [% CASE 'success_on_restore' %]
67
                    [% CASE 'success_on_restore' %]
69
                <span>Debit type restored successfully.</span>
68
                        <span>Debit type restored successfully.</span>
70
            [% CASE %]
69
                    [% CASE %]
71
                <span>[% m.code | html %]</span>
70
                        <span>[% m.code | html %]</span>
72
            [% END %]
71
                    [% END %]
73
        </div>
72
                </div>
74
    [% END %]
73
                [% END %]
75
76
    [% IF op == 'add_form' %]
77
        [% IF debit_type %]
78
            <h1>[% tx("Modify debit type '{debit_type}'", { debit_type = debit_type.code }) | html %]</h1>
79
        [% ELSE %]
80
            <h1>New debit type</h1>
81
        [% END %]
82
83
        <form action="/cgi-bin/koha/admin/debit_types.pl" name="Aform" method="post" class="validated">
84
            [% INCLUDE 'csrf-token.inc' %]
85
            <input type="hidden" name="op" value="cud-add_validate" />
86
            <fieldset class="rows">
87
                <ol>
88
                    <li>
89
                        <label for="code" class="required">Debit type code: </label>
90
                        [% IF debit_type %]
91
                            <strong>[% debit_type.code | html %]</strong>
92
                            <input type="hidden" name="code" value="[% code | html %]" />
93
                        [% ELSE %]
94
                            <input type="text" name="code" id="code" size="80" maxlength="64" class="required focus" required="required" /><span class="required">Required. Maximum length is 64 letters</span>
95
                        [% END %]
96
                    </li>
97
                    <li>
98
                        <label for="default_amount">Default amount: </label>
99
                        <input type="text" pattern="^\d+(\.\d{2})?$" name="default_amount" id="default_amount" size="80" maxlength="100" value="[% debit_type.default_amount | $Price on_editing => 1 %]" step="any" min="0" />
100
                    </li>
101
                    <li>
102
                        <label for="description" class="required">Description: </label>
103
                        [% IF debit_type && debit_type.is_system %]
104
                            <span>[%- PROCESS debit_type_description debit_type = debit_type -%]</span>
105
                        [% ELSE %]
106
                            <input type="text" name="description" id="description" required="required" class="required" size="80" maxlength="100" value="[% debit_type.description | html %]" /> <span class="required">Required</span>
107
                        [% END %]
108
                    </li>
109
                    <li>
110
                        <label for="can_be_invoiced">Can be manually invoiced? </label>
111
                        [% IF debit_type.can_be_invoiced %]
112
                            <input type="checkbox" name="can_be_invoiced" id="can_be_invoiced" checked="checked" value="1" />
113
                        [% ELSE %]
114
                            <input type="checkbox" name="can_be_invoiced" id="can_be_invoiced" value="1" />
115
                        [% END %]
116
                    </li>
117
                    <li>
118
                        <label for="can_be_sold">Can be sold? </label>
119
                        [% IF debit_type.can_be_sold %]
120
                            <input type="checkbox" name="can_be_sold" id="can_be_sold" checked="checked" value="1" />
121
                        [% ELSE %]
122
                            <input type="checkbox" name="can_be_sold" id="can_be_sold" value="1" />
123
                        [% END %]
124
                    </li>
125
                    <li>
126
                        <label for="restricts_checkouts">Included in noissuescharge? </label>
127
                        [% IF debit_type.restricts_checkouts %]
128
                            <input type="checkbox" name="restricts_checkouts" id="restricts_checkouts" checked="checked" value="1" />
129
                        [% ELSE %]
130
                            <input type="checkbox" name="restricts_checkouts" id="restricts_checkouts" value="1" />
131
                        [% END %]
132
                    </li>
133
                    <li>
134
                        <label for="branches">Libraries limitation: </label>
135
                        <select id="branches" name="branches" multiple size="10">
136
                            <option value="">All libraries</option>
137
                            [% FOREACH branch IN branches_loop %]
138
                                [% IF ( branch.selected ) %]
139
                                    <option selected="selected" value="[% branch.branchcode | html %]">[% branch.branchname | html %]</option>
140
                                [% ELSE %]
141
                                    <option value="[% branch.branchcode | html %]">[% branch.branchname | html %]</option>
142
                                [% END %]
143
                            [% END %]
144
                        </select>
145
                        <div class="hint">Select 'All libraries' if this debit type should be available at all libraries. Otherwise select libraries you want to associate debit type with.</div>
146
                    </li>
147
                </ol>
148
            </fieldset>
149
150
            <fieldset class="action">
151
                <button id="save_debit_type" class="btn btn-primary">Save</button>
152
                <a class="cancel" href="/cgi-bin/koha/admin/debit_types.pl">Cancel</a>
153
            </fieldset>
154
        </form>
155
    [% END %]
156
74
157
    [% IF op == 'list' %]
75
                [% IF op == 'add_form' %]
158
        <div id="toolbar" class="btn-toolbar">
76
                    [% IF debit_type %]
159
            <a class="btn btn-default" id="newdebittype" href="/cgi-bin/koha/admin/debit_types.pl?op=add_form"><i class="fa fa-plus"></i> New debit type</a>
77
                        <h1>[% tx("Modify debit type '{debit_type}'", { debit_type = debit_type.code }) | html %]</h1>
160
        </div>
78
                    [% ELSE %]
79
                        <h1>New debit type</h1>
80
                    [% END %]
161
81
162
        <h1>Debit types</h1>
82
                    <form action="/cgi-bin/koha/admin/debit_types.pl" name="Aform" method="post" class="validated">
163
        [% IF debit_types.count %]
83
                        [% INCLUDE 'csrf-token.inc' %]
164
            <div class="page-section">
84
                        <input type="hidden" name="op" value="cud-add_validate" />
165
                <table id="table_debit_types">
85
                        <fieldset class="rows">
166
                    <thead>
86
                            <ol>
167
                        <th>Archived</th>
87
                                <li>
168
                        <th>System</th>
88
                                    <label for="code" class="required">Debit type code: </label>
169
                        <th>Code</th>
89
                                    [% IF debit_type %]
170
                        <th>Description</th>
90
                                        <strong>[% debit_type.code | html %]</strong>
171
                        <th>Default amount</th>
91
                                        <input type="hidden" name="code" value="[% code | html %]" />
172
                        <th>Available for</th>
92
                                    [% ELSE %]
173
                        <th>Library limitations</th>
93
                                    <input type="text" name="code" id="code" size="80" maxlength="64" class="required focus" required="required"><span class="required">Required. Maximum length is 64 letters</span>
174
                        <th>Blocks checkouts?</th>
175
                        <th class="noExport">Actions</th>
176
                    </thead>
177
                    <tbody>
178
                        [% FOREACH debit_type IN debit_types %]
179
                            <tr>
180
                                <td>[% debit_type.archived | html %]</td>
181
                                <td>[% debit_type.is_system | html %]</td>
182
                                <td>[% debit_type.code | html %]</td>
183
                                <td>[%- PROCESS debit_type_description debit_type = debit_type -%]</td>
184
                                <td>[% debit_type.default_amount | $Price %]</td>
185
                                <td
186
                                    >[% IF debit_type.can_be_invoiced && debit_type.can_be_sold %]
187
                                        <i class="fa fa-id-card"></i> Invoicing, <i class="fa fa-shopping-cart"></i> Sale
188
                                    [% ELSIF debit_type.can_be_invoiced %]
189
                                        <i class="fa fa-id-card"></i> Invoicing
190
                                    [% ELSIF debit_type.can_be_sold %]
191
                                        <i class="fa fa-shopping-cart"></i> Sale
192
                                    [% END %]
94
                                    [% END %]
193
                                </td>
95
                                </li>
194
                                <td>
96
                                <li>
195
                                    [% IF debit_type.library_limits.count > 0 %]
97
                                    <label for="default_amount">Default amount: </label>
196
                                        [% library_limits_str = "" %]
98
                                    <input type="text" pattern="^\d+(\.\d{2})?$" name="default_amount" id="default_amount" size="80" maxlength="100" value="[% debit_type.default_amount | $Price on_editing => 1 %]" step="any" min="0"/>
197
                                        [% FOREACH library IN debit_type.library_limits %]
99
                                </li>
198
                                            [%- IF loop.first -%]
100
                                <li>
199
                                                [% library_limits_str = library.branchname _ " (" _ library.branchcode _ ")" %]
101
                                    <label for="description" class="required">Description: </label>
200
                                            [% ELSE %]
102
                                    [% IF debit_type && debit_type.is_system %]
201
                                                [% library_limits_str = library_limits_str _ "\n" _ library.branchname _ " (" _ library.branchcode _ ")" %]
103
                                        <span>[%- PROCESS debit_type_description debit_type = debit_type -%]</span>
202
                                            [% END %]
104
                                    [% ELSE %]
203
                                        [% END %]
105
                                        <input type="text" name="description" id="description" required="required" class="required" size="80" maxlength="100" value="[% debit_type.description | html %]" /> <span class="required">Required</span>
204
                                        <span class="library_limitation" title="[% library_limits_str | html %]">
106
                                    [% END %]
205
                                            [% IF debit_type.library_limits.count > 1 %]
107
                                </li>
206
                                                <span>[% debit_type.library_limits.count | html %] library limitations</span>
108
                                <li>
207
                                            [% ELSE %]
109
                                    <label for="can_be_invoiced">Can be manually invoiced? </label>
208
                                                <span>[% debit_type.library_limits.count | html %] library limitation</span>
110
                                    [% IF debit_type.can_be_invoiced %]
209
                                            [% END %]
111
                                        <input type="checkbox" name="can_be_invoiced" id="can_be_invoiced" checked="checked" value="1" />
210
                                        </span>
211
                                    [% ELSE %]
112
                                    [% ELSE %]
212
                                        <span>No limitation</span>
113
                                        <input type="checkbox" name="can_be_invoiced" id="can_be_invoiced" value="1" />
213
                                    [% END %]
114
                                    [% END %]
214
                                </td>
115
                                </li>
215
                                <td>
116
                                <li>
117
                                    <label for="can_be_sold">Can be sold? </label>
118
                                    [% IF debit_type.can_be_sold %]
119
                                        <input type="checkbox" name="can_be_sold" id="can_be_sold" checked="checked" value="1" />
120
                                    [% ELSE %]
121
                                        <input type="checkbox" name="can_be_sold" id="can_be_sold" value="1" />
122
                                    [% END %]
123
                                </li>
124
                                <li>
125
                                    <label for="restricts_checkouts">Included in noissuescharge? </label>
216
                                    [% IF debit_type.restricts_checkouts %]
126
                                    [% IF debit_type.restricts_checkouts %]
217
                                        <span>Yes</span>
127
                                        <input type="checkbox" name="restricts_checkouts" id="restricts_checkouts" checked="checked" value="1" />
218
                                    [% ELSE %]
128
                                    [% ELSE %]
219
                                        <span>No</span>
129
                                        <input type="checkbox" name="restricts_checkouts" id="restricts_checkouts" value="1" />
220
                                    [% END %]
130
                                    [% END %]
221
                                </td>
131
                                </li>
222
                                <td class="actions">
132
                                <li>
223
                                    [% IF !debit_type.archived %]
133
                                    <label for="branches">Libraries limitation: </label>
224
                                        <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/debit_types.pl?op=add_form&amp;code=[% debit_type.code | uri %]&type=debit"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a>
134
                                    <select id="branches" name="branches" multiple size="10">
225
                                        [% IF !debit_type.is_system %]
135
                                        <option value="">All libraries</option>
226
                                            <form id="archive_[% debit_type.code | html %]" method="post" action="/cgi-bin/koha/admin/debit_types.pl">
136
                                        [% FOREACH branch IN branches_loop %]
227
                                                [% INCLUDE 'csrf-token.inc' %]
137
                                        [% IF ( branch.selected ) %]
228
                                                <input type="hidden" name="op" value="cud-archive" />
138
                                        <option selected="selected" value="[% branch.branchcode | html %]">[% branch.branchname | html %]</option>
229
                                                <input type="hidden" name="code" value="[% debit_type.code | html %]" />
139
                                        [% ELSE %]
230
                                                <button type="submit" class="btn btn-default btn-xs archive_button" href="#" data-code="[% debit_type.code | html %]"><i class="fa fa-archive"></i> Archive</button>
140
                                        <option value="[% branch.branchcode | html %]">[% branch.branchname | html %]</option>
231
                                            </form>
232
                                        [% END %]
141
                                        [% END %]
233
                                    [% ELSIF debit_type.archived %]
142
                                        [% END %]
234
                                        <form id="unarchive_[% debit_type.code | html %]" method="post" action="/cgi-bin/koha/admin/debit_types.pl">
143
                                    </select>
235
                                            [% INCLUDE 'csrf-token.inc' %]
144
                                    <div class="hint">Select 'All libraries' if this debit type should be available at all libraries. Otherwise select libraries you want to associate debit type with.</div>
236
                                            <input type="hidden" name="op" value="cud-unarchive" />
145
                                </li>
237
                                            <input type="hidden" name="code" value="[% debit_type.code | html %]" />
146
                            </ol>
238
                                            <button type="submit" class="btn btn-default btn-xs unarchive_button" href="#" data-code="[% debit_type.code | html %]"><i class="fa fa-undo"></i> Restore</button>
147
                        </fieldset>
239
                                        </form>
148
                        [% IF additional_fields.size %]
240
                                    [% END %]
149
                            [% INCLUDE 'additional-fields-entry.inc' available=additional_fields values=additional_field_values wrap_fieldset=1 %]
241
                                </td>
242
                            </tr>
243
                        [% END %]
150
                        [% END %]
244
                    </tbody>
151
                        <fieldset class="action">
245
                </table> </div
152
                            <button id="save_debit_type" class="btn btn-primary">Save</button>
246
            ><!-- /.page-section -->
153
                            <a class="cancel" href="/cgi-bin/koha/admin/debit_types.pl">Cancel</a>
247
        [% ELSE %]
154
                        </fieldset>
248
            <div class="alert alert-info"> There are no account debit types defined. <a href="/cgi-bin/koha/admin/debit_types.pl?op=add_form">Create new debit type</a> </div>
155
                    </form>
249
        [% END %]
156
                [% END %]
250
    [% END %]
157
158
                [% IF op == 'list' %]
159
                    <div id="toolbar" class="btn-toolbar">
160
                        <a class="btn btn-default" id="newdebittype" href="/cgi-bin/koha/admin/debit_types.pl?op=add_form"><i class="fa fa-plus"></i> New debit type</a>
161
                    </div>
162
163
                    <h1>Debit types</h1>
164
                    [% IF debit_types.count %]
165
                        <div class="page-section">
166
                            <table id="table_debit_types">
167
                                <thead>
168
                                    <th>Archived</th>
169
                                    <th>System</th>
170
                                    <th>Code</th>
171
                                    <th>Description</th>
172
                                    <th>Default amount</th>
173
                                    <th>Available for</th>
174
                                    <th>Library limitations</th>
175
                                    <th>Blocks checkouts?</th>
176
                                    <th class="noExport">Actions</th>
177
                                </thead>
178
                                <tbody>
179
                                    [% FOREACH debit_type IN debit_types %]
180
                                    <tr>
181
                                        <td>[% debit_type.archived | html %]</td>
182
                                        <td>[% debit_type.is_system | html %]</td>
183
                                        <td>[% debit_type.code | html %]</td>
184
                                        <td>[%- PROCESS debit_type_description debit_type = debit_type -%]</td>
185
                                        <td>[% debit_type.default_amount | $Price %]</td>
186
                                        <td>[% IF debit_type.can_be_invoiced && debit_type.can_be_sold %]
187
                                            <i class="fa fa-id-card"></i> Invoicing, <i class="fa fa-shopping-cart"></i> Sale
188
                                            [% ELSIF debit_type.can_be_invoiced %]
189
                                            <i class="fa fa-id-card"></i> Invoicing
190
                                            [% ELSIF debit_type.can_be_sold %]
191
                                            <i class="fa fa-shopping-cart"></i> Sale
192
                                            [% END %]
193
                                        </td>
194
                                        <td>
195
                                            [% IF debit_type.library_limits.count > 0 %]
196
                                                [% library_limits_str = "" %]
197
                                                [% FOREACH library IN debit_type.library_limits %]
198
                                                    [%- IF loop.first -%]
199
                                                    [% library_limits_str = library.branchname _ " (" _ library.branchcode _ ")" %]
200
                                                    [% ELSE %]
201
                                                    [% library_limits_str = library_limits_str _ "\n" _ library.branchname _ " (" _ library.branchcode _ ")" %]
202
                                                    [% END %]
203
                                                [% END %]
204
                                                <span class="library_limitation" title="[% library_limits_str | html %]">
205
                                                    [% IF debit_type.library_limits.count > 1 %]
206
                                                        <span>[% debit_type.library_limits.count | html %] library limitations</span>
207
                                                    [% ELSE %]
208
                                                        <span>[% debit_type.library_limits.count | html %] library limitation</span>
209
                                                    [% END %]
210
                                            [% ELSE %]
211
                                                <span>No limitation</span>
212
                                            [% END %]
213
                                        </td>
214
                                        <td>
215
                                            [% IF debit_type.restricts_checkouts %]
216
                                                <span>Yes</span>
217
                                            [% ELSE %]
218
                                                <span>No</span>
219
                                            [% END %]
220
                                        </td>
221
                                        <td class="actions">
222
                                            [% IF !debit_type.archived %]
223
                                                <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/debit_types.pl?op=add_form&amp;code=[% debit_type.code | uri %]&type=debit"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a>
224
                                                [% IF !debit_type.is_system %]
225
                                                    <form id="archive_[% debit_type.code | html %]" method="post" action="/cgi-bin/koha/admin/debit_types.pl">
226
                                                        [% INCLUDE 'csrf-token.inc' %]
227
                                                        <input type="hidden" name="op" value="cud-archive" />
228
                                                        <input type="hidden" name="code" value="[% debit_type.code | html %]" />
229
                                                        <button type="submit" class="btn btn-default btn-xs archive_button" href="#" data-code="[% debit_type.code | html %]"><i class="fa fa-archive"></i> Archive</button>
230
                                                    </form>
231
                                                [% END %]
232
                                            [% ELSIF debit_type.archived %]
233
                                                <form id="unarchive_[% debit_type.code | html %]" method="post" action="/cgi-bin/koha/admin/debit_types.pl">
234
                                                    [% INCLUDE 'csrf-token.inc' %]
235
                                                    <input type="hidden" name="op" value="cud-unarchive" />
236
                                                    <input type="hidden" name="code" value="[% debit_type.code | html %]" />
237
                                                    <button type="submit" class="btn btn-default btn-xs unarchive_button" href="#" data-code="[% debit_type.code | html %]"><i class="fa fa-undo"></i> Restore</button>
238
                                                </form>
239
                                            [% END %]
240
                                        </td>
241
                                    </tr>
242
                                    [% END %]
243
                                </tbody>
244
                            </table>
245
                        </div><!-- /.page-section -->
246
                    [% ELSE %]
247
                        <div class="alert alert-info">
248
                            There are no account debit types defined. <a href="/cgi-bin/koha/admin/debit_types.pl?op=add_form">Create new debit type</a>
249
                        </div>
250
                    [% END %]
251
                [% END %]
251
[% END %]
252
[% END %]
252
253
253
[% MACRO jsinclude BLOCK %]
254
[% MACRO jsinclude BLOCK %]
254
    [% Asset.js("js/admin-menu.js") | $raw %]
255
    [% Asset.js("js/admin-menu.js") | $raw %]
256
    [% Asset.js("js/additional-fields-entry.js") | $raw %]
255
    [% INCLUDE 'datatables.inc' %]
257
    [% INCLUDE 'datatables.inc' %]
258
256
    <script>
259
    <script>
257
        $(document).ready(function () {
260
        $(document).ready(function() {
258
            var txtActivefilter = _("Filter system debit types");
261
            var txtActivefilter = _("Filter system debit types");
259
            var txtInactivefilter = _("Show all debit types");
262
            var txtInactivefilter = _("Show all debit types");
260
            var table_debit_types = $("#table_debit_types").dataTable(
263
            var table_debit_types = $("#table_debit_types").dataTable($.extend(true, {}, dataTablesDefaults, {
261
                $.extend(true, {}, dataTablesDefaults, {
264
                "columnDefs": [
262
                    columnDefs: [
265
                    { "targets": [ -1 ], "orderable": false, "searchable":  false },
263
                        { targets: [-1], orderable: false, searchable: false },
266
                    { "targets": [ 0, 1 ], "orderable": false, "visible": false },
264
                        { targets: [0, 1], orderable: false, visible: false },
267
                ],
265
                    ],
268
                "order": [[ 0, "asc" ],[ 2, "asc" ]],
266
                    order: [
269
                "dom": 'C<"top pager"ilpfB><"#filter_s">tr<"bottom pager"ip>',
267
                        [0, "asc"],
270
                "pageLength": 20,
268
                        [2, "asc"],
271
                "pagingType": "full_numbers"
269
                    ],
272
            }));
270
                    dom: 'C<"top pager"ilpfB><"#filter_s">tr<"bottom pager"ip>',
273
            $("#filter_s").html('<p><a href="#" id="filter_system"><i class="fa fa-filter"></i> '+txtActivefilter+'</a>');
271
                    pageLength: 20,
274
            $('#filter_system').click(function(e) {
272
                    pagingType: "full_numbers",
273
                })
274
            );
275
            $("#filter_s").html('<p><a href="#" id="filter_system"><i class="fa fa-filter"></i> ' + txtActivefilter + "</a>");
276
            $("#filter_system").click(function (e) {
277
                e.preventDefault();
275
                e.preventDefault();
278
                if ($(this).hasClass("filtered")) {
276
                if ($(this).hasClass('filtered')) {
279
                    var filteredValue = "";
277
                    var filteredValue = '';
280
                    $(this).html('<i class="fa fa-filter"></i> ' + txtActivefilter);
278
                    $(this).html('<i class="fa fa-filter"></i> '+txtActivefilter);
281
                } else {
279
                } else { // Not filtered. Let's do it!
282
                    // Not filtered. Let's do it!
280
                    var filteredValue = '0';
283
                    var filteredValue = "0";
281
                    $(this).html('<i class="fa fa-filter"></i> '+txtInactivefilter);
284
                    $(this).html('<i class="fa fa-filter"></i> ' + txtInactivefilter);
285
                }
282
                }
286
                table_debit_types.DataTable().columns(1).search(filteredValue, false, false).draw();
283
                table_debit_types.DataTable().columns(1).search(filteredValue, false, false).draw();
287
                $(this).toggleClass("filtered");
284
                $(this).toggleClass('filtered');
288
            });
285
            });
289
286
290
            //Start filtered
287
            //Start filtered
291
            $("#filter_system").click();
288
            $('#filter_system').click();
289
292
        });
290
        });
293
    </script>
291
    </script>
294
[% END %]
292
[% END %]
295
293
296
[% INCLUDE 'intranet-bottom.inc' %]
294
[% INCLUDE 'intranet-bottom.inc' %]
297
- 

Return to bug 38457