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

(-)a/Koha/Biblio.pm (-1 / +160 lines)
Lines 1766-1771 sub get_marc_hostinfo_only { Link Here
1766
    return $hostinfo;
1766
    return $hostinfo;
1767
}
1767
}
1768
1768
1769
=head3 link_marc_host
1770
1771
=cut
1772
1773
sub link_marc_host {
1774
    my ( $self, $params ) = @_;
1775
1776
    my $host = Koha::Biblios->find( $params->{biblionumber} );
1777
    return unless $host;
1778
1779
    my $marcflavour = C4::Context->preference('marcflavour');
1780
    my $marc_host = $host->metadata->record;
1781
    my %sfd;
1782
    my $field;
1783
    my $host_field;
1784
1785
    if ( $marcflavour eq 'MARC21' ) {
1786
        # Author
1787
        if ( $field =
1788
            $marc_host->field('100') || $marc_host->field('110') || $marc_host->field('111') )
1789
        {
1790
            my $s = $field->as_string('ab');
1791
            if ($s) {
1792
                $sfd{a} = $s;
1793
            }
1794
        }
1795
        # Title
1796
        if ( $field = $marc_host->field('245') ) {
1797
            my $s = $field->as_string('ab');
1798
            if ($s) {
1799
                $sfd{t} = $s;
1800
            }
1801
        }
1802
        # Uniform title
1803
        if ( $field = $marc_host->field('240') ) {
1804
            my $s = $field->as_string('a');
1805
            if ($s) {
1806
                $sfd{s} = $s;
1807
            }
1808
        }
1809
        # Publication
1810
        if ( $field = $marc_host->field('260') ) {
1811
            my $s = $field->as_string('abc');
1812
            if ($s) {
1813
                $sfd{d} = $s;
1814
            }
1815
        }
1816
        # Edition
1817
        if ( $field = $marc_host->field('250') ) {
1818
            my $s = $field->as_string('ab');
1819
            if ($s) {
1820
                $sfd{b} = $s;
1821
            }
1822
        }
1823
        # ISSN
1824
        if ( $field = $marc_host->field('022') ) {
1825
            my $s = $field->as_string('a');
1826
            if ($s) {
1827
                $sfd{x} = $s;
1828
            }
1829
        }
1830
        # ISBN
1831
        if ( $field = $marc_host->field('020') ) {
1832
            my $s = $field->as_string('a');
1833
            if ($s) {
1834
                $sfd{z} = $s;
1835
            }
1836
        }
1837
        if ( C4::Context->preference('UseControlNumber') ) {
1838
            # Control number
1839
            if ( $field = $marc_host->field('001') ) {
1840
                $sfd{w} = $field->data(),;
1841
            }
1842
            # Control number identifier
1843
            if ( $field = $marc_host->field('003') ) {
1844
                $sfd{w} = '('.$field->data().')'.$sfd{w};
1845
            }
1846
        }
1847
        $host_field = MARC::Field->new( 773, '0', ' ', %sfd );
1848
    }
1849
    elsif ( $marcflavour eq 'UNIMARC' ) {
1850
1851
        #author
1852
        if ( $field =
1853
            $marc_host->field('700') || $marc_host->field('710') || $marc_host->field('720') )
1854
        {
1855
            my $s = $field->as_string('ab');
1856
            if ($s) {
1857
                $sfd{a} = $s;
1858
            }
1859
        }
1860
1861
        #title
1862
        if ( $field = $marc_host->field('200') ) {
1863
            my $s = $field->as_string('a');
1864
            if ($s) {
1865
                $sfd{t} = $s;
1866
            }
1867
        }
1868
1869
        #place of publicaton
1870
        if ( $field = $marc_host->field('210') ) {
1871
            my $s = $field->as_string('a');
1872
            if ($s) {
1873
                $sfd{c} = $s;
1874
            }
1875
        }
1876
1877
        #date of publication
1878
        if ( $field = $marc_host->field('210') ) {
1879
            my $s = $field->as_string('d');
1880
            if ($s) {
1881
                $sfd{d} = $s;
1882
            }
1883
        }
1884
1885
        #edition statement
1886
        if ( $field = $marc_host->field('205') ) {
1887
            my $s = $field->as_string();
1888
            if ($s) {
1889
                $sfd{e} = $s;
1890
            }
1891
        }
1892
1893
        #URL
1894
        if ( $field = $marc_host->field('856') ) {
1895
            my $s = $field->as_string('u');
1896
            if ($s) {
1897
                $sfd{u} = $s;
1898
            }
1899
        }
1900
1901
        #ISSN
1902
        if ( $field = $marc_host->field('011') ) {
1903
            my $s = $field->as_string('a');
1904
            if ($s) {
1905
                $sfd{x} = $s;
1906
            }
1907
        }
1908
1909
        #ISBN
1910
        if ( $field = $marc_host->field('010') ) {
1911
            my $s = $field->as_string('a');
1912
            if ($s) {
1913
                $sfd{y} = $s;
1914
            }
1915
        }
1916
        if ( $field = $marc_host->field('001') ) {
1917
            $sfd{0} = $field->data(),;
1918
        }
1919
        $host_field = MARC::Field->new( 461, '0', ' ', %sfd );
1920
    }
1921
1922
    my $marc_record = $self->metadata->record;
1923
    $marc_record->append_fields($host_field);
1924
1925
    C4::Biblio::ModBiblioMarc($marc_record, $self->biblionumber);
1926
    return $self;
1927
}
1928
1769
=head3 recalls
1929
=head3 recalls
1770
1930
1771
    my $recalls = $biblio->recalls;
1931
    my $recalls = $biblio->recalls;
1772
- 

Return to bug 29560