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

(-)a/Koha/Items.pm (-9 / +10 lines)
Lines 295-309 sub batch_update { Link Here
295
295
296
                my $old = $old_values->{$attribute};
296
                my $old = $old_values->{$attribute};
297
                my $new = $new_values->{$attribute};
297
                my $new = $new_values->{$attribute};
298
		if ( $attribute eq 'permanent_location' && $new eq '' ){
298
                if ( $attribute eq 'permanent_location' && $new eq '' ) {
299
		    # In the case where permanent_location is exposed we need
299
300
		    # to preserve the original value when none is passed
300
                    # In the case where permanent_location is exposed we need
301
		    # the script will send a blank value to indicate that it was
301
                    # to preserve the original value when none is passed
302
		    # included in the form
302
                    # the script will send a blank value to indicate that it was
303
		    $modified++;
303
                    # included in the form
304
		    $new_values->{permanent_location} = $old;
304
                    $modified++;
305
		    $item->make_column_dirty('permanent_location');
305
                    $new_values->{permanent_location} = $old;
306
	        }
306
                    $item->make_column_dirty('permanent_location');
307
                }
307
                $modified++
308
                $modified++
308
                  if ( defined $old xor defined $new )
309
                  if ( defined $old xor defined $new )
309
                  || ( defined $old && defined $new && $new ne $old );
310
                  || ( defined $old && defined $new && $new ne $old );
(-)a/t/db_dependent/Koha/Items/BatchUpdate.t (-10 / +14 lines)
Lines 164-186 subtest 'permanent_location' => sub { Link Here
164
164
165
    plan tests => 2;
165
    plan tests => 2;
166
166
167
    $items->batch_update({
167
    $items->batch_update(
168
        {
168
            new_values => {
169
            new_values => {
169
	        'permanent_location' => 'perm',
170
                'permanent_location' => 'perm',
170
		'location' => 'loc'
171
                'location'           => 'loc'
171
	    }
172
            }
172
        });
173
        }
174
    );
173
    $items->reset;
175
    $items->reset;
174
176
175
    $item = $item->get_from_storage;
177
    $item = $item->get_from_storage;
176
    is( $item->permanent_location, 'perm', 'Updated as expected when value passed');
178
    is( $item->permanent_location, 'perm', 'Updated as expected when value passed');
177
179
178
    $items->batch_update({
180
    $items->batch_update(
181
        {
179
            new_values => {
182
            new_values => {
180
	        'permanent_location' => '',
183
                'permanent_location' => '',
181
		'location' => 'new_loc'
184
                'location'           => 'new_loc'
182
	    }
185
            }
183
        });
186
        }
187
    );
184
    $items->reset;
188
    $items->reset;
185
189
186
    $item = $item->get_from_storage;
190
    $item = $item->get_from_storage;
(-)a/tools/batchMod.pl (-5 / +4 lines)
Lines 156-165 if ( $op eq "action" ) { Link Here
156
                      grep { $_ ne "" } uniq $input->multi_param($cgi_var_name);
156
                      grep { $_ ne "" } uniq $input->multi_param($cgi_var_name);
157
157
158
                    next unless @v || $attr eq 'permanent_location';
158
                    next unless @v || $attr eq 'permanent_location';
159
		    # If permanent_location is present in the form we need to pass it forward
159
                    # If permanent_location is present in the form we need to pass it forward
160
		    # to indicate that the user may modify this field directly and so
160
                    # to indicate that the user may modify this field directly and so
161
		    # it needs to be marked as 'dirty' on any update. Otherwise the object always
161
                    # it needs to be marked as 'dirty' on any update. Otherwise the object always
162
		    # sets location to the permanent_location as well
162
                    # sets location to the permanent_location as well
163
163
164
                    $new_item_data->{$attr} = join '|', @v;
164
                    $new_item_data->{$attr} = join '|', @v;
165
                }
165
                }
166
- 

Return to bug 31187