3 # Copyright 2000-2003 Katipo Communications
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA 02111-1307 USA
28 this script add a subscription into the database.
35 op use to know the operation to do on this template.
36 * mod : to modify an existing subscription
37 * addsubscription : to add a subscription
39 Note that if op = mod or addsubscription there are a lot of other params.
55 use C4::Interface::CGI::Output;
62 my $op = $query->param('op');
63 my $dbh = C4::Context->dbh;
64 my ($subscriptionid,$auser,$librarian,$cost,$aqbooksellerid, $aqbooksellername,$aqbudgetid, $bookfundid, $startdate, $periodicity,
65 $dow, $numberlength, $weeklength, $monthlength,
66 $add1,$every1,$whenmorethan1,$setto1,$lastvalue1,$innerloop1,
67 $add2,$every2,$whenmorethan2,$setto2,$lastvalue2,$innerloop2,
68 $add3,$every3,$whenmorethan3,$setto3,$lastvalue3,$innerloop3,
69 $numberingmethod, $status, $biblionumber,
70 $bibliotitle, $notes, $letter);
73 my ($template, $loggedinuser, $cookie)
74 = get_template_and_user({template_name => "serials/subscription-add.tmpl",
78 flagsrequired => {catalogue => 1},
83 my $subscriptionid = $query->param('subscriptionid');
84 my $subs = &GetSubscription($subscriptionid);
85 $auser = $subs->{'user'};
86 $librarian = $subs->{'librarian'};
87 $cost = $subs->{'cost'};
88 $aqbooksellerid = $subs->{'aqbooksellerid'};
89 $aqbooksellername = $subs->{'aqbooksellername'};
90 $bookfundid = $subs->{'bookfundid'};
91 $aqbudgetid = $subs->{'aqbudgetid'};
92 defined $aqbudgetid or $aqbudgetid='';
93 $startdate = $subs->{'startdate'};
94 $periodicity = $subs->{'periodicity'};
95 $dow = $subs->{'dow'};
96 $numberlength = $subs->{'numberlength'};
97 $weeklength = $subs->{'weeklength'};
98 $monthlength = $subs->{'monthlength'};
99 $add1 = $subs->{'add1'};
100 $every1 = $subs->{'every1'};
101 $whenmorethan1 = $subs->{'whenmorethan1'};
102 $setto1 = $subs->{'setto1'};
103 $lastvalue1 = $subs->{'lastvalue1'};
104 $innerloop1 = $subs->{'innerloop1'};
105 $add2 = $subs->{'add2'};
106 $every2 = $subs->{'every2'};
107 $whenmorethan2 = $subs->{'whenmorethan2'};
108 $setto2 = $subs->{'setto2'};
109 $lastvalue2 = $subs->{'lastvalue2'};
110 $innerloop2 = $subs->{'innerloop2'};
111 $add3 = $subs->{'add3'};
112 $every3 = $subs->{'every3'};
113 $whenmorethan3 = $subs->{'whenmorethan3'};
114 $setto3 = $subs->{'setto3'};
115 $lastvalue3 = $subs->{'lastvalue3'};
116 $innerloop3 = $subs->{'innerloop3'};
117 $numberingmethod = $subs->{'numberingmethod'};
118 $status = $subs->{status};
119 $biblionumber = $subs->{'biblionumber'};
120 $bibliotitle = $subs->{'bibliotitle'},
121 $notes = $subs->{'notes'};
122 $letter = $subs->{'letter'};
123 defined $letter or $letter='';
127 librarian => $librarian,
128 aqbooksellerid => $aqbooksellerid,
129 aqbooksellername => $aqbooksellername,
131 aqbudgetid => $aqbudgetid,
132 bookfundid => $bookfundid,
133 startdate => format_date($startdate),
134 periodicity => $periodicity,
136 numberlength => $numberlength,
137 weeklength => $weeklength,
138 monthlength => $monthlength,
141 whenmorethan1 => $whenmorethan1,
143 lastvalue1 => $lastvalue1,
144 innerloop1 => $innerloop1,
147 whenmorethan2 => $whenmorethan2,
149 lastvalue2 => $lastvalue2,
150 innerloop2 => $innerloop2,
153 whenmorethan3 => $whenmorethan3,
155 lastvalue3 => $lastvalue3,
156 innerloop3 => $innerloop3,
157 numberingmethod => $numberingmethod,
159 biblionumber => $biblionumber,
160 bibliotitle => $bibliotitle,
163 subscriptionid => $subscriptionid,
164 "periodicity$periodicity" => 1,
169 my @letterlist = GetLetterList('serial');
170 for (my $i=0;$i<=$#letterlist;$i++) {
171 $letterlist[$i]->{'selected'} =1 if $letterlist[$i]->{'code'} eq $letter;
173 $template->param(letters => \@letterlist);
175 if ($op eq 'addsubscription') {
176 my $auser = $query->param('user');
177 my $aqbooksellerid = $query->param('aqbooksellerid');
178 my $cost = $query->param('cost');
179 my $aqbudgetid = $query->param('aqbudgetid');
180 my $startdate = $query->param('startdate');
181 my $periodicity = $query->param('periodicity');
182 my $dow = $query->param('dow');
183 my $numberlength = $query->param('numberlength');
184 my $weeklength = $query->param('weeklength');
185 my $monthlength = $query->param('monthlength');
186 my $add1 = $query->param('add1');
187 my $every1 = $query->param('every1');
188 my $whenmorethan1 = $query->param('whenmorethan1');
189 my $setto1 = $query->param('setto1');
190 my $lastvalue1 = $query->param('lastvalue1');
191 my $add2 = $query->param('add2');
192 my $every2 = $query->param('every2');
193 my $whenmorethan2 = $query->param('whenmorethan2');
194 my $setto2 = $query->param('setto2');
195 my $lastvalue2 = $query->param('lastvalue2');
196 my $add3 = $query->param('add3');
197 my $every3 = $query->param('every3');
198 my $whenmorethan3 = $query->param('whenmorethan3');
199 my $setto3 = $query->param('setto3');
200 my $lastvalue3 = $query->param('lastvalue3');
201 my $numberingmethod = $query->param('numberingmethod');
203 my $biblionumber = $query->param('biblionumber');
204 my $notes = $query->param('notes');
205 my $letter = $query->param('letter');
206 my $subscriptionid = NewSubscription($auser,$aqbooksellerid,$cost,$aqbudgetid,$biblionumber,
207 $startdate,$periodicity,$dow,$numberlength,$weeklength,$monthlength,
208 $add1,$every1,$whenmorethan1,$setto1,$lastvalue1,
209 $add2,$every2,$whenmorethan2,$setto2,$lastvalue2,
210 $add3,$every3,$whenmorethan3,$setto3,$lastvalue3,
211 $numberingmethod, $status, $notes, $letter
213 print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
215 output_html_with_http_headers $query, $cookie, $template->output;