credit limit for CDR prerating, RT#27267
[freeside.git] / httemplate / search / cust_main_credit_limit.html
1 <& elements/search.html,
2      'title'         => 'Credit limit incidents',
3      'name_singular' => 'incident',
4      'query'         => { table     => 'cust_main_credit_limit',
5                           hashref   => \%hash,
6                           extra_sql => " AND $dates_sql ",
7                           order_by  => 'ORDER BY _date ASC',
8                         },
9      'count_query'   => "SELECT COUNT(*) FROM cust_main_credit_limit",
10      'header'        => [ 'Date',
11
12                           #XXX should use cust_fields etc.
13                           '#',
14                           'Customer',
15
16                           'Amount',
17                           'Limit',
18                         ],
19      'fields'        => [ sub { time2str($date_format, shift->_date); },
20
21                           #XXX should use cust_fields etc.
22                           sub { shift->cust_main->display_custnum },
23                           sub { shift->cust_main->name },
24
25                           sub { $money_char. shift->amount },
26                           sub { $money_char. shift->credit_limit },
27                         ],
28
29      'links'         => [ '',
30
31                           #XXX should use cust_fields etc.
32                           $cust_link,
33                           $cust_link,
34
35                           '',
36                           '',
37                         ],
38 &>
39 <%init>
40
41 die "access denied"
42   unless $FS::CurrentUser::CurrentUser->access_right('List rating data');
43
44 my $conf = new FS::Conf;
45
46 my $date_format = $conf->config('date_format') || '%m/%d/%Y';
47
48 my $money_char = $conf->config('money_char') || '$';
49
50 my $cust_link = [ "${p}view/cust_main.cgi?", 'custnum' ];
51
52 my ($begin, $end) = FS::UI::Web::parse_beginning_ending($cgi);
53 my $dates_sql = "_date >= $begin AND _date < $end";
54
55 my $count_query= "SELECT COUNT(*) FROM cust_main_credit_limit WHERE $dates_sql";
56
57 my %hash = ();
58 if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
59   $hash{custnum} = $1;
60   $count_query .= " AND custnum = $1";
61 }
62
63 </%init>