Bug 3150: (follow-up) Send list and cart emails immediately again
[koha-ffzg.git] / tools / csv-profiles.pl
index a9b8525..2883f71 100755 (executable)
@@ -37,14 +37,13 @@ This script allow the user to define a new profile for CSV export
 use Modern::Perl;
 use Encode;
 
-use C4::Auth;
+use C4::Auth qw( get_template_and_user );
 use C4::Context;
-use C4::Output;
+use C4::Output qw( output_html_with_http_headers );
 use CGI qw ( -utf8 );
-use C4::Koha;
 use Koha::CsvProfiles;
 
-my $input            = new CGI;
+my $input            = CGI->new;
 my $export_format_id = $input->param('export_format_id');
 my $op               = $input->param('op') || 'list';
 my @messages;
@@ -53,9 +52,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
     {   template_name   => "tools/csv-profiles.tt",
         query           => $input,
         type            => "intranet",
-        authnotrequired => 0,
         flagsrequired   => { tools => 'manage_csv_profiles' },
-        debug           => 1,
     }
 );
 
@@ -72,6 +69,10 @@ if ( $op eq 'add_form' ) {
     my $profile     = $input->param("profile");
     my $description = $input->param("description");
     my $type        = $input->param("type");
+    my $used_for    =
+        $type eq "marc"
+      ? $input->param("used_for_marc")
+      : $input->param("used_for_sql");
     my $content =
         $type eq "marc"
       ? $input->param("marc_content")
@@ -80,6 +81,7 @@ if ( $op eq 'add_form' ) {
     my $field_separator    = $input->param("field_separator");
     my $subfield_separator = $input->param("subfield_separator");
     my $encoding           = $input->param("encoding");
+    my $staff_only         = $input->param("staff_only") ? 1 : 0;
 
     if ($export_format_id) {
         my $csv_profile = Koha::CsvProfiles->find($export_format_id)
@@ -92,6 +94,8 @@ if ( $op eq 'add_form' ) {
         $csv_profile->subfield_separator($subfield_separator);
         $csv_profile->encoding($encoding);
         $csv_profile->type($type);
+        $csv_profile->used_for($used_for);
+        $csv_profile->staff_only($staff_only);
         eval { $csv_profile->store; };
 
         if ($@) {
@@ -109,6 +113,8 @@ if ( $op eq 'add_form' ) {
                 subfield_separator => $subfield_separator,
                 encoding           => $encoding,
                 type               => $type,
+                used_for           => $used_for,
+                staff_only         => $staff_only
             }
         );
         eval { $csv_profile->store; };