diff options
| author | Mark Wells <mark@freeside.biz> | 2012-07-13 15:35:18 -0700 |
|---|---|---|
| committer | Mark Wells <mark@freeside.biz> | 2012-07-13 15:35:18 -0700 |
| commit | 7d3df502cdb301418ea0659e39c48bd940591d4c (patch) | |
| tree | 7adcda893bba4c7b32d43fe0ce3d1bb0f7891056 /FS | |
| parent | e5b69b895a09ab1e1904ffb06d910956ca7a7e4e (diff) | |
XLSX format for spreadsheet download, #17971
Diffstat (limited to 'FS')
| -rw-r--r-- | FS/FS/Conf.pm | 11 | ||||
| -rw-r--r-- | FS/FS/Mason.pm | 3 | ||||
| -rw-r--r-- | FS/FS/access_user.pm | 32 |
3 files changed, 46 insertions, 0 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index 2645a42af..81e1b7d8c 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -5097,6 +5097,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 5ab9534ab..7d81fb64a 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 075733a68..c5ce1afd1 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 |
