summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2012-07-13 15:33:43 -0700
committerMark Wells <mark@freeside.biz>2012-07-13 15:33:43 -0700
commit8ce2c1f11378b22966ec536f11898b4708a40237 (patch)
tree6b3a23fa6c52dcd930fef9ff092f0af2de6eb137 /FS
parent15db7ad6e6ea2e57784368eec80e4aae54358f77 (diff)
XLSX format for spreadsheet download, #17971
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/Conf.pm11
-rw-r--r--FS/FS/Mason.pm3
-rw-r--r--FS/FS/access_user.pm32
3 files changed, 46 insertions, 0 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index b4ce0baaa..f081c1796 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -5204,6 +5204,17 @@ and customer address. Include units.',
'description' => 'If set, automatically log users out of the backoffice after this many minutes.',
'type' => 'text',
},
+
+ {
+ 'key' => 'spreadsheet_format',
+ 'section' => 'UI',
+ 'description' => 'Default format for spreadsheet download.',
+ 'type' => 'select',
+ 'select_hash' => [
+ 'XLS' => 'XLS (Excel 97/2000/XP)',
+ 'XLSX' => 'XLSX (Excel 2007+)',
+ ],
+ },
{ key => "apacheroot", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
{ key => "apachemachine", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
diff --git a/FS/FS/Mason.pm b/FS/FS/Mason.pm
index e26a4b747..51edd97cc 100644
--- a/FS/FS/Mason.pm
+++ b/FS/FS/Mason.pm
@@ -91,6 +91,9 @@ if ( -e $addl_handler_use_file ) {
use Text::CSV_XS;
use Spreadsheet::WriteExcel;
use Spreadsheet::WriteExcel::Utility;
+ use Excel::Writer::XLSX;
+ use Excel::Writer::XLSX::Utility;
+
use Business::CreditCard 0.30; #for mask-aware cardtype()
use NetAddr::IP;
use Net::Ping;
diff --git a/FS/FS/access_user.pm b/FS/FS/access_user.pm
index 5d5cc126c..4d72c2ee7 100644
--- a/FS/FS/access_user.pm
+++ b/FS/FS/access_user.pm
@@ -511,6 +511,38 @@ sub default_customer_view {
}
+=item spreadsheet_format
+
+Returns a hashref of this user's Excel spreadsheet download settings:
+'extension' (xls or xlsx), 'class' (Spreadsheet::WriteExcel or
+Excel::Writer::XLSX), and 'mime_type'.
+
+=cut
+
+my %formats = (
+ XLS => {
+ extension => '.xls',
+ class => 'Spreadsheet::WriteExcel',
+ mime_type => 'application/vnd.ms-excel',
+ },
+ XLSX => {
+ extension => '.xlsx',
+ class => 'Excel::Writer::XLSX',
+ mime_type => # it's on wikipedia, it must be true
+ 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
+ }
+);
+
+sub spreadsheet_format {
+ my $self = shift;
+
+ my $f = $self->option('spreadsheet_format')
+ || $conf->config('spreadsheet_format')
+ || 'XLS';
+
+ $formats{$f};
+}
+
=item is_system_user
Returns true if this user has the name of a known system account. These