diff options
author | Mark Wells <mark@freeside.biz> | 2013-09-27 17:19:36 -0700 |
---|---|---|
committer | Mark Wells <mark@freeside.biz> | 2013-09-27 17:19:36 -0700 |
commit | eb3bd392a89b8b666dc512951e78913c05b98810 (patch) | |
tree | 22670bdf99b0a473abb708f6f5c55cbfa2f0c249 /httemplate/browse/invoice_conf.html | |
parent | e3012c0751dad6710ea35b6d074b551bffdad09b (diff) |
invoice configurations, #24723
Diffstat (limited to 'httemplate/browse/invoice_conf.html')
-rw-r--r-- | httemplate/browse/invoice_conf.html | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/httemplate/browse/invoice_conf.html b/httemplate/browse/invoice_conf.html new file mode 100644 index 000000000..c8fd1bffb --- /dev/null +++ b/httemplate/browse/invoice_conf.html @@ -0,0 +1,70 @@ +<& elements/browse.html, + 'title' => 'Invoice modes', + 'name_singular' => 'configuration', + 'menubar' => \@menubar, + 'query' => { + 'select' => $select, + 'table' => 'invoice_conf', + 'addl_from' => ' JOIN invoice_mode USING (modenum)', + 'extra_sql' => ' WHERE '.$curuser->agentnums_sql( + 'table' => 'invoice_mode', + 'null_right' => ['Edit global templates'], + ), + 'order_by' => q( ORDER BY modename asc, COALESCE(locale,'') asc), + }, + 'count_query' => 'SELECT COUNT(*) FROM invoice_conf JOIN invoice_mode USING (modenum)', + 'header' => [ 'Name', 'Agent', 'Locale', 'Overrides', ], + 'fields' => [ $modename, + $agent, + $locale_label, + $overrides, + ], + 'align' => 'llcl', + 'links' => [ '', '', $link ], + 'disable_maxselect' => 1, +&> +<%init> + +my $curuser = $FS::CurrentUser::CurrentUser; + +die "access denied" + unless $curuser->access_right([ 'View templates', 'View global templates', + 'Edit templates', 'Edit global templates', ]); + +my @overrides = grep {$_ ne 'modenum' and $_ ne 'confnum'} FS::invoice_conf->fields; +my $select = join(',', 'modename', 'agentnum', 'confnum', 'invoice_conf.*'); + +my @menubar = (); +if ( $curuser->access_right(['Edit templates', 'Edit global templates']) ) { + push @menubar, 'Add a new invoice mode' => $p.'edit/invoice_conf.html'; +} + +my $locale_style = 'font-size:0.8em; padding:3px; background-color:'; + +my $last_modenum = 0; +my $modename = sub { + return '' if $_[0]->modenum == $last_modenum; + $_[0]->modename; +}; + +my $agent = sub { + return '' if $_[0]->modenum == $last_modenum; + $last_modenum = $_[0]->modenum; + $_[0]->agentnum ? FS::agent->by_key($_[0]->agentnum)->agent : '(global)'; +}; + +my $locale_label = sub { + my $l = $_[0]->locale; + $l ? +{ FS::Locales->locale_info($l) }->{'label'} : '(default)'; +}; + +my $overrides = sub { + my $invoice_conf = shift; + [ map { [ { data => $_ } ] } + grep { length $invoice_conf->get($_) } + @overrides + ], +}; + +my $link = [ $p.'edit/invoice_conf.html?', 'confnum' ]; +</%init> |