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

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

Return to bug 29560