@@ -, +, @@ for duplicates, display availability information. well. So we can't "hide" a import_record from the staged_file after an order is placed. so next acquirers know that it is already in our catalog. of one Biblio to the consortium. Thus we color each row and show the count of Items in the current user's branch and the total amount of Items in the whole consortium. Additional tooltip listing of Item counts by Branch is displayed so we know are there any such Items near us. You can use an existing matcher as well if you have it configured to other than ISBN. to order from at acqui/addorderiso2709.pl?import_batch_id=50... the previous view and reload. in your consortium, and a tooltip from the record title, showing a breakdown of items by branch. get many Biblios for many orderlines. basket. title. First number is the count of Items for this Biblio in user's logged-in-branch, second is the total number of Items in the catalogue. Hovering mouse pointer over the title displays a tooltip with a breakdown of all Items by homebranch. --- acqui/addorderiso2709.pl | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) --- a/acqui/addorderiso2709.pl +++ a/acqui/addorderiso2709.pl @@ -175,7 +175,7 @@ if ($op eq ""){ my $c_quantity = shift( @quantities ) || GetMarcQuantity($marcrecord, C4::Context->preference('marcflavour') ) || 1; my $c_budget_id = shift( @budgets_id ) || $input->param('all_budget_id') || $budget_id; my $c_discount = shift ( @discount); - $c_discount = $c_discount / 100 if $c_discount > 1; + $c_discount = $c_discount / 100 if $c_discount && $c_discount > 1; my $c_sort1 = shift( @sort1 ) || $input->param('all_sort1') || ''; my $c_sort2 = shift( @sort2 ) || $input->param('all_sort2') || ''; @@ -197,6 +197,11 @@ if ($op eq ""){ } ( $biblionumber, $bibitemnum ) = AddBiblio( $marcrecord, $cgiparams->{'frameworkcode'} || '' ); SetImportRecordStatus( $biblio->{'import_record_id'}, 'imported' ); + + #We need to provide information to koha.import_record_matches to tell Koha that this import_record matches the + #just AddBiblio'd biblio. This is necessary to prevent adding the same import_record to koha.biblio many times. + SetImportRecordBiblioMatch($biblio->{'import_record_id'}, $biblionumber); + # 2nd add authorities if applicable if (C4::Context->preference("BiblioAddsAuthorities")){ my $headings_linked =BiblioAutoLink($marcrecord, $cgiparams->{'frameworkcode'}); @@ -357,7 +362,7 @@ sub import_biblios_list { my ($template, $import_batch_id) = @_; my $batch = GetImportBatch($import_batch_id,'staged'); return () unless $batch and $batch->{import_status} =~ /^staged$|^reverted$/; - my $biblios = GetImportRecordsRange($import_batch_id,'','',$batch->{import_status}); + my $biblios = GetImportRecordsRange($import_batch_id,'','',undef); my @list = (); foreach my $biblio (@$biblios) { @@ -403,6 +408,8 @@ sub import_biblios_list { $cellrecord{sort1} = $sort1 || ''; $cellrecord{sort2} = $sort2 || ''; + get_matched_cellrecord_items( \%cellrecord ); + push @list, \%cellrecord; } my $num_records = $batch->{'num_records'}; @@ -463,6 +470,27 @@ sub add_matcher_list { $template->param(available_matchers => \@matchers); } +#Get the Items already in Koha for this import_record. +#A summary of them is displayed for the user. +sub get_matched_cellrecord_items { + my $cellrecord = shift; + + if ($cellrecord->{match_biblionumber}) { + my $itemsCountByBranch = C4::Items::GetItemsCountByBranch( $cellrecord->{match_biblionumber} ); + my $loginBranchcode = $template->{VARS}->{LoginBranchcode}; + my $totalItemsCount = 0; + my @availabilityMap; + foreach my $homebranch (sort keys %$itemsCountByBranch) { + push (@availabilityMap, $homebranch.' = '.$itemsCountByBranch->{ $homebranch }->{ count }); + $totalItemsCount += $itemsCountByBranch->{ $homebranch }->{ count }; + } + my $loginBranchcount = $itemsCountByBranch->{ $loginBranchcode }->{ count }; + $cellrecord->{loginBranchItemsCount} = $loginBranchcount || '0'; + $cellrecord->{totalItemsCount} = $totalItemsCount; + $cellrecord->{availabilityMap} = join("\n", @availabilityMap); + } +} + sub get_infos_syspref { my ($record, $field_list) = @_; my $syspref = C4::Context->preference('MarcFieldsToOrder'); --