diff options
Diffstat (limited to 'httemplate/search')
-rw-r--r-- | httemplate/search/cust_bill_pay_pkg.html | 30 | ||||
-rwxr-xr-x | httemplate/search/cust_pay.html | 1 | ||||
-rwxr-xr-x | httemplate/search/cust_pay_pending.html | 2 | ||||
-rw-r--r-- | httemplate/search/cust_pkg-date.html | 69 | ||||
-rw-r--r-- | httemplate/search/cust_pkg_churn.html | 21 | ||||
-rwxr-xr-x | httemplate/search/elements/cust_pay_or_refund.html | 59 | ||||
-rw-r--r-- | httemplate/search/elements/report_cust_pay_or_refund.html | 6 | ||||
-rw-r--r-- | httemplate/search/elements/search.html | 13 | ||||
-rw-r--r-- | httemplate/search/report_cust_bill_pay_pkg.html | 7 | ||||
-rwxr-xr-x | httemplate/search/report_cust_pkg-date.html | 38 | ||||
-rw-r--r-- | httemplate/search/sqlradius_usage.html | 21 | ||||
-rwxr-xr-x | httemplate/search/svc_broadband.cgi | 39 |
12 files changed, 231 insertions, 75 deletions
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> |