X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=C4%2FSerials.pm;h=147118498ded9384dd553531da9ba14f083ac58e;hb=d57da73c2f51d837cb7557d7e8ca368cd74fe5c4;hp=5e2fa2235ffb3fdd1b6b1d18c754e7c1a1b9d59b;hpb=2a3f7c141798121a75fc9ee670af0fdde431d9c2;p=srvgit diff --git a/C4/Serials.pm b/C4/Serials.pm index 5e2fa2235f..147118498d 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; } @@ -581,27 +581,27 @@ sub GetSubscriptions { my @sqlstrings; my @strings_to_search; @strings_to_search = map { "%$_%" } split( / /, $string ); - foreach my $index qw(biblio.title subscription.callnumber subscription.location subscription.notes subscription.internalnotes) { + foreach my $index (qw(biblio.title subscription.callnumber subscription.location subscription.notes subscription.internalnotes)) { push @bind_params, @strings_to_search; my $tmpstring = "AND $index LIKE ? " x scalar(@strings_to_search); $debug && warn "$tmpstring"; $tmpstring =~ s/^AND //; push @sqlstrings, $tmpstring; } - $sqlwhere .= ( $sqlwhere ? " AND " : " WHERE " ) . "(" . join( ") OR (", @sqlstrings ) . ")"; + $sqlwhere .= ( $sqlwhere ? " AND " : " WHERE " ) . "((" . join( ") OR (", @sqlstrings ) . "))"; } if ($issn) { my @sqlstrings; my @strings_to_search; @strings_to_search = map { "%$_%" } split( / /, $issn ); - foreach my $index qw(biblioitems.issn subscription.callnumber) { + foreach my $index ( qw(biblioitems.issn subscription.callnumber)) { push @bind_params, @strings_to_search; my $tmpstring = "OR $index LIKE ? " x scalar(@strings_to_search); $debug && warn "$tmpstring"; $tmpstring =~ s/^OR //; push @sqlstrings, $tmpstring; } - $sqlwhere .= ( $sqlwhere ? " AND " : " WHERE " ) . "(" . join( ") OR (", @sqlstrings ) . ")"; + $sqlwhere .= ( $sqlwhere ? " AND " : " WHERE " ) . "((" . join( ") OR (", @sqlstrings ) . "))"; } $sql .= "$sqlwhere ORDER BY title"; $debug and warn "GetSubscriptions query: $sql params : ", join( " ", @bind_params ); @@ -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} ); @@ -1634,7 +1634,9 @@ sub HasSubscriptionExpired { my $sth = $dbh->prepare($query); $sth->execute($subscriptionid); my ($res) = $sth->fetchrow; - return 0 unless $res; + if (!$res || $res=~m/^0000/) { + return 0; + } my @res = split( /-/, $res ); my @endofsubscriptiondate = split( /-/, $expirationdate ); return 2 if ( scalar(@res) != 3 || scalar(@endofsubscriptiondate) != 3 || not check_date(@res) || not check_date(@endofsubscriptiondate) ); @@ -2152,7 +2154,7 @@ sub abouttoexpire { @res=Date::Calc::Today; } my @endofsubscriptiondate=split(/-/,$expirationdate); - my @per_list = (0, 7, 7, 14, 21, 31, 62, 93, 93, 190, 365, 730, 0, 0, 0, 0); + my @per_list = (0, 7, 7, 14, 21, 31, 62, 93, 93, 190, 365, 730, 0, 124, 0, 0); my @datebeforeend; @datebeforeend = Add_Delta_Days( $endofsubscriptiondate[0],$endofsubscriptiondate[1],$endofsubscriptiondate[2], - (3 * $per_list[$per])) if (@endofsubscriptiondate && $endofsubscriptiondate[0]*$endofsubscriptiondate[1]*$endofsubscriptiondate[2]); @@ -2315,6 +2317,15 @@ sub GetNextDate(@) { } @resultdate = Add_Delta_YMD( $year, $month, $day, 0, 3, 0 ); } + if ( $subscription->{periodicity} == 13 ) { + for ( my $i = 0 ; $i < @irreg ; $i++ ) { + if ( $irreg[$i] == ( ( $tmpmonth != 8 ) ? ( $tmpmonth + 4 ) % 12 : 12 ) ) { + ( $year, $month, $day ) = Add_Delta_YMD( $year, $month, $day, 0, 4, 0 ); + $tmpmonth = ( ( $tmpmonth != 8 ) ? ( $tmpmonth + 4 ) % 12 : 12 ); + } + } + @resultdate = Add_Delta_YMD( $year, $month, $day, 0, 4, 0 ); + } if ( $subscription->{periodicity} == 9 ) { for ( my $i = 0 ; $i < @irreg ; $i++ ) { if ( $irreg[$i] == ( ( $tmpmonth != 9 ) ? ( $tmpmonth + 3 ) % 12 : 12 ) ) { @@ -2337,29 +2348,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;