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

(-)a/admin/authorised_values.pl (-20 / +11 lines)
Lines 104-120 if ($op eq 'add_form') { Link Here
104
    my $duplicate_entry = 0;
104
    my $duplicate_entry = 0;
105
    my @branches = grep { $_ ne q{} } $input->multi_param('branches');
105
    my @branches = grep { $_ ne q{} } $input->multi_param('branches');
106
106
107
    my $already_exists = Koha::AuthorisedValues->search(
107
    if ( $new_category eq 'branches' or $new_category eq 'itemtypes' or $new_category eq 'cn_source' ) {
108
        {
109
            category => $new_category,
110
            authorised_value => $new_authorised_value,
111
        }
112
    )->next;
113
114
    if ( $already_exists and ( not $id or $already_exists->id != $id ) ) {
115
        push @messages, {type => 'error', code => 'already_exists' };
116
    }
117
    elsif ( $new_category eq 'branches' or $new_category eq 'itemtypes' or $new_category eq 'cn_source' ) {
118
        push @messages, {type => 'error', code => 'invalid_category_name' };
108
        push @messages, {type => 'error', code => 'invalid_category_name' };
119
    }
109
    }
120
    elsif ( $id ) { # Update
110
    elsif ( $id ) { # Update
Lines 136-152 if ($op eq 'add_form') { Link Here
136
        }
126
        }
137
    }
127
    }
138
    else { # Insert
128
    else { # Insert
139
        my $av = Koha::AuthorisedValue->new( {
140
            category => $new_category,
141
            authorised_value => $new_authorised_value,
142
            lib => scalar $input->param('lib') || undef,
143
            lib_opac => scalar $input->param('lib_opac') || undef,
144
            imageurl => $imageurl,
145
        } );
146
147
        eval {
129
        eval {
148
            $av->store;
130
            my $av = Koha::AuthorisedValue->new(
131
                {
132
                    category         => $new_category,
133
                    authorised_value => $new_authorised_value,
134
                    lib              => scalar $input->param('lib') || undef,
135
                    lib_opac         => scalar $input->param('lib_opac') || undef,
136
                    imageurl         => $imageurl,
137
                }
138
            )->store;
149
            $av->replace_library_limits( \@branches );
139
            $av->replace_library_limits( \@branches );
140
            $av->store;
150
        };
141
        };
151
142
152
        if ( $@ ) {
143
        if ( $@ ) {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt (-3 lines)
Lines 177-184 Link Here
177
            Authorized value category added successfully.
177
            Authorized value category added successfully.
178
        [% CASE 'success_on_delete' %]
178
        [% CASE 'success_on_delete' %]
179
            Authorized value deleted successfully.
179
            Authorized value deleted successfully.
180
        [% CASE 'already_exists' %]
181
            This authorized value already exists.
182
        [% CASE 'cat_already_exists' %]
180
        [% CASE 'cat_already_exists' %]
183
            This authorized value category already exists.
181
            This authorized value category already exists.
184
        [% CASE 'invalid_category_name' %]
182
        [% CASE 'invalid_category_name' %]
185
- 

Return to bug 22887