X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=C4%2FSerials.pm;h=af5c8335c607b010fc380c32ab8511f634f60d52;hb=6dda8a63795439cde4d97f97b9d09b63011ef54a;hp=8aa6ebc68d70329c56724f48eb667bb8b09347b6;hpb=30dc7ed25b14775819320106d1c0479f990a6a8c;p=koha.git diff --git a/C4/Serials.pm b/C4/Serials.pm index 8aa6ebc68d..af5c8335c6 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -23,13 +23,7 @@ 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; @@ -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/; @@ -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; @@ -588,7 +582,7 @@ sub GetSubscriptions { $tmpstring =~ s/^AND //; push @sqlstrings, $tmpstring; } - $sqlwhere .= ( $sqlwhere ? " AND " : " WHERE " ) . "(" . join( ") OR (", @sqlstrings ) . ")"; + $sqlwhere .= ( $sqlwhere ? " AND " : " WHERE " ) . "((" . join( ") OR (", @sqlstrings ) . "))"; } if ($issn) { my @sqlstrings; @@ -601,25 +595,15 @@ sub GetSubscriptions { $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 ); $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 +1073,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 +1323,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 +1541,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 +2013,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 +2027,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 @@ -2154,7 +2133,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]); @@ -2317,6 +2296,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 ) ) {