11 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 $firstacquidate, $dow, $irregularity, $numberpattern, $numberlength, $weeklength, $monthlength, $sublength,
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, $callnumber, $notes, $hemisphere);
29 my ($template, $loggedinuser, $cookie)
30 = get_template_and_user({template_name => "serials/alt_subscription-add.tmpl",
34 flagsrequired => {catalogue => 1},
41 my ($year, $month, $day) = UnixDate("today", "%Y", "%m", "%d");
42 my $firstday = Date_DayOfYear($month,$day,$year);
43 my $wkno = Date_WeekOfYear($month,$day,$year,1); # week starting monday
45 for(my $i=$firstday;$i<($firstday+365);$i=$i+7){
47 if($wkno > 52){$year++; $wkno=1;}
48 if($count>365){$count=$i-365;}
49 my ($y,$m,$d) = Date_NthDayOfYear($year,$count);
50 my $output = "$y-$m-$d";
51 $weekarrayjs .= "'Wk $wkno: ".format_date($output)."',";
58 my @subscription_types = (
59 'issues', 'weeks', 'months'
63 my $subscriptionid = $query->param('subscriptionid');
64 my $subs = &GetSubscription($subscriptionid);
65 $auser = $subs->{'user'};
66 $librarian => $subs->{'librarian'},
67 $cost = $subs->{'cost'};
68 $aqbooksellerid = $subs->{'aqbooksellerid'};
69 $aqbooksellername = $subs->{'aqbooksellername'};
70 $startdate = $subs->{'startdate'};
71 $firstacquidate = $subs->{'firstacquidate'};
72 $periodicity = $subs->{'periodicity'};
73 $dow = $subs->{'dow'};
74 $irregularity = $subs->{'irregularity'};
75 $numberpattern = $subs->{'numberpattern'};
76 $numberlength = $subs->{'numberlength'};
77 $weeklength = $subs->{'weeklength'};
78 $monthlength = $subs->{'monthlength'};
81 $sublength = $monthlength;
82 $sub_on = $subscription_types[2];
83 } elsif ($weeklength>0){
84 $sublength = $weeklength;
85 $sub_on = $subscription_types[1];
87 $sublength = $numberlength;
88 $sub_on = $subscription_types[0];
92 while (@subscription_types) {
93 my $sub_type = shift @subscription_types;
94 my %row = ( 'name' => $sub_type );
95 if ( $sub_on eq $sub_type ) {
96 $row{'selected'} = ' selected';
98 $row{'selected'} = '';
100 push( @sub_type_data, \%row );
103 $add1 = $subs->{'add1'};
104 $every1 = $subs->{'every1'};
105 $whenmorethan1 = $subs->{'whenmorethan1'};
106 $setto1 = $subs->{'setto1'};
107 $lastvalue1 = $subs->{'lastvalue1'};
108 $innerloop1 = $subs->{'innerloop1'};
109 $add2 = $subs->{'add2'};
110 $every2 = $subs->{'every2'};
111 $whenmorethan2 = $subs->{'whenmorethan2'};
112 $setto2 = $subs->{'setto2'};
113 $lastvalue2 = $subs->{'lastvalue2'};
114 $innerloop2 = $subs->{'innerloop2'};
115 $add3 = $subs->{'add3'};
116 $every3 = $subs->{'every3'};
117 $whenmorethan3 = $subs->{'whenmorethan3'};
118 $setto3 = $subs->{'setto3'};
119 $lastvalue3 = $subs->{'lastvalue3'};
120 $innerloop3 = $subs->{'innerloop3'};
121 $numberingmethod = $subs->{'numberingmethod'};
122 $status = $subs->{status};
123 $biblionumber = $subs->{'biblionumber'};
124 $bibliotitle = $subs->{'bibliotitle'};
125 $callnumber = $subs->{'callnumber'};
126 $notes = $subs->{'notes'};
127 $hemisphere = $subs->{'hemisphere'};
131 librarian => $librarian,
132 aqbooksellerid => $aqbooksellerid,
133 aqbooksellername => $aqbooksellername,
135 aqbudgetid => $aqbudgetid,
136 bookfundid => $bookfundid,
137 startdate => format_date($startdate),
138 firstacquidate => format_date($firstacquidate),
139 periodicity => $periodicity,
141 irregularity => $irregularity,
142 numberpattern => $numberpattern,
143 sublength => $sublength,
144 subtype => \@sub_type_data,
147 whenmorethan1 => $whenmorethan1,
149 lastvalue1 => $lastvalue1,
150 innerloop1 => $innerloop1,
153 whenmorethan2 => $whenmorethan2,
155 lastvalue2 => $lastvalue2,
156 innerloop2 => $innerloop2,
159 whenmorethan3 => $whenmorethan3,
161 lastvalue3 => $lastvalue3,
162 innerloop3 => $innerloop3,
163 numberingmethod => $numberingmethod,
165 biblionumber => $biblionumber,
166 bibliotitle => $bibliotitle,
167 callnumber => $callnumber,
169 subscriptionid => $subscriptionid,
170 weekarrayjs => $weekarrayjs,
172 hemisphere => $hemisphere,
176 "periodicity$periodicity" => 1,
178 "numberpattern$numberpattern" => 1,
182 if ($op eq 'addsubscription') {
183 my @irregular = $query->param('irregular');
184 my $irregular_count = @irregular;
185 for(my $i =0;$i<$irregular_count;$i++){
186 $irregularity .=$irregular[$i]."|";
188 $irregularity =~ s/\|$//;
190 my $auser = $query->param('user');
191 my $aqbooksellerid = $query->param('aqbooksellerid');
192 my $cost = $query->param('cost');
193 my $aqbudgetid = $query->param('aqbudgetid');
194 my $startdate = $query->param('startdate');
195 my $firstacquidate = $query->param('firstacquidate');
196 my $periodicity = $query->param('periodicity');
197 my $dow = $query->param('dow');
198 # my $irregularity = $query->param('irregularity');
199 my $numberlength = 0;
202 my $numberpattern = $query->param('numbering_pattern');
203 my $sublength = $query->param('sublength');
204 my $subtype = $query->param('subtype');
205 if ($subtype eq 'months'){
206 $monthlength = $sublength;
207 } elsif ($subtype eq 'weeks'){
208 $weeklength = $sublength;
210 $numberlength = $sublength;
213 my $add1 = $query->param('add1');
214 my $every1 = $query->param('every1');
215 my $whenmorethan1 = $query->param('whenmorethan1');
216 my $setto1 = $query->param('setto1');
217 my $lastvalue1 = $query->param('lastvalue1');
218 my $add2 = $query->param('add2');
219 my $every2 = $query->param('every2');
220 my $whenmorethan2 = $query->param('whenmorethan2');
221 my $setto2 = $query->param('setto2');
222 my $lastvalue2 = $query->param('lastvalue2');
223 my $add3 = $query->param('add3');
224 my $every3 = $query->param('every3');
225 my $whenmorethan3 = $query->param('whenmorethan3');
226 my $setto3 = $query->param('setto3');
227 my $lastvalue3 = $query->param('lastvalue3');
228 my $numberingmethod = $query->param('numberingmethod');
230 my $biblionumber = $query->param('biblionumber');
231 my $callnumber = $query->param('callnumber');
232 my $notes = $query->param('notes');
233 my $hemisphere = $query->param('hemisphere') || 1;
235 my $subscriptionid = old_newsubscription($auser,$aqbooksellerid,$cost,$aqbudgetid,$biblionumber,
236 $startdate,$periodicity,$firstacquidate,$dow,$irregularity,$numberpattern,$numberlength,$weeklength,$monthlength,
237 $add1,$every1,$whenmorethan1,$setto1,$lastvalue1,
238 $add2,$every2,$whenmorethan2,$setto2,$lastvalue2,
239 $add3,$every3,$whenmorethan3,$setto3,$lastvalue3,
240 $numberingmethod, $status, $callnumber, $notes, $hemisphere
242 print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
245 while (@subscription_types) {
246 my $sub_type = shift @subscription_types;
247 my %row = ( 'name' => $sub_type );
248 if ( $sub_on eq $sub_type ) {
249 $row{'selected'} = ' selected';
251 $row{'selected'} = '';
253 push( @sub_type_data, \%row );
255 $template->param(subtype => \@sub_type_data,
256 weekarrayjs => $weekarrayjs,
259 output_html_with_http_headers $query, $cookie, $template->output;