diff options
Diffstat (limited to 'httemplate')
28 files changed, 244 insertions, 116 deletions
diff --git a/httemplate/browse/part_fee.html b/httemplate/browse/part_fee.html index 0370fe06d..482c692d7 100644 --- a/httemplate/browse/part_fee.html +++ b/httemplate/browse/part_fee.html @@ -1,16 +1,16 @@ <& elements/browse.html, - 'title' => 'Fee definitions', - 'name_singular' => 'fee definition', - 'query' => $query, - 'count_query' => $count_query, - 'header' => [ '#', + title => 'Fee definitions', + name_singular => 'fee definition', + query => $query, + count_query => $count_query, + header => [ '#', 'Description', 'Comment', 'Class', 'Amount', 'Tax status', ], - 'fields' => [ 'feepart', + fields => [ 'feepart', 'itemdesc', 'comment', 'classname', @@ -27,6 +27,7 @@ $link, ], align => 'cllccc', + menubar => \@menubar, &> <%init> my $curuser = $FS::CurrentUser::CurrentUser; @@ -64,4 +65,7 @@ my $sub_tax = sub { }; my $link = [ $p.'edit/part_fee.html?', 'feepart' ]; + +my @menubar = ( 'Add a new fee definition', + $p.'edit/part_fee.html' ); </%init> diff --git a/httemplate/config/config-view.cgi b/httemplate/config/config-view.cgi index 864a61279..8472dd68e 100644 --- a/httemplate/config/config-view.cgi +++ b/httemplate/config/config-view.cgi @@ -415,8 +415,10 @@ my @config_items = grep { !defined($locale) or $_->per_locale } my @deleteable = qw( invoice_latexreturnaddress invoice_htmlreturnaddress ); my %deleteable = map { $_ => 1 } @deleteable; -my @sections = qw(required billing invoicing notification UI self-service ticketing network_monitoring username password session shell BIND telephony ); -push @sections, '', 'deprecated'; +my @sections = qw( + required billing invoicing notification UI API self-service ticketing + network_monitoring username password session shell BIND telephony +), '', 'deprecated'; my %section_items = (); foreach my $section (@sections) { diff --git a/httemplate/edit/credit-cust_bill_pkg.html b/httemplate/edit/credit-cust_bill_pkg.html index a5ecb69e3..40faddc46 100644 --- a/httemplate/edit/credit-cust_bill_pkg.html +++ b/httemplate/edit/credit-cust_bill_pkg.html @@ -269,7 +269,8 @@ my @cust_bill_pkg = qsearch({ 'select' => 'cust_bill_pkg.*', 'table' => 'cust_bill_pkg', 'addl_from' => 'LEFT JOIN cust_bill USING (invnum)', - 'extra_sql' => "WHERE custnum = $custnum AND pkgnum != 0", + 'extra_sql' => "WHERE custnum = $custnum ". + "AND (pkgnum != 0 or feepart IS NOT NULL)", 'order_by' => 'ORDER BY invnum ASC, billpkgnum ASC', }); diff --git a/httemplate/edit/part_fee.html b/httemplate/edit/part_fee.html index dada23360..e057a752d 100644 --- a/httemplate/edit/part_fee.html +++ b/httemplate/edit/part_fee.html @@ -14,7 +14,6 @@ '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', @@ -55,8 +54,8 @@ 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, type => 'hidden' }, + { field => 'feepartmsgnum'. $n. '_locale', type => 'hidden', value => $_ }, { field => 'feepartmsgnum'. $n. '_itemdesc', type => 'text', size => 40 }, ; $locale_labels{ 'feepartmsgnum'.$n.'_itemdesc' } = @@ -64,6 +63,19 @@ foreach (@locales) { $n++; } +$n = 0; +my %layer_fields = ( + 'charged' => [ + 'percent' => { label => 'Fraction of invoice total', type => 'percentage', }, + ], + 'owed' => [ + 'percent' => { label => 'Fraction of balance', type => 'percentage', }, + ], + 'usage' => [ + 'usage' => { type => 'part_fee_usage' } + ], +); + my @fields = ( { field => 'itemdesc', type => 'text', size => 40, }, @@ -95,15 +107,23 @@ my @fields = ( { 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', }, + type => 'selectlayers', + options => [ 'charged', 'owed', 'usage' ], + labels => { 'charged' => 'amount charged', + 'owed' => 'balance due', + 'usage' => 'usage charges' }, + layer_fields => \%layer_fields, + layer_values_callback => sub { + my ($cgi, $obj) = @_; + { + 'charged' => { percent => $obj->percent }, + 'owed' => { percent => $obj->percent }, + 'usage' => { usage => [ $obj->part_fee_usage ] }, + } + }, }, - { field => 'minimum', type => 'money', }, { field => 'maximum', type => 'money', }, { field => 'limit_credit', diff --git a/httemplate/edit/process/part_fee.html b/httemplate/edit/process/part_fee.html index 25656e9b0..1fca231ec 100755 --- a/httemplate/edit/process/part_fee.html +++ b/httemplate/edit/process/part_fee.html @@ -1,13 +1,22 @@ <& elements/process.html, - 'debug' => 1, + #'debug' => 1, 'table' => 'part_fee', 'agent_virt' => 1, 'agent_null_right' => 'Edit global fee definitions', 'viewall_dir' => 'browse', - 'process_o2m' => { - 'table' => 'part_fee_msgcat', - 'fields' => [ 'locale', 'itemdesc' ], - }, + 'process_o2m' => [ + { + 'table' => 'part_fee_msgcat', + 'fields' => [ 'locale', 'itemdesc' ], + }, + { + 'table' => 'part_fee_usage', + 'fields' => [ 'classnum', + 'amount', + 'percent' + ], + }, + ], &> <%init> diff --git a/httemplate/elements/email-link.html b/httemplate/elements/email-link.html index 692e5bc2e..2612faabb 100644 --- a/httemplate/elements/email-link.html +++ b/httemplate/elements/email-link.html @@ -1,9 +1,10 @@ % if ( $FS::CurrentUser::CurrentUser->access_right('Bulk send customer notices') ) { -<A HREF="<%$p%>misc/email-customers.html?table=<%$table%>&<%$query%>"><%$label%></A> +<A HREF="<%$p%>misc/email-customers.html?table=<%$table%>&agent_virt_agentnum=<%$agent_virt_agentnum%>&<%$query%>"><%$label%></A> % } <%init> my %opt = @_; my $table = $opt{'table'}; +my $agent_virt_agentnum = $opt{'agent_virt_agentnum'}; my $search_hash = $opt{'search_hash'}; die "'table' required" if !$table; die "'search_hash' required" if !$search_hash; diff --git a/httemplate/elements/tr-part_fee_usage.html b/httemplate/elements/tr-part_fee_usage.html new file mode 100644 index 000000000..00f4e122a --- /dev/null +++ b/httemplate/elements/tr-part_fee_usage.html @@ -0,0 +1,29 @@ +% my $n = 0; +% foreach my $class (@classes) { +% my $pre = "feepartusagenum$n"; +% my $x = $part_fee_usage{$class->classnum} || FS::part_fee_usage->new({}); +<tr> + <td align="right"> + <input type="hidden" name="<%$pre%>" value="<% $x->partfeeusagenum %>"> + <input type="hidden" name="<%$pre%>_classnum" value="<% $class->classnum %>"> + <% $class->classname %>:</td> + <td> + <%$money_char%><input size=4 name="<%$pre%>_amount" \ + value="<% sprintf("%.2f", $x->amount) %>"> + </td> + <td>per call<b> + </b></td> + <td> + <input size=4 name="<%$pre%>_percent" \ + value="<% sprintf("%.1f", $x->percent) %>">% + </td> +</tr> +% $n++; +% } +<%init> +my %opt = @_; +my $value = $opt{'curr_value'} || $opt{'value'}; +# values is an arrayref of part_fee_usage objects +my %part_fee_usage = map { $_->classnum => $_ } @$value; +my @classes = qsearch('usage_class', { disabled => '' }); +my $money_char = FS::Conf->new->config('money_char') || '$'; +</%init> diff --git a/httemplate/elements/tr-select-from_to.html b/httemplate/elements/tr-select-from_to.html index ad9b40a6b..57b2388b1 100644 --- a/httemplate/elements/tr-select-from_to.html +++ b/httemplate/elements/tr-select-from_to.html @@ -39,7 +39,7 @@ my %hash = ( 'show_month_abbr' => 1, 'start_year' => '1999', - 'end_year' => '2014', + 'end_year' => '2016', @_, ); </%init> diff --git a/httemplate/misc/cust-part_pkg.cgi b/httemplate/misc/cust-part_pkg.cgi index afe8e4249..e129347ec 100644 --- a/httemplate/misc/cust-part_pkg.cgi +++ b/httemplate/misc/cust-part_pkg.cgi @@ -37,7 +37,8 @@ my $date_format = $conf->config('date_format') || '%m/%d/%Y'; my $default_start_date = $conf->exists('order_pkg-no_start_date') ? '' - : $cust_main->next_bill_date; + : $cust_main ? $cust_main->next_bill_date + : ''; #num_billing_pkgs may be slightly better (will allow you to fill in a start # date in the weird edge case where you're using sync_next_bill and diff --git a/httemplate/misc/email-customers.html b/httemplate/misc/email-customers.html index b47f4414f..15926308e 100644 --- a/httemplate/misc/email-customers.html +++ b/httemplate/misc/email-customers.html @@ -103,13 +103,13 @@ Template: <& /elements/tr-td-label.html, 'label' => 'From:' &> <TD><& /elements/input-text.html, 'field' => 'from_name', - 'value' => $conf->config('company_name'), #? + 'value' => $conf->config('company_name', $agent_virt_agentnum), #? 'size' => 20, &> <\ <& /elements/input-text.html, 'field' => 'from_addr', 'type' => 'email', # HTML5, woot - 'value' => $conf->config('invoice_from'), + 'value' => $conf->config('invoice_from', $agent_virt_agentnum), 'size' => 20, &>></TD> @@ -154,7 +154,10 @@ die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Bulk send customer notices'); my $conf = FS::Conf->new; + my $table = $cgi->param('table') or die "'table' required"; +my $agent_virt_agentnum = $cgi->param('agent_virt_agentnum') || ''; + my %search; if ( $cgi->param('search') ) { %search = %{ thaw(decode_base64($cgi->param('search'))) }; diff --git a/httemplate/misc/xmlhttp-calculate_taxes.html b/httemplate/misc/xmlhttp-calculate_taxes.html index ed7bd0173..2bb1f4cce 100644 --- a/httemplate/misc/xmlhttp-calculate_taxes.html +++ b/httemplate/misc/xmlhttp-calculate_taxes.html @@ -62,14 +62,7 @@ if ( $sub eq 'calculate_taxes' ) { my $taxlisthash = {}; foreach my $cust_bill_pkg (values %cust_bill_pkg) { - my $part_pkg = $cust_bill_pkg->part_pkg; - $cust_main->_handle_taxes( $part_pkg, - $taxlisthash, - $cust_bill_pkg, - $cust_bill_pkg->cust_pkg, - $cust_bill_pkg->cust_bill->_date, - $cust_bill_pkg->cust_pkg->pkgpart, - ); + $cust_main->_handle_taxes( $taxlisthash, $cust_bill_pkg ); } my $listref_or_error = $cust_main->calculate_taxes( [ values %cust_bill_pkg ], $taxlisthash, [ values %cust_bill_pkg ]->[0]->cust_bill->_date ); diff --git a/httemplate/misc/xmlhttp-cust_bill_pkg-calculate_taxes.html b/httemplate/misc/xmlhttp-cust_bill_pkg-calculate_taxes.html index c0db3e2c4..4558682bd 100644 --- a/httemplate/misc/xmlhttp-cust_bill_pkg-calculate_taxes.html +++ b/httemplate/misc/xmlhttp-cust_bill_pkg-calculate_taxes.html @@ -62,15 +62,7 @@ if ( $sub eq 'calculate_taxes' ) { push @cust_bill_pkg, $cust_bill_pkg; - my $part_pkg = $cust_bill_pkg->part_pkg; - $cust_main->_handle_taxes( $part_pkg, - $taxlisthash, - $cust_bill_pkg, - $cust_bill_pkg->cust_pkg, - $cust_bill_pkg->cust_bill->_date, - $cust_bill_pkg->cust_pkg->pkgpart, - ); - + $cust_main->_handle_taxes( $taxlisthash, $cust_bill_pkg ); } if ( @cust_bill_pkg ) { @@ -89,7 +81,10 @@ if ( $sub eq 'calculate_taxes' ) { foreach my $taxline ( @$listref_or_error ) { my $amount = $taxline->setup; my $desc = $taxline->desc; - foreach my $location ( @{$taxline->cust_bill_pkg_tax_location}, @{$taxline->cust_bill_pkg_tax_rate_location} ) { + foreach my $location ( + @{$taxline->get('cust_bill_pkg_tax_location')}, + @{$taxline->get('cust_bill_pkg_tax_rate_location')} ) + { my $taxlocnum = $location->locationnum || ''; my $taxratelocnum = $location->taxratelocationnum || ''; $location->cust_bill_pkg_desc($taxline->desc); #ugh @ that kludge diff --git a/httemplate/misc/xmlrpc.cgi b/httemplate/misc/xmlrpc.cgi deleted file mode 100644 index 14bf9ef92..000000000 --- a/httemplate/misc/xmlrpc.cgi +++ /dev/null @@ -1,16 +0,0 @@ -<% $response_xml %>\ -<%init> - -my $request_xml = $cgi->param('POSTDATA'); - -#warn $request_xml; - -my $fsxmlrpc = new FS::XMLRPC; -my ($error, $response_xml) = $fsxmlrpc->serve($request_xml); - -#warn $error; - -http_header('Content-Type' => 'text/xml', - 'Content-Length' => length($response_xml)); - -</%init> diff --git a/httemplate/search/477.html b/httemplate/search/477.html index eed3df946..3e7888c40 100755 --- a/httemplate/search/477.html +++ b/httemplate/search/477.html @@ -49,18 +49,22 @@ <& "477part${part}.html", 'tech_code' => $tech, 'url' => $url, - 'type' => $type + 'type' => $type, + 'date' => $date, &> % if ( $type eq 'xml' ) { </<% 'Part_IA_'. chr(65 + $tech) %>> % } % } -% } else { +% } else { # not part IA % if ( $type eq 'xml' ) { <<% 'Part_'. $part %>> % } % my $url = &{$url_mangler}($part); -<& "477part${part}.html", 'url' => $url &> +<& "477part${part}.html", + 'url' => $url, + 'date' => $date, +&> % if ( $type eq 'xml' ) { </<% 'Part_'. $part %>> % } @@ -80,6 +84,9 @@ my $curuser = $FS::CurrentUser::CurrentUser; die "access denied" unless $curuser->access_right('List packages'); +my $date = $cgi->param('date') ? parse_datetime($cgi->param('date')) + : time; + my $state = uc($cgi->param('state')); $state =~ /^[A-Z]{2}$/ or die "illegal state: $state"; diff --git a/httemplate/search/477partIA.html b/httemplate/search/477partIA.html index 6b4bffd41..aa7381139 100755 --- a/httemplate/search/477partIA.html +++ b/httemplate/search/477partIA.html @@ -84,7 +84,6 @@ my %search_hash; for ( qw(agentnum state) ) { $search_hash{$_} = $cgi->param($_) if $cgi->param($_); } -$search_hash{'status'} = 'active'; $search_hash{'country'} = 'US'; $search_hash{'classnum'} = [ $cgi->param('classnum') ]; @@ -114,6 +113,13 @@ if ( $technology eq 'Symmetric xDSL' or $technology eq 'Other Wireline' ) { # whether to show residential percentages in each cell of the matrix my $percentages = ($technology eq 'Terrestrial Mobile Wireless'); +# as of date +# FCC 477 instructions: "Only count connections that are in service." +# So we count packages that were in active status as of the specified date, +# not over any sort of range. +$search_hash{'active'} = [ $opt{date}, $opt{date} ]; +warn Dumper \%search_hash; + my $query = FS::cust_pkg->search(\%search_hash); my $count_query = $query->{'count_query'}; diff --git a/httemplate/search/477partIIA.html b/httemplate/search/477partIIA.html index 907a176e5..467b19c5f 100755 --- a/httemplate/search/477partIIA.html +++ b/httemplate/search/477partIIA.html @@ -40,25 +40,25 @@ </TABLE> % } #XML/HTML <%init> - my $curuser = $FS::CurrentUser::CurrentUser; die "access denied" unless $curuser->access_right('List packages'); +my %opt = @_; my %search_hash = (); $search_hash{'agentnum'} = $cgi->param('agentnum'); $search_hash{'state'} = $cgi->param('state'); $search_hash{'classnum'} = [ $cgi->param('classnum') ]; -$search_hash{'status'} = 'active'; +$search_hash{'active'} = [ $opt{date}, $opt{date} ]; my @row_option; foreach ($cgi->param('part2a_row_option')) { push @row_option, (/^\d+$/ ? $_ : undef); } -my $is_residential = "AND COALESCE(cust_main.company, '') = ''"; +my $is_residential = " AND COALESCE(cust_main.company, '') = ''"; my $has_report_option = sub { map { defined($row_option[$_]) ? diff --git a/httemplate/search/477partIIB.html b/httemplate/search/477partIIB.html index cb181f4fd..ce1ac03f0 100755 --- a/httemplate/search/477partIIB.html +++ b/httemplate/search/477partIIB.html @@ -46,28 +46,29 @@ my $curuser = $FS::CurrentUser::CurrentUser; die "access denied" unless $curuser->access_right('List packages'); +my %opt = @_; my %search_hash = (); $search_hash{'agentnum'} = $cgi->param('agentnum'); $search_hash{'state'} = $cgi->param('state'); $search_hash{'classnum'} = [ $cgi->param('classnum') ]; -$search_hash{'status'} = 'active'; +$search_hash{'active'} = [ $opt{date}, $opt{date} ]; my @row_option; foreach ($cgi->param('part2b_row_option')) { push @row_option, (/^\d+$/ ? $_ : undef); } -my $is_residential = "AND COALESCE(cust_main.company, '') = ''"; +my $is_residential = " AND COALESCE(cust_main.company, '') = ''"; my $has_report_option = sub { map { defined($row_option[$_]) ? - "AND EXISTS( + " AND EXISTS( SELECT 1 FROM part_pkg_option WHERE part_pkg_option.pkgpart = part_pkg.pkgpart AND optionname = 'report_option_" . $row_option[$_]."' AND optionvalue = '1' - )" : 'AND FALSE' + )" : ' AND FALSE' } @_ }; diff --git a/httemplate/search/477partV.html b/httemplate/search/477partV.html index b2dd9ca95..5f7708140 100755 --- a/httemplate/search/477partV.html +++ b/httemplate/search/477partV.html @@ -33,13 +33,14 @@ my %search_hash = (); my @sql_query = (); my @count_query = (); -for ( qw(agentnum magic state) ) { +for ( qw(agentnum state) ) { $search_hash{$_} = $cgi->param($_) if $cgi->param($_); } $search_hash{'country'} = 'US'; $search_hash{'classnum'} = [ $cgi->param('classnum') ]; $search_hash{report_option} = $cgi->param('part5_report_option') if $cgi->param('part5_report_option'); +$search_hash{'active'} = [ $opt{date}, $opt{date} ]; my $sql_query = FS::cust_pkg->search( { %search_hash, 'fcc_line' => 1, diff --git a/httemplate/search/477partVI_census.html b/httemplate/search/477partVI_census.html index 0dafc6b21..b4f6ddc01 100755 --- a/httemplate/search/477partVI_census.html +++ b/httemplate/search/477partVI_census.html @@ -81,9 +81,11 @@ push @fields, my %search_hash = (); my @sql_query = (); -for ( qw(agentnum magic state) ) { +for ( qw(agentnum state) ) { $search_hash{$_} = $cgi->param($_) if $cgi->param($_); } + +$search_hash{'active'} = [ $opt{date}, $opt{date} ]; $search_hash{'country'} = 'US'; $search_hash{'classnum'} = [ $cgi->param('classnum') ] if grep { $_ eq 'classnum' } $cgi->param; @@ -115,12 +117,11 @@ foreach my $row ( @row_option ) { ($report_option ? ( 'report_option' => $report_option ) : () ), } ); +warn Dumper($sql_query) if $rowcount==1 and $columncount==3; my $extracolumns = "$rowcount AS upload, $columncount AS download, $tech_code as technology_code"; my $percent = "CASE WHEN count(*) > 0 THEN 100-100*cast(count(cust_main.company) as numeric)/cast(count(*) as numeric) ELSE cast(0 as numeric) END AS residential"; $sql_query->{select} = "count(*) AS quantity, $extracolumns, cust_location.censustract, $percent"; - $sql_query->{order_by} =~ /^(.*)(ORDER BY pkgnum)(.*)$/s - or die "couldn't parse order_by"; - $sql_query->{order_by} = "$1 GROUP BY cust_location.censustract $3"; + $sql_query->{order_by} = " GROUP BY cust_location.censustract "; push @sql_query, $sql_query; } $columncount++; diff --git a/httemplate/search/cust_bill_pkg.cgi b/httemplate/search/cust_bill_pkg.cgi index 6b7a5e6e2..440ab150c 100644 --- a/httemplate/search/cust_bill_pkg.cgi +++ b/httemplate/search/cust_bill_pkg.cgi @@ -137,9 +137,9 @@ Filtering parameters: - use_override: Apply "classnum" and "taxclass" filtering based on the override (bundle) pkgpart, rather than always using the true pkgpart. -- nottax: Limit to items that are not taxes (pkgnum > 0). +- nottax: Limit to items that are not taxes (pkgnum > 0 or feepart > 0). -- istax: Limit to items that are taxes (pkgnum == 0). +- istax: Limit to items that are taxes (pkgnum == 0 and feepart = null). - taxnum: Limit to items whose tax definition matches this taxnum. With "nottax" that means items that are subject to that tax; @@ -305,7 +305,8 @@ if ( $cgi->param('custnum') =~ /^(\d+)$/ ) { # we want the package and its definition if available my $join_pkg = ' LEFT JOIN cust_pkg USING (pkgnum) - LEFT JOIN part_pkg USING (pkgpart)'; + LEFT JOIN part_pkg USING (pkgpart) + LEFT JOIN part_fee USING (feepart)'; my $part_pkg = 'part_pkg'; # "Separate sub-packages from parents" @@ -319,12 +320,16 @@ if ( $use_override ) { $part_pkg = 'override'; } push @select, "$part_pkg.pkgpart", "$part_pkg.pkg"; -push @select, "$part_pkg.taxclass" if $conf->exists('enable_taxclasses'); +push @select, "COALESCE($part_pkg.taxclass, part_fee.taxclass) AS taxclass" + if $conf->exists('enable_taxclasses'); # the non-tax case if ( $cgi->param('nottax') ) { - push @where, 'cust_bill_pkg.pkgnum > 0'; + push @select, "part_fee.itemdesc"; + + push @where, + '(cust_bill_pkg.pkgnum > 0 OR cust_bill_pkg.feepart IS NOT NULL)'; my @tax_where; # will go into a subquery my @exempt_where; # will also go into a subquery @@ -335,7 +340,7 @@ if ( $cgi->param('nottax') ) { # N: classnum if ( grep { $_ eq 'classnum' } $cgi->param ) { my @classnums = grep /^\d*$/, $cgi->param('classnum'); - push @where, "COALESCE($part_pkg.classnum, 0) IN ( ". + push @where, "COALESCE(part_fee.classnum, $part_pkg.classnum, 0) IN ( ". join(',', @classnums ). ' )' if @classnums; @@ -360,7 +365,7 @@ if ( $cgi->param('nottax') ) { # effective taxclass, not the real one push @tax_where, 'cust_main_county.taxclass IS NULL' } elsif ( $cgi->param('taxclass') ) { - push @tax_where, "$part_pkg.taxclass IN (" . + push @tax_where, "COALESCE(part_fee.taxclass, $part_pkg.taxclass) IN (" . join(', ', map {dbh->quote($_)} $cgi->param('taxclass') ). ')'; } @@ -681,7 +686,7 @@ if ( $cgi->param('salesnum') =~ /^(\d+)$/ ) { 'paid' => ($cgi->param('paid') ? 1 : 0), 'classnum' => scalar($cgi->param('classnum')) ); - $join_pkg .= " JOIN sales_pkg_class ON ( COALESCE(sales_pkg_class.classnum, 0) = COALESCE( part_pkg.classnum, 0) )"; + $join_pkg .= " JOIN sales_pkg_class ON ( COALESCE(sales_pkg_class.classnum, 0) = COALESCE( part_fee.classnum, part_pkg.classnum, 0) )"; my $extra_sql = $subsearch->{extra_sql}; $extra_sql =~ s/^WHERE//; diff --git a/httemplate/search/cust_bill_pkg_referral.html b/httemplate/search/cust_bill_pkg_referral.html index c4dde32a0..f8e2ea72d 100644 --- a/httemplate/search/cust_bill_pkg_referral.html +++ b/httemplate/search/cust_bill_pkg_referral.html @@ -41,8 +41,11 @@ 'classname', sub { # report_option my $cust_bill_pkg = shift; - my $pkgpart = $cust_bill_pkg->pkgpart_override - || $cust_bill_pkg->cust_pkg->pkgpart; + my $pkgpart = $cust_bill_pkg->pkgpart_override; + unless ( $pkgpart ) { + my $cust_pkg = $cust_bill_pkg->cust_pkg or return ''; + $pkgpart = $cust_pkg->pkgpart; + } if ( !exists($report_classes{$pkgpart}) ) { my $part_pkg = FS::part_pkg->by_key($pkgpart); my %opts = $part_pkg->options; @@ -130,7 +133,9 @@ my $agentnums_sql = my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi); my @where = ( $agentnums_sql, - 'cust_bill_pkg.pkgnum != 0', # exclude taxes + # exclude taxes + '(cust_bill_pkg.pkgnum != 0 OR '. + 'cust_bill_pkg.feepart IS NOT NULL)', "cust_bill._date >= $beginning", "cust_bill._date <= $ending", ); @@ -184,11 +189,13 @@ if ( $cgi->param('classnum') =~ /^(\d+)$/ ) { if ( $use_override ) { push @where, "( - part_pkg.classnum $comparison AND pkgpart_override IS NULL OR - override.classnum $comparison AND pkgpart_override IS NOT NULL + (part_pkg.classnum $comparison AND pkgpart_override IS NULL) OR + (override.classnum $comparison AND pkgpart_override IS NOT NULL) OR + (part_fee.classnum $comparison AND feepart IS NOT NULL) )"; } else { - push @where, "part_pkg.classnum $comparison"; + push @where, + "(part_pkg.classnum $comparison) OR (part_fee.classnum $comparison)"; } } @@ -228,15 +235,19 @@ $join_pkg .= ' LEFT JOIN cust_pkg USING ( pkgnum ) LEFT JOIN part_pkg USING ( pkgpart ) LEFT JOIN part_pkg AS override ON pkgpart_override = override.pkgpart + LEFT JOIN part_fee USING ( feepart ) LEFT JOIN pkg_class ON '; #... if ( $use_override ) { # join to whichever pkgpart is appropriate $join_pkg .= ' ( pkgpart_override IS NULL AND part_pkg.classnum = pkg_class.classnum ) - OR ( pkgpart_override IS NOT NULL AND override.classnum = pkg_class.classnum )'; + OR ( pkgpart_override IS NOT NULL AND override.classnum = pkg_class.classnum ) + OR ( feepart IS NOT NULL AND part_fee.classnum = pkg_class.classnum )'; } else { - $join_pkg .= 'part_pkg.classnum = pkg_class.classnum'; + $join_pkg .= ' + ( part_pkg.classnum = pkg_class.classnum ) + OR ( part_fee.classnum = pkg_class.classnum )'; } my $where = ' WHERE '. join(' AND ', @where); @@ -258,7 +269,7 @@ my $last_pay_sql = "SELECT MAX(_date) FROM cust_bill_pay JOIN cust_bill_pay_pkg USING (billpaynum) WHERE cust_bill_pay_pkg.billpkgnum = cust_bill_pkg.billpkgnum"; -push @select, 'part_pkg.pkg', +push @select, 'COALESCE(part_pkg.pkg, part_fee.itemdesc) AS pkg', 'part_pkg.freq', 'cust_main.custnum', 'cust_main.first', diff --git a/httemplate/search/cust_msg.html b/httemplate/search/cust_msg.html index f71a86607..716addfd6 100644 --- a/httemplate/search/cust_msg.html +++ b/httemplate/search/cust_msg.html @@ -5,7 +5,7 @@ 'count_query' => $count_query, 'header' => [ 'Date', - 'Template', + 'Type', 'Destination', 'Status', '', #error @@ -15,7 +15,9 @@ my $date = $_[0]->_date; $date ? time2str('%Y-%m-%d %T',$_[0]->_date) : '' }, - 'msgname', + sub { + ucfirst($_[0]->msgtype) || $_[0]->msgname + }, sub { join('<BR>', split(/,\s*/, $_[0]->env_to) ) }, @@ -31,9 +33,11 @@ '', '', ], - 'color' => [ ('') x 3, - $statuscolor, - $statuscolor, + 'color' => [ '', + $typecolor, + '', + $statuscolor, + $statuscolor, ], 'html_init' => $html_init, 'really_disable_download' => 1, @@ -51,6 +55,9 @@ my @where; if ( $cgi->param('status') =~ /^(\w+)$/ ) { push @where, "status = '$1'"; } +if ( $cgi->param('msgtype') =~ /^(\w+)$/ ) { + push @where, "msgtype = '$1'"; +} my ($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi, ''); push @where, "(_date >= $beginning AND _date <= $ending)"; @@ -79,16 +86,22 @@ my $sub_popup_link = sub { include('/elements/popup_link_onclick.html', 'action' => $p. 'view/cust_msg.html?' . $custmsgnum, 'actionlabel' => 'Message detail', - 'width' => 600, - 'height' => 500, + 'width' => 680, + 'height' => 550, ); }; my %color = ( 'failed' => 'FF0000', 'sent' => '', + + 'invoice' => '00CC00', + 'receipt' => '0000CC', + 'admin' => 'CC0000', + '' => '000000', ); my $statuscolor = sub { $color{$_[0]->status} }; +my $typecolor = sub { $color{$_[0]->msgtype} }; my $html_init = qq!<FORM ACTION="$p/search/cust_msg.html" METHOD="GET"> <TABLE cellspacing="10">!. @@ -110,6 +123,17 @@ include('/elements/select.html', 'failed' => 'failed', 'sent' => 'sent', }, ) . +'</TD><TD> Type '. +include('/elements/select.html', + 'field' => 'msgtype', + 'curr_value' => $cgi->param('msgtype') || '', + 'options' => [ '', 'invoice', 'receipt', 'admin' ], + 'labels' => { '' => '(any)', + 'invoice' => 'Invoices', + 'receipt' => 'Receipts', + 'admin' => 'Admin notices', + }, +) . '</TD> <TD><INPUT type="submit" value="Search"></TD></TR> </TABLE></FORM><BR> diff --git a/httemplate/search/elements/search-html.html b/httemplate/search/elements/search-html.html index bee33cfe8..10cc95539 100644 --- a/httemplate/search/elements/search-html.html +++ b/httemplate/search/elements/search-html.html @@ -446,7 +446,7 @@ % $cstyle = qq(STYLE="$cstyle") % if $cstyle; - <TD CLASS="<% $class %>" BGCOLOR="<% $bgcolor %>" <% $align %> <% $cstyle %>><% $font %><% $a %><% $s %><% $field %><% $es %><% $a ? '</A>' : '' %><% $font ? '</FONT>' : '' %></TD> + <TD CLASS="<% $class %>" BGCOLOR="<% $bgcolor %>" <% $align %> <% $cstyle %>><% $a %><% $font %><% $s %><% $field %><% $es %><% $font ? '</FONT>' : '' %><% $a ? '</A>' : '' %></TD> % } % diff --git a/httemplate/search/report_477.html b/httemplate/search/report_477.html index b842b1f3f..a5dd70b7c 100755 --- a/httemplate/search/report_477.html +++ b/httemplate/search/report_477.html @@ -29,6 +29,13 @@ 'records' => \@states, &> + <& /elements/tr-input-date-field.html, { + 'label' => 'As of date', + 'name' => 'date', + 'value' => '', + 'format' => '%m/%d/%Y' + } &> + <% include( '/elements/tr-select-pkg_class.html', 'multiple' => 1, 'empty_label' => '(empty class)', diff --git a/httemplate/search/report_tax.cgi b/httemplate/search/report_tax.cgi index 111f22d3d..916d44bce 100755 --- a/httemplate/search/report_tax.cgi +++ b/httemplate/search/report_tax.cgi @@ -274,7 +274,8 @@ if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) { $where .= ' AND cust_main.agentnum = '. $agent->agentnum; } -my $nottax = 'cust_bill_pkg.pkgnum != 0'; +my $nottax = + '(cust_bill_pkg.pkgnum != 0 OR cust_bill_pkg.feepart IS NOT NULL)'; # one query for each column of the report # plus separate queries for the totals row diff --git a/httemplate/search/sales_commission.html b/httemplate/search/sales_commission.html index e74f3792e..57b6cdcd5 100644 --- a/httemplate/search/sales_commission.html +++ b/httemplate/search/sales_commission.html @@ -33,7 +33,12 @@ my $date_format = $conf->config('date_format') || '%m/%d/%Y'; my %query = ( 'table' => 'sales' ); my $count_query = "SELECT COUNT(*) FROM sales"; -my $salesnum; +if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) { + $query{hashref}->{agentnum} = $1; + $count_query .= " WHERE agentnum = $1"; +} + +my $salesnum = ''; if ( $cgi->param('salesnum') =~ /^(\d+)$/ ) { $salesnum = $1; } else { diff --git a/httemplate/search/sqlradius.cgi b/httemplate/search/sqlradius.cgi index c8f7932c5..f7873e72f 100644 --- a/httemplate/search/sqlradius.cgi +++ b/httemplate/search/sqlradius.cgi @@ -4,11 +4,8 @@ % # and finally, display the thing % ### % -% foreach my $part_export ( -% #grep $_->can('usage_sessions'), qsearch( 'part_export' ) -% qsearch( 'part_export', { 'exporttype' => 'sqlradius' } ), -% qsearch( 'part_export', { 'exporttype' => 'sqlradius_withdomain' } ) -% ) { +% foreach my $part_export ( @part_export ) { +% % %user2svc = (); % % my $efields = tie my %efields, 'Tie::IxHash', %fields; @@ -27,10 +24,12 @@ % }, % ); % } -% -% - <% $part_export->exporttype %> to <% $part_export->machine %><BR> + <FONT CLASS="fsinnerbox-title"> + <% $part_export->exportname || $part_export->exporttype |h %> + <% $part_export->machine ? ' to '. $part_export->machine : '' |h %> + </FONT><BR> + <% include( '/elements/table-grid.html' ) %> % my $bgcolor1 = '#eeeeee'; % my $bgcolor2 = '#ffffff'; @@ -150,6 +149,23 @@ if ( $cgi->param('svcnum') =~ /^(\d+)$/ ) { $cgi_svc = qsearchs( 'svc_acct', { 'username' => $1 } ); } +my @part_export = (); +if ( $cgi_svc ) { + my $part_svc = $cgi_svc->cust_svc->part_svc; + @part_export = ( + $part_svc->part_export('sqlradius'), + $part_svc->part_export('sqlradius_withdomain'), + $part_svc->part_export('broadband_sqlradius'), + ); +} else { + @part_export = ( + #grep $_->can('usage_sessions'), qsearch( 'part_export' ) + qsearch( 'part_export', { 'exporttype' => 'sqlradius' } ), + qsearch( 'part_export', { 'exporttype' => 'sqlradius_withdomain' } ), + qsearch( 'part_export', { 'exporttype' => 'broadband_sqlradius' } ), + ); +} + my $ip = ''; if ( $cgi->param('ip') =~ /^((\d+\.){3}\d+)$/ ) { $ip = $1; diff --git a/httemplate/view/cust_main.cgi b/httemplate/view/cust_main.cgi index 391988190..3dfe003a3 100755 --- a/httemplate/view/cust_main.cgi +++ b/httemplate/view/cust_main.cgi @@ -125,9 +125,10 @@ function areyousure(href, message) { % % my $email_link = ($cust_main->invoicing_list_emailonly) && % include('/elements/email-link.html', -% 'table' => 'cust_main', -% 'search_hash' => { 'custnum' => $custnum }, -% 'label' => 'Email a notice to this customer', +% 'table' => 'cust_main', +% 'search_hash' => { 'custnum' => $custnum }, +% 'agent_virt_agentnum' => $cust_main->agentnum, +% 'label' => 'Email a notice to this customer', % ); % if ( $email_link and $br ) { | |
