Lines 48-53
use C4::Members;
Link Here
|
48 |
use Koha::Number::Price; |
48 |
use Koha::Number::Price; |
49 |
use Koha::Acquisition::Order; |
49 |
use Koha::Acquisition::Order; |
50 |
|
50 |
|
|
|
51 |
#my $batches = GetAllImportBatches(); |
52 |
#foreach my $b (@$batches) { |
53 |
# BatchFindDuplicates($b->{import_batch_id}, C4::Matcher->fetch(1), 1000, 1000, undef); |
54 |
#} |
55 |
|
51 |
my $input = new CGI; |
56 |
my $input = new CGI; |
52 |
my ($template, $loggedinuser, $cookie, $userflags) = get_template_and_user({ |
57 |
my ($template, $loggedinuser, $cookie, $userflags) = get_template_and_user({ |
53 |
template_name => "acqui/addorderiso2709.tt", |
58 |
template_name => "acqui/addorderiso2709.tt", |
Lines 159-164
if ($op eq ""){
Link Here
|
159 |
my $import_batch_id = $cgiparams->{'import_batch_id'}; |
164 |
my $import_batch_id = $cgiparams->{'import_batch_id'}; |
160 |
my $biblios = GetImportRecordsRange($import_batch_id); |
165 |
my $biblios = GetImportRecordsRange($import_batch_id); |
161 |
my @import_record_id_selected = $input->param("import_record_id"); |
166 |
my @import_record_id_selected = $input->param("import_record_id"); |
|
|
167 |
my @overlay = $input->param("overlay"); |
162 |
my @quantities = $input->param('quantity'); |
168 |
my @quantities = $input->param('quantity'); |
163 |
my @prices = $input->param('price'); |
169 |
my @prices = $input->param('price'); |
164 |
my @budgets_id = $input->param('budget_id'); |
170 |
my @budgets_id = $input->param('budget_id'); |
Lines 173-187
if ($op eq ""){
Link Here
|
173 |
my $marcrecord = MARC::Record->new_from_usmarc($marcblob) || die "couldn't translate marc information"; |
179 |
my $marcrecord = MARC::Record->new_from_usmarc($marcblob) || die "couldn't translate marc information"; |
174 |
my $match = GetImportRecordMatches( $biblio->{'import_record_id'}, 1 ); |
180 |
my $match = GetImportRecordMatches( $biblio->{'import_record_id'}, 1 ); |
175 |
my $biblionumber=$#$match > -1?$match->[0]->{'biblionumber'}:0; |
181 |
my $biblionumber=$#$match > -1?$match->[0]->{'biblionumber'}:0; |
|
|
182 |
my $c_overlay = shift @overlay; |
176 |
my $c_quantity = shift( @quantities ) || GetMarcQuantity($marcrecord, C4::Context->preference('marcflavour') ) || 1; |
183 |
my $c_quantity = shift( @quantities ) || GetMarcQuantity($marcrecord, C4::Context->preference('marcflavour') ) || 1; |
177 |
my $c_budget_id = shift( @budgets_id ) || $input->param('all_budget_id') || $budget_id; |
184 |
my $c_budget_id = shift( @budgets_id ) || $input->param('all_budget_id') || $budget_id; |
178 |
my $c_discount = shift ( @discount); |
185 |
my $c_discount = shift ( @discount); |
179 |
$c_discount = $c_discount / 100 if $c_discount > 1; |
186 |
$c_discount = $c_discount / 100 if $c_discount && $c_discount > 1; |
180 |
my $c_sort1 = shift( @sort1 ) || $input->param('all_sort1') || ''; |
187 |
my $c_sort1 = shift( @sort1 ) || $input->param('all_sort1') || ''; |
181 |
my $c_sort2 = shift( @sort2 ) || $input->param('all_sort2') || ''; |
188 |
my $c_sort2 = shift( @sort2 ) || $input->param('all_sort2') || ''; |
182 |
|
189 |
|
183 |
# 1st insert the biblio, or find it through matcher |
190 |
# INSERT the biblio if no match found, or if we want to overlay the existing match |
184 |
unless ( $biblionumber ) { |
191 |
if ( not($biblionumber) || $c_overlay ) { |
185 |
# add the biblio |
192 |
# add the biblio |
186 |
my $bibitemnum; |
193 |
my $bibitemnum; |
187 |
|
194 |
|
Lines 196-203
if ($op eq ""){
Link Here
|
196 |
} |
203 |
} |
197 |
} |
204 |
} |
198 |
} |
205 |
} |
199 |
( $biblionumber, $bibitemnum ) = AddBiblio( $marcrecord, $cgiparams->{'frameworkcode'} || '' ); |
206 |
( $biblionumber, $bibitemnum ) = AddBiblio( $marcrecord, $cgiparams->{'frameworkcode'} || '' ) unless $c_overlay; |
|
|
207 |
ModBiblio( $marcrecord, $biblionumber, $cgiparams->{'frameworkcode'} || '' ) if $c_overlay; |
200 |
SetImportRecordStatus( $biblio->{'import_record_id'}, 'imported' ); |
208 |
SetImportRecordStatus( $biblio->{'import_record_id'}, 'imported' ); |
|
|
209 |
|
210 |
#We need to provide information to koha.import_record_matches to tell Koha that this import_record matches the |
211 |
#just AddBiblio'd biblio. This is necessary to prevent adding the same import_record to koha.biblio many times. |
212 |
SetImportRecordBiblioMatch($biblio->{'import_record_id'}, $biblionumber); |
213 |
|
201 |
# 2nd add authorities if applicable |
214 |
# 2nd add authorities if applicable |
202 |
if (C4::Context->preference("BiblioAddsAuthorities")){ |
215 |
if (C4::Context->preference("BiblioAddsAuthorities")){ |
203 |
my $headings_linked =BiblioAutoLink($marcrecord, $cgiparams->{'frameworkcode'}); |
216 |
my $headings_linked =BiblioAutoLink($marcrecord, $cgiparams->{'frameworkcode'}); |
Lines 270-277
if ($op eq ""){
Link Here
|
270 |
my @serials = $input->param('serial'); |
283 |
my @serials = $input->param('serial'); |
271 |
my @indicator = $input->param('indicator'); #Passing the imaginary empty " " -indicators from the templates, to stop C4::Biblio::TransformHtmlToXml() to warn the bejesus out of my koha-error.log |
284 |
my @indicator = $input->param('indicator'); #Passing the imaginary empty " " -indicators from the templates, to stop C4::Biblio::TransformHtmlToXml() to warn the bejesus out of my koha-error.log |
272 |
my @ind_tag = $input->param('ind_tag'); |
285 |
my @ind_tag = $input->param('ind_tag'); |
273 |
my @indicator = $input->param('indicator'); |
286 |
my $item; #WHAT IS THIS MADNESS?? |
274 |
my $item; |
|
|
275 |
push @{ $item->{tags} }, $tags[0]; |
287 |
push @{ $item->{tags} }, $tags[0]; |
276 |
push @{ $item->{subfields} }, $subfields[0]; |
288 |
push @{ $item->{subfields} }, $subfields[0]; |
277 |
push @{ $item->{field_values} }, $field_values[0]; |
289 |
push @{ $item->{field_values} }, $field_values[0]; |
Lines 403-408
sub import_biblios_list {
Link Here
|
403 |
$cellrecord{discount} = $discount || ''; |
415 |
$cellrecord{discount} = $discount || ''; |
404 |
$cellrecord{sort1} = $sort1 || ''; |
416 |
$cellrecord{sort1} = $sort1 || ''; |
405 |
$cellrecord{sort2} = $sort2 || ''; |
417 |
$cellrecord{sort2} = $sort2 || ''; |
|
|
418 |
|
419 |
get_matched_cellrecord_items( \%cellrecord ); |
420 |
|
406 |
|
421 |
|
407 |
push @list, \%cellrecord; |
422 |
push @list, \%cellrecord; |
408 |
} |
423 |
} |
Lines 464-469
sub add_matcher_list {
Link Here
|
464 |
$template->param(available_matchers => \@matchers); |
479 |
$template->param(available_matchers => \@matchers); |
465 |
} |
480 |
} |
466 |
|
481 |
|
|
|
482 |
#Get the Items already in Koha for this import_record. |
483 |
#A summary of them is displayed for the user. |
484 |
sub get_matched_cellrecord_items { |
485 |
my $cellrecord = shift; |
486 |
|
487 |
if ($cellrecord->{match_biblionumber}) { |
488 |
my $itemsCountByBranch = C4::Items::GetItemsCountByBranch( $cellrecord->{match_biblionumber} ); |
489 |
my $loginBranchcode = $template->{VARS}->{LoginBranchcode}; |
490 |
my $totalItemsCount = 0; |
491 |
my @availabilityMap; |
492 |
foreach my $homebranch (sort keys %$itemsCountByBranch) { |
493 |
push (@availabilityMap, $homebranch.' = '.$itemsCountByBranch->{ $homebranch }->{ count }); |
494 |
$totalItemsCount += $itemsCountByBranch->{ $homebranch }->{ count }; |
495 |
} |
496 |
my $loginBranchcount = $itemsCountByBranch->{ $loginBranchcode }->{ count }; |
497 |
$cellrecord->{loginBranchItemsCount} = $loginBranchcount || '0'; |
498 |
$cellrecord->{totalItemsCount} = $totalItemsCount; |
499 |
$cellrecord->{availabilityMap} = join("\n", @availabilityMap); |
500 |
} |
501 |
} |
502 |
|
467 |
sub get_infos_syspref { |
503 |
sub get_infos_syspref { |
468 |
my ($record, $field_list) = @_; |
504 |
my ($record, $field_list) = @_; |
469 |
my $syspref = C4::Context->preference('MarcFieldsToOrder'); |
505 |
my $syspref = C4::Context->preference('MarcFieldsToOrder'); |