From f7fdd8e36f98ed05ed0eb49c02d414aa8c5cb403 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 27 Mar 2013 09:18:24 -0400 Subject: [PATCH] Bug 9902 - item subfields not populating Test Plan: 1) Create a new serial with a default location, call number, and library ( the library will need to be any but the one you are logged in as ) 2) Click the "Recieve" button for this serial 3) Click "Click to add item" 4) Note those values are not populated 5) Apply the patch 6) Reload the page 7) Click "Click to add item" 8) Note those values are now populated Signed-off-by: Nicole C. Engard All tests pass! Signed-off-by: Chris Cormack This seems to restore the former behaviour. Signed-off-by: Liz Rea signing for 3.10.x - restores former behaviour. Signed-off-by: Katrin Fischer Works nicely. Before applying the patch callnumber, location and branches are not carried over correctly. After applying the patch, this works as expected. Signed-off-by: Bernardo Gonzalez Kriegel Pushed to 3.10.x --- C4/Items.pm | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/C4/Items.pm b/C4/Items.pm index 741d42a2da..08d7b1a51e 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -2650,6 +2650,10 @@ sub PrepareItemrecordDisplay { && $defaultvalues && $defaultvalues->{'callnumber'} ) { if( $itemrecord and $defaultvalues and not $itemrecord->field($subfield) ){ + # if the item record exists, only use default value if the item has no callnumber + $defaultvalue = $defaultvalues->{callnumber}; + } elsif ( !$itemrecord and $defaultvalues ) { + # if the item record *doesn't* exists, always use the default value $defaultvalue = $defaultvalues->{callnumber}; } } @@ -2665,6 +2669,10 @@ sub PrepareItemrecordDisplay { && $defaultvalues->{'location'} ) { if ( $itemrecord and $defaultvalues and not $itemrecord->field($subfield) ) { + # if the item record exists, only use default value if the item has no locationr + $defaultvalue = $defaultvalues->{location}; + } elsif ( !$itemrecord and $defaultvalues ) { + # if the item record *doesn't* exists, always use the default value $defaultvalue = $defaultvalues->{location}; } } @@ -2695,6 +2703,7 @@ sub PrepareItemrecordDisplay { $authorised_lib{$branchcode} = $branchname; } } + $defaultvalue = $defaultvalues->{branchcode} || C4::Context->userenv->{branch}; #----- itemtypes } elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "itemtypes" ) { @@ -2720,6 +2729,8 @@ sub PrepareItemrecordDisplay { $authorised_lib{$class_source} = $class_sources->{$class_source}->{'description'}; } + $defaultvalue = $default_source; + #---- "true" authorised value } else { $authorised_values_sth->execute( $tagslib->{$tag}->{$subfield}->{authorised_value} ); -- 2.39.5