Lines 4-10
Link Here
|
4 |
#the script first displays a list of import batches, then when a batch is selected displays all the biblios in it. |
4 |
#the script first displays a list of import batches, then when a batch is selected displays all the biblios in it. |
5 |
#The user can then pick which biblios he wants to order |
5 |
#The user can then pick which biblios he wants to order |
6 |
|
6 |
|
7 |
# Copyright 2008 - 2010 BibLibre SARL |
7 |
# Copyright 2008 - 2011 BibLibre SARL |
8 |
# |
8 |
# |
9 |
# This file is part of Koha. |
9 |
# This file is part of Koha. |
10 |
# |
10 |
# |
Lines 124-134
if ($op eq ""){
Link Here
|
124 |
my $import_batch_id = $cgiparams->{'import_batch_id'}; |
124 |
my $import_batch_id = $cgiparams->{'import_batch_id'}; |
125 |
my $biblios = GetImportBibliosRange($import_batch_id); |
125 |
my $biblios = GetImportBibliosRange($import_batch_id); |
126 |
for my $biblio (@$biblios){ |
126 |
for my $biblio (@$biblios){ |
127 |
# 1st insert the biblio |
127 |
# 1st insert the biblio, or find it through matcher |
128 |
my ( $marcblob, $encoding ) = GetImportRecordMarc( $biblio->{'import_record_id'} ); |
128 |
my ( $marcblob, $encoding ) = GetImportRecordMarc( $biblio->{'import_record_id'} ); |
129 |
my $marcrecord = MARC::Record->new_from_usmarc($marcblob) || die "couldn't translate marc information"; |
129 |
my $marcrecord = MARC::Record->new_from_usmarc($marcblob) || die "couldn't translate marc information"; |
130 |
my ( $duplicatetitle, $biblionumber ); |
130 |
my $match = GetImportRecordMatches( $biblio->{'import_record_id'}, 1 ); |
131 |
if ( !( ( $biblionumber, $duplicatetitle ) = FindDuplicate($marcrecord) ) ) { |
131 |
my $biblionumber=$#$match > -1?$match->[0]->{'biblionumber'}:0; |
|
|
132 |
|
133 |
unless ( $biblionumber ) { |
132 |
# add the biblio |
134 |
# add the biblio |
133 |
my $bibitemnum; |
135 |
my $bibitemnum; |
134 |
|
136 |
|
Lines 148-213
if ($op eq ""){
Link Here
|
148 |
if (C4::Context->preference("BiblioAddsAuthorities")){ |
150 |
if (C4::Context->preference("BiblioAddsAuthorities")){ |
149 |
my ($countlinked,$countcreated)=BiblioAddAuthorities($marcrecord, $cgiparams->{'frameworkcode'}); |
151 |
my ($countlinked,$countcreated)=BiblioAddAuthorities($marcrecord, $cgiparams->{'frameworkcode'}); |
150 |
} |
152 |
} |
151 |
# 3rd add order |
153 |
} else { |
152 |
my $patron = C4::Members->GetMember(borrowernumber => $loggedinuser); |
154 |
SetImportRecordStatus( $biblio->{'import_record_id'}, 'imported' ); |
153 |
my $branch = C4::Branch->GetBranchDetail($patron->{branchcode}); |
155 |
} |
154 |
my ($invoice); |
156 |
# 3rd add order |
155 |
# get quantity in the MARC record (1 if none) |
157 |
my $patron = C4::Members->GetMember( borrowernumber => $loggedinuser ); |
156 |
my $quantity = GetMarcQuantity($marcrecord, C4::Context->preference('marcflavour')) || 1; |
158 |
my $branch = C4::Branch->GetBranchDetail( $patron->{branchcode} ); |
157 |
my %orderinfo = ("biblionumber", $biblionumber, |
159 |
my ($invoice); |
158 |
"basketno", $cgiparams->{'basketno'}, |
160 |
# get quantity in the MARC record (1 if none) |
159 |
"quantity", $quantity, |
161 |
my $quantity = GetMarcQuantity($marcrecord, C4::Context->preference('marcflavour')) || 1; |
160 |
"branchcode", $branch, |
162 |
my %orderinfo = ( |
161 |
"booksellerinvoicenumber", $invoice, |
163 |
"biblionumber", $biblionumber, "basketno", $cgiparams->{'basketno'}, |
162 |
"budget_id", $budget_id, |
164 |
"quantity", $quantity, "branchcode", $branch, |
163 |
"uncertainprice", 1, |
165 |
"booksellerinvoicenumber", $invoice, |
164 |
"sort1", $cgiparams->{'sort1'}, |
166 |
"budget_id", $budget_id, "uncertainprice", 1, |
165 |
"sort2", $cgiparams->{'sort2'}, |
167 |
"sort1", $cgiparams->{'sort1'},"sort2", $cgiparams->{'sort2'}, |
166 |
); |
168 |
"notes", $cgiparams->{'notes'}, "budget_id", $cgiparams->{'budget_id'}, |
167 |
# get the price if there is one. |
169 |
); |
168 |
# filter by storing only the 1st number |
170 |
# get the price if there is one. |
169 |
# we suppose the currency is correct, as we have no possibilities to get it. |
171 |
# filter by storing only the 1st number |
170 |
my $price= GetMarcPrice($marcrecord, C4::Context->preference('marcflavour')); |
172 |
# we suppose the currency is correct, as we have no possibilities to get it. |
171 |
if ($price){ |
173 |
my $price= GetMarcPrice($marcrecord, C4::Context->preference('marcflavour')); |
172 |
$price = $num->unformat_number($price); |
174 |
if ($price){ |
173 |
} |
175 |
$price = $num->unformat_number($price); |
174 |
if ($price){ |
176 |
} |
175 |
$orderinfo{'listprice'} = $price; |
177 |
if ($price){ |
176 |
eval "use C4::Acquisition qw/GetBasket/;"; |
178 |
$orderinfo{'listprice'} = $price; |
177 |
eval "use C4::Bookseller qw/GetBookSellerFromId/;"; |
179 |
eval "use C4::Acquisition qw/GetBasket/;"; |
178 |
my $basket = GetBasket( $orderinfo{basketno} ); |
180 |
eval "use C4::Bookseller qw/GetBookSellerFromId/;"; |
179 |
my $bookseller = GetBookSellerFromId( $basket->{booksellerid} ); |
181 |
my $basket = GetBasket( $orderinfo{basketno} ); |
180 |
my $gst = $bookseller->{gstrate} || C4::Context->preference("gist") || 0; |
182 |
my $bookseller = GetBookSellerFromId( $basket->{booksellerid} ); |
181 |
$orderinfo{'unitprice'} = $orderinfo{listprice} - ( $orderinfo{listprice} * ( $bookseller->{discount} / 100 ) ); |
183 |
my $gst = $bookseller->{gstrate} || C4::Context->preference("gist") || 0; |
182 |
$orderinfo{'ecost'} = $orderinfo{unitprice}; |
184 |
$orderinfo{'unitprice'} = $orderinfo{listprice} - ( $orderinfo{listprice} * ( $bookseller->{discount} / 100 ) ); |
183 |
} else { |
185 |
$orderinfo{'ecost'} = $orderinfo{unitprice}; |
184 |
$orderinfo{'listprice'} = 0; |
186 |
} else { |
185 |
} |
187 |
$orderinfo{'listprice'} = 0; |
186 |
$orderinfo{'rrp'} = $orderinfo{'listprice'}; |
188 |
} |
|
|
189 |
$orderinfo{'rrp'} = $orderinfo{'listprice'}; |
187 |
|
190 |
|
188 |
# remove uncertainprice flag if we have found a price in the MARC record |
191 |
# remove uncertainprice flag if we have found a price in the MARC record |
189 |
$orderinfo{uncertainprice} = 0 if $orderinfo{listprice}; |
192 |
$orderinfo{uncertainprice} = 0 if $orderinfo{listprice}; |
190 |
my $basketno; |
193 |
my $basketno; |
191 |
( $basketno, $ordernumber ) = NewOrder(\%orderinfo); |
194 |
( $basketno, $ordernumber ) = NewOrder( \%orderinfo ); |
192 |
|
195 |
|
193 |
# 4th, add items if applicable |
196 |
# 4th, add items if applicable |
194 |
# parse the item sent by the form, and create an item just for the import_record_id we are dealing with |
197 |
# parse the item sent by the form, and create an item just for the import_record_id we are dealing with |
195 |
# this is not optimised, but it's working ! |
198 |
# this is not optimised, but it's working ! |
196 |
if (C4::Context->preference('AcqCreateItem') eq 'ordering') { |
199 |
if ( C4::Context->preference('AcqCreateItem') eq 'ordering' ) { |
197 |
my @tags = $input->param('tag'); |
200 |
my @tags = $input->param('tag'); |
198 |
my @subfields = $input->param('subfield'); |
201 |
my @subfields = $input->param('subfield'); |
199 |
my @field_values = $input->param('field_value'); |
202 |
my @field_values = $input->param('field_value'); |
200 |
my @serials = $input->param('serial'); |
203 |
my @serials = $input->param('serial'); |
201 |
my @ind_tag = $input->param('ind_tag'); |
204 |
my @ind_tag = $input->param('ind_tag'); |
202 |
my @indicator = $input->param('indicator'); |
205 |
my @indicator = $input->param('indicator'); |
203 |
my $item; |
206 |
my $item; |
204 |
push @{ $item->{tags} }, $tags[0]; |
207 |
push @{ $item->{tags} }, $tags[0]; |
205 |
push @{ $item->{subfields} }, $subfields[0]; |
208 |
push @{ $item->{subfields} }, $subfields[0]; |
206 |
push @{ $item->{field_values} }, $field_values[0]; |
209 |
push @{ $item->{field_values} }, $field_values[0]; |
207 |
push @{ $item->{ind_tag} }, $ind_tag[0]; |
210 |
push @{ $item->{ind_tag} }, $ind_tag[0]; |
208 |
push @{ $item->{indicator} }, $indicator[0]; |
211 |
push @{ $item->{indicator} }, $indicator[0]; |
209 |
my $xml = TransformHtmlToXml( \@tags, \@subfields, \@field_values, \@ind_tag, \@indicator ); |
212 |
my $xml = TransformHtmlToXml( \@tags, \@subfields, \@field_values, \@ind_tag, \@indicator ); |
210 |
my $record = MARC::Record::new_from_xml( $xml, 'UTF-8' ); |
213 |
my $record = MARC::Record::new_from_xml( $xml, 'UTF-8' ); |
|
|
214 |
for (my $qtyloop=1;$qtyloop <=$quantity;$qtyloop++) { |
211 |
my ( $biblionumber, $bibitemnum, $itemnumber ) = AddItemFromMarc( $record, $biblionumber ); |
215 |
my ( $biblionumber, $bibitemnum, $itemnumber ) = AddItemFromMarc( $record, $biblionumber ); |
212 |
NewOrderItem( $itemnumber, $ordernumber ); |
216 |
NewOrderItem( $itemnumber, $ordernumber ); |
213 |
} |
217 |
} |