|
Lines 46-86
unless ($authenticated) {
Link Here
|
| 46 |
exit 0; |
46 |
exit 0; |
| 47 |
} |
47 |
} |
| 48 |
|
48 |
|
| 49 |
my $frameworkcode = $input->param('frameworkcode') || 'default'; |
49 |
my $frameworkcode = $input->param('frameworkcode') || ''; |
|
|
50 |
my $framework_name = $frameworkcode || 'default'; |
| 50 |
my $action = $input->param('action') || 'export'; |
51 |
my $action = $input->param('action') || 'export'; |
| 51 |
|
52 |
|
| 52 |
## Exporting |
53 |
## Exporting |
| 53 |
if ($action eq 'export' && $input->request_method() eq 'GET') { |
54 |
if ($action eq 'export' && $input->request_method() eq 'GET') { |
| 54 |
my $strXml = ''; |
55 |
my $strXml = ''; |
| 55 |
my $format = $input->param('type_export_' . $frameworkcode); |
56 |
my $format = $input->param('type_export_' . $framework_name); |
| 56 |
if ($frameworkcode eq 'default') { |
57 |
ExportFramework($frameworkcode, \$strXml, $format); |
| 57 |
ExportFramework('', \$strXml, $format); |
|
|
| 58 |
} else { |
| 59 |
ExportFramework($frameworkcode, \$strXml, $format); |
| 60 |
} |
| 61 |
|
58 |
|
| 62 |
if ($format eq 'csv') { |
59 |
if ($format eq 'csv') { |
| 63 |
# CSV file |
60 |
# CSV file |
| 64 |
|
61 |
|
| 65 |
# Correctly set the encoding to output plain text in UTF-8 |
62 |
# Correctly set the encoding to output plain text in UTF-8 |
| 66 |
binmode(STDOUT,':encoding(UTF-8)'); |
63 |
binmode(STDOUT,':encoding(UTF-8)'); |
| 67 |
print $input->header(-type => 'application/vnd.ms-excel', -attachment => 'export_' . $frameworkcode . '.csv'); |
64 |
print $input->header(-type => 'application/vnd.ms-excel', -attachment => 'export_' . $framework_name . '.csv'); |
| 68 |
print $strXml; |
65 |
print $strXml; |
| 69 |
} elsif ($format eq 'excel') { |
66 |
} elsif ($format eq 'excel') { |
| 70 |
# Excel-xml file |
67 |
# Excel-xml file |
| 71 |
print $input->header(-type => 'application/excel', -attachment => 'export_' . $frameworkcode . '.xml'); |
68 |
print $input->header(-type => 'application/excel', -attachment => 'export_' . $framework_name . '.xml'); |
| 72 |
print $strXml; |
69 |
print $strXml; |
| 73 |
} else { |
70 |
} else { |
| 74 |
# ODS file |
71 |
# ODS file |
| 75 |
my $strODS = ''; |
72 |
my $strODS = ''; |
| 76 |
createODS($strXml, 'en', \$strODS); |
73 |
createODS($strXml, 'en', \$strODS); |
| 77 |
print $input->header(-type => 'application/vnd.oasis.opendocument.spreadsheet', -attachment => 'export_' . $frameworkcode . '.ods'); |
74 |
print $input->header(-type => 'application/vnd.oasis.opendocument.spreadsheet', -attachment => 'export_' . $framework_name . '.ods'); |
| 78 |
print $strODS; |
75 |
print $strODS; |
| 79 |
} |
76 |
} |
| 80 |
## Importing |
77 |
## Importing |
| 81 |
} elsif ($input->request_method() eq 'POST') { |
78 |
} elsif ($input->request_method() eq 'POST') { |
| 82 |
my $ok = -1; |
79 |
my $ok = -1; |
| 83 |
my $fieldname = 'file_import_' . $frameworkcode; |
80 |
my $fieldname = 'file_import_' . $framework_name; |
| 84 |
my $filename = $input->param($fieldname); |
81 |
my $filename = $input->param($fieldname); |
| 85 |
# upload the input file |
82 |
# upload the input file |
| 86 |
if ($filename && $filename =~ /\.(csv|ods|xml)$/i) { |
83 |
if ($filename && $filename =~ /\.(csv|ods|xml)$/i) { |