| 
      
            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 ( $@ ) { |