|
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 $del_category = $input->param('category'); |
| 196 |
if ( Koha::AuthorisedValues->new->search({ category => $del_category })->count > 0 ) { |
| 197 |
push @messages, {type => 'error', code => 'error_on_delete_cat_notempty' }; |
| 198 |
} else { |
| 199 |
my $cat = Koha::AuthorisedValueCategories->new->find( $del_category ); |
| 200 |
my $deleted = eval {$cat->delete}; |
| 201 |
if ( $@ or not $deleted ) { |
| 202 |
push @messages, {type => 'error', code => 'error_on_delete_cat' }; |
| 203 |
} else { |
| 204 |
push @messages, { type => 'message', code => 'success_on_delete_cat' }; |
| 205 |
} |
| 206 |
} |
| 207 |
$op = 'list'; |
| 208 |
$template->param( delete_success => 1 ); |
| 194 |
} elsif ($op eq 'delete') { |
209 |
} elsif ($op eq 'delete') { |
| 195 |
my $av = Koha::AuthorisedValues->new->find( $id ); |
210 |
my $av = Koha::AuthorisedValues->new->find( $id ); |
| 196 |
my $deleted = eval {$av->delete}; |
211 |
my $deleted = eval {$av->delete}; |
|
Lines 214-225
if ( $op eq 'list' ) {
Link Here
|
| 214 |
# build categories list |
229 |
# build categories list |
| 215 |
my @categories = Koha::AuthorisedValueCategories->search({ category_name => { -not_in => ['', 'branches', 'itemtypes', 'cn_source']}}, { order_by => ['category_name'] } ); |
230 |
my @categories = Koha::AuthorisedValueCategories->search({ category_name => { -not_in => ['', 'branches', 'itemtypes', 'cn_source']}}, { order_by => ['category_name'] } ); |
| 216 |
my @category_list; |
231 |
my @category_list; |
|
|
232 |
my $deletable = 1; |
| 217 |
for my $category ( @categories ) { |
233 |
for my $category ( @categories ) { |
| 218 |
push( @category_list, $category->category_name ); |
234 |
push( @category_list, $category->category_name ); |
| 219 |
} |
235 |
} |
| 220 |
|
|
|
| 221 |
$searchfield ||= $category_list[0]; |
236 |
$searchfield ||= $category_list[0]; |
|
|
237 |
my %cant_del = ( |
| 238 |
LOC => 1, |
| 239 |
LOST => 1, |
| 240 |
WITHDRAWN => 1, |
| 241 |
Bsort1 => 1, |
| 242 |
Bsort2 => 1, |
| 243 |
Asort1 => 1, |
| 244 |
Asort2 => 1, |
| 245 |
SUGGEST => 1, |
| 246 |
DAMAGED => 1, |
| 247 |
LOST => 1, |
| 248 |
MANUAL_INV => 1, |
| 249 |
BOR_NOTES => 1, |
| 250 |
LOC => 1, |
| 251 |
CCODE => 1, |
| 252 |
NOT_LOAN => 1, |
| 253 |
); |
| 222 |
|
254 |
|
|
|
255 |
if ( $cant_del{$searchfield} ) { |
| 256 |
undef $deletable ; |
| 257 |
} |
| 223 |
my @avs_by_category = Koha::AuthorisedValues->new->search( { category => $searchfield } ); |
258 |
my @avs_by_category = Koha::AuthorisedValues->new->search( { category => $searchfield } ); |
| 224 |
my @loop_data = (); |
259 |
my @loop_data = (); |
| 225 |
# builds value list |
260 |
# builds value list |
|
Lines 239-244
if ( $op eq 'list' ) {
Link Here
|
| 239 |
loop => \@loop_data, |
274 |
loop => \@loop_data, |
| 240 |
category => $searchfield, |
275 |
category => $searchfield, |
| 241 |
categories => \@category_list, |
276 |
categories => \@category_list, |
|
|
277 |
deletable => $deletable, |
| 242 |
); |
278 |
); |
| 243 |
|
279 |
|
| 244 |
} |
280 |
} |