diff options
author | Ivan Kohler <ivan@freeside.biz> | 2014-01-04 23:31:16 -0800 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2014-01-04 23:31:16 -0800 |
commit | 013646e6629fc94b4cda03c495aa56677f2de381 (patch) | |
tree | 05b085bdd194e04f9db78a8feab44018071b4ded /httemplate/edit/part_pkg.cgi | |
parent | 0ce4ba640f3c216a37d78296a0e9d4dd262df2d9 (diff) |
time/data/etc. unit pricing add-ons, RT#24392
Diffstat (limited to 'httemplate/edit/part_pkg.cgi')
-rwxr-xr-x | httemplate/edit/part_pkg.cgi | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/httemplate/edit/part_pkg.cgi b/httemplate/edit/part_pkg.cgi index 7f8a70710..23de7c146 100755 --- a/httemplate/edit/part_pkg.cgi +++ b/httemplate/edit/part_pkg.cgi @@ -59,6 +59,7 @@ } $conf->config('currencies') ), + 'usagepricepart' => ' ', 'discountnum' => 'Offer discounts for longer terms', 'bill_dst_pkgpart' => 'Include line item(s) from package', 'svc_dst_pkgpart' => 'Include services of package', @@ -245,6 +246,16 @@ { type => 'columnend' }, + { type => 'tablebreak-tr-title', + value => 'Usage pricing add-ons', #better name? just 'Usage pricing' ? there's also CDR usage pricing, RADIUS usage pricing, etc :/ + }, + { 'field' => 'usagepricepart', + 'type' => 'part_pkg_usageprice', + 'o2m_table' => 'part_pkg_usageprice', + 'm2_label' => ' ', + 'm2_error_callback' => $usageprice_error_callback, + }, + { 'type' => $report_option ? 'tablebreak-tr-title' : 'hidden', 'value' => 'Optional report classes', @@ -684,6 +695,28 @@ my $discount_error_callback = sub { $cgi->param; }; +my $usageprice_error_callback = sub { + my( $cgi, $object ) = @_; + map { + if ( /^usagepricepart(\d+)_price$/ + && $cgi->param("usagepricepart$1_price") ) + { + new FS::part_pkg_usageprice { + 'usagepricepart' => $cgi->param("usagepricepart$1"), + 'pkgpart' => $object->pkgpart, + 'price' => scalar($cgi->param("usagepricepart$1_price")), + #'currency + 'action' => scalar($cgi->param("usagepricepart$1_action")), + 'target' => scalar($cgi->param("usagepricepart$1_target")), + 'amount' => scalar($cgi->param("usagepricepart$1_amount")), + }; + } else { + (); + } + } + $cgi->param; +}; + my $m2_error_callback_maker = sub { my $link_type = shift; #yay closures return sub { |