Bugzilla – Attachment 122655 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.53 KB, created by
Tomás Cohen Arazi (tcohen)
on 2021-07-07 21:20:24 UTC
(
hide
)
Description:
Bug 27526: Remove ModItemFromMarc from additem
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2021-07-07 21:20:24 UTC
Size:
12.53 KB
patch
obsolete
>From 04b3d84199621e0aff80a5b285e10faf16d4e2f7 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 > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > 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 45d1b31887..e8e952cbf4 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -2077,7 +2077,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 b1e0357398..011148c2fa 100755 >--- a/cataloguing/additem.pl >+++ b/cataloguing/additem.pl >@@ -117,6 +117,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}; >@@ -730,33 +731,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 bfecf0016c..666c38d275 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >@@ -156,6 +156,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> >@@ -165,12 +172,12 @@ > > [% SET mv = ite.marc_value %] > [% IF ( mv.type == 'hidden' ) %] >- <input type="hidden" id="[%- mv.id | html -%]" name="field_value" class="input_marceditor" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]"> >+ <input type="hidden" id="[%- mv.id | html -%]" name="[% kohafield %]" class="input_marceditor" 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 -%]" class="input_marceditor" readonly="readonly" disabled="disabled" data-width="50%"> >+ <select name="[% kohafield %]" id="[%- mv.id | html -%]" class="input_marceditor" readonly="readonly" disabled="disabled" data-width="50%"> > [% ELSE %] >- <select name="field_value" id="[%- mv.id | html -%]" class="input_marceditor" data-category="[% mv.category | html %]" data-width="50%"> >+ <select name="[% kohafield %]" id="[%- mv.id | html -%]" class="input_marceditor" data-category="[% mv.category | html %]" data-width="50%"> > [% END %] > [% FOREACH aval IN mv.values %] > [% IF aval == mv.default %] >@@ -186,17 +193,17 @@ > </select> > [% ELSIF ( mv.type == 'text_auth' ) %] > [% IF mv.readonly %] >- <input type="text" id="[%- mv.id | html -%]" name="field_value" class="input_marceditor" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" readonly="readonly" /> >+ <input type="text" id="[%- mv.id | html -%]" name="[% kohafield %]" class="input_marceditor" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" readonly="readonly" /> > [% ELSE %] >- <input type="text" id="[%- mv.id | html -%]" name="field_value" class="input_marceditor" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" /> >+ <input type="text" id="[%- mv.id | html -%]" name="[% kohafield %]" class="input_marceditor" 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" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" readonly="readonly" /> >+ <input type="text" id="[%- mv.id | html -%]" name="[% kohafield %]" class="input_marceditor" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" readonly="readonly" /> > [% ELSE %] >- <input type="text" id="[%- mv.id | html -%]" name="field_value" class="input_marceditor" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" /> >+ <input type="text" id="[%- mv.id | html -%]" name="[% kohafield %]" class="input_marceditor" 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 %] >@@ -206,18 +213,21 @@ > [% END %] > [% ELSIF ( mv.type == 'text' ) %] > [% IF mv.readonly %] >- <input type="text" id="[%- mv.id | html -%]" name="field_value" class="input_marceditor" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" readonly="readonly" /> >+ <input type="text" id="[%- mv.id | html -%]" name="[% kohafield %]" class="input_marceditor" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" readonly="readonly" /> > [% ELSE %] >- <input type="text" id="[%- mv.id | html -%]" name="field_value" class="input_marceditor" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" /> >+ <input type="text" id="[%- mv.id | html -%]" name="[% kohafield %]" class="input_marceditor" 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 %]" /> >@@ -261,7 +271,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.32.0
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