|
|
@ -36,6 +36,7 @@ This script allow the user to define a new profile for CSV export |
|
|
|
|
|
|
|
use strict; |
|
|
|
use Data::Dumper; |
|
|
|
use Encode; |
|
|
|
|
|
|
|
use C4::Auth; |
|
|
|
use C4::Context; |
|
|
@ -59,6 +60,10 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
|
|
|
} |
|
|
|
); |
|
|
|
|
|
|
|
# Getting available encodings list |
|
|
|
my @encodings = Encode->encodings(); |
|
|
|
my @encodings_loop = map{{encoding => $_}} @encodings; |
|
|
|
$template->param(encodings => \@encodings_loop); |
|
|
|
|
|
|
|
my $profile_name = $input->param("profile_name"); |
|
|
|
my $profile_description = $input->param("profile_description"); |
|
|
@ -66,6 +71,7 @@ my $profile_content = $input->param("profile_content"); |
|
|
|
my $csv_separator = $input->param("csv_separator"); |
|
|
|
my $field_separator = $input->param("field_separator"); |
|
|
|
my $subfield_separator = $input->param("subfield_separator"); |
|
|
|
my $encoding = $input->param("encoding"); |
|
|
|
my $action = $input->param("action"); |
|
|
|
my $delete = $input->param("delete"); |
|
|
|
my $id = $input->param("id"); |
|
|
@ -75,17 +81,16 @@ if ($profile_name && $profile_content && $action) { |
|
|
|
my $rows; |
|
|
|
|
|
|
|
if ($action eq "create") { |
|
|
|
my $query = "INSERT INTO export_format(export_format_id, profile, description, marcfields, csv_separator, field_separator, subfield_separator) VALUES (NULL, ?, ?, ?, ?, ?, ?)"; |
|
|
|
my $query = "INSERT INTO export_format(export_format_id, profile, description, marcfields, csv_separator, field_separator, subfield_separator, encoding) VALUES (NULL, ?, ?, ?, ?, ?, ?, ?)"; |
|
|
|
my $sth = $dbh->prepare($query); |
|
|
|
$rows = $sth->execute($profile_name, $profile_description, $profile_content, $csv_separator, $field_separator, $subfield_separator); |
|
|
|
$rows = $sth->execute($profile_name, $profile_description, $profile_content, $csv_separator, $field_separator, $subfield_separator, $encoding); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if ($action eq "edit") { |
|
|
|
my $query = "UPDATE export_format SET description=?, marcfields=?, csv_separator=?, field_separator=?, subfield_separator=? WHERE export_format_id=? LIMIT 1"; |
|
|
|
my $query = "UPDATE export_format SET description=?, marcfields=?, csv_separator=?, field_separator=?, subfield_separator=?, encoding=? WHERE export_format_id=? LIMIT 1"; |
|
|
|
my $sth = $dbh->prepare($query); |
|
|
|
$rows = $sth->execute($profile_description, $profile_content, $csv_separator, $field_separator, $subfield_separator, $profile_name); |
|
|
|
warn "id $id"; |
|
|
|
$rows = $sth->execute($profile_description, $profile_content, $csv_separator, $field_separator, $subfield_separator, $encoding, $profile_name); |
|
|
|
} |
|
|
|
|
|
|
|
if ($action eq "delete") { |
|
|
@ -103,13 +108,12 @@ warn "id $id"; |
|
|
|
|
|
|
|
# If a profile has been selected for modification |
|
|
|
if ($id) { |
|
|
|
my $query = "SELECT export_format_id, profile, description, marcfields, csv_separator, field_separator, subfield_separator FROM export_format WHERE export_format_id = ?"; |
|
|
|
my $query = "SELECT export_format_id, profile, description, marcfields, csv_separator, field_separator, subfield_separator, encoding FROM export_format WHERE export_format_id = ?"; |
|
|
|
my $sth; |
|
|
|
$sth = $dbh->prepare($query); |
|
|
|
|
|
|
|
$sth->execute($id); |
|
|
|
my $selected_profile = $sth->fetchrow_arrayref(); |
|
|
|
warn "value : " . $selected_profile->[4]; |
|
|
|
$template->param( |
|
|
|
selected_profile_id => $selected_profile->[0], |
|
|
|
selected_profile_name => $selected_profile->[1], |
|
|
@ -117,7 +121,8 @@ warn "id $id"; |
|
|
|
selected_profile_marcfields => $selected_profile->[3], |
|
|
|
selected_csv_separator => $selected_profile->[4], |
|
|
|
selected_field_separator => $selected_profile->[5], |
|
|
|
selected_subfield_separator => $selected_profile->[6] |
|
|
|
selected_subfield_separator => $selected_profile->[6], |
|
|
|
selected_encoding => $selected_profile->[7] |
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|