Koha/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt
Lyon3 Team bf9bff898f Bug 12074: Filter duplicates when adding a batch from a staged file
When adding a batch of records to a basket, duplicates are skipped and
an alert is displayed with a link to them so as they could be treated
individually.

Test plan :

You need the 2 test attached files TestFile1.mrc and TestFile2.elc
(TestFile1 includes only the title "Amilec ou La graine d'hommes" that
is also included in TestFile2)

1) go to “Stage MARC records for import” page, upload TestFile1 and
stage it (select iso 5426 encoding).
2) Manage staged record and import the batch.
3) Make sure that the new record is indexed (depending to your indexing
system and test platform).
4) Go back to go to “Stage MARC records for import” page upload
TestFile2 and stage it (select iso 5426 encoding).
5) Go to acquisitions module and create a new basket.
6) From your basket, in the “Add order to basket block”  choose  'From a
staged file'.
7) Then click File2 (‘addorder button').
8) Go down the "Import all" block and save.
9) You are redirected to the basket page : a warning is displayed to
tell you that some duplicates have been found and skipped.
There's a link on the warning throughout you can go back to the list of
remaining records and treat them individually if necesary.
10) Click the link : you fall upon the title of TestFile1 (of course as
it's a duplicate).
11) Check that the imported records have been indexed.
11) Go down the "Import all" block and save.
12) A warning is displayed saying that no records have been imported
because they all match an existing record. The “Import all” block is not
any more visible.

Signed-off-by: JA <aloi54@live.fr>

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2015-06-24 11:32:30 -03:00

437 lines
26 KiB
Text

