From 722bd487f3610dbd32e4e3b396c765a170695b2f Mon Sep 17 00:00:00 2001 From: toins Date: Wed, 12 Jul 2006 10:49:39 +0000 Subject: [PATCH] Code cleaning : Sub renamed & POD added. --- C4/Serials.pm | 1140 ++++++++++++++++++++++++++++++------------------- 1 file changed, 707 insertions(+), 433 deletions(-) diff --git a/C4/Serials.pm b/C4/Serials.pm index 5b1d657a0b..9745086651 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -48,30 +48,34 @@ Give all XYZ functions =head1 FUNCTIONS -=over 2 - =cut @ISA = qw(Exporter); @EXPORT = qw( &NewSubscription &ModSubscription &DelSubscription &GetSubscriptions &GetSubscription - &GetSubscriptionFromBiblionumber &GetSubscriptionListFromBiblionumber - &GetFullSubscriptionListFromBiblionumber + &CountSubscriptionFromBiblionumber &GetSubscriptionsFromBiblionumber + &GetFullSubscriptionsFromBiblionumber &GetNextSeq &ModSubscriptionHistory &NewIssue &ItemizeSerials &GetSerials &GetLatestSerials &ModSerialStatus - &HasSubscriptionExpired &SubscriptionExpirationDate &SubscriptionReNew - &GetSupplierListWithLateIssues &GetLateIssues - ); + &HasSubscriptionExpired &GetSubscriptionExpirationDate &ReNewSubscription + &GetSuppliersWithLateIssues &GetLateIssues + &GetDistributedTo &SetDistributedto +); -=item GetSupplierListWithLateIssues +=head2 GetSuppliersWithLateIssues -%supplierlist = &GetSupplierListWithLateIssues +=over 4 - this function get all supplier with late issue. +%supplierlist = &GetSuppliersWithLateIssues + +this function get all suppliers with late issues. return : -the supplierlist into an hash. +the supplierlist into a hash. this hash containts id & name of the supplier + +=back + =cut -sub GetSupplierListWithLateIssues { +sub GetSuppliersWithLateIssues { my $dbh = C4::Context->dbh; my $query = qq| SELECT DISTINCT id, name @@ -89,17 +93,21 @@ sub GetSupplierListWithLateIssues { return %supplierlist; } -=item GetLateIssues +=head2 GetLateIssues + +=over 4 @issuelist = &GetLateIssues($supplierid) this function select late issues on database return : -the issuelist into an table. +the issuelist into an table. Each line of this table containts a ref to a hash which it containts +name,title,planneddate,serialseq,serial.subscriptionid from tables : subscription, serial & biblio -=cut +=back +=cut sub GetLateIssues { my ($supplierid) = @_; my $dbh = C4::Context->dbh; @@ -143,84 +151,65 @@ sub GetLateIssues { return @issuelist; } -=item NewSubscription +=head2 GetSubscriptionHistoryFromSubscriptionId -$subscriptionid = &NewSubscription($auser,$aqbooksellerid,$cost,$aqbudgetid,$biblionumber, - $startdate,$periodicity,$dow,$numberlength,$weeklength,$monthlength, - $add1,$every1,$whenmorethan1,$setto1,$lastvalue1,$innerloop1, - $add2,$every2,$whenmorethan2,$setto2,$lastvalue2,$innerloop2, - $add3,$every3,$whenmorethan3,$setto3,$lastvalue3,$innerloop3, - $numberingmethod, $status, $notes) - -Create a new subscription. +=over 4 +$sth = GetSubscriptionHistoryFromSubscriptionId() +this function just prepare the SQL request. +After this function, don't forget to execute it by using $sth->execute($subscriptionid) return : -the id of this new subscription +$sth = $dbh->prepare($query). + +=back =cut -sub NewSubscription { - my ($auser,$aqbooksellerid,$cost,$aqbudgetid,$biblionumber, - $startdate,$periodicity,$dow,$numberlength,$weeklength,$monthlength, - $add1,$every1,$whenmorethan1,$setto1,$lastvalue1,$innerloop1, - $add2,$every2,$whenmorethan2,$setto2,$lastvalue2,$innerloop2, - $add3,$every3,$whenmorethan3,$setto3,$lastvalue3,$innerloop3, - $numberingmethod, $status, $notes) = @_; +sub GetSubscriptionHistoryFromSubscriptionId() { my $dbh = C4::Context->dbh; - #save subscription my $query = qq| - INSERT INTO subscription - (librarian,aqbooksellerid,cost,aqbudgetid,biblionumber, - startdate,periodicity,dow,numberlength,weeklength,monthlength, - add1,every1,whenmorethan1,setto1,lastvalue1,innerloop1, - add2,every2,whenmorethan2,setto2,lastvalue2,innerloop2, - add3,every3,whenmorethan3,setto3,lastvalue3,innerloop3, - numberingmethod, status, notes) - VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) - |; - my $sth=$dbh->prepare($query); - $sth->execute($auser,$aqbooksellerid,$cost,$aqbudgetid,$biblionumber, - format_date_in_iso($startdate),$periodicity,$dow,$numberlength,$weeklength,$monthlength, - $add1,$every1,$whenmorethan1,$setto1,$lastvalue1,$innerloop1, - $add2,$every2,$whenmorethan2,$setto2,$lastvalue2,$innerloop2, - $add3,$every3,$whenmorethan3,$setto3,$lastvalue3,$innerloop3, - $numberingmethod, $status, $notes); - - #then create the 1st waited number - my $subscriptionid = $dbh->{'mysql_insertid'}; - my $query = qq( - INSERT INTO subscriptionhistory - (biblionumber, subscriptionid, histstartdate, enddate, missinglist, recievedlist, opacnote, librariannote) - VALUES (?,?,?,?,?,?,?,?) - ); - $sth = $dbh->prepare($query); - $sth->execute($biblionumber, $subscriptionid, format_date_in_iso($startdate), 0, "", "", "", $notes); - # reread subscription to get a hash (for calculation of the 1st issue number) - my $query = qq( SELECT * - FROM subscription + FROM subcriptionhistory WHERE subscriptionid = ? - ); - $sth = $dbh->prepare($query); - $sth->execute($subscriptionid); - my $val = $sth->fetchrow_hashref; + |; + return $dbh->prepare($query); +} - # calculate issue number - my $serialseq = GetSeq($val); - my $query = qq( - INSERT INTO serial - (serialseq,subscriptionid,biblionumber,status, planneddate) - VALUES (?,?,?,?,?) - ); - $sth = $dbh->prepare($query); - $sth->execute($serialseq, $subscriptionid, $val->{'biblionumber'}, 1, format_date_in_iso($startdate)); - return $subscriptionid; +=head2 GetSerialStatusFromSerialId + +=over 4 + +$sth = GetSerialStatusFromSerialId(); +this function just prepare the SQL request. +After this function, don't forget to execute it by using $sth->execute($serialid) +return : +$sth = $dbh->prepare($query). + +=back + +=cut +sub GetSerialStatusFromSerialId(){ + my $dbh = C4::Context->dbh; + my $query = qq| + SELECT status + FROM serial + WHERE serialid = ? + |; + return $dbh->prepare($query); } -=item GetSubscription - $subs = GetSubscription($subscriptionid) - this function get the subscription which have $subscriptionid as id. + + +=head2 GetSubscription + +=over 4 + +$subs = GetSubscription($subscriptionid) +this function get the subscription which has $subscriptionid as id. return : - a ref to a hash. This hash containts - subscription, subscriptionhistory, aqbudget.bookfundid, biblio.title +a hashref. This hash containts +subscription, subscriptionhistory, aqbudget.bookfundid, biblio.title + +=back + =cut sub GetSubscription { my ($subscriptionid) = @_; @@ -243,29 +232,22 @@ sub GetSubscription { my $subs = $sth->fetchrow_hashref; return $subs; } -=item GetSubscriptionFromBiblionumber - $subscriptionsnumber = GetSubscriptionFromBiblionumber($biblionumber) + +=head2 GetSubscriptionsFromBiblionumber + +=over 4 + +\@res = GetSubscriptionsFromBiblionumber($biblionumber) +this function get the subscription list. it reads on subscription table. return : - the number of subscription with biblionumber given on input arg. -=cut -sub GetSubscriptionFromBiblionumber { - my ($biblionumber) = @_; - my $dbh = C4::Context->dbh; - my $query = qq( - SELECT count(*) - FROM subscription - WHERE biblionumber=? - ); - my $sth = $dbh->prepare($query); - $sth->execute($biblionumber); - my $subscriptionsnumber = $sth->fetchrow; - return $subscriptionsnumber; -} -=item GetSubscriptionListFromBiblionumber - \@res = GetSubscriptionListFromBiblionumber($biblionumber) - TODO ! +table of subscription which has the biblionumber given on input arg. +each line of this table is a hashref. All hashes containt +startdate, histstartdate,opacnote,missinglist,recievedlist,periodicity,status & enddate + +=back + =cut -sub GetSubscriptionListFromBiblionumber { +sub GetSubscriptionsFromBiblionumber { my ($biblionumber) = @_; my $dbh = C4::Context->dbh; my $query = qq( @@ -301,29 +283,37 @@ sub GetSubscriptionListFromBiblionumber { } return \@res; } -=item GetFullSubscriptionListFromBiblionumber - GetFullSubscriptionListFromBiblionumber($biblionumber) +=head2 GetFullSubscriptionsFromBiblionumber + +=over 4 + + \@res = GetFullSubscriptionsFromBiblionumber($biblionumber) + this function read on serial table. + +=back + =cut -sub GetFullSubscriptionListFromBiblionumber { +sub GetFullSubscriptionsFromBiblionumber { my ($biblionumber) = @_; my $dbh = C4::Context->dbh; - my $query=qq(SELECT serial.serialseq, + my $query=qq| + SELECT serial.serialseq, serial.planneddate, serial.publisheddate, serial.status, serial.notes, - year(serial.publisheddate) as year, - aqbudget.bookfundid,aqbooksellers.name as aqbooksellername, - biblio.title as bibliotitle + year(serial.publisheddate) AS year, + aqbudget.bookfundid,aqbooksellers.name AS aqbooksellername, + biblio.title AS bibliotitle FROM serial LEFT JOIN subscription ON (serial.subscriptionid=subscription.subscriptionid AND subscription.biblionumber=serial.biblionumber) LEFT JOIN aqbudget ON subscription.aqbudgetid=aqbudget.aqbudgetid - LEFT JOIN aqbooksellers on subscription.aqbooksellerid=aqbooksellers.id + LEFT JOIN aqbooksellers on subscription.aqbooksellerid=aqbooksellers.id LEFT JOIN biblio on biblio.biblionumber=subscription.biblionumber WHERE subscription.biblionumber = ? ORDER BY year,serial.publisheddate,serial.subscriptionid,serial.planneddate - ); + |; my $sth = $dbh->prepare($query); $sth->execute($biblionumber); @@ -376,48 +366,19 @@ sub GetFullSubscriptionListFromBiblionumber { } return \@res; } -=item ModSubscription - this function modify a subscription. -=cut -sub ModSubscription { - my ($auser,$aqbooksellerid,$cost,$aqbudgetid,$startdate, - $periodicity,$dow,$numberlength,$weeklength,$monthlength, - $add1,$every1,$whenmorethan1,$setto1,$lastvalue1,$innerloop1, - $add2,$every2,$whenmorethan2,$setto2,$lastvalue2,$innerloop2, - $add3,$every3,$whenmorethan3,$setto3,$lastvalue3,$innerloop3, - $numberingmethod, $status, $biblionumber, $notes, $letter, $subscriptionid)= @_; - my $dbh = C4::Context->dbh; - my $sth=$dbh->prepare("update subscription set librarian=?, aqbooksellerid=?,cost=?,aqbudgetid=?,startdate=?, - periodicity=?,dow=?,numberlength=?,weeklength=?,monthlength=?, - add1=?,every1=?,whenmorethan1=?,setto1=?,lastvalue1=?,innerloop1=?, - add2=?,every2=?,whenmorethan2=?,setto2=?,lastvalue2=?,innerloop2=?, - add3=?,every3=?,whenmorethan3=?,setto3=?,lastvalue3=?,innerloop3=?, - numberingmethod=?, status=?, biblionumber=?, notes=?, letter=? where subscriptionid = ?"); - $sth->execute($auser,$aqbooksellerid,$cost,$aqbudgetid,$startdate, - $periodicity,$dow,$numberlength,$weeklength,$monthlength, - $add1,$every1,$whenmorethan1,$setto1,$lastvalue1,$innerloop1, - $add2,$every2,$whenmorethan2,$setto2,$lastvalue2,$innerloop2, - $add3,$every3,$whenmorethan3,$setto3,$lastvalue3,$innerloop3, - $numberingmethod, $status, $biblionumber, $notes, $letter, $subscriptionid); - $sth->finish; -} -=item DelSubscription - DelSubscription($subscriptionid) - this function delete the subscription which have $subscriptionid as id. -=cut -sub DelSubscription { - my ($subscriptionid) = @_; - my $dbh = C4::Context->dbh; - $subscriptionid=$dbh->quote($subscriptionid); - $dbh->do("DELETE FROM subscription WHERE subscriptionid=$subscriptionid"); - $dbh->do("DELETE FROM subscriptionhistory WHERE subscriptionid=$subscriptionid"); - $dbh->do("DELETE FROM serial WHERE subscriptionid=$subscriptionid"); -} -=item GetSubscriptions - @results = GetSubscriptions($title,$ISSN,$biblionumber); - this function get all subscriptions which have $title,$ISSN,$biblionumber. + + +=head2 GetSubscriptions + +=over 4 + +@results = GetSubscriptions($title,$ISSN,$biblionumber); +this function get all subscriptions which has title like $title,ISSN like $ISSN and biblionumber like $biblionumber. return: - a table of ref to hash. Each hash containt the subscription. +a table of hashref. Each hash containt the subscription. + +=back + =cut sub GetSubscriptions { my ($title,$ISSN,$biblionumber) = @_; @@ -437,14 +398,14 @@ sub GetSubscriptions { $sth->execute($biblionumber); } else { if ($ISSN and $title){ - my $query = qq( + my $query = qq| SELECT subscription.subscriptionid,biblio.title,biblioitems.issn,subscription.notes,biblio.biblionumber FROM subscription,biblio,biblioitems WHERE biblio.biblionumber = biblioitems.biblionumber AND biblio.biblionumber= subscription.biblionumber AND (biblio.title LIKE ? or biblioitems.issn = ?) ORDER BY title - ); + |; $sth = $dbh->prepare($query); $sth->execute("%$title%",$ISSN); } @@ -489,43 +450,32 @@ sub GetSubscriptions { } push @results, $line; } - return @results; -} -=item ModSubscriptionHistory - ModSubscriptionHistory($subscriptionid,$histstartdate,$enddate,$recievedlist,$missinglist,$opacnote,$librariannote); -this function modify the history of the subscription given on input args. -=cut -sub ModSubscriptionHistory { - my ($subscriptionid,$histstartdate,$enddate,$recievedlist,$missinglist,$opacnote,$librariannote)=@_; - my $dbh=C4::Context->dbh; - my $query = qq( - UPDATE subscriptionhistory - SET histstartdate=?,enddate=?,recievedlist=?,missinglist=?,opacnote=?,librariannote=? - WHERE subscriptionid=? - ); - my $sth = $dbh->prepare($query); - $recievedlist =~ s/^,//g; - $missinglist =~ s/^,//g; - $opacnote =~ s/^,//g; - $sth->execute($histstartdate,$enddate,$recievedlist,$missinglist,$opacnote,$librariannote,$subscriptionid); + return @results; } -=item GetSerials - ($totalissues,@serials) = GetSerials($subscriptionid); - this function get every serial not arrived for a given subscription - as well as the number of issues registered in the database (all types) - this number is used to see if a subscription can be deleted (=it must have only 1 issue) + +=head2 GetSerials + +=over 4 + +($totalissues,@serials) = GetSerials($subscriptionid); +this function get every serial not arrived for a given subscription +as well as the number of issues registered in the database (all types) +this number is used to see if a subscription can be deleted (=it must have only 1 issue) + +=back + =cut sub GetSerials { my ($subscriptionid) = @_; my $dbh = C4::Context->dbh; # OK, now add the last 5 issues arrives/missing - my $query = qq( + my $query = qq| SELECT serialid,serialseq, status, planneddate,notes FROM serial WHERE subscriptionid = ? AND (status in (2,4,5)) ORDER BY serialid DESC - ); + |; my $sth=$dbh->prepare($query); $sth->execute($subscriptionid); my $counter=0; @@ -537,44 +487,51 @@ sub GetSerials { push @serials,$line; } # status = 2 is "arrived" - my $query = qq( + my $query = qq| SELECT serialid,serialseq, status, publisheddate, planneddate,notes - FROM serial + FROM serial WHERE subscriptionid = ? AND status NOT IN (2,4,5) - ); + |; my $sth=$dbh->prepare($query); $sth->execute($subscriptionid); while(my $line = $sth->fetchrow_hashref) { - $line->{"status".$line->{status}} = 1; # fills a "statusX" value, used for template status select list - $line->{"publisheddate"} = format_date($line->{"publisheddate"}); - $line->{"planneddate"} = format_date($line->{"planneddate"}); - push @serials,$line; - } - my $query = qq( + $line->{"status".$line->{status}} = 1; # fills a "statusX" value, used for template status select list + $line->{"publisheddate"} = format_date($line->{"publisheddate"}); + $line->{"planneddate"} = format_date($line->{"planneddate"}); + push @serials,$line; + } + my $query = qq| SELECT count(*) FROM serial WHERE subscriptionid=? - ); + |; $sth=$dbh->prepare($query); $sth->execute($subscriptionid); my ($totalissues) = $sth->fetchrow; return ($totalissues,@serials); } -=item GetLatestSerials - \@serials = GetLatestSerials($subscriptionid,$limit) - get the $limit's latest serials arrived or missing for a given subscription + +=head2 GetLatestSerials + +=over 4 + +\@serials = GetLatestSerials($subscriptionid,$limit) +get the $limit's latest serials arrived or missing for a given subscription return : - a ref to a table which it containts all of the latest serials. +a ref to a table which it containts all of the latest serials stored into a hash. + +=back + =cut -sub GetLatestSerials{ +sub GetLatestSerials { my ($subscriptionid,$limit) = @_; my $dbh = C4::Context->dbh; # status = 2 is "arrived" my $strsth=qq( - SELECT serialid,serialseq, status, planneddate - FROM serial - WHERE subscriptionid = ? - AND (status =2 or status=4) + SELECT serialid,serialseq, status, planneddate + FROM serial + WHERE subscriptionid = ? + AND (status =2 or status=4) ORDER BY planneddate DESC LIMIT 0,$limit ); my $sth=$dbh->prepare($strsth); @@ -585,96 +542,494 @@ sub GetLatestSerials{ $line->{"planneddate"} = format_date($line->{"planneddate"}); push @serials,$line; } - my $query = qq( - SELECT count(*) - FROM serial - WHERE subscriptionid=? - ); - $sth=$dbh->prepare($query); - $sth->execute($subscriptionid); - my ($totalissues) = $sth->fetchrow; +# my $query = qq| +# SELECT count(*) +# FROM serial +# WHERE subscriptionid=? +# |; +# $sth=$dbh->prepare($query); +# $sth->execute($subscriptionid); +# my ($totalissues) = $sth->fetchrow; return \@serials; } -=item ModSerialStatus - ModSerialStatus($serialid,$serialseq, $publisheddate,$planneddate,$status,$notes) - - this function modify the serial status + +=head2 GetDistributedTo + +=over 4 + +$distributedto=GetDistributedTo($subscriptionid) +This function select the old previous value of distributedto in the database. + +=back =cut -sub ModSerialStatus { - my ($serialid,$serialseq, $publisheddate,$planneddate,$status,$notes)=@_; - # warn "($serialid,$serialseq,$planneddate,$status)"; - # 1st, get previous status : if we change from "waited" to something else, then we will have to create a new "waited" entry +sub GetDistributedTo { my $dbh = C4::Context->dbh; - my $query = qq( - SELECT subscriptionid,status - FROM serial - WHERE serialid=? - ); + my $distributedto; + my $subscriptionid = @_; + my $query = qq| + SELECT distributedto + FROM subscription + WHERE subscriptionid=? + |; my $sth = $dbh->prepare($query); - $sth->execute($serialid); - my ($subscriptionid,$oldstatus) = $sth->fetchrow; - # change status & update subscriptionhistory - if ($status eq 6){ - DelIssue($serialseq, $subscriptionid) - } else { - my $query = qq( - UPDATE serial - SET serialseq=?,publisheddate=?,planneddate=?,status=?,notes=? - WHERE serialid = ? - ); - $sth = $dbh->prepare($query); - $sth->execute($serialseq,$publisheddate,$planneddate,$status,$notes,$serialid); - my $query = qq( - SELECT missinglist,recievedlist - FROM subscriptionhistory - WHERE subscriptionid=? - ); - $sth = $dbh->prepare($query); - $sth->execute($subscriptionid); - my ($missinglist,$recievedlist) = $sth->fetchrow; - if ($status eq 2) { - $recievedlist .= ",$serialseq"; - } - $missinglist .= ",$serialseq" if ($status eq 4) ; - $missinglist .= ",not issued $serialseq" if ($status eq 5); - $query qq( - UPDATE subscriptionhistory - SET recievedlist=?, missinglist=? - WHERE subscriptionid=? - ); - $sth=$dbh->prepare($query); - $sth->execute($recievedlist,$missinglist,$subscriptionid); - } - # create new waited entry if needed (ie : was a "waited" and has changed) - if ($oldstatus eq 1 && $status ne 1) { - my $query = qq( - SELECT * - FROM subscription - WHERE subscriptionid = ? - ); - $sth = $dbh->prepare($query); - $sth->execute($subscriptionid); - my $val = $sth->fetchrow_hashref; - # next issue number - my ($newserialseq,$newlastvalue1,$newlastvalue2,$newlastvalue3,$newinnerloop1,$newinnerloop2,$newinnerloop3) = GetNextSeq($val); - # next date (calculated from actual date & frequency parameters) - my $nextpublisheddate = GetNextDate($publisheddate,$val); - NewIssue($newserialseq, $subscriptionid, $val->{'biblionumber'}, 1, $nextpublisheddate,0); - my $query = qq| - UPDATE subscription - SET lastvalue1=?, lastvalue2=?, lastvalue3=?, - innerloop1=?, innerloop2=?, innerloop3=? + $sth->execute($subscriptionid); + return ($distributedto) = $sth->fetchrow; +} + +=head2 GetNextSeq + +=over 4 + +GetNextSeq($val) +$val is a hashref containing all the attributes of the table 'subscription' +This function get the next issue for the subscription given on input arg +return: +all the input params updated. + +=back + +=cut +sub GetNextSeq { + my ($val) =@_; + my ($calculated,$newlastvalue1,$newlastvalue2,$newlastvalue3,$newinnerloop1,$newinnerloop2,$newinnerloop3); + $calculated = $val->{numberingmethod}; +# calculate the (expected) value of the next issue recieved. + $newlastvalue1 = $val->{lastvalue1}; +# check if we have to increase the new value. + $newinnerloop1 = $val->{innerloop1}+1; + $newinnerloop1=0 if ($newinnerloop1 >= $val->{every1}); + $newlastvalue1 += $val->{add1} if ($newinnerloop1<1); # <1 to be true when 0 or empty. + $newlastvalue1=$val->{setto1} if ($newlastvalue1>$val->{whenmorethan1}); # reset counter if needed. + $calculated =~ s/\{X\}/$newlastvalue1/g; + + $newlastvalue2 = $val->{lastvalue2}; +# check if we have to increase the new value. + $newinnerloop2 = $val->{innerloop2}+1; + $newinnerloop2=0 if ($newinnerloop2 >= $val->{every2}); + $newlastvalue2 += $val->{add2} if ($newinnerloop2<1); # <1 to be true when 0 or empty. + $newlastvalue2=$val->{setto2} if ($newlastvalue2>$val->{whenmorethan2}); # reset counter if needed. + $calculated =~ s/\{Y\}/$newlastvalue2/g; + + $newlastvalue3 = $val->{lastvalue3}; +# check if we have to increase the new value. + $newinnerloop3 = $val->{innerloop3}+1; + $newinnerloop3=0 if ($newinnerloop3 >= $val->{every3}); + $newlastvalue3 += $val->{add3} if ($newinnerloop3<1); # <1 to be true when 0 or empty. + $newlastvalue3=$val->{setto3} if ($newlastvalue3>$val->{whenmorethan3}); # reset counter if needed. + $calculated =~ s/\{Z\}/$newlastvalue3/g; + return ($calculated,$newlastvalue1,$newlastvalue2,$newlastvalue3,$newinnerloop1,$newinnerloop2,$newinnerloop3); +} + +=head2 GetNextDate + +=over 4 + +$resultdate = GetNextDate($planneddate,$subscription) + +this function get the date after $planneddate. +return: +the date on ISO format. + +=back + +=cut +sub GetNextDate(@) { + my ($planneddate,$subscription) = @_; + my $resultdate; + if ($subscription->{periodicity} == 1) { + $resultdate=DateCalc($planneddate,"1 day"); + } + if ($subscription->{periodicity} == 2) { + $resultdate=DateCalc($planneddate,"1 week"); + } + if ($subscription->{periodicity} == 3) { + $resultdate=DateCalc($planneddate,"2 weeks"); + } + if ($subscription->{periodicity} == 4) { + $resultdate=DateCalc($planneddate,"3 weeks"); + } + if ($subscription->{periodicity} == 5) { + $resultdate=DateCalc($planneddate,"1 month"); + } + if ($subscription->{periodicity} == 6) { + $resultdate=DateCalc($planneddate,"2 months"); + } + if ($subscription->{periodicity} == 7) { + $resultdate=DateCalc($planneddate,"3 months"); + } + if ($subscription->{periodicity} == 8) { + $resultdate=DateCalc($planneddate,"3 months"); + } + if ($subscription->{periodicity} == 9) { + $resultdate=DateCalc($planneddate,"6 months"); + } + if ($subscription->{periodicity} == 10) { + $resultdate=DateCalc($planneddate,"1 year"); + } + if ($subscription->{periodicity} == 11) { + $resultdate=DateCalc($planneddate,"2 years"); + } + return format_date_in_iso($resultdate); +} + +=head2 GetSeq + +=over 4 + +$calculated = GetSeq($val) +$val is a hashref containing all the attributes of the table 'subscription' +this function transforms {X},{Y},{Z} to 150,0,0 for example. +return: +the sequence in integer format + +=back + +=cut +sub GetSeq { + my ($val) =@_; + my $calculated = $val->{numberingmethod}; + my $x=$val->{'lastvalue1'}; + $calculated =~ s/\{X\}/$x/g; + my $y=$val->{'lastvalue2'}; + $calculated =~ s/\{Y\}/$y/g; + my $z=$val->{'lastvalue3'}; + $calculated =~ s/\{Z\}/$z/g; + return $calculated; +} + +=head2 GetSubscriptionExpirationDate + +=over 4 + +$sensddate = GetSubscriptionExpirationDate($subscriptionid) + +this function return the expiration date for a subscription given on input args. + +return +the enddate + +=back + +=cut +sub GetSubscriptionExpirationDate { + my ($subscriptionid) = @_; + my $dbh = C4::Context->dbh; + my $subscription = GetSubscription($subscriptionid); + my $enddate=$subscription->{startdate}; + # we don't do the same test if the subscription is based on X numbers or on X weeks/months + if ($subscription->{numberlength}) { + #calculate the date of the last issue. + for (my $i=1;$i<=$subscription->{numberlength};$i++) { + $enddate = GetNextDate($enddate,$subscription); + } + } + else { + $enddate = DateCalc(format_date_in_iso($subscription->{startdate}),$subscription->{monthlength}." months") if ($subscription->{monthlength}); + $enddate = DateCalc(format_date_in_iso($subscription->{startdate}),$subscription->{weeklength}." weeks") if ($subscription->{weeklength}); + } + return $enddate; +} + +=head2 CountSubscriptionFromBiblionumber + +=over 4 + +$subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber) +this count the number of subscription for a biblionumber given. +return : +the number of subscriptions with biblionumber given on input arg. + +=back + +=cut +sub CountSubscriptionFromBiblionumber { + my ($biblionumber) = @_; + my $dbh = C4::Context->dbh; + my $query = qq| + SELECT count(*) + FROM subscription + WHERE biblionumber=? + |; + my $sth = $dbh->prepare($query); + $sth->execute($biblionumber); + my $subscriptionsnumber = $sth->fetchrow; + return $subscriptionsnumber; +} + + +=head2 ModSubscriptionHistory + +=over 4 + +ModSubscriptionHistory($subscriptionid,$histstartdate,$enddate,$recievedlist,$missinglist,$opacnote,$librariannote); + +this function modify the history of a subscription. Put your new values on input arg. + +=back + +=cut +sub ModSubscriptionHistory { + my ($subscriptionid,$histstartdate,$enddate,$recievedlist,$missinglist,$opacnote,$librariannote)=@_; + my $dbh=C4::Context->dbh; + my $query = qq( + UPDATE subscriptionhistory + SET histstartdate=?,enddate=?,recievedlist=?,missinglist=?,opacnote=?,librariannote=? + WHERE subscriptionid=? + ); + my $sth = $dbh->prepare($query); + $recievedlist =~ s/^,//g; + $missinglist =~ s/^,//g; + $opacnote =~ s/^,//g; + $sth->execute($histstartdate,$enddate,$recievedlist,$missinglist,$opacnote,$librariannote,$subscriptionid); +} + +=head2 ModSerialStatus + +=over 4 + +ModSerialStatus($serialid,$serialseq, $publisheddate,$planneddate,$status,$notes) + +This function modify the serial status. Serial status is a number.(eg 2 is "arrived") +Note : if we change from "waited" to something else,then we will have to create a new "waited" entry + +=back + +=cut +sub ModSerialStatus { + my ($serialid,$serialseq, $publisheddate,$planneddate,$status,$notes)=@_; + # 1st, get previous status : + my $dbh = C4::Context->dbh; + my $query = qq| + SELECT subscriptionid,status + FROM serial + WHERE serialid=? + |; + my $sth = $dbh->prepare($query); + $sth->execute($serialid); + my ($subscriptionid,$oldstatus) = $sth->fetchrow; + # change status & update subscriptionhistory + if ($status eq 6){ + DelIssue($serialseq, $subscriptionid) + } else { + my $query = qq( + UPDATE serial + SET serialseq=?,publisheddate=?,planneddate=?,status=?,notes=? + WHERE serialid = ? + ); + $sth = $dbh->prepare($query); + $sth->execute($serialseq,$publisheddate,$planneddate,$status,$notes,$serialid); + my $query = qq( + SELECT missinglist,recievedlist + FROM subscriptionhistory + WHERE subscriptionid=? + ); + $sth = $dbh->prepare($query); + $sth->execute($subscriptionid); + my ($missinglist,$recievedlist) = $sth->fetchrow; + if ($status eq 2) { + $recievedlist .= ",$serialseq"; + } + $missinglist .= ",$serialseq" if ($status eq 4) ; + $missinglist .= ",not issued $serialseq" if ($status eq 5); + my $query = qq( + UPDATE subscriptionhistory + SET recievedlist=?, missinglist=? + WHERE subscriptionid=? + ); + $sth=$dbh->prepare($query); + $sth->execute($recievedlist,$missinglist,$subscriptionid); + } + # create new waited entry if needed (ie : was a "waited" and has changed) + if ($oldstatus eq 1 && $status ne 1) { + my $query = qq( + SELECT * + FROM subscription + WHERE subscriptionid = ? + ); + $sth = $dbh->prepare($query); + $sth->execute($subscriptionid); + my $val = $sth->fetchrow_hashref; + # next issue number + my ($newserialseq,$newlastvalue1,$newlastvalue2,$newlastvalue3,$newinnerloop1,$newinnerloop2,$newinnerloop3) = GetNextSeq($val); + # next date (calculated from actual date & frequency parameters) + my $nextpublisheddate = GetNextDate($publisheddate,$val); + NewIssue($newserialseq, $subscriptionid, $val->{'biblionumber'}, 1, $nextpublisheddate,0); + my $query = qq| + UPDATE subscription + SET lastvalue1=?, lastvalue2=?, lastvalue3=?, + innerloop1=?, innerloop2=?, innerloop3=? WHERE subscriptionid = ? |; - $sth = $dbh->prepare($query); - $sth->execute($newlastvalue1,$newlastvalue2,$newlastvalue3,$newinnerloop1,$newinnerloop2,$newinnerloop3,$subscriptionid); - } + $sth = $dbh->prepare($query); + $sth->execute($newlastvalue1,$newlastvalue2,$newlastvalue3,$newinnerloop1,$newinnerloop2,$newinnerloop3,$subscriptionid); + } +} + +=head2 ModSubscription + +=over 4 + +this function modify a subscription. Put all new values on input args. + +=back + +=cut +sub ModSubscription { + my ($auser,$aqbooksellerid,$cost,$aqbudgetid,$startdate, + $periodicity,$dow,$numberlength,$weeklength,$monthlength, + $add1,$every1,$whenmorethan1,$setto1,$lastvalue1,$innerloop1, + $add2,$every2,$whenmorethan2,$setto2,$lastvalue2,$innerloop2, + $add3,$every3,$whenmorethan3,$setto3,$lastvalue3,$innerloop3, + $numberingmethod, $status, $biblionumber, $notes, $letter, $subscriptionid)= @_; + my $dbh = C4::Context->dbh; + my $query = qq| + UPDATE subscription + SET librarian=?, aqbooksellerid=?,cost=?,aqbudgetid=?,startdate=?, + periodicity=?,dow=?,numberlength=?,weeklength=?,monthlength=?, + add1=?,every1=?,whenmorethan1=?,setto1=?,lastvalue1=?,innerloop1=?, + add2=?,every2=?,whenmorethan2=?,setto2=?,lastvalue2=?,innerloop2=?, + add3=?,every3=?,whenmorethan3=?,setto3=?,lastvalue3=?,innerloop3=?, + numberingmethod=?, status=?, biblionumber=?, notes=?, letter=? + WHERE subscriptionid = ? + |; + my $sth=$dbh->prepare($query); + $sth->execute($auser,$aqbooksellerid,$cost,$aqbudgetid,$startdate, + $periodicity,$dow,$numberlength,$weeklength,$monthlength, + $add1,$every1,$whenmorethan1,$setto1,$lastvalue1,$innerloop1, + $add2,$every2,$whenmorethan2,$setto2,$lastvalue2,$innerloop2, + $add3,$every3,$whenmorethan3,$setto3,$lastvalue3,$innerloop3, + $numberingmethod, $status, $biblionumber, $notes, $letter, $subscriptionid); + $sth->finish; +} + + +=head2 NewSubscription + +=over 4 + +$subscriptionid = &NewSubscription($auser,$aqbooksellerid,$cost,$aqbudgetid,$biblionumber, + $startdate,$periodicity,$dow,$numberlength,$weeklength,$monthlength, + $add1,$every1,$whenmorethan1,$setto1,$lastvalue1,$innerloop1, + $add2,$every2,$whenmorethan2,$setto2,$lastvalue2,$innerloop2, + $add3,$every3,$whenmorethan3,$setto3,$lastvalue3,$innerloop3, + $numberingmethod, $status, $notes) + +Create a new subscription with value given on input args. + +return : +the id of this new subscription + +=back + +=cut +sub NewSubscription { + my ($auser,$aqbooksellerid,$cost,$aqbudgetid,$biblionumber, + $startdate,$periodicity,$dow,$numberlength,$weeklength,$monthlength, + $add1,$every1,$whenmorethan1,$setto1,$lastvalue1,$innerloop1, + $add2,$every2,$whenmorethan2,$setto2,$lastvalue2,$innerloop2, + $add3,$every3,$whenmorethan3,$setto3,$lastvalue3,$innerloop3, + $numberingmethod, $status, $notes) = @_; + my $dbh = C4::Context->dbh; +#save subscription (insert into database) + my $query = qq| + INSERT INTO subscription + (librarian,aqbooksellerid,cost,aqbudgetid,biblionumber, + startdate,periodicity,dow,numberlength,weeklength,monthlength, + add1,every1,whenmorethan1,setto1,lastvalue1,innerloop1, + add2,every2,whenmorethan2,setto2,lastvalue2,innerloop2, + add3,every3,whenmorethan3,setto3,lastvalue3,innerloop3, + numberingmethod, status, notes) + VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) + |; + my $sth=$dbh->prepare($query); + $sth->execute( + $auser,$aqbooksellerid,$cost,$aqbudgetid,$biblionumber, + format_date_in_iso($startdate),$periodicity,$dow,$numberlength,$weeklength,$monthlength, + $add1,$every1,$whenmorethan1,$setto1,$lastvalue1,$innerloop1, + $add2,$every2,$whenmorethan2,$setto2,$lastvalue2,$innerloop2, + $add3,$every3,$whenmorethan3,$setto3,$lastvalue3,$innerloop3, + $numberingmethod, $status, $notes); + +#then create the 1st waited number + my $subscriptionid = $dbh->{'mysql_insertid'}; + my $query = qq( + INSERT INTO subscriptionhistory + (biblionumber, subscriptionid, histstartdate, enddate, missinglist, recievedlist, opacnote, librariannote) + VALUES (?,?,?,?,?,?,?,?) + ); + $sth = $dbh->prepare($query); + $sth->execute($biblionumber, $subscriptionid, format_date_in_iso($startdate), 0, "", "", "", $notes); + +# reread subscription to get a hash (for calculation of the 1st issue number) + my $query = qq( + SELECT * + FROM subscription + WHERE subscriptionid = ? + ); + $sth = $dbh->prepare($query); + $sth->execute($subscriptionid); + my $val = $sth->fetchrow_hashref; + +# calculate issue number + my $serialseq = GetSeq($val); + my $query = qq| + INSERT INTO serial + (serialseq,subscriptionid,biblionumber,status, planneddate) + VALUES (?,?,?,?,?) + |; + $sth = $dbh->prepare($query); + $sth->execute($serialseq, $subscriptionid, $val->{'biblionumber'}, 1, format_date_in_iso($startdate)); + return $subscriptionid; +} + + +=head2 ReNewSubscription + +=over 4 + +ReNewSubscription($subscriptionid,$user,$startdate,$numberlength,$weeklength,$monthlength,$note) + +this function renew a subscription with values given on input args. + +=back + +=cut +sub ReNewSubscription { + my ($subscriptionid,$user,$startdate,$numberlength,$weeklength,$monthlength,$note) = @_; + my $dbh = C4::Context->dbh; + my $subscription = GetSubscription($subscriptionid); + my $query = qq| + SELECT * + FROM biblio,biblioitems + WHERE biblio.biblionumber=biblioitems.biblionumber + AND biblio.biblionumber=? + |; + 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}); + # renew subscription + my $query = qq| + UPDATE subscription + SET startdate=?,numberlength=?,weeklength=?,monthlength=? + WHERE subscriptionid=? + |; + $sth=$dbh->prepare($query); + $sth->execute(format_date_in_iso($startdate),$numberlength,$weeklength,$monthlength, $subscriptionid); } -=item NewIssue - NewIssue($serialseq,$subscriptionid,$biblionumber,$status, $publisheddate, $planneddate) - - Create a new issue stored on the database. + + +=head2 NewIssue + +=over 4 + +NewIssue($serialseq,$subscriptionid,$biblionumber,$status, $publisheddate, $planneddate) + +Create a new issue stored on the database. +Note : we have to update the recievedlist and missinglist on subscriptionhistory for this subscription. + +=back =cut sub NewIssue { @@ -682,7 +1037,7 @@ sub NewIssue { my $dbh = C4::Context->dbh; my $query = qq| INSERT INTO serial - (serialseq,subscriptionid,biblionumber,status,publisheddate,planneddate) + (serialseq,subscriptionid,biblionumber,status,publisheddate,planneddate) VALUES (?,?,?,?,?,?) |; my $sth = $dbh->prepare($query); @@ -710,11 +1065,19 @@ sub NewIssue { $sth->execute($recievedlist,$missinglist,$subscriptionid); } -=item ItemizeSerials +=head2 ItemizeSerials + +=over 4 + +ItemizeSerials($serialid, $info); +$info is a hashref containing barcode branch, itemcallnumber, status, location +$serialid the serialid +return : +1 if the itemize is a succes. +0 and @error else. @error containts the list of errors found. + +=back - ItemizeSerials($serialid, $info); - $info is a hashref containing barcode branch, itemcallnumber, status, location - $serialid the serialid =cut sub ItemizeSerials { my ($serialid, $info) =@_; @@ -823,119 +1186,20 @@ sub ItemizeSerials { return (0,@errors); } } -=item DelIssue - DelIssue($serialseq,$subscriptionid) -=cut -sub DelIssue { - my ($serialseq,$subscriptionid) = @_; - my $dbh = C4::Context->dbh; - my $query = qq| - DELETE FROM serial - WHERE serialseq= ? - AND subscriptionid= ? - |; - my $sth = $dbh->prepare($query); - $sth->execute($serialseq,$subscriptionid); -} -=item GetNextDate - $resultdate = GetNextDate($planneddate,$subscription) - - this function get the date after $planneddate. - return: - the next date in iso format. -=cut -sub GetNextDate(@) { - my ($planneddate,$subscription) = @_; - my $resultdate; - if ($subscription->{periodicity} == 1) { - $resultdate=DateCalc($planneddate,"1 day"); - } - if ($subscription->{periodicity} == 2) { - $resultdate=DateCalc($planneddate,"1 week"); - } - if ($subscription->{periodicity} == 3) { - $resultdate=DateCalc($planneddate,"2 weeks"); - } - if ($subscription->{periodicity} == 4) { - $resultdate=DateCalc($planneddate,"3 weeks"); - } - if ($subscription->{periodicity} == 5) { - $resultdate=DateCalc($planneddate,"1 month"); - } - if ($subscription->{periodicity} == 6) { - $resultdate=DateCalc($planneddate,"2 months"); - } - if ($subscription->{periodicity} == 7) { - $resultdate=DateCalc($planneddate,"3 months"); - } - if ($subscription->{periodicity} == 8) { - $resultdate=DateCalc($planneddate,"3 months"); - } - if ($subscription->{periodicity} == 9) { - $resultdate=DateCalc($planneddate,"6 months"); - } - if ($subscription->{periodicity} == 10) { - $resultdate=DateCalc($planneddate,"1 year"); - } - if ($subscription->{periodicity} == 11) { - $resultdate=DateCalc($planneddate,"2 years"); - } - return format_date_in_iso($resultdate); -} -=item GetSeq - GetSeq($val) -=cut -sub GetSeq { - my ($val) =@_; - my $calculated = $val->{numberingmethod}; - my $x=$val->{'lastvalue1'}; - $calculated =~ s/\{X\}/$x/g; - my $y=$val->{'lastvalue2'}; - $calculated =~ s/\{Y\}/$y/g; - my $z=$val->{'lastvalue3'}; - $calculated =~ s/\{Z\}/$z/g; - return $calculated; -} -=item GetNextSeq - GetNextSeq($val) -=cut -sub GetNextSeq { - my ($val) =@_; - my ($calculated,$newlastvalue1,$newlastvalue2,$newlastvalue3,$newinnerloop1,$newinnerloop2,$newinnerloop3); - $calculated = $val->{numberingmethod}; - # calculate the (expected) value of the next issue recieved. - $newlastvalue1 = $val->{lastvalue1}; - # check if we have to increase the new value. - $newinnerloop1 = $val->{innerloop1}+1; - $newinnerloop1=0 if ($newinnerloop1 >= $val->{every1}); - $newlastvalue1 += $val->{add1} if ($newinnerloop1<1); # <1 to be true when 0 or empty. - $newlastvalue1=$val->{setto1} if ($newlastvalue1>$val->{whenmorethan1}); # reset counter if needed. - $calculated =~ s/\{X\}/$newlastvalue1/g; +=head2 HasSubscriptionExpired - $newlastvalue2 = $val->{lastvalue2}; - # check if we have to increase the new value. - $newinnerloop2 = $val->{innerloop2}+1; - $newinnerloop2=0 if ($newinnerloop2 >= $val->{every2}); - $newlastvalue2 += $val->{add2} if ($newinnerloop2<1); # <1 to be true when 0 or empty. - $newlastvalue2=$val->{setto2} if ($newlastvalue2>$val->{whenmorethan2}); # reset counter if needed. - $calculated =~ s/\{Y\}/$newlastvalue2/g; +=over 4 + +1 or 0 = HasSubscriptionExpired($subscriptionid) - $newlastvalue3 = $val->{lastvalue3}; - # check if we have to increase the new value. - $newinnerloop3 = $val->{innerloop3}+1; - $newinnerloop3=0 if ($newinnerloop3 >= $val->{every3}); - $newlastvalue3 += $val->{add3} if ($newinnerloop3<1); # <1 to be true when 0 or empty. - $newlastvalue3=$val->{setto3} if ($newlastvalue3>$val->{whenmorethan3}); # reset counter if needed. - $calculated =~ s/\{Z\}/$newlastvalue3/g; - return ($calculated,$newlastvalue1,$newlastvalue2,$newlastvalue3,$newinnerloop1,$newinnerloop2,$newinnerloop3); -} -=item HasSubscriptionExpired - 1|0 = HasSubscriptionExpired($subscriptionid) - the subscription has expired when the next issue to arrive is out of subscription limit. + return : - 1 if true, 0 if false. +1 if true, 0 if false. + +=back + =cut sub HasSubscriptionExpired { my ($subscriptionid) = @_; @@ -973,60 +1237,70 @@ sub HasSubscriptionExpired { return 0; } } -=item SubscriptionExpirationDate -$sensddate = SubscriptionExpirationDate($subscriptionid) -this function return the expiration date for a subscription id given on input args. +=head2 SetDistributedto + +=over 4 + +SetDistributedto($distributedto,$subscriptionid); +This function update the value of distributedto for a subscription given on input arg. + +=back + +=cut +sub SetDistributedto { + my ($distributedto,$subscriptionid) = @_; + my $dbh = C4::Context->dbh; + my $query = qq| + UPDATE subscription + SET distributedto=? + WHERE subscriptionid=? + |; + my $sth = $dbh->prepare($query); + $sth->execute($distributedto,$subscriptionid); +} + +=head2 DelSubscription + +=over 4 + +DelSubscription($subscriptionid) +this function delete the subscription which has $subscriptionid as id. + +=back -return - the subscriptionid. =cut -sub SubscriptionExpirationDate { +sub DelSubscription { my ($subscriptionid) = @_; my $dbh = C4::Context->dbh; - my $subscription = GetSubscription($subscriptionid); - my $enddate=$subscription->{startdate}; - # we don't do the same test if the subscription is based on X numbers or on X weeks/months - if ($subscription->{numberlength}) { - #calculate the date of the last issue. - for (my $i=1;$i<=$subscription->{numberlength};$i++) { - $enddate = GetNextDate($enddate,$subscription); - } - } else { - $enddate = DateCalc(format_date_in_iso($subscription->{startdate}),$subscription->{monthlength}." months") if ($subscription->{monthlength}); - $enddate = DateCalc(format_date_in_iso($subscription->{startdate}),$subscription->{weeklength}." weeks") if ($subscription->{weeklength}); - } - return $enddate; + $subscriptionid=$dbh->quote($subscriptionid); + $dbh->do("DELETE FROM subscription WHERE subscriptionid=$subscriptionid"); + $dbh->do("DELETE FROM subscriptionhistory WHERE subscriptionid=$subscriptionid"); + $dbh->do("DELETE FROM serial WHERE subscriptionid=$subscriptionid"); } -=item SubscriptionReNew -SubscriptionReNew($subscriptionid,$user,$startdate,$numberlength,$weeklength,$monthlength,$note) +=head2 DelIssue + +=over 4 + +DelIssue($serialseq,$subscriptionid) +this function delete an issue which has $serialseq and $subscriptionid given on input arg. + +=back -this function renew a subscription. =cut -sub SubscriptionReNew { - my ($subscriptionid,$user,$startdate,$numberlength,$weeklength,$monthlength,$note) = @_; +sub DelIssue { + my ($serialseq,$subscriptionid) = @_; my $dbh = C4::Context->dbh; - my $subscription = GetSubscription($subscriptionid); my $query = qq| - SELECT * - FROM biblio,biblioitems - WHERE biblio.biblionumber=biblioitems.biblionumber - AND biblio.biblionumber=? + DELETE FROM serial + WHERE serialseq= ? + AND 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}); - # renew subscription - my $query = qq| - UPDATE subscription - SET startdate=?,numberlength=?,weeklength=?,monthlength=? - WHERE subscriptionid=? - |; - $sth=$dbh->prepare($query); - $sth->execute(format_date_in_iso($startdate),$numberlength,$weeklength,$monthlength, $subscriptionid); + $sth->execute($serialseq,$subscriptionid); } + END { } # module clean-up code here (global destructor) 1; \ No newline at end of file -- 2.39.5