Lines 33-38
use Koha::Database;
Link Here
|
33 |
use Koha::Exception; |
33 |
use Koha::Exception; |
34 |
use Koha::Biblios; |
34 |
use Koha::Biblios; |
35 |
use Koha::Items; |
35 |
use Koha::Items; |
|
|
36 |
use Koha::Object; |
36 |
use Koha::Patrons; |
37 |
use Koha::Patrons; |
37 |
use Koha::Item::Attributes; |
38 |
use Koha::Item::Attributes; |
38 |
use Koha::BackgroundJob::BatchDeleteItem; |
39 |
use Koha::BackgroundJob::BatchDeleteItem; |
Lines 112-124
if ( $op eq "cud-action" ) {
Link Here
|
112 |
|
113 |
|
113 |
} else { # modification |
114 |
} else { # modification |
114 |
|
115 |
|
115 |
my @item_columns = Koha::Items->columns; |
116 |
my $items_info = Koha::Items->_resultset->result_source->columns_info; |
116 |
|
117 |
|
117 |
my $new_item_data; |
118 |
my $new_item_data; |
118 |
my ($columns_with_regex); |
119 |
my ($columns_with_regex); |
119 |
my @subfields_to_blank = $input->multi_param('disable_input'); |
120 |
my @subfields_to_blank = $input->multi_param('disable_input'); |
120 |
my @more_subfields = $input->multi_param("items.more_subfields_xml"); |
121 |
my @more_subfields = $input->multi_param("items.more_subfields_xml"); |
121 |
for my $item_column (@item_columns) { |
122 |
for my $item_column ( keys %$items_info ) { |
122 |
my @attributes = ($item_column); |
123 |
my @attributes = ($item_column); |
123 |
my $cgi_param_prefix = 'items.'; |
124 |
my $cgi_param_prefix = 'items.'; |
124 |
if ( $item_column eq 'more_subfields_xml' ) { |
125 |
if ( $item_column eq 'more_subfields_xml' ) { |
Lines 136-148
if ( $op eq "cud-action" ) {
Link Here
|
136 |
|
137 |
|
137 |
if ( grep { $cgi_var_name eq $_ } @subfields_to_blank ) { |
138 |
if ( grep { $cgi_var_name eq $_ } @subfields_to_blank ) { |
138 |
|
139 |
|
139 |
# Empty this column |
140 |
# Empty this column, check nullable and data_type |
140 |
if ( $attr eq 'withdrawn' || $attr eq 'itemlost' || $attr eq 'damaged' || $attr eq 'notforloan' ) { |
141 |
next if !$items_info->{$attr}; # skip this weird case |
141 |
|
142 |
if ( $items_info->{$attr}->{is_nullable} ) { |
142 |
# these fields are not nullable; they must be set to 0 instead |
143 |
$new_item_data->{$attr} = undef; |
|
|
144 |
} elsif ( Koha::Object::_numeric_column_type( $items_info->{$attr}->{data_type} ) ) { |
143 |
$new_item_data->{$attr} = 0; |
145 |
$new_item_data->{$attr} = 0; |
144 |
} else { |
146 |
} else { |
145 |
$new_item_data->{$attr} = undef; |
147 |
$new_item_data->{$attr} = q{}; |
146 |
} |
148 |
} |
147 |
} elsif ( my $regex_search = $input->param( $cgi_var_name . '_regex_search' ) ) { |
149 |
} elsif ( my $regex_search = $input->param( $cgi_var_name . '_regex_search' ) ) { |
148 |
$columns_with_regex->{$attr} = { |
150 |
$columns_with_regex->{$attr} = { |
149 |
- |
|
|