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
26 use C4::Interface::CGI::Output;
32 use C4::Koha; # XXX subfield_is_koha_internal_p
33 use Date::Calc qw(Today);
35 use MARC::File::USMARC;
37 if (C4::Context->preference('marcflavour') eq 'UNIMARC') {
38 MARC::File::XML->default_record_format( 'UNIMARC' );
41 use vars qw( $tagslib);
42 use vars qw( $authorised_values_sth);
43 use vars qw( $is_a_modif );
45 my $itemtype; # created here because it can be used in build_authorized_values_list sub
49 ($indicators, $value) = find_value($tag, $subfield, $record,$encoding);
51 Find the given $subfield in the given $tag in the given
52 MARC::Record $record. If the subfield is found, returns
53 the (indicators, value) pair; otherwise, (undef, undef) is
59 my ($tagfield,$insubfield,$record,$encoding) = @_;
63 if ($record->field($tagfield)) {
64 push @result, $record->field($tagfield)->data();
69 foreach my $field ($record->field($tagfield)) {
70 my @subfields = $field->subfields();
71 foreach my $subfield (@subfields) {
72 if (@$subfield[0] eq $insubfield) {
73 push @result,@$subfield[1];
74 $indicator = $field->indicator(1).$field->indicator(2);
79 return($indicator,@result);
83 =item MARCfindbreeding
85 $record = MARCfindbreeding($dbh, $breedingid);
87 Look up the breeding farm with database handle $dbh, for the
88 record with id $breedingid. If found, returns the decoded
89 MARC::Record; otherwise, -1 is returned (FIXME).
90 Returns as second parameter the character encoding.
94 sub MARCfindbreeding {
96 my $sth = $dbh->prepare("select file,marc,encoding from marc_breeding where id=?");
98 my ($file,$marc,$encoding) = $sth->fetchrow;
100 my $record = MARC::Record->new_from_usmarc($marc);
101 if ($record->field('010')){
102 foreach my $field ($record->field('010'))
104 foreach my $subfield ($field->subfield('a')){
105 my $newisbn = $field->subfield('a');
107 $field->update( 'a' => $newisbn );
111 # $record->insert_fields_ordered($record->field('010'));
115 if ($record->subfield(100,'a')){
116 my $f100a=$record->subfield(100,'a');
117 my $f100 = $record->field(100);
118 my $f100temp = $f100->as_string;
119 $record->delete_field($f100);
120 if (length($f100temp)>28){
121 substr($f100temp,26,2,"50");
122 $f100->update('a' => $f100temp);
123 my $f100 = MARC::Field->new('100','','','a' => $f100temp);
124 $record->insert_fields_ordered($f100);
127 if (ref($record) eq undef) {
130 if (C4::Context->preference("z3950NormalizeAuthor") and C4::Context->preference("z3950AuthorAuthFields")){
131 my ($tag,$subfield) = GetMarcFromKohaField($dbh,"biblio.author");
132 # my $summary = C4::Context->preference("z3950authortemplate");
133 my $auth_fields = C4::Context->preference("z3950AuthorAuthFields");
134 my @auth_fields= split /,/,$auth_fields;
136 #warn $record->as_formatted;
137 if ($record->field($tag)){
138 foreach my $tmpfield ($record->field($tag)->subfields){
139 # foreach my $subfieldcode ($tmpfield->subfields){
140 my $subfieldcode=shift @$tmpfield;
141 my $subfieldvalue=shift @$tmpfield;
143 $field->add_subfields("$subfieldcode"=>$subfieldvalue) if ($subfieldcode ne $subfield);
145 $field=MARC::Field->new($tag,"","",$subfieldcode=>$subfieldvalue) if ($subfieldcode ne $subfield);
148 # warn $field->as_formatted;
151 $record->delete_field($record->field($tag));
152 foreach my $fieldtag (@auth_fields){
153 next unless ($record->field($fieldtag));
154 my $lastname = $record->field($fieldtag)->subfield('a');
155 my $firstname= $record->field($fieldtag)->subfield('b');
156 my $title = $record->field($fieldtag)->subfield('c');
157 my $number= $record->field($fieldtag)->subfield('d');
159 # $field->add_subfields("$subfield"=>"[ ".ucfirst($title).ucfirst($firstname)." ".$number." ]");
160 $field->add_subfields("$subfield"=>ucfirst($title)." ".ucfirst($firstname)." ".$number);
162 # $field->add_subfields("$subfield"=>"[ ".ucfirst($firstname).", ".ucfirst($lastname)." ]");
163 $field->add_subfields("$subfield"=>ucfirst($firstname).", ".ucfirst($lastname));
166 $record->insert_fields_ordered($field);
168 return $record,$encoding;
175 =item build_authorized_values_list
179 sub build_authorized_values_list ($$$$$) {
180 my($tag, $subfield, $value, $dbh,$authorised_values_sth) = @_;
182 my @authorised_values;
185 # builds list, depending on authorised value...
188 if ($tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
189 my $sth=$dbh->prepare("select branchcode,branchname from branches order by branchname");
191 push @authorised_values, ""
192 unless ($tagslib->{$tag}->{$subfield}->{mandatory});
194 while (my ($branchcode,$branchname) = $sth->fetchrow_array) {
195 push @authorised_values, $branchcode;
196 $authorised_lib{$branchcode}=$branchname;
200 } elsif ($tagslib->{$tag}->{$subfield}->{authorised_value} eq "itemtypes") {
201 my $sth=$dbh->prepare("select itemtype,description from itemtypes order by description");
203 push @authorised_values, "" unless ($tagslib->{$tag}->{$subfield}->{mandatory});
205 while (my ($itemtype,$description) = $sth->fetchrow_array) {
206 push @authorised_values, $itemtype;
207 $authorised_lib{$itemtype}=$description;
209 $value=$itemtype unless ($value);
211 #---- "true" authorised value
213 $authorised_values_sth->execute($tagslib->{$tag}->{$subfield}->{authorised_value});
215 push @authorised_values, "" unless ($tagslib->{$tag}->{$subfield}->{mandatory});
217 while (my ($value,$lib) = $authorised_values_sth->fetchrow_array) {
218 push @authorised_values, $value;
219 $authorised_lib{$value}=$lib;
222 return CGI::scrolling_list( -name => 'field_value',
223 -values => \@authorised_values,
225 -labels => \%authorised_lib,
233 builds the <input ...> entry for a subfield.
237 sub create_input () {
238 my ($tag,$subfield,$value,$i,$tabloop,$rec,$authorised_values_sth) = @_;
239 # must be encoded as utf-8 before it reaches the editor
241 #$value = encode('utf-8', $value);
242 $value =~ s/"/"/g;
243 # if there is no value provided but a default value in parameters, get it
245 $value = $tagslib->{$tag}->{$subfield}->{defaultvalue};
246 # get today date & replace YYYY, MM, DD if provided in the default value
247 my ($year,$month,$day) = Today();
248 $month = sprintf("%02d",$month);
249 $day = sprintf("%02d",$day);
250 $value =~ s/YYYY/$year/g;
251 $value =~ s/MM/$month/g;
252 $value =~ s/DD/$day/g;
255 my $dbh = C4::Context->dbh;
257 $subfield_data{tag}=$tag;
258 $subfield_data{subfield}=$subfield;
259 $subfield_data{marc_lib}="<span id=\"error$i\" title=\"".$tagslib->{$tag}->{$subfield}->{lib}."\">".substr($tagslib->{$tag}->{$subfield}->{lib},0,15)."</span>";
260 $subfield_data{marc_lib_plain}=$tagslib->{$tag}->{$subfield}->{lib};
261 $subfield_data{tag_mandatory}=$tagslib->{$tag}->{mandatory};
262 $subfield_data{mandatory}=$tagslib->{$tag}->{$subfield}->{mandatory};
263 $subfield_data{repeatable}=$tagslib->{$tag}->{$subfield}->{repeatable};
264 $subfield_data{kohafield}=$tagslib->{$tag}->{$subfield}->{kohafield};
265 $subfield_data{index} = $i;
266 $subfield_data{visibility} = "display:none" unless (($tagslib->{$tag}->{$subfield}->{hidden}%2==0) or $value ne ''); #check parity
267 # it's an authorised field
268 if ($tagslib->{$tag}->{$subfield}->{authorised_value}) {
269 $subfield_data{marc_value}= build_authorized_values_list($tag, $subfield, $value, $dbh,$authorised_values_sth);
270 # it's a thesaurus / authority field
271 } elsif ($tagslib->{$tag}->{$subfield}->{authtypecode}) {
272 $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>";
273 # it's a plugin field
274 } elsif ($tagslib->{$tag}->{$subfield}->{'value_builder'}) {
275 # opening plugin. Just check wether we are on a developper computer on a production one
276 # (the cgidir differs)
277 my $cgidir = C4::Context->intranetdir ."/cgi-bin/cataloguing/value_builder";
278 unless (opendir(DIR, "$cgidir")) {
279 $cgidir = C4::Context->intranetdir."/cataloguing/value_builder";
281 my $plugin=$cgidir."/".$tagslib->{$tag}->{$subfield}->{'value_builder'};
283 my $extended_param = plugin_parameters($dbh,$rec,$tagslib,$i,$tabloop);
284 my ($function_name,$javascript) = plugin_javascript($dbh,$rec,$tagslib,$i,$tabloop);
285 $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";
286 # it's an hidden field
287 } elsif ($tag eq '') {
288 $subfield_data{marc_value}="<input onblur=\"this.style.backgroundColor='#ffffff';\" onfocus=\"this.style.backgroundColor='#ffff00'; \" tabindex=\"1\" type=\"hidden\" name=\"field_value\" value=\"$value\">";
289 } elsif ($tagslib->{$tag}->{$subfield}->{'hidden'}) {
290 $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\" >";
291 # it's a standard field
293 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")) {
294 $subfield_data{marc_value}="<textarea tabindex=\"1\" name=\"field_value\" cols=\"70\" rows=\"5\" >$value</textarea>";
296 $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\">"; #"
299 return \%subfield_data;
302 sub build_tabs ($$$$) {
303 my($template, $record, $dbh,$encoding) = @_;
308 my $authorised_values_sth = $dbh->prepare("select authorised_value,lib
309 from authorised_values
310 where category=? order by lib");
312 # in this array, we will push all the 10 tabs
313 # to avoid having 10 tabs in the template : they will all be in the same BIG_LOOP
316 # loop through each tab 0 through 9
317 for (my $tabloop = 0; $tabloop <= 9; $tabloop++) {
319 foreach my $tag (sort(keys (%{$tagslib}))) {
321 # if MARC::Record is not empty => use it as master loop, then add missing subfields that should be in the tab.
322 # if MARC::Record is empty => use tab as master loop.
323 if ($record ne -1 && ($record->field($tag) || $tag eq '000')) {
326 @fields = $record->field($tag);
328 push @fields,$record->leader();
330 foreach my $field (@fields) {
333 my ($value,$subfield);
335 $value=$field->data();
341 next if ($tagslib->{$tag}->{$subfield}->{tab} ne $tabloop);
342 next if ($tagslib->{$tag}->{$subfield}->{kohafield} eq 'biblio.biblionumber');
343 push(@subfields_data, &create_input($tag,$subfield,$value,$i,$tabloop,$record,$authorised_values_sth));
346 my @subfields=$field->subfields();
347 foreach my $subfieldcount (0..$#subfields) {
348 my $subfield=$subfields[$subfieldcount][0];
349 my $value=$subfields[$subfieldcount][1];
350 next if (length $subfield !=1);
351 next if ($tagslib->{$tag}->{$subfield}->{tab} ne $tabloop);
352 push(@subfields_data, &create_input($tag,$subfield,$value,$i,$tabloop,$record,$authorised_values_sth));
356 # now, loop again to add parameter subfield that are not in the MARC::Record
357 foreach my $subfield (sort( keys %{$tagslib->{$tag}})) {
358 next if (length $subfield !=1);
359 next if ($tagslib->{$tag}->{$subfield}->{tab} ne $tabloop);
361 next if (($tagslib->{$tag}->{$subfield}->{hidden}<=-4) or ($tagslib->{$tag}->{$subfield}->{hidden}>=5) ); #check for visibility flag
362 next if (defined($field->subfield($subfield)));
363 push(@subfields_data, &create_input($tag,$subfield,'',$i,$tabloop,$record,$authorised_values_sth));
366 if ($#subfields_data >= 0) {
368 $tag_data{tag} = $tag;
369 $tag_data{tag_lib} = $tagslib->{$tag}->{lib};
370 $tag_data{repeatable} = $tagslib->{$tag}->{repeatable};
371 $tag_data{indicator} = $record->field($tag)->indicator(1). $record->field($tag)->indicator(2) if ($tag>=10);
372 $tag_data{subfield_loop} = \@subfields_data;
374 $tag_data{fixedfield} = 1;
377 push (@loop_data, \%tag_data);
379 # If there is more than 1 field, add an empty hidden field as separator.
380 if ($#fields >=1 && $#loop_data >=0 && $loop_data[$#loop_data]->{'tag'} eq $tag) {
383 push(@subfields_data, &create_input('','','',$i,$tabloop,$record,$authorised_values_sth));
385 $tag_data{tag_lib} = '';
386 $tag_data{indicator} = '';
387 $tag_data{subfield_loop} = \@subfields_data;
389 $tag_data{fixedfield} = 1;
391 push (@loop_data, \%tag_data);
395 # if breeding is empty
398 foreach my $subfield (sort(keys %{$tagslib->{$tag}})) {
399 next if (length $subfield !=1);
400 next if (($tagslib->{$tag}->{$subfield}->{hidden}<=-5) or ($tagslib->{$tag}->{$subfield}->{hidden}>=4) ); #check for visibility flag
401 next if ($tagslib->{$tag}->{$subfield}->{tab} ne $tabloop);
402 push(@subfields_data, &create_input($tag,$subfield,'',$i,$tabloop,$record,$authorised_values_sth));
405 if ($#subfields_data >= 0) {
407 $tag_data{tag} = $tag;
408 $tag_data{tag_lib} = $tagslib->{$tag}->{lib};
409 $tag_data{repeatable} = $tagslib->{$tag}->{repeatable};
410 $tag_data{indicator} = $indicator;
411 $tag_data{subfield_loop} = \@subfields_data;
412 $tag_data{tagfirstsubfield} = $tag_data{subfield_loop}[0];
414 $tag_data{fixedfield} = 1;
416 push (@loop_data, \%tag_data);
420 if ($#loop_data >=0) {
422 $big_loop_line{number}=$tabloop;
423 $big_loop_line{innerloop}=\@loop_data;
424 push @BIG_LOOP,\%big_loop_line;
426 # $template->param($tabloop."XX" =>\@loop_data);
428 $template->param(BIG_LOOP => \@BIG_LOOP);
433 sub build_hidden_data () {
434 # build hidden data =>
435 # we store everything, even if we show only requested subfields.
439 foreach my $tag (keys %{$tagslib}) {
440 my $previous_tag = '';
442 # loop through each subfield
443 foreach my $subfield (keys %{$tagslib->{$tag}}) {
444 next if ($subfield eq 'lib');
445 next if ($subfield eq 'tab');
446 next if ($subfield eq 'mandatory');
447 next if ($subfield eq 'repeatable');
448 next if ($tagslib->{$tag}->{$subfield}->{'tab'} ne "-1");
450 $subfield_data{marc_lib}=$tagslib->{$tag}->{$subfield}->{lib};
451 $subfield_data{marc_mandatory}=$tagslib->{$tag}->{$subfield}->{mandatory};
452 $subfield_data{marc_repeatable}=$tagslib->{$tag}->{$subfield}->{repeatable};
453 $subfield_data{marc_value}="<input type=\"hidden\" name=\"field_value[]\">";
454 push(@loop_data, \%subfield_data);
461 # ========================
463 #=========================
465 my $error = $input->param('error');
466 my $biblionumber=$input->param('biblionumber'); # if biblionumber exists, it's a modif, not a new biblio.
467 my $breedingid = $input->param('breedingid');
468 my $z3950 = $input->param('z3950');
469 my $op = $input->param('op');
470 my $frameworkcode = $input->param('frameworkcode');
471 my $dbh = C4::Context->dbh;
473 $frameworkcode = &GetFrameworkCode($biblionumber) if ($biblionumber and not ($frameworkcode));
475 $frameworkcode='' if ($frameworkcode eq 'Default');
476 my ($template, $loggedinuser, $cookie)
477 = get_template_and_user({template_name => "cataloguing/addbiblio.tmpl",
480 authnotrequired => 0,
481 flagsrequired => {editcatalogue => 1},
485 #Getting the list of all frameworks
486 my $queryfwk =$dbh->prepare("select frameworktext, frameworkcode from biblio_framework");
491 push @select_fwk,"Default";
492 $select_fwk{"Default"} = "Default";
493 while (my ($description, $fwk) =$queryfwk->fetchrow) {
494 push @select_fwk, $fwk;
495 $select_fwk{$fwk} = $description;
497 $curfwk=$frameworkcode;
498 my $framework=CGI::scrolling_list(
499 -name => 'Frameworks',
502 -OnChange => 'Changefwk(this);',
503 -values => \@select_fwk,
504 -labels => \%select_fwk,
507 $template->param( framework => $framework, breedingid => $breedingid);
509 $tagslib = &GetMarcStructure($dbh,1,$frameworkcode);
512 $record = GetMarcBiblio( $biblionumber ) if ($biblionumber);
513 ($record,$encoding) = MARCfindbreeding($dbh,$breedingid) if ($breedingid);
515 # warn "biblionumber : $biblionumber = ".$record->as_formatted;
517 my ($biblionumtagfield,$biblionumtagsubfield);
518 my ($biblioitemnumtagfield,$biblioitemnumtagsubfield,$bibitem,$biblioitemnumber);
521 # if it's a modif, retrieve bibli and biblioitem numbers for the future modification of old-DB.
522 ($biblionumtagfield,$biblionumtagsubfield) = &GetMarcFromKohaField($dbh,"biblio.biblionumber",$frameworkcode);
523 ($biblioitemnumtagfield,$biblioitemnumtagsubfield) = &GetMarcFromKohaField($dbh,"biblioitems.biblioitemnumber",$frameworkcode);
524 # search biblioitems value
525 my $sth=$dbh->prepare("select biblioitemnumber from biblioitems where biblionumber=?");
526 $sth->execute($biblionumber);
527 ($biblioitemnumber) = $sth->fetchrow;
529 #-------------------------------------------------------------------------------------
530 if ($op eq "addbiblio") {
531 #-------------------------------------------------------------------------------------
533 my @tags = $input->param('tag');
534 my @subfields = $input->param('subfield');
535 my @values = $input->param('field_value');
536 # build indicator hash.
537 my @ind_tag = $input->param('ind_tag');
538 my @indicator = $input->param('indicator');
539 if (C4::Context->preference('TemplateEncoding') eq "iso-8859-1") {
540 $record = TransformHtmlToMarc($dbh,\@tags,\@subfields,\@values,\@indicator,\@ind_tag);
542 my $xml = TransformHtmlToXml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag);
543 $record=MARC::Record->new_from_xml($xml,C4::Context->preference('TemplateEncoding'),C4::Context->preference('marcflavour'));
544 # warn "MARC :".$record->as_formatted;
547 # check for a duplicate
548 my ($duplicatebiblionumber,$duplicatebiblionumber,$duplicatetitle) = FindDuplicate($record) if ($op eq "addbiblio") && (!$is_a_modif);
549 my $confirm_not_duplicate = $input->param('confirm_not_duplicate');
550 # it is not a duplicate (determined either by Koha itself or by user checking it's not a duplicate)
551 if (!$duplicatebiblionumber or $confirm_not_duplicate) {
552 # MARC::Record built => now, record in DB
556 ModBiblioframework($biblionumber,$frameworkcode);
557 ModBiblio($record,$biblionumber,$frameworkcode);
560 ($biblionumber,$oldbibitemnum) = AddBiblio($record,$frameworkcode);
562 # now, redirect to additem page
563 print $input->redirect("additem.pl?biblionumber=$biblionumber&frameworkcode=$frameworkcode");
566 # it may be a duplicate, warn the user and do nothing
567 build_tabs ($template, $record, $dbh,$encoding);
570 biblionumber => $biblionumber,
571 biblionumtagfield => $biblionumtagfield,
572 biblionumtagsubfield => $biblionumtagsubfield,
573 biblioitemnumtagfield => $biblioitemnumtagfield,
574 biblioitemnumtagsubfield => $biblioitemnumtagsubfield,
575 biblioitemnumber => $biblioitemnumber,
576 duplicatebiblionumber => $duplicatebiblionumber,
577 duplicatebibid => $duplicatebiblionumber,
578 duplicatetitle => $duplicatetitle,
581 #--------------------------------------------------------------------------
582 } elsif ($op eq "addfield") {
583 #--------------------------------------------------------------------------
584 my $addedfield = $input->param('addfield_field');
585 my $cntrepeatfield=$input->param('repeat_field');
586 $cntrepeatfield=1 unless ($cntrepeatfield);
587 my $tagaddfield_subfield = $input->param('addfield_subfield');
588 my @tags = $input->param('tag');
589 my @subfields = $input->param('subfield');
590 my @values = $input->param('field_value');
591 # build indicator hash.
592 my @ind_tag = $input->param('ind_tag');
593 my @indicator = $input->param('indicator');
594 my $xml = TransformHtmlToXml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag);
596 if (C4::Context->preference('TemplateEncoding') eq "iso-8859-1") {
598 for (my $i=0;$i<=$#ind_tag;$i++) {
599 $indicators{$ind_tag[$i]} = $indicator[$i];
601 $record = TransformHtmlToMarc($dbh,\@tags,\@subfields,\@values,%indicators);
603 my $xml = TransformHtmlToXml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag);
604 $record=MARC::Record->new_from_xml($xml,C4::Context->preference('TemplateEncoding'),C4::Context->preference('marcflavour'));
606 for (my $i=1;$i<=$cntrepeatfield;$i++){
607 my $field = MARC::Field->new("$addedfield",'','',"$tagaddfield_subfield" => "");
608 $record->append_fields($field);
610 #warn "result : ".$record->as_formatted;
611 build_tabs ($template, $record, $dbh,$encoding);
614 biblionumber => $biblionumber,
615 biblionumtagfield => $biblionumtagfield,
616 biblionumtagsubfield => $biblionumtagsubfield,
617 biblioitemnumtagfield => $biblioitemnumtagfield,
618 biblioitemnumtagsubfield => $biblioitemnumtagsubfield,
619 biblioitemnumber => $biblioitemnumber );
620 } elsif ($op eq "delete") {
621 #-----------------------------------------------------------------------------
622 my $error = &DelBiblio($biblionumber);
624 warn "ERROR when DELETING BIBLIO $biblionumber : $error";
625 print "Content-Type: text/html\n\n<html><body><h1>ERROR when DELETING BIBLIO $biblionumber : $error</h1></body></html>";
627 print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=/cgi-bin/koha/catalogue/search.pl?type=intranet\"></html>";
630 #----------------------------------------------------------------------------
632 #----------------------------------------------------------------------------
633 # If we're in a duplication case, we have to set to "" the biblionumber
634 # as we'll save the biblio as a new one.
635 if ($op eq "duplicate")
639 #FIXME: it's kind of silly to go from MARC::Record to MARC::File::XML and then back again just to fix the encoding
641 my $uxml = $record->as_xml;
642 MARC::Record::default_record_format("UNIMARC") if (C4::Context->preference("marcflavour") eq "UNIMARC");
643 my $urecord = MARC::Record::new_from_xml($uxml, 'UTF-8');
646 build_tabs ($template, $record, $dbh,$encoding);
649 biblionumber => $biblionumber,
650 biblionumtagfield => $biblionumtagfield,
651 biblionumtagsubfield => $biblionumtagsubfield,
652 biblioitemnumtagfield => $biblioitemnumtagfield,
653 biblioitemnumtagsubfield => $biblioitemnumtagsubfield,
654 biblioitemnumber => $biblioitemnumber,
657 $template->param( title => $record->title() ) if ($record ne "-1");
659 frameworkcode => $frameworkcode,
660 itemtype => $frameworkcode, # HINT: if the library has itemtype = framework, itemtype is auto filled !
661 hide_marc => C4::Context->preference('hide_marc'),
662 intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
663 intranetstylesheet => C4::Context->preference("intranetstylesheet"),
664 IntranetNav => C4::Context->preference("IntranetNav"),
665 advancedMARCEditor => C4::Context->preference("advancedMARCEditor"),
667 output_html_with_http_headers $input, $cookie, $template->output;