use C4::Search;
use C4::Letters;
use C4::Log; # logaction
-
-require Exporter;
+use C4::Debug;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
-$VERSION = 3.00; # set version for version checking
-
-=head1 NAME
-
-C4::Serials - Give functions for serializing.
-
-=head1 SYNOPSIS
-
- use C4::Serials;
-
-=head1 DESCRIPTION
-
-Give all XYZ functions
-
-=head1 FUNCTIONS
-
-=cut
-
-@ISA = qw(Exporter);
-@EXPORT = qw(
-
+BEGIN {
+ $VERSION = 3.01; # set version for version checking
+ require Exporter;
+ @ISA = qw(Exporter);
+ @EXPORT = qw(
&NewSubscription &ModSubscription &DelSubscription &GetSubscriptions
&GetSubscription &CountSubscriptionFromBiblionumber &GetSubscriptionsFromBiblionumber
&GetFullSubscriptionsFromBiblionumber &GetFullSubscription &ModSubscriptionHistory
&check_routing &updateClaim &removeMissingIssue
&old_newsubscription &old_modsubscription &old_getserials
-);
+ );
+}
=head2 GetSuppliersWithLateIssues
+=head1 NAME
+
+C4::Serials - Give functions for serializing.
+
+=head1 SYNOPSIS
+
+ use C4::Serials;
+
+=head1 DESCRIPTION
+
+Give all XYZ functions
+
+=head1 FUNCTIONS
+
=over 4
%supplierlist = &GetSuppliersWithLateIssues
my ($serialid) = @_;
my $dbh = C4::Context->dbh;
my $query = qq|
- SELECT serial.*, serial.notes as sernotes, serial.status as serstatus,subscription.*,subscription.subscriptionid as subsid|;
+ SELECT serial.*, serial.notes as sernotes, serial.status as serstatus,subscription.*,subscription.subscriptionid as subsid |;
if (C4::Context->preference('IndependantBranches') &&
C4::Context->userenv &&
C4::Context->userenv->{'flags'} != 1 && C4::Context->userenv->{'branch'}){
my $rq = $dbh->prepare($query);
$rq->execute($serialid);
my $data = $rq->fetchrow_hashref;
-
- if ( C4::Context->preference("serialsadditems") ) {
+ # create item information if we have serialsadditems for this subscription
+ if ( $data->{'serialsadditems'} ) {
if ( $data->{'itemnumber'} ) {
my @itemnumbers = split /,/, $data->{'itemnumber'};
foreach my $itemnum (@itemnumbers) {
#It is ASSUMED that GetMarcItem ALWAYS WORK...
#Maybe GetMarcItem should return values on failure
-# warn "itemnumber :$itemnum, bibnum :".$data->{'biblionumber'};
+ $debug and warn "itemnumber :$itemnum, bibnum :".$data->{'biblionumber'};
my $itemprocessed =
PrepareItemrecordDisplay( $data->{'biblionumber'}, $itemnum );
$itemprocessed->{'itemnumber'} = $itemnum;
sub AddItem2Serial {
my ( $serialid, $itemnumber ) = @_;
my $dbh = C4::Context->dbh;
- my $query = qq|
- UPDATE serial SET itemnumber=IF(itemnumber IS NULL, $itemnumber, CONCAT(itemnumber,",",$itemnumber))
- WHERE serialid = ?
- |;
- my $rq = $dbh->prepare($query);
- $rq->execute($serialid);
+ my $rq = $dbh->prepare("INSERT INTO `serialitems` SET serialid=? , itemnumber=?");
+ $rq->execute($serialid, $itemnumber);
return $rq->rows;
}
my $query = qq(
SELECT subscription.*,
subscriptionhistory.*,
+ subscriptionhistory.enddate as histenddate,
aqbudget.bookfundid,
aqbooksellers.name AS aqbooksellername,
biblio.title AS bibliotitle,
# if (C4::Context->preference('IndependantBranches') &&
# C4::Context->userenv &&
# C4::Context->userenv->{'flags'} != 1){
-# # warn "flags: ".C4::Context->userenv->{'flags'};
+# # $debug and warn "flags: ".C4::Context->userenv->{'flags'};
# $query.=" AND subscription.branchcode IN ('".C4::Context->userenv->{'branch'}."',\"\")";
# }
-# warn "query : $query";
+ $debug and warn "query : $query\nsubsid :$subscriptionid";
my $sth = $dbh->prepare($query);
-# warn "subsid :$subscriptionid";
$sth->execute($subscriptionid);
- my $subs = $sth->fetchrow_hashref;
- return $subs;
+ return $sth->fetchrow_hashref;
}
=head2 GetFullSubscription
IF(serial.publisheddate="00-00-0000",serial.planneddate,serial.publisheddate) DESC,
serial.subscriptionid
|;
-# warn $query;
+ $debug and warn "GetFullSubscription query: $query";
my $sth = $dbh->prepare($query);
$sth->execute($subscriptionid);
- my $subs = $sth->fetchall_arrayref({});
- return $subs;
+ return $sth->fetchall_arrayref({});
}
SELECT subscription.*,
branches.branchname,
subscriptionhistory.*,
+ subscriptionhistory.enddate as histenddate,
aqbudget.bookfundid,
aqbooksellers.name AS aqbooksellername,
biblio.title AS bibliotitle
while ( my $subs = $sth->fetchrow_hashref ) {
$subs->{startdate} = format_date( $subs->{startdate} );
$subs->{histstartdate} = format_date( $subs->{histstartdate} );
+ $subs->{histenddate} = format_date( $subs->{histenddate} );
$subs->{opacnote} =~ s/\n/\<br\/\>/g;
$subs->{missinglist} =~ s/\n/\<br\/\>/g;
$subs->{recievedlist} =~ s/\n/\<br\/\>/g;
|;
my $sth = $dbh->prepare($query);
$sth->execute($biblionumber);
- my $subs= $sth->fetchall_arrayref({});
- return $subs;
+ return $sth->fetchall_arrayref({});
}
=head2 GetSubscriptions
WHERE biblio.biblionumber=?
);
$query.=" ORDER BY title";
-# warn "query :$query";
+ $debug and warn "GetSubscriptions query: $query";
$sth = $dbh->prepare($query);
$sth->execute($biblionumber);
}
LEFT JOIN biblioitems ON biblio.biblionumber = biblioitems.biblionumber
WHERE (biblioitems.issn = ? or|. join('and ',map{"biblio.title LIKE \"%$_%\""}split (" ",$title))." )";
$query.=" ORDER BY title";
+ $debug and warn "GetSubscriptions query: $query";
$sth = $dbh->prepare($query);
$sth->execute( $ISSN );
}
WHERE biblioitems.issn LIKE ?
);
$query.=" ORDER BY title";
-# warn "query :$query";
+ $debug and warn "GetSubscriptions query: $query";
$sth = $dbh->prepare($query);
$sth->execute( "%" . $ISSN . "%" );
}
).($title?" and ":""). join('and ',map{"biblio.title LIKE \"%$_%\""} split (" ",$title) );
$query.=" ORDER BY title";
-# warn $query;
+ $debug and warn "GetSubscriptions query: $query";
$sth = $dbh->prepare($query);
$sth->execute;
}
if ( $previoustitle eq $line->{title} ) {
$line->{title} = "";
$line->{issn} = "";
- $line->{toggle} = 1 if $odd == 1;
}
else {
$previoustitle = $line->{title};
$odd = -$odd;
- $line->{toggle} = 1 if $odd == 1;
}
+ $line->{toggle} = 1 if $odd == 1;
$line->{'cannotedit'}=(C4::Context->preference('IndependantBranches') &&
C4::Context->userenv &&
C4::Context->userenv->{flags} !=1 &&
WHERE subscriptionid=$subscription AND status IN ($status)
ORDER BY publisheddate,serialid DESC
|;
-# warn $query;
+ $debug and warn "GetSerials2 query: $query";
my $sth=$dbh->prepare($query);
$sth->execute;
my @serials;
$whenmorethan3, $setto3, $lastvalue3, $innerloop3,
$numberingmethod, $status, $biblionumber, $callnumber,
$notes, $letter, $hemisphere, $manualhistory,
- $internalnotes,
+ $internalnotes, $serialsadditems,
$subscriptionid
) = @_;
# warn $irregularity;
add1=?,every1=?,whenmorethan1=?,setto1=?,lastvalue1=?,innerloop1=?,
add2=?,every2=?,whenmorethan2=?,setto2=?,lastvalue2=?,innerloop2=?,
add3=?,every3=?,whenmorethan3=?,setto3=?,lastvalue3=?,innerloop3=?,
- numberingmethod=?, status=?, biblionumber=?, callnumber=?, notes=?, letter=?, hemisphere=?,manualhistory=?,internalnotes=?
+ numberingmethod=?, status=?, biblionumber=?, callnumber=?, notes=?, letter=?, hemisphere=?,manualhistory=?,internalnotes=?,serialsadditems=?
WHERE subscriptionid = ?";
# warn "query :".$query;
my $sth = $dbh->prepare($query);
$whenmorethan3, $setto3, $lastvalue3, $innerloop3,
$numberingmethod, $status, $biblionumber, $callnumber,
$notes, $letter, $hemisphere, ($manualhistory?$manualhistory:0),
- $internalnotes,
+ $internalnotes, $serialsadditems,
$subscriptionid
);
my $rows=$sth->rows;
$sth->finish;
- &logaction(C4::Context->userenv->{'number'},"SERIAL","MODIFY",$subscriptionid,"")
- if C4::Context->preference("SubscriptionLog");
+ logaction("SERIAL", "MODIFY", $subscriptionid, "") if C4::Context->preference("SubscriptionLog");
return $rows;
}
$add1,$every1,$whenmorethan1,$setto1,$lastvalue1,$innerloop1,
$add2,$every2,$whenmorethan2,$setto2,$lastvalue2,$innerloop2,
$add3,$every3,$whenmorethan3,$setto3,$lastvalue3,$innerloop3,
- $numberingmethod, $status, $notes)
+ $numberingmethod, $status, $notes, $serialsadditems)
Create a new subscription with value given on input args.
$lastvalue3, $innerloop3, $numberingmethod, $status,
$notes, $letter, $firstacquidate, $irregularity,
$numberpattern, $callnumber, $hemisphere, $manualhistory,
- $internalnotes
+ $internalnotes, $serialsadditems,
) = @_;
my $dbh = C4::Context->dbh;
add2,every2,whenmorethan2,setto2,lastvalue2,innerloop2,
add3,every3,whenmorethan3,setto3,lastvalue3,innerloop3,
numberingmethod, status, notes, letter,firstacquidate,irregularity,
- numberpattern, callnumber, hemisphere,manualhistory,internalnotes)
- VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
+ numberpattern, callnumber, hemisphere,manualhistory,internalnotes,serialsadditems)
+ VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
|;
my $sth = $dbh->prepare($query);
$sth->execute(
format_date_in_iso($firstacquidate), $irregularity,
$numberpattern, $callnumber,
$hemisphere, $manualhistory,
- $internalnotes
+ $internalnotes, $serialsadditems,
);
#then create the 1st waited number
my $subscriptionid = $dbh->{'mysql_insertid'};
$query = qq(
INSERT INTO subscriptionhistory
- (biblionumber, subscriptionid, histstartdate, enddate, missinglist, recievedlist, opacnote, librariannote)
- VALUES (?,?,?,?,?,?,?,?)
+ (biblionumber, subscriptionid, histstartdate, opacnote, librariannote)
+ VALUES (?,?,?,?,?)
);
$sth = $dbh->prepare($query);
$sth->execute( $biblionumber, $subscriptionid,
format_date_in_iso($startdate),
- 0, "", "", "", "$notes" );
+ $notes,$internalnotes );
# reread subscription to get a hash (for calculation of the 1st issue number)
$query = qq(
format_date_in_iso($startdate)
);
- &logaction(C4::Context->userenv->{'number'},"SERIAL","ADD",$subscriptionid,"")
- if C4::Context->preference("SubscriptionLog");
+ logaction("SERIAL", "ADD", $subscriptionid, "") if C4::Context->preference("SubscriptionLog");
+#set serial flag on biblio if not already set.
+ my ($null, ($bib)) = GetBiblio($biblionumber);
+ if( ! $bib->{'serial'} ) {
+ my $record = GetMarcBiblio($biblionumber);
+ my ($tag,$subf) = GetMarcFromKohaField('biblio.serial',$bib->{'frameworkcode'});
+ if($tag) {
+ eval {
+ $record->field($tag)->update( $subf => 1 );
+ };
+ }
+ ModBiblio($record,$biblionumber,$bib->{'frameworkcode'});
+ }
return $subscriptionid;
}
my $sth = $dbh->prepare($query);
$sth->execute( $subscription->{biblionumber} );
my $biblio = $sth->fetchrow_hashref;
- NewSuggestion(
- $user, $subscription->{bibliotitle},
- $biblio->{author}, $biblio->{publishercode},
- $biblio->{note}, '',
- '', '',
- '', '',
- $subscription->{biblionumber}
- );
+ if (C4::Context->preference("RenewSerialAddsSuggestion")){
+ NewSuggestion(
+ $user, $subscription->{bibliotitle},
+ $biblio->{author}, $biblio->{publishercode},
+ $biblio->{note}, '',
+ '', '',
+ '', '',
+ $subscription->{biblionumber}
+ );
+ }
# renew subscription
- my $query = qq|
+ $query = qq|
UPDATE subscription
SET startdate=?,numberlength=?,weeklength=?,monthlength=?
WHERE subscriptionid=?
|;
- my $sth = $dbh->prepare($query);
+ $sth = $dbh->prepare($query);
$sth->execute( format_date_in_iso($startdate),
$numberlength, $weeklength, $monthlength, $subscriptionid );
- &logaction(C4::Context->userenv->{'number'},"SERIAL","RENEW",$subscriptionid,"")
- if C4::Context->preference("SubscriptionLog");
+ logaction("SERIAL", "RENEW", $subscriptionid, "") if C4::Context->preference("SubscriptionLog");
}
=head2 NewIssue
return 0;
}
}
- return 0;
+ return 0; # Notice that you'll never get here.
}
=head2 SetDistributedto
"DELETE FROM subscriptionhistory WHERE subscriptionid=$subscriptionid");
$dbh->do("DELETE FROM serial WHERE subscriptionid=$subscriptionid");
- &logaction(C4::Context->userenv->{'number'},"SERIAL","DELETE",$subscriptionid,"")
- if C4::Context->preference("SubscriptionLog");
+ logaction("SERIAL", "DELETE", $subscriptionid, "") if C4::Context->preference("SubscriptionLog");
}
=head2 DelIssue
return ($data);
}
-END { } # module clean-up code here (global destructor)
-
1;
+__END__
=back