View | Details | Raw Unified | Return to bug 11175
Collapse All | Expand All

(-)a/Koha/Biblio.pm (-4 / +6 lines)
Lines 519-540 sub get_components_query { Link Here
519
        my $pf001 = $marc->field('001') || undef;
519
        my $pf001 = $marc->field('001') || undef;
520
520
521
        if ( defined($pf001) ) {
521
        if ( defined($pf001) ) {
522
            $searchstr = "(";
522
            my $pf003 = $marc->field('003') || undef;
523
            my $pf003 = $marc->field('003') || undef;
523
524
524
            if ( !defined($pf003) ) {
525
            if ( !defined($pf003) ) {
525
                # search for 773$w='Host001'
526
                # search for 773$w='Host001'
526
                $searchstr = "rcn:" . $pf001->data();
527
                $searchstr .= "rcn:" . $pf001->data();
527
            }
528
            }
528
            else {
529
            else {
529
                $searchstr  = "(";
530
                $searchstr .= "(";
530
                # search for (773$w='Host001' and 003='Host003') or 773$w='Host003 Host001')
531
                # search for (773$w='Host001' and 003='Host003') or 773$w='(Host003)Host001'
531
                $searchstr .= "(rcn:" . $pf001->data() . " AND cni:" . $pf003->data() . ")";
532
                $searchstr .= "(rcn:" . $pf001->data() . " AND cni:" . $pf003->data() . ")";
532
                $searchstr .= " OR rcn:" . $pf003->data() . " " . $pf001->data();
533
                $searchstr .= " OR rcn:\"" . $pf003->data() . " " . $pf001->data() . "\"";
533
                $searchstr .= ")";
534
                $searchstr .= ")";
534
            }
535
            }
535
536
536
            # limit to monograph and serial component part records
537
            # limit to monograph and serial component part records
537
            $searchstr .= " AND (bib-level:a OR bib-level:b)";
538
            $searchstr .= " AND (bib-level:a OR bib-level:b)";
539
            $searchstr .= ")";
538
        }
540
        }
539
    }
541
    }
540
    else {
542
    else {
(-)a/t/db_dependent/Koha/Biblio.t (-3 / +2 lines)
Lines 558-571 subtest 'get_components_query' => sub { Link Here
558
    C4::Biblio::ModBiblio( $record, $biblio->biblionumber );
558
    C4::Biblio::ModBiblio( $record, $biblio->biblionumber );
559
    $biblio = Koha::Biblios->find( $biblio->biblionumber);
559
    $biblio = Koha::Biblios->find( $biblio->biblionumber);
560
560
561
    is($biblio->get_components_query, "rcn:$biblionumber AND (bib-level:a OR bib-level:b)", "UseControlNumber enabled without MarcOrgCode");
561
    is($biblio->get_components_query, "(rcn:$biblionumber AND (bib-level:a OR bib-level:b))", "UseControlNumber enabled without MarcOrgCode");
562
562
563
    my $marc_003_field = MARC::Field->new('003', 'OSt');
563
    my $marc_003_field = MARC::Field->new('003', 'OSt');
564
    $record->append_fields($marc_003_field);
564
    $record->append_fields($marc_003_field);
565
    C4::Biblio::ModBiblio( $record, $biblio->biblionumber );
565
    C4::Biblio::ModBiblio( $record, $biblio->biblionumber );
566
    $biblio = Koha::Biblios->find( $biblio->biblionumber);
566
    $biblio = Koha::Biblios->find( $biblio->biblionumber);
567
567
568
    is($biblio->get_components_query, "((rcn:$biblionumber AND cni:OSt) OR rcn:OSt $biblionumber) AND (bib-level:a OR bib-level:b)", "UseControlNumber enabled with MarcOrgCode");
568
    is($biblio->get_components_query, "(((rcn:$biblionumber AND cni:OSt) OR rcn:\"OSt $biblionumber\") AND (bib-level:a OR bib-level:b))", "UseControlNumber enabled with MarcOrgCode");
569
};
569
};
570
570
571
subtest 'orders() and active_orders() tests' => sub {
571
subtest 'orders() and active_orders() tests' => sub {
572
- 

Return to bug 11175