diff options
Diffstat (limited to 'httemplate')
21 files changed, 271 insertions, 154 deletions
diff --git a/httemplate/edit/cust_pay_pending.html b/httemplate/edit/cust_pay_pending.html index 0056bb925..7d480f319 100644 --- a/httemplate/edit/cust_pay_pending.html +++ b/httemplate/edit/cust_pay_pending.html @@ -4,6 +4,10 @@ <CENTER><FONT SIZE="+1"><B>Are you sure you want to delete this pending payment?</B></FONT></CENTER> +% } elsif (( $action eq 'complete' ) and $authorized) { + + <CENTER><FONT SIZE="+1"><B>Payment was authorized but not captured. Contact <% $cust_pay_pending->processor || 'the payment gateway' %> to establish the final disposition of this transaction.</B></FONT></CENTER> + % } elsif ( $action eq 'complete' ) { <CENTER><FONT SIZE="+1"><B>No response was received from <% $cust_pay_pending->processor || 'the payment gateway' %> for this transaction. Check <% $cust_pay_pending->processor || 'the payment gateway' %>'s reporting and determine if this transaction completed successfully.</B></FONT></CENTER> @@ -97,8 +101,6 @@ % } else { -%# if ( $action eq 'complete' ) { - <INPUT TYPE="hidden" NAME="action" VALUE=""> <TR> @@ -106,18 +108,25 @@ <BUTTON TYPE="button" onClick="document.pendingform.action.value = 'insert_cust_pay'; document.pendingform.submit();"><!--IMG SRC="<%$p%>images/tick.png" ALT=""-->Yes, transaction completed sucessfully.</BUTTON> </TD> -% if ( $action eq 'complete' ) { +% if ( $action eq 'complete' ) { <TD> </TD> +% if ($authorized) { + <TD ALIGN="center"> + <BUTTON TYPE="button" onClick="document.pendingform.action.value = 'reverse'; document.pendingform.submit();"><!--IMG SRC="<%$p%>images/cross.png" ALT=""-->No, transaction was reversed</BUTTON> + </TD> +% } else { <TD ALIGN="center"> <BUTTON TYPE="button" onClick="document.pendingform.action.value = 'decline'; document.pendingform.submit();"><!--IMG SRC="<%$p%>images/cross.png" ALT=""-->No, transaction was declined</BUTTON> </TD> +% } <TD> </TD> <TD ALIGN="center"> <BUTTON TYPE="button" onClick="document.pendingform.action.value = 'delete'; document.pendingform.submit();"><!--IMG SRC="<%$p%>images/cross.png" ALT=""-->No, transaction was not received</BUTTON> </TD> - </TR> % } + </TR> + <TR><TD COLSPAN=5></TD></TR> <TR> @@ -156,6 +165,8 @@ my $cust_pay_pending = }) or die 'unknown paypendingnum'; +my $authorized = ($cust_pay_pending->status eq 'authorized') ? 1 : 0; + my $conf = new FS::Conf; my $money_char = $conf->config('money_char') || '$'; diff --git a/httemplate/edit/process/cust_pay_pending.html b/httemplate/edit/process/cust_pay_pending.html index 1bad6cffe..0ff7d26d0 100644 --- a/httemplate/edit/process/cust_pay_pending.html +++ b/httemplate/edit/process/cust_pay_pending.html @@ -59,6 +59,15 @@ if ( $action eq 'delete' ) { $title = 'Pending payment completed (decline)'; } +} elsif ( $action eq 'reverse' ) { + + $error = $cust_pay_pending->reverse; + if ( $error ) { + $title = 'Error reversing pending payment'; + } else { + $title = 'Pending payment completed (reverse)'; + } + } else { die "unknown action $action"; diff --git a/httemplate/edit/process/part_event.html b/httemplate/edit/process/part_event.html index bac69241c..0293af886 100644 --- a/httemplate/edit/process/part_event.html +++ b/httemplate/edit/process/part_event.html @@ -39,8 +39,8 @@ split(/\0/, $value) }; } elsif ( $info->{'type'} eq 'freq' ) { - $value = '0' if !length($value); - $value .= $params->{$cgi_field.'_units'}; + $value = '0' if !length($value) and !$info->{'allow_blank'}; + $value .= $params->{$cgi_field.'_units'} if length($value); } #warn "value of $cgi_field is $value\n"; diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html index 582dda622..cdb1d733c 100644 --- a/httemplate/elements/menu.html +++ b/httemplate/elements/menu.html @@ -274,7 +274,7 @@ $report_packages{'Suspension summary'} = [ $fsurl.'search/cust_pkg_susp.html', ' $report_packages{'Customer packages with unconfigured services'} = [ $fsurl.'search/cust_pkg.cgi?APKG_pkgnum', 'List packages which have provisionable services' ]; $report_packages{'FCC Form 477'} = [ $fsurl.'search/report_477.html' ] if $conf->exists('part_pkg-show_fcc_options'); -$report_packages{'Contract end dates'} = [ $fsurl.'search/cust_pkg-date.html?date=contract_end', 'Show packages by contract end date' ]; +$report_packages{'Contract end dates'} = [ $fsurl.'search/report_cust_pkg-date.html?date=contract_end', 'Show packages by contract end date' ]; $report_packages{'Advanced package reports'} = [ $fsurl.'search/report_cust_pkg.html', 'by agent, date range, status, package definition' ]; tie my %report_inventory, 'Tie::IxHash', diff --git a/httemplate/elements/select-rt-queue.html b/httemplate/elements/select-rt-queue.html index 4ae8bc942..289336516 100644 --- a/httemplate/elements/select-rt-queue.html +++ b/httemplate/elements/select-rt-queue.html @@ -1,4 +1,4 @@ -<SELECT NAME="<% $opt{'name'} %>"<% $opt{'multiple'} ? ' MULTIPLE' : '' %>> +<SELECT NAME="<% $opt{'name'} || $opt{'field'} %>"<% $opt{'multiple'} ? ' MULTIPLE' : '' %>> % while ( @fields ) { % my $value = shift @fields; % my $label = shift @fields; diff --git a/httemplate/elements/tr-freq.html b/httemplate/elements/tr-freq.html index cb58bf6b5..795684cf7 100644 --- a/httemplate/elements/tr-freq.html +++ b/httemplate/elements/tr-freq.html @@ -15,7 +15,7 @@ <% $freq eq $units ? 'SELECTED' : '' %> ><% $freq{$freq} %> % } - </SELECT> + </SELECT><% $opt{'post_text'} || '' %> </TD> diff --git a/httemplate/elements/tr-select-rt-queue.html b/httemplate/elements/tr-select-rt-queue.html new file mode 100644 index 000000000..ac3689b1c --- /dev/null +++ b/httemplate/elements/tr-select-rt-queue.html @@ -0,0 +1,7 @@ + +<& 'tr-td-label.html', @_ &> +<TD> +<& 'select-rt-queue.html', @_ &> +</TD> +</TR> + diff --git a/httemplate/search/cust_bill_pay_pkg.html b/httemplate/search/cust_bill_pay_pkg.html index 7c231a65d..e2ffd1258 100644 --- a/httemplate/search/cust_bill_pay_pkg.html +++ b/httemplate/search/cust_bill_pay_pkg.html @@ -14,7 +14,7 @@ #payment 'Date', - 'Order Number', + @on_header, 'By', #application @@ -44,7 +44,7 @@ ? cardtype($cust_pay->paymask) : ''; }, sub { time2str('%b %d %Y', shift->get('cust_pay_date') ) }, - sub { shift->cust_bill_pay->cust_pay->order_number }, + @on_field, sub { shift->cust_bill_pay->cust_pay->otaker }, sub { sprintf($money_char.'%.2f', shift->amount ) }, @@ -66,7 +66,7 @@ '', #payinfo/paymask '', #cardtype 'cust_pay_date', - '', #order_number + @on_null, #order_number '', #'otaker', '', #amount '', #line item description @@ -83,7 +83,7 @@ '', '', '', - '', + @on_null, '', '', '', @@ -96,10 +96,9 @@ FS::UI::Web::cust_header() ), ], - 'align' => 'rcrlrrlrlll', -#original value before cardtype & package were added -#why are there 13 cols? -#'rcrrlrlllrrcl'. + 'align' => 'rcrlr'. + $on_align. + 'lrlll'. $post_desc_align. 'rr'. FS::UI::Web::cust_aligns(), @@ -109,7 +108,7 @@ '', '', '', - '', + @on_null, '', '', '', @@ -126,7 +125,7 @@ '', '', '', - '', + @on_null, '', '', '', @@ -148,6 +147,17 @@ die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Financial reports'); +my @on_header = (); +my @on_field = (); +my @on_null = (); +my $on_align = ''; +if ($cgi->param('show_order_number')) { + @on_header = ('Order Number'); + @on_field = (sub { shift->cust_bill_pay->cust_pay->order_number }); + @on_null = (''); + $on_align = 'r'; +} + my $conf = new FS::Conf; my %payby = FS::payby->payby2shortname; diff --git a/httemplate/search/cust_pay.html b/httemplate/search/cust_pay.html index 536ab291f..e466f6afa 100755 --- a/httemplate/search/cust_pay.html +++ b/httemplate/search/cust_pay.html @@ -4,5 +4,4 @@ 'name_singular' => emt('payment'), 'name_verb' => emt('paid'), 'show_card_type' => 1, - 'show_order_number' => 1, &> diff --git a/httemplate/search/cust_pay_pending.html b/httemplate/search/cust_pay_pending.html index 942085c6c..52646265b 100755 --- a/httemplate/search/cust_pay_pending.html +++ b/httemplate/search/cust_pay_pending.html @@ -17,7 +17,7 @@ my %statusaction = ( 'new' => 'delete', 'pending' => 'complete', - #'authorized' => '', + 'authorized' => 'complete', 'captured' => 'capture', #'declined' => '', #wouldn't need to take action on a done state#'done' diff --git a/httemplate/search/cust_pkg-date.html b/httemplate/search/cust_pkg-date.html index 1b9377546..22a67402b 100644 --- a/httemplate/search/cust_pkg-date.html +++ b/httemplate/search/cust_pkg-date.html @@ -1,3 +1,17 @@ +<& elements/search.html, + 'title' => $title, + 'name' => 'packages', + 'query' => $query, + 'count_query' => $count_query, + 'header' => \@header, + 'fields' => \@fields, + 'sort_fields' => [], + 'align' => 'rrrl'. FS::UI::Web::cust_aligns(), + 'color' => \@color, + 'style' => \@style, + 'links' => \@links, + 'cell_style' => [ $date_color_sub ], +&> <%init> my $curuser = $FS::CurrentUser::CurrentUser; die 'access denied' unless $curuser->access_right('List packages'); @@ -18,8 +32,6 @@ my $col = $cgi->param('date'); die "invalid date column" unless $cols{$col}; my $title = 'Packages by ' . lc($cols{$col}) . ' date'; -# second option on the cust_fields_avail list, plus email -my $cust_fields = 'Cust# | Customer | Day phone | Night phone | Mobile phone | Invoicing email(s)'; my @header = ( $cols{$col}, emt('#'), emt('Quan.'), @@ -31,35 +43,47 @@ my @fields = ( sub { time2str('%b %d %Y', $_[0]->$col) }, 'quantity', 'pkg_label', ); -my @sort_fields = ( map '', @fields ); # should only ever sort by $col +my @color = ( map '', @fields ); +my @style = ( map '', @fields ); + +my $pkg_link = sub { + my $self = shift; + my $frag = 'cust_pkg'. $self->pkgnum; + [ "${p}view/cust_main.cgi?custnum=".$self->custnum. + ";show=packages;fragment=$frag#cust_pkg", + 'pkgnum' + ]; +}; + +my @links = ( '', ($pkg_link) x 3 ); -push @header, FS::UI::Web::cust_header($cust_fields); +push @header, FS::UI::Web::cust_header($cgi->param('cust_fields')); push @fields, \&FS::UI::Web::cust_fields; +push @color, FS::UI::Web::cust_colors(); +push @style, FS::UI::Web::cust_styles(); +push @links, FS::UI::Web::cust_links(); + +my $agentnums_sql = $curuser->agentnums_sql('table' => 'cust_main'); +if ( $cgi->param('agentnum') =~ /^(\d+)$/ and $1 ) { + $agentnums_sql .= " AND agentnum = $1"; +} my $query = { + 'select' => join(',', 'cust_pkg.*', FS::UI::Web::cust_sql_fields() ), 'table' => 'cust_pkg', 'addl_from' => FS::UI::Web::join_cust_main('cust_pkg', 'cust_pkg'), 'hashref' => { $col => { op => '!=', value => '' }, 'cancel' => '', }, - 'order_by' => "ORDER BY $col", + 'extra_sql' => ' AND '.$agentnums_sql, + 'order_by' => "ORDER BY $col", }; my $count_query = - "SELECT COUNT(*) FROM cust_pkg WHERE $col IS NOT NULL AND cancel IS NULL"; + "SELECT COUNT(*) FROM cust_pkg JOIN cust_main USING (custnum) ". + "WHERE $col IS NOT NULL AND cancel IS NULL AND $agentnums_sql"; -my $pkg_link = sub { - my $self = shift; - my $frag = 'cust_pkg'. $self->pkgnum; - [ "${p}view/cust_main.cgi?custnum=".$self->custnum. - ";show=packages;fragment=$frag#cust_pkg", - 'pkgnum' - ]; -}; - -my @links = ( '', ($pkg_link) x 3, - FS::UI::Web::cust_links() ); my $date_color_sub = sub { my $self = shift; @@ -76,15 +100,4 @@ my $date_color_sub = sub { }; </%init> -<& elements/search.html, - 'title' => $title, - 'name' => 'packages', - 'query' => $query, - 'count_query' => $count_query, - 'header' => \@header, - 'fields' => \@fields, - 'align' => 'rrrl'. FS::UI::Web::cust_aligns(), - 'links' => \@links, - 'cell_style' => [ $date_color_sub ], -&> diff --git a/httemplate/search/cust_pkg_churn.html b/httemplate/search/cust_pkg_churn.html index 30962c996..4c7e7e8b2 100644 --- a/httemplate/search/cust_pkg_churn.html +++ b/httemplate/search/cust_pkg_churn.html @@ -18,7 +18,7 @@ emt('Susp.'), emt('Changed'), emt('Cancel'), - #emt('Reason'), # hard to do this right + @reason_header, FS::UI::Web::cust_header( $cgi->param('cust_fields') ), @@ -45,6 +45,7 @@ ( map { time_or_blank($_) } qw( setup last_bill bill susp change_date cancel ) ), + @reason_fields, \&FS::UI::Web::cust_fields, ], 'sort_fields' => [ @@ -53,21 +54,25 @@ ('') x 3, # can't use at all # use the plain SQL column names qw( setup last_bill bill susp change_date cancel ), + @reason_blank, # cust_fields can take care of themselves ], 'color' => [ ('') x 15, + @reason_blank, FS::UI::Web::cust_colors(), ], 'style' => [ ('') x 15, + @reason_blank, FS::UI::Web::cust_styles() ], 'size' => [ '', '', '', '', '-1' ], - 'align' => 'rrlcccrrlrrrrrr'. FS::UI::Web::cust_aligns(). 'r', + 'align' => 'rrlcccrrlrrrrrr'.$reason_align. FS::UI::Web::cust_aligns(). 'r', 'links' => [ $link, $link, $link, ('') x 12, + @reason_blank, ( map { $_ ne 'Cust. Status' ? $clink : '' } FS::UI::Web::cust_header( $cgi->param('cust_fields') @@ -184,4 +189,16 @@ sub time_or_blank { }; } +my (@reason_header,@reason_fields,@reason_blank); +my $reason_align = ''; +if ($status eq 'cancel') { + push @reason_header, emt('Cancel Reason'); + push @reason_fields, sub { + my $c = shift; + my $cust_pkg_reason = $c->last_cust_pkg_reason('cancel'); + $cust_pkg_reason ? $cust_pkg_reason->reason->reason : ''; + }; + push @reason_blank, ''; + $reason_align = 'l'; +} </%init> diff --git a/httemplate/search/elements/cust_pay_or_refund.html b/httemplate/search/elements/cust_pay_or_refund.html index 4ed297dac..cbda680ca 100755 --- a/httemplate/search/elements/cust_pay_or_refund.html +++ b/httemplate/search/elements/cust_pay_or_refund.html @@ -91,29 +91,30 @@ my $title = ''; $title = 'Unapplied ' if $unapplied; $title .= "\u$name_singular Search Results"; -my $link = ''; -if ( ( $curuser->access_right('View invoices') #remove in 2.5 (2.7?) - || ($curuser->access_right('View payments') && $table =~ /^cust_pay/) - || ($curuser->access_right('View refunds') && $table eq 'cust_refund') - ) - && ! $opt{'disable_link'} - ) -{ - - my $key; - my $q = ''; - if ( $table eq 'cust_pay_void' ) { - $key = 'paynum'; - $q .= 'void=1;'; - } elsif ( $table eq /^cust_(\w+)$/ ) { - $key = $1.'num'; - } - - if ( $key ) { - $q .= "$key="; - $link = [ "${p}view/$table.html?$q", $key ] - } -} +###NOT USED??? +#my $link = ''; +#if ( ( $curuser->access_right('View invoices') #remove in 2.5 (2.7?) +# || ($curuser->access_right('View payments') && $table =~ /^cust_pay/) +# || ($curuser->access_right('View refunds') && $table eq 'cust_refund') +# ) +# && ! $opt{'disable_link'} +# ) +#{ +# +# my $key; +# my $q = ''; +# if ( $table eq 'cust_pay_void' ) { +# $key = 'paynum'; +# $q .= 'void=1;'; +# } elsif ( $table eq /^cust_(\w+)$/ ) { +# $key = $1.'num'; +# } +# +# if ( $key ) { +# $q .= "$key="; +# $link = [ "${p}view/$table.html?$q", $key ] +# } +#} my $cust_link = sub { my $cust_thing = shift; @@ -166,12 +167,18 @@ if ( $opt{'pre_header'} ) { push @sort_fields, @{ $opt{'pre_fields'} }; } -my $sub_receipt = sub { +my $sub_receipt = $opt{'disable_link'} ? '' : sub { my $obj = shift; my $objnum = $obj->primary_key . '=' . $obj->get($obj->primary_key); + my $table = $obj->table; + my $void = ''; + if ($table eq 'cust_pay_void') { + $table = 'cust_pay'; + $void = ';void=1'; + } include('/elements/popup_link_onclick.html', - 'action' => $p.'view/cust_pay.html?link=popup;'.$objnum, + 'action' => $p.'view/'.$table.'.html?link=popup;'.$objnum.$void, 'actionlabel' => emt('Payment Receipt'), ); }; @@ -211,7 +218,7 @@ push @links, ''; push @fields, sub { time2str('%b %d %Y', shift->_date ) }; push @sort_fields, '_date'; -if ($opt{'show_order_number'}) { +if ($cgi->param('show_order_number')) { push @header, emt('Order Number'); $align .= 'r'; push @links, ''; diff --git a/httemplate/search/elements/report_cust_pay_or_refund.html b/httemplate/search/elements/report_cust_pay_or_refund.html index 730db68e8..806746a23 100644 --- a/httemplate/search/elements/report_cust_pay_or_refund.html +++ b/httemplate/search/elements/report_cust_pay_or_refund.html @@ -151,6 +151,12 @@ Examples: 'value' => 1, &> + <& /elements/tr-checkbox.html, + 'label' => emt('Include order number'), + 'field' => 'show_order_number', + 'value' => 1, + &> + </TABLE> % } diff --git a/httemplate/search/elements/search.html b/httemplate/search/elements/search.html index beb017300..8b85324c9 100644 --- a/httemplate/search/elements/search.html +++ b/httemplate/search/elements/search.html @@ -135,8 +135,11 @@ Example: # sort, link & display properties for fields - 'sort_fields' => [], #optional list of field names or SQL expressions for - # sorts + 'sort_fields' => [], #optional list of field names or SQL expressions for sorts + + 'order_by_sql' => { #to keep complex SQL expressions out of cgi order_by value, + 'fieldname' => 'sql snippet', # maps fields/sort_fields values to sql snippets + } #listref - each item is the empty string, # or a listref of link and method name to append, @@ -406,6 +409,12 @@ $order_by = $cgi->param('order_by') if $cgi->param('order_by'); my $header = [ map { ref($_) ? $_->{'label'} : $_ } @{$opt{header}} ]; my $rows; +my ($order_by_key,$order_by_desc) = ($order_by =~ /^\s*(.*?)(\s+DESC)?\s*$/i); +$opt{'order_by_sql'} ||= {}; +$order_by_desc ||= ''; +$order_by = $opt{'order_by_sql'}{$order_by_key} . $order_by_desc + if $opt{'order_by_sql'}{$order_by_key}; + if ( ref $query ) { my @query; if (ref($query) eq 'HASH') { diff --git a/httemplate/search/report_cust_bill_pay_pkg.html b/httemplate/search/report_cust_bill_pay_pkg.html index 2347bab6d..bdcd1549e 100644 --- a/httemplate/search/report_cust_bill_pay_pkg.html +++ b/httemplate/search/report_cust_bill_pay_pkg.html @@ -41,6 +41,13 @@ field => 'paid', &> + <& /elements/tr-checkbox.html, + 'label' => emt('Display order number'), + 'field' => 'show_order_number', + 'value' => 1, + 'cell_style' => 'font-weight: normal', #for consistency + &> + <!-- <TR> <TD ALIGN="right"><INPUT TYPE="checkbox" NAME="nottax" VALUE="Y" onClick="nottax_changed(this)" onChange="nottax_change(thid)"></TD> diff --git a/httemplate/search/report_cust_pkg-date.html b/httemplate/search/report_cust_pkg-date.html new file mode 100755 index 000000000..ceb9a9c75 --- /dev/null +++ b/httemplate/search/report_cust_pkg-date.html @@ -0,0 +1,38 @@ +<& /elements/header.html, mt($title) &> + +<FORM ACTION="cust_pkg-date.html" METHOD="GET"> +<INPUT TYPE="hidden" NAME="date" VALUE="<% $col %>"> + +<TABLE BGCOLOR="#cccccc" CELLSPACING=0> + + <& /elements/tr-select-agent.html, + 'curr_value' => scalar( $cgi->param('agentnum') ), + 'disable_empty' => 0, + &> + + <& /elements/tr-select-cust-fields.html &> + +</TABLE> + +<BR> +<INPUT TYPE="submit" VALUE="Get Report"> + +</FORM> + +<% include('/elements/footer.html') %> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('List packages'); + +# for the page title +my %cols = ( + 'contract_end' => 'Contract end' +); + +# or let the column be selected here? +my $col = $cgi->param('date'); +die "invalid date column" unless $cols{$col}; +my $title = 'Packages by ' . lc($cols{$col}) . ' date'; + +</%init> diff --git a/httemplate/search/sqlradius_usage.html b/httemplate/search/sqlradius_usage.html index fcf6c100e..561476e0b 100644 --- a/httemplate/search/sqlradius_usage.html +++ b/httemplate/search/sqlradius_usage.html @@ -39,6 +39,7 @@ @svc_fields, @svc_usage, ], + 'order_by_sql' => $order_by_sql, 'links' => [ #( map { $_ ne 'Cust. Status' ? $link_cust : '' } # FS::UI::Web::cust_header() ), $link_cust, @@ -256,4 +257,24 @@ sub bytes_to_gb { $_[0] ? sprintf('%.3f', $_[0] / (1024*1024*1024.0)) : ''; } + +my $conf = new FS::Conf; +my $order_by_sql = { + 'name' => "CASE WHEN cust_main.company IS NOT NULL + AND cust_main.company != '' + THEN CONCAT(cust_main.company,' (',cust_main.last,', ',cust_main.first,')') + ELSE CONCAT(cust_main.last,', ',cust_main.first) + END", + 'display_custnum' => $conf->exists('cust_main-default_agent_custid') + ? "CASE WHEN cust_main.agent_custid IS NOT NULL + AND cust_main.agent_custid != '' + AND cust_main.agent_custid ". regexp_sql. " '^[0-9]+\$' + THEN CAST(cust_main.agent_custid AS BIGINT) + ELSE cust_main.custnum + END" + : "custnum", +}; + +#warn Dumper \%usage_by_username; + </%init> diff --git a/httemplate/search/svc_broadband.cgi b/httemplate/search/svc_broadband.cgi index 8cdf29d1c..0e52d5fb6 100755 --- a/httemplate/search/svc_broadband.cgi +++ b/httemplate/search/svc_broadband.cgi @@ -10,6 +10,7 @@ 'Router', @tower_header, 'IP Address', + @header_pkg, emt('Pkg. Status'), FS::UI::Web::cust_header($cgi->param('cust_fields')), ], @@ -21,6 +22,7 @@ }, @tower_fields, 'ip_addr', + @fields_pkg, sub { $cust_pkg_cache{$_[0]->svcnum} ||= $_[0]->cust_svc->cust_pkg; return '' unless $cust_pkg_cache{$_[0]->svcnum}; @@ -32,20 +34,25 @@ $link, '', #$link_router, (map '', @tower_fields), - $link, + $link, # ip_addr + @blank_pkg, '', # pkg status ( map { $_ ne 'Cust. Status' ? $link_cust : '' } FS::UI::Web::cust_header($cgi->param('cust_fields')) ), ], - 'align' => 'rll'.('r' x @tower_fields).'rr'. + 'align' => 'rll'.('r' x @tower_fields). + 'r'. # ip_addr + $align_pkg. + 'r'. # pkg status FS::UI::Web::cust_aligns(), 'color' => [ '', '', '', (map '', @tower_fields), - '', + '', # ip_addr + @blank_pkg, sub { $cust_pkg_cache{$_[0]->svcnum} ||= $_[0]->cust_svc->cust_pkg; return '' unless $cust_pkg_cache{$_[0]->svcnum}; @@ -59,8 +66,9 @@ '', '', (map '', @tower_fields), - '', - 'b', + '', # ip_addr + @blank_pkg, + 'b', # pkg status FS::UI::Web::cust_styles(), ], @@ -129,4 +137,25 @@ $html_init .= ' | ' . $fsurl . 'search/svc_broadband-map.html?' . $cgi->query_string . '">' . emt('View a map of these services') . '</a>'; +my (@header_pkg,@fields_pkg,@blank_pkg); +my $align_pkg = ''; +#false laziness with search/svc_acct.cgi +$cgi->param('cust_pkg_fields') =~ /^([\w\,]*)$/ or die "bad cust_pkg_fields"; +my @pkg_fields = split(',', $1); +foreach my $pkg_field ( @pkg_fields ) { + ( my $header = ucfirst($pkg_field) ) =~ s/_/ /; #:/ + push @header_pkg, $header; + + #not the most efficient to do it every field, but this is of niche use. so far + push @fields_pkg, sub { my $svc_x = shift; + my $cust_pkg = $svc_x->cust_svc->cust_pkg or return ''; + my $value = $cust_pkg->get($pkg_field);#closures help alot + $value ? time2str('%b %d %Y', $value ) : ''; + }; + + push @blank_pkg, ''; + $align_pkg .= 'c'; +} + + </%init> diff --git a/httemplate/view/cust_main/billing.html b/httemplate/view/cust_main/billing.html index 3d0983e67..7be320131 100644 --- a/httemplate/view/cust_main/billing.html +++ b/httemplate/view/cust_main/billing.html @@ -28,79 +28,12 @@ % # customer base, and compare it to a graph of the overhead for generating this % # information. (and optimize it better, we could get it more from SQL) % if ( $cust_main->num_ncancelled_pkgs < 54 ) { -% my $sth = dbh->prepare(" -% SELECT DISTINCT freq FROM cust_pkg LEFT JOIN part_pkg USING (pkgpart) -% WHERE freq IS NOT NULL AND freq != '0' -% AND ( cancel IS NULL OR cancel = 0 ) -% AND custnum = ? -% ") or die $DBI::errstr; -% -% $sth->execute($cust_main->custnum) or die $sth->errstr; - -% #not really a numeric sort because freqs can actually be all sorts of things -% # but good enough for the 99% cases of ordering monthly quarterly annually -% my @freqs = sort { $a <=> $b } map { $_->[0] } @{ $sth->fetchall_arrayref }; -% -% foreach my $freq (@freqs) { -% my @cust_pkg = qsearch({ -% 'table' => 'cust_pkg', -% 'addl_from' => 'LEFT JOIN part_pkg USING (pkgpart)', -% 'hashref' => { 'custnum' => $cust_main->custnum, }, -% 'extra_sql' => 'AND ( cancel IS NULL OR cancel = 0 ) -% AND freq = '. dbh->quote($freq), -% 'order_by' => 'ORDER BY COALESCE(start_date,0), pkgnum', # to ensure old pkgs come before change_to_pkg -% }) or next; -% -% my $freq_pretty = $cust_pkg[0]->part_pkg->freq_pretty; -% -% my $amount = 0; -% my $skip_pkg = {}; -% foreach my $cust_pkg (@cust_pkg) { -% my $part_pkg = $cust_pkg->part_pkg; -% next if $cust_pkg->susp -% && ! $cust_pkg->option('suspend_bill') -% && ( ! $part_pkg->option('suspend_bill') -% || $cust_pkg->option('no_suspend_bill') -% ); -% -% #pkg change handling -% next if $skip_pkg->{$cust_pkg->pkgnum}; -% if ($cust_pkg->change_to_pkgnum) { -% #if change is on or before next bill date, use new pkg -% next if $cust_pkg->expire <= $cust_pkg->bill; -% #if change is after next bill date, use old (this) pkg -% $skip_pkg->{$cust_pkg->change_to_pkgnum} = 1; -% } -% -% my $pkg_amount = 0; -% -% #add recurring amounts for this package and its billing add-ons -% foreach my $l_part_pkg ( $part_pkg->self_and_bill_linked ) { -% $pkg_amount += $l_part_pkg->base_recur($cust_pkg); -% } -% -% #subtract amounts for any active discounts -% #(there should only be one at the moment, otherwise this makes no sense) -% foreach my $cust_pkg_discount ( $cust_pkg->cust_pkg_discount_active ) { -% my $discount = $cust_pkg_discount->discount; -% #and only one of these for each -% $pkg_amount -= $discount->amount; -% $pkg_amount -= $amount * $discount->percent/100; -% } -% -% $pkg_amount *= ( $cust_pkg->quantity || 1 ); -% -% $amount += $pkg_amount; -% -% } - +% foreach my $freq_info ($cust_main->display_recurring) { <TR> - <TD ALIGN="right"><% emt( ucfirst($freq_pretty). ' recurring' ) %></TD> - <TD BGCOLOR="#ffffff"><% $money_char. sprintf('%.2f', $amount) %></TD> - </TD> + <TD ALIGN="right"><% emt( ucfirst($freq_info->{'freq_pretty'}). ' recurring' ) %></TD> + <TD BGCOLOR="#ffffff"><% $money_char. sprintf('%.2f', $freq_info->{'amount'}) %></TD> </TR> % } - % } % if ( $conf->exists('cust_main-select-prorate_day') ) { diff --git a/httemplate/view/cust_main/payment_history/pending_payment.html b/httemplate/view/cust_main/payment_history/pending_payment.html index 31149231b..cf7ef7c08 100644 --- a/httemplate/view/cust_main/payment_history/pending_payment.html +++ b/httemplate/view/cust_main/payment_history/pending_payment.html @@ -12,6 +12,7 @@ my %statusaction = ( 'new' => 'delete', 'thirdparty' => 'delete', 'pending' => 'complete', + 'authorized' => 'complete', 'captured' => 'capture', ); |