X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=C4%2FSerials.pm;h=1f8c170445535d9a53f998d6aee93cf815ede7f0;hb=7c09c12e6a9fc0576fc807952fbae5625a4b9d5d;hp=5e2fa2235ffb3fdd1b6b1d18c754e7c1a1b9d59b;hpb=1144c92ffc040438df1229f216453b1987c031f0;p=koha_fer diff --git a/C4/Serials.pm b/C4/Serials.pm index 5e2fa2235f..1f8c170445 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -125,10 +125,11 @@ sub GetLateIssues { LEFT JOIN biblio ON biblio.biblionumber = subscription.biblionumber LEFT JOIN aqbooksellers ON subscription.aqbooksellerid = aqbooksellers.id WHERE ((planneddate < now() AND serial.STATUS =1) OR serial.STATUS = 3) - AND subscription.aqbooksellerid=$supplierid + AND subscription.aqbooksellerid=? ORDER BY title |; $sth = $dbh->prepare($query); + $sth->execute($supplierid); } else { my $query = qq| SELECT name,title,planneddate,serialseq,serial.subscriptionid @@ -140,8 +141,8 @@ sub GetLateIssues { ORDER BY title |; $sth = $dbh->prepare($query); + $sth->execute; } - $sth->execute; my @issuelist; my $last_title; my $odd = 0; @@ -440,7 +441,6 @@ sub PrepareSerialsData { foreach my $key ( sort { $b cmp $a } keys %tmpresults ) { push @res, $tmpresults{$key}; } - $res[0]->{'first'} = 1; return \@res; } @@ -1480,9 +1480,9 @@ sub ItemizeSerials { my $fwk = GetFrameworkCode( $data->{'biblionumber'} ); if ( $info->{barcode} ) { my @errors; - my $exists = itemdata( $info->{'barcode'} ); - push @errors, "barcode_not_unique" if ($exists); - unless ($exists) { + if ( is_barcode_in_use( $info->{barcode} ) ) { + push @errors, 'barcode_not_unique'; + } else { my $marcrecord = MARC::Record->new(); my ( $tag, $subfield ) = GetMarcFromKohaField( "items.barcode", $fwk ); my $newField = MARC::Field->new( "$tag", '', '', "$subfield" => $info->{barcode} ); @@ -2337,29 +2337,24 @@ sub GetNextDate(@) { return "$resultdate"; } -=head2 itemdata - - $item = itemdata($barcode); +=head2 is_barcode_in_use -Looks up the item with the given barcode, and returns a -reference-to-hash containing information about that item. The keys of -the hash are the fields from the C and C tables in -the Koha database. +Returns number of occurence of the barcode in the items table +Can be used as a boolean test of whether the barcode has +been deployed as yet =cut -#' -sub itemdata { - my ($barcode) = @_; +sub is_barcode_in_use { + my $barcode = shift; my $dbh = C4::Context->dbh; - my $sth = $dbh->prepare( - "Select * from items LEFT JOIN biblioitems ON items.biblioitemnumber=biblioitems.biblioitemnumber - WHERE barcode=?" + my $occurences = $dbh->selectall_arrayref( + 'SELECT itemnumber from items where barcode = ?', + {}, $barcode + ); - $sth->execute($barcode); - my $data = $sth->fetchrow_hashref; - $sth->finish; - return ($data); + + return @{$occurences}; } 1;