serials : lot of bugfixes.
[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, $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 = format_date_in_iso($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         $status = 1;
59         $notes = $query->param('notes');
60     
61         &modsubscription($auser,$aqbooksellerid,$cost,$aqbudgetid,$startdate,
62                                         $periodicity,$dow,$numberlength,$weeklength,$monthlength,
63                                         $add1,$every1,$whenmorethan1,$setto1,$lastvalue1,
64                                         $add2,$every2,$whenmorethan2,$setto2,$lastvalue2,
65                                         $add3,$every3,$whenmorethan3,$setto3,$lastvalue3,
66                                         $numberingmethod, $status, $biblionumber, $notes, $subscriptionid);
67 }
68
69 my $subs = &getsubscription($subscriptionid);
70 my @serialslist = getserials($subscriptionid);
71
72 ($template, $loggedinuser, $cookie)
73 = get_template_and_user({template_name => "bull/subscription-detail.tmpl",
74                                 query => $query,
75                                 type => "intranet",
76                                 authnotrequired => 0,
77                                 flagsrequired => {catalogue => 1},
78                                 debug => 1,
79                                 });
80
81 my ($user, $cookie, $sessionID, $flags)
82         = checkauth($query, 0, {catalogue => 1}, "intranet");
83
84 $template->param(
85         user => $subs->{auser},
86         librarian => $subs->{librarian},
87         aqbooksellerid => $subs->{aqbooksellerid},
88         aqbooksellername => $subs->{aqbooksellername},
89         cost => $subs->{cost},
90         aqbudgetid => $subs->{aqbudgetid},
91         bookfundid => $subs->{bookfundid},
92         startdate => format_date($subs->{startdate}),
93         periodicity => $subs->{periodicity},
94         dow => $subs->{dow},
95         numberlength => $subs->{numberlength},
96         weeklength => $subs->{weeklength},
97         monthlength => $subs->{monthlength},
98         add1 => $subs->{add1},
99         every1 => $subs->{every1},
100         whenmorethan1 => $subs->{whenmorethan1},
101         setto1 => $subs->{setto1},
102         lastvalue1 => $subs->{lastvalue1},
103         add2 => $subs->{add2},
104         every2 => $subs->{every2},
105         whenmorethan2 => $subs->{whenmorethan2},
106         setto2 => $subs->{setto2},
107         lastvalue2 => $subs->{lastvalue2},
108         add3 => $subs->{add3},
109         every3 => $subs->{every3},
110         whenmorethan3 => $subs->{whenmorethan3},
111         setto3 => $subs->{setto3},
112         lastvalue3 => $subs->{lastvalue3},
113         numberingmethod => $subs->{numberingmethod},
114         status => $subs->{status},
115         biblionumber => $subs->{biblionumber},
116         bibliotitle => $subs->{bibliotitle},
117         notes => $subs->{notes},
118         subscriptionid => $subs->{subscriptionid},
119         serialslist => \@serialslist,
120         );
121 $template->param(
122                         "periodicity$subs->{periodicity}" => 1,
123                         "arrival$subs->{dow}" => 1,
124                         );
125
126 output_html_with_http_headers $query, $cookie, $template->output;