bug 4169: fix item batch modification for MARC21
The MARC21 framework uses $0 for the item withdrawn status. Because of how the tool had marked the barcode and stocknumber as being uneditable, this resulted in an off-by-one error, causing the wrong item fields to be updated. Fixed by simply not including the uneditable fields in list of item fields that can be edited - if you can't change the barcode, there's no point in displaying it in the list of fields. Also fixed how the bib title/author/ISBN got displayed so that the withdrawn column gets displayed after an item update. Signed-off-by: Galen Charlton <gmcharlt@gmail.com> Signed-off-by: Liz Rea <lrea@nekls.org>
This commit is contained in:
parent
33230acc29
commit
9b98fc778d
|
|
@ -54,6 +54,7 @@
|
|||
<table id="itemst">
|
||||
<thead>
|
||||
<tr>
|
||||
<th> </th>
|
||||
<th> </th>
|
||||
<!-- TMPL_LOOP NAME="item_header_loop" -->
|
||||
<th> <!-- TMPL_VAR NAME="header_value" --> </th>
|
||||
|
|
@ -62,6 +63,7 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
<!-- TMPL_LOOP NAME="item_loop" --> <tr> <!-- TMPL_IF Name="nomod"--> <td class="error">Cannot Edit</td><!--TMPL_ELSE--><td><input type="checkbox" name="itemnumber" value="<!--TMPL_VAR Name="itemnumber"-->" id="row<!-- TMPL_VAR NAME="itemnumber" -->" checked="checked" /></td><!--/TMPL_IF-->
|
||||
<td><!-- TMPL_VAR ESCAPE="HTML" NAME="bibinfo" --></td>
|
||||
<!-- TMPL_LOOP NAME="item_value" --> <td><!-- TMPL_VAR ESCAPE="HTML" NAME="field" --></td>
|
||||
<!-- /TMPL_LOOP --> </tr>
|
||||
<!-- /TMPL_LOOP -->
|
||||
|
|
@ -83,9 +85,9 @@
|
|||
<!-- TMPL_IF name="mandatory" --> *</b><!-- /TMPL_IF -->
|
||||
</label>
|
||||
<!-- TMPL_VAR NAME="marc_value" -->
|
||||
<!-- TMPL_IF NAME="tag" --><input type="hidden" name="tag" value="<!-- TMPL_VAR NAME="tag" -->" /><!-- /TMPL_IF -->
|
||||
<!-- TMPL_IF NAME="subfield" --><input type="hidden" name="subfield" value="<!-- TMPL_VAR NAME="subfield" -->" /><!-- /TMPL_IF -->
|
||||
<!-- TMPL_IF NAME="mandatory" --><input type="hidden" name="mandatory" value="<!-- TMPL_VAR NAME="mandatory" -->" /><!-- /TMPL_IF -->
|
||||
<input type="hidden" name="tag" value="<!-- TMPL_VAR NAME="tag" -->" />
|
||||
<input type="hidden" name="subfield" value="<!-- TMPL_VAR NAME="subfield" -->" />
|
||||
<input type="hidden" name="mandatory" value="<!-- TMPL_VAR NAME="mandatory" -->" />
|
||||
<!-- TMPL_IF NAME="repeatable" -->
|
||||
<span class="buttonPlus" onclick="CloneSubfield('subfield<!-- TMPL_VAR NAME='tag' --><!-- TMPL_VAR NAME='subfield' --><!-- TMPL_VAR name="random" -->')">+</span>
|
||||
<!-- /TMPL_IF -->
|
||||
|
|
|
|||
|
|
@ -176,6 +176,9 @@ foreach my $tag (sort keys %{$tagslib}) {
|
|||
foreach my $subfield (sort keys %{$tagslib->{$tag}}) {
|
||||
next if subfield_is_koha_internal_p($subfield);
|
||||
next if ($tagslib->{$tag}->{$subfield}->{'tab'} ne "10");
|
||||
# barcode and stocknumber are not meant to be batch-modified
|
||||
next if $tagslib->{$tag}->{$subfield}->{'kohafield'} eq 'items.barcode';
|
||||
next if $tagslib->{$tag}->{$subfield}->{'kohafield'} eq 'items.stocknumber';
|
||||
my %subfield_data;
|
||||
|
||||
my $index_subfield = int(rand(1000000));
|
||||
|
|
@ -204,31 +207,8 @@ foreach my $tag (sort keys %{$tagslib}) {
|
|||
$subfield_data{visibility} = "display:none;" if (($tagslib->{$tag}->{$subfield}->{hidden} > 4) || ($tagslib->{$tag}->{$subfield}->{hidden} < -4));
|
||||
# testing branch value if IndependantBranches.
|
||||
|
||||
my $attributes_no_value;
|
||||
my $not_editable = 0;
|
||||
# Disable barcode and stock numbers batch editing
|
||||
my @not_editable_koha_fields = ( 'items.barcode', 'items.stocknumber' );
|
||||
foreach (@not_editable_koha_fields) {
|
||||
my ($bctag, $bcsubfield) = GetMarcFromKohaField($_, $frameworkcode);
|
||||
if (($bctag eq $subfield_data{tag}) && ($bcsubfield eq $subfield_data{subfield})) {
|
||||
$not_editable = 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
my $attributes;
|
||||
# If a field is found to be non-editable,
|
||||
if ($not_editable) {
|
||||
# We mark it as disabled, so the user won't be able to edit it
|
||||
$attributes_no_value = qq(disabled="disabled");
|
||||
$attributes = $attributes_no_value;
|
||||
# We also remove it's data, so it won't be modified
|
||||
undef($subfield_data{tag});
|
||||
undef($subfield_data{subfield});
|
||||
} else {
|
||||
$attributes_no_value = qq(tabindex="1" id="$subfield_data{id}" name="field_value" class="input_marceditor" size="67" maxlength="255" );
|
||||
$attributes = qq($attributes_no_value value="$value" );
|
||||
}
|
||||
my $attributes_no_value = qq(tabindex="1" id="$subfield_data{id}" name="field_value" class="input_marceditor" size="67" maxlength="255" );
|
||||
my $attributes = qq($attributes_no_value value="$value" );
|
||||
|
||||
if ( $tagslib->{$tag}->{$subfield}->{authorised_value} ) {
|
||||
my @authorised_values;
|
||||
|
|
@ -387,7 +367,6 @@ sub BuildItemsData{
|
|||
foreach my $itemnumber (@itemnumbers){
|
||||
my $itemdata=GetItem($itemnumber);
|
||||
my $itemmarc=Item2Marc($itemdata);
|
||||
my $biblio=GetBiblioData($$itemdata{biblionumber});
|
||||
my %this_row;
|
||||
foreach my $field (grep {$_->tag() eq $itemtagfield} $itemmarc->fields()) {
|
||||
# loop through each subfield
|
||||
|
|
@ -415,8 +394,12 @@ sub BuildItemsData{
|
|||
$this_row{itemnumber} = $subfvalue if ($tag eq $itemtagfield && $subfcode eq $itemtagsubfield);
|
||||
}
|
||||
}
|
||||
$this_row{0}=join("\n",@$biblio{qw(title author ISBN)});
|
||||
$witness{0}=" ";
|
||||
|
||||
# grab title, author, and ISBN to identify bib that the item
|
||||
# belongs to in the display
|
||||
my $biblio=GetBiblioData($$itemdata{biblionumber});
|
||||
$this_row{bibinfo} = join("\n", @$biblio{qw(title author ISBN)});
|
||||
|
||||
if (%this_row) {
|
||||
push(@big_array, \%this_row);
|
||||
}
|
||||
|
|
@ -434,9 +417,11 @@ sub BuildItemsData{
|
|||
$row_data{itemnumber} = $row->{itemnumber};
|
||||
#reporting this_row values
|
||||
$row_data{'nomod'} = $row->{'nomod'};
|
||||
$row_data{bibinfo} = $row->{bibinfo};
|
||||
push(@item_value_loop,\%row_data);
|
||||
}
|
||||
my @header_loop=map { { header_value=> $witness{$_}} } @witnesscodessorted;
|
||||
|
||||
return { item_loop => \@item_value_loop, item_header_loop => \@header_loop };
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue