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

(-)a/admin/authorised_values.pl (-3 / +13 lines)
Lines 88-94 if ($op eq 'add_form') { Link Here
88
        );
88
        );
89
    } else {
89
    } else {
90
        $template->param(
90
        $template->param(
91
            category  => $category,
91
            category_name  => $category,
92
            imagesets => C4::Koha::getImageSets(),
92
            imagesets => C4::Koha::getImageSets(),
93
        );
93
        );
94
    }
94
    }
Lines 193-199 if ($op eq 'add_form') { Link Here
193
    }
193
    }
194
194
195
    $op = 'list';
195
    $op = 'list';
196
    $template->param( delete_success => 1 );
196
} elsif ($op eq 'delete_category') {
197
    my $category_name = $input->param('category_name');
198
    my $avc = Koha::AuthorisedValueCategories->find( $category_name );
199
    my $deleted = eval {$avc->delete};
200
    if ( $@ or not $deleted ) {
201
        push @messages, {type => 'error', code => 'error_on_delete_category' };
202
    } else {
203
        push @messages, { type => 'message', code => 'success_on_delete_category' };
204
    }
205
206
    $op = 'list';
197
}
207
}
198
208
199
$template->param(
209
$template->param(
Lines 229-235 if ( $op eq 'list' ) { Link Here
229
239
230
    $template->param(
240
    $template->param(
231
        loop     => \@loop_data,
241
        loop     => \@loop_data,
232
        category => $searchfield,
242
        category => Koha::AuthorisedValueCategories->find($searchfield), # TODO Move this up and add a Koha::AVC->authorised_values method to replace call for avs_by_category
233
        categories => \@category_list,
243
        categories => \@category_list,
234
    );
244
    );
235
245
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt (-8 / +22 lines)
Lines 32-38 Link Here
32
        [% IF ( action_add_category ) %]New category[% END %]
32
        [% IF ( action_add_category ) %]New category[% END %]
33
    [% ELSIF ( loop ) %]
33
    [% ELSIF ( loop ) %]
34
        <a href="/cgi-bin/koha/admin/authorised_values.pl">Authorized values</a> &rsaquo;
34
        <a href="/cgi-bin/koha/admin/authorised_values.pl">Authorized values</a> &rsaquo;
35
        Authorized values for category [% category | html %]
35
        Authorized values for category [% category_name | html %]
36
    [% ELSE %]
36
    [% ELSE %]
37
        Authorized values
37
        Authorized values
38
    [% END %]
38
    [% END %]
Lines 65-71 Link Here
65
            <li>
65
            <li>
66
                <span class="label">Category</span>
66
                <span class="label">Category</span>
67
                <input type="hidden" name="op" value="add" />
67
                <input type="hidden" name="op" value="add" />
68
                <input type="hidden" name="category" value="[% category | html %]" /> [% category | html %]
68
                <input type="hidden" name="category" value="[% category_name | html %]" /> [% category_name | html %]
69
            </li>
69
            </li>
70
        <li>
70
        <li>
71
            <label for="authorised_value">Authorized value: </label>
71
            <label for="authorised_value">Authorized value: </label>
Lines 132-138 Link Here
132
        [% END %]
132
        [% END %]
133
        </fieldset>
133
        </fieldset>
134
       <fieldset class="action"> <input type="hidden" name="id" value="[% id | html %]" />
134
       <fieldset class="action"> <input type="hidden" name="id" value="[% id | html %]" />
135
        <input type="submit" value="Save" /> <a class="cancel" href="/cgi-bin/koha/admin/authorised_values.pl?searchfield=[% category | url %]">Cancel</a></fieldset>
135
        <input type="submit" value="Save" /> <a class="cancel" href="/cgi-bin/koha/admin/authorised_values.pl?searchfield=[% category_name | url %]">Cancel</a></fieldset>
136
    </form>
136
    </form>
137
[% END %]
137
[% END %]
138
138
Lines 141-152 Link Here
141
<div id="toolbar" class="btn-toolbar">
141
<div id="toolbar" class="btn-toolbar">
142
    <a id="addcat" class="btn btn-default" href= "/cgi-bin/koha/admin/authorised_values.pl?op=add_form"><i class="fa fa-plus"> </i> New category</a>
142
    <a id="addcat" class="btn btn-default" href= "/cgi-bin/koha/admin/authorised_values.pl?op=add_form"><i class="fa fa-plus"> </i> New category</a>
143
    [% IF ( searchfield ) %]
143
    [% IF ( searchfield ) %]
144
        <a id="addauth" class="btn btn-default" href= "/cgi-bin/koha/admin/authorised_values.pl?op=add_form&amp;category=[% category | url %]"><i class="fa fa-plus"> </i> New authorized value for [% category | html %]</a>
144
        <a id="addauth" class="btn btn-default" href= "/cgi-bin/koha/admin/authorised_values.pl?op=add_form&amp;category=[% category.category_name | url %]"><i class="fa fa-plus"> </i> New authorized value for [% category.category_name | html %]</a>
145
    [% END %]
145
    [% END %]
146
</div>
146
</div>
147
147
148
[% IF ( searchfield ) %]
148
[% IF ( searchfield ) %]
149
    <h1>Authorized values for category [% category | html %]</h1>
149
    <h1>Authorized values for category [% category.category_name | html %]</h1>
150
    [% PROCESS category_descriptions code_category = category %]
150
    [% PROCESS category_descriptions code_category = category %]
151
[% ELSE %]
151
[% ELSE %]
152
    <h1>Authorized values</h1>
152
    <h1>Authorized values</h1>
Lines 169-174 Link Here
169
            An error occurred when inserting this authorized value category. Perhaps the category name already exists.
169
            An error occurred when inserting this authorized value category. Perhaps the category name already exists.
170
        [% CASE 'error_on_delete' %]
170
        [% CASE 'error_on_delete' %]
171
            An error occurred when deleting this authorized value. Check the logs.
171
            An error occurred when deleting this authorized value. Check the logs.
172
        [% CASE 'error_on_delete_category' %]
173
            An error occurred when deleting this authorized value category. Check the logs.
172
        [% CASE 'success_on_update' %]
174
        [% CASE 'success_on_update' %]
173
            Authorized value updated successfully.
175
            Authorized value updated successfully.
174
        [% CASE 'success_on_insert' %]
176
        [% CASE 'success_on_insert' %]
Lines 177-182 Link Here
177
            Authorized value category added successfully.
179
            Authorized value category added successfully.
178
        [% CASE 'success_on_delete' %]
180
        [% CASE 'success_on_delete' %]
179
            Authorized value deleted successfully.
181
            Authorized value deleted successfully.
182
        [% CASE 'success_on_delete_category' %]
183
            Authorized value category deleted successfully.
180
        [% CASE 'cat_already_exists' %]
184
        [% CASE 'cat_already_exists' %]
181
            This authorized value category already exists.
185
            This authorized value category already exists.
182
        [% CASE 'invalid_category_name' %]
186
        [% CASE 'invalid_category_name' %]
Lines 250-261 Link Here
250
    </tbody></table>
254
    </tbody></table>
251
    [% ELSE %]
255
    [% ELSE %]
252
        <div class="dialog message">
256
        <div class="dialog message">
253
            <p>There are no authorized values defined for [% category | html %]</p>
257
            <p>There are no authorized values defined for [% category.category_name | html %]</p>
254
            <form action="/cgi-bin/koha/admin/authorised_values.pl" method="get">
258
            <form action="/cgi-bin/koha/admin/authorised_values.pl" method="get">
255
                <input type="hidden" name="op" value="add_form" />
259
                <input type="hidden" name="op" value="add_form" />
256
                <input type="hidden" name="category" value="[% category | html %]" />
260
                <input type="hidden" name="category" value="[% category.category_name | html %]" />
257
                <button type="submit"><i class="fa fa-plus"></i> Add a new authorized value</button>
261
                <button type="submit"><i class="fa fa-plus"></i> Add a new authorized value</button>
258
            </form>
262
            </form>
263
            [% UNLESS category.is_system %]
264
                <form id="delete_category" action="/cgi-bin/koha/admin/authorised_values.pl" method="post">
265
                    <input type="hidden" name="op" value="delete_category" />
266
                    <input type="hidden" name="category_name" value="[% category.category_name | html %]" />
267
                    <button type="submit"><i class="fa fa-plus"></i> Delete category '[% category.category_name | html %]' </button>
268
                </form>
269
            [% END %]
259
        </div>
270
        </div>
260
    [% END %]
271
    [% END %]
261
272
Lines 326-331 Link Here
326
                $('#category').submit();
337
                $('#category').submit();
327
            });
338
            });
328
            $(".library_limitation").tooltip();
339
            $(".library_limitation").tooltip();
340
341
            $("#delete_category").on('submit', function(){
342
                return confirm(_("Are you sure you want to delete this authorized value category?"));
343
            });
329
        });
344
        });
330
    </script>
345
    </script>
331
[% END %]
346
[% END %]
332
- 

Return to bug 17355