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

(-)a/Koha/Biblio.pm (-1 / +162 lines)
Lines 1163-1168 sub get_marc_host { Link Here
1163
    }
1163
    }
1164
}
1164
}
1165
1165
1166
=head3 link_marc_host
1167
1168
=cut
1169
1170
sub link_marc_host {
1171
    my ( $self, $params ) = @_;
1172
1173
    my $host = Koha::Biblios->find( $params->{biblionumber} );
1174
    return unless $host;
1175
1176
    my $marcflavour = C4::Context->preference('marcflavour');
1177
    my $marc_host = $host->metadata->record;
1178
    my %sfd;
1179
    my $field;
1180
    my $host_field;
1181
1182
    if ( $marcflavour eq 'MARC21' ) {
1183
        # Author
1184
        if ( $field =
1185
            $marc_host->field('100') || $marc_host->field('110') || $marc_host->field('111') )
1186
        {
1187
            my $s = $field->as_string('ab');
1188
            if ($s) {
1189
                $sfd{a} = $s;
1190
            }
1191
        }
1192
        # Title
1193
        if ( $field = $marc_host->field('245') ) {
1194
            my $s = $field->as_string('ab');
1195
            if ($s) {
1196
                $sfd{t} = $s;
1197
            }
1198
        }
1199
        # Uniform title
1200
        if ( $field = $marc_host->field('240') ) {
1201
            my $s = $field->as_string('a');
1202
            if ($s) {
1203
                $sfd{s} = $s;
1204
            }
1205
        }
1206
        # Publication
1207
        if ( $field = $marc_host->field('260') ) {
1208
            my $s = $field->as_string('abc');
1209
            if ($s) {
1210
                $sfd{d} = $s;
1211
            }
1212
        }
1213
        # Edition
1214
        if ( $field = $marc_host->field('250') ) {
1215
            my $s = $field->as_string('ab');
1216
            if ($s) {
1217
                $sfd{b} = $s;
1218
            }
1219
        }
1220
        # ISSN
1221
        if ( $field = $marc_host->field('022') ) {
1222
            my $s = $field->as_string('a');
1223
            if ($s) {
1224
                $sfd{x} = $s;
1225
            }
1226
        }
1227
        # ISBN
1228
        if ( $field = $marc_host->field('020') ) {
1229
            my $s = $field->as_string('a');
1230
            if ($s) {
1231
                $sfd{z} = $s;
1232
            }
1233
        }
1234
        if ( C4::Context->preference('UseControlNumber') ) {
1235
            # Control number
1236
            if ( $field = $marc_host->field('001') ) {
1237
                $sfd{w} = $field->data(),;
1238
            }
1239
            # Control number identifier
1240
            if ( $field = $marc_host->field('003') ) {
1241
                $sfd{w} = '('.$field->data().')'.$sfd{w};
1242
            }
1243
        }
1244
        $host_field = MARC::Field->new( 773, '0', ' ', %sfd );
1245
        return $host_field;
1246
    }
1247
    elsif ( $marcflavour eq 'UNIMARC' ) {
1248
1249
        #author
1250
        if ( $field =
1251
            $marc_host->field('700') || $marc_host->field('710') || $marc_host->field('720') )
1252
        {
1253
            my $s = $field->as_string('ab');
1254
            if ($s) {
1255
                $sfd{a} = $s;
1256
            }
1257
        }
1258
1259
        #title
1260
        if ( $field = $marc_host->field('200') ) {
1261
            my $s = $field->as_string('a');
1262
            if ($s) {
1263
                $sfd{t} = $s;
1264
            }
1265
        }
1266
1267
        #place of publicaton
1268
        if ( $field = $marc_host->field('210') ) {
1269
            my $s = $field->as_string('a');
1270
            if ($s) {
1271
                $sfd{c} = $s;
1272
            }
1273
        }
1274
1275
        #date of publication
1276
        if ( $field = $marc_host->field('210') ) {
1277
            my $s = $field->as_string('d');
1278
            if ($s) {
1279
                $sfd{d} = $s;
1280
            }
1281
        }
1282
1283
        #edition statement
1284
        if ( $field = $marc_host->field('205') ) {
1285
            my $s = $field->as_string();
1286
            if ($s) {
1287
                $sfd{e} = $s;
1288
            }
1289
        }
1290
1291
        #URL
1292
        if ( $field = $marc_host->field('856') ) {
1293
            my $s = $field->as_string('u');
1294
            if ($s) {
1295
                $sfd{u} = $s;
1296
            }
1297
        }
1298
1299
        #ISSN
1300
        if ( $field = $marc_host->field('011') ) {
1301
            my $s = $field->as_string('a');
1302
            if ($s) {
1303
                $sfd{x} = $s;
1304
            }
1305
        }
1306
1307
        #ISBN
1308
        if ( $field = $marc_host->field('010') ) {
1309
            my $s = $field->as_string('a');
1310
            if ($s) {
1311
                $sfd{y} = $s;
1312
            }
1313
        }
1314
        if ( $field = $marc_host->field('001') ) {
1315
            $sfd{0} = $field->data(),;
1316
        }
1317
        $host_field = MARC::Field->new( 461, '0', ' ', %sfd );
1318
        return $host_field;
1319
    }
1320
1321
    my $marc_record = $self->metadata->record;
1322
    $marc_record->append_fields($host_field);
1323
1324
    C4::Biblio::ModBiblioMarc($marc_record, $self->biblionumber);
1325
    return $self;
1326
}
1327
1166
=head3 recalls
1328
=head3 recalls
1167
1329
1168
    my $recalls = $biblio->recalls;
1330
    my $recalls = $biblio->recalls;
1169
- 

Return to bug 29560