Bug 7356 - Fix various typos and mis-spellings
[koha.git] / cataloguing / addbiblio.pl
index ba10332..568007e 100755 (executable)
@@ -159,7 +159,7 @@ sub MARCfindbreeding {
 
 =cut
 
-sub build_authorized_values_list ($$$$$$$) {
+sub build_authorized_values_list {
     my ( $tag, $subfield, $value, $dbh, $authorised_values_sth,$index_tag,$index_subfield ) = @_;
 
     my @authorised_values;
@@ -252,7 +252,7 @@ sub build_authorized_values_list ($$$$$$$) {
 
 =cut
 
-sub CreateKey(){
+sub CreateKey {
     return int(rand(1000000));
 }
 
@@ -263,7 +263,7 @@ sub CreateKey(){
 
 =cut
 
-sub GetMandatoryFieldZ3950($){
+sub GetMandatoryFieldZ3950 {
     my $frameworkcode = shift;
     my @isbn   = GetMarcFromKohaField('biblioitems.isbn',$frameworkcode);
     my @title  = GetMarcFromKohaField('biblio.title',$frameworkcode);
@@ -349,6 +349,10 @@ sub create_input {
            $value eq '' &&
            !$tdef->{$subfield}->{mandatory} &&
            !$tdef->{mandatory};
+    # expand all subfields of 773 if there is a host item provided in the input
+    $subfield_data{visibility} ="" if ($tag eq 773 and $cgi->param('hostitemnumber'));
+
+
     # it's an authorised field
     if ( $tagslib->{$tag}->{$subfield}->{authorised_value} ) {
         $subfield_data{marc_value} =
@@ -410,7 +414,7 @@ sub create_input {
     }
     elsif ( $tagslib->{$tag}->{$subfield}->{'value_builder'} ) {
 
-        # opening plugin. Just check wether we are on a developper computer on a production one
+        # opening plugin. Just check whether we are on a developer computer on a production one
         # (the cgidir differs)
         my $cgidir = C4::Context->intranetdir . "/cgi-bin/cataloguing/value_builder";
         unless ( opendir( DIR, "$cgidir" ) ) {
@@ -532,7 +536,7 @@ sub format_indicator {
     return $ind_value;
 }
 
-sub build_tabs ($$$$$) {
+sub build_tabs {
     my ( $template, $record, $dbh, $encoding,$input ) = @_;
 
     # fill arrays
@@ -696,7 +700,7 @@ sub build_tabs ($$$$$) {
                            # always include in the form regardless of the hidden setting - bug 2206
                     next
                       if ( $tagslib->{$tag}->{$subfield}->{tab} ne $tabloop );
-                    push(
+                       push(
                         @subfields_data,
                         &create_input(
                             $tag, $subfield, '', $index_tag, $tabloop, $record,
@@ -834,6 +838,8 @@ my $mode          = $input->param('mode');
 my $frameworkcode = $input->param('frameworkcode');
 my $redirect      = $input->param('redirect');
 my $dbh           = C4::Context->dbh;
+my $hostbiblionumber = $input->param('hostbiblionumber');
+my $hostitemnumber = $input->param('hostitemnumber');
 
     
 my $userflags = 'edit_catalogue';
@@ -904,6 +910,14 @@ if (($biblionumber) && !($breedingid)){
 if ($breedingid) {
     ( $record, $encoding ) = MARCfindbreeding( $breedingid ) ;
 }
+#populate hostfield if hostbiblionumber is available
+if ($hostbiblionumber){
+       my $marcflavour = C4::Context->preference("marcflavour");
+       $record=MARC::Record->new();
+       $record->leader('');
+        my $field = PrepHostMarcField($hostbiblionumber, $hostitemnumber,$marcflavour);
+       $record->append_fields($field);
+}
 
 $is_a_modif = 0;
     
@@ -1037,10 +1051,7 @@ elsif ( $op eq "delete" ) {
         $biblionumber = "";
     }
 
-    if ( $record eq -1 ) {
-        $record = TransformHtmlToMarc( $input );
-    }
-    else {
+    if ( $record ne -1 ) {
 #FIXME: it's kind of silly to go from MARC::Record to MARC::File::XML and then back again just to fix the encoding
         eval {
             my $uxml = $record->as_xml;
@@ -1058,20 +1069,18 @@ elsif ( $op eq "delete" ) {
         biblioitemnumtagfield    => $biblioitemnumtagfield,
         biblioitemnumtagsubfield => $biblioitemnumtagsubfield,
         biblioitemnumber         => $biblioitemnumber,
+       hostbiblionumber        => $hostbiblionumber,
+       hostitemnumber          => $hostitemnumber
     );
 }
 
 $template->param( title => $record->title() ) if ( $record ne "-1" );
-if (C4::Context->preference("marcflavour") eq "MARC21"){
-    $template->param(MARC21 => 1);
-}
-
-
 $template->param(
     popup => $mode,
     frameworkcode => $frameworkcode,
     itemtype => $frameworkcode,
-    borrowernumber => $loggedinuser
+    borrowernumber => $loggedinuser, 
+    marcflavour => C4::Context->preference("marcflavour"),
 );
 
 output_html_with_http_headers $input, $cookie, $template->output;