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

(-)a/C4/Serials.pm (-21 / +15 lines)
Lines 1481-1489 sub ItemizeSerials { Link Here
1481
    my $fwk = GetFrameworkCode( $data->{'biblionumber'} );
1481
    my $fwk = GetFrameworkCode( $data->{'biblionumber'} );
1482
    if ( $info->{barcode} ) {
1482
    if ( $info->{barcode} ) {
1483
        my @errors;
1483
        my @errors;
1484
        my $exists = itemdata( $info->{'barcode'} );
1484
        if ( is_barcode_in_use( $info->{barcode} ) ) {
1485
        push @errors, "barcode_not_unique" if ($exists);
1485
            push @errors, 'barcode_not_unique';
1486
        unless ($exists) {
1486
        } else {
1487
            my $marcrecord = MARC::Record->new();
1487
            my $marcrecord = MARC::Record->new();
1488
            my ( $tag, $subfield ) = GetMarcFromKohaField( "items.barcode", $fwk );
1488
            my ( $tag, $subfield ) = GetMarcFromKohaField( "items.barcode", $fwk );
1489
            my $newField = MARC::Field->new( "$tag", '', '', "$subfield" => $info->{barcode} );
1489
            my $newField = MARC::Field->new( "$tag", '', '', "$subfield" => $info->{barcode} );
Lines 2338-2366 sub GetNextDate(@) { Link Here
2338
    return "$resultdate";
2338
    return "$resultdate";
2339
}
2339
}
2340
2340
2341
=head2 itemdata
2341
=head2 is_barcode_in_use
2342
2343
  $item = itemdata($barcode);
2344
2342
2345
Looks up the item with the given barcode, and returns a
2343
Returns number of occurence of the barcode in the items table
2346
reference-to-hash containing information about that item. The keys of
2344
Can be used as a boolean test of whether the barcode has
2347
the hash are the fields from the C<items> and C<biblioitems> tables in
2345
been deployed as yet
2348
the Koha database.
2349
2346
2350
=cut
2347
=cut
2351
2348
2352
#'
2349
sub is_barcode_in_use {
2353
sub itemdata {
2350
    my $barcode = shift;
2354
    my ($barcode) = @_;
2355
    my $dbh       = C4::Context->dbh;
2351
    my $dbh       = C4::Context->dbh;
2356
    my $sth       = $dbh->prepare(
2352
    my $occurences = $dbh->selectall_arrayref(
2357
        "Select * from items LEFT JOIN biblioitems ON items.biblioitemnumber=biblioitems.biblioitemnumber 
2353
        'SELECT itemnumber from items where barcode = ?',
2358
        WHERE barcode=?"
2354
        {}, $barcode
2355
2359
    );
2356
    );
2360
    $sth->execute($barcode);
2357
2361
    my $data = $sth->fetchrow_hashref;
2358
    return @{$occurences};
2362
    $sth->finish;
2363
    return ($data);
2364
}
2359
}
2365
2360
2366
1;
2361
1;
2367
- 

Return to bug 5932