- my $subscription = GetSubscription($subscriptionid);
- my $expirationdate = GetExpirationDate($subscriptionid);
- my $sth =
- $dbh->prepare(
- "select max(planneddate) from serial where subscriptionid=?");
- $sth->execute($subscriptionid);
- my ($res) = $sth->fetchrow ;
-# warn "date expiration : ".$expirationdate." date courante ".$res;
- my @res=split /-/,$res;
- my @endofsubscriptiondate=split/-/,$expirationdate;
- my $per = $subscription->{'periodicity'};
- my $x;
- if ( $per == 1 ) {$x=7;}
- if ( $per == 2 ) {$x=7; }
- if ( $per == 3 ) {$x=14;}
- if ( $per == 4 ) { $x = 21; }
- if ( $per == 5 ) { $x = 31; }
- if ( $per == 6 ) { $x = 62; }
- if ( $per == 7 || $per == 8 ) { $x = 93; }
- if ( $per == 9 ) { $x = 190; }
- if ( $per == 10 ) { $x = 365; }
- if ( $per == 11 ) { $x = 730; }
- my @datebeforeend=Add_Delta_Days( $endofsubscriptiondate[0],$endofsubscriptiondate[1],$endofsubscriptiondate[2],
- - (3 * $x)) if (@endofsubscriptiondate);
- # warn "DATE BEFORE END: $datebeforeend";
- return 1 if ( @res &&
- (@datebeforeend &&
- Delta_Days($res[0],$res[1],$res[2],
- $datebeforeend[0],$datebeforeend[1],$datebeforeend[2]) <= 0) &&
- (@endofsubscriptiondate &&
- Delta_Days($res[0],$res[1],$res[2],
- $endofsubscriptiondate[0],$endofsubscriptiondate[1],$endofsubscriptiondate[2]) >= 0) );
- return 0;
-}
-
-=head2 old_newsubscription
-
-=over 4
-
-($subscriptionid) = &old_newsubscription($auser,$aqbooksellerid,$cost,$aqbudgetid,$biblionumber,
- $startdate,$periodicity,$firstacquidate,$dow,$irregularity,$numberpattern,$numberlength,$weeklength,$monthlength,
- $add1,$every1,$whenmorethan1,$setto1,$lastvalue1,
- $add2,$every2,$whenmorethan2,$setto2,$lastvalue2,
- $add3,$every3,$whenmorethan3,$setto3,$lastvalue3,
- $numberingmethod, $status, $callnumber, $notes, $hemisphere)
-
-this function is similar to the NewSubscription subroutine but has a few different
-values passed in
-$firstacquidate - date of first serial issue to arrive
-$irregularity - the issues not expected separated by a '|'
-- eg. monthly issue but not expecting issue for june and july would have $irregularity of '6|7'
-$numberpattern - the number for an array of labels to reconstruct the javascript correctly in the
- subscription-add.tmpl file
-$callnumber - display the callnumber of the serial
-$hemisphere - either 2 = southern hemisphere or 1 = northern hemisphere - used for quarterly serials
-
-return :
-the $subscriptionid number of the new subscription
-
-=back
-
-=cut
-
-sub old_newsubscription {
- my (
- $auser, $aqbooksellerid, $cost, $aqbudgetid,
- $biblionumber, $startdate, $periodicity, $firstacquidate,
- $dow, $irregularity, $numberpattern, $numberlength,
- $weeklength, $monthlength, $add1, $every1,
- $whenmorethan1, $setto1, $lastvalue1, $add2,
- $every2, $whenmorethan2, $setto2, $lastvalue2,
- $add3, $every3, $whenmorethan3, $setto3,
- $lastvalue3, $numberingmethod, $status, $callnumber,
- $notes, $hemisphere
- ) = @_;
- my $dbh = C4::Context->dbh;
-
- #save subscription
- my $sth = $dbh->prepare(
-"insert into subscription (librarian,aqbooksellerid,cost,aqbudgetid,biblionumber,
- startdate,periodicity,firstacquidate,dow,irregularity,numberpattern,numberlength,weeklength,monthlength,
- add1,every1,whenmorethan1,setto1,lastvalue1,
- add2,every2,whenmorethan2,setto2,lastvalue2,
- add3,every3,whenmorethan3,setto3,lastvalue3,
- numberingmethod, status, callnumber, notes, hemisphere) values
- (?,?,?,?,?,?,?,?,?,?,?,
- ?,?,?,?,?,?,?,?,?,?,?,
- ?,?,?,?,?,?,?,?,?,?,?,?)"
- );
- $sth->execute(
- $auser, $aqbooksellerid,
- $cost, $aqbudgetid,
- $biblionumber, format_date_in_iso($startdate),
- $periodicity, format_date_in_iso($firstacquidate),
- $dow, $irregularity,
- $numberpattern, $numberlength,
- $weeklength, $monthlength,
- $add1, $every1,
- $whenmorethan1, $setto1,
- $lastvalue1, $add2,
- $every2, $whenmorethan2,
- $setto2, $lastvalue2,
- $add3, $every3,
- $whenmorethan3, $setto3,
- $lastvalue3, $numberingmethod,
- $status, $callnumber,
- $notes, $hemisphere
- );
-
- #then create the 1st waited number
- my $subscriptionid = $dbh->{'mysql_insertid'};
- my $enddate = GetExpirationDate($subscriptionid);
-
- $sth =
- $dbh->prepare(
-"insert into subscriptionhistory (biblionumber, subscriptionid, histstartdate, enddate, missinglist, recievedlist, opacnote, librariannote) values (?,?,?,?,?,?,?,?)"
- );
- $sth->execute(
- $biblionumber, $subscriptionid,
- format_date_in_iso($startdate),
- format_date_in_iso($enddate),
- "", "", "", $notes
- );
-
- # reread subscription to get a hash (for calculation of the 1st issue number)
- $sth =
- $dbh->prepare("select * from subscription where subscriptionid = ? ");
- $sth->execute($subscriptionid);
- my $val = $sth->fetchrow_hashref;
-
- # calculate issue number
- my $serialseq = GetSeq($val);
- $sth =
- $dbh->prepare(
-"insert into serial (serialseq,subscriptionid,biblionumber,status, planneddate) values (?,?,?,?,?)"
- );
- $sth->execute( $serialseq, $subscriptionid, $val->{'biblionumber'},
- 1, format_date_in_iso($startdate) );
- return $subscriptionid;
-}
-
-=head2 old_modsubscription
-
-=over 4
-
-($subscriptionid) = &old_modsubscription($auser,$aqbooksellerid,$cost,$aqbudgetid,$biblionumber,
- $startdate,$periodicity,$firstacquidate,$dow,$irregularity,$numberpattern,$numberlength,$weeklength,$monthlength,
- $add1,$every1,$whenmorethan1,$setto1,$lastvalue1,
- $add2,$every2,$whenmorethan2,$setto2,$lastvalue2,
- $add3,$every3,$whenmorethan3,$setto3,$lastvalue3,
- $numberingmethod, $status, $callnumber, $notes, $hemisphere, $subscriptionid)
-
-this function is similar to the ModSubscription subroutine but has a few different
-values passed in
-$firstacquidate - date of first serial issue to arrive
-$irregularity - the issues not expected separated by a '|'
-- eg. monthly issue but not expecting issue for june and july would have $irregularity of '6|7'
-$numberpattern - the number for an array of labels to reconstruct the javascript correctly in the
- subscription-add.tmpl file
-$callnumber - display the callnumber of the serial
-$hemisphere - either 2 = southern hemisphere or 1 = northern hemisphere - used for quarterly serials
-
-=back
-
-=cut
-
-sub old_modsubscription {
- my (
- $auser, $aqbooksellerid, $cost, $aqbudgetid,
- $startdate, $periodicity, $firstacquidate, $dow,
- $irregularity, $numberpattern, $numberlength, $weeklength,
- $monthlength, $add1, $every1, $whenmorethan1,
- $setto1, $lastvalue1, $innerloop1, $add2,
- $every2, $whenmorethan2, $setto2, $lastvalue2,
- $innerloop2, $add3, $every3, $whenmorethan3,
- $setto3, $lastvalue3, $innerloop3, $numberingmethod,
- $status, $biblionumber, $callnumber, $notes,
- $hemisphere, $subscriptionid
- ) = @_;
- my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare(
-"update subscription set librarian=?, aqbooksellerid=?,cost=?,aqbudgetid=?,startdate=?,
- periodicity=?,firstacquidate=?,dow=?,irregularity=?,numberpattern=?,numberlength=?,weeklength=?,monthlength=?,
- add1=?,every1=?,whenmorethan1=?,setto1=?,lastvalue1=?,innerloop1=?,
- add2=?,every2=?,whenmorethan2=?,setto2=?,lastvalue2=?,innerloop2=?,
- add3=?,every3=?,whenmorethan3=?,setto3=?,lastvalue3=?,innerloop3=?,
- numberingmethod=?, status=?, biblionumber=?, callnumber=?, notes=?, hemisphere=? where subscriptionid = ?"
- );
- $sth->execute(
- $auser, $aqbooksellerid, $cost, $aqbudgetid,
- $startdate, $periodicity, $firstacquidate, $dow,
- $irregularity, $numberpattern, $numberlength, $weeklength,
- $monthlength, $add1, $every1, $whenmorethan1,
- $setto1, $lastvalue1, $innerloop1, $add2,
- $every2, $whenmorethan2, $setto2, $lastvalue2,
- $innerloop2, $add3, $every3, $whenmorethan3,
- $setto3, $lastvalue3, $innerloop3, $numberingmethod,
- $status, $biblionumber, $callnumber, $notes,
- $hemisphere, $subscriptionid
- );
- $sth->finish;
-
- $sth =
- $dbh->prepare("select * from subscription where subscriptionid = ? ");
- $sth->execute($subscriptionid);
- my $val = $sth->fetchrow_hashref;
-
- # calculate issue number
- my $serialseq = Get_Seq($val);
- $sth =
- $dbh->prepare("UPDATE serial SET serialseq = ? WHERE subscriptionid = ?");
- $sth->execute( $serialseq, $subscriptionid );
-
- my $enddate = subscriptionexpirationdate($subscriptionid);
- $sth = $dbh->prepare("update subscriptionhistory set enddate=?");
- $sth->execute( format_date_in_iso($enddate) );