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
28 use C4::AuthoritiesMarc;
32 use C4::Koha; # XXX subfield_is_koha_internal_p
33 use Date::Calc qw(Today);
34 use MARC::File::USMARC;
37 if ( C4::Context->preference('marcflavour') eq 'UNIMARC' ) {
38 MARC::File::XML->default_record_format('UNIMARC');
41 our($tagslib,$authorised_values_sth,$is_a_modif,$usedTagsLib,$mandatory_z3950);
43 =item MARCfindbreeding
45 $record = MARCfindbreeding($dbh, $breedingid);
47 Look up the breeding farm with database handle $dbh, for the
48 record with id $breedingid. If found, returns the decoded
49 MARC::Record; otherwise, -1 is returned (FIXME).
50 Returns as second parameter the character encoding.
54 sub MARCfindbreeding {
55 my ( $dbh, $id ) = @_;
57 $dbh->prepare("select file,marc,encoding from marc_breeding where id=?");
59 my ( $file, $marc, $encoding ) = $sth->fetchrow;
61 my $record = MARC::Record->new_from_usmarc($marc);
62 if ( $record->field('010') ) {
63 foreach my $field ( $record->field('010') ) {
64 foreach my $subfield ( $field->subfield('a') ) {
65 my $newisbn = $field->subfield('a');
67 $field->update( 'a' => $newisbn );
69 # record->insert_fields_ordered($record->field('010'));
73 if ($record->subfield(100,'a')) {
74 my $f100a=$record->subfield(100,'a');
75 my $f100 = $record->field(100);
76 my $f100temp = $f100->as_string;
77 $record->delete_field($f100);
78 if ( length($f100temp) > 28 ) {
79 substr( $f100temp, 26, 2, "50" );
80 $f100->update( 'a' => $f100temp );
81 my $f100 = MARC::Field->new( '100', '', '', 'a' => $f100temp );
82 $record->insert_fields_ordered($f100);
86 if ( ref($record) eq undef ) {
90 if ( C4::Context->preference("z3950NormalizeAuthor")
91 and C4::Context->preference("z3950AuthorAuthFields") )
93 my ( $tag, $subfield ) = GetMarcFromKohaField("biblio.author");
95 # my $summary = C4::Context->preference("z3950authortemplate");
97 C4::Context->preference("z3950AuthorAuthFields");
98 my @auth_fields = split /,/, $auth_fields;
101 if ( $record->field($tag) ) {
102 foreach my $tmpfield ( $record->field($tag)->subfields ) {
104 # foreach my $subfieldcode ($tmpfield->subfields){
105 my $subfieldcode = shift @$tmpfield;
106 my $subfieldvalue = shift @$tmpfield;
108 $field->add_subfields(
109 "$subfieldcode" => $subfieldvalue )
110 if ( $subfieldcode ne $subfield );
114 MARC::Field->new( $tag, "", "",
115 $subfieldcode => $subfieldvalue )
116 if ( $subfieldcode ne $subfield );
120 $record->delete_field( $record->field($tag) );
121 foreach my $fieldtag (@auth_fields) {
122 next unless ( $record->field($fieldtag) );
123 my $lastname = $record->field($fieldtag)->subfield('a');
124 my $firstname = $record->field($fieldtag)->subfield('b');
125 my $title = $record->field($fieldtag)->subfield('c');
126 my $number = $record->field($fieldtag)->subfield('d');
129 # $field->add_subfields("$subfield"=>"[ ".ucfirst($title).ucfirst($firstname)." ".$number." ]");
130 $field->add_subfields(
131 "$subfield" => ucfirst($title) . " "
132 . ucfirst($firstname) . " "
137 # $field->add_subfields("$subfield"=>"[ ".ucfirst($firstname).", ".ucfirst($lastname)." ]");
138 $field->add_subfields(
139 "$subfield" => ucfirst($firstname) . ", "
140 . ucfirst($lastname) );
143 $record->insert_fields_ordered($field);
145 return $record, $encoding;
151 =item build_authorized_values_list
155 sub build_authorized_values_list ($$$$$$$) {
156 my ( $tag, $subfield, $value, $dbh, $authorised_values_sth,$index_tag,$index_subfield ) = @_;
158 my @authorised_values;
161 # builds list, depending on authorised value...
164 if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
167 "select branchcode,branchname from branches order by branchname");
169 push @authorised_values, ""
170 unless ( $tagslib->{$tag}->{$subfield}->{mandatory} );
172 while ( my ( $branchcode, $branchname ) = $sth->fetchrow_array ) {
173 push @authorised_values, $branchcode;
174 $authorised_lib{$branchcode} = $branchname;
179 elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "itemtypes" ) {
182 "select itemtype,description from itemtypes order by description");
184 push @authorised_values, ""
185 unless ( $tagslib->{$tag}->{$subfield}->{mandatory} );
189 while ( my ( $itemtype, $description ) = $sth->fetchrow_array ) {
190 push @authorised_values, $itemtype;
191 $authorised_lib{$itemtype} = $description;
193 $value = $itemtype unless ($value);
195 #---- "true" authorised value
198 $authorised_values_sth->execute(
199 $tagslib->{$tag}->{$subfield}->{authorised_value} );
201 push @authorised_values, ""
202 unless ( $tagslib->{$tag}->{$subfield}->{mandatory} );
204 while ( my ( $value, $lib ) = $authorised_values_sth->fetchrow_array ) {
205 push @authorised_values, $value;
206 $authorised_lib{$value} = $lib;
209 return CGI::scrolling_list(
210 -name => "tag_".$tag."_subfield_".$subfield."_".$index_tag."_".$index_subfield,
211 -values => \@authorised_values,
213 -labels => \%authorised_lib,
218 -id => "tag_".$tag."_subfield_".$subfield."_".$index_tag."_".$index_subfield,
219 -class => "input_marceditor",
225 Create a random value to set it into the input name
230 return int(rand(1000000));
233 =item GetMandatoryFieldZ3950
235 This function return an hashref which containts all mandatory field
236 to search with z3950 server.
240 sub GetMandatoryFieldZ3950($){
241 my $frameworkcode = shift;
242 my @isbn = GetMarcFromKohaField('biblioitems.isbn',$frameworkcode);
243 my @title = GetMarcFromKohaField('biblio.title',$frameworkcode);
244 my @author = GetMarcFromKohaField('biblio.author',$frameworkcode);
245 my @issn = GetMarcFromKohaField('biblioitems.issn',$frameworkcode);
248 $isbn[0].$isbn[1] => 'isbn',
249 $title[0].$title[1] => 'title',
250 $author[0].$author[1] => 'author',
251 $issn[0].$issn[1] => 'issn',
257 builds the <input ...> entry for a subfield.
262 my ( $tag, $subfield, $value, $index_tag, $tabloop, $rec, $authorised_values_sth,$cgi ) = @_;
264 my $index_subfield = CreateKey(); # create a specifique key for each subfield
266 $value =~ s/"/"/g;
268 # if there is no value provided but a default value in parameters, get it
270 $value = $tagslib->{$tag}->{$subfield}->{defaultvalue};
272 # get today date & replace YYYY, MM, DD if provided in the default value
273 my ( $year, $month, $day ) = Today();
274 $month = sprintf( "%02d", $month );
275 $day = sprintf( "%02d", $day );
276 $value =~ s/YYYY/$year/g;
277 $value =~ s/MM/$month/g;
278 $value =~ s/DD/$day/g;
280 my $dbh = C4::Context->dbh;
281 my %subfield_data = (
283 subfield => $subfield,
284 marc_lib => substr( $tagslib->{$tag}->{$subfield}->{lib}, 0, 22 ),
285 marc_lib_plain => $tagslib->{$tag}->{$subfield}->{lib},
286 tag_mandatory => $tagslib->{$tag}->{mandatory},
287 mandatory => $tagslib->{$tag}->{$subfield}->{mandatory},
288 repeatable => $tagslib->{$tag}->{$subfield}->{repeatable},
289 kohafield => $tagslib->{$tag}->{$subfield}->{kohafield},
291 id => "tag_".$tag."_subfield_".$subfield."_".$index_tag."_".$index_subfield,
294 if($subfield eq '@'){
295 $subfield_data{id} = "tag_".$tag."_subfield_00_".$index_tag."_".$index_subfield;
297 $subfield_data{id} = "tag_".$tag."_subfield_".$subfield."_".$index_tag."_".$index_subfield;
300 if(exists $mandatory_z3950->{$tag.$subfield}){
301 $subfield_data{z3950_mandatory} = $mandatory_z3950->{$tag.$subfield};
304 $subfield_data{visibility} = "display:none;"
305 if ( ($tagslib->{$tag}->{$subfield}->{hidden} % 2 == 1) and $value ne ''
306 or ($value eq '' and !$tagslib->{$tag}->{$subfield}->{mandatory})
309 # it's an authorised field
310 if ( $tagslib->{$tag}->{$subfield}->{authorised_value} ) {
311 $subfield_data{marc_value} =
312 build_authorized_values_list( $tag, $subfield, $value, $dbh,
313 $authorised_values_sth,$index_tag,$index_subfield );
315 # it's a thesaurus / authority field
317 elsif ( $tagslib->{$tag}->{$subfield}->{authtypecode} ) {
318 $subfield_data{marc_value} =
319 "<input type=\"text\"
320 id=\"".$subfield_data{id}."\"
321 name=\"".$subfield_data{id}."\"
323 class=\"input_marceditor\"
325 disabled=\"disabled\" readonly=\"readonly\" \/>
326 <span class=\"buttonDot\"
327 onclick=\"Dopop('/cgi-bin/koha/authorities/auth_finder.pl?authtypecode=".$tagslib->{$tag}->{$subfield}->{authtypecode}."&index=$subfield_data{id}','$subfield_data{id}')\">...</span>
329 # it's a plugin field
331 elsif ( $tagslib->{$tag}->{$subfield}->{'value_builder'} ) {
333 # opening plugin. Just check wether we are on a developper computer on a production one
334 # (the cgidir differs)
335 my $cgidir = C4::Context->intranetdir . "/cgi-bin/cataloguing/value_builder";
336 unless ( opendir( DIR, "$cgidir" ) ) {
337 $cgidir = C4::Context->intranetdir . "/cataloguing/value_builder";
339 my $plugin = $cgidir . "/" . $tagslib->{$tag}->{$subfield}->{'value_builder'};
340 do $plugin || die "Plugin Failed: ".$plugin;
341 my $extended_param = plugin_parameters( $dbh, $rec, $tagslib, $subfield_data{id}, $tabloop );
342 my ( $function_name, $javascript ) = plugin_javascript( $dbh, $rec, $tagslib, $subfield_data{id}, $tabloop );
343 # my ( $function_name, $javascript,$extended_param );
345 $subfield_data{marc_value} =
346 "<input tabindex=\"1\"
348 id=\"".$subfield_data{id}."\"
349 name=\"".$subfield_data{id}."\"
351 class=\"input_marceditor\"
352 onfocus=\"Focus$function_name($index_tag)\"
353 onblur=\"Blur$function_name($index_tag); \" \/>
354 <span class=\"buttonDot\" onclick=\"Clic$function_name('$subfield_data{id}')\">...</a>
356 # it's an hidden field
358 elsif ( $tag eq '' ) {
359 $subfield_data{marc_value} =
360 "<input tabindex=\"1\"
362 id=\"".$subfield_data{id}."\"
363 name=\"".$subfield_data{id}."\"
367 elsif ( $tagslib->{$tag}->{$subfield}->{'hidden'} ) {
368 $subfield_data{marc_value} =
369 "<input type=\"text\"
370 id=\"".$subfield_data{id}."\"
371 name=\"".$subfield_data{id}."\"
372 class=\"input_marceditor\"
377 # it's a standard field
383 ( C4::Context->preference("marcflavour") eq "UNIMARC" && $tag >= 300
384 and $tag < 400 && $subfield eq 'a' )
387 && C4::Context->preference("marcflavour") eq "MARC21" )
390 $subfield_data{marc_value} =
391 "<textarea cols=\"70\"
393 id=\"".$subfield_data{id}."\"
394 name=\"".$subfield_data{id}."\"
395 class=\"input_marceditor\"
401 $subfield_data{marc_value} =
402 "<input type=\"text\"
403 id=\"".$subfield_data{id}."\"
404 name=\"".$subfield_data{id}."\"
407 class=\"input_marceditor\"
412 $subfield_data{'index_subfield'} = $index_subfield;
413 return \%subfield_data;
416 sub build_tabs ($$$$$) {
417 my ( $template, $record, $dbh, $encoding,$input ) = @_;
423 my $authorised_values_sth = $dbh->prepare(
424 "select authorised_value,lib
425 from authorised_values
426 where category=? order by lib"
429 # in this array, we will push all the 10 tabs
430 # to avoid having 10 tabs in the template : they will all be in the same BIG_LOOP
433 my @tab_data; # all tags to display
435 foreach my $used ( @$usedTagsLib ){
436 push @tab_data,$used->{tagfield} if not $seen{$used->{tagfield}};
437 $seen{$used->{tagfield}}++;
441 foreach(@$usedTagsLib){
442 if($_->{tab} > -1 && $_->{tab} >= $max_num_tab && $_->{tagfield} != '995'){ # FIXME : MARC21 ?
443 $max_num_tab = $_->{tab};
446 if($max_num_tab >= 9){
449 # loop through each tab 0 through 9
450 for ( my $tabloop = 0 ; $tabloop <= $max_num_tab ; $tabloop++ ) {
451 my @loop_data = (); #innerloop in the template.
453 foreach my $tag (@tab_data) {
457 my $index_tag = CreateKey;
459 # if MARC::Record is not empty =>use it as master loop, then add missing subfields that should be in the tab.
460 # if MARC::Record is empty => use tab as master loop.
461 if ( $record ne -1 && ( $record->field($tag) || $tag eq '000' ) ) {
463 if ( $tag ne '000' ) {
464 @fields = $record->field($tag);
467 push @fields, $record->leader(); # if tag == 000
469 # loop through each field
470 foreach my $field (@fields) {
474 my ( $value, $subfield );
475 if ( $tag ne '000' ) {
476 $value = $field->data();
483 next if ( $tagslib->{$tag}->{$subfield}->{tab} ne $tabloop );
485 if ( $tagslib->{$tag}->{$subfield}->{kohafield} eq
486 'biblio.biblionumber' );
490 $tag, $subfield, $value, $index_tag, $tabloop, $record,
491 $authorised_values_sth,$input
496 my @subfields = $field->subfields();
497 foreach my $subfieldcount ( 0 .. $#subfields ) {
498 my $subfield = $subfields[$subfieldcount][0];
499 my $value = $subfields[$subfieldcount][1];
500 next if ( length $subfield != 1 );
501 next if ( $tagslib->{$tag}->{$subfield}->{tab} ne $tabloop );
505 $tag, $subfield, $value, $index_tag, $tabloop,
506 $record, $authorised_values_sth,$input
512 # now, loop again to add parameter subfield that are not in the MARC::Record
513 foreach my $subfield ( sort( keys %{ $tagslib->{$tag} } ) )
515 next if ( length $subfield != 1 );
516 next if ( $tagslib->{$tag}->{$subfield}->{tab} ne $tabloop );
517 next if ( $tag < 10 );
519 if ( ( $tagslib->{$tag}->{$subfield}->{hidden} <= -4 )
520 or ( $tagslib->{$tag}->{$subfield}->{hidden} >= 5 )
521 ); #check for visibility flag
522 next if ( defined( $field->subfield($subfield) ) );
526 $tag, $subfield, '', $index_tag, $tabloop, $record,
527 $authorised_values_sth,$input
531 if ( $#subfields_data >= 0 ) {
532 # build the tag entry.
533 # note that the random() field is mandatory. Otherwise, on repeated fields, you'll
534 # have twice the same "name" value, and cgi->param() will return only one, making
535 # all subfields to be merged in a single field.
539 tag_lib => $tagslib->{$tag}->{lib},
540 repeatable => $tagslib->{$tag}->{repeatable},
541 subfield_loop => \@subfields_data,
542 fixedfield => ($tag < 10)?(1):(0),
545 if ($tag >= 010){ # no indicator for theses tag
546 $tag_data{indicator} = $field->indicator(1).$field->indicator(2);
548 push( @loop_data, \%tag_data );
550 } # foreach $field end
552 # if breeding is empty
556 foreach my $subfield ( sort( keys %{ $tagslib->{$tag} } ) ) {
557 next if ( length $subfield != 1 );
559 if ( ( $tagslib->{$tag}->{$subfield}->{hidden} <= -5 )
560 or ( $tagslib->{$tag}->{$subfield}->{hidden} >= 4 ) )
561 ; #check for visibility flag
563 if ( $tagslib->{$tag}->{$subfield}->{tab} ne $tabloop );
567 $tag, $subfield, '', $index_tag, $tabloop, $record,
568 $authorised_values_sth,$input
572 if ( $#subfields_data >= 0 ) {
576 tag_lib => $tagslib->{$tag}->{lib},
577 repeatable => $tagslib->{$tag}->{repeatable},
578 indicator => $indicator,
579 subfield_loop => \@subfields_data,
580 tagfirstsubfield => $subfields_data[0],
581 fixedfield => ($tag < 10)?(1):(0)
584 push @loop_data, \%tag_data ;
588 if ( $#loop_data >= 0 ) {
591 innerloop => \@loop_data,
595 $template->param( BIG_LOOP => \@BIG_LOOP );
598 sub BiblioAddAuthorities{
599 my ( $record, $frameworkcode ) = @_;
600 my $dbh=C4::Context->dbh;
601 my $query=$dbh->prepare(qq|
602 SELECT authtypecode,tagfield
603 FROM marc_subfield_structure
604 WHERE frameworkcode=?
605 AND (authtypecode IS NOT NULL AND authtypecode<>\"\")|);
606 # SELECT authtypecode,tagfield
607 # FROM marc_subfield_structure
608 # WHERE frameworkcode=?
609 # AND (authtypecode IS NOT NULL OR authtypecode<>\"\")|);
610 $query->execute($frameworkcode);
611 my ($countcreated,$countlinked);
612 while (my $data=$query->fetchrow_hashref){
613 if ($record->field($data->{tagfield})){
614 next if ($record->subfield($data->{tagfield},'3')||$record->subfield($data->{tagfield},'9'));
615 # No authorities id in the tag.
616 # Search if there is any authorities to link to.
617 my $query='at='.$data->{authtypecode}.' ';
618 map {$query.= " and he=".$_->[1] if ($_->[0]=~/[A-z]/)} $record->field($data->{tagfield})->subfields();
619 my ($error,$results)=SimpleSearch($query,"authorityserver");
620 # there is at least 1 result => return the 1st one
622 my $marcrecord = MARC::File::USMARC::decode($results->[0]);
623 $record->field($data->{tagfield})->add_subfields('9'=>$marcrecord->field('001')->data);
626 #There are no results, build authority record, add it to Authorities, get authid and add it to 9
627 ###NOTICE : This is only valid if a subfield is linked to one and only one authtypecode
629 my $authtypedata=GetAuthType($data->{authtypecode});
630 my $marcrecordauth=MARC::Record->new();
631 my $field=MARC::Field->new($authtypedata->{auth_tag_to_report},'','',"a"=>"".$record->subfield($data->{tagfield},'a'));
632 map { $field->add_subfields($_->[0]=>$_->[1]) if ($_->[0]=~/[A-z]/ && $_->[0] ne "a" )} $record->field($data->{tagfield})->subfields();
633 $marcrecordauth->insert_fields_ordered($field);
634 my $authid=AddAuthority($marcrecordauth,'',$data->{authtypecode});
636 $record->field($data->{tagfield})->add_subfields('9'=>$authid);
640 return ($countlinked,$countcreated);
643 # ========================
645 #=========================
647 my $error = $input->param('error');
648 my $biblionumber = $input->param('biblionumber'); # if biblionumber exists, it's a modif, not a new biblio.
649 my $breedingid = $input->param('breedingid');
650 my $z3950 = $input->param('z3950');
651 my $op = $input->param('op');
652 my $mode = $input->param('mode');
653 my $frameworkcode = $input->param('frameworkcode');
654 my $dbh = C4::Context->dbh;
656 $frameworkcode = &GetFrameworkCode($biblionumber)
657 if ( $biblionumber and not($frameworkcode) );
659 $frameworkcode = '' if ( $frameworkcode eq 'Default' );
660 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
662 template_name => "cataloguing/addbiblio.tmpl",
665 authnotrequired => 0,
666 flagsrequired => { editcatalogue => 1 },
670 #Getting the list of all frameworks
671 my $queryfwk = $dbh->prepare("select frameworktext, frameworkcode from biblio_framework");
676 push @select_fwk, "Default";
677 $select_fwk{"Default"} = "Default";
679 while ( my ( $description, $fwk ) = $queryfwk->fetchrow ) {
680 push @select_fwk, $fwk;
681 $select_fwk{$fwk} = $description;
683 $curfwk = $frameworkcode;
684 my $framework = CGI::scrolling_list(
685 -name => 'Frameworks',
688 -onchange => 'Changefwk(this);',
689 -values => \@select_fwk,
690 -labels => \%select_fwk,
694 $template->param( framework => $framework, breedingid => $breedingid );
697 $tagslib = &GetMarcStructure( 1, $frameworkcode );
698 $usedTagsLib = &GetUsedMarcStructure( $frameworkcode );
699 $mandatory_z3950 = GetMandatoryFieldZ3950($frameworkcode);
705 $biblionumbertagfield,
706 $biblionumbertagsubfield,
707 $biblioitemnumtagfield,
708 $biblioitemnumtagsubfield,
713 if (($biblionumber) && !($breedingid)){
714 $record = GetMarcBiblio($biblionumber);
717 ( $record, $encoding ) = MARCfindbreeding( $dbh, $breedingid ) ;
725 # if it's a modif, retrieve bibli and biblioitem numbers for the future modification of old-DB.
726 ( $biblionumbertagfield, $biblionumbertagsubfield ) =
727 &GetMarcFromKohaField( "biblio.biblionumber", $frameworkcode );
728 ( $biblioitemnumtagfield, $biblioitemnumtagsubfield ) =
729 &GetMarcFromKohaField( "biblioitems.biblioitemnumber", $frameworkcode );
731 # search biblioitems value
732 my $sth = $dbh->prepare("select biblioitemnumber from biblioitems where biblionumber=?");
733 $sth->execute($biblionumber);
734 ($biblioitemnumber) = $sth->fetchrow;
737 #-------------------------------------------------------------------------------------
738 if ( $op eq "addbiblio" ) {
739 #-------------------------------------------------------------------------------------
741 my @params = $input->param();
742 $record = TransformHtmlToMarc( \@params , $input );
743 # check for a duplicate
744 my ($duplicatebiblionumber,$duplicatetitle) = FindDuplicate($record) if (!$is_a_modif);
745 my $confirm_not_duplicate = $input->param('confirm_not_duplicate');
746 # it is not a duplicate (determined either by Koha itself or by user checking it's not a duplicate)
747 if ( !$duplicatebiblionumber or $confirm_not_duplicate ) {
750 if (C4::Context->preference("BiblioAddsAuthorities")){
751 my ($countlinked,$countcreated)=BiblioAddAuthorities($record,$frameworkcode);
754 ModBiblioframework( $biblionumber, $frameworkcode );
755 ModBiblio( $record, $biblionumber, $frameworkcode );
758 ( $biblionumber, $oldbibitemnum ) = AddBiblio( $record, $frameworkcode );
761 if ($mode ne "popup"){
762 print $input->redirect(
763 "/cgi-bin/koha/cataloguing/additem.pl?biblionumber=$biblionumber&frameworkcode=$frameworkcode"
768 biblionumber => $biblionumber,
772 $template->param( title => $record->subfield('200',"a") ) if ($record ne "-1" && C4::Context->preference('marcflavour') =~/unimarc/i);
773 $template->param( title => $record->title() ) if ($record ne "-1" && C4::Context->preference('marcflavour') eq "usmarc");
776 itemtype => $frameworkcode,
778 output_html_with_http_headers $input, $cookie, $template->output;
782 # it may be a duplicate, warn the user and do nothing
783 build_tabs ($template, $record, $dbh,$encoding,$input);
785 biblionumber => $biblionumber,
786 biblioitemnumber => $biblioitemnumber,
787 duplicatebiblionumber => $duplicatebiblionumber,
788 duplicatebibid => $duplicatebiblionumber,
789 duplicatetitle => $duplicatetitle,
793 elsif ( $op eq "delete" ) {
795 my $error = &DelBiblio($biblionumber);
797 warn "ERROR when DELETING BIBLIO $biblionumber : $error";
798 print "Content-Type: text/html\n\n<html><body><h1>ERROR when DELETING BIBLIO $biblionumber : $error</h1></body></html>";
802 print $input->redirect('/cgi-bin/koha/catalogue/search.pl');
806 #----------------------------------------------------------------------------
807 # If we're in a duplication case, we have to set to "" the biblionumber
808 # as we'll save the biblio as a new one.
809 if ( $op eq "duplicate" ) {
813 #FIXME: it's kind of silly to go from MARC::Record to MARC::File::XML and then back again just to fix the encoding
815 my $uxml = $record->as_xml;
816 MARC::Record::default_record_format("UNIMARC")
817 if ( C4::Context->preference("marcflavour") eq "UNIMARC" );
818 my $urecord = MARC::Record::new_from_xml( $uxml, 'UTF-8' );
821 build_tabs( $template, $record, $dbh, $encoding,$input );
823 biblionumber => $biblionumber,
824 biblionumbertagfield => $biblionumbertagfield,
825 biblionumbertagsubfield => $biblionumbertagsubfield,
826 biblioitemnumtagfield => $biblioitemnumtagfield,
827 biblioitemnumtagsubfield => $biblioitemnumtagsubfield,
828 biblioitemnumber => $biblioitemnumber,
832 $template->param( title => $record->title() ) if ( $record ne "-1" );
835 frameworkcode => $frameworkcode,
836 itemtype => $frameworkcode,
839 output_html_with_http_headers $input, $cookie, $template->output;