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
37 use C4::Interface::CGI::Output;
41 my $booksellerid=$input->param('booksellerid');
42 my $title=$input->param('title');
43 my $author=$input->param('author');
44 my $copyright=$input->param('copyright');
45 my ($count,@booksellers)=bookseller($booksellerid);
46 my $ordnum=$input->param('ordnum');
47 my $biblio=$input->param('biblio');
48 my $basketno=$input->param('basketno');
49 my $suggestionid = $input->param('suggestionid');
50 my $close= $input->param('close');
53 my $dbh = C4::Context->dbh;
54 if ($ordnum eq ''){ # create order
56 # $ordnum=newordernum;
57 if ($biblio && !$suggestionid) {
58 $data=bibdata($biblio);
60 # get suggestion fields if applicable. If it's a subscription renewal, then the biblio already exists
61 # otherwise, retrieve suggestion information.
64 $data=bibdata($biblio);
66 $data = getsuggestion($suggestionid);
69 if ($data->{'title'} eq ''){
70 $data->{'title'}=$title;
71 $data->{'author'}=$author;
72 $data->{'copyrightdate'}=$copyright;
75 $data=getsingleorder($ordnum);
76 $biblio=$data->{'biblionumber'};
78 my ($template, $loggedinuser, $cookie)
79 = get_template_and_user({template_name => "acqui/newbiblio.tmpl",
83 flagsrequired => {acquisition => 1},
88 # get currencies (for change rates calcs if needed
89 my ($count,$rates)=getcurrencies();
90 my @loop_currency = ();
91 for (my $i=0;$i<$count;$i++){
93 $line{currency} = $rates->[$i]->{'currency'};
94 $line{rate} = $rates->[$i]->{'rate'};
95 push @loop_currency, \%line;
99 my $sth=$dbh->prepare("Select itemtype,description from itemtypes order by description");
103 while (my ($value,$lib) = $sth->fetchrow_array) {
104 push @itemtype, $value;
105 $itemtypes{$value}=$lib;
107 my $CGIitemtype=CGI::scrolling_list( -name => 'format',
108 -values => \@itemtype,
109 -default => $data->{'itemtype'},
110 -labels => \%itemtypes,
115 # build branches list
116 my $branches = getbranches;
118 foreach my $thisbranch (sort keys %$branches) {
119 my %row =(value => $thisbranch,
120 branchname => $branches->{$thisbranch}->{'branchname'},
122 push @branchloop, \%row;
124 $template->param(branchloop =>\@branchloop);
126 # build bookfund list
127 my $sthtemp = $dbh->prepare("Select flags, branchcode from borrowers where borrowernumber = ?");
128 $sthtemp->execute($loggedinuser);
129 my ($flags, $homebranch)=$sthtemp->fetchrow;
134 my %select_bookfunds;
135 ($count2,@bookfund)=bookfunds($homebranch);
136 for (my $i=0;$i<$count2;$i++){
137 push @select_bookfund, $bookfund[$i]->{'bookfundid'};
138 $select_bookfunds{$bookfund[$i]->{'bookfundid'}} = $bookfund[$i]->{'bookfundname'}
140 my $CGIbookfund=CGI::scrolling_list( -name => 'bookfund',
141 -values => \@select_bookfund,
142 -default => $data->{'bookfundid'},
143 -labels => \%select_bookfunds,
149 $bookfundid=$data->{'bookfundid'};
150 $bookfundname= $select_bookfunds{$bookfundid};
154 my $CGIsort1 = buildCGIsort("Asort1","sort1",$data->{'sort1'});
156 $template->param(CGIsort1 => $CGIsort1);
158 $template->param( sort1 => $data->{'sort1'});
161 my $CGIsort2 = buildCGIsort("Asort2","sort2",$data->{'sort2'});
163 $template->param(CGIsort2 =>$CGIsort2);
165 $template->param( sort2 => $data->{'sort2'});
169 $template->param( close=> $close, bookfundid=>$bookfundid, bookfundname=>$bookfundname) if ($close);
172 $template->param( existing => $biblio,
175 basketno => $basketno,
176 booksellerid => $booksellerid,
177 suggestionid => $suggestionid,
179 biblioitemnumber => $data->{'biblioitemnumber'},
180 itemtype => $data->{'itemtype'},
181 discount => $booksellers[0]->{'discount'},
182 listincgst => $booksellers[0]->{'listincgst'},
183 listprice => $booksellers[0]->{'listprice'},
184 gstreg => $booksellers[0]->{'gstreg'},
185 invoiceinc => $booksellers[0]->{'invoiceincgst'},
186 invoicedisc => $booksellers[0]->{'invoicedisc'},
187 nocalc => $booksellers[0]->{'nocalc'},
188 name => $booksellers[0]->{'name'},
189 currency => $booksellers[0]->{'listprice'},
190 gstrate => C4::Context->preference("gist") ,
191 loop_currencies => \@loop_currency,
192 orderexists => ($new eq 'yes')?0:1,
193 title => $data->{'title'},
194 author => $data->{'author'},
195 copyrightdate => $data->{'copyrightdate'},
196 CGIitemtype => $CGIitemtype,
197 CGIbookfund => $CGIbookfund,
198 isbn => $data->{'isbn'},
199 seriestitle => $data->{'seriestitle'},
200 quantity => $data->{'quantity'},
201 listprice => $data->{'listprice'},
202 rrp => $data->{'rrp'},
203 invoice => $data->{'booksellerinvoicenumber'},
204 ecost => $data->{'ecost'},
205 notes => $data->{'notes'},
206 publishercode => $data->{'publishercode'});
208 output_html_with_http_headers $input, $cookie, $template->output;