3 #script to show display basket of orders
4 #written by chris@katipo.co.nz 24/2/2000
7 # Copyright 2000-2002 Katipo Communications
9 # This file is part of Koha.
11 # Koha is free software; you can redistribute it and/or modify it under the
12 # terms of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
16 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
17 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
18 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License along with
21 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
22 # Suite 330, Boston, MA 02111-1307 USA
35 use C4::Interface::CGI::Output;
39 my $booksellerid=$input->param('booksellerid');
40 my $title=$input->param('title');
41 my $author=$input->param('author');
42 my $copyright=$input->param('copyright');
43 my ($count,@booksellers)=bookseller($booksellerid);
44 my $ordnum=$input->param('ordnum');
45 my $biblio=$input->param('biblio');
46 my $basketno=$input->param('basketno');
47 my $suggestionid = $input->param('suggestionid');
50 my $dbh = C4::Context->dbh;
51 if ($ordnum eq ''){ # create order
53 # $ordnum=newordernum;
54 if ($biblio && !$suggestionid) {
55 $data=bibdata($biblio);
57 # get suggestion fields if applicable. If it's a subscription renewal, then the biblio already exists
58 # otherwise, retrieve suggestion information.
61 $data=bibdata($biblio);
63 $data = getsuggestion($suggestionid);
66 if ($data->{'title'} eq ''){
67 $data->{'title'}=$title;
68 $data->{'author'}=$author;
69 $data->{'copyrightdate'}=$copyright;
72 $data=getsingleorder($ordnum);
73 $biblio=$data->{'biblionumber'};
75 my ($template, $loggedinuser, $cookie)
76 = get_template_and_user({template_name => "acqui/newbiblio.tmpl",
80 flagsrequired => {acquisition => 1},
85 # get currencies (for change rates calcs if needed
86 my ($count,$rates)=getcurrencies();
87 my @loop_currency = ();
88 for (my $i=0;$i<$count;$i++){
90 $line{currency} = $rates->[$i]->{'currency'};
91 $line{rate} = $rates->[$i]->{'rate'};
92 push @loop_currency, \%line;
96 my $sth=$dbh->prepare("Select itemtype,description from itemtypes order by description");
100 while (my ($value,$lib) = $sth->fetchrow_array) {
101 push @itemtype, $value;
102 $itemtypes{$value}=$lib;
104 my $CGIitemtype=CGI::scrolling_list( -name => 'format',
105 -values => \@itemtype,
106 -default => $data->{'itemtype'},
107 -labels => \%itemtypes,
112 # build branches list
116 my ($count2,@branches)=branches();
117 for (my $i=0;$i<$count2;$i++){
118 push @select_branch, $branches[$i]->{'branchcode'};#
119 $select_branches{$branches[$i]->{'branchcode'}} = $branches[$i]->{'branchname'};
121 my $CGIbranch=CGI::scrolling_list( -name => 'branch',
122 -values => \@select_branch,
123 -default => $data->{'branchcode'},
124 -labels => \%select_branches,
128 # build bookfund list
129 my $sthtemp = $dbh->prepare("Select flags, branchcode from borrowers where borrowernumber = ?");
130 $sthtemp->execute($loggedinuser);
131 my ($flags, $homebranch)=$sthtemp->fetchrow;
135 my %select_bookfunds;
136 ($count2,@bookfund)=bookfunds($homebranch);
137 for (my $i=0;$i<$count2;$i++){
138 push @select_bookfund, $bookfund[$i]->{'bookfundid'};
139 $select_bookfunds{$bookfund[$i]->{'bookfundid'}} = $bookfund[$i]->{'bookfundname'}
141 my $CGIbookfund=CGI::scrolling_list( -name => 'bookfund',
142 -values => \@select_bookfund,
143 -default => $data->{'bookfundid'},
144 -labels => \%select_bookfunds,
149 my $CGIsort1 = buildCGIsort("Asort1","sort1",$data->{'sort1'});
151 $template->param(CGIsort1 => $CGIsort1);
153 $template->param( sort1 => $data->{'sort1'});
156 my $CGIsort2 = buildCGIsort("Asort2","sort2",$data->{'sort2'});
158 $template->param(CGIsort2 =>$CGIsort2);
160 $template->param( sort2 => $data->{'sort2'});
164 $template->param( existing => $biblio,
167 basketno => $basketno,
168 booksellerid => $booksellerid,
169 suggestionid => $suggestionid,
171 biblioitemnumber => $data->{'biblioitemnumber'},
172 itemtype => $data->{'itemtype'},
173 discount => $booksellers[0]->{'discount'},
174 listincgst => $booksellers[0]->{'listincgst'},
175 listprice => $booksellers[0]->{'listprice'},
176 gstreg => $booksellers[0]->{'gstreg'},
177 invoiceinc => $booksellers[0]->{'invoiceincgst'},
178 invoicedisc => $booksellers[0]->{'invoicedisc'},
179 nocalc => $booksellers[0]->{'nocalc'},
180 name => $booksellers[0]->{'name'},
181 currency => $booksellers[0]->{'listprice'},
182 gstrate => C4::Context->preference("gist") ,
183 loop_currencies => \@loop_currency,
184 orderexists => ($new eq 'yes')?0:1,
185 title => $data->{'title'},
186 author => $data->{'author'},
187 copyrightdate => $data->{'copyrightdate'},
188 CGIitemtype => $CGIitemtype,
189 CGIbranch => $CGIbranch,
190 CGIbookfund => $CGIbookfund,
191 isbn => $data->{'isbn'},
192 seriestitle => $data->{'seriestitle'},
193 quantity => $data->{'quantity'},
194 listprice => $data->{'listprice'},
195 rrp => $data->{'rrp'},
196 invoice => $data->{'booksellerinvoicenumber'},
197 ecost => $data->{'ecost'},
198 notes => $data->{'notes'},
199 publishercode => $data->{'publishercode'});
201 output_html_with_http_headers $input, $cookie, $template->output;