Bug 16013: Make classification sources deletable
[srvgit] / admin / authorised_values.pl
index 620ddc7..0f00126 100755 (executable)
@@ -103,7 +103,17 @@ if ($op eq 'add_form') {
     my $duplicate_entry = 0;
     my @branches = grep { $_ ne q{} } $input->param('branches');
 
-    if ( $id ) { # Update
+    my $already_exists = Koha::AuthorisedValues->search(
+        {
+            category => $new_category,
+            authorised_value => $new_authorised_value,
+        }
+    )->next;
+
+    if ( $already_exists and ( not $id or $already_exists->id != $id ) ) {
+        push @messages, {type => 'error', code => 'already_exists' };
+    }
+    elsif ( $id ) { # Update
         my $av = Koha::AuthorisedValues->new->find( $id );
 
         $av->lib( $input->param('lib') || undef );
@@ -174,7 +184,7 @@ if ( $op eq 'list' ) {
     }
 
     # push koha system categories
-    foreach (qw(Asort1 Asort2 Bsort1 Bsort2 SUGGEST DAMAGED LOST REPORT_GROUP REPORT_SUBGROUP DEPARTMENT TERM SUGGEST_STATUS)) {
+    foreach (qw(Asort1 Asort2 Bsort1 Bsort2 SUGGEST DAMAGED LOST REPORT_GROUP REPORT_SUBGROUP DEPARTMENT TERM SUGGEST_STATUS ITEMTYPECAT)) {
         push @category_list, $_ unless $categories{$_};
     }