12 use C4::Interface::CGI::Output;
18 my $op = $query->param('op');
19 my $dbh = C4::Context->dbh;
20 my ($subscriptionid,$auser,$librarian,$cost,$aqbooksellerid, $aqbooksellername,$aqbudgetid, $bookfundid, $startdate, $periodicity,
21 $dow, $numberlength, $weeklength, $monthlength,
22 $add1,$every1,$whenmorethan1,$setto1,$lastvalue1,$innerloop1,
23 $add2,$every2,$whenmorethan2,$setto2,$lastvalue2,$innerloop2,
24 $add3,$every3,$whenmorethan3,$setto3,$lastvalue3,$innerloop3,
25 $numberingmethod, $status, $biblionumber,
26 $bibliotitle, $notes, $letter);
29 my ($template, $loggedinuser, $cookie)
30 = get_template_and_user({template_name => "serials/subscription-add.tmpl",
34 flagsrequired => {catalogue => 1},
39 #FIXME : If Budgets are never used, then these lines are useless.
40 $dbh = C4::Context->dbh;
41 my $sthtemp = $dbh->prepare("Select flags, branchcode from borrowers where borrowernumber = ?");
42 $sthtemp->execute($loggedinuser);
43 my ($flags, $homebranch)=$sthtemp->fetchrow;
44 #FIXME : END added by hdl on July,14 2005
47 my $subscriptionid = $query->param('subscriptionid');
48 my $subs = &GetSubscription($subscriptionid);
49 $auser = $subs->{'user'};
50 $librarian = $subs->{'librarian'};
51 $cost = $subs->{'cost'};
52 $aqbooksellerid = $subs->{'aqbooksellerid'};
53 $aqbooksellername = $subs->{'aqbooksellername'};
54 $bookfundid = $subs->{'bookfundid'};
55 $aqbudgetid = $subs->{'aqbudgetid'};
56 defined $aqbudgetid or $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'};
87 defined $letter or $letter='';
91 librarian => $librarian,
92 aqbooksellerid => $aqbooksellerid,
93 aqbooksellername => $aqbooksellername,
95 aqbudgetid => $aqbudgetid,
96 bookfundid => $bookfundid,
97 startdate => format_date($startdate),
98 periodicity => $periodicity,
100 numberlength => $numberlength,
101 weeklength => $weeklength,
102 monthlength => $monthlength,
105 whenmorethan1 => $whenmorethan1,
107 lastvalue1 => $lastvalue1,
108 innerloop1 => $innerloop1,
111 whenmorethan2 => $whenmorethan2,
113 lastvalue2 => $lastvalue2,
114 innerloop2 => $innerloop2,
117 whenmorethan3 => $whenmorethan3,
119 lastvalue3 => $lastvalue3,
120 innerloop3 => $innerloop3,
121 numberingmethod => $numberingmethod,
123 biblionumber => $biblionumber,
124 bibliotitle => $bibliotitle,
127 subscriptionid => $subscriptionid,
130 "periodicity$periodicity" => 1,
134 ##FIXME : Looks like never used.
135 (my $temp,@budgets) = bookfunds($homebranch);
136 # find default value & set it for the template
137 for (my $i=0;$i<$#budgets;$i++) {
138 if ($budgets[$i]->{'aqbudgetid'} eq $aqbudgetid) {
139 $budgets[$i]->{'selected'}=1;
142 $template->param(budgets => \@budgets);
143 #FIXME : END Added by hdl on July, 14 2005
145 my @letterlist = GetLetterList('serial');
146 for (my $i=0;$i<=$#letterlist;$i++) {
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/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
191 output_html_with_http_headers $query, $cookie, $template->output;