[Koha-patches] [PATCH] Bug 5961: follow-up : use matchingrules selected in manage-stage-import instead of FindDuplicate
Julian Maurice
julian.maurice at biblibre.com
Tue Mar 29 14:12:06 CEST 2011
From: Paul Poulain <paul.poulain at biblibre.com>
Now, bulk importing the iso2709 result in adding biblio or connecting to an existing one
---
acqui/addorderiso2709.pl | 132 ++++++++++----------
.../prog/en/modules/acqui/addorderiso2709.tmpl | 11 ++-
2 files changed, 77 insertions(+), 66 deletions(-)
diff --git a/acqui/addorderiso2709.pl b/acqui/addorderiso2709.pl
index 78b9147..a77b111 100755
--- a/acqui/addorderiso2709.pl
+++ b/acqui/addorderiso2709.pl
@@ -4,7 +4,7 @@
#the script first displays a list of import batches, then when a batch is selected displays all the biblios in it.
#The user can then pick which biblios he wants to order
-# Copyright 2008 - 2010 BibLibre SARL
+# Copyright 2008 - 2011 BibLibre SARL
#
# This file is part of Koha.
#
@@ -124,11 +124,13 @@ if ($op eq ""){
my $import_batch_id = $cgiparams->{'import_batch_id'};
my $biblios = GetImportBibliosRange($import_batch_id);
for my $biblio (@$biblios){
- # 1st insert the biblio
+ # 1st insert the biblio, or find it through matcher
my ( $marcblob, $encoding ) = GetImportRecordMarc( $biblio->{'import_record_id'} );
my $marcrecord = MARC::Record->new_from_usmarc($marcblob) || die "couldn't translate marc information";
- my ( $duplicatetitle, $biblionumber );
- if ( !( ( $biblionumber, $duplicatetitle ) = FindDuplicate($marcrecord) ) ) {
+ my $match = GetImportRecordMatches( $biblio->{'import_record_id'}, 1 );
+ my $biblionumber=$#$match > -1?$match->[0]->{'biblionumber'}:0;
+
+ unless ( $biblionumber ) {
# add the biblio
my $bibitemnum;
@@ -148,66 +150,68 @@ if ($op eq ""){
if (C4::Context->preference("BiblioAddsAuthorities")){
my ($countlinked,$countcreated)=BiblioAddAuthorities($marcrecord, $cgiparams->{'frameworkcode'});
}
- # 3rd add order
- my $patron = C4::Members->GetMember(borrowernumber => $loggedinuser);
- my $branch = C4::Branch->GetBranchDetail($patron->{branchcode});
- my ($invoice);
- # get quantity in the MARC record (1 if none)
- my $quantity = GetMarcQuantity($marcrecord, C4::Context->preference('marcflavour')) || 1;
- my %orderinfo = ("biblionumber", $biblionumber,
- "basketno", $cgiparams->{'basketno'},
- "quantity", $quantity,
- "branchcode", $branch,
- "booksellerinvoicenumber", $invoice,
- "budget_id", $budget_id,
- "uncertainprice", 1,
- "sort1", $cgiparams->{'sort1'},
- "sort2", $cgiparams->{'sort2'},
- );
- # get the price if there is one.
- # filter by storing only the 1st number
- # we suppose the currency is correct, as we have no possibilities to get it.
- my $price= GetMarcPrice($marcrecord, C4::Context->preference('marcflavour'));
- if ($price){
- $price = $num->unformat_number($price);
- }
- if ($price){
- $orderinfo{'listprice'} = $price;
- eval "use C4::Acquisition qw/GetBasket/;";
- eval "use C4::Bookseller qw/GetBookSellerFromId/;";
- my $basket = GetBasket( $orderinfo{basketno} );
- my $bookseller = GetBookSellerFromId( $basket->{booksellerid} );
- my $gst = $bookseller->{gstrate} || C4::Context->preference("gist") || 0;
- $orderinfo{'unitprice'} = $orderinfo{listprice} - ( $orderinfo{listprice} * ( $bookseller->{discount} / 100 ) );
- $orderinfo{'ecost'} = $orderinfo{unitprice};
- } else {
- $orderinfo{'listprice'} = 0;
- }
- $orderinfo{'rrp'} = $orderinfo{'listprice'};
+ } else {
+ SetImportRecordStatus( $biblio->{'import_record_id'}, 'imported' );
+ }
+ # 3rd add order
+ my $patron = C4::Members->GetMember( borrowernumber => $loggedinuser );
+ my $branch = C4::Branch->GetBranchDetail( $patron->{branchcode} );
+ my ($invoice);
+ # get quantity in the MARC record (1 if none)
+ my $quantity = GetMarcQuantity($marcrecord, C4::Context->preference('marcflavour')) || 1;
+ my %orderinfo = (
+ "biblionumber", $biblionumber, "basketno", $cgiparams->{'basketno'},
+ "quantity", $quantity, "branchcode", $branch,
+ "booksellerinvoicenumber", $invoice,
+ "budget_id", $budget_id, "uncertainprice", 1,
+ "sort1", $cgiparams->{'sort1'},"sort2", $cgiparams->{'sort2'},
+ "notes", $cgiparams->{'notes'}, "budget_id", $cgiparams->{'budget_id'},
+ );
+ # get the price if there is one.
+ # filter by storing only the 1st number
+ # we suppose the currency is correct, as we have no possibilities to get it.
+ my $price= GetMarcPrice($marcrecord, C4::Context->preference('marcflavour'));
+ if ($price){
+ $price = $num->unformat_number($price);
+ }
+ if ($price){
+ $orderinfo{'listprice'} = $price;
+ eval "use C4::Acquisition qw/GetBasket/;";
+ eval "use C4::Bookseller qw/GetBookSellerFromId/;";
+ my $basket = GetBasket( $orderinfo{basketno} );
+ my $bookseller = GetBookSellerFromId( $basket->{booksellerid} );
+ my $gst = $bookseller->{gstrate} || C4::Context->preference("gist") || 0;
+ $orderinfo{'unitprice'} = $orderinfo{listprice} - ( $orderinfo{listprice} * ( $bookseller->{discount} / 100 ) );
+ $orderinfo{'ecost'} = $orderinfo{unitprice};
+ } else {
+ $orderinfo{'listprice'} = 0;
+ }
+ $orderinfo{'rrp'} = $orderinfo{'listprice'};
- # remove uncertainprice flag if we have found a price in the MARC record
- $orderinfo{uncertainprice} = 0 if $orderinfo{listprice};
- my $basketno;
- ( $basketno, $ordernumber ) = NewOrder(\%orderinfo);
+ # remove uncertainprice flag if we have found a price in the MARC record
+ $orderinfo{uncertainprice} = 0 if $orderinfo{listprice};
+ my $basketno;
+ ( $basketno, $ordernumber ) = NewOrder( \%orderinfo );
- # 4th, add items if applicable
- # parse the item sent by the form, and create an item just for the import_record_id we are dealing with
- # this is not optimised, but it's working !
- if (C4::Context->preference('AcqCreateItem') eq 'ordering') {
- my @tags = $input->param('tag');
- my @subfields = $input->param('subfield');
- my @field_values = $input->param('field_value');
- my @serials = $input->param('serial');
- my @ind_tag = $input->param('ind_tag');
- my @indicator = $input->param('indicator');
- my $item;
- push @{ $item->{tags} }, $tags[0];
- push @{ $item->{subfields} }, $subfields[0];
- push @{ $item->{field_values} }, $field_values[0];
- push @{ $item->{ind_tag} }, $ind_tag[0];
- push @{ $item->{indicator} }, $indicator[0];
- my $xml = TransformHtmlToXml( \@tags, \@subfields, \@field_values, \@ind_tag, \@indicator );
- my $record = MARC::Record::new_from_xml( $xml, 'UTF-8' );
+ # 4th, add items if applicable
+ # parse the item sent by the form, and create an item just for the import_record_id we are dealing with
+ # this is not optimised, but it's working !
+ if ( C4::Context->preference('AcqCreateItem') eq 'ordering' ) {
+ my @tags = $input->param('tag');
+ my @subfields = $input->param('subfield');
+ my @field_values = $input->param('field_value');
+ my @serials = $input->param('serial');
+ my @ind_tag = $input->param('ind_tag');
+ my @indicator = $input->param('indicator');
+ my $item;
+ push @{ $item->{tags} }, $tags[0];
+ push @{ $item->{subfields} }, $subfields[0];
+ push @{ $item->{field_values} }, $field_values[0];
+ push @{ $item->{ind_tag} }, $ind_tag[0];
+ push @{ $item->{indicator} }, $indicator[0];
+ my $xml = TransformHtmlToXml( \@tags, \@subfields, \@field_values, \@ind_tag, \@indicator );
+ my $record = MARC::Record::new_from_xml( $xml, 'UTF-8' );
+ for (my $qtyloop=1;$qtyloop <=$quantity;$qtyloop++) {
my ( $biblionumber, $bibitemnum, $itemnumber ) = AddItemFromMarc( $record, $biblionumber );
NewOrderItem( $itemnumber, $ordernumber );
}
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tmpl
index 03077d3..7365030 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tmpl
@@ -38,6 +38,7 @@
<table>
<tr>
<th>Citation</th>
+ <th>Match?</th>
<th>Order</th>
</tr>
<!-- TMPL_LOOP name="biblio_list" -->
@@ -46,9 +47,15 @@
<!-- TMPL_VAR name="citation"-->
</td>
- <td><a href="/cgi-bin/koha/acqui/neworderempty.pl?booksellerid=<!--TMPL_VAR name="booksellerid" -->&basketno=<!-- TMPL_VAR name="basketno" -->&booksellerid=<!-- TMPL_VAR name="booksellerid" -->&breedingid=<!-- TMPL_VAR name="import_record_id" -->&import_batch_id=<!-- TMPL_VAR name="import_batch_id" -->">Add order</a></td>
+ <td><!-- TMPL_VAR name="overlay_status"--></td>
+ <td><a href="/cgi-bin/koha/acqui/neworderempty.pl?booksellerid=<!--TMPL_VAR name="booksellerid" -->&basketno=<!-- TMPL_VAR name="basketno" -->&booksellerid=<!-- TMPL_VAR name="booksellerid" -->&breedingid=<!-- TMPL_VAR name="import_record_id" -->&import_batch_id=<!-- TMPL_VAR name="import_batch_id" -->&biblionumber=<!-- TMPL_VAR name="match_biblionumber" -->">Add order</a></td>
</tr>
- <!-- /TMPL_LOOP -->
+ <!-- TMPL_IF name="match_biblionumber" -->
+ <tr>
+ <td class="highlight" colspan="3"> Matches biblio <!-- TMPL_VAR name="match_biblionumber" --> (score = <!-- TMPL_VAR name="match_score" -->): <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=<!-- TMPL_VAR name="match_biblionumber" -->"><!-- TMPL_VAR name="match_citation" --></a></td>
+ </tr>
+ <!-- /TMPL_IF -->
+ <!-- /TMPL_LOOP -->
</table>
</form>
</div>
--
1.7.4.1
More information about the Koha-patches
mailing list