Bugzilla – Attachment 115679 Details for
Bug 27526
Remove Mod/AddItemFromMarc from additem.pl
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27526: Remove ModItemFromMarc from additem
Bug-27526-Remove-ModItemFromMarc-from-additem.patch (text/plain), 12.58 KB, created by
Jonathan Druart
on 2021-01-22 12:20:30 UTC
(
hide
)
Description:
Bug 27526: Remove ModItemFromMarc from additem
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2021-01-22 12:20:30 UTC
Size:
12.58 KB
patch
obsolete
>From 166c1c4385c8463775a2d351e9f24e7d57481fe7 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 22 Jan 2021 11:24:58 +0100 >Subject: [PATCH] Bug 27526: Remove ModItemFromMarc from additem > >--- > C4/Biblio.pm | 2 +- > cataloguing/additem.pl | 59 ++++++++++++------- > .../prog/en/modules/cataloguing/additem.tt | 34 +++++++---- > 3 files changed, 61 insertions(+), 34 deletions(-) > >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index 42e3b3668a..33d0a71185 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -2135,7 +2135,7 @@ sub TransformHtmlToXml { > > my $xml = MARC::File::XML::header('UTF-8'); > $xml .= "<record>\n"; >- $auth_type = C4::Context->preference('marcflavour') unless $auth_type; >+ $auth_type = C4::Context->preference('marcflavour') unless $auth_type; # FIXME auth_type must be removed > MARC::File::XML->default_record_format($auth_type); > > # in UNIMARC, field 100 contains the encoding >diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl >index 758de9b2df..24ff82f454 100755 >--- a/cataloguing/additem.pl >+++ b/cataloguing/additem.pl >@@ -131,6 +131,7 @@ sub generate_subfield_form { > $subfield_data{repeatable} = $subfieldlib->{repeatable}; > $subfield_data{maxlength} = $subfieldlib->{maxlength}; > $subfield_data{display_order} = $subfieldlib->{display_order}; >+ $subfield_data{kohafield} = $subfieldlib->{kohafield} || 'items.more_subfields_xml'; > > if ( ! defined( $value ) || $value eq '') { > $value = $subfieldlib->{defaultvalue}; >@@ -742,33 +743,49 @@ if ($op eq "additem") { > #------------------------------------------------------------------------------- > } elsif ($op eq "saveitem") { > #------------------------------------------------------------------------------- >- # rebuild >- my @tags = $input->multi_param('tag'); >- my @subfields = $input->multi_param('subfield'); >- my @values = $input->multi_param('field_value'); >- # build indicator hash. >- my @ind_tag = $input->multi_param('ind_tag'); >- my @indicator = $input->multi_param('indicator'); >- # my $itemnumber = $input->param('itemnumber'); >- my $xml = TransformHtmlToXml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag,'ITEM'); >- my $itemtosave=MARC::Record::new_from_xml($xml, 'UTF-8'); >- # MARC::Record builded => now, record in DB >- # warn "R: ".$record->as_formatted; >+ >+ my $itemnumber = $input->param('itemnumber'); >+ my $item = Koha::Items->find($itemnumber); >+ # FIXME Handle non existent item >+ my $olditemlost = $item->itemlost; >+ my @columns = Koha::Items->columns; >+ for my $c ( @columns ) { >+ if ( $c eq 'more_subfields_xml' ) { >+ my @more_subfields_xml = $input->multi_param("items.more_subfields_xml"); >+ my @unlinked_item_subfields; >+ for my $subfield ( @more_subfields_xml ) { >+ my $v = $input->param('items.more_subfields_xml_' . $subfield); >+ push @unlinked_item_subfields, $subfield, $v; >+ } >+ if ( @unlinked_item_subfields ) { >+ my $marc = MARC::Record->new(); >+ # use of tag 999 is arbitrary, and doesn't need to match the item tag >+ # used in the framework >+ $marc->append_fields(MARC::Field->new('999', ' ', ' ', @unlinked_item_subfields)); >+ $marc->encoding("UTF-8"); >+ $item->more_subfields_xml($marc->as_xml("USMARC")); >+ next; >+ } >+ $item->more_subfields_xml(undef); >+ } else { >+ my $v = $input->param("items.".$c); >+ next unless defined $v; >+ $item->$c($v); >+ } >+ } >+ > # check that the barcode don't exist already >- my $addedolditem = TransformMarcToKoha($itemtosave); >- my $exist_itemnumber = get_item_from_barcode($addedolditem->{'barcode'}); >- if ($exist_itemnumber && $exist_itemnumber != $itemnumber) { >+ if ( Koha::Items->search({ barcode => $item->barcode, itemnumber => { '!=' => $item->itemnumber } })->count ) { >+ # FIXME We shouldn't need that, ->store would explode as there is a unique constraint on items.barcode > push @errors,"barcode_not_unique"; > } else { >- my $item = Koha::Items->find($itemnumber ); >- my $newitem = ModItemFromMarc($itemtosave, $biblionumber, $itemnumber); >- $itemnumber = q{}; >- my $olditemlost = $item->itemlost; >- my $newitemlost = $newitem->{itemlost}; >+ my $newitemlost = $item->itemlost; > if ( $newitemlost && $newitemlost ge '1' && !$olditemlost ) { >- LostItem( $item->itemnumber, 'additem' ) >+ LostItem( $item->itemnumber, 'additem' ); > } >+ $item->store; > } >+ > $nextop="additem"; > } elsif ($op eq "delinkitem"){ > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >index d4581936da..9d60c2d964 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >@@ -148,6 +148,13 @@ > <fieldset class="rows"> > <ol> > [% FOREACH ite IN item %] >+ >+ [% IF ite.kohafield == 'items.more_subfields_xml' %] >+ [% SET kohafield = 'items.more_subfields_xml_' _ ite.subfield %] >+ [% ELSE %] >+ [% SET kohafield = ite.kohafield %] >+ [% END %] >+ > <li><div class="subfield_line" style="[% ite.visibility | html %]" id="subfield[% ite.tag | html %][% ite.subfield | html %][% ite.random | html %]"> > [% IF ( ite.mandatory ) %] > <label class="required">[% ite.subfield | html %] - [% ite.marc_lib | $raw %]</label> >@@ -157,12 +164,12 @@ > > [% SET mv = ite.marc_value %] > [% IF ( mv.type == 'hidden' ) %] >- <input type="hidden" id="[%- mv.id | html -%]" name="field_value" class="input_marceditor" size="50" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]"> >+ <input type="hidden" id="[%- mv.id | html -%]" name="[% kohafield %]" class="input_marceditor" size="50" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]"> > [% ELSIF ( mv.type == 'select' ) %] > [% IF ( mv.readonly || ite.IS_RETURN_CLAIM ) %] >- <select name="field_value" id="[%- mv.id | html -%]" size="1" class="input_marceditor" readonly="readonly" disabled="disabled"> >+ <select name="[% kohafield %]" id="[%- mv.id | html -%]" size="1" class="input_marceditor" readonly="readonly" disabled="disabled"> > [% ELSE %] >- <select name="field_value" id="[%- mv.id | html -%]" size="1" class="input_marceditor" data-category="[% mv.category | html %]"> >+ <select name="[% kohafield %]" id="[%- mv.id | html -%]" size="1" class="input_marceditor" data-category="[% mv.category | html %]"> > [% END %] > [% FOREACH aval IN mv.values %] > [% IF aval == mv.default %] >@@ -178,17 +185,17 @@ > </select> > [% ELSIF ( mv.type == 'text_auth' ) %] > [% IF mv.readonly %] >- <input type="text" id="[%- mv.id | html -%]" name="field_value" class="input_marceditor" size="50" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" readonly="readonly" /> >+ <input type="text" id="[%- mv.id | html -%]" name="[% kohafield %]" class="input_marceditor" size="50" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" readonly="readonly" /> > [% ELSE %] >- <input type="text" id="[%- mv.id | html -%]" name="field_value" class="input_marceditor" size="50" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" /> >+ <input type="text" id="[%- mv.id | html -%]" name="[% kohafield %]" class="input_marceditor" size="50" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" /> > [% SET dopop = "Dopop('/cgi-bin/koha/authorities/auth_finder.pl?authtypecode=\"${mv.authtypecode}\"&index=${mv.id}','${mv.id}')" %] > <a href="#" class="buttonDot" onclick="[%- dopop | html -%]; return false;" title="Tag editor">...</a> > [% END %] > [% ELSIF ( mv.type == 'text_plugin' ) %] > [% IF mv.readonly %] >- <input type="text" id="[%- mv.id | html -%]" name="field_value" class="input_marceditor" size="50" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" readonly="readonly" /> >+ <input type="text" id="[%- mv.id | html -%]" name="[% kohafield %]" class="input_marceditor" size="50" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" readonly="readonly" /> > [% ELSE %] >- <input type="text" id="[%- mv.id | html -%]" name="field_value" class="input_marceditor" size="50" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" /> >+ <input type="text" id="[%- mv.id | html -%]" name="[% kohafield %]" class="input_marceditor" size="50" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" /> > [% IF ( mv.nopopup ) %] > <a href="#" id="buttonDot_[%- mv.id | html -%]" class="[%- mv.class | html -%]" title="No popup">...</a> > [% ELSE %] >@@ -198,18 +205,21 @@ > [% END %] > [% ELSIF ( mv.type == 'text' ) %] > [% IF mv.readonly %] >- <input type="text" id="[%- mv.id | html -%]" name="field_value" class="input_marceditor" size="50" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" readonly="readonly" /> >+ <input type="text" id="[%- mv.id | html -%]" name="[% kohafield %]" class="input_marceditor" size="50" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" readonly="readonly" /> > [% ELSE %] >- <input type="text" id="[%- mv.id | html -%]" name="field_value" class="input_marceditor" size="50" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" /> >+ <input type="text" id="[%- mv.id | html -%]" name="[% kohafield %]" class="input_marceditor" size="50" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" /> > [% END %] > [% ELSIF ( mv.type == 'textarea' ) %] > [% IF mv.readonly %] >- <textarea id="[%- mv.id | html -%]" name="field_value" class="input_marceditor" rows="5" cols="64" readonly="readonly" >[% mv.value | html %]</textarea> >+ <textarea id="[%- mv.id | html -%]" name="[% kohafield %]" class="input_marceditor" rows="5" cols="64" readonly="readonly" >[% mv.value | html %]</textarea> > [% ELSE %] >- <textarea id="[%- mv.id | html -%]" name="field_value" class="input_marceditor" rows="5" cols="64" >[% mv.value | html %]</textarea> >+ <textarea id="[%- mv.id | html -%]" name="[% kohafield %]" class="input_marceditor" rows="5" cols="64" >[% mv.value | html %]</textarea> > [% END %] > [% END %] > >+ [% IF ite.kohafield == 'items.more_subfields_xml' %] >+ <input type="hidden" name="items.more_subfields_xml" value="[% ite.subfield %]" /> >+ [% END %] > <input type="hidden" name="tag" value="[% ite.tag | html %]" /> > <input type="hidden" name="subfield" value="[% ite.subfield | html %]" /> > <input type="hidden" name="mandatory" value="[% ite.mandatory | html %]" /> >@@ -253,7 +263,7 @@ > [% ELSE %] > <input type="hidden" name="tag" value="[% itemtagfield | html %]" /> > <input type="hidden" name="subfield" value="[% itemtagsubfield | html %]" /> >- <input type="hidden" name="field_value" value="[% itemnumber | html %]" /> >+ <input type="hidden" name="itemnumber" value="[% itemnumber | html %]" /> > <input type="submit" value="Save changes" onclick="return Check(this.form)"> > <input type="button" id="addnewitem" value="Add a new item"> > <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber | uri %]">Cancel</a> >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 27526
:
115679
|
115680
|
116006
|
117806
|
117807
|
117808
|
121589
|
121590
|
121591
|
122288
|
122318
|
122655
|
122656
|
122657
|
122658
|
122676
|
122677
|
122681
|
122682
|
122694
|
122695
|
122696
|
122946
|
122947
|
122948
|
122949
|
122950
|
122951
|
122952
|
122953
|
122954
|
122957
|
122958
|
122959
|
122974
|
123006
|
123007
|
123110
|
123329
|
123372
|
123415
|
123757
|
123758
|
123759
|
123760
|
123761
|
123762
|
123763
|
123764
|
123765
|
123766
|
123767
|
123768
|
123769
|
123770
|
123771
|
123772
|
125069
|
125605
|
125606
|
125607
|
125608
|
125609
|
125610
|
125611
|
125612
|
125613
|
125614
|
125615
|
125616
|
125617
|
125618
|
125619
|
125620
|
125818
|
125839
|
125863
|
126034
|
126051
|
126143
|
126144
|
126393
|
127025
|
127032