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

(-)a/Koha/Biblio.pm (-1 / +162 lines)
Lines 1197-1202 sub get_marc_host { Link Here
1197
    }
1197
    }
1198
}
1198
}
1199
1199
1200
=head3 link_marc_host
1201
1202
=cut
1203
1204
sub link_marc_host {
1205
    my ( $self, $params ) = @_;
1206
1207
    my $host = Koha::Biblios->find( $params->{biblionumber} );
1208
    return unless $host;
1209
1210
    my $marcflavour = C4::Context->preference('marcflavour');
1211
    my $marc_host = $host->metadata->record;
1212
    my %sfd;
1213
    my $field;
1214
    my $host_field;
1215
1216
    if ( $marcflavour eq 'MARC21' ) {
1217
        # Author
1218
        if ( $field =
1219
            $marc_host->field('100') || $marc_host->field('110') || $marc_host->field('111') )
1220
        {
1221
            my $s = $field->as_string('ab');
1222
            if ($s) {
1223
                $sfd{a} = $s;
1224
            }
1225
        }
1226
        # Title
1227
        if ( $field = $marc_host->field('245') ) {
1228
            my $s = $field->as_string('ab');
1229
            if ($s) {
1230
                $sfd{t} = $s;
1231
            }
1232
        }
1233
        # Uniform title
1234
        if ( $field = $marc_host->field('240') ) {
1235
            my $s = $field->as_string('a');
1236
            if ($s) {
1237
                $sfd{s} = $s;
1238
            }
1239
        }
1240
        # Publication
1241
        if ( $field = $marc_host->field('260') ) {
1242
            my $s = $field->as_string('abc');
1243
            if ($s) {
1244
                $sfd{d} = $s;
1245
            }
1246
        }
1247
        # Edition
1248
        if ( $field = $marc_host->field('250') ) {
1249
            my $s = $field->as_string('ab');
1250
            if ($s) {
1251
                $sfd{b} = $s;
1252
            }
1253
        }
1254
        # ISSN
1255
        if ( $field = $marc_host->field('022') ) {
1256
            my $s = $field->as_string('a');
1257
            if ($s) {
1258
                $sfd{x} = $s;
1259
            }
1260
        }
1261
        # ISBN
1262
        if ( $field = $marc_host->field('020') ) {
1263
            my $s = $field->as_string('a');
1264
            if ($s) {
1265
                $sfd{z} = $s;
1266
            }
1267
        }
1268
        if ( C4::Context->preference('UseControlNumber') ) {
1269
            # Control number
1270
            if ( $field = $marc_host->field('001') ) {
1271
                $sfd{w} = $field->data(),;
1272
            }
1273
            # Control number identifier
1274
            if ( $field = $marc_host->field('003') ) {
1275
                $sfd{w} = '('.$field->data().')'.$sfd{w};
1276
            }
1277
        }
1278
        $host_field = MARC::Field->new( 773, '0', ' ', %sfd );
1279
        return $host_field;
1280
    }
1281
    elsif ( $marcflavour eq 'UNIMARC' ) {
1282
1283
        #author
1284
        if ( $field =
1285
            $marc_host->field('700') || $marc_host->field('710') || $marc_host->field('720') )
1286
        {
1287
            my $s = $field->as_string('ab');
1288
            if ($s) {
1289
                $sfd{a} = $s;
1290
            }
1291
        }
1292
1293
        #title
1294
        if ( $field = $marc_host->field('200') ) {
1295
            my $s = $field->as_string('a');
1296
            if ($s) {
1297
                $sfd{t} = $s;
1298
            }
1299
        }
1300
1301
        #place of publicaton
1302
        if ( $field = $marc_host->field('210') ) {
1303
            my $s = $field->as_string('a');
1304
            if ($s) {
1305
                $sfd{c} = $s;
1306
            }
1307
        }
1308
1309
        #date of publication
1310
        if ( $field = $marc_host->field('210') ) {
1311
            my $s = $field->as_string('d');
1312
            if ($s) {
1313
                $sfd{d} = $s;
1314
            }
1315
        }
1316
1317
        #edition statement
1318
        if ( $field = $marc_host->field('205') ) {
1319
            my $s = $field->as_string();
1320
            if ($s) {
1321
                $sfd{e} = $s;
1322
            }
1323
        }
1324
1325
        #URL
1326
        if ( $field = $marc_host->field('856') ) {
1327
            my $s = $field->as_string('u');
1328
            if ($s) {
1329
                $sfd{u} = $s;
1330
            }
1331
        }
1332
1333
        #ISSN
1334
        if ( $field = $marc_host->field('011') ) {
1335
            my $s = $field->as_string('a');
1336
            if ($s) {
1337
                $sfd{x} = $s;
1338
            }
1339
        }
1340
1341
        #ISBN
1342
        if ( $field = $marc_host->field('010') ) {
1343
            my $s = $field->as_string('a');
1344
            if ($s) {
1345
                $sfd{y} = $s;
1346
            }
1347
        }
1348
        if ( $field = $marc_host->field('001') ) {
1349
            $sfd{0} = $field->data(),;
1350
        }
1351
        $host_field = MARC::Field->new( 461, '0', ' ', %sfd );
1352
        return $host_field;
1353
    }
1354
1355
    my $marc_record = $self->metadata->record;
1356
    $marc_record->append_fields($host_field);
1357
1358
    C4::Biblio::ModBiblioMarc($marc_record, $self->biblionumber);
1359
    return $self;
1360
}
1361
1200
=head3 recalls
1362
=head3 recalls
1201
1363
1202
    my $recalls = $biblio->recalls;
1364
    my $recalls = $biblio->recalls;
1203
- 

Return to bug 29560