Merge branch 'master' of ssh://git.freeside.biz/home/git/freeside
[freeside.git] / httemplate / misc / xmlhttp-cust_main-discount_terms.cgi
1 % if ( $sub eq 'discount_terms' ) {
2
3 %   my $return = [];
4 %   my $custnum = $cgi->param('arg');
5 %   if ( $custnum =~ /^\d+$/ ) {
6 %     my $cust_main = '';
7 %     $cust_main = qsearchs({
8 %       'table'   => 'cust_main',
9 %       'hashref' => { 'custnum' => $custnum },
10 %       'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
11 %     });
12 %     
13 %     if ($cust_main) {
14 %       $return = [ map [ $_, sprintf("%d months", $_) ], 
15 %         $cust_main->discount_terms ];
16 %     }
17 %   }
18 %
19 <% encode_json($return) %>\
20 % } 
21 <%init>
22
23 my $conf = new FS::Conf;
24
25 my $sub = $cgi->param('sub');
26
27 </%init>