From 86d3bab91d8baadcbe33e5bbceeb607990efa1eb Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Sun, 16 Feb 2014 17:23:51 -0800 Subject: credit limit for CDR prerating, RT#27267 --- httemplate/search/cust_main_credit_limit.html | 63 ++++++++++++++++++++++ .../search/report_cust_main_credit_limit.html | 24 +++++++++ httemplate/view/cust_main/billing.html | 3 ++ 3 files changed, 90 insertions(+) create mode 100644 httemplate/search/cust_main_credit_limit.html create mode 100644 httemplate/search/report_cust_main_credit_limit.html (limited to 'httemplate') diff --git a/httemplate/search/cust_main_credit_limit.html b/httemplate/search/cust_main_credit_limit.html new file mode 100644 index 000000000..b2a0c9bc4 --- /dev/null +++ b/httemplate/search/cust_main_credit_limit.html @@ -0,0 +1,63 @@ +<& elements/search.html, + 'title' => 'Credit limit incidents', + 'name_singular' => 'incident', + 'query' => { table => 'cust_main_credit_limit', + hashref => \%hash, + extra_sql => " AND $dates_sql ", + order_by => 'ORDER BY _date ASC', + }, + 'count_query' => "SELECT COUNT(*) FROM cust_main_credit_limit", + 'header' => [ 'Date', + + #XXX should use cust_fields etc. + '#', + 'Customer', + + 'Amount', + 'Limit', + ], + 'fields' => [ sub { time2str($date_format, shift->_date); }, + + #XXX should use cust_fields etc. + sub { shift->cust_main->display_custnum }, + sub { shift->cust_main->name }, + + sub { $money_char. shift->amount }, + sub { $money_char. shift->credit_limit }, + ], + + 'links' => [ '', + + #XXX should use cust_fields etc. + $cust_link, + $cust_link, + + '', + '', + ], +&> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('List rating data'); + +my $conf = new FS::Conf; + +my $date_format = $conf->config('date_format') || '%m/%d/%Y'; + +my $money_char = $conf->config('money_char') || '$'; + +my $cust_link = [ "${p}view/cust_main.cgi?", 'custnum' ]; + +my ($begin, $end) = FS::UI::Web::parse_beginning_ending($cgi); +my $dates_sql = "_date >= $begin AND _date < $end"; + +my $count_query= "SELECT COUNT(*) FROM cust_main_credit_limit WHERE $dates_sql"; + +my %hash = (); +if ( $cgi->param('custnum') =~ /^(\d+)$/ ) { + $hash{custnum} = $1; + $count_query .= " AND custnum = $1"; +} + + diff --git a/httemplate/search/report_cust_main_credit_limit.html b/httemplate/search/report_cust_main_credit_limit.html new file mode 100644 index 000000000..8503fb396 --- /dev/null +++ b/httemplate/search/report_cust_main_credit_limit.html @@ -0,0 +1,24 @@ +<& /elements/header.html, 'Credit limit incidents' &> + +
+ + + +<& /elements/tr-search-cust_main.html, 'label' => 'Customer' &> + + + +<& /elements/tr-input-beginning_ending.html &> + +
(leave blank for all customers)
+ +
+ + +<& /elements/footer.html &> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('List rating data'); + + diff --git a/httemplate/view/cust_main/billing.html b/httemplate/view/cust_main/billing.html index 382fdacf5..2c4b3fb2d 100644 --- a/httemplate/view/cust_main/billing.html +++ b/httemplate/view/cust_main/billing.html @@ -273,6 +273,9 @@ ? "Default ($money_char". sprintf("%.2f", $default_credit_limit). ")" : emt('Unlimited') %> +% if ( $cust_main->num_cust_main_credit_limit ) { + (incidents) +% } -- cgit v1.2.1