Bug 19074: Fix category display in Batch patron modification.
[koha.git] / tools / marc_modification_templates.pl
index 4f9323f..c115429 100755 (executable)
@@ -18,7 +18,7 @@
 
 use Modern::Perl;
 
-use CGI;
+use CGI qw ( -utf8 );
 
 use C4::Auth;
 use C4::Koha;
@@ -36,13 +36,13 @@ my ($template, $loggedinuser, $cookie)
             query => $cgi,
             type => "intranet",
             authnotrequired => 0,
-            flagsrequired => { tools => 'marc_modfication_templates' },
+            flagsrequired => { tools => 'marc_modification_templates' },
             debug => 1,
     });
 
 if ( $op eq "create_template" ) {
   $template_id = '' unless $cgi->param('duplicate_current_template');
-  $template_id = AddModificationTemplate( $cgi->param('template_name'), $template_id );
+  $template_id = AddModificationTemplate( scalar $cgi->param('template_name'), $template_id );
 
 } elsif ( $op eq "delete_template" ) {
 
@@ -103,27 +103,23 @@ if ( $op eq "create_template" ) {
     }
 
 } elsif ( $op eq "delete_action" ) {
-  DelModificationTemplateAction( $cgi->param('mmta_id') );
+  DelModificationTemplateAction( scalar $cgi->param('mmta_id') );
 
 } elsif ( $op eq "move_action" ) {
 
-  MoveModificationTemplateAction( $cgi->param('mmta_id'), $cgi->param('where') );
+  MoveModificationTemplateAction( scalar $cgi->param('mmta_id'), scalar $cgi->param('where') );
 
 }
 
 my @templates = GetModificationTemplates( $template_id );
 
-unless ( $template_id ) {
-  $template_id = $templates[0]->{'template_id'};
-  @templates = GetModificationTemplates( $template_id );
-}
-
 my @actions = GetModificationTemplateActions( $template_id );
 foreach my $action ( @actions ) {
   $action->{'action_delete_field'} = ( $action->{'action'} eq 'delete_field' );
   $action->{'action_update_field'} = ( $action->{'action'} eq 'update_field' );
   $action->{'action_move_field'} = ( $action->{'action'} eq 'move_field' );
   $action->{'action_copy_field'} = ( $action->{'action'} eq 'copy_field' );
+  $action->{'action_copy_and_replace_field'} = ( $action->{'action'} eq 'copy_and_replace_field' );
 
   $action->{'conditional_if'} = ( $action->{'conditional'} eq 'if' );
   $action->{'conditional_unless'} = ( $action->{'conditional'} eq 'unless' );