Lines 24-29
use C4::Biblio;
Link Here
|
24 |
use C4::Search; |
24 |
use C4::Search; |
25 |
use C4::AuthoritiesMarc::MARC21; |
25 |
use C4::AuthoritiesMarc::MARC21; |
26 |
use C4::AuthoritiesMarc::UNIMARC; |
26 |
use C4::AuthoritiesMarc::UNIMARC; |
|
|
27 |
use C4::AuthoritiesRameau; |
27 |
use C4::Charset; |
28 |
use C4::Charset; |
28 |
use C4::Log; |
29 |
use C4::Log; |
29 |
use Koha::Authority; |
30 |
use Koha::Authority; |
Lines 1446-1452
Then we should add some new parameter : bibliotargettag, authtargettag
Link Here
|
1446 |
=cut |
1447 |
=cut |
1447 |
|
1448 |
|
1448 |
sub merge { |
1449 |
sub merge { |
1449 |
my ($mergefrom,$MARCfrom,$mergeto,$MARCto) = @_; |
1450 |
my ($mergefrom,$MARCfrom,$mergeto,$MARCto, $biblionumber) = @_; |
1450 |
my ($counteditedbiblio,$countunmodifiedbiblio,$counterrors)=(0,0,0); |
1451 |
my ($counteditedbiblio,$countunmodifiedbiblio,$counterrors)=(0,0,0); |
1451 |
my $dbh=C4::Context->dbh; |
1452 |
my $dbh=C4::Context->dbh; |
1452 |
my $authtypecodefrom = GetAuthTypeCode($mergefrom); |
1453 |
my $authtypecodefrom = GetAuthTypeCode($mergefrom); |
Lines 1468-1501
sub merge {
Link Here
|
1468 |
@record_from = $MARCfrom->field($auth_tag_to_report_from)->subfields() if $MARCfrom->field($auth_tag_to_report_from); |
1469 |
@record_from = $MARCfrom->field($auth_tag_to_report_from)->subfields() if $MARCfrom->field($auth_tag_to_report_from); |
1469 |
|
1470 |
|
1470 |
my @reccache; |
1471 |
my @reccache; |
1471 |
# search all biblio tags using this authority. |
1472 |
if ($biblionumber) { |
1472 |
#Getting marcbiblios impacted by the change. |
1473 |
my $marcrecorddb = GetMarcBiblio($biblionumber); |
1473 |
#zebra connection |
|
|
1474 |
my $oConnection=C4::Context->Zconn("biblioserver",0); |
1475 |
# We used to use XML syntax here, but that no longer works. |
1476 |
# Thankfully, we don't need it. |
1477 |
my $query; |
1478 |
$query= "an=".$mergefrom; |
1479 |
my $oResult = $oConnection->search(new ZOOM::Query::CCL2RPN( $query, $oConnection )); |
1480 |
my $count = 0; |
1481 |
if ($oResult) { |
1482 |
$count=$oResult->size(); |
1483 |
} |
1484 |
my $z=0; |
1485 |
while ( $z<$count ) { |
1486 |
my $marcrecordzebra = C4::Search::new_record_from_zebra( |
1487 |
'biblioserver', |
1488 |
$oResult->record($z)->raw() |
1489 |
); |
1490 |
my ( $biblionumbertagfield, $biblionumbertagsubfield ) = &GetMarcFromKohaField( "biblio.biblionumber", '' ); |
1491 |
my $i = ($biblionumbertagfield < 10) |
1492 |
? $marcrecordzebra->field( $biblionumbertagfield )->data |
1493 |
: $marcrecordzebra->subfield( $biblionumbertagfield, $biblionumbertagsubfield ); |
1494 |
my $marcrecorddb = GetMarcBiblio($i); |
1495 |
push @reccache, $marcrecorddb; |
1474 |
push @reccache, $marcrecorddb; |
1496 |
$z++; |
1475 |
} else { |
|
|
1476 |
# search all biblio tags using this authority. |
1477 |
#Getting marcbiblios impacted by the change. |
1478 |
#zebra connection |
1479 |
my $oConnection=C4::Context->Zconn("biblioserver",0); |
1480 |
# We used to use XML syntax here, but that no longer works. |
1481 |
# Thankfully, we don't need it. |
1482 |
my $query; |
1483 |
$query= "an=".$mergefrom; |
1484 |
my $oResult = $oConnection->search(new ZOOM::Query::CCL2RPN( $query, $oConnection )); |
1485 |
my $count = 0; |
1486 |
if ($oResult) { |
1487 |
$count=$oResult->size(); |
1488 |
} |
1489 |
my $z=0; |
1490 |
while ( $z<$count ) { |
1491 |
my $marcrecordzebra = C4::Search::new_record_from_zebra( |
1492 |
'biblioserver', |
1493 |
$oResult->record($z)->raw() |
1494 |
); |
1495 |
my ( $biblionumbertagfield, $biblionumbertagsubfield ) = &GetMarcFromKohaField( "biblio.biblionumber", '' ); |
1496 |
my $i = ($biblionumbertagfield < 10) |
1497 |
? $marcrecordzebra->field( $biblionumbertagfield )->data |
1498 |
: $marcrecordzebra->subfield( $biblionumbertagfield, $biblionumbertagsubfield ); |
1499 |
my $marcrecorddb = GetMarcBiblio($i); |
1500 |
push @reccache, $marcrecorddb; |
1501 |
$z++; |
1502 |
} |
1503 |
$oResult->destroy(); |
1497 |
} |
1504 |
} |
1498 |
$oResult->destroy(); |
|
|
1499 |
#warn scalar(@reccache)." biblios to update"; |
1505 |
#warn scalar(@reccache)." biblios to update"; |
1500 |
# Get All candidate Tags for the change |
1506 |
# Get All candidate Tags for the change |
1501 |
# (This will reduce the search scope in marc records). |
1507 |
# (This will reduce the search scope in marc records). |
Lines 1515-1524
sub merge {
Link Here
|
1515 |
# BulkEdit marc records |
1521 |
# BulkEdit marc records |
1516 |
# May be used as a template for a bulkedit field |
1522 |
# May be used as a template for a bulkedit field |
1517 |
foreach my $marcrecord(@reccache){ |
1523 |
foreach my $marcrecord(@reccache){ |
1518 |
my $update; |
1524 |
my $update; |
1519 |
foreach my $tagfield (@tags_using_authtype){ |
1525 |
foreach my $tagfield (@tags_using_authtype){ |
1520 |
# warn "tagfield : $tagfield "; |
1526 |
# warn "tagfield : $tagfield "; |
1521 |
foreach my $field ($marcrecord->field($tagfield)){ |
1527 |
foreach my $field ($marcrecord->field($tagfield)){ |
|
|
1528 |
|
1529 |
# If Rameau authorities are enabled and there are multiple $9's in the field, skip it. |
1530 |
my @internallinks = $field->subfield("9"); |
1531 |
next if (C4::Context->preference('useRameau') && scalar(@internallinks) > 1); |
1532 |
|
1522 |
# biblio is linked to authority with $9 subfield containing authid |
1533 |
# biblio is linked to authority with $9 subfield containing authid |
1523 |
my $auth_number=$field->subfield("9"); |
1534 |
my $auth_number=$field->subfield("9"); |
1524 |
my $tag=$field->tag(); |
1535 |
my $tag=$field->tag(); |
Lines 1553-1558
sub merge {
Link Here
|
1553 |
warn "pas de numéro de notice bibliographique dans : ".$marcrecord->as_formatted; |
1564 |
warn "pas de numéro de notice bibliographique dans : ".$marcrecord->as_formatted; |
1554 |
next; |
1565 |
next; |
1555 |
} |
1566 |
} |
|
|
1567 |
if (C4::Context->preference('useRameau')) { |
1568 |
my $rameauUpdate = rameauProcessing($marcrecord); |
1569 |
$update = 1 if ($rameauUpdate == 1); |
1570 |
} |
1556 |
if ($update==1){ |
1571 |
if ($update==1){ |
1557 |
&ModBiblio($marcrecord,$biblionumber,GetFrameworkCode($biblionumber)) ; |
1572 |
&ModBiblio($marcrecord,$biblionumber,GetFrameworkCode($biblionumber)) ; |
1558 |
$counteditedbiblio++; |
1573 |
$counteditedbiblio++; |