12 use C4::Interface::CGI::Output;
19 my $op = $query->param('op');
20 my $dbh = C4::Context->dbh;
21 my ($subscriptionid,$auser,$librarian,$cost,$aqbooksellerid, $aqbooksellername,$aqbudgetid, $bookfundid, $startdate, $periodicity,
22 $dow, $numberlength, $weeklength, $monthlength,
23 $add1,$every1,$whenmorethan1,$setto1,$lastvalue1,$innerloop1,
24 $add2,$every2,$whenmorethan2,$setto2,$lastvalue2,$innerloop2,
25 $add3,$every3,$whenmorethan3,$setto3,$lastvalue3,$innerloop3,
26 $numberingmethod, $status, $biblionumber,
27 $bibliotitle, $notes, $letter);
30 my ($template, $loggedinuser, $cookie)
31 = get_template_and_user({template_name => "bull/subscription-add.tmpl",
35 flagsrequired => {catalogue => 1},
40 #FIXME : If Budgets are never used, then these lines are useless.
41 my $dbh = C4::Context->dbh;
42 my $sthtemp = $dbh->prepare("Select flags, branchcode from borrowers where borrowernumber = ?");
43 $sthtemp->execute($loggedinuser);
44 my ($flags, $homebranch)=$sthtemp->fetchrow;
45 #FIXME : END added by hdl on July,14 2005
48 my $subscriptionid = $query->param('subscriptionid');
49 my $subs = &getsubscription($subscriptionid);
50 $auser = $subs->{'user'};
51 $librarian => $subs->{'librarian'},
52 $cost = $subs->{'cost'};
53 $aqbooksellerid = $subs->{'aqbooksellerid'};
54 $aqbooksellername = $subs->{'aqbooksellername'};
55 $bookfundid = $subs->{'bookfundid'};
56 $aqbudgetid = $subs->{'aqbudgetid'};
57 $startdate = $subs->{'startdate'};
58 $periodicity = $subs->{'periodicity'};
59 $dow = $subs->{'dow'};
60 $numberlength = $subs->{'numberlength'};
61 $weeklength = $subs->{'weeklength'};
62 $monthlength = $subs->{'monthlength'};
63 $add1 = $subs->{'add1'};
64 $every1 = $subs->{'every1'};
65 $whenmorethan1 = $subs->{'whenmorethan1'};
66 $setto1 = $subs->{'setto1'};
67 $lastvalue1 = $subs->{'lastvalue1'};
68 $innerloop1 = $subs->{'innerloop1'};
69 $add2 = $subs->{'add2'};
70 $every2 = $subs->{'every2'};
71 $whenmorethan2 = $subs->{'whenmorethan2'};
72 $setto2 = $subs->{'setto2'};
73 $lastvalue2 = $subs->{'lastvalue2'};
74 $innerloop2 = $subs->{'innerloop2'};
75 $add3 = $subs->{'add3'};
76 $every3 = $subs->{'every3'};
77 $whenmorethan3 = $subs->{'whenmorethan3'};
78 $setto3 = $subs->{'setto3'};
79 $lastvalue3 = $subs->{'lastvalue3'};
80 $innerloop3 = $subs->{'innerloop3'};
81 $numberingmethod = $subs->{'numberingmethod'};
82 $status = $subs->{status};
83 $biblionumber = $subs->{'biblionumber'};
84 $bibliotitle = $subs->{'bibliotitle'},
85 $notes = $subs->{'notes'};
86 $letter = $subs->{'letter'};
90 librarian => $librarian,
91 aqbooksellerid => $aqbooksellerid,
92 aqbooksellername => $aqbooksellername,
94 aqbudgetid => $aqbudgetid,
95 bookfundid => $bookfundid,
96 startdate => format_date($startdate),
97 periodicity => $periodicity,
99 numberlength => $numberlength,
100 weeklength => $weeklength,
101 monthlength => $monthlength,
104 whenmorethan1 => $whenmorethan1,
106 lastvalue1 => $lastvalue1,
107 innerloop1 => $innerloop1,
110 whenmorethan2 => $whenmorethan2,
112 lastvalue2 => $lastvalue2,
113 innerloop2 => $innerloop2,
116 whenmorethan3 => $whenmorethan3,
118 lastvalue3 => $lastvalue3,
119 innerloop3 => $innerloop3,
120 numberingmethod => $numberingmethod,
122 biblionumber => $biblionumber,
123 bibliotitle => $bibliotitle,
126 subscriptionid => $subscriptionid,
129 "periodicity$periodicity" => 1,
133 ##FIXME : Looks like never used.
134 (my $temp,@budgets) = bookfunds($homebranch);
135 # find default value & set it for the template
136 for (my $i=0;$i<=$#budgets;$i++) {
137 if ($budgets[$i]->{'aqbudgetid'} eq $aqbudgetid) {
138 $budgets[$i]->{'selected'}=1;
141 $template->param(budgets => \@budgets);
142 #FIXME : END Added by hdl on July, 14 2005
144 my @letterlist = GetLetterList('serial');
145 for (my $i=0;$i<=$#letterlist;$i++) {
146 warn "$letterlist[$i]->{'code'} eq ".$letter;
147 $letterlist[$i]->{'selected'} =1 if $letterlist[$i]->{'code'} eq $letter;
149 $template->param(letters => \@letterlist);
151 if ($op eq 'addsubscription') {
152 my $auser = $query->param('user');
153 my $aqbooksellerid = $query->param('aqbooksellerid');
154 my $cost = $query->param('cost');
155 my $aqbudgetid = $query->param('aqbudgetid');
156 my $startdate = $query->param('startdate');
157 my $periodicity = $query->param('periodicity');
158 my $dow = $query->param('dow');
159 my $numberlength = $query->param('numberlength');
160 my $weeklength = $query->param('weeklength');
161 my $monthlength = $query->param('monthlength');
162 my $add1 = $query->param('add1');
163 my $every1 = $query->param('every1');
164 my $whenmorethan1 = $query->param('whenmorethan1');
165 my $setto1 = $query->param('setto1');
166 my $lastvalue1 = $query->param('lastvalue1');
167 my $add2 = $query->param('add2');
168 my $every2 = $query->param('every2');
169 my $whenmorethan2 = $query->param('whenmorethan2');
170 my $setto2 = $query->param('setto2');
171 my $lastvalue2 = $query->param('lastvalue2');
172 my $add3 = $query->param('add3');
173 my $every3 = $query->param('every3');
174 my $whenmorethan3 = $query->param('whenmorethan3');
175 my $setto3 = $query->param('setto3');
176 my $lastvalue3 = $query->param('lastvalue3');
177 my $numberingmethod = $query->param('numberingmethod');
179 my $biblionumber = $query->param('biblionumber');
180 my $notes = $query->param('notes');
181 my $letter = $query->param('letter');
182 my $subscriptionid = newsubscription($auser,$aqbooksellerid,$cost,$aqbudgetid,$biblionumber,
183 $startdate,$periodicity,$dow,$numberlength,$weeklength,$monthlength,
184 $add1,$every1,$whenmorethan1,$setto1,$lastvalue1,
185 $add2,$every2,$whenmorethan2,$setto2,$lastvalue2,
186 $add3,$every3,$whenmorethan3,$setto3,$lastvalue3,
187 $numberingmethod, $status, $notes, $letter
189 print $query->redirect("/cgi-bin/koha/bull/subscription-detail.pl?subscriptionid=$subscriptionid");
191 output_html_with_http_headers $query, $cookie, $template->output;