5 # Copyright 2000-2002 Katipo Communications
7 # This file is part of Koha.
9 # Koha is free software; you can redistribute it and/or modify it under the
10 # terms of the GNU General Public License as published by the Free Software
11 # Foundation; either version 2 of the License, or (at your option) any later
14 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License along with
19 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
20 # Suite 330, Boston, MA 02111-1307 USA
31 use C4::Koha; # XXX subfield_is_koha_internal_p
32 use Date::Calc qw(Today);
34 use MARC::File::USMARC;
36 if (C4::Context->preference('marcflavour') eq 'UNIMARC') {
37 MARC::File::XML->default_record_format( 'UNIMARC' );
40 use vars qw( $tagslib);
41 use vars qw( $authorised_values_sth);
42 use vars qw( $is_a_modif );
44 my $itemtype; # created here because it can be used in build_authorized_values_list sub
48 ($indicators, $value) = find_value($tag, $subfield, $record,$encoding);
50 Find the given $subfield in the given $tag in the given
51 MARC::Record $record. If the subfield is found, returns
52 the (indicators, value) pair; otherwise, (undef, undef) is
58 my ($tagfield,$insubfield,$record,$encoding) = @_;
62 if ($record->field($tagfield)) {
63 push @result, $record->field($tagfield)->data();
68 foreach my $field ($record->field($tagfield)) {
69 my @subfields = $field->subfields();
70 foreach my $subfield (@subfields) {
71 if (@$subfield[0] eq $insubfield) {
72 push @result,@$subfield[1];
73 $indicator = $field->indicator(1).$field->indicator(2);
78 return($indicator,@result);
82 =item MARCfindbreeding
84 $record = MARCfindbreeding($dbh, $breedingid);
86 Look up the breeding farm with database handle $dbh, for the
87 record with id $breedingid. If found, returns the decoded
88 MARC::Record; otherwise, -1 is returned (FIXME).
89 Returns as second parameter the character encoding.
93 sub MARCfindbreeding {
95 my $sth = $dbh->prepare("select file,marc,encoding from marc_breeding where id=?");
97 my ($file,$marc,$encoding) = $sth->fetchrow;
99 my $record = MARC::Record->new_from_usmarc($marc);
100 if ($record->field('010')){
101 foreach my $field ($record->field('010'))
103 foreach my $subfield ($field->subfield('a')){
104 my $newisbn = $field->subfield('a');
106 $field->update( 'a' => $newisbn );
108 # $record->insert_fields_ordered($record->field('010'));
111 if ($record->subfield(100,'a')) {
112 my $f100a=$record->subfield(100,'a');
113 my $f100 = $record->field(100);
114 my $f100temp = $f100->as_string;
115 $record->delete_field($f100);
116 if (length($f100temp)>28) {
117 substr($f100temp,26,2,"50");
118 $f100->update('a' => $f100temp);
119 my $f100 = MARC::Field->new('100','','','a' => $f100temp);
120 $record->insert_fields_ordered($f100);
123 if (ref($record) eq undef) {
126 if (C4::Context->preference("z3950NormalizeAuthor") and C4::Context->preference("z3950AuthorAuthFields")){
127 my ($tag,$subfield) = GetMarcFromKohaField("biblio.author");
128 # my $summary = C4::Context->preference("z3950authortemplate");
129 my $auth_fields = C4::Context->preference("z3950AuthorAuthFields");
130 my @auth_fields= split /,/,$auth_fields;
132 #warn $record->as_formatted;
133 if ($record->field($tag)){
134 foreach my $tmpfield ($record->field($tag)->subfields){
135 # foreach my $subfieldcode ($tmpfield->subfields){
136 my $subfieldcode=shift @$tmpfield;
137 my $subfieldvalue=shift @$tmpfield;
139 $field->add_subfields("$subfieldcode"=>$subfieldvalue) if ($subfieldcode ne $subfield);
141 $field=MARC::Field->new($tag,"","",$subfieldcode=>$subfieldvalue) if ($subfieldcode ne $subfield);
144 # warn $field->as_formatted;
147 $record->delete_field($record->field($tag));
148 foreach my $fieldtag (@auth_fields){
149 next unless ($record->field($fieldtag));
150 my $lastname = $record->field($fieldtag)->subfield('a');
151 my $firstname= $record->field($fieldtag)->subfield('b');
152 my $title = $record->field($fieldtag)->subfield('c');
153 my $number= $record->field($fieldtag)->subfield('d');
155 # $field->add_subfields("$subfield"=>"[ ".ucfirst($title).ucfirst($firstname)." ".$number." ]");
156 $field->add_subfields("$subfield"=>ucfirst($title)." ".ucfirst($firstname)." ".$number);
158 # $field->add_subfields("$subfield"=>"[ ".ucfirst($firstname).", ".ucfirst($lastname)." ]");
159 $field->add_subfields("$subfield"=>ucfirst($firstname).", ".ucfirst($lastname));
162 $record->insert_fields_ordered($field);
164 return $record,$encoding;
171 =item build_authorized_values_list
175 sub build_authorized_values_list ($$$$$) {
176 my($tag, $subfield, $value, $dbh,$authorised_values_sth) = @_;
178 my @authorised_values;
181 # builds list, depending on authorised value...
184 if ($tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
185 my $sth=$dbh->prepare("select branchcode,branchname from branches order by branchname");
187 push @authorised_values, ""
188 unless ($tagslib->{$tag}->{$subfield}->{mandatory});
190 while (my ($branchcode,$branchname) = $sth->fetchrow_array) {
191 push @authorised_values, $branchcode;
192 $authorised_lib{$branchcode}=$branchname;
196 } elsif ($tagslib->{$tag}->{$subfield}->{authorised_value} eq "itemtypes") {
197 my $sth=$dbh->prepare("select itemtype,description from itemtypes order by description");
199 push @authorised_values, "" unless ($tagslib->{$tag}->{$subfield}->{mandatory});
201 while (my ($itemtype,$description) = $sth->fetchrow_array) {
202 push @authorised_values, $itemtype;
203 $authorised_lib{$itemtype}=$description;
205 $value=$itemtype unless ($value);
207 #---- "true" authorised value
209 $authorised_values_sth->execute($tagslib->{$tag}->{$subfield}->{authorised_value});
211 push @authorised_values, "" unless ($tagslib->{$tag}->{$subfield}->{mandatory});
213 while (my ($value,$lib) = $authorised_values_sth->fetchrow_array) {
214 push @authorised_values, $value;
215 $authorised_lib{$value}=$lib;
218 return CGI::scrolling_list( -name => 'field_value',
219 -values => \@authorised_values,
221 -labels => \%authorised_lib,
229 builds the <input ...> entry for a subfield.
233 sub create_input () {
234 my ($tag,$subfield,$value,$i,$tabloop,$rec,$authorised_values_sth) = @_;
235 # must be encoded as utf-8 before it reaches the editor
237 #$value = encode('utf-8', $value);
238 $value =~ s/"/"/g;
239 # if there is no value provided but a default value in parameters, get it
241 $value = $tagslib->{$tag}->{$subfield}->{defaultvalue};
242 # get today date & replace YYYY, MM, DD if provided in the default value
243 my ($year,$month,$day) = Today();
244 $month = sprintf("%02d",$month);
245 $day = sprintf("%02d",$day);
246 $value =~ s/YYYY/$year/g;
247 $value =~ s/MM/$month/g;
248 $value =~ s/DD/$day/g;
251 my $dbh = C4::Context->dbh;
253 $subfield_data{tag}=$tag;
254 $subfield_data{subfield}=$subfield;
255 $subfield_data{marc_lib}="<span id=\"error$i\" title=\"".$tagslib->{$tag}->{$subfield}->{lib}."\">".substr($tagslib->{$tag}->{$subfield}->{lib},0,15)."</span>";
256 $subfield_data{marc_lib_plain}=$tagslib->{$tag}->{$subfield}->{lib};
257 $subfield_data{tag_mandatory}=$tagslib->{$tag}->{mandatory};
258 $subfield_data{mandatory}=$tagslib->{$tag}->{$subfield}->{mandatory};
259 $subfield_data{repeatable}=$tagslib->{$tag}->{$subfield}->{repeatable};
260 $subfield_data{kohafield}=$tagslib->{$tag}->{$subfield}->{kohafield};
261 $subfield_data{index} = $i;
262 $subfield_data{visibility} = "display:none" unless (($tagslib->{$tag}->{$subfield}->{hidden}%2==0) or $value ne ''); #check parity
263 # it's an authorised field
264 if ($tagslib->{$tag}->{$subfield}->{authorised_value}) {
265 $subfield_data{marc_value}= build_authorized_values_list($tag, $subfield, $value, $dbh,$authorised_values_sth);
266 # it's a thesaurus / authority field
267 } elsif ($tagslib->{$tag}->{$subfield}->{authtypecode}) {
268 $subfield_data{marc_value}="<input type=\"text\" onblur=\"this.style.backgroundColor='#ffffff';\" onfocus=\"this.style.backgroundColor='#ffff00;'\"\" tabindex=\"1\" type=\"text\" name=\"field_value\" value=\"$value\" size=\"70\" maxlength=\"255\" DISABLE READONLY> <a style=\"cursor: help;\" href=\"javascript:Dopop('../authorities/auth_finder.pl?authtypecode=".$tagslib->{$tag}->{$subfield}->{authtypecode}."&index=$i',$i)\">...</a>";
269 # it's a plugin field
270 } elsif ($tagslib->{$tag}->{$subfield}->{'value_builder'}) {
271 # opening plugin. Just check wether we are on a developper computer on a production one
272 # (the cgidir differs)
273 my $cgidir = C4::Context->intranetdir ."/cgi-bin/cataloguing/value_builder";
274 unless (opendir(DIR, "$cgidir")) {
275 $cgidir = C4::Context->intranetdir."/cataloguing/value_builder";
277 my $plugin=$cgidir."/".$tagslib->{$tag}->{$subfield}->{'value_builder'};
279 my $extended_param = plugin_parameters($dbh,$rec,$tagslib,$i,$tabloop);
280 my ($function_name,$javascript) = plugin_javascript($dbh,$rec,$tagslib,$i,$tabloop);
281 $subfield_data{marc_value}="<input tabindex=\"1\" type=\"text\" name=\"field_value\" value=\"$value\" size=\"70\" maxlength=\"255\" OnFocus=\"javascript:Focus$function_name($i)\" OnBlur=\"javascript:Blur$function_name($i); \"> <a style=\"cursor: help;\" href=\"javascript:Clic$function_name($i)\">...</a> $javascript";
282 # it's an hidden field
283 } elsif ($tag eq '') {
284 $subfield_data{marc_value}="<input onblur=\"this.style.backgroundColor='#ffffff';\" onfocus=\"this.style.backgroundColor='#ffff00'; \" tabindex=\"1\" type=\"hidden\" name=\"field_value\" value=\"$value\">";
285 } elsif ($tagslib->{$tag}->{$subfield}->{'hidden'}) {
286 $subfield_data{marc_value}="<input onblur=\"this.style.backgroundColor='#ffffff';\" onfocus=\"this.style.backgroundColor='#ffff00'; \" tabindex=\"1\" type=\"text\" name=\"field_value\" value=\"$value\" size=\"70\" maxlength=\"255\" >";
287 # it's a standard field
289 if (length($value) >100 or (C4::Context->preference("marcflavour") eq "UNIMARC" && $tag >=300 and $tag <400 && $subfield eq 'a') or ($tag >=500 and $tag <600 && C4::Context->preference("marcflavour") eq "MARC21")) {
290 $subfield_data{marc_value}="<textarea tabindex=\"1\" name=\"field_value\" cols=\"70\" rows=\"5\" >$value</textarea>";
292 $subfield_data{marc_value}="<input onblur=\"this.style.backgroundColor='#ffffff';\" onfocus=\"this.style.backgroundColor='#ffff00'; \" tabindex=\"1\" type=\"text\" name=\"field_value\" value=\"$value\" size=\"70\">"; #"
295 return \%subfield_data;
298 sub build_tabs ($$$$) {
299 my($template, $record, $dbh,$encoding) = @_;
304 my $authorised_values_sth = $dbh->prepare("select authorised_value,lib
305 from authorised_values
306 where category=? order by lib");
308 # in this array, we will push all the 10 tabs
309 # to avoid having 10 tabs in the template : they will all be in the same BIG_LOOP
312 # loop through each tab 0 through 9
313 for (my $tabloop = 0; $tabloop <= 9; $tabloop++) {
315 foreach my $tag (sort(keys (%{$tagslib}))) {
317 # if MARC::Record is not empty => use it as master loop, then add missing subfields that should be in the tab.
318 # if MARC::Record is empty => use tab as master loop.
319 if ($record ne -1 && ($record->field($tag) || $tag eq '000')) {
322 @fields = $record->field($tag);
324 push @fields,$record->leader();
326 foreach my $field (@fields) {
329 my ($value,$subfield);
331 $value=$field->data();
337 next if ($tagslib->{$tag}->{$subfield}->{tab} ne $tabloop);
338 next if ($tagslib->{$tag}->{$subfield}->{kohafield} eq 'biblio.biblionumber');
339 push(@subfields_data, &create_input($tag,$subfield,$value,$i,$tabloop,$record,$authorised_values_sth));
342 my @subfields=$field->subfields();
343 foreach my $subfieldcount (0..$#subfields) {
344 my $subfield=$subfields[$subfieldcount][0];
345 my $value=$subfields[$subfieldcount][1];
346 next if (length $subfield !=1);
347 next if ($tagslib->{$tag}->{$subfield}->{tab} ne $tabloop);
348 push(@subfields_data, &create_input($tag,$subfield,$value,$i,$tabloop,$record,$authorised_values_sth));
352 # now, loop again to add parameter subfield that are not in the MARC::Record
353 foreach my $subfield (sort( keys %{$tagslib->{$tag}})) {
354 next if (length $subfield !=1);
355 next if ($tagslib->{$tag}->{$subfield}->{tab} ne $tabloop);
357 next if (($tagslib->{$tag}->{$subfield}->{hidden}<=-4) or ($tagslib->{$tag}->{$subfield}->{hidden}>=5) ); #check for visibility flag
358 next if (defined($field->subfield($subfield)));
359 push(@subfields_data, &create_input($tag,$subfield,'',$i,$tabloop,$record,$authorised_values_sth));
362 if ($#subfields_data >= 0) {
364 $tag_data{tag} = $tag;
365 $tag_data{tag_lib} = $tagslib->{$tag}->{lib};
366 $tag_data{repeatable} = $tagslib->{$tag}->{repeatable};
367 $tag_data{indicator} = $record->field($tag)->indicator(1). $record->field($tag)->indicator(2) if ($tag>=10);
368 $tag_data{subfield_loop} = \@subfields_data;
370 $tag_data{fixedfield} = 1;
373 push (@loop_data, \%tag_data);
375 # If there is more than 1 field, add an empty hidden field as separator.
376 if ($#fields >=1 && $#loop_data >=0 && $loop_data[$#loop_data]->{'tag'} eq $tag) {
379 push(@subfields_data, &create_input('','','',$i,$tabloop,$record,$authorised_values_sth));
381 $tag_data{tag_lib} = '';
382 $tag_data{indicator} = '';
383 $tag_data{subfield_loop} = \@subfields_data;
385 $tag_data{fixedfield} = 1;
387 push (@loop_data, \%tag_data);
391 # if breeding is empty
394 foreach my $subfield (sort(keys %{$tagslib->{$tag}})) {
395 next if (length $subfield !=1);
396 next if (($tagslib->{$tag}->{$subfield}->{hidden}<=-5) or ($tagslib->{$tag}->{$subfield}->{hidden}>=4) ); #check for visibility flag
397 next if ($tagslib->{$tag}->{$subfield}->{tab} ne $tabloop);
398 push(@subfields_data, &create_input($tag,$subfield,'',$i,$tabloop,$record,$authorised_values_sth));
401 if ($#subfields_data >= 0) {
403 $tag_data{tag} = $tag;
404 $tag_data{tag_lib} = $tagslib->{$tag}->{lib};
405 $tag_data{repeatable} = $tagslib->{$tag}->{repeatable};
406 $tag_data{indicator} = $indicator;
407 $tag_data{subfield_loop} = \@subfields_data;
408 $tag_data{tagfirstsubfield} = $tag_data{subfield_loop}[0];
410 $tag_data{fixedfield} = 1;
412 push (@loop_data, \%tag_data);
416 if ($#loop_data >=0) {
418 $big_loop_line{number}=$tabloop;
419 $big_loop_line{innerloop}=\@loop_data;
420 push @BIG_LOOP,\%big_loop_line;
422 # $template->param($tabloop."XX" =>\@loop_data);
424 $template->param(BIG_LOOP => \@BIG_LOOP);
429 sub build_hidden_data () {
430 # build hidden data =>
431 # we store everything, even if we show only requested subfields.
435 foreach my $tag (keys %{$tagslib}) {
436 my $previous_tag = '';
438 # loop through each subfield
439 foreach my $subfield (keys %{$tagslib->{$tag}}) {
440 next if ($subfield eq 'lib');
441 next if ($subfield eq 'tab');
442 next if ($subfield eq 'mandatory');
443 next if ($subfield eq 'repeatable');
444 next if ($tagslib->{$tag}->{$subfield}->{'tab'} ne "-1");
446 $subfield_data{marc_lib}=$tagslib->{$tag}->{$subfield}->{lib};
447 $subfield_data{marc_mandatory}=$tagslib->{$tag}->{$subfield}->{mandatory};
448 $subfield_data{marc_repeatable}=$tagslib->{$tag}->{$subfield}->{repeatable};
449 $subfield_data{marc_value}="<input type=\"hidden\" name=\"field_value[]\">";
450 push(@loop_data, \%subfield_data);
457 # ========================
459 #=========================
461 my $error = $input->param('error');
462 my $biblionumber=$input->param('biblionumber'); # if biblionumber exists, it's a modif, not a new biblio.
463 my $breedingid = $input->param('breedingid');
464 my $z3950 = $input->param('z3950');
465 my $op = $input->param('op');
466 my $frameworkcode = $input->param('frameworkcode');
467 my $dbh = C4::Context->dbh;
469 $frameworkcode = &GetFrameworkCode($biblionumber) if ($biblionumber and not ($frameworkcode));
471 $frameworkcode='' if ($frameworkcode eq 'Default');
472 my ($template, $loggedinuser, $cookie)
473 = get_template_and_user({template_name => "cataloguing/addbiblio.tmpl",
476 authnotrequired => 0,
477 flagsrequired => {editcatalogue => 1},
481 #Getting the list of all frameworks
482 my $queryfwk =$dbh->prepare("select frameworktext, frameworkcode from biblio_framework");
487 push @select_fwk,"Default";
488 $select_fwk{"Default"} = "Default";
489 while (my ($description, $fwk) =$queryfwk->fetchrow) {
490 push @select_fwk, $fwk;
491 $select_fwk{$fwk} = $description;
493 $curfwk=$frameworkcode;
494 my $framework=CGI::scrolling_list(
495 -name => 'Frameworks',
498 -OnChange => 'Changefwk(this);',
499 -values => \@select_fwk,
500 -labels => \%select_fwk,
503 $template->param( framework => $framework, breedingid => $breedingid);
505 $tagslib = &GetMarcStructure(1,$frameworkcode);
508 $record = GetMarcBiblio( $biblionumber ) if ($biblionumber);
509 ($record,$encoding) = MARCfindbreeding($dbh,$breedingid) if ($breedingid);
511 # warn "biblionumber : $biblionumber = ".$record->as_formatted;
513 my ($biblionumtagfield,$biblionumtagsubfield);
514 my ($biblioitemnumtagfield,$biblioitemnumtagsubfield,$bibitem,$biblioitemnumber);
517 # if it's a modif, retrieve bibli and biblioitem numbers for the future modification of old-DB.
518 ($biblionumtagfield,$biblionumtagsubfield) = &GetMarcFromKohaField("biblio.biblionumber",$frameworkcode);
519 ($biblioitemnumtagfield,$biblioitemnumtagsubfield) = &GetMarcFromKohaField("biblioitems.biblioitemnumber",$frameworkcode);
520 # search biblioitems value
521 my $sth=$dbh->prepare("select biblioitemnumber from biblioitems where biblionumber=?");
522 $sth->execute($biblionumber);
523 ($biblioitemnumber) = $sth->fetchrow;
525 #-------------------------------------------------------------------------------------
526 if ($op eq "addbiblio") {
527 #-------------------------------------------------------------------------------------
529 my @tags = $input->param('tag');
530 my @subfields = $input->param('subfield');
531 my @values = $input->param('field_value');
532 # build indicator hash.
533 my @ind_tag = $input->param('ind_tag');
534 my @indicator = $input->param('indicator');
535 if (C4::Context->preference('TemplateEncoding') eq "iso-8859-1") {
536 $record = TransformHtmlToMarc($dbh,\@tags,\@subfields,\@values,\@indicator,\@ind_tag);
538 my $xml = TransformHtmlToXml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag);
539 $record=MARC::Record->new_from_xml($xml,C4::Context->preference('TemplateEncoding'),C4::Context->preference('marcflavour'));
540 # warn "MARC :".$record->as_formatted;
543 # check for a duplicate
544 my ($duplicatebiblionumber,$duplicatebiblionumber,$duplicatetitle) = FindDuplicate($record) if ($op eq "addbiblio") && (!$is_a_modif);
545 my $confirm_not_duplicate = $input->param('confirm_not_duplicate');
546 # it is not a duplicate (determined either by Koha itself or by user checking it's not a duplicate)
547 if (!$duplicatebiblionumber or $confirm_not_duplicate) {
548 # MARC::Record built => now, record in DB
552 ModBiblioframework($biblionumber,$frameworkcode);
553 ModBiblio($record,$biblionumber,$frameworkcode);
556 ($biblionumber,$oldbibitemnum) = AddBiblio($record,$frameworkcode);
558 # now, redirect to additem page
559 print $input->redirect("/cgi-bin/koha/cataloguing/additem.pl?biblionumber=$biblionumber&frameworkcode=$frameworkcode");
562 # it may be a duplicate, warn the user and do nothing
563 build_tabs ($template, $record, $dbh,$encoding);
566 biblionumber => $biblionumber,
567 biblionumtagfield => $biblionumtagfield,
568 biblionumtagsubfield => $biblionumtagsubfield,
569 biblioitemnumtagfield => $biblioitemnumtagfield,
570 biblioitemnumtagsubfield => $biblioitemnumtagsubfield,
571 biblioitemnumber => $biblioitemnumber,
572 duplicatebiblionumber => $duplicatebiblionumber,
573 duplicatebibid => $duplicatebiblionumber,
574 duplicatetitle => $duplicatetitle,
577 #--------------------------------------------------------------------------
578 } elsif ($op eq "addfield") {
579 #--------------------------------------------------------------------------
580 my $addedfield = $input->param('addfield_field');
581 my $cntrepeatfield=$input->param('repeat_field');
582 $cntrepeatfield=1 unless ($cntrepeatfield);
583 my $tagaddfield_subfield = $input->param('addfield_subfield');
584 my @tags = $input->param('tag');
585 my @subfields = $input->param('subfield');
586 my @values = $input->param('field_value');
587 # build indicator hash.
588 my @ind_tag = $input->param('ind_tag');
589 my @indicator = $input->param('indicator');
590 my $xml = TransformHtmlToXml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag);
592 if (C4::Context->preference('TemplateEncoding') eq "iso-8859-1") {
594 for (my $i=0;$i<=$#ind_tag;$i++) {
595 $indicators{$ind_tag[$i]} = $indicator[$i];
597 $record = TransformHtmlToMarc($dbh,\@tags,\@subfields,\@values,%indicators);
599 my $xml = TransformHtmlToXml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag);
600 $record=MARC::Record->new_from_xml($xml,C4::Context->preference('TemplateEncoding'),C4::Context->preference('marcflavour'));
602 for (my $i=1;$i<=$cntrepeatfield;$i++){
603 my $field = MARC::Field->new("$addedfield",'','',"$tagaddfield_subfield" => "");
604 $record->append_fields($field);
606 #warn "result : ".$record->as_formatted;
607 build_tabs ($template, $record, $dbh,$encoding);
610 biblionumber => $biblionumber,
611 biblionumtagfield => $biblionumtagfield,
612 biblionumtagsubfield => $biblionumtagsubfield,
613 biblioitemnumtagfield => $biblioitemnumtagfield,
614 biblioitemnumtagsubfield => $biblioitemnumtagsubfield,
615 biblioitemnumber => $biblioitemnumber );
616 } elsif ($op eq "delete") {
617 #-----------------------------------------------------------------------------
618 my $error = &DelBiblio($biblionumber);
620 warn "ERROR when DELETING BIBLIO $biblionumber : $error";
621 print "Content-Type: text/html\n\n<html><body><h1>ERROR when DELETING BIBLIO $biblionumber : $error</h1></body></html>";
623 print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=/cgi-bin/koha/catalogue/search.pl?type=intranet\"></html>";
626 #----------------------------------------------------------------------------
628 #----------------------------------------------------------------------------
629 # If we're in a duplication case, we have to set to "" the biblionumber
630 # as we'll save the biblio as a new one.
631 if ($op eq "duplicate")
635 #FIXME: it's kind of silly to go from MARC::Record to MARC::File::XML and then back again just to fix the encoding
637 my $uxml = $record->as_xml;
638 MARC::Record::default_record_format("UNIMARC") if (C4::Context->preference("marcflavour") eq "UNIMARC");
639 my $urecord = MARC::Record::new_from_xml($uxml, 'UTF-8');
642 build_tabs ($template, $record, $dbh,$encoding);
645 biblionumber => $biblionumber,
646 biblionumtagfield => $biblionumtagfield,
647 biblionumtagsubfield => $biblionumtagsubfield,
648 biblioitemnumtagfield => $biblioitemnumtagfield,
649 biblioitemnumtagsubfield => $biblioitemnumtagsubfield,
650 biblioitemnumber => $biblioitemnumber,
653 $template->param( title => $record->title() ) if ($record ne "-1");
655 frameworkcode => $frameworkcode,
656 itemtype => $frameworkcode, # HINT: if the library has itemtype = framework, itemtype is auto filled !
657 hide_marc => C4::Context->preference('hide_marc'),
658 intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
659 intranetstylesheet => C4::Context->preference("intranetstylesheet"),
660 IntranetNav => C4::Context->preference("IntranetNav"),
661 advancedMARCEditor => C4::Context->preference("advancedMARCEditor"),
663 output_html_with_http_headers $input, $cookie, $template->output;