[% USE KohaDates %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha &rsaquo; Acquisitions &rsaquo; Order staged MARC records
[% IF ( batch_details ) %]
&rsaquo; Batch [% import_batch_id %]
[% ELSE %]
&rsaquo; Batch list
[% END %]
</title>
[% INCLUDE 'greybox.inc' %]
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
[% INCLUDE 'doc-head-close.inc' %]
[% INCLUDE 'datatables.inc' %]
<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
<script type="text/javascript" src="[% themelang %]/js/acq.js"></script>
<script type="text/JavaScript">
//<![CDATA[
$(document).ready(function() {
$("#files").dataTable($.extend(true, {}, dataTablesDefaults, {
"aoColumnDefs": [
{ "bSortable": false, "bSearchable": false, 'aTargets': [ 'NoSort' ] },
{ "sType": "anti-the", "aTargets" : [ "anti-the" ] },
{ "sType": "title-string", "aTargets" : [ "title-string" ] }
],
"sPaginationType": "four_button",
"aaSorting": []
} ) );
// keep copy of the inactive budgets
disabledBudgetsCopy = $("select[name='all_budget_id']").html();
$("select[name='all_budget_id'] .b_inactive").remove();
$("select[name='budget_id'] .b_inactive").remove();
$("#showallbudgets").click(function() {
if ($(this).is(":checked")) {
$("select[name='budget_id']").html(disabledBudgetsCopy)
}
else {
$("select[name='budget_id'] .b_inactive").remove();
}
});
$("#all_showallbudgets").click(function() {
if ($(this).is(":checked")) {
$("select[name='all_budget_id']").html(disabledBudgetsCopy);
}
else {
$("select[name='all_budget_id'] .b_inactive").remove();
}
});
$("select[name='budget_id']").change(function(){
var sort1_authcat = $(this).find("option:selected").attr('data-sort1-authcat');
var sort2_authcat = $(this).find("option:selected").attr('data-sort2-authcat');
var destination_sort1 = $(this).parents('fieldset').find('li.sort1').find('input[name="sort1"]');
var sort1 = $(destination_sort1).val() || "";
if ( destination_sort1.length < 1 ) {
destination_sort1 = $(this).parents('fieldset').find('li.sort1 > select[name="sort1"]');
}
var destination_sort2 = $(this).parents('fieldset').find('li.sort2').find('input[name="sort2"]');
var sort2 = $(destination_sort2).val() || "";
if ( destination_sort2.length < 1 ) {
destination_sort2 = $(this).parents('fieldset').find('li.sort2').find('select[name="sort2"]');
}
getAuthValueDropbox( 'sort1', sort1_authcat, destination_sort1, sort1 );
getAuthValueDropbox( 'sort2', sort2_authcat, destination_sort2, sort2 );
} );
$("select[name='budget_id']").change();
$("select[name='all_budget_id']").change(function(){
var sort1_authcat = $(this).find("option:selected").attr('data-sort1-authcat');
var sort2_authcat = $(this).find("option:selected").attr('data-sort2-authcat');
var destination_sort1 = $(this).parent().siblings('li').find('input[name="all_sort1"]');
if ( destination_sort1.length < 1 ) {
destination_sort1 = $(this).parent().siblings('li').find('select[name="all_sort1"]');
}
var destination_sort2 = $(this).parent().siblings('li').find('input[name="all_sort2"]');
if ( destination_sort2.length < 1 ) {
destination_sort2 = $(this).parent().siblings('li').find('select[name="all_sort2"]');
}
getAuthValueDropbox( 'sort1', sort1_authcat, destination_sort1 );
getAuthValueDropbox( 'sort2', sort2_authcat, destination_sort2 );
$(this).parent().siblings('li').find('select[name="sort1"]').attr('name', 'all_sort1');
$(this).parent().siblings('li').find('input[name="sort1"]').attr('name', 'all_sort1');
$(this).parent().siblings('li').find('select[name="sort2"]').attr('name', 'all_sort2');
$(this).parent().siblings('li').find('input[name="sort2"]').attr('name', 'all_sort2');
} );
$("select[name='all_budget_id']").change();
$("#records_to_import fieldset.rows ol").hide();
$('input:checkbox[name="import_record_id"]').change(function(){
var container = $(this).parents("fieldset");
if ( $(this).is(':checked') ) {
$(container).addClass("selected");
$(container).removeClass("unselected");
$(container).find("ol").toggle(true);
} else {
$(container).addClass("unselected");
$(container).removeClass("selected");
$(container).find("ol").toggle(false);
}
} );
$("input:checkbox").attr("checked", false);
$("div.biblio.unselected select").attr("disabled", false);
$("div.biblio.unselected input").attr("disabled", false);
$("#checkAll").click(function(){
$("#Aform").checkCheckboxes();
$("input:checkbox[name='import_record_id']").change();
return false;
});
$("#unCheckAll").click(function(){
$("#Aform").unCheckCheckboxes();
$("input:checkbox[name='import_record_id']").change();
return false;
});
$("#Aform").on("submit", function(){
if ( $("input:checkbox[name='import_record_id']:checked").length < 1 ) {
alert(_("There is no record selected"));
return false;
}
var error = 0;
$("input:checkbox[name='import_record_id']:checked").parents('fieldset').find('input[name="quantity"]').each(function(){
if ( $(this).val().length < 1 || isNaN( $(this).val() ) ) {
error++;
}
});
if ( error > 0 ) {
alert(error + " " + _("quantity values are not filled in or are not numbers"));
return false;
}
return disableUnchecked($(this));
});
$('#tabs').tabs();
});
function disableUnchecked(form){
$("fieldset.biblio.unselected").each(function(){
$(this).remove();
});
return 1;
}
//]]>
</script>
</head>
<body id="acq_addorderiso2709" class="acq">
[% INCLUDE 'header.inc' %]
[% INCLUDE 'acquisitions-search.inc' %]
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a> &rsaquo; <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">[% booksellername %]</a> &rsaquo; <a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basketno %]">Basket [% basketno %]</a> &rsaquo; Add orders from iso2709 file</div>
<div id="doc3" class="yui-t2">
<div id="bd">
<div id="yui-main">
<div class="yui-b">
[% IF ( allmatch ) %]<div class="dialog alert">
<h4>No records imported</h4>
No record have been imported because they all match an existing record in your catalog.<br />You'll have to treat them individually.
</div>
[% END %]
[% IF ( batch_details ) %]
<h1>Add orders from [% comments %]
([% file_name %] staged on [% upload_timestamp | $KohaDates with_hours => 1 %])
</h1>
<form action="/cgi-bin/koha/acqui/addorderiso2709.pl" method="post" id="Aform">
<div id="tabs" class="toptabs">
<ul>
<li><a href="#records_to_import">Select to import</a></li>
<li><a href="#items_info" class="items_info">Item information</a></li>
<li><a href="#accounting_details">Default accounting details</a></li>
</ul>
<div id="records_to_import">
<span class="checkall"><a id="checkAll" href="#">Check all</a></span>
<span class="uncheckall"><a id="unCheckAll" href="#">Uncheck all</a></span>
<label for="showallbudgets" style="float:none;width:auto;">&nbsp;Show all funds:</label>
<input type="checkbox" id="showallbudgets" />
<input type="hidden" name="op" value="import_records"/>
<input type="hidden" name="basketno" value="[% basketno %]" />
<input type="hidden" name="booksellerid" value="[% booksellerid %]" />
<input type="hidden" name="import_batch_id" value="[%import_batch_id %]" />
<input type="hidden" name="ordernumber" value="[% ordernumber %]" />
[% FOREACH cur IN loop_currencies %]
<input type="hidden" name="[% cur.currency %]" value="[% cur.rate %]" />
[% END %]
[% FOREACH biblio IN biblio_list %]
<fieldset class="biblio unselected rows" style="float:none;">
<legend>
<label for="record_[% biblio.import_record_id %]" style="width:auto;">
<input type="checkbox" name="import_record_id" id="record_[% biblio.import_record_id %]" value="[% biblio.import_record_id %]" />
<span class="citation">[% biblio.citation %]</span>
</label>
<span class="links" style="font-weight: normal;">
( <a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% biblio.import_record_id %]" title="MARC" rel="gb_page_center[600,500]">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;importid=[% biblio.import_record_id %]" title="Card" rel="gb_page_center[600,500]">Card</a> | <a href="/cgi-bin/koha/acqui/neworderempty.pl?booksellerid=[% booksellerid %]&amp;basketno=[% basketno %]&amp;breedingid=[% biblio.import_record_id %]&amp;import_batch_id=[% biblio.import_batch_id %]&amp;biblionumber=[% biblio.match_biblionumber %]">Add order</a> )
</span>
</legend>
<ol>
<li class="status">
<span class="match">
[% IF ( biblio_lis.overlay_status == 'no_match' ) %]
No match
[% ELSIF ( biblio_lis.overlay_status == 'match_applied' ) %]
Match applied
[% ELSIF ( biblio_lis.overlay_status == 'auto_match' ) %]
Match found
[% ELSE %]
[% biblio_lis.overlay_status %]
[% END %]
[% IF ( biblio.match_biblionumber ) %]
Matches biblio [% biblio.match_biblionumber %] (score = [% biblio.match_score %]): <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblio.match_biblionumber %]">[% biblio.match_citation %]</a>
[% END %]
</span>
</li>
<li class="quantity">
<label for="quantity_record_[% biblio.import_record_id %]" class="required">Quantity: </label>
<input id="quantity_record_[% biblio.import_record_id %]" type="text" value="[% biblio.quantity.length ? biblio.quantity : 1 %]" name="quantity" />
</li>
<li class="price">
<label for="price_record_[% biblio.import_record_id %]">Price: </label>
<input id="price_record_[% biblio.import_record_id %]" type="text" value="[% biblio.price %]" name="price" />
</li>
<li class="discount">
<label for="discount_record_[% biblio.import_record_id %]">Discount: </label>
<input id="discount_record_[% biblio.import_record_id %]" type="text" value="[% biblio.discount %]" name="discount" size="6" /> %
(If empty, discount rate from vendor will be used)
</li>
<li class="budget">
<label for="fund_record_[% biblio.import_record_id %]">Fund: </label>
[% IF ( close ) %]
<input type="hidden" size="20" name="budget_id" value="[% budget_id %]" />[% Budget_name %]
[% ELSE %]
<select id="fund_record_[% biblio.import_record_id %]" size="1" name="budget_id">
<option value="">Select a fund</option>
[% FOREACH budget IN budget_loop %]
[% IF ( budget.b_id == biblio.budget_id ) %]
[% IF budget.b_active %]
<option value="[% budget.b_id %]" data-sort1-authcat="[% budget.b_sort1_authcat %]" data-sort2-authcat="[% budget.b_sort2_authcat %]" selected="selected">[% budget.b_txt %]</option>
[% ELSE %]
<option value="[% budget.b_id %]" data-sort1-authcat="[% budget.b_sort1_authcat %]" data-sort2-authcat="[% budget.b_sort2_authcat %]" selected="selected">[% budget.b_txt %] (inactive)</option>
[% END %]
[% ELSE %]
[% IF budget.b_active %]<option value="[% budget.b_id %]" data-sort1-authcat="[% budget.b_sort1_authcat %]" data-sort2-authcat="[% budget.b_sort2_authcat %]">[% budget.b_txt %]</option>
[% ELSE %]<option value="[% budget.b_id %]" class="b_inactive" data-sort1-authcat="[% budget.b_sort1_authcat %]" data-sort2-authcat="[% budget.b_sort2_authcat %]">[% budget.b_txt %] (inactive)</option>
[% END %]
[% END %]
[% END %]
</select>
[% END %]
</li>
<li class="sort1">
<label for="sort1_record_[% biblio.import_record_id %]">Statistic 1: </label>
<input id="sort1_record_[% biblio.import_record_id %]" type="text" id="sort1" size="20" name="sort1" value="[% biblio.sort1 %]" />
</li>
<li class="sort2">
<label for="sort2_record_[% biblio.import_record_id %]">Statistic 2: </label>
<input id="sort2_record_[% biblio.import_record_id %]" type="text" id="sort2" size="20" name="sort2" value="[% biblio.sort2 %]" />
</li>
</ol>
</fieldset>
[% END %]
</div>
<div id="items_info">
<h2>Item information</h2>
<p>Import all the checked items in the basket with the following parameters:</p>
[% IF ( items ) %]
<fieldset class="rows" style="float:none;">
<legend>Item</legend>
[% IF ( NoACQframework ) %]
<div class="dialog message">No ACQ framework, using default. You should create a framework with code ACQ, the items framework would be used</div>
[% END %]
[% FOREACH item IN items %]
<div id="outeritemblock">
<div id="itemblock">
<ol>
[% FOREACH iteminformatio IN item.iteminformation %]<li style="[% iteminformatio.hidden %];">
<div class="subfield_line" id="subfield[% iteminformatio.serialid %][% iteminformatio.countitems %][% iteminformatio.subfield %][% iteminformatio.random %]">
[% IF (iteminformatio.mandatory) %]
<label class="required">[% iteminformatio.subfield %] - [% iteminformatio.marc_lib %]</label>
[% ELSE %]
<label>[% iteminformatio.subfield %] - [% iteminformatio.marc_lib %]</label>
[% END %]
[% IF ( iteminformatio.marc_value.type == 'select' ) %]
<select name="field_value" size="1">
[% FOREACH value IN iteminformatio.marc_value.values %]
[% IF ( value == iteminformatio.marc_value.default ) %]
<option value="[% value %]" selected="selected">[% iteminformatio.marc_value.labels.$value %]</option>
[% ELSE %]
<option value="[% value %]">[% iteminformatio.marc_value.labels.$value %]</option>
[% END %]
[% END %]
</select>
[% ELSE %]
[% iteminformatio.marc_value %]
[% END %]
<input type="hidden" name="itemid" value="1" />
<input type="hidden" name="kohafield" value="[% iteminformatio.kohafield %]" />
<input type="hidden" name="tag" value="[% iteminformatio.tag %]" />
<input type="hidden" name="subfield" value="[% iteminformatio.subfield %]" />
<input type="hidden" name="mandatory" value="[% iteminformatio.mandatory %]" />
[% IF ( iteminformatio.mandatory ) %] <span class="required">Required</span>[% END %]
</div></li>
[% END %]
</ol>
</div><!-- /iteminformation -->
</div>
[% END %] <!-- /items -->
</fieldset>
[% END %] <!-- items -->
</div>
<div id="accounting_details">
<p>Import all the checked items in the basket with the following accounting details (used only if no information is filled for the item):</p>
<fieldset class="rows" style="float:none;">
<legend>Accounting details</legend>
<ol>
<li>
<!-- origquantityrec only here for javascript compatibility (additem.js needs it, useless here, usefull when receiveing an order -->
<input id="origquantityrec" readonly="readonly" type="hidden" name="origquantityrec" value="1" />
</li>
<li>
[% IF ( close ) %]
<span class="label">Fund: </span>
<input type="hidden" size="20" name="budget_id" id="budget_id" value="[% budget_id %]" />[% Budget_name %]
[% ELSE %]
<li>
<label for="all_currency">Currency:</label>
<select name="all_currency" id="all_currency">
[% FOREACH loop_currencie IN loop_currencies %]
[% IF ( loop_currencie.selected ) %]
<option value="[% loop_currencie.currcode %]" selected="selected">[% loop_currencie.currcode %]</option>
[% ELSE %]
<option value="[% loop_currencie.currcode %]">[% loop_currencie.currcode %]</option>
[% END %]
[% END %]
</select>
</li>
<li>
<label for="all_budget_id">Fund: </label>
<select id="all_budget_id" size="1" name="all_budget_id">
<option value="">Select a fund</option>
[% FOREACH budget_loo IN budget_loop %]
[% IF ( budget_loo.b_active ) %]<option value="[% budget_loo.b_id %]" data-sort1-authcat="[% budget_loo.b_sort1_authcat %]" data-sort2-authcat="[% budget_loo.b_sort2_authcat %]">[% budget_loo.b_txt %]</option>
[% ELSE %]<option value="[% budget_loo.b_id %]" class="b_inactive" data-sort1-authcat="[% budget_loo.b_sort1_authcat %]" data-sort2-authcat="[% budget_loo.b_sort2_authcat %]">[% budget_loo.b_txt %] (inactive)</option>
[% END %]
[% END %]
</select>
<label for="all_showallbudgets" style="float:none;width:auto;">&nbsp;Show all:</label>
<input type="checkbox" id="all_showallbudgets" />
</li>
[% END %]
</li>
<li>
<label for="all_order_internalnote">Internal note: </label>
<textarea id="all_order_internalnote" cols="30" rows="3" name="all_order_internalnote"></textarea>
</li>
<li>
<label for="all_order_vendornote">Vendor note: </label>
<textarea id="all_order_vendornote" cols="30" rows="3" name="all_order_vendornote"></textarea>
</li>
<li>
<div class="hint">The 2 following fields are available for your own usage. They can be useful for statistical purposes</div>
<label for="all_sort1">Statistic 1: </label>
<input type="text" id="all_sort1" size="20" name="all_sort1" value="" />
</li>
<li>
<label for="all_sort2">Statistic 2: </label>
<input type="text" id="all_sort2" size="20" name="all_sort2" value="" />
</li>
</ol>
</fieldset>
</div>
</div>
<fieldset class="action">
<input type="submit" value="Save" /><a class="cancel" href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basketno %]">Cancel</a>
</fieldset>
</form>
[% ELSE %]
<div>
<h1>Choose the file to add to the basket</h1>
<table id="files">
<thead>
<tr>
<th>File name</th>
<th>Comments</th>
<th>Status</th>
<th class="title-string">Staged</th>
<th># Bibs</th>
<th class="NoSort">&nbsp;</th>
</tr>
</thead>
<tbody>
[% FOREACH batch_lis IN batch_list %]
<tr>
<td>[% batch_lis.file_name %]</td>
<td>[% batch_lis.comments %]</td>
<td>
[% IF ( batch_lis.import_status == 'cleaned' ) %]
Cleaned
[% ELSIF ( batch_lis.import_status == 'imported' ) %]
Imported
[% ELSIF ( batch_lis.import_status == 'importing' ) %]
Importing
[% ELSIF ( batch_lis.import_status == 'reverted' ) %]
Reverted
[% ELSIF ( batch_lis.import_status == 'reverting' ) %]
Reverting
[% ELSIF ( batch_lis.import_status == 'staged' ) %]
Staged
[% ELSE %]
[% batch_lis.import_status %]
[% END %]
</td>
<td><span title="[% batch_lis.staged_date %]">[% batch_lis.staged_date | $KohaDates with_hours => 1 %]</span></td>
<td>[% batch_lis.num_records %]</td>
<td><a href="[% batch_lis.scriptname %]?import_batch_id=[% batch_lis.import_batch_id %]&amp;basketno=[% basketno %]&amp;booksellerid=[% booksellerid %]">Add orders</a></td>
</tr>
[% END %]
</tbody>
</table>
</div>
[% END %]
</div>
</div>
</div>
</div>
</body>
</html>