reordering code & debugging
[koha.git] / bull / subscription-detail.pl
1 #!/usr/bin/perl
2
3 use strict;
4 use CGI;
5 use C4::Auth;
6 use C4::Koha;
7 use C4::Bull;
8 use C4::Output;
9 use C4::Interface::CGI::Output;
10 use C4::Context;
11 use HTML::Template;
12
13 my $query = new CGI;
14 my $op = $query->param('op');
15 my $dbh = C4::Context->dbh;
16 my $sth;
17 # my $id;
18 my ($template, $loggedinuser, $cookie, $subs);
19 my ($subscriptionid,$auser,$librarian,$cost,$aqbooksellerid, $aqbooksellername,$aqbudgetid, $bookfundid, $startdate, $periodicity,
20         $dow, $numberlength, $weeklength, $monthlength,
21         $seqnum1,$startseqnum1,$seqtype1,$freq1,$step1,
22         $seqnum2,$startseqnum2,$seqtype2,$freq2,$step2,
23         $seqnum3,$startseqnum3,$seqtype3,$freq3,$step3,
24         $numberingmethod, $arrivalplanified, $status, $biblionumber, $bibliotitle, $notes);
25
26 $subscriptionid = $query->param('subscriptionid');
27
28 if ($op eq 'modsubscription') {
29         $auser = $query->param('user');
30         $librarian => $query->param('librarian'),
31         $cost = $query->param('cost');
32         $aqbooksellerid = $query->param('aqbooksellerid');
33         $biblionumber = $query->param('biblionumber');
34         $aqbudgetid = $query->param('aqbudgetid');
35         $startdate = $query->param('startdate');
36         $periodicity = $query->param('periodicity');
37         $dow = $query->param('dow');
38         $numberlength = $query->param('numberlength');
39         $weeklength = $query->param('weeklength');
40         $monthlength = $query->param('monthlength');
41         $seqnum1 = $query->param('seqnum1');
42         $startseqnum1 = $query->param('startseqnum1');
43         $seqtype1 = $query->param('seqtype1');
44         $freq1 = $query->param('freq1');
45         $step1 = $query->param('step1');
46         $seqnum2 = $query->param('seqnum2');
47         $startseqnum2 = $query->param('startseqnum2');
48         $seqtype2 = $query->param('seqtype2');
49         $freq2 = $query->param('freq2');
50         $step2 = $query->param('step2');
51         $seqnum3 = $query->param('seqnum3');
52         $startseqnum3 = $query->param('startseqnum3');
53         $seqtype3 = $query->param('seqtype3');
54         $freq3 = $query->param('freq3');
55         $step3 = $query->param('step3');
56         $numberingmethod = $query->param('numberingmethod');
57         $arrivalplanified = $query->param('arrivalplanified');
58         $status = 1;
59         $notes = $query->param('notes');
60     
61         &modsubscription($auser,$aqbooksellerid,$cost,$aqbudgetid,$startdate,
62                                         $periodicity,$dow,$numberlength,$weeklength,$monthlength,
63                                         $seqnum1,$startseqnum1,$seqtype1,$freq1,$step1,
64                                         $seqnum2,$startseqnum2,$seqtype2,$freq2,$step2,
65                                         $seqnum3,$startseqnum3,$seqtype3,$freq3,$step3,
66                                         $numberingmethod, $arrivalplanified, $status, $biblionumber, $notes, $subscriptionid);
67         
68  } else {
69                 my $subs = &getsubscription($subscriptionid);
70                 $auser = $subs->{'user'};
71                 $librarian => $subs->{'librarian'},
72                 $cost = $subs->{'cost'};
73                 $aqbooksellerid = $subs->{'aqbooksellerid'};
74                 $aqbooksellername = $subs->{'aqbooksellername'};
75                 $bookfundid = $subs->{'bookfundid'};
76                 $aqbudgetid = $subs->{'aqbudgetid'};
77                 $startdate = $subs->{'startdate'};
78                 $periodicity = $subs->{'periodicity'};
79                 $dow = $subs->{'dow'};
80                 $numberlength = $subs->{'numberlength'};
81                 $weeklength = $subs->{'weeklength'};
82                 $monthlength = $subs->{'monthlength'};
83                 $seqnum1 = $subs->{'seqnum1'};
84                 $startseqnum1 = $subs->{'startseqnum1'};
85                 $seqtype1 = $subs->{'seqtype1'};
86                 $freq1 = $subs->{'freq1'};
87                 $step1 = $subs->{'step1'};
88                 $seqnum2 = $subs->{'seqnum2'};
89                 $startseqnum2 = $subs->{'startseqnum2'};
90                 $seqtype2 = $subs->{'seqtype2'};
91                 $freq2 = $subs->{'freq2'};
92                 $step2 = $subs->{'step2'};
93                 $seqnum3 = $subs->{'seqnum3'};
94                 $startseqnum3 = $subs->{'startseqnum3'};
95                 $seqtype3 = $subs->{'seqtype3'};
96                 $freq3 = $subs->{'freq3'};
97                 $step3 = $subs->{'step3'};
98                 $numberingmethod = $subs->{'numberingmethod'};
99                 $arrivalplanified = $subs->{'arrivalplanified'};
100                 $status = $subs->{status};
101                 $biblionumber = $subs->{'biblionumber'};
102                 $bibliotitle = $subs->{'bibliotitle'},
103                 $notes = $subs->{'notes'};
104         
105 }
106
107 ($template, $loggedinuser, $cookie)
108 = get_template_and_user({template_name => "bull/subscription-detail.tmpl",
109                                 query => $query,
110                                 type => "intranet",
111                                 authnotrequired => 0,
112                                 flagsrequired => {catalogue => 1},
113                                 debug => 1,
114                                 });
115
116 my ($user, $cookie, $sessionID, $flags)
117         = checkauth($query, 0, {catalogue => 1}, "intranet");
118
119 $template->param(
120         user => $auser,
121         librarian => $librarian,
122         aqbooksellerid => $aqbooksellerid,
123         aqbooksellername => $aqbooksellername,
124         cost => $cost,
125         aqbudgetid => $aqbudgetid,
126         bookfundid => $bookfundid,
127         startdate => $startdate,
128         periodicity => $periodicity,
129         dow => $dow,
130         numberlength => $numberlength,
131         weeklength => $weeklength,
132         monthlength => $monthlength,
133         seqnum1 =>$seqnum1,
134         startseqnum1 =>$startseqnum1,
135         seqtype1 =>$seqtype1,
136         freq1 =>$freq1,
137         step1 =>$step1,
138         seqnum2 => $seqnum2,
139         startseqnum2 => $startseqnum2,
140         seqtype2 => $seqtype2,
141         freq2 => $freq2,
142         step2 => $step2,
143         seqnum3 => $seqnum3,
144         startseqnum3 => $startseqnum3,
145         seqtype3 => $seqtype3,
146         freq3 => $freq3,
147         step3 => $step3,
148         numberingmethod => $numberingmethod,
149         arrivalplanified => $arrivalplanified,
150         status => $status,
151         biblionumber => $biblionumber,
152         bibliotitle => $bibliotitle,
153         notes => $notes,
154         subscriptionid => $subscriptionid
155         );
156 $template->param(
157                         "periodicity$periodicity" => 1,
158                         "seqtype1$seqtype1" => 1,
159                         "seqtype2$seqtype2" => 1,
160                         "seqtype3$seqtype3" => 1,
161                         "arrival$dow" => 1,
162                         );
163
164
165 output_html_with_http_headers $query, $cookie, $template->output;