Followup updating translation process
[koha.git] / admin / marctagstructure.pl
index 94fafd0..b930271 100755 (executable)
@@ -24,7 +24,6 @@ use C4::Auth;
 use C4::Koha;
 use C4::Context;
 use C4::Output;
-use C4::Interface::CGI::Output;
 use C4::Context;
 
 
@@ -38,6 +37,7 @@ my $frameworkinfo = getframeworkinfo($frameworkcode);
 my $searchfield=$input->param('searchfield');
 $searchfield=0 unless $searchfield;
 $searchfield=~ s/\,//g;
+my $last_searchfield=$input->param('searchfield');
 
 my $offset=$input->param('offset') || 0;
 my $op = $input->param('op') || '';
@@ -118,15 +118,14 @@ if ($op eq 'add_form') {
        my $authorised_value  = CGI::scrolling_list(-name=>'authorised_value',
                        -values=> \@authorised_values,
                        -size=>1,
-                       -tabindex=>'',
                        -id=>"authorised_value",
                        -multiple=>0,
                        -default => $data->{'authorised_value'},
                        );
 
+  $template->param(searchfield => $searchfield) if ($searchfield);
        if ($searchfield) {
-               $template->param(action => "Modify tag",
-                                                               searchfield => $searchfield);
+               $template->param(action => "Modify tag");
                $template->param('heading-modify-tag-p' => 1);
        } else {
                $template->param(action => "Add tag");
@@ -138,13 +137,11 @@ if ($op eq 'add_form') {
                        repeatable => CGI::checkbox(-name=>'repeatable',
                                                -checked=> $data->{'repeatable'}?'checked':'',
                                                -value=> 1,
-                                               -tabindex=>'',
                                                -label => '',
                                                -id=> 'repeatable'),
                        mandatory => CGI::checkbox(-name => 'mandatory',
                                                -checked => $data->{'mandatory'}?'checked':'',
                                                -value => 1,
-                                               -tabindex=>'',
                                                -label => '',
                                                -id => 'mandatory'),
                        authorised_value => $authorised_value,
@@ -154,25 +151,40 @@ if ($op eq 'add_form') {
 ################## ADD_VALIDATE ##################################
 # called by add_form, used to insert/modify data in DB
 } elsif ($op eq 'add_validate') {
-       $sth=$dbh->prepare("replace marc_tag_structure (tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value,frameworkcode) values (?,?,?,?,?,?,?)");
        my $tagfield       =$input->param('tagfield');
        my $liblibrarian  = $input->param('liblibrarian');
        my $libopac       =$input->param('libopac');
        my $repeatable =$input->param('repeatable');
        my $mandatory =$input->param('mandatory');
        my $authorised_value =$input->param('authorised_value');
-       unless (C4::Context->config('demo') eq 1) {
-               $sth->execute($tagfield,
-                                                       $liblibrarian,
-                                                       $libopac,
-                                                       $repeatable?1:0,
-                                                       $mandatory?1:0,
-                                                       $authorised_value,
-                                                       $frameworkcode
-                                                       );
+    if ($input->param('modif')) {
+        $sth=$dbh->prepare("UPDATE marc_tag_structure SET liblibrarian=? ,libopac=? ,repeatable=? ,mandatory=? ,authorised_value=? WHERE frameworkcode=? AND tagfield=?");
+         unless (C4::Context->config('demo') eq 1) {
+            $sth->execute(  $liblibrarian,
+                            $libopac,
+                            $repeatable?1:0,
+                            $mandatory?1:0,
+                            $authorised_value,
+                            $frameworkcode,
+                            $tagfield
+                                );
+        }
+        $sth->finish;
+       } else {
+        $sth=$dbh->prepare("INSERT INTO marc_tag_structure (tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value,frameworkcode) values (?,?,?,?,?,?,?)");
+        unless (C4::Context->config('demo') eq 1) {
+            $sth->execute($tagfield,
+                                $liblibrarian,
+                                $libopac,
+                                $repeatable?1:0,
+                                $mandatory?1:0,
+                                $authorised_value,
+                                $frameworkcode
+                                );
+        }
+        $sth->finish;
        }
-       $sth->finish;
-       print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=marctagstructure.pl?searchfield=$tagfield&frameworkcode=$frameworkcode\"></html>";
+    print $input->redirect("/cgi-bin/koha/admin/marctagstructure.pl?searchfield=$tagfield&frameworkcode=$frameworkcode");
        exit;
                                                                                                        # END $OP eq ADD_VALIDATE
 ################## DELETE_CONFIRM ##################################
@@ -194,6 +206,9 @@ if ($op eq 'add_form') {
                $dbh->do("delete from marc_tag_structure where tagfield='$searchfield' and frameworkcode='$frameworkcode'");
                $dbh->do("delete from marc_subfield_structure where tagfield='$searchfield' and frameworkcode='$frameworkcode'");
        }
+       $template->param(searchfield => $searchfield,
+                                                       frameworkcode => $frameworkcode,
+                                                       );
                                                                                                        # END $OP eq DELETE_CONFIRMED
 ################## ITEMTYPE_CREATE ##################################
 # called automatically if an unexisting  frameworkis selected
@@ -259,9 +274,9 @@ if ($op eq 'add_form') {
                        $row_data{repeatable} = $results[$i]->{'mts_repeatable'};
                        $row_data{mandatory} = $results[$i]->{'mts_mandatory'};
                        $row_data{authorised_value} = $results[$i]->{'mts_authorised_value'};
-                       $row_data{subfield_link} ="marc_subfields_structure.pl?op=add_form&tagfield=".$results[$i]->{'mts_tagfield'}."&frameworkcode=".$frameworkcode;
-                       $row_data{edit} = "$script_name?op=add_form&amp;searchfield=".$results[$i]->{'mts_tagfield'}."&frameworkcode=".$frameworkcode;
-                       $row_data{delete} = "$script_name?op=delete_confirm&amp;searchfield=".$results[$i]->{'mts_tagfield'}."&frameworkcode=".$frameworkcode;
+                       $row_data{subfield_link} ="marc_subfields_structure.pl?op=add_form&amp;tagfield=".$results[$i]->{'mts_tagfield'}."&amp;frameworkcode=".$frameworkcode;
+                       $row_data{edit} = "$script_name?op=add_form&amp;searchfield=".$results[$i]->{'mts_tagfield'}."&amp;frameworkcode=".$frameworkcode;
+                       $row_data{delete} = "$script_name?op=delete_confirm&amp;searchfield=".$results[$i]->{'mts_tagfield'}."&amp;frameworkcode=".$frameworkcode;
                        $row_data{toggle} = $toggle;
                        $j=$i;
                        my @internal_loop = ();
@@ -309,9 +324,9 @@ if ($op eq 'add_form') {
                        $row_data{repeatable} = $results->[$i]{'repeatable'};
                        $row_data{mandatory} = $results->[$i]{'mandatory'};
                        $row_data{authorised_value} = $results->[$i]{'authorised_value'};
-                       $row_data{subfield_link} ="marc_subfields_structure.pl?tagfield=".$results->[$i]{'tagfield'}."&frameworkcode=".$frameworkcode;
-                       $row_data{edit} = "$script_name?op=add_form&amp;searchfield=".$results->[$i]{'tagfield'}."&frameworkcode=".$frameworkcode;
-                       $row_data{delete} = "$script_name?op=delete_confirm&amp;searchfield=".$results->[$i]{'tagfield'}."&frameworkcode=".$frameworkcode;
+                       $row_data{subfield_link} ="marc_subfields_structure.pl?tagfield=".$results->[$i]{'tagfield'}."&amp;frameworkcode=".$frameworkcode;
+                       $row_data{edit} = "$script_name?op=add_form&amp;searchfield=".$results->[$i]{'tagfield'}."&amp;frameworkcode=".$frameworkcode;
+                       $row_data{delete} = "$script_name?op=delete_confirm&amp;searchfield=".$results->[$i]{'tagfield'}."&amp;frameworkcode=".$frameworkcode;
                        $row_data{toggle} = $toggle;
                        push(@loop_data, \%row_data);
                }
@@ -337,9 +352,6 @@ if ($op eq 'add_form') {
 } #---- END $OP eq DEFAULT
 
 $template->param(loggeninuser => $loggedinuser,
-               intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
-               intranetstylesheet => C4::Context->preference("intranetstylesheet"),
-               IntranetNav => C4::Context->preference("IntranetNav"),
                );
 output_html_with_http_headers $input, $cookie, $template->output;
 
@@ -376,11 +388,11 @@ sub duplicate_framework {
                $sth_insert->execute($tagfield,$liblibrarian,$libopac,$repeatable,$mandatory,$authorised_value,$newframeworkcode);
        }
 
-       $sth = $dbh->prepare("select frameworkcode,tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,authorised_value,authtypecode,value_builder,seealso from marc_subfield_structure where frameworkcode=?");
+       $sth = $dbh->prepare("select frameworkcode,tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,authorised_value,authtypecode,value_builder,seealso,hidden from marc_subfield_structure where frameworkcode=?");
        $sth->execute($oldframeworkcode);
-       $sth_insert = $dbh->prepare("insert into marc_subfield_structure (frameworkcode,tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,authorised_value,authtypecode,value_builder,seealso) values (?,?,?,?,?,?,?,?,?,?,?,?,?)");
-       while ( my ($frameworkcode, $tagfield, $tagsubfield, $liblibrarian, $libopac, $repeatable, $mandatory, $kohafield, $tab, $authorised_value, $thesaurus_category, $value_builder, $seealso) = $sth->fetchrow) {
-           $sth_insert->execute($newframeworkcode, $tagfield, $tagsubfield, $liblibrarian, $libopac, $repeatable, $mandatory, $kohafield, $tab, $authorised_value, $thesaurus_category, $value_builder, $seealso);
+       $sth_insert = $dbh->prepare("insert into marc_subfield_structure (frameworkcode,tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,authorised_value,authtypecode,value_builder,seealso,hidden) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
+       while ( my ($frameworkcode, $tagfield, $tagsubfield, $liblibrarian, $libopac, $repeatable, $mandatory, $kohafield, $tab, $authorised_value, $thesaurus_category, $value_builder, $seealso,$hidden) = $sth->fetchrow) {
+           $sth_insert->execute($newframeworkcode, $tagfield, $tagsubfield, $liblibrarian, $libopac, $repeatable, $mandatory, $kohafield, $tab, $authorised_value, $thesaurus_category, $value_builder, $seealso, $hidden);
        }
 }