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 warn "AVANT : ".$record->as_formatted;
112 if ($record->subfield(100,'a')) {
113 my $f100a=$record->subfield(100,'a');
114 my $f100 = $record->field(100);
115 my $f100temp = $f100->as_string;
116 $record->delete_field($f100);
117 if (length($f100temp)>28) {
118 substr($f100temp,26,2,"50");
119 $f100->update('a' => $f100temp);
120 my $f100 = MARC::Field->new('100','','','a' => $f100temp);
121 $record->insert_fields_ordered($f100);
124 warn "APRES: ".$record->as_formatted;
125 if (ref($record) eq undef) {
128 if (C4::Context->preference("z3950NormalizeAuthor") and C4::Context->preference("z3950AuthorAuthFields")){
129 my ($tag,$subfield) = GetMarcFromKohaField("biblio.author");
130 # my $summary = C4::Context->preference("z3950authortemplate");
131 my $auth_fields = C4::Context->preference("z3950AuthorAuthFields");
132 my @auth_fields= split /,/,$auth_fields;
134 #warn $record->as_formatted;
135 if ($record->field($tag)){
136 foreach my $tmpfield ($record->field($tag)->subfields){
137 # foreach my $subfieldcode ($tmpfield->subfields){
138 my $subfieldcode=shift @$tmpfield;
139 my $subfieldvalue=shift @$tmpfield;
141 $field->add_subfields("$subfieldcode"=>$subfieldvalue) if ($subfieldcode ne $subfield);
143 $field=MARC::Field->new($tag,"","",$subfieldcode=>$subfieldvalue) if ($subfieldcode ne $subfield);
146 # warn $field->as_formatted;
149 $record->delete_field($record->field($tag));
150 foreach my $fieldtag (@auth_fields){
151 next unless ($record->field($fieldtag));
152 my $lastname = $record->field($fieldtag)->subfield('a');
153 my $firstname= $record->field($fieldtag)->subfield('b');
154 my $title = $record->field($fieldtag)->subfield('c');
155 my $number= $record->field($fieldtag)->subfield('d');
157 # $field->add_subfields("$subfield"=>"[ ".ucfirst($title).ucfirst($firstname)." ".$number." ]");
158 $field->add_subfields("$subfield"=>ucfirst($title)." ".ucfirst($firstname)." ".$number);
160 # $field->add_subfields("$subfield"=>"[ ".ucfirst($firstname).", ".ucfirst($lastname)." ]");
161 $field->add_subfields("$subfield"=>ucfirst($firstname).", ".ucfirst($lastname));
164 $record->insert_fields_ordered($field);
166 return $record,$encoding;
173 =item build_authorized_values_list
177 sub build_authorized_values_list ($$$$$) {
178 my($tag, $subfield, $value, $dbh,$authorised_values_sth) = @_;
180 my @authorised_values;
183 # builds list, depending on authorised value...
186 if ($tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
187 my $sth=$dbh->prepare("select branchcode,branchname from branches order by branchname");
189 push @authorised_values, ""
190 unless ($tagslib->{$tag}->{$subfield}->{mandatory});
192 while (my ($branchcode,$branchname) = $sth->fetchrow_array) {
193 push @authorised_values, $branchcode;
194 $authorised_lib{$branchcode}=$branchname;
198 } elsif ($tagslib->{$tag}->{$subfield}->{authorised_value} eq "itemtypes") {
199 my $sth=$dbh->prepare("select itemtype,description from itemtypes order by description");
201 push @authorised_values, "" unless ($tagslib->{$tag}->{$subfield}->{mandatory});
203 while (my ($itemtype,$description) = $sth->fetchrow_array) {
204 push @authorised_values, $itemtype;
205 $authorised_lib{$itemtype}=$description;
207 $value=$itemtype unless ($value);
209 #---- "true" authorised value
211 $authorised_values_sth->execute($tagslib->{$tag}->{$subfield}->{authorised_value});
213 push @authorised_values, "" unless ($tagslib->{$tag}->{$subfield}->{mandatory});
215 while (my ($value,$lib) = $authorised_values_sth->fetchrow_array) {
216 push @authorised_values, $value;
217 $authorised_lib{$value}=$lib;
220 return CGI::scrolling_list( -name => 'field_value',
221 -values => \@authorised_values,
223 -labels => \%authorised_lib,
231 builds the <input ...> entry for a subfield.
235 sub create_input () {
236 my ($tag,$subfield,$value,$i,$tabloop,$rec,$authorised_values_sth) = @_;
237 # must be encoded as utf-8 before it reaches the editor
239 #$value = encode('utf-8', $value);
240 $value =~ s/"/"/g;
241 # if there is no value provided but a default value in parameters, get it
243 $value = $tagslib->{$tag}->{$subfield}->{defaultvalue};
244 # get today date & replace YYYY, MM, DD if provided in the default value
245 my ($year,$month,$day) = Today();
246 $month = sprintf("%02d",$month);
247 $day = sprintf("%02d",$day);
248 $value =~ s/YYYY/$year/g;
249 $value =~ s/MM/$month/g;
250 $value =~ s/DD/$day/g;
253 my $dbh = C4::Context->dbh;
255 $subfield_data{tag}=$tag;
256 $subfield_data{subfield}=$subfield;
257 $subfield_data{marc_lib}="<span id=\"error$i\" title=\"".$tagslib->{$tag}->{$subfield}->{lib}."\">".substr($tagslib->{$tag}->{$subfield}->{lib},0,15)."</span>";
258 $subfield_data{marc_lib_plain}=$tagslib->{$tag}->{$subfield}->{lib};
259 $subfield_data{tag_mandatory}=$tagslib->{$tag}->{mandatory};
260 $subfield_data{mandatory}=$tagslib->{$tag}->{$subfield}->{mandatory};
261 $subfield_data{repeatable}=$tagslib->{$tag}->{$subfield}->{repeatable};
262 $subfield_data{kohafield}=$tagslib->{$tag}->{$subfield}->{kohafield};
263 $subfield_data{index} = $i;
264 $subfield_data{visibility} = "display:none" unless (($tagslib->{$tag}->{$subfield}->{hidden}%2==0) or $value ne ''); #check parity
265 # it's an authorised field
266 if ($tagslib->{$tag}->{$subfield}->{authorised_value}) {
267 $subfield_data{marc_value}= build_authorized_values_list($tag, $subfield, $value, $dbh,$authorised_values_sth);
268 # it's a thesaurus / authority field
269 } elsif ($tagslib->{$tag}->{$subfield}->{authtypecode}) {
270 $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>";
271 # it's a plugin field
272 } elsif ($tagslib->{$tag}->{$subfield}->{'value_builder'}) {
273 # opening plugin. Just check wether we are on a developper computer on a production one
274 # (the cgidir differs)
275 my $cgidir = C4::Context->intranetdir ."/cgi-bin/cataloguing/value_builder";
276 unless (opendir(DIR, "$cgidir")) {
277 $cgidir = C4::Context->intranetdir."/cataloguing/value_builder";
279 my $plugin=$cgidir."/".$tagslib->{$tag}->{$subfield}->{'value_builder'};
281 my $extended_param = plugin_parameters($dbh,$rec,$tagslib,$i,$tabloop);
282 my ($function_name,$javascript) = plugin_javascript($dbh,$rec,$tagslib,$i,$tabloop);
283 $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";
284 # it's an hidden field
285 } elsif ($tag eq '') {
286 $subfield_data{marc_value}="<input onblur=\"this.style.backgroundColor='#ffffff';\" onfocus=\"this.style.backgroundColor='#ffff00'; \" tabindex=\"1\" type=\"hidden\" name=\"field_value\" value=\"$value\">";
287 } elsif ($tagslib->{$tag}->{$subfield}->{'hidden'}) {
288 $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\" >";
289 # it's a standard field
291 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")) {
292 $subfield_data{marc_value}="<textarea tabindex=\"1\" name=\"field_value\" cols=\"70\" rows=\"5\" >$value</textarea>";
294 $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\">"; #"
297 return \%subfield_data;
300 sub build_tabs ($$$$) {
301 my($template, $record, $dbh,$encoding) = @_;
306 my $authorised_values_sth = $dbh->prepare("select authorised_value,lib
307 from authorised_values
308 where category=? order by lib");
310 # in this array, we will push all the 10 tabs
311 # to avoid having 10 tabs in the template : they will all be in the same BIG_LOOP
314 # loop through each tab 0 through 9
315 for (my $tabloop = 0; $tabloop <= 9; $tabloop++) {
317 foreach my $tag (sort(keys (%{$tagslib}))) {
319 # if MARC::Record is not empty => use it as master loop, then add missing subfields that should be in the tab.
320 # if MARC::Record is empty => use tab as master loop.
321 if ($record ne -1 && ($record->field($tag) || $tag eq '000')) {
324 @fields = $record->field($tag);
326 push @fields,$record->leader();
328 foreach my $field (@fields) {
331 my ($value,$subfield);
333 $value=$field->data();
339 next if ($tagslib->{$tag}->{$subfield}->{tab} ne $tabloop);
340 next if ($tagslib->{$tag}->{$subfield}->{kohafield} eq 'biblio.biblionumber');
341 push(@subfields_data, &create_input($tag,$subfield,$value,$i,$tabloop,$record,$authorised_values_sth));
344 my @subfields=$field->subfields();
345 foreach my $subfieldcount (0..$#subfields) {
346 my $subfield=$subfields[$subfieldcount][0];
347 my $value=$subfields[$subfieldcount][1];
348 next if (length $subfield !=1);
349 next if ($tagslib->{$tag}->{$subfield}->{tab} ne $tabloop);
350 push(@subfields_data, &create_input($tag,$subfield,$value,$i,$tabloop,$record,$authorised_values_sth));
354 # now, loop again to add parameter subfield that are not in the MARC::Record
355 foreach my $subfield (sort( keys %{$tagslib->{$tag}})) {
356 next if (length $subfield !=1);
357 next if ($tagslib->{$tag}->{$subfield}->{tab} ne $tabloop);
359 next if (($tagslib->{$tag}->{$subfield}->{hidden}<=-4) or ($tagslib->{$tag}->{$subfield}->{hidden}>=5) ); #check for visibility flag
360 next if (defined($field->subfield($subfield)));
361 push(@subfields_data, &create_input($tag,$subfield,'',$i,$tabloop,$record,$authorised_values_sth));
364 if ($#subfields_data >= 0) {
366 $tag_data{tag} = $tag;
367 $tag_data{tag_lib} = $tagslib->{$tag}->{lib};
368 $tag_data{repeatable} = $tagslib->{$tag}->{repeatable};
369 $tag_data{indicator} = $record->field($tag)->indicator(1). $record->field($tag)->indicator(2) if ($tag>=10);
370 $tag_data{subfield_loop} = \@subfields_data;
372 $tag_data{fixedfield} = 1;
375 push (@loop_data, \%tag_data);
377 # If there is more than 1 field, add an empty hidden field as separator.
378 if ($#fields >=1 && $#loop_data >=0 && $loop_data[$#loop_data]->{'tag'} eq $tag) {
381 push(@subfields_data, &create_input('','','',$i,$tabloop,$record,$authorised_values_sth));
383 $tag_data{tag_lib} = '';
384 $tag_data{indicator} = '';
385 $tag_data{subfield_loop} = \@subfields_data;
387 $tag_data{fixedfield} = 1;
389 push (@loop_data, \%tag_data);
393 # if breeding is empty
396 foreach my $subfield (sort(keys %{$tagslib->{$tag}})) {
397 next if (length $subfield !=1);
398 next if (($tagslib->{$tag}->{$subfield}->{hidden}<=-5) or ($tagslib->{$tag}->{$subfield}->{hidden}>=4) ); #check for visibility flag
399 next if ($tagslib->{$tag}->{$subfield}->{tab} ne $tabloop);
400 push(@subfields_data, &create_input($tag,$subfield,'',$i,$tabloop,$record,$authorised_values_sth));
403 if ($#subfields_data >= 0) {
405 $tag_data{tag} = $tag;
406 $tag_data{tag_lib} = $tagslib->{$tag}->{lib};
407 $tag_data{repeatable} = $tagslib->{$tag}->{repeatable};
408 $tag_data{indicator} = $indicator;
409 $tag_data{subfield_loop} = \@subfields_data;
410 $tag_data{tagfirstsubfield} = $tag_data{subfield_loop}[0];
412 $tag_data{fixedfield} = 1;
414 push (@loop_data, \%tag_data);
418 if ($#loop_data >=0) {
420 $big_loop_line{number}=$tabloop;
421 $big_loop_line{innerloop}=\@loop_data;
422 push @BIG_LOOP,\%big_loop_line;
424 # $template->param($tabloop."XX" =>\@loop_data);
426 $template->param(BIG_LOOP => \@BIG_LOOP);
431 sub build_hidden_data () {
432 # build hidden data =>
433 # we store everything, even if we show only requested subfields.
437 foreach my $tag (keys %{$tagslib}) {
438 my $previous_tag = '';
440 # loop through each subfield
441 foreach my $subfield (keys %{$tagslib->{$tag}}) {
442 next if ($subfield eq 'lib');
443 next if ($subfield eq 'tab');
444 next if ($subfield eq 'mandatory');
445 next if ($subfield eq 'repeatable');
446 next if ($tagslib->{$tag}->{$subfield}->{'tab'} ne "-1");
448 $subfield_data{marc_lib}=$tagslib->{$tag}->{$subfield}->{lib};
449 $subfield_data{marc_mandatory}=$tagslib->{$tag}->{$subfield}->{mandatory};
450 $subfield_data{marc_repeatable}=$tagslib->{$tag}->{$subfield}->{repeatable};
451 $subfield_data{marc_value}="<input type=\"hidden\" name=\"field_value[]\">";
452 push(@loop_data, \%subfield_data);
459 # ========================
461 #=========================
463 my $error = $input->param('error');
464 my $biblionumber=$input->param('biblionumber'); # if biblionumber exists, it's a modif, not a new biblio.
465 my $breedingid = $input->param('breedingid');
466 my $z3950 = $input->param('z3950');
467 my $op = $input->param('op');
468 my $frameworkcode = $input->param('frameworkcode');
469 my $dbh = C4::Context->dbh;
471 $frameworkcode = &GetFrameworkCode($biblionumber) if ($biblionumber and not ($frameworkcode));
473 $frameworkcode='' if ($frameworkcode eq 'Default');
474 my ($template, $loggedinuser, $cookie)
475 = get_template_and_user({template_name => "cataloguing/addbiblio.tmpl",
478 authnotrequired => 0,
479 flagsrequired => {editcatalogue => 1},
483 #Getting the list of all frameworks
484 my $queryfwk =$dbh->prepare("select frameworktext, frameworkcode from biblio_framework");
489 push @select_fwk,"Default";
490 $select_fwk{"Default"} = "Default";
491 while (my ($description, $fwk) =$queryfwk->fetchrow) {
492 push @select_fwk, $fwk;
493 $select_fwk{$fwk} = $description;
495 $curfwk=$frameworkcode;
496 my $framework=CGI::scrolling_list(
497 -name => 'Frameworks',
500 -OnChange => 'Changefwk(this);',
501 -values => \@select_fwk,
502 -labels => \%select_fwk,
505 $template->param( framework => $framework, breedingid => $breedingid);
507 $tagslib = &GetMarcStructure(1,$frameworkcode);
510 $record = GetMarcBiblio( $biblionumber ) if ($biblionumber);
511 ($record,$encoding) = MARCfindbreeding($dbh,$breedingid) if ($breedingid);
513 # warn "biblionumber : $biblionumber = ".$record->as_formatted;
515 my ($biblionumtagfield,$biblionumtagsubfield);
516 my ($biblioitemnumtagfield,$biblioitemnumtagsubfield,$bibitem,$biblioitemnumber);
519 # if it's a modif, retrieve bibli and biblioitem numbers for the future modification of old-DB.
520 ($biblionumtagfield,$biblionumtagsubfield) = &GetMarcFromKohaField("biblio.biblionumber",$frameworkcode);
521 ($biblioitemnumtagfield,$biblioitemnumtagsubfield) = &GetMarcFromKohaField("biblioitems.biblioitemnumber",$frameworkcode);
522 # search biblioitems value
523 my $sth=$dbh->prepare("select biblioitemnumber from biblioitems where biblionumber=?");
524 $sth->execute($biblionumber);
525 ($biblioitemnumber) = $sth->fetchrow;
527 #-------------------------------------------------------------------------------------
528 if ($op eq "addbiblio") {
529 #-------------------------------------------------------------------------------------
531 my @tags = $input->param('tag');
532 my @subfields = $input->param('subfield');
533 my @values = $input->param('field_value');
534 # build indicator hash.
535 my @ind_tag = $input->param('ind_tag');
536 my @indicator = $input->param('indicator');
537 if (C4::Context->preference('TemplateEncoding') eq "iso-8859-1") {
538 $record = TransformHtmlToMarc($dbh,\@tags,\@subfields,\@values,\@indicator,\@ind_tag);
540 my $xml = TransformHtmlToXml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag);
541 $record=MARC::Record->new_from_xml($xml,C4::Context->preference('TemplateEncoding'),C4::Context->preference('marcflavour'));
542 # warn "MARC :".$record->as_formatted;
545 # check for a duplicate
546 my ($duplicatebiblionumber,$duplicatebiblionumber,$duplicatetitle) = FindDuplicate($record) if ($op eq "addbiblio") && (!$is_a_modif);
547 my $confirm_not_duplicate = $input->param('confirm_not_duplicate');
548 # it is not a duplicate (determined either by Koha itself or by user checking it's not a duplicate)
549 if (!$duplicatebiblionumber or $confirm_not_duplicate) {
550 # MARC::Record built => now, record in DB
554 ModBiblioframework($biblionumber,$frameworkcode);
555 ModBiblio($record,$biblionumber,$frameworkcode);
558 ($biblionumber,$oldbibitemnum) = AddBiblio($record,$frameworkcode);
560 # now, redirect to additem page
561 print $input->redirect("/cgi-bin/koha/cataloguing/additem.pl?biblionumber=$biblionumber&frameworkcode=$frameworkcode");
564 # it may be a duplicate, warn the user and do nothing
565 build_tabs ($template, $record, $dbh,$encoding);
568 biblionumber => $biblionumber,
569 biblionumtagfield => $biblionumtagfield,
570 biblionumtagsubfield => $biblionumtagsubfield,
571 biblioitemnumtagfield => $biblioitemnumtagfield,
572 biblioitemnumtagsubfield => $biblioitemnumtagsubfield,
573 biblioitemnumber => $biblioitemnumber,
574 duplicatebiblionumber => $duplicatebiblionumber,
575 duplicatebibid => $duplicatebiblionumber,
576 duplicatetitle => $duplicatetitle,
579 #--------------------------------------------------------------------------
580 } elsif ($op eq "addfield") {
581 #--------------------------------------------------------------------------
582 my $addedfield = $input->param('addfield_field');
583 my $cntrepeatfield=$input->param('repeat_field');
584 $cntrepeatfield=1 unless ($cntrepeatfield);
585 my $tagaddfield_subfield = $input->param('addfield_subfield');
586 my @tags = $input->param('tag');
587 my @subfields = $input->param('subfield');
588 my @values = $input->param('field_value');
589 # build indicator hash.
590 my @ind_tag = $input->param('ind_tag');
591 my @indicator = $input->param('indicator');
592 my $xml = TransformHtmlToXml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag);
594 if (C4::Context->preference('TemplateEncoding') eq "iso-8859-1") {
596 for (my $i=0;$i<=$#ind_tag;$i++) {
597 $indicators{$ind_tag[$i]} = $indicator[$i];
599 $record = TransformHtmlToMarc($dbh,\@tags,\@subfields,\@values,%indicators);
601 my $xml = TransformHtmlToXml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag);
602 $record=MARC::Record->new_from_xml($xml,C4::Context->preference('TemplateEncoding'),C4::Context->preference('marcflavour'));
604 for (my $i=1;$i<=$cntrepeatfield;$i++){
605 my $field = MARC::Field->new("$addedfield",'','',"$tagaddfield_subfield" => "");
606 $record->append_fields($field);
608 #warn "result : ".$record->as_formatted;
609 build_tabs ($template, $record, $dbh,$encoding);
612 biblionumber => $biblionumber,
613 biblionumtagfield => $biblionumtagfield,
614 biblionumtagsubfield => $biblionumtagsubfield,
615 biblioitemnumtagfield => $biblioitemnumtagfield,
616 biblioitemnumtagsubfield => $biblioitemnumtagsubfield,
617 biblioitemnumber => $biblioitemnumber );
618 } elsif ($op eq "delete") {
619 #-----------------------------------------------------------------------------
620 my $error = &DelBiblio($biblionumber);
622 warn "ERROR when DELETING BIBLIO $biblionumber : $error";
623 print "Content-Type: text/html\n\n<html><body><h1>ERROR when DELETING BIBLIO $biblionumber : $error</h1></body></html>";
625 print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=/cgi-bin/koha/catalogue/search.pl?type=intranet\"></html>";
628 #----------------------------------------------------------------------------
630 #----------------------------------------------------------------------------
631 # If we're in a duplication case, we have to set to "" the biblionumber
632 # as we'll save the biblio as a new one.
633 if ($op eq "duplicate")
637 #FIXME: it's kind of silly to go from MARC::Record to MARC::File::XML and then back again just to fix the encoding
639 my $uxml = $record->as_xml;
640 MARC::Record::default_record_format("UNIMARC") if (C4::Context->preference("marcflavour") eq "UNIMARC");
641 my $urecord = MARC::Record::new_from_xml($uxml, 'UTF-8');
644 build_tabs ($template, $record, $dbh,$encoding);
647 biblionumber => $biblionumber,
648 biblionumtagfield => $biblionumtagfield,
649 biblionumtagsubfield => $biblionumtagsubfield,
650 biblioitemnumtagfield => $biblioitemnumtagfield,
651 biblioitemnumtagsubfield => $biblioitemnumtagsubfield,
652 biblioitemnumber => $biblioitemnumber,
655 $template->param( title => $record->title() ) if ($record ne "-1");
657 frameworkcode => $frameworkcode,
658 itemtype => $frameworkcode, # HINT: if the library has itemtype = framework, itemtype is auto filled !
659 hide_marc => C4::Context->preference('hide_marc'),
660 intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
661 intranetstylesheet => C4::Context->preference("intranetstylesheet"),
662 IntranetNav => C4::Context->preference("IntranetNav"),
663 advancedMARCEditor => C4::Context->preference("advancedMARCEditor"),
665 output_html_with_http_headers $input, $cookie, $template->output;