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 if ((!C4::Context->preference('IndependantBranches'))||(C4::Context->preference('IndependantBranches') && (C4::Context->userenv->{flags} ==1))
119 ||((C4::Context->preference('IndependantBranches') && (C4::Context->userenv->{flags} !=1) && (C4::Context->userenv->{branch} eq $branches[$i]->{'branchcode'})))){
120 push @select_branch, $branches[$i]->{'branchcode'};#
121 $select_branches{$branches[$i]->{'branchcode'}} = $branches[$i]->{'branchname'};
124 my $CGIbranch=CGI::scrolling_list( -name => 'branch',
125 -values => \@select_branch,
126 -default => $data->{'branchcode'},
127 -labels => \%select_branches,
131 # build bookfund list
132 my $sthtemp = $dbh->prepare("Select flags, branchcode from borrowers where borrowernumber = ?");
133 $sthtemp->execute($loggedinuser);
134 my ($flags, $homebranch)=$sthtemp->fetchrow;
138 my %select_bookfunds;
139 ($count2,@bookfund)=bookfunds($homebranch);
140 for (my $i=0;$i<$count2;$i++){
141 push @select_bookfund, $bookfund[$i]->{'bookfundid'};
142 $select_bookfunds{$bookfund[$i]->{'bookfundid'}} = $bookfund[$i]->{'bookfundname'}
144 my $CGIbookfund=CGI::scrolling_list( -name => 'bookfund',
145 -values => \@select_bookfund,
146 -default => $data->{'bookfundid'},
147 -labels => \%select_bookfunds,
152 my $CGIsort1 = buildCGIsort("Asort1","sort1",$data->{'sort1'});
154 $template->param(CGIsort1 => $CGIsort1);
156 $template->param( sort1 => $data->{'sort1'});
159 my $CGIsort2 = buildCGIsort("Asort2","sort2",$data->{'sort2'});
161 $template->param(CGIsort2 =>$CGIsort2);
163 $template->param( sort2 => $data->{'sort2'});
167 $template->param( existing => $biblio,
170 basketno => $basketno,
171 booksellerid => $booksellerid,
172 suggestionid => $suggestionid,
174 biblioitemnumber => $data->{'biblioitemnumber'},
175 itemtype => $data->{'itemtype'},
176 discount => $booksellers[0]->{'discount'},
177 listincgst => $booksellers[0]->{'listincgst'},
178 listprice => $booksellers[0]->{'listprice'},
179 gstreg => $booksellers[0]->{'gstreg'},
180 invoiceinc => $booksellers[0]->{'invoiceincgst'},
181 invoicedisc => $booksellers[0]->{'invoicedisc'},
182 nocalc => $booksellers[0]->{'nocalc'},
183 name => $booksellers[0]->{'name'},
184 currency => $booksellers[0]->{'listprice'},
185 gstrate => C4::Context->preference("gist") ,
186 loop_currencies => \@loop_currency,
187 orderexists => ($new eq 'yes')?0:1,
188 title => $data->{'title'},
189 author => $data->{'author'},
190 copyrightdate => $data->{'copyrightdate'},
191 CGIitemtype => $CGIitemtype,
192 CGIbranch => $CGIbranch,
193 CGIbookfund => $CGIbookfund,
194 isbn => $data->{'isbn'},
195 seriestitle => $data->{'seriestitle'},
196 quantity => $data->{'quantity'},
197 listprice => $data->{'listprice'},
198 rrp => $data->{'rrp'},
199 invoice => $data->{'booksellerinvoicenumber'},
200 ecost => $data->{'ecost'},
201 notes => $data->{'notes'},
202 publishercode => $data->{'publishercode'});
204 output_html_with_http_headers $input, $cookie, $template->output;