changing DB structure to calculate next issue number.
[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::Date;
8 use C4::Bull;
9 use C4::Output;
10 use C4::Interface::CGI::Output;
11 use C4::Context;
12 use HTML::Template;
13
14 my $query = new CGI;
15 my $op = $query->param('op');
16 my $dbh = C4::Context->dbh;
17 my $sth;
18 # my $id;
19 my ($template, $loggedinuser, $cookie, $subs);
20 my ($subscriptionid,$auser,$librarian,$cost,$aqbooksellerid, $aqbooksellername,$aqbudgetid, $bookfundid, $startdate, $periodicity,
21         $dow, $numberlength, $weeklength, $monthlength,
22         $add1,$every1,$whenmorethan1,$setto1,$lastvalue1,
23         $add2,$every2,$whenmorethan2,$setto2,$lastvalue2,
24         $add3,$every3,$whenmorethan3,$setto3,$lastvalue3,
25         $numberingmethod, $arrivalplanified, $status, $biblionumber, $bibliotitle, $notes);
26
27 $subscriptionid = $query->param('subscriptionid');
28
29 if ($op eq 'modsubscription') {
30         $auser = $query->param('user');
31         $librarian => $query->param('librarian'),
32         $cost = $query->param('cost');
33         $aqbooksellerid = $query->param('aqbooksellerid');
34         $biblionumber = $query->param('biblionumber');
35         $aqbudgetid = $query->param('aqbudgetid');
36         $startdate = $query->param('startdate');
37         $periodicity = $query->param('periodicity');
38         $dow = $query->param('dow');
39         $numberlength = $query->param('numberlength');
40         $weeklength = $query->param('weeklength');
41         $monthlength = $query->param('monthlength');
42         $add1 = $query->param('add1');
43         $every1 = $query->param('every1');
44         $whenmorethan1 = $query->param('whenmorethan1');
45         $setto1 = $query->param('setto1');
46         $lastvalue1 = $query->param('lastvalue1');
47         $add2 = $query->param('add2');
48         $every2 = $query->param('every2');
49         $whenmorethan2 = $query->param('whenmorethan2');
50         $setto2 = $query->param('setto2');
51         $lastvalue2 = $query->param('lastvalue2');
52         $add3 = $query->param('add3');
53         $every3 = $query->param('every3');
54         $whenmorethan3 = $query->param('whenmorethan3');
55         $setto3 = $query->param('setto3');
56         $lastvalue3 = $query->param('lastvalue3');
57         $numberingmethod = $query->param('numberingmethod');
58         $arrivalplanified = $query->param('arrivalplanified');
59         $status = 1;
60         $notes = $query->param('notes');
61     
62         &modsubscription($auser,$aqbooksellerid,$cost,$aqbudgetid,$startdate,
63                                         $periodicity,$dow,$numberlength,$weeklength,$monthlength,
64                                         $add1,$every1,$whenmorethan1,$setto1,$lastvalue1,
65                                         $add2,$every2,$whenmorethan2,$setto2,$lastvalue2,
66                                         $add3,$every3,$whenmorethan3,$setto3,$lastvalue3,
67                                         $numberingmethod, $arrivalplanified, $status, $biblionumber, $notes, $subscriptionid);
68 }
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         $add1 = $subs->{'add1'};
84         $every1 = $subs->{'every1'};
85         $whenmorethan1 = $subs->{'whenmorethan1'};
86         $setto1 = $subs->{'setto1'};
87         $lastvalue1 = $subs->{'lastvalue1'};
88         $add2 = $subs->{'add2'};
89         $every2 = $subs->{'every2'};
90         $whenmorethan2 = $subs->{'whenmorethan2'};
91         $setto2 = $subs->{'setto2'};
92         $lastvalue2 = $subs->{'lastvalue2'};
93         $add3 = $subs->{'add3'};
94         $every3 = $subs->{'every3'};
95         $whenmorethan3 = $subs->{'whenmorethan3'};
96         $setto3 = $subs->{'setto3'};
97         $lastvalue3 = $subs->{'lastvalue3'};
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 ($template, $loggedinuser, $cookie)
106 = get_template_and_user({template_name => "bull/subscription-detail.tmpl",
107                                 query => $query,
108                                 type => "intranet",
109                                 authnotrequired => 0,
110                                 flagsrequired => {catalogue => 1},
111                                 debug => 1,
112                                 });
113
114 my ($user, $cookie, $sessionID, $flags)
115         = checkauth($query, 0, {catalogue => 1}, "intranet");
116
117 $template->param(
118         user => $auser,
119         librarian => $librarian,
120         aqbooksellerid => $aqbooksellerid,
121         aqbooksellername => $aqbooksellername,
122         cost => $cost,
123         aqbudgetid => $aqbudgetid,
124         bookfundid => $bookfundid,
125         startdate => format_date($startdate),
126         periodicity => $periodicity,
127         dow => $dow,
128         numberlength => $numberlength,
129         weeklength => $weeklength,
130         monthlength => $monthlength,
131         add1 => $add1,
132         every1 => $every1,
133         whenmorethan1 => $whenmorethan1,
134         setto1 => $setto1,
135         lastvalue1 => $lastvalue1,
136         add2 => $add2,
137         every2 => $every2,
138         whenmorethan2 => $whenmorethan2,
139         setto2 => $setto2,
140         lastvalue2 => $lastvalue2,
141         add3 => $add3,
142         every3 => $every3,
143         whenmorethan3 => $whenmorethan3,
144         setto3 => $setto3,
145         lastvalue3 => $lastvalue3,
146         numberingmethod => $numberingmethod,
147         arrivalplanified => $arrivalplanified,
148         status => $status,
149         biblionumber => $biblionumber,
150         bibliotitle => $bibliotitle,
151         notes => $notes,
152         subscriptionid => $subscriptionid
153         );
154 $template->param(
155                         "periodicity$periodicity" => 1,
156                         "arrival$dow" => 1,
157                         );
158
159 output_html_with_http_headers $query, $cookie, $template->output;