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