From 1e33d3ca1a7eb928daa2d19c4cbc3a93a4204f02 Mon Sep 17 00:00:00 2001 From: tipaul Date: Fri, 6 Aug 2004 16:38:41 +0000 Subject: [PATCH] changing DB structure to calculate next issue number. Seems to work fine. Still misses the date calculation & the test of end of subscription (maybe for monday ?) --- C4/Bull.pm | 238 ++++++------------ bull/subscription-add.pl | 131 +++++----- bull/subscription-detail.pl | 152 ++++++----- .../intranet-tmpl/default/en/bull/order.tmpl | 5 +- .../intranet-tmpl/default/en/bull/result.tmpl | 21 +- .../default/en/bull/subscription-add.tmpl | 124 ++++----- .../default/en/bull/subscription-detail.tmpl | 73 +++--- .../en/help/bull/subscription-detail.tmpl | 16 +- updater/updatedatabase | 99 +++++++- 9 files changed, 413 insertions(+), 446 deletions(-) diff --git a/C4/Bull.pm b/C4/Bull.pm index 05759a5d17..dbfeb6bc04 100755 --- a/C4/Bull.pm +++ b/C4/Bull.pm @@ -19,6 +19,7 @@ package C4::Bull; #assumes C4/Bull.pm # Suite 330, Boston, MA 02111-1307 USA use strict; +use C4::Date; require Exporter; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); @@ -44,22 +45,45 @@ Give all XYZ functions @EXPORT = qw(&newsubscription &modsubscription &getsubscriptions &getsubscription &modsubscriptionhistory &getserials &serialchangestatus - &Initialize_Sequence &Find_Next_Date, &Get_Next_Seq); + &Find_Next_Date, &Get_Next_Seq); sub newsubscription { - my ($auser,$aqbooksellerid,$cost,$aqbudgetid,$biblionumber,$startdate,$periodicity,$dow,$numberlength,$weeklength,$monthlength,$seqnum1,$seqnum1,$seqtype1,$freq1, $step1,$seqnum2,$seqnum2,$seqtype2,$freq2, $step2,$seqnum3,$seqnum3,$seqtype3,$freq3, $step3, $numberingmethod, $arrivalplanified, $status, $notes) = @_; + my ($auser,$aqbooksellerid,$cost,$aqbudgetid,$biblionumber, + $startdate,$periodicity,$dow,$numberlength,$weeklength,$monthlength, + $add1,$every1,$whenmorethan1,$setto1,$lastvalue1, + $add2,$every2,$whenmorethan2,$setto2,$lastvalue2, + $add3,$every3,$whenmorethan3,$setto3,$lastvalue3, + $numberingmethod, $arrivalplanified, $status, $notes) = @_; my $dbh = C4::Context->dbh; #save subscription - my $sth=$dbh->prepare("insert into subscription (librarian, aqbooksellerid,cost,aqbudgetid,biblionumber,startdate, periodicity,dow,numberlength,weeklength,monthlength,seqnum1,startseqnum1,seqtype1,freq1,step1,seqnum2,startseqnum2,seqtype2,freq2, step2, seqnum3,startseqnum3,seqtype3, freq3, step3,numberingmethod, arrivalplanified, status, notes, pos1, pos2, pos3) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, 0, 0, 0)"); - $sth->execute($auser,$aqbooksellerid,$cost,$aqbudgetid,$biblionumber,$startdate,$periodicity,$dow,$numberlength,$weeklength,$monthlength,$seqnum1,$seqnum1,$seqtype1,$freq1, $step1,$seqnum2,$seqnum2,$seqtype2,$freq2, $step2,$seqnum3,$seqnum3,$seqtype3,$freq3, $step3, $numberingmethod, $arrivalplanified, $status, $notes); + my $sth=$dbh->prepare("insert into subscription (librarian,aqbooksellerid,cost,aqbudgetid,biblionumber, + startdate,periodicity,dow,numberlength,weeklength,monthlength, + add1,every1,whenmorethan1,setto1,lastvalue1, + add2,every2,whenmorethan2,setto2,lastvalue2, + add3,every3,whenmorethan3,setto3,lastvalue3, + numberingmethod, arrivalplanified, status, notes) values + (?,?,?,?,?,?,?,?,?,?, + ?,?,?,?,?,?,?,?,?,?, + ?,?,?,?,?,?,?,?,?,?)"); + $sth->execute($auser,$aqbooksellerid,$cost,$aqbudgetid,$biblionumber, + format_date_in_iso($startdate),$periodicity,$dow,$numberlength,$weeklength,$monthlength, + $add1,$every1,$whenmorethan1,$setto1,$lastvalue1, + $add2,$every2,$whenmorethan2,$setto2,$lastvalue2, + $add3,$every3,$whenmorethan3,$setto3,$lastvalue3, + $numberingmethod, format_date_in_iso($arrivalplanified), $status, $notes); #then create the 1st waited number my $subscriptionid = $dbh->{'mysql_insertid'}; $sth = $dbh->prepare("insert into subscriptionhistory (biblionumber, subscriptionid, startdate, enddate, missinglist, recievedlist, opacnote, librariannote) values (?,?,?,?,?,?,?,?)"); $sth->execute($biblionumber, $subscriptionid, $startdate, 0, "", "", 0, $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; $sth = $dbh->prepare("insert into serial (biblionumber, subscriptionid, serialseq, status, planneddate) values (?,?,?,?,?)"); - $sth->execute($biblionumber, $subscriptionid, Initialize_Sequence($numberingmethod, $seqnum1, $seqtype1, $freq1, $step1, $seqnum2, $seqtype2, $freq2, $step2, $seqnum3, $seqtype3, $freq3, $step3), $status, C4::Bull::Find_Next_Date()); + $sth->execute($biblionumber, $subscriptionid, + &Get_Next_Seq($val), + $status, Find_Next_Date()); $sth->finish; - } sub getsubscription { my ($subscriptionid) = @_; @@ -78,17 +102,22 @@ sub getsubscription { sub modsubscription { my ($auser,$aqbooksellerid,$cost,$aqbudgetid,$startdate, $periodicity,$dow,$numberlength,$weeklength,$monthlength, - $seqnum1,$startseqnum1,$seqtype1,$freq1,$step1, - $seqnum2,$startseqnum2,$seqtype2,$freq2,$step2, - $seqnum3,$startseqnum3,$seqtype3,$freq3,$step3, + $add1,$every1,$whenmorethan1,$setto1,$lastvalue1, + $add2,$every2,$whenmorethan2,$setto2,$lastvalue2, + $add3,$every3,$whenmorethan3,$setto3,$lastvalue3, $numberingmethod, $arrivalplanified, $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=?,seqnum1=?,startseqnum1=?,seqtype1=?,freq1=?,step1=?,seqnum2=?,startseqnum2=?,seqtype2=?,freq2=?, step2=?, seqnum3=?,startseqnum3=?,seqtype3=?, freq3=?, step3=?,numberingmethod=?, arrivalplanified=?, status=?, biblionumber=?, notes=? where subscriptionid = ?"); + 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=?, + numberingmethod=?, arrivalplanified=?, status=?, biblionumber=?, notes=? where subscriptionid = ?"); $sth->execute($auser,$aqbooksellerid,$cost,$aqbudgetid,$startdate, $periodicity,$dow,$numberlength,$weeklength,$monthlength, - $seqnum1,$startseqnum1,$seqtype1,$freq1,$step1, - $seqnum2,$startseqnum2,$seqtype2,$freq2,$step2, - $seqnum3,$startseqnum3,$seqtype3,$freq3,$step3, + $add1,$every1,$whenmorethan1,$setto1,$lastvalue1, + $add2,$every2,$whenmorethan2,$setto2,$lastvalue2, + $add3,$every3,$whenmorethan3,$setto3,$lastvalue3, $numberingmethod, $arrivalplanified, $status, $biblionumber, $notes, $subscriptionid); $sth->finish; @@ -130,8 +159,7 @@ sub getserials { sub serialchangestatus { my ($serialid,$serialseq,$planneddate,$status)=@_; - warn "($serialid,$serialseq,$planneddate,$status)"; -# return 1; +# 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 my $dbh = C4::Context->dbh; my $sth = $dbh->prepare("select subscriptionid,status from serial where serialid=?"); @@ -153,154 +181,54 @@ sub serialchangestatus { $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) { - $sth = $dbh->prepare("select * from subscription where subscriptionid = ? "); - $sth->execute($subscriptionid); - my $val = $sth->fetchrow_hashref; - $sth = $dbh->prepare("insert into serial (serialseq,subscriptionid,biblionumber,status, planneddate) values (?,?,?,?,?)"); - my ($temp, $X, $Y, $Z, $pos1, $pos2, $pos3) = Get_Next_Seq($val->{'numberingmethod'},$val->{'seqnum1'},$val->{'freq1'}, $val->{'step1'}, $val->{'seqtype1'}, $val->{'seqnum2'}, $val->{'freq2'}, $val->{'step2'}, $val->{'seqtype2'}, $val->{'seqnum3'}, $val->{'freq3'}, $val->{'step3'}, $val->{'seqtype3'}, $val->{'pos1'}, $val->{'pos2'}, $val->{'pos3'}); - $sth->execute($temp, $subscriptionid, $val->{'biblionumber'}, 1, 0); - $sth = $dbh->prepare("update subscription set seqnum1=?, seqnum2=?,seqnum3=?,pos1=?,pos2=?,pos3=? where subscriptionid = ?"); - $sth->execute($X, $Y, $Z, $pos1, $pos2, $pos3, $subscriptionid); - - } -} -sub GetValue(@) { - my $seq = shift; - my $X = shift; - my $Y = shift; - my $Z = shift; - - return $X if ($seq eq 'X'); - return $Y if ($seq eq 'Y'); - return $Z if ($seq eq 'Z'); - return "5 Syntax Error in Sequence"; -} - - -sub Initialize_Sequence(@) { - my $sequence = shift; - my $X = shift; - my $seqtype1 = shift; - my $freq1 = shift; - my $step1 = shift; - my $Y = shift; - my $seqtype2 = shift; - my $freq2 = shift; - my $step2 = shift; - my $Z = shift; - my $seqtype3 = shift; - my $freq3 = shift; - my $step3 = shift; - my $finalstring = ""; - my @string = split //, $sequence; - my $etat = 0; - - for (my $i = 0; $i < (scalar @string); $i++) { - if ($string[$i] ne '{') { - if (!$etat) { - $finalstring .= $string[$i]; - } else { - return "1 Syntax Error in Sequence"; - } - } else { - return "3 Syntax Error in Sequence" - if ($string[$i + 1] ne 'X' && $string[$i + 1] ne 'Y' && $string[$i + 1] ne 'Z'); - $finalstring .= GetValue($string[$i + 1], $X, $Y, $Z); - $i += 2; - } + $sth = $dbh->prepare("select * from subscription where subscriptionid = ? "); + $sth->execute($subscriptionid); + my $val = $sth->fetchrow_hashref; + my ($newserialseq,$newlastvalue1,$newlastvalue2,$newlastvalue3,$newinnerloop1,$newinnerloop2,$newinnerloop3) = Get_Next_Seq($val); + $sth = $dbh->prepare("insert into serial (serialseq,subscriptionid,biblionumber,status, planneddate) values (?,?,?,?,?)"); + $sth->execute($newserialseq, $subscriptionid, $val->{'biblionumber'}, 1, 0); + $sth = $dbh->prepare("update subscription set lastvalue1=?, lastvalue2=?,lastvalue3=?, + innerloop1=?,innerloop2=?,innerloop3=? + where subscriptionid = ?"); + $sth->execute($newlastvalue1,$newlastvalue2,$newlastvalue3,$newinnerloop1,$newinnerloop2,$newinnerloop3,$subscriptionid); } - return "$finalstring"; } sub Find_Next_Date(@) { return "2004-29-03"; } -sub Step(@) { - my $seqnum1 = shift; - my $seqtype1 = shift; - my $freq1 = shift; - my $step1 = shift; - my $seqnum2 = shift; - my $seqtype2 = shift; - my $freq2 = shift; - my $step2 = shift; - my $seqnum3 = shift; - my $seqtype3 = shift; - my $freq3 = shift; - my $step3 = shift; - my $pos1 = shift; - my $pos2 = shift; - my $pos3 = shift; - - $seqnum1 += $step1 if ($seqtype1 == 1); - if ($seqtype1 == 2) { - $pos1 += 1; - if ($pos1 >= $freq1) { - $pos1 = 0; - $seqnum1 += $step1; - } - } - - $seqnum2 += $step2 if ($seqtype2 == 1); - if ($seqtype2 == 2) { - $pos2 += 1; - if ($pos2 >= $freq2) { - $pos2 = 0; - $seqnum2 += $step2; - } - } - - $seqnum3 += $step3 if ($seqtype3 == 1); - if ($seqtype3 == 2) { - $pos3 += 1; - if ($pos3 >= $freq3) { - $pos3 = 0; - $seqnum3 += $step3; - } - } - -# $Y += $step2; if ($seqtype2 == 1); - # if ($seqtype2 == 2) { $pos2 += 1; if ($pos2 >= $freq2) { - #$pos2 = 0; $Y += $step2; } } - - - # $Z += $step3; if ($seqtype3 == 1); - # if ($seqtype3 == 2) { $pos3 += 1; if ($pos3 >= $freq3) { -# $pos3 = 0; $Z += $step3; } } - - return ($seqnum1, $seqnum2, $seqnum3, $pos1, $pos2, $pos3); -} - -sub Get_Next_Seq(@) { - my $sequence = shift; - my $seqnum1 = shift; - my $freq1 = shift; - my $step1 = shift; - my $seqtype1 = shift; - my $seqnum2 = shift; - my $freq2 = shift; - my $step2 = shift; - my $seqtype2 = shift; - my $seqnum3 = shift; - my $freq3 = shift; - my $step3 = shift; - my $seqtype3 = shift; - my $pos1 = shift; - my $pos2 = shift; - my $pos3 = shift; - - return ("$sequence", $seqnum1, $seqnum2, $seqnum3) - if (!defined($seqnum1) && !defined($seqnum2) && !defined($seqnum3)); +sub Get_Next_Seq { + my ($val) =@_; +# return ("$sequence", $seqnum1, $seqnum2, $seqnum3) +# if (!defined($seqnum1) && !defined($seqnum2) && !defined($seqnum3)); + 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; - ($seqnum1, $seqnum2, $seqnum3, $pos1, $pos2, $pos3) = - Step($seqnum1, $seqtype1, $freq1, $step1, $seqnum2, $seqtype2, $freq2, - $step2, $seqnum3, $seqtype3, $freq3, $step3, $pos1, $pos2, $pos3); - - return (Initialize_Sequence($sequence, $seqnum1, $seqtype1, - $freq1, $step1, $seqnum2, $seqtype2, $freq2, - $step2, $seqnum3, $seqtype3, $freq3, $step3), - $seqnum1, $seqnum2, $seqnum3, $pos1, $pos2, $pos3); + $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); } END { } # module clean-up code here (global destructor) diff --git a/bull/subscription-add.pl b/bull/subscription-add.pl index eb81cccd76..f5e90e4fe9 100755 --- a/bull/subscription-add.pl +++ b/bull/subscription-add.pl @@ -4,8 +4,10 @@ use strict; use CGI; use C4::Koha; use C4::Auth; +use C4::Date; use C4::Output; use C4::Bull; +use C4::Acquisition; use C4::Interface::CGI::Output; use C4::Context; use HTML::Template; @@ -16,12 +18,13 @@ 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, - $seqnum1,$startseqnum1,$seqtype1,$freq1,$step1, - $seqnum2,$startseqnum2,$seqtype2,$freq2,$step2, - $seqnum3,$startseqnum3,$seqtype3,$freq3,$step3, + $add1,$every1,$whenmorethan1,$setto1,$lastvalue1, + $add2,$every2,$whenmorethan2,$setto2,$lastvalue2, + $add3,$every3,$whenmorethan3,$setto3,$lastvalue3, $numberingmethod, $arrivalplanified, $status, $biblionumber, $bibliotitle, $notes); + my @budgets; my ($template, $loggedinuser, $cookie) = get_template_and_user({template_name => "bull/subscription-add.tmpl", query => $query, @@ -48,21 +51,21 @@ if ($op eq 'mod') { $numberlength = $subs->{'numberlength'}; $weeklength = $subs->{'weeklength'}; $monthlength = $subs->{'monthlength'}; - $seqnum1 = $subs->{'seqnum1'}; - $startseqnum1 = $subs->{'startseqnum1'}; - $seqtype1 = $subs->{'seqtype1'}; - $freq1 = $subs->{'freq1'}; - $step1 = $subs->{'step1'}; - $seqnum2 = $subs->{'seqnum2'}; - $startseqnum2 = $subs->{'startseqnum2'}; - $seqtype2 = $subs->{'seqtype2'}; - $freq2 = $subs->{'freq2'}; - $step2 = $subs->{'step2'}; - $seqnum3 = $subs->{'seqnum3'}; - $startseqnum3 = $subs->{'startseqnum3'}; - $seqtype3 = $subs->{'seqtype3'}; - $freq3 = $subs->{'freq3'}; - $step3 = $subs->{'step3'}; + $add1 = $subs->{'add1'}; + $every1 = $subs->{'every1'}; + $whenmorethan1 = $subs->{'whenmorethan1'}; + $setto1 = $subs->{'setto1'}; + $lastvalue1 = $subs->{'lastvalue1'}; + $add2 = $subs->{'add2'}; + $every2 = $subs->{'every2'}; + $whenmorethan2 = $subs->{'whenmorethan2'}; + $setto2 = $subs->{'setto2'}; + $lastvalue2 = $subs->{'lastvalue2'}; + $add3 = $subs->{'add3'}; + $every3 = $subs->{'every3'}; + $whenmorethan3 = $subs->{'whenmorethan3'}; + $setto3 = $subs->{'setto3'}; + $lastvalue3 = $subs->{'lastvalue3'}; $numberingmethod = $subs->{'numberingmethod'}; $arrivalplanified = $subs->{'arrivalplanified'}; $status = $subs->{status}; @@ -78,50 +81,49 @@ if ($op eq 'mod') { cost => $cost, aqbudgetid => $aqbudgetid, bookfundid => $bookfundid, - startdate => $startdate, + startdate => format_date($startdate), periodicity => $periodicity, dow => $dow, numberlength => $numberlength, weeklength => $weeklength, monthlength => $monthlength, - seqnum1 =>$seqnum1, - startseqnum =>$startseqnum1, - seqtype1 =>$seqtype1, - freq1 =>$freq1, - step1 =>$step1, - seqnum2 => $seqnum2, - startseqnum2 => $startseqnum2, - seqtype2 => $seqtype2, - freq2 => $freq2, - step2 => $step2, - seqnum3 => $seqnum3, - startseqnum3 => $startseqnum3, - seqtype3 => $seqtype3, - freq3 => $freq3, - step3 => $step3, + add1 => $add1, + every1 => $every1, + whenmorethan1 => $whenmorethan1, + setto1 => $setto1, + lastvalue1 => $lastvalue1, + add2 => $add2, + every2 => $every2, + whenmorethan2 => $whenmorethan2, + setto2 => $setto2, + lastvalue2 => $lastvalue2, + add3 => $add3, + every3 => $every3, + whenmorethan3 => $whenmorethan3, + setto3 => $setto3, + lastvalue3 => $lastvalue3, numberingmethod => $numberingmethod, - arrivalplanified => $arrivalplanified, + arrivalplanified => format_date($arrivalplanified), status => $status, biblionumber => $biblionumber, bibliotitle => $bibliotitle, notes => $notes, - subscriptionid => $subscriptionid + subscriptionid => $subscriptionid, ); $template->param( "periodicity$periodicity" => 1, - "seqtype1$seqtype1" => 1, - "seqtype2$seqtype2" => 1, - "seqtype3$seqtype3" => 1, "dow$dow" => 1, ); -} else { -# fill seqtype with 0 to avoid a javascript error - $template->param( - "seqtype1" => 0, - "seqtype2" => 0, - "seqtype3" => 0, - ); } +(my $temp,@budgets) = bookfunds(); +# find default value & set it for the template +for (my $i=0;$i<=$#budgets;$i++) { + if ($budgets[$i]->{'aqbudgetid'} eq $aqbudgetid) { + $budgets[$i]->{'selected'}=1; + } +} +$template->param(budgets => \@budgets); + if ($op eq 'addsubscription') { my $auser = $query->param('user'); my $aqbooksellerid = $query->param('aqbooksellerid'); @@ -133,26 +135,33 @@ if ($op eq 'addsubscription') { my $numberlength = $query->param('numberlength'); my $weeklength = $query->param('weeklength'); my $monthlength = $query->param('monthlength'); - my $seqnum1 = $query->param('seqnum1'); - my $seqtype1 = $query->param('seqtype1'); - my $freq1 = $query->param('freq1'); - my $step1 = $query->param('step1'); - my $seqnum2 = $query->param('seqnum2'); - my $seqtype2 = $query->param('seqtype2'); - my $freq2 = $query->param('freq2'); - my $step2 = $query->param('step2'); - my $seqnum3 = $query->param('seqnum3'); - my $seqtype3 = $query->param('seqtype3'); - my $freq3 = $query->param('freq3'); - my $step3 = $query->param('step3'); + my $add1 = $query->param('add1'); + my $every1 = $query->param('every1'); + my $whenmorethan1 = $query->param('whenmorethan1'); + my $setto1 = $query->param('setto1'); + my $lastvalue1 = $query->param('lastvalue1'); + my $add2 = $query->param('add2'); + my $every2 = $query->param('every2'); + my $whenmorethan2 = $query->param('whenmorethan2'); + my $setto2 = $query->param('setto2'); + my $lastvalue2 = $query->param('lastvalue2'); + my $add3 = $query->param('add3'); + my $every3 = $query->param('every3'); + my $whenmorethan3 = $query->param('whenmorethan3'); + my $setto3 = $query->param('setto3'); + my $lastvalue3 = $query->param('lastvalue3'); my $numberingmethod = $query->param('numberingmethod'); my $arrivalplanified = $query->param('arrivalplanified'); my $status = 1; my $biblionumber = $query->param('biblionumber'); my $notes = $query->param('notes'); - - my $sth=$dbh->prepare("insert into subscription (librarian, aqbooksellerid,cost,aqbudgetid,biblionumber,startdate, periodicity,dow,numberlength,weeklength,monthlength,seqnum1,startseqnum1,seqtype1,freq1,step1,seqnum2,startseqnum2,seqtype2,freq2, step2, seqnum3,startseqnum3,seqtype3, freq3, step3,numberingmethod, arrivalplanified, status, notes, pos1, pos2, pos3) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, 0, 0, 0)"); - newsubscription($auser,$aqbooksellerid,$cost,$aqbudgetid,$biblionumber,$startdate,$periodicity,$dow,$numberlength,$weeklength,$monthlength,$seqnum1,$seqnum1,$seqtype1,$freq1, $step1,$seqnum2,$seqnum2,$seqtype2,$freq2, $step2,$seqnum3,$seqnum3,$seqtype3,$freq3, $step3, $numberingmethod, $arrivalplanified, $status, $notes); + newsubscription($auser,$aqbooksellerid,$cost,$aqbudgetid,$biblionumber, + $startdate,$periodicity,$dow,$numberlength,$weeklength,$monthlength, + $add1,$every1,$whenmorethan1,$setto1,$lastvalue1, + $add2,$every2,$whenmorethan2,$setto2,$lastvalue2, + $add3,$every3,$whenmorethan3,$setto3,$lastvalue3, + $numberingmethod, $arrivalplanified, $status, $notes + ); } diff --git a/bull/subscription-detail.pl b/bull/subscription-detail.pl index f446e7e59e..49846ed7f3 100755 --- a/bull/subscription-detail.pl +++ b/bull/subscription-detail.pl @@ -4,6 +4,7 @@ use strict; use CGI; use C4::Auth; use C4::Koha; +use C4::Date; use C4::Bull; use C4::Output; use C4::Interface::CGI::Output; @@ -18,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, - $seqnum1,$startseqnum1,$seqtype1,$freq1,$step1, - $seqnum2,$startseqnum2,$seqtype2,$freq2,$step2, - $seqnum3,$startseqnum3,$seqtype3,$freq3,$step3, + $add1,$every1,$whenmorethan1,$setto1,$lastvalue1, + $add2,$every2,$whenmorethan2,$setto2,$lastvalue2, + $add3,$every3,$whenmorethan3,$setto3,$lastvalue3, $numberingmethod, $arrivalplanified, $status, $biblionumber, $bibliotitle, $notes); $subscriptionid = $query->param('subscriptionid'); @@ -38,21 +39,21 @@ if ($op eq 'modsubscription') { $numberlength = $query->param('numberlength'); $weeklength = $query->param('weeklength'); $monthlength = $query->param('monthlength'); - $seqnum1 = $query->param('seqnum1'); - $startseqnum1 = $query->param('startseqnum1'); - $seqtype1 = $query->param('seqtype1'); - $freq1 = $query->param('freq1'); - $step1 = $query->param('step1'); - $seqnum2 = $query->param('seqnum2'); - $startseqnum2 = $query->param('startseqnum2'); - $seqtype2 = $query->param('seqtype2'); - $freq2 = $query->param('freq2'); - $step2 = $query->param('step2'); - $seqnum3 = $query->param('seqnum3'); - $startseqnum3 = $query->param('startseqnum3'); - $seqtype3 = $query->param('seqtype3'); - $freq3 = $query->param('freq3'); - $step3 = $query->param('step3'); + $add1 = $query->param('add1'); + $every1 = $query->param('every1'); + $whenmorethan1 = $query->param('whenmorethan1'); + $setto1 = $query->param('setto1'); + $lastvalue1 = $query->param('lastvalue1'); + $add2 = $query->param('add2'); + $every2 = $query->param('every2'); + $whenmorethan2 = $query->param('whenmorethan2'); + $setto2 = $query->param('setto2'); + $lastvalue2 = $query->param('lastvalue2'); + $add3 = $query->param('add3'); + $every3 = $query->param('every3'); + $whenmorethan3 = $query->param('whenmorethan3'); + $setto3 = $query->param('setto3'); + $lastvalue3 = $query->param('lastvalue3'); $numberingmethod = $query->param('numberingmethod'); $arrivalplanified = $query->param('arrivalplanified'); $status = 1; @@ -60,49 +61,46 @@ if ($op eq 'modsubscription') { &modsubscription($auser,$aqbooksellerid,$cost,$aqbudgetid,$startdate, $periodicity,$dow,$numberlength,$weeklength,$monthlength, - $seqnum1,$startseqnum1,$seqtype1,$freq1,$step1, - $seqnum2,$startseqnum2,$seqtype2,$freq2,$step2, - $seqnum3,$startseqnum3,$seqtype3,$freq3,$step3, + $add1,$every1,$whenmorethan1,$setto1,$lastvalue1, + $add2,$every2,$whenmorethan2,$setto2,$lastvalue2, + $add3,$every3,$whenmorethan3,$setto3,$lastvalue3, $numberingmethod, $arrivalplanified, $status, $biblionumber, $notes, $subscriptionid); - - } else { - my $subs = &getsubscription($subscriptionid); - $auser = $subs->{'user'}; - $librarian => $subs->{'librarian'}, - $cost = $subs->{'cost'}; - $aqbooksellerid = $subs->{'aqbooksellerid'}; - $aqbooksellername = $subs->{'aqbooksellername'}; - $bookfundid = $subs->{'bookfundid'}; - $aqbudgetid = $subs->{'aqbudgetid'}; - $startdate = $subs->{'startdate'}; - $periodicity = $subs->{'periodicity'}; - $dow = $subs->{'dow'}; - $numberlength = $subs->{'numberlength'}; - $weeklength = $subs->{'weeklength'}; - $monthlength = $subs->{'monthlength'}; - $seqnum1 = $subs->{'seqnum1'}; - $startseqnum1 = $subs->{'startseqnum1'}; - $seqtype1 = $subs->{'seqtype1'}; - $freq1 = $subs->{'freq1'}; - $step1 = $subs->{'step1'}; - $seqnum2 = $subs->{'seqnum2'}; - $startseqnum2 = $subs->{'startseqnum2'}; - $seqtype2 = $subs->{'seqtype2'}; - $freq2 = $subs->{'freq2'}; - $step2 = $subs->{'step2'}; - $seqnum3 = $subs->{'seqnum3'}; - $startseqnum3 = $subs->{'startseqnum3'}; - $seqtype3 = $subs->{'seqtype3'}; - $freq3 = $subs->{'freq3'}; - $step3 = $subs->{'step3'}; - $numberingmethod = $subs->{'numberingmethod'}; - $arrivalplanified = $subs->{'arrivalplanified'}; - $status = $subs->{status}; - $biblionumber = $subs->{'biblionumber'}; - $bibliotitle = $subs->{'bibliotitle'}, - $notes = $subs->{'notes'}; - } + my $subs = &getsubscription($subscriptionid); + $auser = $subs->{'user'}; + $librarian => $subs->{'librarian'}, + $cost = $subs->{'cost'}; + $aqbooksellerid = $subs->{'aqbooksellerid'}; + $aqbooksellername = $subs->{'aqbooksellername'}; + $bookfundid = $subs->{'bookfundid'}; + $aqbudgetid = $subs->{'aqbudgetid'}; + $startdate = $subs->{'startdate'}; + $periodicity = $subs->{'periodicity'}; + $dow = $subs->{'dow'}; + $numberlength = $subs->{'numberlength'}; + $weeklength = $subs->{'weeklength'}; + $monthlength = $subs->{'monthlength'}; + $add1 = $subs->{'add1'}; + $every1 = $subs->{'every1'}; + $whenmorethan1 = $subs->{'whenmorethan1'}; + $setto1 = $subs->{'setto1'}; + $lastvalue1 = $subs->{'lastvalue1'}; + $add2 = $subs->{'add2'}; + $every2 = $subs->{'every2'}; + $whenmorethan2 = $subs->{'whenmorethan2'}; + $setto2 = $subs->{'setto2'}; + $lastvalue2 = $subs->{'lastvalue2'}; + $add3 = $subs->{'add3'}; + $every3 = $subs->{'every3'}; + $whenmorethan3 = $subs->{'whenmorethan3'}; + $setto3 = $subs->{'setto3'}; + $lastvalue3 = $subs->{'lastvalue3'}; + $numberingmethod = $subs->{'numberingmethod'}; + $arrivalplanified = $subs->{'arrivalplanified'}; + $status = $subs->{status}; + $biblionumber = $subs->{'biblionumber'}; + $bibliotitle = $subs->{'bibliotitle'}, + $notes = $subs->{'notes'}; ($template, $loggedinuser, $cookie) = get_template_and_user({template_name => "bull/subscription-detail.tmpl", @@ -124,27 +122,27 @@ $template->param( cost => $cost, aqbudgetid => $aqbudgetid, bookfundid => $bookfundid, - startdate => $startdate, + startdate => format_date($startdate), periodicity => $periodicity, dow => $dow, numberlength => $numberlength, weeklength => $weeklength, monthlength => $monthlength, - seqnum1 =>$seqnum1, - startseqnum1 =>$startseqnum1, - seqtype1 =>$seqtype1, - freq1 =>$freq1, - step1 =>$step1, - seqnum2 => $seqnum2, - startseqnum2 => $startseqnum2, - seqtype2 => $seqtype2, - freq2 => $freq2, - step2 => $step2, - seqnum3 => $seqnum3, - startseqnum3 => $startseqnum3, - seqtype3 => $seqtype3, - freq3 => $freq3, - step3 => $step3, + add1 => $add1, + every1 => $every1, + whenmorethan1 => $whenmorethan1, + setto1 => $setto1, + lastvalue1 => $lastvalue1, + add2 => $add2, + every2 => $every2, + whenmorethan2 => $whenmorethan2, + setto2 => $setto2, + lastvalue2 => $lastvalue2, + add3 => $add3, + every3 => $every3, + whenmorethan3 => $whenmorethan3, + setto3 => $setto3, + lastvalue3 => $lastvalue3, numberingmethod => $numberingmethod, arrivalplanified => $arrivalplanified, status => $status, @@ -155,11 +153,7 @@ $template->param( ); $template->param( "periodicity$periodicity" => 1, - "seqtype1$seqtype1" => 1, - "seqtype2$seqtype2" => 1, - "seqtype3$seqtype3" => 1, "arrival$dow" => 1, ); - output_html_with_http_headers $query, $cookie, $template->output; diff --git a/koha-tmpl/intranet-tmpl/default/en/bull/order.tmpl b/koha-tmpl/intranet-tmpl/default/en/bull/order.tmpl index b2074df8f5..717608a5c6 100644 --- a/koha-tmpl/intranet-tmpl/default/en/bull/order.tmpl +++ b/koha-tmpl/intranet-tmpl/default/en/bull/order.tmpl @@ -14,7 +14,7 @@ - + ')"> /images/arrow.gif" title="select this supplier" BORDER=0 height=40 width=40> @@ -28,9 +28,10 @@ \ No newline at end of file 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 4a64ecabc3..3cc3df828c 100644 --- a/koha-tmpl/intranet-tmpl/default/en/bull/subscription-add.tmpl +++ b/koha-tmpl/intranet-tmpl/default/en/bull/subscription-add.tmpl @@ -15,15 +15,28 @@ ">

Librarian

-

">...

-

">

-

">

-

"> ...

+

" size=4> (" disabled readonly>) ...

+

" size=4>

+

+ +

+

" size=4> (" disabled readonly>)...

Planning

-

">

+

" size=13 maxlength=10>

+

" size=13 maxlength=10>

- - - - - - - - - - - - - - - - - + "> - + "> - + "> - Value - "> - "> - "> + once every + "> + "> + "> + + + When more than + "> + "> + "> - Frequency - "> - "> - "> + Set back to + "> + "> + "> - Step - "> - "> - "> + + + Last value + + Begins with + + + "> + "> + "> -Arrival date : "> +

@@ -238,10 +212,6 @@