Updated fix for Bug 2170, Adding 'edititems' user-permission
[koha.git] / cataloguing / additem.pl
blob6dc190a213cae64a6d4b7ac3dd1cf469358c09c0
1 #!/usr/bin/perl
4 # Copyright 2000-2002 Katipo Communications
6 # This file is part of Koha.
8 # Koha is free software; you can redistribute it and/or modify it under the
9 # terms of the GNU General Public License as published by the Free Software
10 # Foundation; either version 2 of the License, or (at your option) any later
11 # version.
13 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along
18 # with Koha; if not, write to the Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 use strict;
22 #use warnings; FIXME - Bug 2505
23 use CGI;
24 use C4::Auth;
25 use C4::Output;
26 use C4::Biblio;
27 use C4::Items;
28 use C4::Context;
29 use C4::Koha; # XXX subfield_is_koha_internal_p
30 use C4::Branch; # XXX subfield_is_koha_internal_p
31 use C4::ClassSource;
32 use C4::Dates;
34 use MARC::File::XML;
36 my $dbh = C4::Context->dbh;
38 sub find_value {
39 my ($tagfield,$insubfield,$record) = @_;
40 my $result;
41 my $indicator;
42 foreach my $field ($record->field($tagfield)) {
43 my @subfields = $field->subfields();
44 foreach my $subfield (@subfields) {
45 if (@$subfield[0] eq $insubfield) {
46 $result .= @$subfield[1];
47 $indicator = $field->indicator(1).$field->indicator(2);
51 return($indicator,$result);
54 sub get_item_from_barcode {
55 my ($barcode)=@_;
56 my $dbh=C4::Context->dbh;
57 my $result;
58 my $rq=$dbh->prepare("SELECT itemnumber from items where items.barcode=?");
59 $rq->execute($barcode);
60 ($result)=$rq->fetchrow;
61 return($result);
64 sub set_item_default_location {
65 my $itemnumber = shift;
66 if ( C4::Context->preference('NewItemsDefaultLocation') ) {
67 my $item = GetItem( $itemnumber );
68 $item->{'permanent_location'} = $item->{'location'};
69 $item->{'location'} = C4::Context->preference('NewItemsDefaultLocation');
70 ModItem( $item, undef, $itemnumber);
74 # NOTE: This code is subject to change in the future with the implemenation of ajax based autobarcode code
75 # NOTE: 'incremental' is the ONLY autoBarcode option available to those not using javascript
76 sub _increment_barcode {
77 my ($record, $frameworkcode) = @_;
78 my ($tagfield,$tagsubfield) = &GetMarcFromKohaField("items.barcode",$frameworkcode);
79 unless ($record->field($tagfield)->subfield($tagsubfield)) {
80 my $sth_barcode = $dbh->prepare("select max(abs(barcode)) from items");
81 $sth_barcode->execute;
82 my ($newbarcode) = $sth_barcode->fetchrow;
83 $newbarcode++;
84 # OK, we have the new barcode, now create the entry in MARC record
85 my $fieldItem = $record->field($tagfield);
86 $record->delete_field($fieldItem);
87 $fieldItem->add_subfields($tagsubfield => $newbarcode);
88 $record->insert_fields_ordered($fieldItem);
90 return $record;
94 my $input = new CGI;
95 my $error = $input->param('error');
96 my $biblionumber = $input->param('biblionumber');
97 my $itemnumber = $input->param('itemnumber');
98 my $op = $input->param('op');
100 my $frameworkcode = &GetFrameworkCode($biblionumber);
102 # Defining which userflag is needing according to the framework currently used
103 my $userflags;
104 if (defined $input->param('frameworkcode')) {
105 $userflags = ($input->param('frameworkcode') eq 'FA') ? "fast_cataloging" : "edit_items";
108 if (not defined $userflags) {
109 $userflags = ($frameworkcode eq 'FA') ? "fast_cataloging" : "edit_items";
112 my ($template, $loggedinuser, $cookie)
113 = get_template_and_user({template_name => "cataloguing/additem.tmpl",
114 query => $input,
115 type => "intranet",
116 authnotrequired => 0,
117 flagsrequired => {editcatalogue => $userflags},
118 debug => 1,
122 my $today_iso = C4::Dates->today('iso');
123 $template->param(today_iso => $today_iso);
125 my $tagslib = &GetMarcStructure(1,$frameworkcode);
126 my $record = GetMarcBiblio($biblionumber);
127 my $oldrecord = TransformMarcToKoha($dbh,$record);
128 my $itemrecord;
129 my $nextop="additem";
130 my @errors; # store errors found while checking data BEFORE saving item.
131 #-------------------------------------------------------------------------------
132 if ($op eq "additem") {
133 #-------------------------------------------------------------------------------
134 # rebuild
135 my @tags = $input->param('tag');
136 my @subfields = $input->param('subfield');
137 my @values = $input->param('field_value');
138 # build indicator hash.
139 my @ind_tag = $input->param('ind_tag');
140 my @indicator = $input->param('indicator');
141 my $xml = TransformHtmlToXml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag, 'ITEM');
142 my $record = MARC::Record::new_from_xml($xml, 'UTF-8');
144 # type of add
145 my $add_submit = $input->param('add_submit');
146 my $add_duplicate_submit = $input->param('add_duplicate_submit');
147 my $add_multiple_copies_submit = $input->param('add_multiple_copies_submit');
148 my $number_of_copies = $input->param('number_of_copies');
150 if (C4::Context->preference('autoBarcode') eq 'incremental') {
151 $record = _increment_barcode($record, $frameworkcode);
154 my $addedolditem = TransformMarcToKoha($dbh,$record);
156 # If we have to add or add & duplicate, we add the item
157 if ($add_submit || $add_duplicate_submit) {
158 # check for item barcode # being unique
159 my $exist_itemnumber = get_item_from_barcode($addedolditem->{'barcode'});
160 push @errors,"barcode_not_unique" if($exist_itemnumber);
161 # if barcode exists, don't create, but report The problem.
162 unless ($exist_itemnumber) {
163 my ($oldbiblionumber,$oldbibnum,$oldbibitemnum) = AddItemFromMarc($record,$biblionumber);
164 set_item_default_location($oldbibitemnum);
166 $nextop = "additem";
167 if ($exist_itemnumber) {
168 $itemrecord = $record;
172 # If we have to add & duplicate
173 if ($add_duplicate_submit) {
174 $itemrecord = $record;
175 if (C4::Context->preference('autoBarcode') eq 'incremental') {
176 $itemrecord = _increment_barcode($itemrecord, $frameworkcode);
178 else {
179 # we have to clear the barcode field in the duplicate item record to make way for the new one generated by the javascript plugin
180 my ($tagfield,$tagsubfield) = &GetMarcFromKohaField("items.barcode",$frameworkcode);
181 my $fieldItem = $itemrecord->field($tagfield);
182 $itemrecord->delete_field($fieldItem);
183 $fieldItem->delete_subfields($tagsubfield);
184 $itemrecord->insert_fields_ordered($fieldItem);
188 # If we have to add multiple copies
189 if ($add_multiple_copies_submit) {
191 use C4::Barcodes;
192 my $barcodeobj = C4::Barcodes->new;
193 my $oldbarcode = $addedolditem->{'barcode'};
194 my ($tagfield,$tagsubfield) = &GetMarcFromKohaField("items.barcode",$frameworkcode);
196 # If there is a barcode and we can't find him new values, we can't add multiple copies
197 my $testbarcode = $barcodeobj->next_value($oldbarcode) if $barcodeobj;
198 if ($oldbarcode && !$testbarcode) {
200 push @errors, "no_next_barcode";
201 $itemrecord = $record;
203 } else {
204 # We add each item
206 # For the first iteration
207 my $barcodevalue = $oldbarcode;
208 my $exist_itemnumber;
211 for (my $i = 0; $i < $number_of_copies;) {
213 # If there is a barcode
214 if ($barcodevalue) {
216 # Getting a new barcode (if it is not the first iteration or the barcode we tried already exists)
217 $barcodevalue = $barcodeobj->next_value($oldbarcode) if ($i > 0 || $exist_itemnumber);
219 # Putting it into the record
220 if ($barcodevalue) {
221 $record->field($tagfield)->update($tagsubfield => $barcodevalue);
224 # Checking if the barcode already exists
225 $exist_itemnumber = get_item_from_barcode($barcodevalue);
228 # Adding the item
229 if (!$exist_itemnumber) {
230 my ($oldbiblionumber,$oldbibnum,$oldbibitemnum) = AddItemFromMarc($record,$biblionumber);
231 set_item_default_location($oldbibitemnum);
233 # We count the item only if it was really added
234 # That way, all items are added, even if there was some already existing barcodes
235 # FIXME : Please note that there is a risk of infinite loop here if we never find a suitable barcode
236 $i++;
239 # Preparing the next iteration
240 $oldbarcode = $barcodevalue;
242 undef($itemrecord);
247 #-------------------------------------------------------------------------------
248 } elsif ($op eq "edititem") {
249 #-------------------------------------------------------------------------------
250 # retrieve item if exist => then, it's a modif
251 $itemrecord = C4::Items::GetMarcItem($biblionumber,$itemnumber);
252 $nextop = "saveitem";
253 #-------------------------------------------------------------------------------
254 } elsif ($op eq "delitem") {
255 #-------------------------------------------------------------------------------
256 # check that there is no issue on this item before deletion.
257 $error = &DelItemCheck($dbh,$biblionumber,$itemnumber);
258 if($error == 1){
259 print $input->redirect("additem.pl?biblionumber=$biblionumber&frameworkcode=$frameworkcode");
260 }else{
261 push @errors,$error;
262 $nextop="additem";
264 #-------------------------------------------------------------------------------
265 } elsif ($op eq "delallitems") {
266 #-------------------------------------------------------------------------------
267 my @biblioitems = &GetBiblioItemByBiblioNumber($biblionumber);
268 foreach my $biblioitem (@biblioitems){
269 my $items = &GetItemsByBiblioitemnumber($biblioitem->{biblioitemnumber});
271 foreach my $item (@$items){
272 # FIXME although it won't delete items that have loans
273 # or waiting holds on them, should explicitly tell operator
274 # about items that are not deleted
275 &DelItemCheck($dbh,$biblionumber,$item->{itemnumber});
278 #-------------------------------------------------------------------------------
279 } elsif ($op eq "saveitem") {
280 #-------------------------------------------------------------------------------
281 # rebuild
282 my @tags = $input->param('tag');
283 my @subfields = $input->param('subfield');
284 my @values = $input->param('field_value');
285 # build indicator hash.
286 my @ind_tag = $input->param('ind_tag');
287 my @indicator = $input->param('indicator');
288 # my $itemnumber = $input->param('itemnumber');
289 my $xml = TransformHtmlToXml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag,'ITEM');
290 my $itemtosave=MARC::Record::new_from_xml($xml, 'UTF-8');
291 # MARC::Record builded => now, record in DB
292 # warn "R: ".$record->as_formatted;
293 # check that the barcode don't exist already
294 my $addedolditem = TransformMarcToKoha($dbh,$itemtosave);
295 my $exist_itemnumber = get_item_from_barcode($addedolditem->{'barcode'});
296 if ($exist_itemnumber && $exist_itemnumber != $itemnumber) {
297 push @errors,"barcode_not_unique";
298 } else {
299 my ($oldbiblionumber,$oldbibnum,$oldbibitemnum) = ModItemFromMarc($itemtosave,$biblionumber,$itemnumber);
300 $itemnumber="";
302 $nextop="additem";
306 #-------------------------------------------------------------------------------
307 # build screen with existing items. and "new" one
308 #-------------------------------------------------------------------------------
310 # now, build existiing item list
311 my $temp = GetMarcBiblio( $biblionumber );
312 my @fields = $temp->fields();
313 #my @fields = $record->fields();
314 my %witness; #---- stores the list of subfields used at least once, with the "meaning" of the code
315 my @big_array;
316 #---- finds where items.itemnumber is stored
317 my ( $itemtagfield, $itemtagsubfield) = &GetMarcFromKohaField("items.itemnumber", $frameworkcode);
318 my ($branchtagfield, $branchtagsubfield) = &GetMarcFromKohaField("items.homebranch", $frameworkcode);
320 foreach my $field (@fields) {
321 next if ($field->tag()<10);
322 my @subf = $field->subfields or (); # don't use ||, as that forces $field->subfelds to be interpreted in scalar context
323 my %this_row;
324 # loop through each subfield
325 for my $i (0..$#subf) {
326 next if ($tagslib->{$field->tag()}->{$subf[$i][0]}->{tab} ne 10
327 && ($field->tag() ne $itemtagfield
328 && $subf[$i][0] ne $itemtagsubfield));
330 $witness{$subf[$i][0]} = $tagslib->{$field->tag()}->{$subf[$i][0]}->{lib} if ($tagslib->{$field->tag()}->{$subf[$i][0]}->{tab} eq 10);
331 if ($tagslib->{$field->tag()}->{$subf[$i][0]}->{tab} eq 10) {
332 $this_row{$subf[$i][0]}=GetAuthorisedValueDesc( $field->tag(),
333 $subf[$i][0], $subf[$i][1], '', $tagslib)
334 || $subf[$i][1];
337 if (($field->tag eq $branchtagfield) && ($subf[$i][$0] eq $branchtagsubfield) && C4::Context->preference("IndependantBranches")) {
338 #verifying rights
339 my $userenv = C4::Context->userenv();
340 unless (($userenv->{'flags'} == 1) or (($userenv->{'branch'} eq $subf[$i][1]))){
341 $this_row{'nomod'}=1;
344 $this_row{itemnumber} = $subf[$i][1] if ($field->tag() eq $itemtagfield && $subf[$i][0] eq $itemtagsubfield);
346 if (%this_row) {
347 push(@big_array, \%this_row);
351 my ($holdingbrtagf,$holdingbrtagsubf) = &GetMarcFromKohaField("items.holdingbranch",$frameworkcode);
352 @big_array = sort {$a->{$holdingbrtagsubf} cmp $b->{$holdingbrtagsubf}} @big_array;
354 # now, construct template !
355 # First, the existing items for display
356 my @item_value_loop;
357 my @header_value_loop;
358 for my $row ( @big_array ) {
359 my %row_data;
360 my @item_fields = map +{ field => $_ || '' }, @$row{ sort keys(%witness) };
361 $row_data{item_value} = [ @item_fields ];
362 $row_data{itemnumber} = $row->{itemnumber};
363 #reporting this_row values
364 $row_data{'nomod'} = $row->{'nomod'};
365 push(@item_value_loop,\%row_data);
367 foreach my $subfield_code (sort keys(%witness)) {
368 my %header_value;
369 $header_value{header_value} = $witness{$subfield_code};
370 push(@header_value_loop, \%header_value);
373 # now, build the item form for entering a new item
374 my @loop_data =();
375 my $i=0;
377 my $branches = GetBranchesLoop(); # build once ahead of time, instead of multiple times later.
378 my $pref_itemcallnumber = C4::Context->preference('itemcallnumber');
380 # Getting the fields where the item location is
381 my ($location_field, $location_subfield) = GetMarcFromKohaField('items.location', $frameworkcode);
383 # Getting the name of the authorised values' category for item location
384 my $item_location_category = $tagslib->{$location_field}->{$location_subfield}->{'authorised_value'};
386 foreach my $tag (sort keys %{$tagslib}) {
387 # loop through each subfield
388 foreach my $subfield (sort keys %{$tagslib->{$tag}}) {
389 next if subfield_is_koha_internal_p($subfield);
390 next if ($tagslib->{$tag}->{$subfield}->{'tab'} ne "10");
391 my %subfield_data;
393 my $index_subfield = int(rand(1000000));
394 if ($subfield eq '@'){
395 $subfield_data{id} = "tag_".$tag."_subfield_00_".$index_subfield;
396 } else {
397 $subfield_data{id} = "tag_".$tag."_subfield_".$subfield."_".$index_subfield;
399 $subfield_data{tag} = $tag;
400 $subfield_data{subfield} = $subfield;
401 $subfield_data{random} = int(rand(1000000)); # why do we need 2 different randoms?
402 # $subfield_data{marc_lib} = $tagslib->{$tag}->{$subfield}->{lib};
403 $subfield_data{marc_lib} ="<span id=\"error$i\" title=\"".$tagslib->{$tag}->{$subfield}->{lib}."\">".$tagslib->{$tag}->{$subfield}->{lib}."</span>";
404 $subfield_data{mandatory} = $tagslib->{$tag}->{$subfield}->{mandatory};
405 $subfield_data{repeatable} = $tagslib->{$tag}->{$subfield}->{repeatable};
406 my ($x,$value);
407 ($x,$value) = find_value($tag,$subfield,$itemrecord) if ($itemrecord);
408 $value =~ s/"/&quot;/g;
409 unless ($value) {
410 $value = $tagslib->{$tag}->{$subfield}->{defaultvalue};
411 # get today date & replace YYYY, MM, DD if provided in the default value
412 my ( $year, $month, $day ) = split ',', $today_iso; # FIXME: iso dates don't have commas!
413 $value =~ s/YYYY/$year/g;
414 $value =~ s/MM/$month/g;
415 $value =~ s/DD/$day/g;
417 $subfield_data{visibility} = "display:none;" if (($tagslib->{$tag}->{$subfield}->{hidden} > 4) || ($tagslib->{$tag}->{$subfield}->{hidden} < -4));
418 # testing branch value if IndependantBranches.
419 if (!$value && $tagslib->{$tag}->{$subfield}->{kohafield} eq 'items.itemcallnumber' && $pref_itemcallnumber) {
420 my $CNtag = substr($pref_itemcallnumber, 0, 3);
421 my $CNsubfield = substr($pref_itemcallnumber, 3, 1);
422 my $CNsubfield2 = substr($pref_itemcallnumber, 4, 1);
423 my $temp2 = $temp->field($CNtag);
424 if ($temp2) {
425 $value = ($temp2->subfield($CNsubfield)).' '.($temp2->subfield($CNsubfield2));
426 #remove any trailing space incase one subfield is used
427 $value =~ s/^\s+|\s+$//g;
431 my $attributes_no_value = qq(id="$subfield_data{id}" name="field_value" class="input_marceditor" size="67" maxlength="255" );
432 my $attributes = qq($attributes_no_value value="$value" );
433 if ( $tagslib->{$tag}->{$subfield}->{authorised_value} ) {
434 my @authorised_values;
435 my %authorised_lib;
436 # builds list, depending on authorised value...
438 if ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "branches" ) {
439 foreach my $thisbranch (@$branches) {
440 push @authorised_values, $thisbranch->{value};
441 $authorised_lib{$thisbranch->{value}} = $thisbranch->{branchname};
442 # in edit item this is set to the data value otherwise use default
443 if ($op ne 'edititem' && $thisbranch->{selected} ) {
444 $value = $thisbranch->{value};
448 elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "itemtypes" ) {
449 push @authorised_values, "" unless ( $tagslib->{$tag}->{$subfield}->{mandatory} );
450 my $sth = $dbh->prepare("select itemtype,description from itemtypes order by description");
451 $sth->execute;
452 while ( my ( $itemtype, $description ) = $sth->fetchrow_array ) {
453 push @authorised_values, $itemtype;
454 $authorised_lib{$itemtype} = $description;
457 unless ( $value ) {
458 my $itype_sth = $dbh->prepare("SELECT itemtype FROM biblioitems WHERE biblionumber = ?");
459 $itype_sth->execute( $biblionumber );
460 ( $value ) = $itype_sth->fetchrow_array;
463 #---- class_sources
465 elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "cn_source" ) {
466 push @authorised_values, "" unless ( $tagslib->{$tag}->{$subfield}->{mandatory} );
468 my $class_sources = GetClassSources();
469 my $default_source = C4::Context->preference("DefaultClassificationSource");
471 foreach my $class_source (sort keys %$class_sources) {
472 next unless $class_sources->{$class_source}->{'used'} or
473 ($value and $class_source eq $value) or
474 ($class_source eq $default_source);
475 push @authorised_values, $class_source;
476 $authorised_lib{$class_source} = $class_sources->{$class_source}->{'description'};
478 $value = $default_source unless ($value);
480 #---- "true" authorised value
482 else {
483 push @authorised_values, "" unless ( $tagslib->{$tag}->{$subfield}->{mandatory} );
485 # Are we dealing with item location ?
486 my $item_location = ($tagslib->{$tag}->{$subfield}->{authorised_value} eq $item_location_category) ? 1 : 0;
488 # If so, we sort by authorised_value, else by libelle
489 my $orderby = $item_location ? 'authorised_value' : 'lib';
491 my $authorised_values_sth = $dbh->prepare("SELECT authorised_value,lib FROM authorised_values WHERE category=? ORDER BY $orderby");
493 $authorised_values_sth->execute( $tagslib->{$tag}->{$subfield}->{authorised_value});
496 while ( my ( $value, $lib ) = $authorised_values_sth->fetchrow_array ) {
497 push @authorised_values, $value;
498 if ($tagslib->{$tag}->{$subfield}->{authorised_value} eq $item_location_category) {
499 $authorised_lib{$value} = $value . " - " . $lib;
500 } else {
501 $authorised_lib{$value} = $lib;
504 # For item location, we show the code and the libelle
505 $authorised_lib{$value} = ($item_location) ? $value . " - " . $lib : $lib;
508 $subfield_data{marc_value} =CGI::scrolling_list( # FIXME: factor out scrolling_list
509 -name => "field_value",
510 -values => \@authorised_values,
511 -default => $value,
512 -labels => \%authorised_lib,
513 -override => 1,
514 -size => 1,
515 -multiple => 0,
516 # -tabindex => 1,
517 -id => "tag_".$tag."_subfield_".$subfield."_".$index_subfield,
518 -class => "input_marceditor",
520 # it's a thesaurus / authority field
522 elsif ( $tagslib->{$tag}->{$subfield}->{authtypecode} ) {
523 $subfield_data{marc_value} = "<input type=\"text\" $attributes />
524 <a href=\"#\" class=\"buttonDot\"
525 onclick=\"Dopop('/cgi-bin/koha/authorities/auth_finder.pl?authtypecode=".$tagslib->{$tag}->{$subfield}->{authtypecode}."&index=$subfield_data{id}','$subfield_data{id}'); return false;\" title=\"Tag Editor\">...</a>
527 # it's a plugin field
529 elsif ( $tagslib->{$tag}->{$subfield}->{value_builder} ) {
530 # opening plugin
531 my $plugin = C4::Context->intranetdir . "/cataloguing/value_builder/" . $tagslib->{$tag}->{$subfield}->{'value_builder'};
532 if (do $plugin) {
533 my $extended_param = plugin_parameters( $dbh, $temp, $tagslib, $subfield_data{id}, \@loop_data );
534 my ( $function_name, $javascript ) = plugin_javascript( $dbh, $temp, $tagslib, $subfield_data{id}, \@loop_data );
535 my $change = index($javascript, 'function Change') > -1 ?
536 "return Change$function_name($subfield_data{random}, '$subfield_data{id}');" :
537 'return 1;';
538 $subfield_data{marc_value} = qq[<input $attributes
539 onfocus="Focus$function_name($subfield_data{random}, '$subfield_data{id}');"
540 onchange=" $change"
541 onblur=" Blur$function_name($subfield_data{random}, '$subfield_data{id}');" />
542 <a href="#" class="buttonDot" onclick="Clic$function_name('$subfield_data{id}'); return false;" title="Tag Editor">...</a>
543 $javascript];
544 } else {
545 warn "Plugin Failed: $plugin";
546 $subfield_data{marc_value} = "<input $attributes />"; # supply default input form
549 elsif ( $tag eq '' ) { # it's an hidden field
550 $subfield_data{marc_value} = qq(<input type="hidden" $attributes />);
552 elsif ( $tagslib->{$tag}->{$subfield}->{'hidden'} ) { # FIXME: shouldn't input type be "hidden" ?
553 $subfield_data{marc_value} = qq(<input type="text" $attributes />);
555 elsif ( length($value) > 100
556 or (C4::Context->preference("marcflavour") eq "UNIMARC" and
557 300 <= $tag && $tag < 400 && $subfield eq 'a' )
558 or (C4::Context->preference("marcflavour") eq "MARC21" and
559 500 <= $tag && $tag < 600 )
561 # oversize field (textarea)
562 $subfield_data{marc_value} = "<textarea $attributes_no_value>$value</textarea>\n";
563 } else {
564 # it's a standard field
565 $subfield_data{marc_value} = "<input $attributes />";
567 # $subfield_data{marc_value}="<input type=\"text\" name=\"field_value\">";
568 push (@loop_data, \%subfield_data);
569 $i++
573 # what's the next op ? it's what we are not in : an add if we're editing, otherwise, and edit.
574 $template->param( title => $record->title() ) if ($record ne "-1");
575 $template->param(
576 biblionumber => $biblionumber,
577 title => $oldrecord->{title},
578 author => $oldrecord->{author},
579 item_loop => \@item_value_loop,
580 item_header_loop => \@header_value_loop,
581 item => \@loop_data,
582 itemnumber => $itemnumber,
583 itemtagfield => $itemtagfield,
584 itemtagsubfield => $itemtagsubfield,
585 op => $nextop,
586 opisadd => ($nextop eq "saveitem") ? 0 : 1,
587 C4::Search::enabled_staff_search_views,
589 foreach my $error (@errors) {
590 $template->param($error => 1);
592 output_html_with_http_headers $input, $cookie, $template->output;