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 );
110 # $record->insert_fields_ordered($record->field('010'));
114 if ($record->subfield(100,'a')){
115 my $f100a=$record->subfield(100,'a');
116 my $f100 = $record->field(100);
117 my $f100temp = $f100->as_string;
118 $record->delete_field($f100);
119 if (length($f100temp)>28){
120 substr($f100temp,26,2,"50");
121 $f100->update('a' => $f100temp);
122 my $f100 = MARC::Field->new('100','','','a' => $f100temp);
123 $record->insert_fields_ordered($f100);
126 if (ref($record) eq undef) {
129 if (C4::Context->preference("z3950NormalizeAuthor") and C4::Context->preference("z3950AuthorAuthFields")){
130 my ($tag,$subfield) = GetMarcFromKohaField("biblio.author");
131 # my $summary = C4::Context->preference("z3950authortemplate");
132 my $auth_fields = C4::Context->preference("z3950AuthorAuthFields");
133 my @auth_fields= split /,/,$auth_fields;
135 #warn $record->as_formatted;
136 if ($record->field($tag)){
137 foreach my $tmpfield ($record->field($tag)->subfields){
138 # foreach my $subfieldcode ($tmpfield->subfields){
139 my $subfieldcode=shift @$tmpfield;
140 my $subfieldvalue=shift @$tmpfield;
142 $field->add_subfields("$subfieldcode"=>$subfieldvalue) if ($subfieldcode ne $subfield);
144 $field=MARC::Field->new($tag,"","",$subfieldcode=>$subfieldvalue) if ($subfieldcode ne $subfield);
147 # warn $field->as_formatted;
150 $record->delete_field($record->field($tag));
151 foreach my $fieldtag (@auth_fields){
152 next unless ($record->field($fieldtag));
153 my $lastname = $record->field($fieldtag)->subfield('a');
154 my $firstname= $record->field($fieldtag)->subfield('b');
155 my $title = $record->field($fieldtag)->subfield('c');
156 my $number= $record->field($fieldtag)->subfield('d');
158 # $field->add_subfields("$subfield"=>"[ ".ucfirst($title).ucfirst($firstname)." ".$number." ]");
159 $field->add_subfields("$subfield"=>ucfirst($title)." ".ucfirst($firstname)." ".$number);
161 # $field->add_subfields("$subfield"=>"[ ".ucfirst($firstname).", ".ucfirst($lastname)." ]");
162 $field->add_subfields("$subfield"=>ucfirst($firstname).", ".ucfirst($lastname));
165 $record->insert_fields_ordered($field);
167 return $record,$encoding;
174 =item build_authorized_values_list
178 sub build_authorized_values_list ($$$$$) {
179 my($tag, $subfield, $value, $dbh,$authorised_values_sth) = @_;
181 my @authorised_values;
184 # builds list, depending on authorised value...
187 if ($tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
188 my $sth=$dbh->prepare("select branchcode,branchname from branches order by branchname");
190 push @authorised_values, ""
191 unless ($tagslib->{$tag}->{$subfield}->{mandatory});
193 while (my ($branchcode,$branchname) = $sth->fetchrow_array) {
194 push @authorised_values, $branchcode;
195 $authorised_lib{$branchcode}=$branchname;
199 } elsif ($tagslib->{$tag}->{$subfield}->{authorised_value} eq "itemtypes") {
200 my $sth=$dbh->prepare("select itemtype,description from itemtypes order by description");
202 push @authorised_values, "" unless ($tagslib->{$tag}->{$subfield}->{mandatory});
204 while (my ($itemtype,$description) = $sth->fetchrow_array) {
205 push @authorised_values, $itemtype;
206 $authorised_lib{$itemtype}=$description;
208 $value=$itemtype unless ($value);
210 #---- "true" authorised value
212 $authorised_values_sth->execute($tagslib->{$tag}->{$subfield}->{authorised_value});
214 push @authorised_values, "" unless ($tagslib->{$tag}->{$subfield}->{mandatory});
216 while (my ($value,$lib) = $authorised_values_sth->fetchrow_array) {
217 push @authorised_values, $value;
218 $authorised_lib{$value}=$lib;
221 return CGI::scrolling_list( -name => 'field_value',
222 -values => \@authorised_values,
224 -labels => \%authorised_lib,
232 builds the <input ...> entry for a subfield.
236 sub create_input () {
237 my ($tag,$subfield,$value,$i,$tabloop,$rec,$authorised_values_sth) = @_;
238 # must be encoded as utf-8 before it reaches the editor
240 #$value = encode('utf-8', $value);
241 $value =~ s/"/"/g;
242 # if there is no value provided but a default value in parameters, get it
244 $value = $tagslib->{$tag}->{$subfield}->{defaultvalue};
245 # get today date & replace YYYY, MM, DD if provided in the default value
246 my ($year,$month,$day) = Today();
247 $month = sprintf("%02d",$month);
248 $day = sprintf("%02d",$day);
249 $value =~ s/YYYY/$year/g;
250 $value =~ s/MM/$month/g;
251 $value =~ s/DD/$day/g;
254 my $dbh = C4::Context->dbh;
256 $subfield_data{tag}=$tag;
257 $subfield_data{subfield}=$subfield;
258 $subfield_data{marc_lib}="<span id=\"error$i\" title=\"".$tagslib->{$tag}->{$subfield}->{lib}."\">".substr($tagslib->{$tag}->{$subfield}->{lib},0,15)."</span>";
259 $subfield_data{marc_lib_plain}=$tagslib->{$tag}->{$subfield}->{lib};
260 $subfield_data{tag_mandatory}=$tagslib->{$tag}->{mandatory};
261 $subfield_data{mandatory}=$tagslib->{$tag}->{$subfield}->{mandatory};
262 $subfield_data{repeatable}=$tagslib->{$tag}->{$subfield}->{repeatable};
263 $subfield_data{kohafield}=$tagslib->{$tag}->{$subfield}->{kohafield};
264 $subfield_data{index} = $i;
265 $subfield_data{visibility} = "display:none" unless (($tagslib->{$tag}->{$subfield}->{hidden}%2==0) or $value ne ''); #check parity
266 # it's an authorised field
267 if ($tagslib->{$tag}->{$subfield}->{authorised_value}) {
268 $subfield_data{marc_value}= build_authorized_values_list($tag, $subfield, $value, $dbh,$authorised_values_sth);
269 # it's a thesaurus / authority field
270 } elsif ($tagslib->{$tag}->{$subfield}->{authtypecode}) {
271 $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>";
272 # it's a plugin field
273 } elsif ($tagslib->{$tag}->{$subfield}->{'value_builder'}) {
274 # opening plugin. Just check wether we are on a developper computer on a production one
275 # (the cgidir differs)
276 my $cgidir = C4::Context->intranetdir ."/cgi-bin/cataloguing/value_builder";
277 unless (opendir(DIR, "$cgidir")) {
278 $cgidir = C4::Context->intranetdir."/cataloguing/value_builder";
280 my $plugin=$cgidir."/".$tagslib->{$tag}->{$subfield}->{'value_builder'};
282 my $extended_param = plugin_parameters($dbh,$rec,$tagslib,$i,$tabloop);
283 my ($function_name,$javascript) = plugin_javascript($dbh,$rec,$tagslib,$i,$tabloop);
284 $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";
285 # it's an hidden field
286 } elsif ($tag eq '') {
287 $subfield_data{marc_value}="<input onblur=\"this.style.backgroundColor='#ffffff';\" onfocus=\"this.style.backgroundColor='#ffff00'; \" tabindex=\"1\" type=\"hidden\" name=\"field_value\" value=\"$value\">";
288 } elsif ($tagslib->{$tag}->{$subfield}->{'hidden'}) {
289 $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\" >";
290 # it's a standard field
292 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")) {
293 $subfield_data{marc_value}="<textarea tabindex=\"1\" name=\"field_value\" cols=\"70\" rows=\"5\" >$value</textarea>";
295 $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\">"; #"
298 return \%subfield_data;
301 sub build_tabs ($$$$) {
302 my($template, $record, $dbh,$encoding) = @_;
307 my $authorised_values_sth = $dbh->prepare("select authorised_value,lib
308 from authorised_values
309 where category=? order by lib");
311 # in this array, we will push all the 10 tabs
312 # to avoid having 10 tabs in the template : they will all be in the same BIG_LOOP
315 # loop through each tab 0 through 9
316 for (my $tabloop = 0; $tabloop <= 9; $tabloop++) {
318 foreach my $tag (sort(keys (%{$tagslib}))) {
320 # if MARC::Record is not empty => use it as master loop, then add missing subfields that should be in the tab.
321 # if MARC::Record is empty => use tab as master loop.
322 if ($record ne -1 && ($record->field($tag) || $tag eq '000')) {
325 @fields = $record->field($tag);
327 push @fields,$record->leader();
329 foreach my $field (@fields) {
332 my ($value,$subfield);
334 $value=$field->data();
340 next if ($tagslib->{$tag}->{$subfield}->{tab} ne $tabloop);
341 next if ($tagslib->{$tag}->{$subfield}->{kohafield} eq 'biblio.biblionumber');
342 push(@subfields_data, &create_input($tag,$subfield,$value,$i,$tabloop,$record,$authorised_values_sth));
345 my @subfields=$field->subfields();
346 foreach my $subfieldcount (0..$#subfields) {
347 my $subfield=$subfields[$subfieldcount][0];
348 my $value=$subfields[$subfieldcount][1];
349 next if (length $subfield !=1);
350 next if ($tagslib->{$tag}->{$subfield}->{tab} ne $tabloop);
351 push(@subfields_data, &create_input($tag,$subfield,$value,$i,$tabloop,$record,$authorised_values_sth));
355 # now, loop again to add parameter subfield that are not in the MARC::Record
356 foreach my $subfield (sort( keys %{$tagslib->{$tag}})) {
357 next if (length $subfield !=1);
358 next if ($tagslib->{$tag}->{$subfield}->{tab} ne $tabloop);
360 next if (($tagslib->{$tag}->{$subfield}->{hidden}<=-4) or ($tagslib->{$tag}->{$subfield}->{hidden}>=5) ); #check for visibility flag
361 next if (defined($field->subfield($subfield)));
362 push(@subfields_data, &create_input($tag,$subfield,'',$i,$tabloop,$record,$authorised_values_sth));
365 if ($#subfields_data >= 0) {
367 $tag_data{tag} = $tag;
368 $tag_data{tag_lib} = $tagslib->{$tag}->{lib};
369 $tag_data{repeatable} = $tagslib->{$tag}->{repeatable};
370 $tag_data{indicator} = $record->field($tag)->indicator(1). $record->field($tag)->indicator(2) if ($tag>=10);
371 $tag_data{subfield_loop} = \@subfields_data;
373 $tag_data{fixedfield} = 1;
376 push (@loop_data, \%tag_data);
378 # If there is more than 1 field, add an empty hidden field as separator.
379 if ($#fields >=1 && $#loop_data >=0 && $loop_data[$#loop_data]->{'tag'} eq $tag) {
382 push(@subfields_data, &create_input('','','',$i,$tabloop,$record,$authorised_values_sth));
384 $tag_data{tag_lib} = '';
385 $tag_data{indicator} = '';
386 $tag_data{subfield_loop} = \@subfields_data;
388 $tag_data{fixedfield} = 1;
390 push (@loop_data, \%tag_data);
394 # if breeding is empty
397 foreach my $subfield (sort(keys %{$tagslib->{$tag}})) {
398 next if (length $subfield !=1);
399 next if (($tagslib->{$tag}->{$subfield}->{hidden}<=-5) or ($tagslib->{$tag}->{$subfield}->{hidden}>=4) ); #check for visibility flag
400 next if ($tagslib->{$tag}->{$subfield}->{tab} ne $tabloop);
401 push(@subfields_data, &create_input($tag,$subfield,'',$i,$tabloop,$record,$authorised_values_sth));
404 if ($#subfields_data >= 0) {
406 $tag_data{tag} = $tag;
407 $tag_data{tag_lib} = $tagslib->{$tag}->{lib};
408 $tag_data{repeatable} = $tagslib->{$tag}->{repeatable};
409 $tag_data{indicator} = $indicator;
410 $tag_data{subfield_loop} = \@subfields_data;
411 $tag_data{tagfirstsubfield} = $tag_data{subfield_loop}[0];
413 $tag_data{fixedfield} = 1;
415 push (@loop_data, \%tag_data);
419 if ($#loop_data >=0) {
421 $big_loop_line{number}=$tabloop;
422 $big_loop_line{innerloop}=\@loop_data;
423 push @BIG_LOOP,\%big_loop_line;
425 # $template->param($tabloop."XX" =>\@loop_data);
427 $template->param(BIG_LOOP => \@BIG_LOOP);
432 sub build_hidden_data () {
433 # build hidden data =>
434 # we store everything, even if we show only requested subfields.
438 foreach my $tag (keys %{$tagslib}) {
439 my $previous_tag = '';
441 # loop through each subfield
442 foreach my $subfield (keys %{$tagslib->{$tag}}) {
443 next if ($subfield eq 'lib');
444 next if ($subfield eq 'tab');
445 next if ($subfield eq 'mandatory');
446 next if ($subfield eq 'repeatable');
447 next if ($tagslib->{$tag}->{$subfield}->{'tab'} ne "-1");
449 $subfield_data{marc_lib}=$tagslib->{$tag}->{$subfield}->{lib};
450 $subfield_data{marc_mandatory}=$tagslib->{$tag}->{$subfield}->{mandatory};
451 $subfield_data{marc_repeatable}=$tagslib->{$tag}->{$subfield}->{repeatable};
452 $subfield_data{marc_value}="<input type=\"hidden\" name=\"field_value[]\">";
453 push(@loop_data, \%subfield_data);
460 # ========================
462 #=========================
464 my $error = $input->param('error');
465 my $biblionumber=$input->param('biblionumber'); # if biblionumber exists, it's a modif, not a new biblio.
466 my $breedingid = $input->param('breedingid');
467 my $z3950 = $input->param('z3950');
468 my $op = $input->param('op');
469 my $frameworkcode = $input->param('frameworkcode');
470 my $dbh = C4::Context->dbh;
472 $frameworkcode = &GetFrameworkCode($biblionumber) if ($biblionumber and not ($frameworkcode));
474 $frameworkcode='' if ($frameworkcode eq 'Default');
475 my ($template, $loggedinuser, $cookie)
476 = get_template_and_user({template_name => "cataloguing/addbiblio.tmpl",
479 authnotrequired => 0,
480 flagsrequired => {editcatalogue => 1},
484 #Getting the list of all frameworks
485 my $queryfwk =$dbh->prepare("select frameworktext, frameworkcode from biblio_framework");
490 push @select_fwk,"Default";
491 $select_fwk{"Default"} = "Default";
492 while (my ($description, $fwk) =$queryfwk->fetchrow) {
493 push @select_fwk, $fwk;
494 $select_fwk{$fwk} = $description;
496 $curfwk=$frameworkcode;
497 my $framework=CGI::scrolling_list(
498 -name => 'Frameworks',
501 -OnChange => 'Changefwk(this);',
502 -values => \@select_fwk,
503 -labels => \%select_fwk,
506 $template->param( framework => $framework, breedingid => $breedingid);
508 $tagslib = &GetMarcStructure($dbh,1,$frameworkcode);
511 $record = GetMarcBiblio( $biblionumber ) if ($biblionumber);
512 ($record,$encoding) = MARCfindbreeding($dbh,$breedingid) if ($breedingid);
514 # warn "biblionumber : $biblionumber = ".$record->as_formatted;
516 my ($biblionumtagfield,$biblionumtagsubfield);
517 my ($biblioitemnumtagfield,$biblioitemnumtagsubfield,$bibitem,$biblioitemnumber);
520 # if it's a modif, retrieve bibli and biblioitem numbers for the future modification of old-DB.
521 ($biblionumtagfield,$biblionumtagsubfield) = &GetMarcFromKohaField("biblio.biblionumber",$frameworkcode);
522 ($biblioitemnumtagfield,$biblioitemnumtagsubfield) = &GetMarcFromKohaField("biblioitems.biblioitemnumber",$frameworkcode);
523 # search biblioitems value
524 my $sth=$dbh->prepare("select biblioitemnumber from biblioitems where biblionumber=?");
525 $sth->execute($biblionumber);
526 ($biblioitemnumber) = $sth->fetchrow;
528 #-------------------------------------------------------------------------------------
529 if ($op eq "addbiblio") {
530 #-------------------------------------------------------------------------------------
532 my @tags = $input->param('tag');
533 my @subfields = $input->param('subfield');
534 my @values = $input->param('field_value');
535 # build indicator hash.
536 my @ind_tag = $input->param('ind_tag');
537 my @indicator = $input->param('indicator');
538 if (C4::Context->preference('TemplateEncoding') eq "iso-8859-1") {
539 $record = TransformHtmlToMarc($dbh,\@tags,\@subfields,\@values,\@indicator,\@ind_tag);
541 my $xml = TransformHtmlToXml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag);
542 $record=MARC::Record->new_from_xml($xml,C4::Context->preference('TemplateEncoding'),C4::Context->preference('marcflavour'));
543 # warn "MARC :".$record->as_formatted;
546 # check for a duplicate
547 my ($duplicatebiblionumber,$duplicatebiblionumber,$duplicatetitle) = FindDuplicate($record) if ($op eq "addbiblio") && (!$is_a_modif);
548 my $confirm_not_duplicate = $input->param('confirm_not_duplicate');
549 # it is not a duplicate (determined either by Koha itself or by user checking it's not a duplicate)
550 if (!$duplicatebiblionumber or $confirm_not_duplicate) {
551 # MARC::Record built => now, record in DB
555 ModBiblioframework($biblionumber,$frameworkcode);
556 ModBiblio($record,$biblionumber,$frameworkcode);
559 ($biblionumber,$oldbibitemnum) = AddBiblio($record,$frameworkcode);
561 # now, redirect to additem page
562 print $input->redirect("additem.pl?biblionumber=$biblionumber&frameworkcode=$frameworkcode");
565 # it may be a duplicate, warn the user and do nothing
566 build_tabs ($template, $record, $dbh,$encoding);
569 biblionumber => $biblionumber,
570 biblionumtagfield => $biblionumtagfield,
571 biblionumtagsubfield => $biblionumtagsubfield,
572 biblioitemnumtagfield => $biblioitemnumtagfield,
573 biblioitemnumtagsubfield => $biblioitemnumtagsubfield,
574 biblioitemnumber => $biblioitemnumber,
575 duplicatebiblionumber => $duplicatebiblionumber,
576 duplicatebibid => $duplicatebiblionumber,
577 duplicatetitle => $duplicatetitle,
580 #--------------------------------------------------------------------------
581 } elsif ($op eq "addfield") {
582 #--------------------------------------------------------------------------
583 my $addedfield = $input->param('addfield_field');
584 my $cntrepeatfield=$input->param('repeat_field');
585 $cntrepeatfield=1 unless ($cntrepeatfield);
586 my $tagaddfield_subfield = $input->param('addfield_subfield');
587 my @tags = $input->param('tag');
588 my @subfields = $input->param('subfield');
589 my @values = $input->param('field_value');
590 # build indicator hash.
591 my @ind_tag = $input->param('ind_tag');
592 my @indicator = $input->param('indicator');
593 my $xml = TransformHtmlToXml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag);
595 if (C4::Context->preference('TemplateEncoding') eq "iso-8859-1") {
597 for (my $i=0;$i<=$#ind_tag;$i++) {
598 $indicators{$ind_tag[$i]} = $indicator[$i];
600 $record = TransformHtmlToMarc($dbh,\@tags,\@subfields,\@values,%indicators);
602 my $xml = TransformHtmlToXml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag);
603 $record=MARC::Record->new_from_xml($xml,C4::Context->preference('TemplateEncoding'),C4::Context->preference('marcflavour'));
605 for (my $i=1;$i<=$cntrepeatfield;$i++){
606 my $field = MARC::Field->new("$addedfield",'','',"$tagaddfield_subfield" => "");
607 $record->append_fields($field);
609 #warn "result : ".$record->as_formatted;
610 build_tabs ($template, $record, $dbh,$encoding);
613 biblionumber => $biblionumber,
614 biblionumtagfield => $biblionumtagfield,
615 biblionumtagsubfield => $biblionumtagsubfield,
616 biblioitemnumtagfield => $biblioitemnumtagfield,
617 biblioitemnumtagsubfield => $biblioitemnumtagsubfield,
618 biblioitemnumber => $biblioitemnumber );
619 } elsif ($op eq "delete") {
620 #-----------------------------------------------------------------------------
621 my $error = &DelBiblio($biblionumber);
623 warn "ERROR when DELETING BIBLIO $biblionumber : $error";
624 print "Content-Type: text/html\n\n<html><body><h1>ERROR when DELETING BIBLIO $biblionumber : $error</h1></body></html>";
626 print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=/cgi-bin/koha/catalogue/search.pl?type=intranet\"></html>";
629 #----------------------------------------------------------------------------
631 #----------------------------------------------------------------------------
632 # If we're in a duplication case, we have to set to "" the biblionumber
633 # as we'll save the biblio as a new one.
634 if ($op eq "duplicate")
638 #FIXME: it's kind of silly to go from MARC::Record to MARC::File::XML and then back again just to fix the encoding
640 my $uxml = $record->as_xml;
641 MARC::Record::default_record_format("UNIMARC") if (C4::Context->preference("marcflavour") eq "UNIMARC");
642 my $urecord = MARC::Record::new_from_xml($uxml, 'UTF-8');
645 build_tabs ($template, $record, $dbh,$encoding);
648 biblionumber => $biblionumber,
649 biblionumtagfield => $biblionumtagfield,
650 biblionumtagsubfield => $biblionumtagsubfield,
651 biblioitemnumtagfield => $biblioitemnumtagfield,
652 biblioitemnumtagsubfield => $biblioitemnumtagsubfield,
653 biblioitemnumber => $biblioitemnumber,
656 $template->param( title => $record->title() ) if ($record ne "-1");
658 frameworkcode => $frameworkcode,
659 itemtype => $frameworkcode, # HINT: if the library has itemtype = framework, itemtype is auto filled !
660 hide_marc => C4::Context->preference('hide_marc'),
661 intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
662 intranetstylesheet => C4::Context->preference("intranetstylesheet"),
663 IntranetNav => C4::Context->preference("IntranetNav"),
664 advancedMARCEditor => C4::Context->preference("advancedMARCEditor"),
666 output_html_with_http_headers $input, $cookie, $template->output;