From 315a8670f18610d341ecc90bb180bac4d492e655 Mon Sep 17 00:00:00 2001 From: tipaul Date: Mon, 20 Sep 2004 10:16:05 +0000 Subject: [PATCH] some changes in serial management : * in subscription Add, the issue number & date is used to calculate the 1st issue (previously, a "next issue number & date" was applied, meaning you had to enter the number & date of a previous issue) * the "inner loop" used for serials number ({XYZ}) is now shown & can be modified. The innerloop is used for numbering formulas saying "change the number once every 4 times". --- C4/Bull.pm | 54 ++++++++++++------- bull/subscription-add.pl | 12 +++-- bull/subscription-detail.pl | 18 ++++--- .../default/en/bull/subscription-add.tmpl | 29 ++++++---- .../default/en/bull/subscription-detail.tmpl | 12 +++-- 5 files changed, 83 insertions(+), 42 deletions(-) diff --git a/C4/Bull.pm b/C4/Bull.pm index b49f1670dc..e831d8fea7 100755 --- a/C4/Bull.pm +++ b/C4/Bull.pm @@ -82,17 +82,21 @@ sub newsubscription { $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("insert into serial (serialseq,subscriptionid,biblionumber,status, planneddate) values (?,?,?,?,?)"); + $sth->execute($serialseq, $subscriptionid, $val->{'biblionumber'}, 1, format_date_in_iso($startdate)); + # next issue number - my ($newserialseq,$newlastvalue1,$newlastvalue2,$newlastvalue3,$newinnerloop1,$newinnerloop2,$newinnerloop3) = Get_Next_Seq($val); + #my ($newserialseq,$newlastvalue1,$newlastvalue2,$newlastvalue3,$newinnerloop1,$newinnerloop2,$newinnerloop3) = Get_Next_Seq($val); # next date (calculated from actual date & frequency parameters) - my $nextplanneddate = Get_Next_Date($startdate,$val); - $sth = $dbh->prepare("insert into serial (serialseq,subscriptionid,biblionumber,status, planneddate) values (?,?,?,?,?)"); - $sth->execute($newserialseq, $subscriptionid, $val->{'biblionumber'}, 1, $nextplanneddate); - $sth = $dbh->prepare("update subscription set lastvalue1=?, lastvalue2=?,lastvalue3=?, - innerloop1=?,innerloop2=?,innerloop3=? - where subscriptionid = ?"); - $sth->execute($newlastvalue1,$newlastvalue2,$newlastvalue3,$newinnerloop1,$newinnerloop2,$newinnerloop3,$subscriptionid); - $sth->finish; + #my $nextplanneddate = Get_Next_Date($startdate,$val); +# $sth = $dbh->prepare("update subscription set lastvalue1=?, lastvalue2=?,lastvalue3=?, +# innerloop1=?,innerloop2=?,innerloop3=? +# where subscriptionid = ?"); +# $sth->execute($newlastvalue1,$newlastvalue2,$newlastvalue3,$newinnerloop1,$newinnerloop2,$newinnerloop3,$subscriptionid); +# $sth->finish; return $subscriptionid; } sub getsubscription { @@ -122,22 +126,22 @@ sub getsubscriptionfrombiblionumber { sub modsubscription { my ($auser,$aqbooksellerid,$cost,$aqbudgetid,$startdate, $periodicity,$dow,$numberlength,$weeklength,$monthlength, - $add1,$every1,$whenmorethan1,$setto1,$lastvalue1, - $add2,$every2,$whenmorethan2,$setto2,$lastvalue2, - $add3,$every3,$whenmorethan3,$setto3,$lastvalue3, + $add1,$every1,$whenmorethan1,$setto1,$lastvalue1,$innerloop1, + $add2,$every2,$whenmorethan2,$setto2,$lastvalue2,$innerloop2, + $add3,$every3,$whenmorethan3,$setto3,$lastvalue3,$innerloop3, $numberingmethod, $status, $biblionumber, $notes, $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=?, - add2=?,every2=?,whenmorethan2=?,setto2=?,lastvalue2=?, - add3=?,every3=?,whenmorethan3=?,setto3=?,lastvalue3=?, + add1=?,every1=?,whenmorethan1=?,setto1=?,lastvalue1=?,innerloop1=?, + add2=?,every2=?,whenmorethan2=?,setto2=?,lastvalue2=?,innerloop2=?, + add3=?,every3=?,whenmorethan3=?,setto3=?,lastvalue3=?,innerloop3=?, numberingmethod=?, status=?, biblionumber=?, notes=? where subscriptionid = ?"); $sth->execute($auser,$aqbooksellerid,$cost,$aqbudgetid,$startdate, $periodicity,$dow,$numberlength,$weeklength,$monthlength, - $add1,$every1,$whenmorethan1,$setto1,$lastvalue1, - $add2,$every2,$whenmorethan2,$setto2,$lastvalue2, - $add3,$every3,$whenmorethan3,$setto3,$lastvalue3, + $add1,$every1,$whenmorethan1,$setto1,$lastvalue1,$innerloop1, + $add2,$every2,$whenmorethan2,$setto2,$lastvalue2,$innerloop2, + $add3,$every3,$whenmorethan3,$setto3,$lastvalue3,$innerloop3, $numberingmethod, $status, $biblionumber, $notes, $subscriptionid); $sth->finish; @@ -148,7 +152,7 @@ sub getsubscriptions { my $dbh = C4::Context->dbh; my $sth; $sth = $dbh->prepare("select subscription.subscriptionid,biblio.title,biblioitems.issn from subscription,biblio,biblioitems where biblio.biblionumber = biblioitems.biblionumber and biblio.biblionumber=subscription.biblionumber and (biblio.title like ? or biblioitems.issn = ? )"); - $sth->execute($title,$ISSN); + $sth->execute("%$title%",$ISSN); my @results; while (my $line = $sth->fetchrow_hashref) { push @results, $line; @@ -257,6 +261,18 @@ sub Get_Next_Date(@) { return format_date_in_iso($resultdate); } +sub Get_Seq { + 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; +} + sub Get_Next_Seq { my ($val) =@_; my ($calculated,$newlastvalue1,$newlastvalue2,$newlastvalue3,$newinnerloop1,$newinnerloop2,$newinnerloop3); diff --git a/bull/subscription-add.pl b/bull/subscription-add.pl index c585bb027c..079da3b9ec 100755 --- a/bull/subscription-add.pl +++ b/bull/subscription-add.pl @@ -19,9 +19,9 @@ my $op = $query->param('op'); my $dbh = C4::Context->dbh; my ($subscriptionid,$auser,$librarian,$cost,$aqbooksellerid, $aqbooksellername,$aqbudgetid, $bookfundid, $startdate, $periodicity, $dow, $numberlength, $weeklength, $monthlength, - $add1,$every1,$whenmorethan1,$setto1,$lastvalue1, - $add2,$every2,$whenmorethan2,$setto2,$lastvalue2, - $add3,$every3,$whenmorethan3,$setto3,$lastvalue3, + $add1,$every1,$whenmorethan1,$setto1,$lastvalue1,$innerloop1, + $add2,$every2,$whenmorethan2,$setto2,$lastvalue2,$innerloop2, + $add3,$every3,$whenmorethan3,$setto3,$lastvalue3,$innerloop3, $numberingmethod, $status, $biblionumber, $bibliotitle, $notes); @@ -57,16 +57,19 @@ if ($op eq 'mod') { $whenmorethan1 = $subs->{'whenmorethan1'}; $setto1 = $subs->{'setto1'}; $lastvalue1 = $subs->{'lastvalue1'}; + $innerloop1 = $subs->{'innerloop1'}; $add2 = $subs->{'add2'}; $every2 = $subs->{'every2'}; $whenmorethan2 = $subs->{'whenmorethan2'}; $setto2 = $subs->{'setto2'}; $lastvalue2 = $subs->{'lastvalue2'}; + $innerloop2 = $subs->{'innerloop2'}; $add3 = $subs->{'add3'}; $every3 = $subs->{'every3'}; $whenmorethan3 = $subs->{'whenmorethan3'}; $setto3 = $subs->{'setto3'}; $lastvalue3 = $subs->{'lastvalue3'}; + $innerloop3 = $subs->{'innerloop3'}; $numberingmethod = $subs->{'numberingmethod'}; $status = $subs->{status}; $biblionumber = $subs->{'biblionumber'}; @@ -92,16 +95,19 @@ if ($op eq 'mod') { whenmorethan1 => $whenmorethan1, setto1 => $setto1, lastvalue1 => $lastvalue1, + innerloop1 => $innerloop1, add2 => $add2, every2 => $every2, whenmorethan2 => $whenmorethan2, setto2 => $setto2, lastvalue2 => $lastvalue2, + innerloop2 => $innerloop2, add3 => $add3, every3 => $every3, whenmorethan3 => $whenmorethan3, setto3 => $setto3, lastvalue3 => $lastvalue3, + innerloop3 => $innerloop3, numberingmethod => $numberingmethod, status => $status, biblionumber => $biblionumber, diff --git a/bull/subscription-detail.pl b/bull/subscription-detail.pl index b57b6b4053..9732f72b0a 100755 --- a/bull/subscription-detail.pl +++ b/bull/subscription-detail.pl @@ -19,9 +19,9 @@ my $sth; my ($template, $loggedinuser, $cookie, $subs); my ($subscriptionid,$auser,$librarian,$cost,$aqbooksellerid, $aqbooksellername,$aqbudgetid, $bookfundid, $startdate, $periodicity, $dow, $numberlength, $weeklength, $monthlength, - $add1,$every1,$whenmorethan1,$setto1,$lastvalue1, - $add2,$every2,$whenmorethan2,$setto2,$lastvalue2, - $add3,$every3,$whenmorethan3,$setto3,$lastvalue3, + $add1,$every1,$whenmorethan1,$setto1,$lastvalue1,$innerloop1, + $add2,$every2,$whenmorethan2,$setto2,$lastvalue2,$innerloop2, + $add3,$every3,$whenmorethan3,$setto3,$lastvalue3,$innerloop3, $numberingmethod, $status, $biblionumber, $bibliotitle, $notes); $subscriptionid = $query->param('subscriptionid'); @@ -44,25 +44,28 @@ if ($op eq 'modsubscription') { $whenmorethan1 = $query->param('whenmorethan1'); $setto1 = $query->param('setto1'); $lastvalue1 = $query->param('lastvalue1'); + $innerloop1 = $query->param('innerloop1'); $add2 = $query->param('add2'); $every2 = $query->param('every2'); $whenmorethan2 = $query->param('whenmorethan2'); $setto2 = $query->param('setto2'); $lastvalue2 = $query->param('lastvalue2'); + $innerloop2 = $query->param('innerloop2'); $add3 = $query->param('add3'); $every3 = $query->param('every3'); $whenmorethan3 = $query->param('whenmorethan3'); $setto3 = $query->param('setto3'); $lastvalue3 = $query->param('lastvalue3'); + $innerloop3 = $query->param('innerloop3'); $numberingmethod = $query->param('numberingmethod'); $status = 1; $notes = $query->param('notes'); &modsubscription($auser,$aqbooksellerid,$cost,$aqbudgetid,$startdate, $periodicity,$dow,$numberlength,$weeklength,$monthlength, - $add1,$every1,$whenmorethan1,$setto1,$lastvalue1, - $add2,$every2,$whenmorethan2,$setto2,$lastvalue2, - $add3,$every3,$whenmorethan3,$setto3,$lastvalue3, + $add1,$every1,$whenmorethan1,$setto1,$lastvalue1,$innerloop1, + $add2,$every2,$whenmorethan2,$setto2,$lastvalue2,$innerloop2, + $add3,$every3,$whenmorethan3,$setto3,$lastvalue3,$innerloop3, $numberingmethod, $status, $biblionumber, $notes, $subscriptionid); } @@ -98,6 +101,7 @@ $template->param( add1 => $subs->{add1}, every1 => $subs->{every1}, whenmorethan1 => $subs->{whenmorethan1}, + innerloop1 => $subs->{innerloop1}, setto1 => $subs->{setto1}, lastvalue1 => $subs->{lastvalue1}, add2 => $subs->{add2}, @@ -105,11 +109,13 @@ $template->param( whenmorethan2 => $subs->{whenmorethan2}, setto2 => $subs->{setto2}, lastvalue2 => $subs->{lastvalue2}, + innerloop2 => $subs->{innerloop2}, add3 => $subs->{add3}, every3 => $subs->{every3}, whenmorethan3 => $subs->{whenmorethan3}, setto3 => $subs->{setto3}, lastvalue3 => $subs->{lastvalue3}, + innerloop3 => $subs->{innerloop3}, numberingmethod => $subs->{numberingmethod}, status => $subs->{status}, biblionumber => $subs->{biblionumber}, diff --git a/koha-tmpl/intranet-tmpl/default/en/bull/subscription-add.tmpl b/koha-tmpl/intranet-tmpl/default/en/bull/subscription-add.tmpl index 7f4532655b..86135752c3 100644 --- a/koha-tmpl/intranet-tmpl/default/en/bull/subscription-add.tmpl +++ b/koha-tmpl/intranet-tmpl/default/en/bull/subscription-add.tmpl @@ -129,10 +129,12 @@

Subscription length

-

">

-

">

-

">

- +

* fill 1 from :

+

Numbering calculation

@@ -169,6 +171,14 @@ "> "> + + + The loop is for instance + "> + "> + "> + + Set back to "> @@ -215,12 +225,11 @@ function FindAcqui(f) function Check(f) { - if (f.dow.value.length != 0 - && f.startdate.value.length != 0 && f.dow.value.length != 0) - { -// alert('subscription ok'); - document.f.submit(); - } + if (f.startdate.value.length != 0 && + f.numberlength.value+f.weeklength.value+f.monthlength.value > 0) + { + document.f.submit(); + } else { alert('field marked with * are mandatory'); diff --git a/koha-tmpl/intranet-tmpl/default/en/bull/subscription-detail.tmpl b/koha-tmpl/intranet-tmpl/default/en/bull/subscription-detail.tmpl index 783262e4e6..8da6b62093 100644 --- a/koha-tmpl/intranet-tmpl/default/en/bull/subscription-detail.tmpl +++ b/koha-tmpl/intranet-tmpl/default/en/bull/subscription-detail.tmpl @@ -114,9 +114,12 @@ When more than - - - +
+ (is ) +
+ (is ) +
+ (is ) Set back to @@ -131,7 +134,8 @@ - + +

Issues

-- 2.39.5