From 56634350761824e060f34468a813da3ade3b6a15 Mon Sep 17 00:00:00 2001 From: tipaul Date: Tue, 2 Nov 2004 16:44:45 +0000 Subject: [PATCH] new feature : checking for duplicate biblio. For instance, it's only done on ISBN only. Will be improved soon. When a duplicate is detected, the biblio is not saved, but the user is asked for a confirmations. --- C4/Biblio.pm | 20 ++++++++- acqui.simple/addbiblio.pl | 45 ++++++++++++++----- .../default/en/acqui.simple/addbiblio.tmpl | 10 +++++ 3 files changed, 62 insertions(+), 13 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 90ad1338f6..b962cf6d68 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -67,6 +67,8 @@ $VERSION = 0.01; &MARCgetbiblio &MARCgetitem &MARCaddword &MARCdelword &char_decode + + &FindDuplicate ); # @@ -1094,7 +1096,6 @@ sub MARCmarc2koha { $sth2=$dbh->prepare("SHOW COLUMNS from items"); $sth2->execute; while (($field)=$sth2->fetchrow) { -# warn "X"; $result=&MARCmarc2kohaOneField($sth,"items",$field,$record,$result,$frameworkcode); } # additional authors : specific @@ -2528,6 +2529,16 @@ sub nsb_clean { return ($string); } +sub FindDuplicate { + my ($record)=@_; + my $dbh = C4::Context->dbh; + my $result = MARCmarc2koha($dbh,$record,''); + my $sth = $dbh->prepare("select biblio.biblionumber,bibid,title from biblio,biblioitems,marc_biblio where biblio.biblionumber=biblioitems.biblionumber and marc_biblio.biblionumber=biblioitems.biblionumber and isbn=?"); + $sth->execute($result->{'isbn'}); + my ($biblionumber,$bibid,$title) = $sth->fetchrow; + return $biblionumber,$bibid,$title; +} + END { } # module clean-up code here (global destructor) =back @@ -2542,6 +2553,13 @@ Paul POULAIN paul.poulain@free.fr # $Id$ # $Log$ +# Revision 1.106 2004/11/02 16:44:45 tipaul +# new feature : checking for duplicate biblio. +# +# For instance, it's only done on ISBN only. Will be improved soon. +# +# When a duplicate is detected, the biblio is not saved, but the user is asked for a confirmations. +# # Revision 1.105 2004/09/23 16:15:37 tipaul # indenting diff # diff --git a/acqui.simple/addbiblio.pl b/acqui.simple/addbiblio.pl index 79d7a5318b..9065b475c9 100755 --- a/acqui.simple/addbiblio.pl +++ b/acqui.simple/addbiblio.pl @@ -381,17 +381,39 @@ if ($op eq "addbiblio") { $indicators{$ind_tag[$i]} = $indicator[$i]; } my $record = MARChtml2marc($dbh,\@tags,\@subfields,\@values,%indicators); -# MARC::Record built => now, record in DB - my $oldbibnum; - my $oldbibitemnum; - if ($is_a_modif) { - NEWmodbiblio($dbh,$record,$bibid,$frameworkcode); + # check for a duplicate + my ($duplicatebiblionumber,$duplicatebibid,$duplicatetitle) = FindDuplicate($record) if ($op eq "addbiblio") && (!$is_a_modif); + my $confirm_not_duplicate = $input->param('confirm_not_duplicate'); + # it is not a duplicate (determined either by Koha itself or by user checking it's not a duplicate) + if (!$duplicatebiblionumber or $confirm_not_duplicate) { + # MARC::Record built => now, record in DB + my $oldbibnum; + my $oldbibitemnum; + if ($is_a_modif) { + NEWmodbiblio($dbh,$record,$bibid,$frameworkcode); + } else { + ($bibid,$oldbibnum,$oldbibitemnum) = NEWnewbiblio($dbh,$record,$frameworkcode); + } + # now, redirect to additem page + print $input->redirect("additem.pl?bibid=$bibid&frameworkcode=$frameworkcode"); + exit; } else { - ($bibid,$oldbibnum,$oldbibitemnum) = NEWnewbiblio($dbh,$record,$frameworkcode); + # it may be a duplicate, warn the user and do nothing + build_tabs ($template, $record, $dbh,$encoding); + build_hidden_data; + $template->param( + oldbiblionumber => $oldbiblionumber, + bibid => $bibid, + oldbiblionumtagfield => $oldbiblionumtagfield, + oldbiblionumtagsubfield => $oldbiblionumtagsubfield, + oldbiblioitemnumtagfield => $oldbiblioitemnumtagfield, + oldbiblioitemnumtagsubfield => $oldbiblioitemnumtagsubfield, + oldbiblioitemnumber => $oldbiblioitemnumber, + duplicatebiblionumber => $duplicatebiblionumber, + duplicatebibid => $duplicatebibid, + duplicatetitle => $duplicatetitle, + ); } -# now, redirect to additem page - print $input->redirect("additem.pl?bibid=$bibid&frameworkcode=$frameworkcode"); - exit; #------------------------------------------------------------------------------------------------------------------------------ } elsif ($op eq "addfield") { #------------------------------------------------------------------------------------------------------------------------------ @@ -419,7 +441,6 @@ if ($op eq "addbiblio") { $start=$i if ($end>0 && $tags[$i] eq $addedfield); last if ($end>0 && $tags[$i] ne $addedfield); } - warn "ST : $addedfield => $start / $end"; # add an empty line in all arrays. This forces a new field in MARC::Record. splice(@tags,$end+1,0,''); splice(@subfields,$end+1,0,''); @@ -438,7 +459,6 @@ if ($op eq "addbiblio") { $indicators{$ind_tag[$i]} = $indicator[$i]; } my $record = MARChtml2marc($dbh,\@tags,\@subfields,\@values,%indicators); - warn "R=>".$record->as_formatted; build_tabs ($template, $record, $dbh,$encoding); build_hidden_data; $template->param( @@ -467,7 +487,8 @@ if ($op eq "addbiblio") { oldbiblionumtagsubfield => $oldbiblionumtagsubfield, oldbiblioitemnumtagfield => $oldbiblioitemnumtagfield, oldbiblioitemnumtagsubfield => $oldbiblioitemnumtagsubfield, - oldbiblioitemnumber => $oldbiblioitemnumber ); + oldbiblioitemnumber => $oldbiblioitemnumber, + ); } $template->param( frameworkcode => $frameworkcode, diff --git a/koha-tmpl/intranet-tmpl/default/en/acqui.simple/addbiblio.tmpl b/koha-tmpl/intranet-tmpl/default/en/acqui.simple/addbiblio.tmpl index 3e8e9a564f..13366d2299 100644 --- a/koha-tmpl/intranet-tmpl/default/en/acqui.simple/addbiblio.tmpl +++ b/koha-tmpl/intranet-tmpl/default/en/acqui.simple/addbiblio.tmpl @@ -51,6 +51,16 @@
+ +
+

Duplicate suspected with

+

You must either :

+ +
+

-- 2.39.2