View | Details | Raw Unified | Return to bug 27526
Collapse All | Expand All

(-)a/C4/Biblio.pm (-1 / +1 lines)
Lines 2086-2092 sub TransformHtmlToXml { Link Here
2086
2086
2087
    my $xml = MARC::File::XML::header('UTF-8');
2087
    my $xml = MARC::File::XML::header('UTF-8');
2088
    $xml .= "<record>\n";
2088
    $xml .= "<record>\n";
2089
    $auth_type = C4::Context->preference('marcflavour') unless $auth_type;
2089
    $auth_type = C4::Context->preference('marcflavour') unless $auth_type; # FIXME auth_type must be removed
2090
    MARC::File::XML->default_record_format($auth_type);
2090
    MARC::File::XML->default_record_format($auth_type);
2091
2091
2092
    # in UNIMARC, field 100 contains the encoding
2092
    # in UNIMARC, field 100 contains the encoding
(-)a/cataloguing/additem.pl (-21 / +38 lines)
Lines 127-132 sub generate_subfield_form { Link Here
127
        $subfield_data{repeatable} = $subfieldlib->{repeatable};
127
        $subfield_data{repeatable} = $subfieldlib->{repeatable};
128
        $subfield_data{maxlength}  = $subfieldlib->{maxlength};
128
        $subfield_data{maxlength}  = $subfieldlib->{maxlength};
129
        $subfield_data{display_order} = $subfieldlib->{display_order};
129
        $subfield_data{display_order} = $subfieldlib->{display_order};
130
        $subfield_data{kohafield}  = $subfieldlib->{kohafield} || 'items.more_subfields_xml';
130
        
131
        
131
        if ( ! defined( $value ) || $value eq '')  {
132
        if ( ! defined( $value ) || $value eq '')  {
132
            $value = $subfieldlib->{defaultvalue};
133
            $value = $subfieldlib->{defaultvalue};
Lines 741-773 if ($op eq "additem") { Link Here
741
#-------------------------------------------------------------------------------
742
#-------------------------------------------------------------------------------
742
} elsif ($op eq "saveitem") {
743
} elsif ($op eq "saveitem") {
743
#-------------------------------------------------------------------------------
744
#-------------------------------------------------------------------------------
744
    # rebuild
745
745
    my @tags      = $input->multi_param('tag');
746
    my $itemnumber = $input->param('itemnumber');
746
    my @subfields = $input->multi_param('subfield');
747
    my $item = Koha::Items->find($itemnumber);
747
    my @values    = $input->multi_param('field_value');
748
    # FIXME Handle non existent item
748
    # build indicator hash.
749
    my $olditemlost = $item->itemlost;
749
    my @ind_tag   = $input->multi_param('ind_tag');
750
    my @columns = Koha::Items->columns;
750
    my @indicator = $input->multi_param('indicator');
751
    for my $c ( @columns ) {
751
    # my $itemnumber = $input->param('itemnumber');
752
        if ( $c eq 'more_subfields_xml' ) {
752
    my $xml = TransformHtmlToXml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag,'ITEM');
753
            my @more_subfields_xml = $input->multi_param("items.more_subfields_xml");
753
    my $itemtosave=MARC::Record::new_from_xml($xml, 'UTF-8');
754
            my @unlinked_item_subfields;
754
    # MARC::Record builded => now, record in DB
755
            for my $subfield ( @more_subfields_xml ) {
755
    # warn "R: ".$record->as_formatted;
756
                my $v = $input->param('items.more_subfields_xml_' . $subfield);
757
                push @unlinked_item_subfields, $subfield, $v;
758
            }
759
            if ( @unlinked_item_subfields ) {
760
                my $marc = MARC::Record->new();
761
                # use of tag 999 is arbitrary, and doesn't need to match the item tag
762
                # used in the framework
763
                $marc->append_fields(MARC::Field->new('999', ' ', ' ', @unlinked_item_subfields));
764
                $marc->encoding("UTF-8");
765
                $item->more_subfields_xml($marc->as_xml("USMARC"));
766
                next;
767
            }
768
            $item->more_subfields_xml(undef);
769
        } else {
770
            my $v = $input->param("items.".$c);
771
            next unless defined $v;
772
            $item->$c($v);
773
        }
774
    }
775
756
    # check that the barcode don't exist already
776
    # check that the barcode don't exist already
757
    my $addedolditem = TransformMarcToKoha($itemtosave);
777
    if ( Koha::Items->search({ barcode => $item->barcode, itemnumber => { '!=' => $item->itemnumber } })->count ) {
758
    my $exist_itemnumber = get_item_from_barcode($addedolditem->{'barcode'});
778
        # FIXME We shouldn't need that, ->store would explode as there is a unique constraint on items.barcode
759
    if ($exist_itemnumber && $exist_itemnumber != $itemnumber) {
760
        push @errors,"barcode_not_unique";
779
        push @errors,"barcode_not_unique";
761
    } else {
780
    } else {
762
        my $item = Koha::Items->find($itemnumber );
781
        my $newitemlost = $item->itemlost;
763
        my $newitem = ModItemFromMarc($itemtosave, $biblionumber, $itemnumber);
764
        $itemnumber = q{};
765
        my $olditemlost = $item->itemlost;
766
        my $newitemlost = $newitem->{itemlost};
767
        if ( $newitemlost && $newitemlost ge '1' && !$olditemlost ) {
782
        if ( $newitemlost && $newitemlost ge '1' && !$olditemlost ) {
768
            LostItem( $item->itemnumber, 'additem' )
783
            LostItem( $item->itemnumber, 'additem' );
769
        }
784
        }
785
        $item->store;
770
    }
786
    }
787
771
    $nextop="additem";
788
    $nextop="additem";
772
} elsif ($op eq "delinkitem"){
789
} elsif ($op eq "delinkitem"){
773
790
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt (-13 / +22 lines)
Lines 156-161 Link Here
156
	<fieldset class="rows">
156
	<fieldset class="rows">
157
	<ol>
157
	<ol>
158
        [% FOREACH ite IN item %]
158
        [% FOREACH ite IN item %]
159
160
                [% IF ite.kohafield == 'items.more_subfields_xml' %]
161
                    [% SET kohafield = 'items.more_subfields_xml_' _ ite.subfield %]
162
                [% ELSE %]
163
                    [% SET kohafield = ite.kohafield %]
164
                [% END %]
165
159
               <li><div class="subfield_line" style="[% ite.visibility | html %]" id="subfield[% ite.tag | html %][% ite.subfield | html %][% ite.random | html %]">
166
               <li><div class="subfield_line" style="[% ite.visibility | html %]" id="subfield[% ite.tag | html %][% ite.subfield | html %][% ite.random | html %]">
160
                [% IF ( ite.mandatory ) %]
167
                [% IF ( ite.mandatory ) %]
161
               <label class="required">[% ite.subfield | html %] - [% ite.marc_lib | $raw %]</label>
168
               <label class="required">[% ite.subfield | html %] - [% ite.marc_lib | $raw %]</label>
Lines 165-176 Link Here
165
172
166
                [% SET mv = ite.marc_value %]
173
                [% SET mv = ite.marc_value %]
167
                [% IF ( mv.type == 'hidden' ) %]
174
                [% IF ( mv.type == 'hidden' ) %]
168
                    <input type="hidden" id="[%- mv.id | html -%]" name="field_value" class="input_marceditor" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]">
175
                    <input type="hidden" id="[%- mv.id | html -%]" name="[% kohafield %]" class="input_marceditor" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]">
169
                [% ELSIF ( mv.type == 'select' ) %]
176
                [% ELSIF ( mv.type == 'select' ) %]
170
                    [% IF ( mv.readonly || ite.IS_RETURN_CLAIM ) %]
177
                    [% IF ( mv.readonly || ite.IS_RETURN_CLAIM ) %]
171
                        <select name="field_value" id="[%- mv.id | html -%]" class="input_marceditor" readonly="readonly" disabled="disabled" data-width="50%">
178
                        <select name="[% kohafield %]" id="[%- mv.id | html -%]" class="input_marceditor" readonly="readonly" disabled="disabled" data-width="50%">
172
                    [% ELSE %]
179
                    [% ELSE %]
173
                        <select name="field_value" id="[%- mv.id | html -%]" class="input_marceditor" data-category="[% mv.category | html %]"  data-width="50%">
180
                        <select name="[% kohafield %]" id="[%- mv.id | html -%]" class="input_marceditor" data-category="[% mv.category | html %]" data-width="50%">
174
                    [% END %]
181
                    [% END %]
175
                    [% FOREACH aval IN mv.values %]
182
                    [% FOREACH aval IN mv.values %]
176
                        [% IF aval == mv.default %]
183
                        [% IF aval == mv.default %]
Lines 186-202 Link Here
186
                    </select>
193
                    </select>
187
                [% ELSIF ( mv.type == 'text_auth' ) %]
194
                [% ELSIF ( mv.type == 'text_auth' ) %]
188
                    [% IF mv.readonly %]
195
                    [% IF mv.readonly %]
189
                        <input type="text" id="[%- mv.id | html -%]" name="field_value" class="input_marceditor" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" readonly="readonly" />
196
                        <input type="text" id="[%- mv.id | html -%]" name="[% kohafield %]" class="input_marceditor" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" readonly="readonly" />
190
                    [% ELSE %]
197
                    [% ELSE %]
191
                        <input type="text" id="[%- mv.id | html -%]" name="field_value" class="input_marceditor" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" />
198
                        <input type="text" id="[%- mv.id | html -%]" name="[% kohafield %]" class="input_marceditor" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" />
192
                        [% SET dopop = "Dopop('/cgi-bin/koha/authorities/auth_finder.pl?authtypecode=\"${mv.authtypecode}\"&index=${mv.id}','${mv.id}')" %]
199
                        [% SET dopop = "Dopop('/cgi-bin/koha/authorities/auth_finder.pl?authtypecode=\"${mv.authtypecode}\"&index=${mv.id}','${mv.id}')" %]
193
                        <a href="#" class="buttonDot"  onclick="[%- dopop | html -%]; return false;" title="Tag editor">...</a>
200
                        <a href="#" class="buttonDot"  onclick="[%- dopop | html -%]; return false;" title="Tag editor">...</a>
194
                    [% END %]
201
                    [% END %]
195
                [% ELSIF ( mv.type == 'text_plugin' ) %]
202
                [% ELSIF ( mv.type == 'text_plugin' ) %]
196
                    [% IF mv.readonly %]
203
                    [% IF mv.readonly %]
197
                        <input type="text" id="[%- mv.id | html -%]" name="field_value" class="input_marceditor" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" readonly="readonly" />
204
                        <input type="text" id="[%- mv.id | html -%]" name="[% kohafield %]" class="input_marceditor" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" readonly="readonly" />
198
                    [% ELSE %]
205
                    [% ELSE %]
199
                        <input type="text" id="[%- mv.id | html -%]" name="field_value" class="input_marceditor" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" />
206
                        <input type="text" id="[%- mv.id | html -%]" name="[% kohafield %]" class="input_marceditor" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" />
200
                        [% IF ( mv.nopopup ) %]
207
                        [% IF ( mv.nopopup ) %]
201
                            <a href="#" id="buttonDot_[%- mv.id | html -%]" class="[%- mv.class | html -%]" title="No popup">...</a>
208
                            <a href="#" id="buttonDot_[%- mv.id | html -%]" class="[%- mv.class | html -%]" title="No popup">...</a>
202
                        [% ELSE  %]
209
                        [% ELSE  %]
Lines 206-223 Link Here
206
                    [% END %]
213
                    [% END %]
207
                [% ELSIF ( mv.type == 'text' ) %]
214
                [% ELSIF ( mv.type == 'text' ) %]
208
                    [% IF mv.readonly %]
215
                    [% IF mv.readonly %]
209
                        <input type="text" id="[%- mv.id | html -%]" name="field_value" class="input_marceditor" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" readonly="readonly" />
216
                        <input type="text" id="[%- mv.id | html -%]" name="[% kohafield %]" class="input_marceditor" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" readonly="readonly" />
210
                    [% ELSE %]
217
                    [% ELSE %]
211
                        <input type="text" id="[%- mv.id | html -%]" name="field_value" class="input_marceditor" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" />
218
                        <input type="text" id="[%- mv.id | html -%]" name="[% kohafield %]" class="input_marceditor" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" />
212
                    [% END %]
219
                    [% END %]
213
                [% ELSIF ( mv.type == 'textarea' ) %]
220
                [% ELSIF ( mv.type == 'textarea' ) %]
214
                    [% IF mv.readonly %]
221
                    [% IF mv.readonly %]
215
                        <textarea id="[%- mv.id | html -%]" name="field_value" class="input_marceditor" rows="5" cols="64" readonly="readonly" >[% mv.value | html %]</textarea>
222
                        <textarea id="[%- mv.id | html -%]" name="[% kohafield %]" class="input_marceditor" rows="5" cols="64" readonly="readonly" >[% mv.value | html %]</textarea>
216
                    [% ELSE %]
223
                    [% ELSE %]
217
                        <textarea id="[%- mv.id | html -%]" name="field_value" class="input_marceditor" rows="5" cols="64" >[% mv.value | html %]</textarea>
224
                        <textarea id="[%- mv.id | html -%]" name="[% kohafield %]" class="input_marceditor" rows="5" cols="64" >[% mv.value | html %]</textarea>
218
                    [% END %]
225
                    [% END %]
219
                [% END %]
226
                [% END %]
220
227
228
                [% IF ite.kohafield == 'items.more_subfields_xml' %]
229
                    <input type="hidden" name="items.more_subfields_xml" value="[% ite.subfield %]" />
230
                [% END %]
221
                <input type="hidden" name="tag"       value="[% ite.tag | html %]" />
231
                <input type="hidden" name="tag"       value="[% ite.tag | html %]" />
222
                <input type="hidden" name="subfield"  value="[% ite.subfield | html %]" />
232
                <input type="hidden" name="subfield"  value="[% ite.subfield | html %]" />
223
                <input type="hidden" name="mandatory" value="[% ite.mandatory | html %]" />
233
                <input type="hidden" name="mandatory" value="[% ite.mandatory | html %]" />
Lines 261-267 Link Here
261
    [% ELSE %]
271
    [% ELSE %]
262
    <input type="hidden" name="tag" value="[% itemtagfield | html %]" />
272
    <input type="hidden" name="tag" value="[% itemtagfield | html %]" />
263
    <input type="hidden" name="subfield" value="[% itemtagsubfield | html %]" />
273
    <input type="hidden" name="subfield" value="[% itemtagsubfield | html %]" />
264
    <input type="hidden" name="field_value" value="[% itemnumber | html %]" />
274
    <input type="hidden" name="itemnumber" value="[% itemnumber | html %]" />
265
    <input type="submit" value="Save changes" onclick="return Check(this.form)">
275
    <input type="submit" value="Save changes" onclick="return Check(this.form)">
266
    <input type="button" id="addnewitem" value="Add a new item">
276
    <input type="button" id="addnewitem" value="Add a new item">
267
    <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber | uri %]">Cancel</a>
277
    <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber | uri %]">Cancel</a>
268
- 

Return to bug 27526