X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=C4%2FSerials.pm;h=58b6078c28255ce0ef9338c529b08b8259d526e8;hb=096d8a6e3df6de8d8659fb75d36e19f9e2fadb04;hp=147118498ded9384dd553531da9ba14f083ac58e;hpb=236747534115e35975de8d51554e6e87f4248462;p=koha.git diff --git a/C4/Serials.pm b/C4/Serials.pm index 147118498d..58b6078c28 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -23,20 +23,14 @@ use warnings; use C4::Dates qw(format_date format_date_in_iso); use Date::Calc qw(:all); use POSIX qw(strftime); -use C4::Suggestions; -use C4::Koha; use C4::Biblio; -use C4::Branch; -use C4::Items; -use C4::Search; -use C4::Letters; use C4::Log; # logaction use C4::Debug; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); BEGIN { - $VERSION = 3.01; # set version for version checking + $VERSION = 3.07.00.049; # set version for version checking require Exporter; @ISA = qw(Exporter); @EXPORT = qw( @@ -231,13 +225,14 @@ sub GetSerialInformation { my $queryitem = $dbh->prepare("SELECT itemnumber from serialitems where serialid=?"); $queryitem->execute($serialid); my $itemnumbers = $queryitem->fetchall_arrayref( [0] ); + require C4::Items; if ( scalar(@$itemnumbers) > 0 ) { foreach my $itemnum (@$itemnumbers) { #It is ASSUMED that GetMarcItem ALWAYS WORK... #Maybe GetMarcItem should return values on failure $debug and warn "itemnumber :$itemnum->[0], bibnum :" . $data->{'biblionumber'}; - my $itemprocessed = PrepareItemrecordDisplay( $data->{'biblionumber'}, $itemnum->[0], $data ); + my $itemprocessed = C4::Items::PrepareItemrecordDisplay( $data->{'biblionumber'}, $itemnum->[0], $data ); $itemprocessed->{'itemnumber'} = $itemnum->[0]; $itemprocessed->{'itemid'} = $itemnum->[0]; $itemprocessed->{'serialid'} = $serialid; @@ -245,7 +240,7 @@ sub GetSerialInformation { push @{ $data->{'items'} }, $itemprocessed; } } else { - my $itemprocessed = PrepareItemrecordDisplay( $data->{'biblionumber'}, '', $data ); + my $itemprocessed = C4::Items::PrepareItemrecordDisplay( $data->{'biblionumber'}, '', $data ); $itemprocessed->{'itemid'} = "N$serialid"; $itemprocessed->{'serialid'} = $serialid; $itemprocessed->{'biblionumber'} = $data->{'biblionumber'}; @@ -417,7 +412,6 @@ sub PrepareSerialsData { $subs->{$datefield} = format_date( $subs->{$datefield} ); } } - $subs->{'branchname'} = GetBranchName( $subs->{'branchcode'} ); $subs->{ "status" . $subs->{'status'} } = 1; $subs->{"checked"} = $subs->{'status'} =~ /1|3|4|7/; @@ -551,15 +545,15 @@ sub GetFullSubscriptionsFromBiblionumber { =head2 GetSubscriptions -@results = GetSubscriptions($title,$ISSN,$biblionumber); -this function gets all subscriptions which have title like $title,ISSN like $ISSN and biblionumber like $biblionumber. +@results = GetSubscriptions($title,$ISSN,$ean,$biblionumber); +this function gets all subscriptions which have title like $title,ISSN like $ISSN,EAN like $ean and biblionumber like $biblionumber. return: a table of hashref. Each hash containt the subscription. =cut sub GetSubscriptions { - my ( $string, $issn, $biblionumber ) = @_; + my ( $string, $issn, $ean, $biblionumber ) = @_; #return unless $title or $ISSN or $biblionumber; my $dbh = C4::Context->dbh; @@ -572,7 +566,7 @@ sub GetSubscriptions { LEFT JOIN biblioitems ON biblio.biblionumber = biblioitems.biblionumber ); my @bind_params; - my $sqlwhere; + my $sqlwhere = q{}; if ($biblionumber) { $sqlwhere = " WHERE biblio.biblionumber=?"; push @bind_params, $biblionumber; @@ -603,23 +597,27 @@ sub GetSubscriptions { } $sqlwhere .= ( $sqlwhere ? " AND " : " WHERE " ) . "((" . join( ") OR (", @sqlstrings ) . "))"; } + if ($ean) { + my @sqlstrings; + my @strings_to_search; + @strings_to_search = map { "$_" } split( / /, $ean ); + foreach my $index ( qw(biblioitems.ean) ) { + push @bind_params, @strings_to_search; + my $tmpstring = "OR $index = ? " x scalar(@strings_to_search); + $debug && warn "$tmpstring"; + $tmpstring =~ s/^OR //; + push @sqlstrings, $tmpstring; + } + $sqlwhere .= ( $sqlwhere ? " AND " : " WHERE " ) . "((" . join( ") OR (", @sqlstrings ) . "))"; + } + $sql .= "$sqlwhere ORDER BY title"; $debug and warn "GetSubscriptions query: $sql params : ", join( " ", @bind_params ); $sth = $dbh->prepare($sql); $sth->execute(@bind_params); my @results; - my $previousbiblio = ""; - my $odd = 1; while ( my $line = $sth->fetchrow_hashref ) { - if ( $previousbiblio eq $line->{biblionumber} ) { - $line->{title} = ""; - $line->{issn} = ""; - } else { - $previousbiblio = $line->{biblionumber}; - $odd = -$odd; - } - $line->{toggle} = 1 if $odd == 1; $line->{'cannotedit'} = ( C4::Context->preference('IndependantBranches') && C4::Context->userenv @@ -1089,7 +1087,8 @@ sub ModSerialStatus { # check if an alert must be sent... (= a letter is defined & status became "arrived" if ( $val->{letter} && $status == 2 && $oldstatus != 2 ) { - SendAlerts( 'issue', $val->{subscriptionid}, $val->{letter} ); + require C4::Letters; + C4::Letters::SendAlerts( 'issue', $val->{subscriptionid}, $val->{letter} ); } } return; @@ -1338,8 +1337,8 @@ sub ReNewSubscription { my $biblio = $sth->fetchrow_hashref; if ( C4::Context->preference("RenewSerialAddsSuggestion") ) { - - NewSuggestion( + require C4::Suggestions; + C4::Suggestions::NewSuggestion( { 'suggestedby' => $user, 'title' => $subscription->{bibliotitle}, 'author' => $biblio->{author}, @@ -1556,7 +1555,8 @@ sub ItemizeSerials { $marcrecord->insert_fields_ordered($newField); } } - AddItemFromMarc( $marcrecord, $data->{'biblionumber'} ); + require C4::Items; + C4::Items::AddItemFromMarc( $marcrecord, $data->{'biblionumber'} ); return 1; } return ( 0, @errors ); @@ -2027,12 +2027,11 @@ sub delroutingmember { =head2 getroutinglist -($count,@routinglist) = getroutinglist($subscriptionid) +@routinglist = getroutinglist($subscriptionid) this gets the info from the subscriptionroutinglist for $subscriptionid return : -a count of the number of members on routinglist the routinglist as an array. Each element of the array contains a hash_ref containing routingid - a unique id, borrowernumber, ranking, and biblionumber of subscription @@ -2042,20 +2041,14 @@ sub getroutinglist { my ($subscriptionid) = @_; my $dbh = C4::Context->dbh; my $sth = $dbh->prepare( - "SELECT routingid, borrowernumber, ranking, biblionumber + 'SELECT routingid, borrowernumber, ranking, biblionumber FROM subscription JOIN subscriptionroutinglist ON subscription.subscriptionid = subscriptionroutinglist.subscriptionid - WHERE subscription.subscriptionid = ? ORDER BY ranking ASC - " + WHERE subscription.subscriptionid = ? ORDER BY ranking ASC' ); $sth->execute($subscriptionid); - my @routinglist; - my $count = 0; - while ( my $line = $sth->fetchrow_hashref ) { - $count++; - push( @routinglist, $line ); - } - return ( $count, @routinglist ); + my $routinglist = $sth->fetchall_arrayref({}); + return @{$routinglist}; } =head2 countissuesfrom