From b605f4d26a79530317a4761ecee84e6ae8b0c114 Mon Sep 17 00:00:00 2001 From: hdl Date: Tue, 5 Apr 2005 15:23:40 +0000 Subject: [PATCH] Searching for double entries when adding a new authority. --- C4/AuthoritiesMarc.pm | 58 ++++++++++++++----- authorities/authorities.pl | 20 ++++--- .../default/en/authorities/authorities.tmpl | 6 +- 3 files changed, 59 insertions(+), 25 deletions(-) diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm index cd68b4afbd..24c647eed0 100644 --- a/C4/AuthoritiesMarc.pm +++ b/C4/AuthoritiesMarc.pm @@ -75,9 +75,11 @@ sub authoritysearch { # "Normal" statements # quote marc fields/subfields - for (my $i=0;$i<$#{$tags};$i++) { + for (my $i=0;$i<=$#{$tags};$i++) { +# warn " $i: ".@$tags[$i]; if (@$tags[$i]) { @$tags[$i] = $dbh->quote(@$tags[$i]); +# warn " $i After process: ".@$tags[$i]; } } my @normal_tags = (); @@ -196,6 +198,7 @@ sub create_request { for(my $i=0; $i<=@$value;$i++) { if (@$value[$i]) { $nb_active++; +# warn " @$tags[$i]"; if ($nb_active==1) { if (@$operator[$i] eq "start") { $sql_tables .= "auth_subfield_table as m$nb_table,"; @@ -849,37 +852,59 @@ sub FindDuplicate { my ($record,$authtypecode)=@_; my $dbh = C4::Context->dbh; - warn "".$record->as_formatted; +# warn "".$record->as_formatted; # search duplicate on ISBN, easy and fast... - my $sth = $dbh->prepare("select auth_tag_to_report from auth_types where authtypecode=?"); + my $sth = $dbh->prepare("select auth_tag_to_report,summary from auth_types where authtypecode=?"); $sth->execute($authtypecode); - my ($auth_tag_to_report) = $sth->fetchrow; + my ($auth_tag_to_report,$taglist) = $sth->fetchrow; $sth->finish; # a more complex search : build a request for authoritysearch my (@tags, @and_or, @excluding, @operator, @value, $offset, $length); # search on biblio.title - warn " tag a reporter : $auth_tag_to_report"; +# warn " tag a reporter : $auth_tag_to_report"; + warn "taglist ".$taglist; + my @subfield = split /\[/, $taglist; + my $max = @subfield; + for (my $i=1; $i<$max;$i++){ + warn " ".$subfield[$i]; + $subfield[$i]=substr($subfield[$i],3,1); + warn " ".$subfield[$i]; + } + if ($record->fields($auth_tag_to_report)) { - my $sth = $dbh->prepare("select tagfield,tagsubfield from auth_subfield_structure where tagfield=? and authtypecode=? and tab >= 0"); - $sth->execute($auth_tag_to_report,$authtypecode); - warn " Champ $auth_tag_to_report present"; - while (my ($tag,$subfield) = $sth->fetchrow){ - if ($record->field($tag)->subfields($subfield)) { - warn "tag :".$tag." subfield: $subfield value : $record->field($tag)->subfield($subfield)->as_formatted"; - push @tags, "'".$tag.$subfield."'"; + foreach my $subfieldcount (1..$#subfield){ + if ($record->field($auth_tag_to_report)->subfields($subfield[$subfieldcount])) { +# warn "tag :".$tag." subfield: $subfield value : ".$record->field($tag)->subfield($subfield); + push @tags, $auth_tag_to_report.$subfield[$subfieldcount]; +# warn "'".$tag.$subfield."' value :". $record->field($tag)->subfield($subfield); push @and_or, "and"; push @excluding, ""; push @operator, "contains"; - push @value, $record->field($tag)->subfield($subfield); + push @value, $record->field($auth_tag_to_report)->subfield($subfield[$subfieldcount]); } } + +# my $sth = $dbh->prepare("select tagfield,tagsubfield from auth_subfield_structure where tagfield=? and authtypecode=? and tab >= 0"); +# $sth->execute($auth_tag_to_report,$authtypecode); +# warn " field $auth_tag_to_report exists"; +# while (my ($tag,$subfield) = $sth->fetchrow){ +# if ($record->field($tag)->subfields($subfield)) { +# # warn "tag :".$tag." subfield: $subfield value : ".$record->field($tag)->subfield($subfield); +# push @tags, $tag.$subfield; +# # warn "'".$tag.$subfield."' value :". $record->field($tag)->subfield($subfield); +# push @and_or, "and"; +# push @excluding, ""; +# push @operator, "contains"; +# push @value, $record->field($tag)->subfield($subfield); +# } +# } } my ($finalresult,$nbresult) = authoritysearch($dbh,\@tags,\@and_or,\@excluding,\@operator,\@value,0,10,$authtypecode); # there is at least 1 result => return the 1st one if ($nbresult) { - warn "$nbresult => ".@$finalresult[0]->{authid},@$finalresult[0]->{summary}; - return @$finalresult[0]->{authid},@$finalresult[0]->{authid},@$finalresult[0]->{summary}; + warn "$nbresult => ".@$finalresult[0]->{authid},$record->field($auth_tag_to_report)->subfield('a'); + return @$finalresult[0]->{authid},@$finalresult[0]->{authid},$record->field($auth_tag_to_report)->subfield('a'); } # no result, returns nothing return; @@ -899,6 +924,9 @@ Paul POULAIN paul.poulain@free.fr # $Id$ # $Log$ +# Revision 1.13 2005/04/05 15:23:41 hdl +# Searching for double entries when adding a new authority. +# # Revision 1.12 2005/04/05 09:58:48 hdl # Adding double authority search before creating a new authority # diff --git a/authorities/authorities.pl b/authorities/authorities.pl index e7209395e0..48881843dd 100755 --- a/authorities/authorities.pl +++ b/authorities/authorities.pl @@ -160,7 +160,7 @@ sub create_input () { sub build_tabs ($$$$) { my($template, $record, $dbh,$encoding) = @_; -# "=>".$record->as_formatted; +# warn "=>".$record->as_formatted if $record; # fill arrays my @loop_data =(); my $tag; @@ -347,16 +347,19 @@ if ($op eq "add") { } # now, redirect to additem page print $input->redirect("detail.pl?authid=$authid"); + build_tabs ($template, $record, $dbh,$encoding); + build_hidden_data; exit; } else { # it may be a duplicate, warn the user and do nothing -# build_tabs ($template, $record, $dbh,$encoding); -# build_hidden_data; $template->param( duplicateauthnumber => $duplicateauthnumber, duplicateauthid => $duplicateauthid, - duplicateauthvalue => $duplicateauthvalue, - ); + duplicateauthvalue => $duplicateauthvalue, + ); + warn " AUTH : ".$record->as_formatted, + build_tabs ($template, $record, $dbh,$encoding); + build_hidden_data; } #------------------------------------------------------------------------------------------------------------------------------ } elsif ($op eq "addfield") { @@ -415,10 +418,13 @@ if ($op eq "add") { } elsif ($op eq "delete") { #------------------------------------------------------------------------------------------------------------------------------ &AUTHdelauthority($dbh,$authid); +} else { + build_tabs ($template, $record, $dbh,$encoding); + build_hidden_data; } -build_tabs ($template, $record, $dbh,$encoding); -build_hidden_data; +# build_tabs ($template, $record, $dbh,$encoding); +# build_hidden_data; $template->param( authid => $authid, # oldbiblionumtagfield => $oldbiblionumtagfield, diff --git a/koha-tmpl/intranet-tmpl/default/en/authorities/authorities.tmpl b/koha-tmpl/intranet-tmpl/default/en/authorities/authorities.tmpl index 072b3849ee..cb88229d06 100644 --- a/koha-tmpl/intranet-tmpl/default/en/authorities/authorities.tmpl +++ b/koha-tmpl/intranet-tmpl/default/en/authorities/authorities.tmpl @@ -19,13 +19,13 @@










- +
-

Duplicate suspected with

+

Duplicate suspected with

You must either :

-- 2.39.5