fix for 2311: linking images to authorized values - need a "no image" option
[koha.git] / admin / marc_subfields_structure.pl
index ae3d94b..3f82b99 100755 (executable)
@@ -103,13 +103,13 @@ if ( $op eq 'add_form' ) {
     while ( ( my $field ) = $sth2->fetchrow_array ) {
         push @kohafields, "biblio." . $field;
     }
-    my $sth2 = $dbh->prepare("SHOW COLUMNS from biblioitems");
+    $sth2 = $dbh->prepare("SHOW COLUMNS from biblioitems");
     $sth2->execute;
     while ( ( my $field ) = $sth2->fetchrow_array ) {
         if ( $field eq 'notes' ) { $field = 'bnotes'; }
         push @kohafields, "biblioitems." . $field;
     }
-    my $sth2 = $dbh->prepare("SHOW COLUMNS from items");
+    $sth2 = $dbh->prepare("SHOW COLUMNS from items");
     $sth2->execute;
     while ( ( my $field ) = $sth2->fetchrow_array ) {
         push @kohafields, "items." . $field;
@@ -126,6 +126,7 @@ if ( $op eq 'add_form' ) {
     }
     push( @authorised_values, "branches" );
     push( @authorised_values, "itemtypes" );
+    push( @authorised_values, "cn_source" );
 
     # build thesaurus categories list
     $sth2->finish;
@@ -205,7 +206,7 @@ if ( $op eq 'add_form' ) {
           . "<input type=\"hidden\" name=\"tagsubfield\" value=\""
           . $data->{'tagsubfield'}
           . "\" id=\"tagsubfield\" />";
-        $row_data{subfieldcode} = $data->{'tagsubfield'};
+        $row_data{subfieldcode} = $data->{'tagsubfield'} eq '@'?'_':$data->{'tagsubfield'};
         $row_data{liblibrarian} = CGI::escapeHTML( $data->{'liblibrarian'} );
         $row_data{libopac}      = CGI::escapeHTML( $data->{'libopac'} );
         $row_data{seealso}      = CGI::escapeHTML( $data->{'seealso'} );
@@ -280,6 +281,7 @@ if ( $op eq 'add_form' ) {
     # add more_subfields empty lines for add if needed
     for ( my $j = 1 ; $j <= 1 ; $j++ ) {
         my %row_data;    # get a fresh hash for the row data
+        $row_data{'new_subfield'} = 1;
         $row_data{'subfieldcode'} = '';
 
         $row_data{tab} = CGI::scrolling_list(
@@ -382,8 +384,7 @@ if ( $op eq 'add_form' ) {
     $template->param( 'heading-edit-subfields-p' => 1 );
     $template->param(
         action   => "Edit subfields",
-        tagfield =>
-"<input type=\"hidden\" name=\"tagfield\" value=\"$tagfield\" />$tagfield",
+        tagfield => $tagfield,
         loop           => \@loop_data,
         more_subfields => $more_subfields,
         more_tag       => $tagfield
@@ -417,6 +418,7 @@ elsif ( $op eq 'add_validate' ) {
         my $tagfield    = $input->param('tagfield');
         my $tagsubfield = $tagsubfield[$i];
         $tagsubfield = "@" unless $tagsubfield ne '';
+        $tagsubfield = "@" if $tagsubfield eq '_';
         my $liblibrarian     = $liblibrarian[$i];
         my $libopac          = $libopac[$i];
         my $repeatable       = $input->param("repeatable$i") ? 1 : 0;
@@ -558,12 +560,12 @@ else {    # DEFAULT
     if ( $offset > 0 ) {
         my $prevpage = $offset - $pagesize;
         $template->param(
-            prev => "<a href=\"$script_name?offset=$prevpage\">" );
+            prev => "<a href=\"$script_name?offset=$prevpage\&tagfield=$tagfield\&frameworkcode=$frameworkcode \">" );
     }
     if ( $offset + $pagesize < $count ) {
         my $nextpage = $offset + $pagesize;
         $template->param(
-            next => "<a href=\"$script_name?offset=$nextpage\">" );
+            next => "<a href=\"$script_name?offset=$nextpage\&tagfield=$tagfield\&frameworkcode=$frameworkcode \">" );
     }
 }    #---- END $OP eq DEFAULT