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

(-)a/admin/authorised_values.pl (+23 lines)
Lines 191-196 if ($op eq 'add_form') { Link Here
191
    }
191
    }
192
192
193
    $op = 'list';
193
    $op = 'list';
194
} elsif ($op eq 'del_category' ) {
195
    my %cant_del = (
196
        LOC => 1,
197
        LOST => 1,
198
        WITHDRAWN => 1,
199
        );
200
201
    my $del_category = $input->param('category');
202
    if ( Koha::AuthorisedValues->new->search({ category => $del_category })->count > 0 ) {
203
        push @messages, {type => 'error', code => 'error_on_delete_cat_notempty' };
204
    } elsif ( $cant_del{$del_category} ) {
205
        push @messages, {type => 'error', code => 'invalid_category_del' };
206
    } else {
207
        my $cat = Koha::AuthorisedValueCategories->new->find( $del_category );
208
        my $deleted = eval {$cat->delete};
209
        if ( $@ or not $deleted ) {
210
            push @messages, {type => 'error', code => 'error_on_delete_cat' };
211
        } else {
212
            push @messages, { type => 'message', code => 'success_on_delete_cat' };
213
        }
214
    }
215
    $op = 'list';
216
    $template->param( delete_success => 1 );
194
} elsif ($op eq 'delete') {
217
} elsif ($op eq 'delete') {
195
    my $av = Koha::AuthorisedValues->new->find( $id );
218
    my $av = Koha::AuthorisedValues->new->find( $id );
196
    my $deleted = eval {$av->delete};
219
    my $deleted = eval {$av->delete};
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt (-2 / +12 lines)
Lines 182-199 $(document).ready(function() { Link Here
182
            An error occurred when inserting this authorized value category. Perhaps the category name already exists.
182
            An error occurred when inserting this authorized value category. Perhaps the category name already exists.
183
        [% CASE 'error_on_delete' %]
183
        [% CASE 'error_on_delete' %]
184
            An error occurred when deleting this authorized value. Check the logs.
184
            An error occurred when deleting this authorized value. Check the logs.
185
        [% CASE 'error_on_delete_cat' %]
186
            An error occurred when deleting this authorized value category. Check the logs.
187
        [% CASE 'error_on_delete_cat_notempty' %]
188
            This category cannot be deleted as it contains values.
185
        [% CASE 'success_on_update' %]
189
        [% CASE 'success_on_update' %]
186
            Authorized value updated successfully.
190
            Authorized value updated successfully.
187
        [% CASE 'success_on_insert' %]
191
        [% CASE 'success_on_insert' %]
188
            Authorized value added successfully.
192
            Authorized value added successfully.
189
        [% CASE 'success_on_insert_cat' %]
193
        [% CASE 'success_on_insert_cat' %]
190
            Authorized value category added successfully.
194
            Authorized value category added successfully.
195
        [% CASE 'success_on_delete_cat' %]
196
            Authorized value deleted added successfully.
191
        [% CASE 'success_on_delete' %]
197
        [% CASE 'success_on_delete' %]
192
            Authorized value deleted successfully.
198
            Authorized value deleted successfully.
193
        [% CASE 'already_exists' %]
199
        [% CASE 'already_exists' %]
194
            This authorized value already exists.
200
            This authorized value already exists.
195
        [% CASE 'cat_already_exists' %]
201
        [% CASE 'cat_already_exists' %]
196
            This authorized value category already exists.
202
            This authorized value category already exists.
203
        [% CASE 'invalid_category_del' %]
204
            The authorized value categories 'LOC', 'CCODE' and 'LOST' are used internally by Koha and may not be deleted.
197
        [% CASE 'invalid_category_name' %]
205
        [% CASE 'invalid_category_name' %]
198
            The authorized value category 'branches', 'itemtypes' and 'cn_source' are used internally by Koha and are not valid.
206
            The authorized value category 'branches', 'itemtypes' and 'cn_source' are used internally by Koha and are not valid.
199
        [% CASE %]
207
        [% CASE %]
Lines 296-302 $(document).ready(function() { Link Here
296
</tr>
304
</tr>
297
[% END %]
305
[% END %]
298
</tbody></table>[% ELSE %]
306
</tbody></table>[% ELSE %]
299
<div class="dialog message">There are no authorized values defined for [% category %]</div>
307
<div class="dialog message">There are no authorized values defined for [% category %]
308
    <a class="delete btn btn-default btn-xs" href="/cgi-bin/koha/admin/authorised_values.pl?op=del_category&amp;category=[% searchfield %]"><i class="fa fa-trash"></i> Delete category</a></td>
309
310
</div>
300
[% END %]
311
[% END %]
301
312
302
[% IF ( isprevpage ) %]
313
[% IF ( isprevpage ) %]
303
- 

Return to bug 17355