diff options
author | Mark Wells <mark@freeside.biz> | 2014-02-18 22:04:12 -0800 |
---|---|---|
committer | Mark Wells <mark@freeside.biz> | 2014-02-18 22:04:24 -0800 |
commit | 30e2dfd524a3f52445cbca6bc2cd1962dce7eb04 (patch) | |
tree | 2f54d7d1e316d4e0ab3137848e46ea8dfceb4a37 /httemplate/edit/part_fee.html | |
parent | 3c7fd3e7d40f2c946b2fcf63c63d595c82fcae22 (diff) |
non-package fees, phase 1, #25899
Diffstat (limited to 'httemplate/edit/part_fee.html')
-rw-r--r-- | httemplate/edit/part_fee.html | 141 |
1 files changed, 141 insertions, 0 deletions
diff --git a/httemplate/edit/part_fee.html b/httemplate/edit/part_fee.html new file mode 100644 index 000000000..dada23360 --- /dev/null +++ b/httemplate/edit/part_fee.html @@ -0,0 +1,141 @@ +<& elements/edit.html, + 'name_singular' => 'fee definition', + 'table' => 'part_fee', + 'labels' => { + 'feepart' => 'Fee definition', + 'itemdesc' => 'Description', + 'comment' => 'Comment (customer-hidden)', + 'classnum' => 'Package class', + 'taxable' => 'This fee is taxable', + 'disabled' => 'Disable this fee', + 'taxclass' => 'Tax class name', + 'taxproductnum' => 'Tax product', + 'pay_weight' => 'Payment weight', + 'credit_weight' => 'Credit weight', + 'agentnum' => 'Agent', + 'amount' => 'Flat fee amount', + 'percent' => 'Percentage of invoice amount', + 'basis' => 'Based on', + 'setuprecur' => 'Report this fee as', + 'minimum' => 'Minimum fee', + 'maximum' => 'Maximum fee', + 'limit_credit' => 'Limit to customer credit balance', + %locale_labels + }, + 'fields' => \@fields, + 'edit_callback' => $edit_callback, + 'error_callback' => $error_callback, +&> +<%init> +my $curuser = $FS::CurrentUser::CurrentUser; +my $acl_edit = $curuser->access_right('Edit fee definitions'); +my $acl_edit_global = $curuser->access_right('Edit global fee definitions'); +die "access denied" + unless $acl_edit or $acl_edit_global; + +my $conf = FS::Conf->new; +my @tax_fields; +if ( $conf->exists('enable_taxproducts') ) { + @tax_fields = ( + { field => 'taxproductnum', type => 'select-taxproduct' } + ); +} else { + @tax_fields = ( + { field => 'taxable', type => 'checkbox', value => 'Y' }, + ); + push ( + { field => 'taxclass', type => 'select-taxclass' }, + ) if $conf->exists('enable_taxclasses'); +} + +my $default_locale = $conf->config('locale') || 'en_US'; +my @locales = grep {$_ ne $default_locale} $conf->config('available-locales'); +# duplicates edit/part_pkg.cgi, yuck +my $n = 0; +my (@locale_fields, %locale_labels); +foreach (@locales) { + push @locale_fields, + { field => 'feepartmsgnum'. $n, type => 'hidden' }, + { field => 'feepartmsgnum'. $n. '_locale', type => 'hidden' }, + { field => 'feepartmsgnum'. $n. '_itemdesc', type => 'text', size => 40 }, + ; + $locale_labels{ 'feepartmsgnum'.$n.'_itemdesc' } = + 'Description—' . FS::Locales->description($_); + $n++; +} + +my @fields = ( + + { field => 'itemdesc', type => 'text', size => 40, }, + @locale_fields, + + { field => 'comment', type => 'text', size => 40, }, + + { field => 'agentnum', + type => 'select-agent', + disable_empty => !$acl_edit_global, + empty_label => '(global)', + }, + + { field => 'classnum', + type => 'select-pkg_class', + }, + + { field => 'disabled', + type => 'checkbox', + value => 'Y', + }, + + { field => 'setuprecur', + type => 'select', + options => [ 'setup', 'recur' ], + labels => { 'setup' => 'a setup fee', + 'recur' => 'a recurring charge' }, + }, + + { type => 'justtitle', value => 'Fee calculation' }, + { field => 'amount', type => 'money', }, + { field => 'percent', type => 'percentage', }, + + { field => 'basis', + type => 'select', + options => [ 'charged', 'owed' ], + labels => { 'charged' => 'amount charged', + 'owed' => 'balance due', }, + }, + + { field => 'minimum', type => 'money', }, + { field => 'maximum', type => 'money', }, + { field => 'limit_credit', + type => 'checkbox', + value => 'Y' }, + + { type => 'justtitle', value => 'Taxation' }, + + @tax_fields, +); + +my $edit_callback = sub { + my ($cgi, $obj, $fields, $opt) = @_; + my %existing_locales; + if ( $obj->feepart ) { + %existing_locales = map { $_->locale => $_ } $obj->part_fee_msgcat; + } + my $n = 0; + foreach (@locales) { + $obj->set('feepartmsgnum'.$n.'_locale', $_); + # load the existing itemdescs + if ( my $msgcat = $existing_locales{$_} ) { + $obj->set('feepartmsgnum'.$n, $msgcat->feepartmsgnum); + $obj->set('feepartmsgnum'.$n.'_itemdesc', $msgcat->itemdesc); + } + # then override that with the CGI param if there is one + if ( my $itemdesc = $cgi->param('feepartmsgnum'.$n.'_itemdesc') ) { + $obj->set('feepartmsgnum'.$n.'_itemdesc', $itemdesc); + } + $n++; + } +}; + +my $error_callback = $edit_callback; +</%init> |