From edf3460da3ba317c9d5dc3230e85587fc45d1ac3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20V=C3=A9ron?= Date: Fri, 24 Apr 2015 22:19:37 +0200 Subject: [PATCH] Bug 14057 - A Rough Start - Compare old and new code This patch gets values using both methods to compare the results. For testing purposes only. To test: Apply patch Compare results by commenting /uncommenting appropriate lines after line 1154 in C4/Items.pm If found one difference: Old code could not handle Withdrawn status (displays 1 instead of the text) ------ Amended: I changed the test code to reflect the old behaviour fixed with patch from Bug 14061 It writes a warning if the old and the new value are not the same. I still got differences with the Withdrawn status and found out, that it took the auth value for OPAC. This is due to a part of the select statement in the first patch (Line 1122) that overrules the value for the staff client: IF(TB.lib_opac>'',TB.lib_opac,TB.lib) --- C4/Items.pm | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/C4/Items.pm b/C4/Items.pm index 2ab3b16..3bb0910 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -1133,9 +1133,30 @@ sub GetItemsForInventory { # Auth values foreach (keys %$row) { + my $new = ''; if (defined($avmapping->{"items.$_,".$row->{'frameworkcode'}.",".$row->{$_}})) { - $row->{$_} = $avmapping->{"items.$_,".$row->{'frameworkcode'}.",".$row->{$_}}; + ### WILL BE SET BELOW $row->{$_} = $avmapping->{"items.$_,".$row->{'frameworkcode'}.",".$row->{$_}}; + $new = $avmapping->{"items.$_,".$row->{'frameworkcode'}.",".$row->{$_}}; } + + #######TESTING WITH OLD CODE + #If the koha field is mapped to a marc fielda + my $old = ''; + my ($f, $sf) = GetMarcFromKohaField("items.$_", $row->{'frameworkcode'}); + if (defined $f and defined $sf) { + # We replace the code with it's description + my $authvals = C4::Koha::GetKohaAuthorisedValuesFromField($f, $sf, $row->{'frameworkcode'}); + if ( defined ($authvals->{$row->{$_}}) ) { + ### WILL BE SET BELOW $row->{$_} = $authvals->{$row->{$_}} ; + $old = $authvals->{$row->{$_}} ; + } + } + #######TEST HERE OUTPUT + if ( $new || $old ) { + warn "|$new| -- |$old|" if ( $new ne $old ); + } + $row->{$_} = $new if ($new); + #$row->{$_} = $old if ($old); } push @results, $row; } -- 1.7.10.4