X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fpart_pkg.cgi;h=65eca6cf406254c8de542d48c0d427c79737a19d;hb=7c370a4579d1ed8b81dba2fb5fae9978b283b49e;hp=7e67c833a6c2f4882fbfb2fe36574cab242495ab;hpb=91dbe4c3834f38d428367d9a1e2c6cf9ea9d84a4;p=freeside.git diff --git a/httemplate/edit/part_pkg.cgi b/httemplate/edit/part_pkg.cgi index 7e67c833a..65eca6cf4 100755 --- a/httemplate/edit/part_pkg.cgi +++ b/httemplate/edit/part_pkg.cgi @@ -48,6 +48,7 @@ 'recur_cost' => 'Recur cost', 'pay_weight' => 'Payment weight', 'credit_weight' => 'Credit weight', + 'agent_pkgpartid' => 'External ID', 'agentnum' => 'Agent', 'setup_fee' => 'Setup fee', 'setup_show_zero' => 'Show zero setup', @@ -59,6 +60,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', @@ -198,8 +200,15 @@ { type => 'tablebreak-tr-title', value => 'Cost tracking', #better name? }, - { field=>'setup_cost', type=>'money', }, - { field=>'recur_cost', type=>'money', }, + + ( $curuser->access_right('Edit package definition costs') + ? ( { field=>'setup_cost', type=>'money', }, + { field=>'recur_cost', type=>'money', }, + ) + : ( { field=>'setup_cost', type=>'fixed', }, + { field=>'recur_cost', type=>'fixed', }, + ) + ), ( $conf->exists('part_pkg-delay_start') ? ( { type => 'tablebreak-tr-title', @@ -223,28 +232,50 @@ }, }, + ($fcc_opts ? ( + { type => 'tablebreak-tr-title', + value => 'FCC Form 477 information', + }, + { field => 'fcc_options_string', + type => 'input-fcc_options', + curr_value_callback => sub { + my ($cgi, $part_pkg, $fref) = @_; + if ( $cgi->param('fcc_options_string') ) { + # error redirect + return $cgi->param('fcc_options_string'); + } + my %hash; + %hash = $part_pkg->fcc_options + if ($part_pkg->pkgpart); + return encode_json(\%hash); + }, + }, + ) : () + ), + + { type => 'tablebreak-tr-title', + value => 'External Links', #better name? + }, + { field=>'agent_pkgpartid', type=>'text', size=>21 }, + { type => 'tablebreak-tr-title', value => 'Line-item revenue recogition', #better name? }, { field=>'pay_weight', type=>'text', size=>6 }, { field=>'credit_weight', type=>'text', size=>6 }, - ( $conf->exists('cust_pkg-show_fcc_voice_grade_equivalent') - ? ( - { type => 'tablebreak-tr-title', - value => 'FCC Form 477 information', - }, - { field=>'fcc_voip_class', - type=>'select-voip_class', - }, - { field=>'fcc_ds0s', type=>'text', size=>6 }, - ) - : () - ), - - { 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', @@ -285,6 +316,7 @@ ? "AND pkgpart != $pkgpart" : '' }, + 'label_callback' => sub { shift->pkg_comment_only }, 'm2_label' => 'Include line item(s) from package', 'm2m_method' => 'bill_part_pkg_link', 'm2m_dstcol' => 'dst_pkgpart', @@ -311,6 +343,7 @@ ? "AND pkgpart != $pkgpart" : '' }, + 'label_callback' => sub { shift->pkg_comment_only }, 'm2_label' => 'Include services of package: ', 'm2m_method' => 'svc_part_pkg_link', 'm2m_dstcol' => 'dst_pkgpart', @@ -327,6 +360,7 @@ }, { 'field' => 'supp_dst_pkgpart', 'type' => 'select-part_pkg', + 'label_callback' => sub { shift->pkg_comment_only }, 'm2_label' => 'When ordering package, also order', 'm2m_method' => 'supp_part_pkg_link', 'm2m_dstcol' => 'dst_pkgpart', @@ -374,6 +408,8 @@ my $agent_clone_extra_sql = my $conf = new FS::Conf; my $taxproducts = $conf->exists('enable_taxproducts'); +my $fcc_opts = $conf->exists('part_pkg-show_fcc_options'); + my @locales = grep { ! /^en_/i } $conf->config('available-locales'); #should filter from the default locale lang instead of en_ my %locale_labels = map { ( $_ => 'Package -- '. FS::Locales->description($_) ) @@ -684,6 +720,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 { @@ -773,13 +831,15 @@ my $javascript = <<'END'; var plan = what.options[what.selectedIndex].value; - var term_table = document.getElementById('TableNumber7') // XXX NOT ROBUST + var term_table = document.getElementById('TableNumber8') // XXX NOT ROBUST if ( plan == 'flat' || plan == 'prorate' || plan == 'subscription' ) { //term_table.disabled = false; - term_table.style.visibility = ''; + //term_table.style.visibility = ''; + term_table.style.display = ''; } else { //term_table.disabled = true; - term_table.style.visibility = 'hidden'; + //term_table.style.visibility = 'hidden'; + term_table.style.display = 'none'; } var currency_regex = /^(setup|recur)_fee_[A-Z]{3}$/; @@ -888,11 +948,16 @@ my $html_bottom = sub { foreach my $field ( grep $_ !~ /^(setup|recur)_fee$/, @fields ) { - if(!exists($href->{$field})) { + if(!exists($href->{$field})) { # shouldn't happen warn "nonexistent part_pkg option: '$field'\n"; next; } + if ( exists($href->{$field}->{display_if}) ) { + my %args = ( 'plan' => $layer ); # anything else? + my $display = &{ $href->{$field}->{display_if} }(%args); + next if !$display; + } $html .= ''. $href->{$field}{'name'}. ''; @@ -917,7 +982,17 @@ my $html_bottom = sub { ? ' CHECKED' : '' ). '>'; - + + } elsif ( $href->{$field}{'type'} eq 'select-rate' ) { + + $html .= include('/elements/select-rate.html', + 'field' => $layer.'__'.$field, + 'curr_value' => $options{$field}, + map { $_ => $href->{$field}{$_} } + grep { $_ !~ /^(name|type)$/ } + keys %{ $href->{$field} } + ); + } elsif ( $href->{$field}{'type'} =~ /^select/ ) { $html .= '